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

Commit

Permalink
Reland "[google_maps_flutter] ios: re-enable test with popup #5312" (#…
Browse files Browse the repository at this point in the history
…6783)

* reland

fix

fix test for iOS 16

fix

fix typos

* format

* update changelog
  • Loading branch information
Chris Yang authored Dec 12, 2022
1 parent e8c9731 commit 2eb6165
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## NEXT

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

## 2.1.12

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ target 'Runner' do

pod 'OCMock', '~> 3.9.1'
end
target 'RunnerUITests' do
inherit! :search_paths
end
end

post_install do |installer|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

@import CoreLocation;
@import XCTest;
@import os.log;
@import GoogleMaps;

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

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

// Temporarily disabled due to https://github.com/flutter/flutter/issues/93325
- (void)skip_testUserInterface {
- (void)testUserInterface {
XCUIApplication *app = self.app;
XCUIElement *userInteface = app.staticTexts[@"User interface"];
if (![userInteface waitForExistenceWithTimeout:30.0]) {
os_log_error(OS_LOG_DEFAULT, "%@", app.debugDescription);
XCTFail(@"Failed due to not able to find User interface");
}
[userInteface tap];

XCUIElement *platformView = app.otherElements[@"platform_view[0]"];
if (![platformView waitForExistenceWithTimeout:30.0]) {
os_log_error(OS_LOG_DEFAULT, "%@", app.debugDescription);
XCTFail(@"Failed due to not able to find platform view");
}

// There is a known bug where the permission popups interruption won't get fired until a tap
// happened in the app. We expect a permission popup so we do a tap here.
// iOS 16 has a bug where if the app itself is directly tapped: [app tap], the first button
// (disable compass) in the app is also tapped, so instead we tap a arbitrary location in the app
// instead.
XCUICoordinate *coordinate = [app coordinateWithNormalizedOffset:CGVectorMake(0, 0)];
[coordinate tap];
XCUIElement *compass = app.buttons[@"disable compass"];
if (![compass waitForExistenceWithTimeout:30.0]) {
os_log_error(OS_LOG_DEFAULT, "%@", app.debugDescription);
XCTFail(@"Failed due to not able to find compass button");
XCTFail(@"Failed due to not able to find disable compass button");
}
[compass tap];

[self forceTap:compass];
}

- (void)testMapCoordinatesPage {
Expand Down Expand Up @@ -190,4 +197,16 @@ - (void)testMapClickPage {
}
}

- (void)forceTap:(XCUIElement *)button {
// iOS 16 introduced a bug where hittable is NO for buttons. We force hit the location of the
// button if that is the case. It is likely similar to
// https://github.com/flutter/flutter/issues/113377.
if (button.isHittable) {
[button tap];
return;
}
XCUICoordinate *coordinate = [button coordinateWithNormalizedOffset:CGVectorMake(0, 0)];
[coordinate tap];
}

@end

0 comments on commit 2eb6165

Please sign in to comment.