summaryrefslogtreecommitdiffhomepage
path: root/android/lib/model/src/test
diff options
context:
space:
mode:
authorDavid Göransson <david.goransson@mullvad.net>2024-03-20 14:01:03 +0100
committerDavid Göransson <david.goransson@mullvad.net>2024-03-22 10:55:42 +0100
commit9d35783e89d662def96e9848641193ff7a3a7810 (patch)
treeea4095ee769eb7b8d31ccee13dcbccdb0508367c /android/lib/model/src/test
parent585c6533122ca88315d47895bbd3f883ad7edfdf (diff)
downloadmullvadvpn-9d35783e89d662def96e9848641193ff7a3a7810.tar.xz
mullvadvpn-9d35783e89d662def96e9848641193ff7a3a7810.zip
Base animation duration on actual distance estimation
Diffstat (limited to 'android/lib/model/src/test')
-rw-r--r--android/lib/model/src/test/kotlin/net/mullvad/mullvadvpn/model/LatLongTest.kt25
1 files changed, 23 insertions, 2 deletions
diff --git a/android/lib/model/src/test/kotlin/net/mullvad/mullvadvpn/model/LatLongTest.kt b/android/lib/model/src/test/kotlin/net/mullvad/mullvadvpn/model/LatLongTest.kt
index 6644e25e82..b8608ca55c 100644
--- a/android/lib/model/src/test/kotlin/net/mullvad/mullvadvpn/model/LatLongTest.kt
+++ b/android/lib/model/src/test/kotlin/net/mullvad/mullvadvpn/model/LatLongTest.kt
@@ -2,12 +2,13 @@ package net.mullvad.mullvadvpn.model
import kotlin.math.sqrt
import org.junit.jupiter.api.Assertions.assertEquals
+import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test
class LatLongTest {
@Test
- fun `distance between two LatLong should be same as hypotenuse`() {
+ fun `degree distance between two LatLong should be same as hypotenuse`() {
val latLong1 = LatLong(Latitude(30f), Longitude(40f))
val latLong2 = LatLong(Latitude(-40f), Longitude(170f))
@@ -15,6 +16,26 @@ class LatLongTest {
val longDiff = latLong1.longitude.distanceTo(latLong2.longitude)
val hypotenuse = sqrt(latDiff * latDiff + longDiff * longDiff)
- assertEquals(hypotenuse, latLong1.distanceTo(latLong2))
+ assertEquals(hypotenuse, latLong1.degreeDistanceTo(latLong2))
+ }
+
+ @Test
+ fun `ensure seppDistance respects lateral value`() {
+ // Malmö & New York is a shorter distance than Malmö & Johannesburg, but the degree
+ // difference is larger since they are at a higher latitude.
+
+ // Malmo 55.6050° N, 13.0038° E
+ val malmo = LatLong(Latitude(55.6050f), Longitude(13.0038f))
+
+ // New York 40.7128° N, 74.0060° W
+ val newYork = LatLong(Latitude(40.7128f), Longitude(-74.0060f))
+
+ // Johannesburg 26.2041° S, 28.0473° E
+ val johannesburg = LatLong(Latitude(-26.2041f), Longitude(28.0473f))
+
+ val malmoToNewYork = malmo.seppDistanceTo(newYork)
+ val malmoToJohannesburg = malmo.seppDistanceTo(johannesburg)
+
+ assertTrue { malmoToNewYork < malmoToJohannesburg }
}
}