@@ -709,6 +709,96 @@ - (void)testAnnouncesRouteChanges {
709709 UIAccessibilityScreenChangedNotification);
710710}
711711
712+ - (void )testDoesNotAnnounceUnnamedRouteChanges {
713+ flutter::MockDelegate mock_delegate;
714+ auto thread_task_runner = CreateNewThread (" AccessibilityBridgeTest" );
715+ flutter::TaskRunners runners (/* label=*/ self.name .UTF8String ,
716+ /* platform=*/ thread_task_runner,
717+ /* raster=*/ thread_task_runner,
718+ /* ui=*/ thread_task_runner,
719+ /* io=*/ thread_task_runner);
720+ auto platform_view = std::make_unique<flutter::PlatformViewIOS>(
721+ /* delegate=*/ mock_delegate,
722+ /* rendering_api=*/ mock_delegate.settings_ .enable_impeller
723+ ? flutter::IOSRenderingAPI::kMetal
724+ : flutter::IOSRenderingAPI::kSoftware ,
725+ /* platform_views_controller=*/ nil ,
726+ /* task_runners=*/ runners,
727+ /* worker_task_runner=*/ nil ,
728+ /* is_gpu_disabled_sync_switch=*/ std::make_shared<fml::SyncSwitch>());
729+ id mockFlutterView = OCMClassMock ([FlutterView class ]);
730+ id mockFlutterViewController = OCMClassMock ([FlutterViewController class ]);
731+ OCMStub ([mockFlutterViewController view ]).andReturn (mockFlutterView);
732+
733+ NSMutableArray <NSDictionary <NSString *, id >*>* accessibility_notifications =
734+ [[NSMutableArray alloc ] init ];
735+ auto ios_delegate = std::make_unique<flutter::MockIosDelegate>();
736+ ios_delegate->on_PostAccessibilityNotification_ =
737+ [accessibility_notifications](UIAccessibilityNotifications notification, id argument) {
738+ [accessibility_notifications addObject: @{
739+ @" notification" : @(notification),
740+ @" argument" : argument ? argument : [NSNull null ],
741+ }];
742+ };
743+ __block auto bridge =
744+ std::make_unique<flutter::AccessibilityBridge>(/* view_controller=*/ mockFlutterViewController,
745+ /* platform_view=*/ platform_view.get (),
746+ /* platform_views_controller=*/ nil ,
747+ /* ios_delegate=*/ std::move (ios_delegate));
748+
749+ flutter::CustomAccessibilityActionUpdates actions;
750+
751+ // Build the first tree: unnamed route + one focusable item.
752+ flutter::SemanticsNodeUpdates first_nodes;
753+
754+ flutter::SemanticsNode first_route;
755+ first_route.id = 1 ;
756+ first_route.flags .scopesRoute = true ;
757+ first_nodes[first_route.id ] = first_route;
758+
759+ flutter::SemanticsNode focused_node;
760+ focused_node.id = 10 ;
761+ focused_node.label = " Item" ;
762+ focused_node.actions = static_cast <int32_t >(flutter::SemanticsAction::kTap );
763+ first_nodes[focused_node.id ] = focused_node;
764+
765+ flutter::SemanticsNode first_root;
766+ first_root.id = kRootNodeId ;
767+ first_root.flags .scopesRoute = true ;
768+ first_root.childrenInTraversalOrder = {1 , 10 };
769+ first_root.childrenInHitTestOrder = {1 , 10 };
770+ first_nodes[first_root.id ] = first_root;
771+
772+ bridge->UpdateSemantics (/* nodes=*/ first_nodes, /* actions=*/ actions);
773+
774+ bridge->AccessibilityObjectDidBecomeFocused (10 );
775+ [accessibility_notifications removeAllObjects ];
776+
777+ // Replace only the route (still unnamed), keep focus on the same item.
778+ flutter::SemanticsNodeUpdates second_nodes;
779+
780+ flutter::SemanticsNode second_route;
781+ second_route.id = 2 ;
782+ second_route.flags .scopesRoute = true ;
783+ second_nodes[second_route.id ] = second_route;
784+
785+ second_nodes[focused_node.id ] = focused_node;
786+
787+ flutter::SemanticsNode second_root;
788+ second_root.id = kRootNodeId ;
789+ second_root.flags .scopesRoute = true ;
790+ second_root.childrenInTraversalOrder = {2 , 10 };
791+ second_root.childrenInHitTestOrder = {2 , 10 };
792+ second_nodes[second_root.id ] = second_root;
793+
794+ bridge->UpdateSemantics (/* nodes=*/ second_nodes, /* actions=*/ actions);
795+
796+ XCTAssertEqual ([accessibility_notifications count ], 1ul );
797+ XCTAssertEqualObjects (accessibility_notifications[0 ][@" argument" ], [NSNull null ]);
798+ XCTAssertEqual ([accessibility_notifications[0 ][@" notification" ] unsignedIntValue ],
799+ UIAccessibilityLayoutChangedNotification);
800+ }
801+
712802- (void )testRadioButtonIsNotSwitchButton {
713803 flutter::MockDelegate mock_delegate;
714804 auto thread_task_runner = CreateNewThread (" AccessibilityBridgeTest" );
0 commit comments