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