Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit a35f830

Browse files
author
Chris Yang
authored
[image_picker] [integration_test] Fixes to make the tree green (#3317)
1 parent a7c4929 commit a35f830

File tree

6 files changed

+50
-14
lines changed

6 files changed

+50
-14
lines changed

packages/image_picker/image_picker/CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 0.6.7+15
2+
3+
* Fix element type in XCUITests to look for staticText type when searching for texts.
4+
* See https://github.com/flutter/flutter/issues/71927
5+
* Minor update in XCUITests to search for different elements on iOS 14 and above.
6+
17
## 0.6.7+14
28

39
* Set up XCUITests.

packages/image_picker/image_picker/example/ios/RunnerUITests/ImagePickerFromGalleryUITests.m

+36-10
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,33 @@ - (void)setUp {
2121
self.continueAfterFailure = NO;
2222
self.app = [[XCUIApplication alloc] init];
2323
[self.app launch];
24+
__weak typeof(self) weakSelf = self;
2425
[self addUIInterruptionMonitorWithDescription:@"Permission popups"
2526
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+
}
3539
[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];
3651
}
3752
return YES;
3853
}];
@@ -92,10 +107,21 @@ - (void)launchPickerAndCancel {
92107
[cancelButton tap];
93108

94109
// Find the "not picked image text".
95-
XCUIElement* imageNotPickedText = [self.app.otherElements
110+
XCUIElement* imageNotPickedText = [self.app.staticTexts
96111
elementMatchingPredicate:[NSPredicate
97112
predicateWithFormat:@"label == %@",
98113
@"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+
}
99125
if (![imageNotPickedText waitForExistenceWithTimeout:kElementWaitingTime]) {
100126
os_log_error(OS_LOG_DEFAULT, "%@", self.app.debugDescription);
101127
XCTFail(@"Failed due to not able to find imageNotPickedText with %@ seconds",

packages/image_picker/image_picker/pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: image_picker
22
description: Flutter plugin for selecting images from the Android and iOS image
33
library, and taking new pictures with the camera.
44
homepage: https://github.com/flutter/plugins/tree/master/packages/image_picker/image_picker
5-
version: 0.6.7+14
5+
version: 0.6.7+15
66

77
flutter:
88
plugin:

packages/integration_test/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.0.1
2+
3+
* Remove usages of deprecated `List` constructor.
4+
15
## 1.0.0
26

37
* Public stable release of plugin.

packages/integration_test/lib/common.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class Response {
8686

8787
/// Create a list of Strings from [_failureDetails].
8888
List<String> _failureDetailsAsString() {
89-
final List<String> list = List<String>();
89+
final List<String> list = <String>[];
9090
if (_failureDetails == null || _failureDetails.isEmpty) {
9191
return list;
9292
}
@@ -100,7 +100,7 @@ class Response {
100100

101101
/// Creates a [Failure] list using a json response.
102102
static List<Failure> _failureDetailsFromJson(List<dynamic> list) {
103-
final List<Failure> failureList = List<Failure>();
103+
final List<Failure> failureList = <Failure>[];
104104
list.forEach((s) {
105105
final String failure = s as String;
106106
failureList.add(Failure.fromJsonString(failure));

packages/integration_test/pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: integration_test
22
description: Runs tests that use the flutter_test API as integration tests.
3-
version: 1.0.0
3+
version: 1.0.1
44
homepage: https://github.com/flutter/plugins/tree/master/packages/integration_test
55

66
environment:

0 commit comments

Comments
 (0)