Skip to content

Commit 1c5227e

Browse files
committed
Added some tests after the fact for flutter#17499.
1 parent 6d17ce6 commit 1c5227e

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,30 @@ - (void)testCreate {
3838
XCTAssertNotNil(object);
3939
}
4040

41+
- (void)testSetChildren {
42+
fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(
43+
new flutter::MockAccessibilityBridge());
44+
fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
45+
SemanticsObject* parent = [[SemanticsObject alloc] initWithBridge:bridge uid:0];
46+
SemanticsObject* child = [[SemanticsObject alloc] initWithBridge:bridge uid:1];
47+
parent.children = @[child];
48+
XCTAssertEqual(parent, child.parent, @"");
49+
parent.children = @[];
50+
XCTAssertNil(child.parent, @"");
51+
}
52+
53+
- (void)testReplaceChildAtIndex {
54+
fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(
55+
new flutter::MockAccessibilityBridge());
56+
fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
57+
SemanticsObject* parent = [[SemanticsObject alloc] initWithBridge:bridge uid:0];
58+
SemanticsObject* child1 = [[SemanticsObject alloc] initWithBridge:bridge uid:1];
59+
SemanticsObject* child2 = [[SemanticsObject alloc] initWithBridge:bridge uid:2];
60+
parent.children = @[child1];
61+
[parent replaceChildAtIndex:0 withChild:child2];
62+
XCTAssertNil(child1.parent, @"");
63+
XCTAssertEqual(parent, child2.parent, @"");
64+
XCTAssertEqualObjects(parent.children, @[child2], @"");
65+
}
66+
4167
@end

testing/ios/IosUnitTests/build_and_run_tests.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/sh
22

3+
set -e
4+
35
FLUTTER_ENGINE=ios_debug_sim_unopt
46

57
if [ $# -eq 1 ]; then

0 commit comments

Comments
 (0)