Skip to content

Commit f452ca2

Browse files
committed
another test
1 parent 2d6dbd8 commit f452ca2

File tree

2 files changed

+35
-22
lines changed

2 files changed

+35
-22
lines changed

packages/image_picker/image_picker_ios/example/ios/Runner/AppDelegate.m

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,33 @@ @implementation AppDelegate
1313
- (BOOL)application:(UIApplication *)application
1414
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
1515
[GeneratedPluginRegistrant registerWithRegistry:self];
16-
17-
if (@available(iOS 14, *)) {
18-
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
19-
__block NSError *saveError = nil;
20-
[PHPhotoLibrary
21-
requestAuthorizationForAccessLevel:PHAccessLevelAddOnly
22-
handler:^(PHAuthorizationStatus status) {
23-
if (![PHPhotoLibrary.sharedPhotoLibrary
24-
performChangesAndWait:^{
25-
NSURL *jpgImageTall =
26-
[bundle URLForResource:@"jpgImageTall"
27-
withExtension:@"jpg"];
28-
[PHAssetChangeRequest
29-
creationRequestForAssetFromImageAtFileURL:
30-
jpgImageTall];
31-
}
32-
error:&saveError]) {
33-
os_log_error(OS_LOG_DEFAULT, "%@", saveError);
34-
}
35-
}];
36-
}
16+
if (@available(iOS 14, *)) {
17+
// Seed the photo library with at least one image for tests to operate on.
18+
NSString *photoAddedKey = @"PhotoAdded";
19+
BOOL photoAdded = [NSUserDefaults.standardUserDefaults boolForKey:photoAddedKey];
20+
if (!photoAdded) {
21+
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
22+
__block NSError *saveError = nil;
23+
[PHPhotoLibrary
24+
requestAuthorizationForAccessLevel:PHAccessLevelAddOnly
25+
handler:^(PHAuthorizationStatus status) {
26+
if ([PHPhotoLibrary.sharedPhotoLibrary
27+
performChangesAndWait:^{
28+
NSURL *jpgImageTall =
29+
[bundle URLForResource:@"jpgImageTall"
30+
withExtension:@"jpg"];
31+
[PHAssetChangeRequest
32+
creationRequestForAssetFromImageAtFileURL:
33+
jpgImageTall];
34+
}
35+
error:&saveError]) {
36+
[NSUserDefaults.standardUserDefaults setBool:YES forKey:photoAddedKey];
37+
} else {
38+
os_log_error(OS_LOG_DEFAULT, "%@", saveError);
39+
}
40+
}];
41+
}
42+
}
3743
return [super application:application didFinishLaunchingWithOptions:launchOptions];
3844
}
3945

packages/image_picker/image_picker_ios/example/ios/RunnerUITests/ImagePickerFromLimitedGalleryUITests.m

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,14 @@ - (void)testSelectingFromGallery API_AVAILABLE(ios(14)) {
115115
@(kLimitedElementWaitingTime));
116116
}
117117

118-
[aImage tap];
118+
if (aImage.isHittable) {
119+
[aImage tap];
120+
} else {
121+
// Known issue where tappable elements are not hittable. Tap it anyway.
122+
// See https://github.com/flutter/plugins/pull/6783 for a similar case.
123+
XCUICoordinate *coordinate = [aImage coordinateWithNormalizedOffset:CGVectorMake(0, 0)];
124+
[coordinate tap];
125+
}
119126

120127
// Find the picked image.
121128
XCUIElement *pickedImage = self.app.images[@"image_picker_example_picked_image"].firstMatch;

0 commit comments

Comments
 (0)