mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 21:32:34 +00:00
Fix LiveLocationReceiver interface and update tests
This commit is contained in:
+1
-1
@@ -11,5 +11,5 @@ import io.element.android.features.location.api.Location
|
|||||||
|
|
||||||
interface LiveLocationReceiver {
|
interface LiveLocationReceiver {
|
||||||
suspend fun onLocationUpdate(location: Location)
|
suspend fun onLocationUpdate(location: Location)
|
||||||
suspend fun onUnrecoverableError() {}
|
suspend fun onUnrecoverableError()
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-6
@@ -27,7 +27,7 @@ class LiveLocationSharingCoordinatorTest {
|
|||||||
nowMillis = { 0L },
|
nowMillis = { 0L },
|
||||||
)
|
)
|
||||||
|
|
||||||
coordinator.register(A_SESSION_ID, LiveLocationReceiver { })
|
coordinator.register(A_SESSION_ID, liveLocationReceiver())
|
||||||
coordinator.unregister(A_SESSION_ID)
|
coordinator.unregister(A_SESSION_ID)
|
||||||
|
|
||||||
assertThat(startCount).isEqualTo(1)
|
assertThat(startCount).isEqualTo(1)
|
||||||
@@ -43,8 +43,8 @@ class LiveLocationSharingCoordinatorTest {
|
|||||||
nowMillis = { 4_000L },
|
nowMillis = { 4_000L },
|
||||||
)
|
)
|
||||||
|
|
||||||
coordinator.register(A_SESSION_ID) { error("boom") }
|
coordinator.register(A_SESSION_ID, liveLocationReceiver { error("boom") })
|
||||||
coordinator.register(A_SESSION_ID_2) { location -> delivered += location }
|
coordinator.register(A_SESSION_ID_2, liveLocationReceiver { delivered += it })
|
||||||
coordinator.dispatch(Location(lat = 1.0, lon = 2.0, accuracy = 3f))
|
coordinator.dispatch(Location(lat = 1.0, lon = 2.0, accuracy = 3f))
|
||||||
|
|
||||||
assertThat(delivered).containsExactly(Location(lat = 1.0, lon = 2.0, accuracy = 3f))
|
assertThat(delivered).containsExactly(Location(lat = 1.0, lon = 2.0, accuracy = 3f))
|
||||||
@@ -60,7 +60,7 @@ class LiveLocationSharingCoordinatorTest {
|
|||||||
nowMillis = { nowMillis },
|
nowMillis = { nowMillis },
|
||||||
)
|
)
|
||||||
|
|
||||||
coordinator.register(A_SESSION_ID) { location -> delivered += location }
|
coordinator.register(A_SESSION_ID, liveLocationReceiver { delivered += it })
|
||||||
|
|
||||||
val firstLocation = Location(lat = 1.0, lon = 2.0, accuracy = 3f)
|
val firstLocation = Location(lat = 1.0, lon = 2.0, accuracy = 3f)
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ class LiveLocationSharingCoordinatorTest {
|
|||||||
nowMillis = { nowMillis },
|
nowMillis = { nowMillis },
|
||||||
)
|
)
|
||||||
|
|
||||||
coordinator.register(A_SESSION_ID) { location -> delivered += location }
|
coordinator.register(A_SESSION_ID, liveLocationReceiver { delivered += it })
|
||||||
|
|
||||||
val firstLocation = Location(lat = 1.0, lon = 2.0, accuracy = 3f)
|
val firstLocation = Location(lat = 1.0, lon = 2.0, accuracy = 3f)
|
||||||
val secondLocation = Location(lat = 4.0, lon = 5.0, accuracy = 6f)
|
val secondLocation = Location(lat = 4.0, lon = 5.0, accuracy = 6f)
|
||||||
@@ -101,7 +101,7 @@ class LiveLocationSharingCoordinatorTest {
|
|||||||
nowMillis = { nowMillis },
|
nowMillis = { nowMillis },
|
||||||
)
|
)
|
||||||
|
|
||||||
coordinator.register(A_SESSION_ID) { location -> delivered += location }
|
coordinator.register(A_SESSION_ID, liveLocationReceiver { delivered += it })
|
||||||
|
|
||||||
val firstLocation = Location(lat = 1.0, lon = 2.0, accuracy = 3f)
|
val firstLocation = Location(lat = 1.0, lon = 2.0, accuracy = 3f)
|
||||||
val secondLocation = Location(lat = 4.0, lon = 5.0, accuracy = 6f)
|
val secondLocation = Location(lat = 4.0, lon = 5.0, accuracy = 6f)
|
||||||
@@ -113,3 +113,10 @@ class LiveLocationSharingCoordinatorTest {
|
|||||||
assertThat(delivered).containsExactly(firstLocation, secondLocation).inOrder()
|
assertThat(delivered).containsExactly(firstLocation, secondLocation).inOrder()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun liveLocationReceiver(
|
||||||
|
onLocation: suspend (Location) -> Unit = {},
|
||||||
|
) = object : LiveLocationReceiver {
|
||||||
|
override suspend fun onLocationUpdate(location: Location) = onLocation(location)
|
||||||
|
override suspend fun onUnrecoverableError() = Unit
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user