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

Reland "[google_maps_flutter] ios: re-enable test with popup #5312" #6783

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need the entire GoogleMaps sdk to run the tests. Only CoreLocation is necessary.

@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)];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hopefully this doesn't cause flakiness.

[coordinate tap];
}

@end