diff --git a/crates/ui-egui/src/scenario.rs b/crates/ui-egui/src/scenario.rs index 4d518bc2..4afef865 100644 --- a/crates/ui-egui/src/scenario.rs +++ b/crates/ui-egui/src/scenario.rs @@ -446,6 +446,21 @@ pub fn check(h: &mut Harness, e: &Value) -> Result<(), String> { return Err(format!("named views: got {n}, want {v}")); } } + "bbox" => { + // {body, min?: [x|null, y|null, z|null], max?: […]}: where a body is (±1e-3 mm). + let name = v["body"].as_str().unwrap_or_default(); + // Where it is in the assembly (measured as placed). + let m = h.call("engine.execute", json!({"command": "MeasureCommand", "params": {"bodies": [name]}}))["result"].clone(); + let b = m["bodies"].as_array().and_then(|a| a.first()).cloned().ok_or_else(|| format!("no body {name}: {m}"))?; + for side in ["min", "max"] { + for (i, want) in v[side].as_array().into_iter().flatten().enumerate() { + let (Some(w), Some(g)) = (want.as_f64(), b["bbox"][side].get(i).and_then(Value::as_f64)) else { continue }; + if (w - g).abs() > 1e-3 { + return Err(format!("{name} bbox {side}[{i}]: got {g}, want {w}")); + } + } + } + } "home" => { if ui["home"] != *v { return Err(format!("start page open: got {}, want {v}", ui["home"])); diff --git a/crates/ui-egui/tests/scenarios/s07_components_joint_drive.json b/crates/ui-egui/tests/scenarios/s07_components_joint_drive.json index 1d7e8e13..10c1970f 100644 --- a/crates/ui-egui/tests/scenarios/s07_components_joint_drive.json +++ b/crates/ui-egui/tests/scenarios/s07_components_joint_drive.json @@ -187,16 +187,26 @@ } } }, + { + "expect": { + "bbox": { + "body": "Body2", + "min": [ + null, + null, + 10 + ], + "max": [ + null, + null, + 20 + ] + } + } + }, { "start": "FusionMoveJointsCommand" }, - { - "widget": "0 deg" - }, - { - "key": "A", - "cmd": true - }, { "text": "90" }, diff --git a/crates/ui-egui/tests/scenarios/s20_section_with_joint_drive.json b/crates/ui-egui/tests/scenarios/s20_section_with_joint_drive.json index 4d4bdea1..6d8dff91 100644 --- a/crates/ui-egui/tests/scenarios/s20_section_with_joint_drive.json +++ b/crates/ui-egui/tests/scenarios/s20_section_with_joint_drive.json @@ -192,9 +192,6 @@ "plane": "XZ" } }, - { - "debug": 1 - }, { "key": "Enter" }, @@ -210,13 +207,6 @@ { "start": "FusionMoveJointsCommand" }, - { - "widget": "0 deg" - }, - { - "key": "A", - "cmd": true - }, { "text": "90" },