6
6
@import XCTest;
7
7
@import os.log;
8
8
9
+ static const NSTimeInterval kWaitTime = 60 ;
10
+
9
11
@interface GoogleMapsUITests : XCTestCase
10
12
@property (nonatomic , strong ) XCUIApplication *app;
11
13
@end
@@ -25,7 +27,7 @@ - (void)setUp {
25
27
XCUIElement *locationPermission =
26
28
interruptingElement.buttons [@" Allow While Using App" ];
27
29
if (![locationPermission
28
- waitForExistenceWithTimeout: 30.0 ]) {
30
+ waitForExistenceWithTimeout: kWaitTime ]) {
29
31
XCTFail (@" Failed due to not able to find "
30
32
@" locationPermission button" );
31
33
}
@@ -34,7 +36,7 @@ - (void)setUp {
34
36
} else {
35
37
XCUIElement *allow =
36
38
interruptingElement.buttons [@" Allow" ];
37
- if (![allow waitForExistenceWithTimeout: 30.0 ]) {
39
+ if (![allow waitForExistenceWithTimeout: kWaitTime ]) {
38
40
XCTFail (@" Failed due to not able to find Allow button" );
39
41
}
40
42
[allow tap ];
@@ -46,14 +48,14 @@ - (void)setUp {
46
48
- (void )testUserInterface {
47
49
XCUIApplication *app = self.app ;
48
50
XCUIElement *userInteface = app.staticTexts [@" User interface" ];
49
- if (![userInteface waitForExistenceWithTimeout: 30.0 ]) {
51
+ if (![userInteface waitForExistenceWithTimeout: kWaitTime ]) {
50
52
os_log_error (OS_LOG_DEFAULT, " %@" , app.debugDescription );
51
53
XCTFail (@" Failed due to not able to find User interface" );
52
54
}
53
55
[userInteface tap ];
54
56
55
57
XCUIElement *platformView = app.otherElements [@" platform_view[0]" ];
56
- if (![platformView waitForExistenceWithTimeout: 30.0 ]) {
58
+ if (![platformView waitForExistenceWithTimeout: kWaitTime ]) {
57
59
os_log_error (OS_LOG_DEFAULT, " %@" , app.debugDescription );
58
60
XCTFail (@" Failed due to not able to find platform view" );
59
61
}
@@ -66,7 +68,7 @@ - (void)testUserInterface {
66
68
XCUICoordinate *coordinate = [app coordinateWithNormalizedOffset: CGVectorMake (0 , 0 )];
67
69
[coordinate tap ];
68
70
XCUIElement *compass = app.buttons [@" disable compass" ];
69
- if (![compass waitForExistenceWithTimeout: 30.0 ]) {
71
+ if (![compass waitForExistenceWithTimeout: kWaitTime ]) {
70
72
os_log_error (OS_LOG_DEFAULT, " %@" , app.debugDescription );
71
73
XCTFail (@" Failed due to not able to find disable compass button" );
72
74
}
@@ -77,20 +79,20 @@ - (void)testUserInterface {
77
79
- (void )testMapCoordinatesPage {
78
80
XCUIApplication *app = self.app ;
79
81
XCUIElement *mapCoordinates = app.staticTexts [@" Map coordinates" ];
80
- if (![mapCoordinates waitForExistenceWithTimeout: 30.0 ]) {
82
+ if (![mapCoordinates waitForExistenceWithTimeout: kWaitTime ]) {
81
83
os_log_error (OS_LOG_DEFAULT, " %@" , app.debugDescription );
82
84
XCTFail (@" Failed due to not able to find 'Map coordinates''" );
83
85
}
84
86
[mapCoordinates tap ];
85
87
86
88
XCUIElement *platformView = app.otherElements [@" platform_view[0]" ];
87
- if (![platformView waitForExistenceWithTimeout: 30.0 ]) {
89
+ if (![platformView waitForExistenceWithTimeout: kWaitTime ]) {
88
90
os_log_error (OS_LOG_DEFAULT, " %@" , app.debugDescription );
89
91
XCTFail (@" Failed due to not able to find platform view" );
90
92
}
91
93
92
94
XCUIElement *titleBar = app.otherElements [@" Map coordinates" ];
93
- if (![titleBar waitForExistenceWithTimeout: 30.0 ]) {
95
+ if (![titleBar waitForExistenceWithTimeout: kWaitTime ]) {
94
96
os_log_error (OS_LOG_DEFAULT, " %@" , app.debugDescription );
95
97
XCTFail (@" Failed due to not able to find title bar" );
96
98
}
@@ -99,7 +101,7 @@ - (void)testMapCoordinatesPage {
99
101
[NSPredicate predicateWithFormat: @" label BEGINSWITH 'VisibleRegion'" ];
100
102
XCUIElement *visibleRegionText =
101
103
[app.staticTexts elementMatchingPredicate: visibleRegionPredicate];
102
- if (![visibleRegionText waitForExistenceWithTimeout: 30.0 ]) {
104
+ if (![visibleRegionText waitForExistenceWithTimeout: kWaitTime ]) {
103
105
os_log_error (OS_LOG_DEFAULT, " %@" , app.debugDescription );
104
106
XCTFail (@" Failed due to not able to find Visible Region label'" );
105
107
}
@@ -168,30 +170,30 @@ - (void)validateVisibleRegion:(NSString *)label
168
170
- (void )testMapClickPage {
169
171
XCUIApplication *app = self.app ;
170
172
XCUIElement *mapClick = app.staticTexts [@" Map click" ];
171
- if (![mapClick waitForExistenceWithTimeout: 30.0 ]) {
173
+ if (![mapClick waitForExistenceWithTimeout: kWaitTime ]) {
172
174
os_log_error (OS_LOG_DEFAULT, " %@" , app.debugDescription );
173
175
XCTFail (@" Failed due to not able to find 'Map click''" );
174
176
}
175
177
[mapClick tap ];
176
178
177
179
XCUIElement *platformView = app.otherElements [@" platform_view[0]" ];
178
- if (![platformView waitForExistenceWithTimeout: 30.0 ]) {
180
+ if (![platformView waitForExistenceWithTimeout: kWaitTime ]) {
179
181
os_log_error (OS_LOG_DEFAULT, " %@" , app.debugDescription );
180
182
XCTFail (@" Failed due to not able to find platform view" );
181
183
}
182
184
183
185
[platformView tap ];
184
186
185
187
XCUIElement *tapped = app.staticTexts [@" Tapped" ];
186
- if (![tapped waitForExistenceWithTimeout: 30.0 ]) {
188
+ if (![tapped waitForExistenceWithTimeout: kWaitTime ]) {
187
189
os_log_error (OS_LOG_DEFAULT, " %@" , app.debugDescription );
188
190
XCTFail (@" Failed due to not able to find 'tapped''" );
189
191
}
190
192
191
193
[platformView pressForDuration: 5.0 ];
192
194
193
195
XCUIElement *longPressed = app.staticTexts [@" Long pressed" ];
194
- if (![longPressed waitForExistenceWithTimeout: 30.0 ]) {
196
+ if (![longPressed waitForExistenceWithTimeout: kWaitTime ]) {
195
197
os_log_error (OS_LOG_DEFAULT, " %@" , app.debugDescription );
196
198
XCTFail (@" Failed due to not able to find 'longPressed''" );
197
199
}
@@ -209,4 +211,67 @@ - (void)forceTap:(XCUIElement *)button {
209
211
[coordinate tap ];
210
212
}
211
213
214
+ - (void )testMarkerDraggingCallbacks {
215
+ XCUIApplication *application = [[XCUIApplication alloc ] init ];
216
+ [application launch ];
217
+ XCUIElement *placeMarkerButton = application.staticTexts [@" Place marker" ];
218
+ if (![placeMarkerButton waitForExistenceWithTimeout: kWaitTime ]) {
219
+ NSLog (@" application.debugDescription: %@ " , application.debugDescription );
220
+ XCTFail (@" Failed to find the Place marker button." );
221
+ }
222
+ [placeMarkerButton tap ];
223
+
224
+ XCUIElement *Add = application.buttons [@" Add" ];
225
+ if (![Add waitForExistenceWithTimeout: kWaitTime ]) {
226
+ NSLog (@" application.debugDescription: %@ " , application.debugDescription );
227
+ XCTFail (@" Failed to find the Add button." );
228
+ }
229
+ [Add tap ];
230
+
231
+ XCUIElement *marker = application.buttons [@" marker_id_1" ];
232
+ if (![marker waitForExistenceWithTimeout: kWaitTime ]) {
233
+ NSLog (@" application.debugDescription: %@ " , application.debugDescription );
234
+ XCTFail (@" Failed to find the marker." );
235
+ }
236
+ [marker tap ];
237
+
238
+ XCUIElement *toggleDraggable = application.buttons [@" toggle draggable" ];
239
+ if (![toggleDraggable waitForExistenceWithTimeout: kWaitTime ]) {
240
+ NSLog (@" application.debugDescription: %@ " , application.debugDescription );
241
+ XCTFail (@" Failed to find the toggle draggable." );
242
+ }
243
+ [toggleDraggable tap ];
244
+
245
+ // Drag marker to center
246
+ [marker pressForDuration: 5 thenDragToElement: application];
247
+
248
+ NSPredicate *predicateDragStart =
249
+ [NSPredicate predicateWithFormat: @" label CONTAINS [c] %@" , @" _onMarkerDragStart" ];
250
+ NSPredicate *predicateDrag =
251
+ [NSPredicate predicateWithFormat: @" label CONTAINS [c] %@" , @" _onMarkerDrag called" ];
252
+ NSPredicate *predicateDragEnd =
253
+ [NSPredicate predicateWithFormat: @" label CONTAINS [c] %@" , @" _onMarkerDragEnd" ];
254
+
255
+ XCUIElement *dragStart = [application.staticTexts matchingPredicate: predicateDragStart].element ;
256
+ if (![dragStart waitForExistenceWithTimeout: kWaitTime ]) {
257
+ NSLog (@" application.debugDescription: %@ " , application.debugDescription );
258
+ XCTFail (@" Failed to find the _onMarkerDragStart." );
259
+ }
260
+ XCTAssertTrue (dragStart.exists );
261
+
262
+ XCUIElement *drag = [application.staticTexts matchingPredicate: predicateDrag].element ;
263
+ if (![drag waitForExistenceWithTimeout: kWaitTime ]) {
264
+ NSLog (@" application.debugDescription: %@ " , application.debugDescription );
265
+ XCTFail (@" Failed to find the _onMarkerDrag." );
266
+ }
267
+ XCTAssertTrue (drag.exists );
268
+
269
+ XCUIElement *dragEnd = [application.staticTexts matchingPredicate: predicateDragEnd].element ;
270
+ if (![dragEnd waitForExistenceWithTimeout: kWaitTime ]) {
271
+ NSLog (@" application.debugDescription: %@ " , application.debugDescription );
272
+ XCTFail (@" Failed to find the _onMarkerDragEnd." );
273
+ }
274
+ XCTAssertTrue (dragEnd.exists );
275
+ }
276
+
212
277
@end
0 commit comments