21 {
22
23 XCUIApplication*
app = [[XCUIApplication alloc] init];
24 [app launch];
25 [app terminate];
26
27 [self.hostApplication launch];
28 XCUIElement* button = self.hostApplication.buttons[@"Open Share"];
29 if (![button waitForExistenceWithTimeout:10]) {
31 XCTFail(@"Failed due to not able to find any button with %@ seconds", @(10));
32 }
33 [button tap];
34 BOOL launchedExtensionInFlutter = NO;
35
36
37
38
39
40
41
42 NSPredicate* cellPredicate = [NSPredicate
43 predicateWithFormat:
44 @"label == 'XCElementSnapshotPrivilegedValuePlaceholder' OR label = 'Scenarios'"];
45
46
47 XCUIElement* firstCell =
48 [self.hostApplication.collectionViews.cells matchingPredicate:cellPredicate].firstMatch;
49 if (![firstCell waitForExistenceWithTimeout:10]) {
51 XCTFail(@"Failed due to not able to find Scenarios cell within %@ seconds", @(10));
52 }
53
54 NSArray<XCUIElement*>* shareSheetCells =
55 [self.hostApplication.collectionViews.cells matchingPredicate:cellPredicate]
56 .allElementsBoundByIndex;
57 for (XCUIElement* shareSheetCell in shareSheetCells) {
58 [shareSheetCell tap];
59
60 XCUIElement* flutterView = self.hostApplication.otherElements[@"flutter_view"];
61 if ([flutterView waitForExistenceWithTimeout:10]) {
62 launchedExtensionInFlutter = YES;
63 break;
64 }
65
66
67
68 XCUIElement* cancel = self.hostApplication.buttons[@"Cancel"];
69 if ([cancel waitForExistenceWithTimeout:10]) {
70 [cancel tap];
71 }
72 }
73
74 XCTAssertTrue(launchedExtensionInFlutter);
75}
XCUIApplication * hostApplication