MCPcopy Create free account
hub / github.com/TheRedDeveloper/ply-engine / test_focused_query

Function test_focused_query

src/lib.rs:2828–2860  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2826
2827 #[test]
2828 fn test_focused_query() {
2829 let mut ply = Ply::<()>::new_headless(Dimensions::new(800.0, 600.0));
2830
2831 let id_a = Id::from("a").id;
2832
2833 // Frame 1: layout + set focus
2834 {
2835 let mut ui = ply.begin();
2836 ui.element()
2837 .id("a")
2838 .width(fixed!(100.0))
2839 .height(fixed!(50.0))
2840 .accessibility(|a| a.button("A"))
2841 .empty();
2842 ui.eval();
2843 }
2844
2845 ply.context.set_focus(id_a);
2846
2847 // Frame 2: check focused() during layout
2848 {
2849 let mut ui = ply.begin();
2850 ui.element()
2851 .id("a")
2852 .width(fixed!(100.0))
2853 .height(fixed!(50.0))
2854 .accessibility(|a| a.button("A"))
2855 .children(|ui| {
2856 assert!(ui.focused(), "element should report as focused");
2857 });
2858 ui.eval();
2859 }
2860 }
2861
2862 #[test]
2863 fn test_on_focus_callback_fires_on_tab() {

Callers

nothing calls this directly

Calls 11

beginMethod · 0.80
accessibilityMethod · 0.80
heightMethod · 0.80
idMethod · 0.80
elementMethod · 0.80
buttonMethod · 0.80
evalMethod · 0.80
childrenMethod · 0.80
emptyMethod · 0.45
widthMethod · 0.45
set_focusMethod · 0.45

Tested by

no test coverage detected