@@ -38,10 +38,9 @@ fn pointer_event() {
3838 let button = NewWidget :: new ( Button :: with_text ( "button" ) . record ( ) ) . with_tag ( button_tag) ;
3939
4040 let mut harness = TestHarness :: create ( test_property_set ( ) , button) ;
41- let button_id = harness. get_widget ( button_tag) . id ( ) ;
4241
4342 harness. flush_records_of ( button_tag) ;
44- harness. mouse_move_to ( button_id ) ;
43+ harness. mouse_move_to ( button_tag ) ;
4544
4645 let records = harness. take_records_of ( button_tag) ;
4746 assert_any ( records, |r| {
@@ -61,10 +60,9 @@ fn pointer_event_bubbling() {
6160 NewWidget :: new ( ModularWidget :: new_parent ( parent) . record ( ) ) . with_tag ( grandparent_tag) ;
6261
6362 let mut harness = TestHarness :: create ( test_property_set ( ) , grandparent) ;
64- let button_id = harness. get_widget ( button_tag) . id ( ) ;
6563
6664 harness. flush_records_of ( button_tag) ;
67- harness. mouse_click_on ( button_id ) ;
65+ harness. mouse_click_on ( button_tag ) ;
6866
6967 fn is_pointer_down ( record : Record ) -> bool {
7068 matches ! ( record, Record :: PointerEvent ( PointerEvent :: Down { .. } ) )
@@ -86,7 +84,7 @@ fn pointer_capture_and_cancel() {
8684
8785 let target_id = harness. get_widget ( target_tag) . id ( ) ;
8886
89- harness. mouse_move_to ( target_id ) ;
87+ harness. mouse_move_to ( target_tag ) ;
9088 harness. mouse_button_press ( PointerButton :: Primary ) ;
9189 assert_eq ! ( harness. pointer_capture_target_id( ) , Some ( target_id) ) ;
9290
@@ -109,7 +107,7 @@ fn synthetic_cancel() {
109107
110108 let target_id = harness. get_widget ( target_tag) . id ( ) ;
111109
112- harness. mouse_move_to ( target_id ) ;
110+ harness. mouse_move_to ( target_tag ) ;
113111 harness. mouse_button_press ( PointerButton :: Primary ) ;
114112 assert_eq ! ( harness. pointer_capture_target_id( ) , Some ( target_id) ) ;
115113
@@ -143,15 +141,14 @@ fn pointer_capture_suppresses_neighbors() {
143141 harness. flush_records_of ( other_tag) ;
144142
145143 let target_id = harness. get_widget ( target_tag) . id ( ) ;
146- let other_id = harness. get_widget ( other_tag) . id ( ) ;
147144
148- harness. mouse_move_to ( target_id ) ;
145+ harness. mouse_move_to ( target_tag ) ;
149146 harness. mouse_button_press ( PointerButton :: Primary ) ;
150147
151148 assert_eq ! ( harness. pointer_capture_target_id( ) , Some ( target_id) ) ;
152149
153150 // As long as 'target' is captured, 'other' doesn't get pointer events, even when the cursor is on it.
154- harness. mouse_move_to ( other_id ) ;
151+ harness. mouse_move_to ( other_tag ) ;
155152 assert_matches ! ( harness. take_records_of( other_tag) [ ..] , [ ] ) ;
156153
157154 // 'other' is not considered hovered either.
@@ -191,8 +188,7 @@ fn try_capture_pointer_on_text_event() {
191188 . with_auto_id ( ) ;
192189
193190 let mut harness = TestHarness :: create ( test_property_set ( ) , widget) ;
194- let id = harness. root_id ( ) ;
195- harness. focus_on ( Some ( id) ) ;
191+ harness. focus_on ( harness. root_tag ( ) ) ;
196192
197193 assert_debug_panics ! (
198194 harness. keyboard_type_chars( "a" ) ,
@@ -211,7 +207,7 @@ fn pointer_cancel_on_window_blur() {
211207
212208 let target_id = harness. get_widget ( target_tag) . id ( ) ;
213209
214- harness. mouse_move_to ( target_id ) ;
210+ harness. mouse_move_to ( target_tag ) ;
215211 harness. mouse_button_press ( PointerButton :: Primary ) ;
216212 assert_eq ! ( harness. pointer_capture_target_id( ) , Some ( target_id) ) ;
217213 harness. flush_records_of ( target_tag) ;
@@ -241,13 +237,11 @@ fn click_anchors_focus() {
241237
242238 let mut harness = TestHarness :: create ( test_property_set ( ) , parent) ;
243239
244- let child_3_id = harness. get_widget ( child_3) . id ( ) ;
245240 let child_4_id = harness. get_widget ( child_4) . id ( ) ;
246- let other_id = harness. get_widget ( other) . id ( ) ;
247241
248242 // Clicking a disabled button doesn't focus it.
249243 harness. set_disabled ( child_3, true ) ;
250- harness. mouse_click_on ( child_3_id ) ;
244+ harness. mouse_click_on ( child_3 ) ;
251245 assert_eq ! ( harness. focused_widget_id( ) , None ) ;
252246
253247 // But the next tab event focuses its neighbor.
@@ -259,7 +253,7 @@ fn click_anchors_focus() {
259253 // is resolved.
260254
261255 // Clicking another non-focusable widget clears focus.
262- harness. mouse_move_to_unchecked ( other_id ) ;
256+ harness. mouse_move_to_unchecked ( other ) ;
263257 harness. mouse_button_press ( PointerButton :: Primary ) ;
264258 harness. mouse_button_release ( PointerButton :: Primary ) ;
265259 assert_eq ! ( harness. focused_widget_id( ) , None ) ;
@@ -433,7 +427,7 @@ fn multi_pointers_capture() {
433427
434428 // Move mouse to button 1, mouse press
435429 // Check mouse is captured, button 1 is active
436- harness. mouse_move_to ( button_1_id ) ;
430+ harness. mouse_move_to ( button_1_tag ) ;
437431 harness. mouse_button_press ( PointerButton :: Primary ) ;
438432
439433 assert_captured_by ( & harness, PointerId :: PRIMARY , button_1_id) ;
@@ -484,15 +478,14 @@ fn text_event() {
484478 let target = NewWidget :: new ( TextArea :: new_editable ( "" ) . record ( ) ) . with_tag ( target_tag) ;
485479
486480 let mut harness = TestHarness :: create ( test_property_set ( ) , target) ;
487- let target_id = harness. get_widget ( target_tag) . id ( ) ;
488481 harness. flush_records_of ( target_tag) ;
489482
490483 // The widget isn't focused, it doesn't get text events.
491484 harness. keyboard_type_chars ( "A" ) ;
492485 assert_matches ! ( harness. take_records_of( target_tag) [ ..] , [ ] ) ;
493486
494487 // We focus on the widget, now it gets text events.
495- harness. focus_on ( Some ( target_id ) ) ;
488+ harness. focus_on ( target_tag ) ;
496489 harness. keyboard_type_chars ( "A" ) ;
497490 let records = harness. take_records_of ( target_tag) ;
498491 assert_any ( records, |r| matches ! ( r, Record :: TextEvent ( _) ) ) ;
@@ -511,9 +504,8 @@ fn text_event_bubbling() {
511504 NewWidget :: new ( ModularWidget :: new_parent ( parent) . record ( ) ) . with_tag ( grandparent_tag) ;
512505
513506 let mut harness = TestHarness :: create ( test_property_set ( ) , grandparent) ;
514- let target_id = harness. get_widget ( target_tag) . id ( ) ;
515507
516- harness. focus_on ( Some ( target_id ) ) ;
508+ harness. focus_on ( target_tag ) ;
517509 harness. process_text_event ( TextEvent :: key_down ( Key :: Character ( "A" . into ( ) ) ) ) ;
518510
519511 fn is_keyboard_event ( record : Record ) -> bool {
@@ -538,16 +530,14 @@ fn text_event_fallback() {
538530 . with_auto_id ( ) ;
539531
540532 let mut harness = TestHarness :: create ( test_property_set ( ) , parent) ;
541- let target_id = harness. get_widget ( target_tag) . id ( ) ;
542- let other_id = harness. get_widget ( other_tag) . id ( ) ;
543533 harness. flush_records_of ( target_tag) ;
544- harness. set_focus_fallback ( Some ( target_id ) ) ;
534+ harness. set_focus_fallback ( target_tag ) ;
545535
546- harness. focus_on ( Some ( other_id ) ) ;
536+ harness. focus_on ( other_tag ) ;
547537 assert_matches ! ( harness. take_records_of( target_tag) [ ..] , [ ] ) ;
548538
549539 // If a widget is set as focus fallback, that widget gets text events when no widget is focused.
550- harness. focus_on ( None ) ;
540+ harness. clear_focus ( ) ;
551541 harness. keyboard_type_chars ( "A" ) ;
552542 let records = harness. take_records_of ( target_tag) ;
553543 assert_any ( records, |r| matches ! ( r, Record :: TextEvent ( _) ) ) ;
@@ -578,30 +568,28 @@ fn tab_focus() {
578568 let mut harness = TestHarness :: create ( test_property_set ( ) , parent) ;
579569
580570 let child_1_id = harness. get_widget ( child_1) . id ( ) ;
581- let child_2_id = harness. get_widget ( child_2) . id ( ) ;
582571 let child_3_id = harness. get_widget ( child_3) . id ( ) ;
583- let child_4_id = harness. get_widget ( child_4) . id ( ) ;
584572 let child_5_id = harness. get_widget ( child_5) . id ( ) ;
585573
586574 assert_eq ! ( harness. focused_widget_id( ) , None ) ;
587575
588576 // Tab moves focus to the next focusable widget in the tree.
589- harness. focus_on ( Some ( child_2_id ) ) ;
577+ harness. focus_on ( child_2 ) ;
590578 harness. press_tab_key ( false ) ;
591579 assert_eq ! ( harness. focused_widget_id( ) , Some ( child_3_id) ) ;
592580
593581 // Shift+Tab moves focus to the previous focusable widget in the tree.
594- harness. focus_on ( Some ( child_4_id ) ) ;
582+ harness. focus_on ( child_4 ) ;
595583 harness. press_tab_key ( true ) ;
596584 assert_eq ! ( harness. focused_widget_id( ) , Some ( child_3_id) ) ;
597585
598586 // When nothing is focused, Tab focuses the first focusable widget in the tree.
599- harness. focus_on ( None ) ;
587+ harness. clear_focus ( ) ;
600588 harness. press_tab_key ( false ) ;
601589 assert_eq ! ( harness. focused_widget_id( ) , Some ( child_1_id) ) ;
602590
603591 // When nothing is focused, Shift+Tab focuses the last focusable widget in the tree.
604- harness. focus_on ( None ) ;
592+ harness. clear_focus ( ) ;
605593 harness. press_tab_key ( true ) ;
606594 assert_eq ! ( harness. focused_widget_id( ) , Some ( child_5_id) ) ;
607595}
@@ -703,9 +691,8 @@ fn downcast_untyped_action() {
703691 let widget = NewWidget :: new ( arbitrary_submitter) . with_tag ( target_tag) ;
704692
705693 let mut harness = TestHarness :: create ( test_property_set ( ) , widget) ;
706- let target_id = harness. get_widget ( target_tag) . id ( ) ;
707694
708- harness. mouse_move_to ( target_id ) ;
695+ harness. mouse_move_to ( target_tag ) ;
709696
710697 assert_matches ! (
711698 harness. pop_action:: <ArbitraryAction >( ) ,
0 commit comments