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 XCUIElement* firstCell = self.hostApplication.collectionViews.cells.firstMatch;
38 if (![firstCell waitForExistenceWithTimeout:10]) {
40 XCTFail(@"Failed due to not able to find any cells with %@ seconds", @(10));
41 }
42
43
44
45
46
47
48
49 NSPredicate* cellPredicate = [NSPredicate
50 predicateWithFormat:
51 @"label == 'XCElementSnapshotPrivilegedValuePlaceholder' OR label = 'Scenarios'"];
52 NSArray<XCUIElement*>* shareSheetCells =
53 [self.hostApplication.collectionViews.cells matchingPredicate:cellPredicate]
54 .allElementsBoundByIndex;
55 for (XCUIElement* shareSheetCell in shareSheetCells) {
56 [shareSheetCell tap];
57
58 XCUIElement* flutterView = self.hostApplication.otherElements[@"flutter_view"];
59 if ([flutterView waitForExistenceWithTimeout:10]) {
60 launchedExtensionInFlutter = YES;
61 break;
62 }
63
64
65
66 XCUIElement* cancel = self.hostApplication.buttons[@"Cancel"];
67 if ([cancel waitForExistenceWithTimeout:10]) {
68 [cancel tap];
69 }
70 }
71
72 XCTAssertTrue(launchedExtensionInFlutter);
73}
XCUIApplication * hostApplication