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

Commit d22be76

Browse files
author
Chris Yang
authored
[google_maps_flutter] Add new XCUITests that do not require permissions. (#4496)
1 parent d09abd5 commit d22be76

File tree

2 files changed

+72
-3
lines changed

2 files changed

+72
-3
lines changed

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

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ - (void)setUp {
1717
self.app = [[XCUIApplication alloc] init];
1818
[self.app launch];
1919

20+
// The location permission interception is currently not working.
21+
// See: https://github.com/flutter/flutter/issues/93325.
2022
[self
2123
addUIInterruptionMonitorWithDescription:@"Permission popups"
2224
handler:^BOOL(XCUIElement* _Nonnull interruptingElement) {
@@ -64,4 +66,59 @@ - (void)skip_testUserInterface {
6466
[compass tap];
6567
}
6668

69+
- (void)testMapCoordinatesPage {
70+
XCUIApplication* app = self.app;
71+
XCUIElement* mapCoordinates = app.staticTexts[@"Map coordinates"];
72+
if (![mapCoordinates waitForExistenceWithTimeout:30.0]) {
73+
os_log_error(OS_LOG_DEFAULT, "%@", app.debugDescription);
74+
XCTFail(@"Failed due to not able to find 'Map coordinates''");
75+
}
76+
[mapCoordinates tap];
77+
78+
XCUIElement* platformView = app.otherElements[@"platform_view[0]"];
79+
if (![platformView waitForExistenceWithTimeout:30.0]) {
80+
os_log_error(OS_LOG_DEFAULT, "%@", app.debugDescription);
81+
XCTFail(@"Failed due to not able to find platform view");
82+
}
83+
84+
XCUIElement* getVisibleRegionBoundsButton = app.buttons[@"Get Visible Region Bounds"];
85+
if (![getVisibleRegionBoundsButton waitForExistenceWithTimeout:30.0]) {
86+
os_log_error(OS_LOG_DEFAULT, "%@", app.debugDescription);
87+
XCTFail(@"Failed due to not able to find 'Get Visible Region Bounds''");
88+
}
89+
[getVisibleRegionBoundsButton tap];
90+
}
91+
92+
- (void)testMapClickPage {
93+
XCUIApplication* app = self.app;
94+
XCUIElement* mapClick = app.staticTexts[@"Map click"];
95+
if (![mapClick waitForExistenceWithTimeout:30.0]) {
96+
os_log_error(OS_LOG_DEFAULT, "%@", app.debugDescription);
97+
XCTFail(@"Failed due to not able to find 'Map click''");
98+
}
99+
[mapClick tap];
100+
101+
XCUIElement* platformView = app.otherElements[@"platform_view[0]"];
102+
if (![platformView waitForExistenceWithTimeout:30.0]) {
103+
os_log_error(OS_LOG_DEFAULT, "%@", app.debugDescription);
104+
XCTFail(@"Failed due to not able to find platform view");
105+
}
106+
107+
[platformView tap];
108+
109+
XCUIElement* tapped = app.staticTexts[@"Tapped"];
110+
if (![tapped waitForExistenceWithTimeout:30.0]) {
111+
os_log_error(OS_LOG_DEFAULT, "%@", app.debugDescription);
112+
XCTFail(@"Failed due to not able to find 'tapped''");
113+
}
114+
115+
[platformView pressForDuration:5.0];
116+
117+
XCUIElement* longPressed = app.staticTexts[@"Long pressed"];
118+
if (![longPressed waitForExistenceWithTimeout:30.0]) {
119+
os_log_error(OS_LOG_DEFAULT, "%@", app.debugDescription);
120+
XCTFail(@"Failed due to not able to find 'longPressed''");
121+
}
122+
}
123+
67124
@end

packages/google_maps_flutter/google_maps_flutter/example/lib/map_click.dart

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,27 @@ class _MapClickBodyState extends State<_MapClickBody> {
6868
if (mapController != null) {
6969
final String lastTap = 'Tap:\n${_lastTap ?? ""}\n';
7070
final String lastLongPress = 'Long press:\n${_lastLongPress ?? ""}';
71-
columnChildren
72-
.add(Center(child: Text(lastTap, textAlign: TextAlign.center)));
71+
columnChildren.add(Center(
72+
child: Text(
73+
lastTap,
74+
textAlign: TextAlign.center,
75+
)));
76+
columnChildren.add(Center(
77+
child: Text(
78+
_lastTap != null ? 'Tapped' : '',
79+
textAlign: TextAlign.center,
80+
)));
7381
columnChildren.add(Center(
7482
child: Text(
7583
lastLongPress,
7684
textAlign: TextAlign.center,
7785
)));
86+
columnChildren.add(Center(
87+
child: Text(
88+
_lastLongPress != null ? 'Long pressed' : '',
89+
textAlign: TextAlign.center,
90+
)));
7891
}
79-
8092
return Column(
8193
mainAxisAlignment: MainAxisAlignment.start,
8294
crossAxisAlignment: CrossAxisAlignment.stretch,

0 commit comments

Comments
 (0)