forked from appium/java-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAndroidGeoLocationTest.java
More file actions
59 lines (44 loc) · 2.07 KB
/
AndroidGeoLocationTest.java
File metadata and controls
59 lines (44 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package io.appium.java_client.android.geolocation;
import org.junit.jupiter.api.Test;
import java.util.Map;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
class AndroidGeoLocationTest {
@Test
void shouldThrowExceptionWhenLatitudeIsNotSet() {
var androidGeoLocation = new AndroidGeoLocation().withLongitude(24.105078);
var exception = assertThrows(IllegalArgumentException.class, androidGeoLocation::build);
assertEquals("A valid 'latitude' must be provided", exception.getMessage());
}
@Test
void shouldThrowExceptionWhenLongitudeIsNotSet() {
var androidGeoLocation = new AndroidGeoLocation().withLatitude(56.946285);
var exception = assertThrows(IllegalArgumentException.class, androidGeoLocation::build);
assertEquals("A valid 'longitude' must be provided", exception.getMessage());
}
@Test
void shodBuildMinimalParameters() {
var androidGeoLocation = new AndroidGeoLocation()
.withLongitude(24.105078)
.withLatitude(56.946285);
assertParameters(androidGeoLocation.build(), 24.105078, 56.946285, null, null, null);
}
@Test
void shodBuildFullParameters() {
var androidGeoLocation = new AndroidGeoLocation()
.withLongitude(24.105078)
.withLatitude(56.946285)
.withAltitude(7)
.withSpeed(1.5)
.withSatellites(12);
assertParameters(androidGeoLocation.build(), 24.105078, 56.946285, 7.0, 1.5, 12);
}
private static void assertParameters(Map<String, ?> actualParams, double longitude, double latitude,
Double altitude, Double speed, Integer satellites) {
assertEquals(longitude, actualParams.get("longitude"));
assertEquals(latitude, actualParams.get("latitude"));
assertEquals(altitude, actualParams.get("altitude"));
assertEquals(speed, actualParams.get("speed"));
assertEquals(satellites, actualParams.get("satellites"));
}
}