@@ -709,7 +709,7 @@ - (void)testAnnouncesRouteChanges {
709709 UIAccessibilityScreenChangedNotification);
710710}
711711
712- - (void )testDoesNotAnnounceUnnamedRouteChanges {
712+ - (void )testTabSwitchDoesNotPostScreenChange {
713713 flutter::MockDelegate mock_delegate;
714714 auto thread_task_runner = CreateNewThread (" AccessibilityBridgeTest" );
715715 flutter::TaskRunners runners (/* label=*/ self.name .UTF8String ,
@@ -748,54 +748,128 @@ - (void)testDoesNotAnnounceUnnamedRouteChanges {
748748
749749 flutter::CustomAccessibilityActionUpdates actions;
750750
751- // Build the first tree: unnamed route + one focusable item.
752751 flutter::SemanticsNodeUpdates first_nodes;
753-
754752 flutter::SemanticsNode first_route;
755753 first_route.id = 1 ;
756754 first_route.flags .scopesRoute = true ;
757755 first_nodes[first_route.id ] = first_route;
758-
759756 flutter::SemanticsNode focused_node;
760757 focused_node.id = 10 ;
761758 focused_node.label = " Item" ;
762759 focused_node.actions = static_cast <int32_t >(flutter::SemanticsAction::kTap );
763760 first_nodes[focused_node.id ] = focused_node;
764-
765761 flutter::SemanticsNode first_root;
766762 first_root.id = kRootNodeId ;
767763 first_root.flags .scopesRoute = true ;
768764 first_root.childrenInTraversalOrder = {1 , 10 };
769765 first_root.childrenInHitTestOrder = {1 , 10 };
770766 first_nodes[first_root.id ] = first_root;
771-
772767 bridge->UpdateSemantics (/* nodes=*/ first_nodes, /* actions=*/ actions);
773-
774768 bridge->AccessibilityObjectDidBecomeFocused (10 );
775769 [accessibility_notifications removeAllObjects ];
776770
777- // Replace only the route (still unnamed), keep focus on the same item.
778771 flutter::SemanticsNodeUpdates second_nodes;
779-
780772 flutter::SemanticsNode second_route;
781773 second_route.id = 2 ;
782774 second_route.flags .scopesRoute = true ;
783775 second_nodes[second_route.id ] = second_route;
784-
785776 second_nodes[focused_node.id ] = focused_node;
786-
787777 flutter::SemanticsNode second_root;
788778 second_root.id = kRootNodeId ;
789779 second_root.flags .scopesRoute = true ;
790780 second_root.childrenInTraversalOrder = {2 , 10 };
791781 second_root.childrenInHitTestOrder = {2 , 10 };
792782 second_nodes[second_root.id ] = second_root;
793-
794783 bridge->UpdateSemantics (/* nodes=*/ second_nodes, /* actions=*/ actions);
795784
796785 XCTAssertEqual ([accessibility_notifications count ], 1ul );
786+ XCTAssertEqual ([accessibility_notifications[0 ][@" notification" ] unsignedIntValue ],
787+ UIAccessibilityLayoutChangedNotification);
797788 XCTAssertEqualObjects (accessibility_notifications[0 ][@" argument" ], [NSNull null ]);
789+ }
790+
791+ - (void )testUnnamedPushTransitionPostsScreenChangeWithNilRouteName {
792+ flutter::MockDelegate mock_delegate;
793+ auto thread_task_runner = CreateNewThread (" AccessibilityBridgeTest" );
794+ flutter::TaskRunners runners (/* label=*/ self.name .UTF8String ,
795+ /* platform=*/ thread_task_runner,
796+ /* raster=*/ thread_task_runner,
797+ /* ui=*/ thread_task_runner,
798+ /* io=*/ thread_task_runner);
799+ auto platform_view = std::make_unique<flutter::PlatformViewIOS>(
800+ /* delegate=*/ mock_delegate,
801+ /* rendering_api=*/ mock_delegate.settings_ .enable_impeller
802+ ? flutter::IOSRenderingAPI::kMetal
803+ : flutter::IOSRenderingAPI::kSoftware ,
804+ /* platform_views_controller=*/ nil ,
805+ /* task_runners=*/ runners,
806+ /* worker_task_runner=*/ nil ,
807+ /* is_gpu_disabled_sync_switch=*/ std::make_shared<fml::SyncSwitch>());
808+ id mockFlutterView = OCMClassMock ([FlutterView class ]);
809+ id mockFlutterViewController = OCMClassMock ([FlutterViewController class ]);
810+ OCMStub ([mockFlutterViewController view ]).andReturn (mockFlutterView);
811+
812+ NSMutableArray <NSDictionary <NSString *, id >*>* accessibility_notifications =
813+ [[NSMutableArray alloc ] init ];
814+ auto ios_delegate = std::make_unique<flutter::MockIosDelegate>();
815+ ios_delegate->on_PostAccessibilityNotification_ =
816+ [accessibility_notifications](UIAccessibilityNotifications notification, id argument) {
817+ [accessibility_notifications addObject: @{
818+ @" notification" : @(notification),
819+ @" argument" : argument ? argument : [NSNull null ],
820+ }];
821+ };
822+ __block auto bridge =
823+ std::make_unique<flutter::AccessibilityBridge>(/* view_controller=*/ mockFlutterViewController,
824+ /* platform_view=*/ platform_view.get (),
825+ /* platform_views_controller=*/ nil ,
826+ /* ios_delegate=*/ std::move (ios_delegate));
827+
828+ flutter::CustomAccessibilityActionUpdates actions;
829+
830+ flutter::SemanticsNodeUpdates first_nodes;
831+ flutter::SemanticsNode first_route;
832+ first_route.id = 1 ;
833+ first_route.flags .scopesRoute = true ;
834+ first_nodes[first_route.id ] = first_route;
835+ flutter::SemanticsNode first_item;
836+ first_item.id = 10 ;
837+ first_item.label = " First" ;
838+ first_item.actions = static_cast <int32_t >(flutter::SemanticsAction::kTap );
839+ first_nodes[first_item.id ] = first_item;
840+ flutter::SemanticsNode first_root;
841+ first_root.id = kRootNodeId ;
842+ first_root.flags .scopesRoute = true ;
843+ first_root.childrenInTraversalOrder = {1 , 10 };
844+ first_root.childrenInHitTestOrder = {1 , 10 };
845+ first_nodes[first_root.id ] = first_root;
846+ bridge->UpdateSemantics (/* nodes=*/ first_nodes, /* actions=*/ actions);
847+ bridge->AccessibilityObjectDidBecomeFocused (10 );
848+ [accessibility_notifications removeAllObjects ];
849+
850+ flutter::SemanticsNodeUpdates second_nodes;
851+ flutter::SemanticsNode second_route;
852+ second_route.id = 2 ;
853+ second_route.flags .scopesRoute = true ;
854+ second_nodes[second_route.id ] = second_route;
855+ flutter::SemanticsNode second_item;
856+ second_item.id = 20 ;
857+ second_item.label = " Second" ;
858+ second_item.actions = static_cast <int32_t >(flutter::SemanticsAction::kTap );
859+ second_nodes[second_item.id ] = second_item;
860+ flutter::SemanticsNode second_root;
861+ second_root.id = kRootNodeId ;
862+ second_root.flags .scopesRoute = true ;
863+ second_root.childrenInTraversalOrder = {2 , 20 };
864+ second_root.childrenInHitTestOrder = {2 , 20 };
865+ second_nodes[second_root.id ] = second_root;
866+ bridge->UpdateSemantics (/* nodes=*/ second_nodes, /* actions=*/ actions);
867+
868+ XCTAssertEqual ([accessibility_notifications count ], 2ul );
798869 XCTAssertEqual ([accessibility_notifications[0 ][@" notification" ] unsignedIntValue ],
870+ UIAccessibilityScreenChangedNotification);
871+ XCTAssertEqualObjects (accessibility_notifications[0 ][@" argument" ], [NSNull null ]);
872+ XCTAssertEqual ([accessibility_notifications[1 ][@" notification" ] unsignedIntValue ],
799873 UIAccessibilityLayoutChangedNotification);
800874}
801875
0 commit comments