@@ -21,18 +21,33 @@ - (void)setUp {
21
21
self.continueAfterFailure = NO ;
22
22
self.app = [[XCUIApplication alloc ] init ];
23
23
[self .app launch ];
24
+ __weak typeof (self) weakSelf = self;
24
25
[self addUIInterruptionMonitorWithDescription: @" Permission popups"
25
26
handler: ^BOOL (XCUIElement* _Nonnull interruptingElement) {
26
- XCUIElement* ok = interruptingElement.buttons [@" OK" ];
27
- if (ok.exists ) {
28
- [ok tap ];
29
- }
30
- // iOS 14.
31
- XCUIElement* allPhotoPermission =
32
- interruptingElement
33
- .buttons [@" Allow Access to All Photos" ];
34
- if (allPhotoPermission.exists ) {
27
+ if (@available (iOS 14 , *)) {
28
+ XCUIElement* allPhotoPermission =
29
+ interruptingElement
30
+ .buttons [@" Allow Access to All Photos" ];
31
+ if (![allPhotoPermission waitForExistenceWithTimeout:
32
+ kElementWaitingTime ]) {
33
+ os_log_error (OS_LOG_DEFAULT, " %@" ,
34
+ self.app .debugDescription );
35
+ XCTFail (@" Failed due to not able to find "
36
+ @" allPhotoPermission button with %@ seconds" ,
37
+ @(kElementWaitingTime ));
38
+ }
35
39
[allPhotoPermission tap ];
40
+ } else {
41
+ XCUIElement* ok = interruptingElement.buttons [@" OK" ];
42
+ if (![ok waitForExistenceWithTimeout:
43
+ kElementWaitingTime ]) {
44
+ os_log_error (OS_LOG_DEFAULT, " %@" ,
45
+ self.app .debugDescription );
46
+ XCTFail (@" Failed due to not able to find ok button "
47
+ @" with %@ seconds" ,
48
+ @(kElementWaitingTime ));
49
+ }
50
+ [ok tap ];
36
51
}
37
52
return YES ;
38
53
}];
@@ -92,10 +107,21 @@ - (void)launchPickerAndCancel {
92
107
[cancelButton tap ];
93
108
94
109
// Find the "not picked image text".
95
- XCUIElement* imageNotPickedText = [self .app.otherElements
110
+ XCUIElement* imageNotPickedText = [self .app.staticTexts
96
111
elementMatchingPredicate: [NSPredicate
97
112
predicateWithFormat: @" label == %@ " ,
98
113
@" You have not yet picked an image." ]];
114
+ if (![imageNotPickedText waitForExistenceWithTimeout: kElementWaitingTime ]) {
115
+ // Before https://github.com/flutter/engine/pull/22811 the label's a11y type was otherElements.
116
+ // TODO(cyanglaz): Remove this after
117
+ // https://github.com/flutter/flutter/commit/057e8230743ec96f33b73948ccd6b80081e3615e rolled to
118
+ // stable.
119
+ // https://github.com/flutter/flutter/issues/71927
120
+ imageNotPickedText = [self .app.otherElements
121
+ elementMatchingPredicate: [NSPredicate
122
+ predicateWithFormat: @" label == %@ " ,
123
+ @" You have not yet picked an image." ]];
124
+ }
99
125
if (![imageNotPickedText waitForExistenceWithTimeout: kElementWaitingTime ]) {
100
126
os_log_error (OS_LOG_DEFAULT, " %@" , self.app .debugDescription );
101
127
XCTFail (@" Failed due to not able to find imageNotPickedText with %@ seconds" ,
0 commit comments