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

Function test_arrow_key_navigation

src/lib.rs:2785–2825  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2783
2784 #[test]
2785 fn test_arrow_key_navigation() {
2786 let mut ply = Ply::<()>::new_headless(Dimensions::new(800.0, 600.0));
2787 use engine::ArrowDirection;
2788
2789 let id_a = Id::from("a").id;
2790 let id_b = Id::from("b").id;
2791
2792 // Frame 1: create two elements with arrow overrides
2793 {
2794 let mut ui = ply.begin();
2795 ui.element()
2796 .id("a")
2797 .width(fixed!(100.0))
2798 .height(fixed!(50.0))
2799 .accessibility(|a| a.button("A").focus_right("b"))
2800 .empty();
2801 ui.element()
2802 .id("b")
2803 .width(fixed!(100.0))
2804 .height(fixed!(50.0))
2805 .accessibility(|a| a.button("B").focus_left("a"))
2806 .empty();
2807 ui.eval();
2808 }
2809
2810 // Focus A first
2811 ply.context.set_focus(id_a);
2812 assert_eq!(ply.context.focused_element_id, id_a);
2813
2814 // Arrow right → B
2815 ply.context.arrow_focus(ArrowDirection::Right);
2816 assert_eq!(ply.context.focused_element_id, id_b);
2817
2818 // Arrow left → A
2819 ply.context.arrow_focus(ArrowDirection::Left);
2820 assert_eq!(ply.context.focused_element_id, id_a);
2821
2822 // Arrow up → no override, stays on A
2823 ply.context.arrow_focus(ArrowDirection::Up);
2824 assert_eq!(ply.context.focused_element_id, id_a);
2825 }
2826
2827 #[test]
2828 fn test_focused_query() {

Callers

nothing calls this directly

Calls 13

beginMethod · 0.80
accessibilityMethod · 0.80
heightMethod · 0.80
idMethod · 0.80
elementMethod · 0.80
focus_rightMethod · 0.80
buttonMethod · 0.80
focus_leftMethod · 0.80
evalMethod · 0.80
arrow_focusMethod · 0.80
emptyMethod · 0.45
widthMethod · 0.45

Tested by

no test coverage detected