Coalesce resize layout diagnostics
This commit is contained in:
1 parent
480f0bc99f
commit
82fa6c1123
7 files changed
+316
-28
No files matched your search
@@ -21,6 +21,53 @@ use std::time::Instant;
|
||||
|
||||
const OUTPUT: (f32, f32) = (1920.0, 1200.0);
|
||||
|
||||
#[cfg(feature = "layout-diagnostics")]
|
||||
#[test]
|
||||
fn a_selected_widget_retains_its_layout_events() {
|
||||
use iris::core::layout_diagnostics::{self as diagnostics, TraceEvent};
|
||||
|
||||
diagnostics::clear_traced_widgets();
|
||||
let _ = diagnostics::take();
|
||||
let mut harness = Harness::new((400, 200));
|
||||
let leaf = rect(Color::RED).add(&mut harness.rsc);
|
||||
let other = rect(Color::BLUE).add(&mut harness.rsc);
|
||||
let root = (leaf, other).span(Dir::RIGHT).add(&mut harness.rsc);
|
||||
harness.set_root(root);
|
||||
diagnostics::trace_widget(leaf.id());
|
||||
let _ = diagnostics::take();
|
||||
|
||||
let _ = harness.rsc.widgets_mut().get_dyn_mut(root.id());
|
||||
let _ = harness.rsc.widgets_mut().get_dyn_mut(leaf.id());
|
||||
harness.frame();
|
||||
|
||||
let report = diagnostics::take();
|
||||
assert!(
|
||||
report
|
||||
.traces()
|
||||
.iter()
|
||||
.any(|event| matches!(event, TraceEvent::Placed { id, .. } if *id == leaf.id()))
|
||||
);
|
||||
assert!(
|
||||
report
|
||||
.traces()
|
||||
.iter()
|
||||
.any(|event| matches!(event, TraceEvent::DrawRequest { id, .. } if *id == leaf.id()))
|
||||
);
|
||||
assert!(
|
||||
report
|
||||
.traces()
|
||||
.iter()
|
||||
.any(|event| matches!(event, TraceEvent::SizeRead { id, .. } if *id == leaf.id()))
|
||||
);
|
||||
assert!(
|
||||
report
|
||||
.traces()
|
||||
.iter()
|
||||
.any(|event| matches!(event, TraceEvent::SizeReported { id, .. } if *id == leaf.id()))
|
||||
);
|
||||
diagnostics::clear_traced_widgets();
|
||||
}
|
||||
|
||||
fn env<T: std::str::FromStr>(name: &str, fallback: T) -> T {
|
||||
std::env::var(name)
|
||||
.ok()
|
||||
|
||||
Reference in new issue
Block a user