only rust changes reset scene (#6060)
Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
@ -1,6 +1,8 @@
|
||||
//! Cache testing framework.
|
||||
|
||||
use kcl_lib::{bust_cache, ExecError, ExecOutcome};
|
||||
use kcmc::{each_cmd as mcmd, ModelingCmd};
|
||||
use kittycad_modeling_cmds as kcmc;
|
||||
|
||||
#[derive(Debug)]
|
||||
struct Variation<'a> {
|
||||
@ -253,3 +255,71 @@ extrude(sketch001, length = 4)
|
||||
second.artifact_graph.len()
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn kcl_test_cache_empty_file_pop_cache_empty_file_planes_work() {
|
||||
// Get the current working directory.
|
||||
let code = "";
|
||||
|
||||
let ctx = kcl_lib::ExecutorContext::new_with_default_client(Default::default())
|
||||
.await
|
||||
.unwrap();
|
||||
let program = kcl_lib::Program::parse_no_errs(code).unwrap();
|
||||
let outcome = ctx.run_with_caching(program).await.unwrap();
|
||||
|
||||
// Ensure nothing is left in the batch
|
||||
assert!(ctx.engine.batch().read().await.is_empty());
|
||||
assert!(ctx.engine.batch_end().read().await.is_empty());
|
||||
|
||||
// Ensure the planes work, and we can show or hide them.
|
||||
// Hide/show the grid.
|
||||
let default_planes = ctx.engine.get_default_planes().read().await.clone().unwrap();
|
||||
|
||||
// Assure the outcome is the same.
|
||||
assert_eq!(outcome.default_planes, Some(default_planes.clone()));
|
||||
|
||||
ctx.engine
|
||||
.send_modeling_cmd(
|
||||
uuid::Uuid::new_v4(),
|
||||
Default::default(),
|
||||
&ModelingCmd::from(mcmd::ObjectVisible {
|
||||
hidden: false,
|
||||
object_id: default_planes.xy,
|
||||
}),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// Now simulate an engine pause/network disconnect.
|
||||
// Raw dog clear the scene entirely.
|
||||
ctx.engine
|
||||
.send_modeling_cmd(
|
||||
uuid::Uuid::new_v4(),
|
||||
Default::default(),
|
||||
&ModelingCmd::from(mcmd::SceneClearAll {}),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// Bust the cache and reset the scene.
|
||||
let outcome = ctx.bust_cache_and_reset_scene().await.unwrap();
|
||||
// Get the default planes.
|
||||
let default_planes = ctx.engine.get_default_planes().read().await.clone().unwrap();
|
||||
|
||||
assert_eq!(outcome.default_planes, Some(default_planes.clone()));
|
||||
|
||||
// Ensure we can show a plane.
|
||||
ctx.engine
|
||||
.send_modeling_cmd(
|
||||
uuid::Uuid::new_v4(),
|
||||
Default::default(),
|
||||
&ModelingCmd::from(mcmd::ObjectVisible {
|
||||
hidden: false,
|
||||
object_id: default_planes.xz,
|
||||
}),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
ctx.close().await;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user