diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md index 81b9c8f0f110..e5f232d3ce16 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md +++ b/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md @@ -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 diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios/Podfile b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios/Podfile index 14b4bdc51c96..29bfe631a3e7 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios/Podfile +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios/Podfile @@ -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| diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios/RunnerUITests/GoogleMapsUITests.m b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios/RunnerUITests/GoogleMapsUITests.m index f4cdb7c50ab2..c3af06691a3f 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios/RunnerUITests/GoogleMapsUITests.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios/RunnerUITests/GoogleMapsUITests.m @@ -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; @@ -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) { @@ -45,8 +43,7 @@ - (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]) { @@ -54,17 +51,27 @@ - (void)skip_testUserInterface { 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 { @@ -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