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

Commit 2eb6165

Browse files
author
Chris Yang
authored
Reland "[google_maps_flutter] ios: re-enable test with popup #5312" (#6783)
* reland fix fix test for iOS 16 fix fix typos * format * update changelog
1 parent e8c9731 commit 2eb6165

File tree

3 files changed

+28
-10
lines changed

3 files changed

+28
-10
lines changed

packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
## NEXT
22

33
* Updates code for new analysis options.
4+
* Re-enable XCUITests: testUserInterface.
5+
* Remove unnecessary `RunnerUITests` target from Podfile of the example app.
46

57
## 2.1.12
68

packages/google_maps_flutter/google_maps_flutter_ios/example/ios/Podfile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@ target 'Runner' do
3434

3535
pod 'OCMock', '~> 3.9.1'
3636
end
37-
target 'RunnerUITests' do
38-
inherit! :search_paths
39-
end
4037
end
4138

4239
post_install do |installer|

packages/google_maps_flutter/google_maps_flutter_ios/example/ios/RunnerUITests/GoogleMapsUITests.m

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
@import CoreLocation;
56
@import XCTest;
67
@import os.log;
7-
@import GoogleMaps;
88

99
@interface GoogleMapsUITests : XCTestCase
1010
@property(nonatomic, strong) XCUIApplication *app;
@@ -18,8 +18,6 @@ - (void)setUp {
1818
self.app = [[XCUIApplication alloc] init];
1919
[self.app launch];
2020

21-
// The location permission interception is currently not working.
22-
// See: https://github.com/flutter/flutter/issues/93325.
2321
[self
2422
addUIInterruptionMonitorWithDescription:@"Permission popups"
2523
handler:^BOOL(XCUIElement *_Nonnull interruptingElement) {
@@ -45,26 +43,35 @@ - (void)setUp {
4543
}];
4644
}
4745

48-
// Temporarily disabled due to https://github.com/flutter/flutter/issues/93325
49-
- (void)skip_testUserInterface {
46+
- (void)testUserInterface {
5047
XCUIApplication *app = self.app;
5148
XCUIElement *userInteface = app.staticTexts[@"User interface"];
5249
if (![userInteface waitForExistenceWithTimeout:30.0]) {
5350
os_log_error(OS_LOG_DEFAULT, "%@", app.debugDescription);
5451
XCTFail(@"Failed due to not able to find User interface");
5552
}
5653
[userInteface tap];
54+
5755
XCUIElement *platformView = app.otherElements[@"platform_view[0]"];
5856
if (![platformView waitForExistenceWithTimeout:30.0]) {
5957
os_log_error(OS_LOG_DEFAULT, "%@", app.debugDescription);
6058
XCTFail(@"Failed due to not able to find platform view");
6159
}
60+
61+
// There is a known bug where the permission popups interruption won't get fired until a tap
62+
// happened in the app. We expect a permission popup so we do a tap here.
63+
// iOS 16 has a bug where if the app itself is directly tapped: [app tap], the first button
64+
// (disable compass) in the app is also tapped, so instead we tap a arbitrary location in the app
65+
// instead.
66+
XCUICoordinate *coordinate = [app coordinateWithNormalizedOffset:CGVectorMake(0, 0)];
67+
[coordinate tap];
6268
XCUIElement *compass = app.buttons[@"disable compass"];
6369
if (![compass waitForExistenceWithTimeout:30.0]) {
6470
os_log_error(OS_LOG_DEFAULT, "%@", app.debugDescription);
65-
XCTFail(@"Failed due to not able to find compass button");
71+
XCTFail(@"Failed due to not able to find disable compass button");
6672
}
67-
[compass tap];
73+
74+
[self forceTap:compass];
6875
}
6976

7077
- (void)testMapCoordinatesPage {
@@ -190,4 +197,16 @@ - (void)testMapClickPage {
190197
}
191198
}
192199

200+
- (void)forceTap:(XCUIElement *)button {
201+
// iOS 16 introduced a bug where hittable is NO for buttons. We force hit the location of the
202+
// button if that is the case. It is likely similar to
203+
// https://github.com/flutter/flutter/issues/113377.
204+
if (button.isHittable) {
205+
[button tap];
206+
return;
207+
}
208+
XCUICoordinate *coordinate = [button coordinateWithNormalizedOffset:CGVectorMake(0, 0)];
209+
[coordinate tap];
210+
}
211+
193212
@end

0 commit comments

Comments
 (0)