99#import < XCTest/XCTest.h>
1010
1111#import < WebDriverAgentLib/FBAlert.h>
12+ #import < XCTest/XCTest.h>
1213
1314#import " FBConfiguration.h"
1415#import " FBIntegrationTestCase.h"
@@ -25,13 +26,33 @@ - (void)setUp
2526 [super setUp ];
2627 static dispatch_once_t onceToken;
2728 dispatch_once (&onceToken, ^{
29+ [self resetPermissions ];
2830 [self launchApplication ];
2931 [self goToAlertsPage ];
3032 [FBConfiguration disableApplicationUIInterruptionsHandling ];
3133 });
3234 [self clearAlert ];
3335}
3436
37+ - (void )resetPermissions
38+ {
39+ if (@available (iOS 13.4 , *)) {
40+ NSArray * resources = @[
41+ @(XCUIProtectedResourceContacts),
42+ @(XCUIProtectedResourceCalendar),
43+ @(XCUIProtectedResourceReminders),
44+ @(XCUIProtectedResourcePhotos),
45+ @(XCUIProtectedResourceMicrophone),
46+ @(XCUIProtectedResourceCamera),
47+ @(XCUIProtectedResourceMediaLibrary),
48+ @(XCUIProtectedResourceLocation),
49+ ];
50+ for (NSNumber *resource in resources) {
51+ [self .testedApplication resetAuthorizationStatusForResource: (XCUIProtectedResource)[resource unsignedLongValue ]];
52+ }
53+ }
54+ }
55+
3556- (void )tearDown
3657{
3758 [self clearAlert ];
@@ -153,24 +174,13 @@ - (void)testNotificationAlert
153174 XCTAssertTrue ([alert.text containsString: @" Notifications may include" ]);
154175}
155176
156- // This test case depends on the local app permission state.
157177- (void )testCameraRollAlert
158178{
159179 FBAlert *alert = [FBAlert alertWithApplication: self .testedApplication];
160180 XCTAssertNil (alert.text );
161181
162182 [self .testedApplication.buttons[@" Create Camera Roll Alert" ] tap ];
163183 FBAssertWaitTillBecomesTrue (alert.isPresent );
164-
165- // "Would Like to Access Your Photos" or "Would Like to Access Your Photo Library" displayes on the alert button.
166- XCTAssertTrue ([alert.text containsString: @" Would Like to Access Your Photo" ]);
167- // iOS 15 has different UI flow
168- if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO (@" 15.0" )) {
169- [[FBAlert alertWithApplication: self .testedApplication] dismissWithError: nil ];
170- // CI env could take longer time to show up the button, thus it needs to wait a bit.
171- XCTAssertTrue ([self .testedApplication.buttons[@" Cancel" ] waitForExistenceWithTimeout: 30.0 ]);
172- [self .testedApplication.buttons[@" Cancel" ] tap ];
173- }
174184}
175185
176186- (void )testGPSAccessAlert
0 commit comments