Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 5229044

Browse files
author
Chris Yang
committed
test
1 parent 266a0d2 commit 5229044

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

shell/platform/darwin/ios/framework/Source/accessibility_bridge_test.mm

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1618,6 +1618,68 @@ - (void)testAnnouncesIgnoresLayoutChangeWhenModal {
16181618
XCTAssertEqual([accessibility_notifications count], 0ul);
16191619
}
16201620

1621+
- (void)testAnnouncesIgnoresLayoutChangeWhenApplicationIsInactive {
1622+
flutter::MockDelegate mock_delegate;
1623+
auto thread_task_runner = CreateNewThread("AccessibilityBridgeTest");
1624+
flutter::TaskRunners runners(/*label=*/self.name.UTF8String,
1625+
/*platform=*/thread_task_runner,
1626+
/*raster=*/thread_task_runner,
1627+
/*ui=*/thread_task_runner,
1628+
/*io=*/thread_task_runner);
1629+
auto platform_view = std::make_unique<flutter::PlatformViewIOS>(
1630+
/*delegate=*/mock_delegate,
1631+
/*rendering_api=*/flutter::IOSRenderingAPI::kSoftware,
1632+
/*platform_views_controller=*/nil,
1633+
/*task_runners=*/runners);
1634+
id mockFlutterView = OCMClassMock([FlutterView class]);
1635+
id mockFlutterViewController = OCMClassMock([FlutterViewController class]);
1636+
OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView);
1637+
1638+
NSMutableArray<NSDictionary<NSString*, id>*>* accessibility_notifications =
1639+
[[[NSMutableArray alloc] init] autorelease];
1640+
auto ios_delegate = std::make_unique<flutter::MockIosDelegate>();
1641+
ios_delegate->on_PostAccessibilityNotification_ =
1642+
[accessibility_notifications](UIAccessibilityNotifications notification, id argument) {
1643+
[accessibility_notifications addObject:@{
1644+
@"notification" : @(notification),
1645+
@"argument" : argument ? argument : [NSNull null],
1646+
}];
1647+
};
1648+
__block auto bridge =
1649+
std::make_unique<flutter::AccessibilityBridge>(/*view_controller=*/mockFlutterViewController,
1650+
/*platform_view=*/platform_view.get(),
1651+
/*platform_views_controller=*/nil,
1652+
/*ios_delegate=*/std::move(ios_delegate));
1653+
id mockApplication = OCMClassMock([UIApplication class]);
1654+
OCMStub([UIApplication sharedApplication]).andReturn(mockApplication);
1655+
OCMStub([mockApplication applicationState]).andReturn(UIApplicationStateInactive);
1656+
1657+
flutter::CustomAccessibilityActionUpdates actions;
1658+
flutter::SemanticsNodeUpdates nodes;
1659+
1660+
flutter::SemanticsNode child_node;
1661+
child_node.id = 1;
1662+
child_node.label = "child_node";
1663+
nodes[child_node.id] = child_node;
1664+
flutter::SemanticsNode root_node;
1665+
root_node.id = kRootNodeId;
1666+
root_node.label = "root";
1667+
root_node.childrenInTraversalOrder = {1};
1668+
root_node.childrenInHitTestOrder = {1};
1669+
nodes[root_node.id] = root_node;
1670+
bridge->UpdateSemantics(/*nodes=*/nodes, /*actions=*/actions);
1671+
1672+
// Removes child_node to simulate a layout change.
1673+
flutter::SemanticsNodeUpdates new_nodes;
1674+
flutter::SemanticsNode new_root_node;
1675+
new_root_node.id = kRootNodeId;
1676+
new_root_node.label = "root";
1677+
new_nodes[new_root_node.id] = new_root_node;
1678+
bridge->UpdateSemantics(/*nodes=*/new_nodes, /*actions=*/actions);
1679+
1680+
XCTAssertEqual([accessibility_notifications count], 0ul);
1681+
}
1682+
16211683
- (void)testAnnouncesIgnoresScrollChangeWhenModal {
16221684
flutter::MockDelegate mock_delegate;
16231685
auto thread_task_runner = CreateNewThread("AccessibilityBridgeTest");

0 commit comments

Comments
 (0)