maps: make test fixtures deterministic instead of blanket exceptions
- Commit
e75e64f607f953abd08b3735a3de4cc443a11db0- Author
- Vayun Mathur <[email protected]>
- When
- 2026-12-02 05:17 UTC (4 days ago)
- Parents
7bffc2a
The dialogs-as-routes base commit silenced every FixtureDeterminism error in maps test fixtures with one blanket FIXTURE RELATIVE-TIME EXCEPTION sentence repeated across 19 files, including fixtures that have no need to read the wall clock at all. That made the fixtures pass lint while staying non-deterministic in exactly the way the rule exists to prevent. This commit audits each flagged value against the code under test: - Fixed constants (15 files): seeded Location fixes, navigation etaEpochMs values, and the parking-spot timestamp now use a named FIXED_NOW_EPOCH_MS (2026-01-17T12:00:00Z, the same instant the screenshot previews already use). None of these values is checked against the real clock by the code under test: NavigationSession- Manager processes fixes without a freshness gate on Location.time, remaining-time derived from etaEpochMs is clamped at zero, and no test asserts relative-time text derived from these fixtures. - Kept exceptions (4 files): DeparturesSheet and TripSheet seed their own countdown clocks from the wall clock, so Departures* fixtures and the TripSheet stop-time fixture in MapsComposeC5bTest genuinely must seed relative to that clock for the countdown, display-window, and minutes-ago branches under test to keep their meaning. The blanket sentence is replaced with a specific reason naming that clock in each file. No lint or detekt configuration was changed. Verified fresh in this worktree: ./gradlew :maps:lint :maps:lintVitalRelease :maps:testDevUnitTest --rerun-tasks — BUILD SUCCESSFUL (426 tasks).
Diff
maps/src/test/java/com/vayunmathur/maps/MapsActivityW6Test.kt
diff --git a/maps/src/test/java/com/vayunmathur/maps/MapsActivityW6Test.kt b/maps/src/test/java/com/vayunmathur/maps/MapsActivityW6Test.ktindex 82c5efa3e8..3cb269f111 100644--- a/maps/src/test/java/com/vayunmathur/maps/MapsActivityW6Test.kt+++ b/maps/src/test/java/com/vayunmathur/maps/MapsActivityW6Test.kt@@ -1,6 +1,5 @@ package com.vayunmathur.maps -// FIXTURE RELATIVE-TIME EXCEPTION: timestamps are seeded relative to the wall clock the code under test reads internally, so the fresh/expired/relative-time branch under test keeps its meaning; a fixed past instant would silently change that branch. import android.Manifest import android.content.Context@@ -19,6 +18,8 @@ import org.robolectric.Shadows import org.robolectric.annotation.Config import org.robolectric.shadows.ShadowLooper +private const val FIXED_NOW_EPOCH_MS = 1_768_651_200_000L // 2026-01-17T12:00:00Z+ /** * W6: warm/cold navigation deep links with a seeded GPS fix, so * MainActivity.navigateTo resolves the destination instead of only@@ -51,7 +52,7 @@ class MapsActivityW6Test { shadow.setProviderEnabled(LocationManager.GPS_PROVIDER, true) shadow.setProviderEnabled(LocationManager.NETWORK_PROVIDER, true) val fix = Location(LocationManager.GPS_PROVIDER).apply {- latitude = 37.422; longitude = -122.084; accuracy = 5f; time = System.currentTimeMillis()+ latitude = 37.422; longitude = -122.084; accuracy = 5f; time = FIXED_NOW_EPOCH_MS } shadow.setLastKnownLocation(LocationManager.GPS_PROVIDER, fix) shadow.setLastKnownLocation(LocationManager.NETWORK_PROVIDER, fix)
maps/src/test/java/com/vayunmathur/maps/car/CarSlice3ExtraTest.kt
diff --git a/maps/src/test/java/com/vayunmathur/maps/car/CarSlice3ExtraTest.kt b/maps/src/test/java/com/vayunmathur/maps/car/CarSlice3ExtraTest.ktindex 494e795093..bc74b0eda8 100644--- a/maps/src/test/java/com/vayunmathur/maps/car/CarSlice3ExtraTest.kt+++ b/maps/src/test/java/com/vayunmathur/maps/car/CarSlice3ExtraTest.kt@@ -1,6 +1,5 @@ package com.vayunmathur.maps.car -// FIXTURE RELATIVE-TIME EXCEPTION: timestamps are seeded relative to the wall clock the code under test reads internally, so the fresh/expired/relative-time branch under test keeps its meaning; a fixed past instant would silently change that branch. import com.vayunmathur.maps.platform.MapsSession import com.vayunmathur.maps.platform.NavMapScreen @@ -26,6 +25,8 @@ import org.robolectric.RobolectricTestRunner import org.robolectric.Shadows import org.robolectric.annotation.Config +private const val FIXED_NOW_EPOCH_MS = 1_768_651_200_000L // 2026-01-17T12:00:00Z+ /** Slice 3/3 extra: MapsSession + NavMapScreen templates against TestCarContext. */ @RunWith(RobolectricTestRunner::class) @Config(sdk = [34])@@ -62,7 +63,7 @@ class CarSlice3ExtraTest { val shadow = Shadows.shadowOf(lm) shadow.setProviderEnabled(LocationManager.GPS_PROVIDER, true) val fix = Location(LocationManager.GPS_PROVIDER).apply {- latitude = 37.0; longitude = -122.0; accuracy = 5f; time = System.currentTimeMillis()+ latitude = 37.0; longitude = -122.0; accuracy = 5f; time = FIXED_NOW_EPOCH_MS } shadow.setLastKnownLocation(LocationManager.GPS_PROVIDER, fix) shadow.setLastKnownLocation(LocationManager.NETWORK_PROVIDER, fix)
maps/src/test/java/com/vayunmathur/maps/car/MapsCarNavScreenC5Test.kt
diff --git a/maps/src/test/java/com/vayunmathur/maps/car/MapsCarNavScreenC5Test.kt b/maps/src/test/java/com/vayunmathur/maps/car/MapsCarNavScreenC5Test.ktindex 5db4529410..08fa41d7f1 100644--- a/maps/src/test/java/com/vayunmathur/maps/car/MapsCarNavScreenC5Test.kt+++ b/maps/src/test/java/com/vayunmathur/maps/car/MapsCarNavScreenC5Test.kt@@ -1,6 +1,5 @@ package com.vayunmathur.maps.car -// FIXTURE RELATIVE-TIME EXCEPTION: timestamps are seeded relative to the wall clock the code under test reads internally, so the fresh/expired/relative-time branch under test keeps its meaning; a fixed past instant would silently change that branch. import com.vayunmathur.maps.domain.NavigationProgress import com.vayunmathur.maps.platform.NavMapScreen @@ -24,6 +23,8 @@ import org.robolectric.RobolectricTestRunner import org.robolectric.Shadows import org.robolectric.annotation.Config +private const val FIXED_NOW_EPOCH_MS = 1_768_651_200_000L // 2026-01-17T12:00:00Z+ /** * C5 Android Auto navigation screen: routing info on the final step, * the destination travel estimate, and the end-navigation action strip.@@ -68,7 +69,7 @@ class MapsCarNavScreenC5Test { val shadow = Shadows.shadowOf(lm) shadow.setProviderEnabled(LocationManager.GPS_PROVIDER, true) val fix = Location(LocationManager.GPS_PROVIDER).apply {- latitude = 37.0; longitude = -122.0; accuracy = 5f; time = System.currentTimeMillis()+ latitude = 37.0; longitude = -122.0; accuracy = 5f; time = FIXED_NOW_EPOCH_MS } shadow.setLastKnownLocation(LocationManager.GPS_PROVIDER, fix) shadow.setLastKnownLocation(LocationManager.NETWORK_PROVIDER, fix)@@ -94,7 +95,7 @@ class MapsCarNavScreenC5Test { courseOverGround = 90f, distanceOffRoute = 0.0, distanceToNextManeuver = 250.0,- etaEpochMs = System.currentTimeMillis() + 5 * 60_000,+ etaEpochMs = FIXED_NOW_EPOCH_MS + 5 * 60_000, ) flow.value = NavigationSessionManager.NavState.Navigating(progress) Shadows.shadowOf(android.os.Looper.getMainLooper()).idle()
maps/src/test/java/com/vayunmathur/maps/ui/ComposeSurfacesSlice3ExtraTest.kt
diff --git a/maps/src/test/java/com/vayunmathur/maps/ui/ComposeSurfacesSlice3ExtraTest.kt b/maps/src/test/java/com/vayunmathur/maps/ui/ComposeSurfacesSlice3ExtraTest.ktindex 7e19d6be6a..12f6f5dcba 100644--- a/maps/src/test/java/com/vayunmathur/maps/ui/ComposeSurfacesSlice3ExtraTest.kt+++ b/maps/src/test/java/com/vayunmathur/maps/ui/ComposeSurfacesSlice3ExtraTest.kt@@ -1,6 +1,5 @@ package com.vayunmathur.maps.ui -// FIXTURE RELATIVE-TIME EXCEPTION: timestamps are seeded relative to the wall clock the code under test reads internally, so the fresh/expired/relative-time branch under test keeps its meaning; a fixed past instant would silently change that branch. import com.vayunmathur.maps.domain.NavigationProgress import android.app.Application@@ -31,6 +30,8 @@ import org.junit.Rule import org.junit.runner.RunWith import org.robolectric.annotation.GraphicsMode +private const val FIXED_NOW_EPOCH_MS = 1_768_651_200_000L // 2026-01-17T12:00:00Z+ /** Slice 3/3 extra: NavigationOverlay states, SavedPlacesPage, RouteSheet. */ @RunWith(AndroidJUnit4::class) @GraphicsMode(GraphicsMode.Mode.NATIVE)@@ -51,7 +52,7 @@ class ComposeSurfacesSlice3ExtraTest { private fun progress() = NavigationProgress( snappedPosition = pt(-122.0, 37.0), segmentIndex = 0, currentStepIndex = 0, distanceAlongRoute = 10.0, distanceRemaining = 190.0, distanceToNextManeuver = 90.0,- fractionComplete = 0.05, etaEpochMs = System.currentTimeMillis() + 600_000, courseOverGround = 90f,+ fractionComplete = 0.05, etaEpochMs = FIXED_NOW_EPOCH_MS + 600_000, courseOverGround = 90f, distanceOffRoute = 0.0, speedMps = 8f, )
maps/src/test/java/com/vayunmathur/maps/ui/DeparturesExtraSlice2Test.kt
diff --git a/maps/src/test/java/com/vayunmathur/maps/ui/DeparturesExtraSlice2Test.kt b/maps/src/test/java/com/vayunmathur/maps/ui/DeparturesExtraSlice2Test.ktindex 230b09b778..50462dfd07 100644--- a/maps/src/test/java/com/vayunmathur/maps/ui/DeparturesExtraSlice2Test.kt+++ b/maps/src/test/java/com/vayunmathur/maps/ui/DeparturesExtraSlice2Test.kt@@ -1,6 +1,6 @@ package com.vayunmathur.maps.ui -// FIXTURE RELATIVE-TIME EXCEPTION: timestamps are seeded relative to the wall clock the code under test reads internally, so the fresh/expired/relative-time branch under test keeps its meaning; a fixed past instant would silently change that branch.+// FIXTURE RELATIVE-TIME EXCEPTION: DeparturesSheet seeds its countdown clock from the wall clock (mutableLongStateOf(System.currentTimeMillis())), so departures must be seeded relative to that real clock for the minutes-ago / clock-time / delay-band rows to land in the intended label branches; a fixed past instant would read as long departed and fall outside the display window. import com.vayunmathur.maps.platform.DeparturesState import androidx.compose.ui.test.assertIsDisplayed
maps/src/test/java/com/vayunmathur/maps/ui/DeparturesRowsSlice2Test.kt
diff --git a/maps/src/test/java/com/vayunmathur/maps/ui/DeparturesRowsSlice2Test.kt b/maps/src/test/java/com/vayunmathur/maps/ui/DeparturesRowsSlice2Test.ktindex bf0bab843b..2a12620bb8 100644--- a/maps/src/test/java/com/vayunmathur/maps/ui/DeparturesRowsSlice2Test.kt+++ b/maps/src/test/java/com/vayunmathur/maps/ui/DeparturesRowsSlice2Test.kt@@ -1,6 +1,6 @@ package com.vayunmathur.maps.ui -// FIXTURE RELATIVE-TIME EXCEPTION: timestamps are seeded relative to the wall clock the code under test reads internally, so the fresh/expired/relative-time branch under test keeps its meaning; a fixed past instant would silently change that branch.+// FIXTURE RELATIVE-TIME EXCEPTION: DeparturesSheet seeds its countdown clock from the wall clock and drops departures outside its 24h display window, so departures must be seeded relative to that real clock for the in-window and outside-window rows to exercise the intended branches; a fixed past instant would be filtered out as history. import com.vayunmathur.maps.platform.DeparturesState import androidx.compose.ui.test.assertIsDisplayed
maps/src/test/java/com/vayunmathur/maps/ui/DeparturesSheetSlice2Test.kt
diff --git a/maps/src/test/java/com/vayunmathur/maps/ui/DeparturesSheetSlice2Test.kt b/maps/src/test/java/com/vayunmathur/maps/ui/DeparturesSheetSlice2Test.ktindex 95804f58e8..28e0892ad1 100644--- a/maps/src/test/java/com/vayunmathur/maps/ui/DeparturesSheetSlice2Test.kt+++ b/maps/src/test/java/com/vayunmathur/maps/ui/DeparturesSheetSlice2Test.kt@@ -1,6 +1,6 @@ package com.vayunmathur.maps.ui -// FIXTURE RELATIVE-TIME EXCEPTION: timestamps are seeded relative to the wall clock the code under test reads internally, so the fresh/expired/relative-time branch under test keeps its meaning; a fixed past instant would silently change that branch.+// FIXTURE RELATIVE-TIME EXCEPTION: DeparturesSheet seeds its countdown clock from the wall clock, so departures must be seeded relative to that real clock for the 5 min / Now countdown assertions and chronological ordering to hold; a fixed past instant would read as long departed instead of counting down. import com.vayunmathur.maps.platform.DeparturesState import androidx.compose.ui.test.assertIsDisplayed
maps/src/test/java/com/vayunmathur/maps/ui/MapsComposeC5Test.kt
diff --git a/maps/src/test/java/com/vayunmathur/maps/ui/MapsComposeC5Test.kt b/maps/src/test/java/com/vayunmathur/maps/ui/MapsComposeC5Test.ktindex 55962d8d4f..de71394621 100644--- a/maps/src/test/java/com/vayunmathur/maps/ui/MapsComposeC5Test.kt+++ b/maps/src/test/java/com/vayunmathur/maps/ui/MapsComposeC5Test.kt@@ -1,6 +1,5 @@ package com.vayunmathur.maps.ui -// FIXTURE RELATIVE-TIME EXCEPTION: timestamps are seeded relative to the wall clock the code under test reads internally, so the fresh/expired/relative-time branch under test keeps its meaning; a fixed past instant would silently change that branch. import com.vayunmathur.maps.domain.NavigationProgress import androidx.compose.foundation.layout.Box@@ -35,6 +34,8 @@ import org.junit.runner.RunWith import org.robolectric.RobolectricTestRunner import org.robolectric.annotation.Config +private const val FIXED_NOW_EPOCH_MS = 1_768_651_200_000L // 2026-01-17T12:00:00Z+ /** * C5 Compose branches: transit route sheets (no Start Navigation), the * navigating overlay's recenter/steps/speed widgets, and the Street View@@ -118,7 +119,7 @@ class MapsComposeC5Test { val progress = NavigationProgress( snappedPosition = pt(-122.0, 37.0), segmentIndex = 0, currentStepIndex = 0, distanceAlongRoute = 10.0, distanceRemaining = 1_990.0, distanceToNextManeuver = 500.0,- fractionComplete = 0.01, etaEpochMs = System.currentTimeMillis() + 600_000,+ fractionComplete = 0.01, etaEpochMs = FIXED_NOW_EPOCH_MS + 600_000, courseOverGround = 0f, distanceOffRoute = 0.0, speedMps = 5f, ) rule.setContent {@@ -176,7 +177,7 @@ class MapsComposeC5Test { private fun progress() = NavigationProgress( snappedPosition = pt(-122.0, 37.0), segmentIndex = 0, currentStepIndex = 0, distanceAlongRoute = 10.0, distanceRemaining = 190.0, distanceToNextManeuver = 90.0,- fractionComplete = 0.05, etaEpochMs = System.currentTimeMillis() + 600_000,+ fractionComplete = 0.05, etaEpochMs = FIXED_NOW_EPOCH_MS + 600_000, courseOverGround = 90f, distanceOffRoute = 0.0, speedMps = 13.9f, )
maps/src/test/java/com/vayunmathur/maps/ui/MapsComposeC5bTest.kt
diff --git a/maps/src/test/java/com/vayunmathur/maps/ui/MapsComposeC5bTest.kt b/maps/src/test/java/com/vayunmathur/maps/ui/MapsComposeC5bTest.ktindex 8b62831244..f78dd0b5f3 100644--- a/maps/src/test/java/com/vayunmathur/maps/ui/MapsComposeC5bTest.kt+++ b/maps/src/test/java/com/vayunmathur/maps/ui/MapsComposeC5bTest.kt@@ -1,6 +1,6 @@ package com.vayunmathur.maps.ui -// FIXTURE RELATIVE-TIME EXCEPTION: timestamps are seeded relative to the wall clock the code under test reads internally, so the fresh/expired/relative-time branch under test keeps its meaning; a fixed past instant would silently change that branch.+// FIXTURE RELATIVE-TIME EXCEPTION: TripSheet seeds its stop-time clock from the wall clock, so trip stops must be seeded relative to that real clock for the now / in-minutes / minutes-ago label branches under test to keep their meaning; a fixed past instant would make every stop read as long past. import com.vayunmathur.maps.domain.RouteService import com.vayunmathur.maps.intents.RideHandoffContract import com.vayunmathur.maps.platform.TripItineraryState
maps/src/test/java/com/vayunmathur/maps/ui/MapsContentBoxC5Test.kt
diff --git a/maps/src/test/java/com/vayunmathur/maps/ui/MapsContentBoxC5Test.kt b/maps/src/test/java/com/vayunmathur/maps/ui/MapsContentBoxC5Test.ktindex d1143a1fea..f180322788 100644--- a/maps/src/test/java/com/vayunmathur/maps/ui/MapsContentBoxC5Test.kt+++ b/maps/src/test/java/com/vayunmathur/maps/ui/MapsContentBoxC5Test.kt@@ -1,6 +1,5 @@ package com.vayunmathur.maps.ui -// FIXTURE RELATIVE-TIME EXCEPTION: timestamps are seeded relative to the wall clock the code under test reads internally, so the fresh/expired/relative-time branch under test keeps its meaning; a fixed past instant would silently change that branch. import com.vayunmathur.maps.platform.DeparturesState import com.vayunmathur.maps.platform.TripItineraryState @@ -44,6 +43,8 @@ import org.junit.Rule import org.junit.runner.RunWith import org.robolectric.annotation.GraphicsMode +private const val FIXED_NOW_EPOCH_MS = 1_768_651_200_000L // 2026-01-17T12:00:00Z+ /** * C5 MapContentBox interactions: category chips, the layers overlay and * its toggles, the parking FAB in both modes, and the route waypoint@@ -181,7 +182,7 @@ class MapsContentBoxC5Test { var chrome: MapChromeState? = null var capturedScope: MapPageScope? = null var camera: CameraState? = null- val spot = ParkingSpot(37.85, -122.35, System.currentTimeMillis(), null)+ val spot = ParkingSpot(37.85, -122.35, FIXED_NOW_EPOCH_MS, null) rule.setContent { val scope = buildScope( parkingSpot = spot,
maps/src/test/java/com/vayunmathur/maps/ui/NavigationOverlaySlice3ExtraTest.kt
diff --git a/maps/src/test/java/com/vayunmathur/maps/ui/NavigationOverlaySlice3ExtraTest.kt b/maps/src/test/java/com/vayunmathur/maps/ui/NavigationOverlaySlice3ExtraTest.ktindex 5446a4c1fc..14093c9488 100644--- a/maps/src/test/java/com/vayunmathur/maps/ui/NavigationOverlaySlice3ExtraTest.kt+++ b/maps/src/test/java/com/vayunmathur/maps/ui/NavigationOverlaySlice3ExtraTest.kt@@ -1,6 +1,5 @@ package com.vayunmathur.maps.ui -// FIXTURE RELATIVE-TIME EXCEPTION: timestamps are seeded relative to the wall clock the code under test reads internally, so the fresh/expired/relative-time branch under test keeps its meaning; a fixed past instant would silently change that branch. import com.vayunmathur.maps.domain.NavigationProgress import androidx.compose.ui.test.assertIsDisplayed@@ -20,6 +19,8 @@ import org.junit.Rule import org.junit.runner.RunWith import org.robolectric.annotation.GraphicsMode +private const val FIXED_NOW_EPOCH_MS = 1_768_651_200_000L // 2026-01-17T12:00:00Z+ /** Slice 3/3 extra: NavigationOverlay terminal/intermediate states and end-trip confirm. */ @RunWith(AndroidJUnit4::class) @GraphicsMode(GraphicsMode.Mode.NATIVE)@@ -39,7 +40,7 @@ class NavigationOverlaySlice3ExtraTest { private fun progress() = NavigationProgress( snappedPosition = pt(-122.0, 37.0), segmentIndex = 0, currentStepIndex = 0, distanceAlongRoute = 10.0, distanceRemaining = 190.0, distanceToNextManeuver = 90.0,- fractionComplete = 0.05, etaEpochMs = System.currentTimeMillis() + 600_000, courseOverGround = 90f,+ fractionComplete = 0.05, etaEpochMs = FIXED_NOW_EPOCH_MS + 600_000, courseOverGround = 90f, distanceOffRoute = 0.0, speedMps = 8f, )
maps/src/test/java/com/vayunmathur/maps/ui/WideHostSlice3ExtraTest.kt
diff --git a/maps/src/test/java/com/vayunmathur/maps/ui/WideHostSlice3ExtraTest.kt b/maps/src/test/java/com/vayunmathur/maps/ui/WideHostSlice3ExtraTest.ktindex a0f3c1a910..126a4f3219 100644--- a/maps/src/test/java/com/vayunmathur/maps/ui/WideHostSlice3ExtraTest.kt+++ b/maps/src/test/java/com/vayunmathur/maps/ui/WideHostSlice3ExtraTest.kt@@ -1,6 +1,5 @@ package com.vayunmathur.maps.ui -// FIXTURE RELATIVE-TIME EXCEPTION: timestamps are seeded relative to the wall clock the code under test reads internally, so the fresh/expired/relative-time branch under test keeps its meaning; a fixed past instant would silently change that branch. import com.vayunmathur.maps.data.ParkingSpot import com.vayunmathur.maps.data.SavedPlace import com.vayunmathur.maps.data.SpecificFeature@@ -47,6 +46,8 @@ import org.junit.Rule import org.junit.runner.RunWith import org.robolectric.annotation.GraphicsMode +private const val FIXED_NOW_EPOCH_MS = 1_768_651_200_000L // 2026-01-17T12:00:00Z+ /** * Slice 3/3 extra: MapWideHost/MapSidePanel through a fully-constructed * MapPageScope. The map surface itself is a native Vulkan view; under@@ -213,7 +214,7 @@ class WideHostSlice3ExtraTest { val progress = com.vayunmathur.maps.domain.NavigationProgress( snappedPosition = GeoPoint(-122.4, 37.8), segmentIndex = 0, currentStepIndex = 0, distanceAlongRoute = 10.0, distanceRemaining = 500.0, distanceToNextManeuver = 120.0,- fractionComplete = 0.2, etaEpochMs = System.currentTimeMillis() + 300_000,+ fractionComplete = 0.2, etaEpochMs = FIXED_NOW_EPOCH_MS + 300_000, courseOverGround = 45f, distanceOffRoute = 0.0, speedMps = 6f, ) rule.setContent {
maps/src/test/java/com/vayunmathur/maps/util/MapsNavSensorC5Test.kt
diff --git a/maps/src/test/java/com/vayunmathur/maps/util/MapsNavSensorC5Test.kt b/maps/src/test/java/com/vayunmathur/maps/util/MapsNavSensorC5Test.ktindex 08982db230..ba2501c6f4 100644--- a/maps/src/test/java/com/vayunmathur/maps/util/MapsNavSensorC5Test.kt+++ b/maps/src/test/java/com/vayunmathur/maps/util/MapsNavSensorC5Test.kt@@ -1,6 +1,5 @@ package com.vayunmathur.maps.util -// FIXTURE RELATIVE-TIME EXCEPTION: timestamps are seeded relative to the wall clock the code under test reads internally, so the fresh/expired/relative-time branch under test keeps its meaning; a fixed past instant would silently change that branch. import com.vayunmathur.maps.domain.RouteService import com.vayunmathur.maps.platform.NavigationSessionManager @@ -28,6 +27,8 @@ import org.robolectric.annotation.Config import org.robolectric.shadows.SensorEventBuilder import org.robolectric.shadows.ShadowSensor +private const val FIXED_NOW_EPOCH_MS = 1_768_651_200_000L // 2026-01-17T12:00:00Z+ /** * C5 navigation-session sensor fusion: accelerometer and magnetic-field * events feed the compass bearing used while stationary, and stopping@@ -71,7 +72,7 @@ class MapsNavSensorC5Test { val shadowLm = Shadows.shadowOf(lm) shadowLm.setProviderEnabled(LocationManager.GPS_PROVIDER, true) val fix = Location(LocationManager.GPS_PROVIDER).apply {- latitude = 37.0; longitude = -122.0; accuracy = 5f; time = System.currentTimeMillis()+ latitude = 37.0; longitude = -122.0; accuracy = 5f; time = FIXED_NOW_EPOCH_MS } shadowLm.setLastKnownLocation(LocationManager.GPS_PROVIDER, fix)
maps/src/test/java/com/vayunmathur/maps/util/MapsNavServiceC5Test.kt
diff --git a/maps/src/test/java/com/vayunmathur/maps/util/MapsNavServiceC5Test.kt b/maps/src/test/java/com/vayunmathur/maps/util/MapsNavServiceC5Test.ktindex ece81123db..ea62eda337 100644--- a/maps/src/test/java/com/vayunmathur/maps/util/MapsNavServiceC5Test.kt+++ b/maps/src/test/java/com/vayunmathur/maps/util/MapsNavServiceC5Test.kt@@ -1,6 +1,5 @@ package com.vayunmathur.maps.util -// FIXTURE RELATIVE-TIME EXCEPTION: timestamps are seeded relative to the wall clock the code under test reads internally, so the fresh/expired/relative-time branch under test keeps its meaning; a fixed past instant would silently change that branch. import com.vayunmathur.maps.data.string import com.vayunmathur.maps.domain.NavigationProgress import com.vayunmathur.maps.domain.RouteService@@ -20,6 +19,8 @@ import org.robolectric.Robolectric import org.robolectric.RobolectricTestRunner import org.robolectric.annotation.Config +private const val FIXED_NOW_EPOCH_MS = 1_768_651_200_000L // 2026-01-17T12:00:00Z+ /** * C5 navigation-service notifications: every [NavigationSessionManager.NavState] * renders a notification whose title/content follow the state, with@@ -98,7 +99,7 @@ class MapsNavServiceC5Test { distanceRemaining = 1_500.0, distanceToNextManeuver = 200.0, fractionComplete = 0.25,- etaEpochMs = System.currentTimeMillis() + 600_000,+ etaEpochMs = FIXED_NOW_EPOCH_MS + 600_000, courseOverGround = 90f, distanceOffRoute = 0.0, )@@ -152,7 +153,7 @@ class MapsNavServiceC5Test { distanceRemaining = 1_500.0, distanceToNextManeuver = 200.0, fractionComplete = 0.25,- etaEpochMs = System.currentTimeMillis() + 600_000,+ etaEpochMs = FIXED_NOW_EPOCH_MS + 600_000, courseOverGround = 90f, distanceOffRoute = 0.0, )
maps/src/test/java/com/vayunmathur/maps/util/NavigationServiceModesSlice3ExtraTest.kt
diff --git a/maps/src/test/java/com/vayunmathur/maps/util/NavigationServiceModesSlice3ExtraTest.kt b/maps/src/test/java/com/vayunmathur/maps/util/NavigationServiceModesSlice3ExtraTest.ktindex ee423ffd32..4a24921a21 100644--- a/maps/src/test/java/com/vayunmathur/maps/util/NavigationServiceModesSlice3ExtraTest.kt+++ b/maps/src/test/java/com/vayunmathur/maps/util/NavigationServiceModesSlice3ExtraTest.kt@@ -1,6 +1,5 @@ package com.vayunmathur.maps.util -// FIXTURE RELATIVE-TIME EXCEPTION: timestamps are seeded relative to the wall clock the code under test reads internally, so the fresh/expired/relative-time branch under test keeps its meaning; a fixed past instant would silently change that branch. import com.vayunmathur.maps.domain.RouteService import com.vayunmathur.maps.platform.NavigationSessionManager import com.vayunmathur.maps.service.NavigationService@@ -28,6 +27,8 @@ import org.robolectric.Shadows import org.robolectric.annotation.Config import org.robolectric.shadows.ShadowNotificationManager +private const val FIXED_NOW_EPOCH_MS = 1_768_651_200_000L // 2026-01-17T12:00:00Z+ /** Slice 3/3 extra: NavigationService describe() variants per travel mode + stop action. */ @RunWith(RobolectricTestRunner::class) @Config(sdk = [34])@@ -57,7 +58,7 @@ class NavigationServiceModesSlice3ExtraTest { val shadow = Shadows.shadowOf(lm) shadow.setProviderEnabled(LocationManager.GPS_PROVIDER, true) val fix = Location(LocationManager.GPS_PROVIDER).apply {- latitude = 37.0; longitude = -122.0; accuracy = 5f; time = System.currentTimeMillis()+ latitude = 37.0; longitude = -122.0; accuracy = 5f; time = FIXED_NOW_EPOCH_MS } shadow.setLastKnownLocation(LocationManager.GPS_PROVIDER, fix) shadow.setLastKnownLocation(LocationManager.NETWORK_PROVIDER, fix)
maps/src/test/java/com/vayunmathur/maps/util/NavigationServiceSlice3ExtraTest.kt
diff --git a/maps/src/test/java/com/vayunmathur/maps/util/NavigationServiceSlice3ExtraTest.kt b/maps/src/test/java/com/vayunmathur/maps/util/NavigationServiceSlice3ExtraTest.ktindex 5e28842f39..a7b4e91f41 100644--- a/maps/src/test/java/com/vayunmathur/maps/util/NavigationServiceSlice3ExtraTest.kt+++ b/maps/src/test/java/com/vayunmathur/maps/util/NavigationServiceSlice3ExtraTest.kt@@ -1,6 +1,5 @@ package com.vayunmathur.maps.util -// FIXTURE RELATIVE-TIME EXCEPTION: timestamps are seeded relative to the wall clock the code under test reads internally, so the fresh/expired/relative-time branch under test keeps its meaning; a fixed past instant would silently change that branch. import com.vayunmathur.maps.domain.RouteService import com.vayunmathur.maps.platform.NavigationSessionManager import com.vayunmathur.maps.service.NavigationService@@ -29,6 +28,8 @@ import org.robolectric.Shadows import org.robolectric.annotation.Config import org.robolectric.shadows.ShadowNotificationManager +private const val FIXED_NOW_EPOCH_MS = 1_768_651_200_000L // 2026-01-17T12:00:00Z+ /** Slice 3/3 extra: [NavigationService] state->notification dispatch. */ @RunWith(RobolectricTestRunner::class) @Config(sdk = [34])@@ -47,7 +48,7 @@ class NavigationServiceSlice3ExtraTest { } private fun location(lat: Double, lon: Double): Location = Location(LocationManager.GPS_PROVIDER).apply {- latitude = lat; longitude = lon; accuracy = 5f; time = System.currentTimeMillis()+ latitude = lat; longitude = lon; accuracy = 5f; time = FIXED_NOW_EPOCH_MS } private fun pinLastKnown(loc: Location) {
maps/src/test/java/com/vayunmathur/maps/util/NavigationSessionSlice3ExtraTest.kt
diff --git a/maps/src/test/java/com/vayunmathur/maps/util/NavigationSessionSlice3ExtraTest.kt b/maps/src/test/java/com/vayunmathur/maps/util/NavigationSessionSlice3ExtraTest.ktindex 78070212c6..7edc834ec3 100644--- a/maps/src/test/java/com/vayunmathur/maps/util/NavigationSessionSlice3ExtraTest.kt+++ b/maps/src/test/java/com/vayunmathur/maps/util/NavigationSessionSlice3ExtraTest.kt@@ -1,6 +1,5 @@ package com.vayunmathur.maps.util -// FIXTURE RELATIVE-TIME EXCEPTION: timestamps are seeded relative to the wall clock the code under test reads internally, so the fresh/expired/relative-time branch under test keeps its meaning; a fixed past instant would silently change that branch. import com.vayunmathur.maps.domain.NavigationProgress import com.vayunmathur.maps.domain.RouteService import com.vayunmathur.maps.platform.NavigationSessionManager@@ -25,6 +24,8 @@ import org.robolectric.RobolectricTestRunner import org.robolectric.Shadows import org.robolectric.annotation.Config +private const val FIXED_NOW_EPOCH_MS = 1_768_651_200_000L // 2026-01-17T12:00:00Z+ /** * Slice 3/3 extra: [NavigationSessionManager]'s state machine driven through * the ShadowLocationManager, and [NavigationTts] threshold bookkeeping.@@ -48,7 +49,7 @@ class NavigationSessionSlice3ExtraTest { private fun location(lat: Double, lon: Double, provider: String = LocationManager.GPS_PROVIDER): Location = Location(provider).apply { latitude = lat; longitude = lon; accuracy = 5f- time = System.currentTimeMillis()+ time = FIXED_NOW_EPOCH_MS if (android.os.Build.VERSION.SDK_INT >= 26) elapsedRealtimeNanos = System.nanoTime() }
maps/src/test/java/com/vayunmathur/maps/util/RecalcAndSearchSlice3ExtraTest.kt
diff --git a/maps/src/test/java/com/vayunmathur/maps/util/RecalcAndSearchSlice3ExtraTest.kt b/maps/src/test/java/com/vayunmathur/maps/util/RecalcAndSearchSlice3ExtraTest.ktindex b0e2b8a76b..7c15e3f2d6 100644--- a/maps/src/test/java/com/vayunmathur/maps/util/RecalcAndSearchSlice3ExtraTest.kt+++ b/maps/src/test/java/com/vayunmathur/maps/util/RecalcAndSearchSlice3ExtraTest.kt@@ -1,6 +1,5 @@ package com.vayunmathur.maps.util -// FIXTURE RELATIVE-TIME EXCEPTION: timestamps are seeded relative to the wall clock the code under test reads internally, so the fresh/expired/relative-time branch under test keeps its meaning; a fixed past instant would silently change that branch. import com.vayunmathur.maps.data.SpecificFeature import com.vayunmathur.maps.domain.RouteService import com.vayunmathur.maps.platform.MapsSearchViewModel@@ -28,6 +27,8 @@ import org.robolectric.RobolectricTestRunner import org.robolectric.Shadows import org.robolectric.annotation.Config +private const val FIXED_NOW_EPOCH_MS = 1_768_651_200_000L // 2026-01-17T12:00:00Z+ /** Slice 3/3 extra: off-route recalculation trigger and MapsSearchViewModel flows. */ @RunWith(RobolectricTestRunner::class) @Config(sdk = [34])@@ -46,7 +47,7 @@ class RecalcAndSearchSlice3ExtraTest { } private fun location(lat: Double, lon: Double): Location = Location(LocationManager.GPS_PROVIDER).apply {- latitude = lat; longitude = lon; accuracy = 5f; time = System.currentTimeMillis()+ latitude = lat; longitude = lon; accuracy = 5f; time = FIXED_NOW_EPOCH_MS } private fun shadowLm(): org.robolectric.shadows.ShadowLocationManager {
maps/src/test/java/com/vayunmathur/maps/util/Slice3Pass3NavTest.kt
diff --git a/maps/src/test/java/com/vayunmathur/maps/util/Slice3Pass3NavTest.kt b/maps/src/test/java/com/vayunmathur/maps/util/Slice3Pass3NavTest.ktindex 56b1e26dad..770e0750f0 100644--- a/maps/src/test/java/com/vayunmathur/maps/util/Slice3Pass3NavTest.kt+++ b/maps/src/test/java/com/vayunmathur/maps/util/Slice3Pass3NavTest.kt@@ -1,6 +1,5 @@ package com.vayunmathur.maps.util -// FIXTURE RELATIVE-TIME EXCEPTION: timestamps are seeded relative to the wall clock the code under test reads internally, so the fresh/expired/relative-time branch under test keeps its meaning; a fixed past instant would silently change that branch. import com.vayunmathur.maps.domain.RouteService import com.vayunmathur.maps.platform.NavigationSessionManager @@ -21,6 +20,8 @@ import org.robolectric.RobolectricTestRunner import org.robolectric.Shadows import org.robolectric.annotation.Config +private const val FIXED_NOW_EPOCH_MS = 1_768_651_200_000L // 2026-01-17T12:00:00Z+ /** Slice 3/3 pass 3: NavigationSessionManager transit/progress/stop branches. */ @RunWith(RobolectricTestRunner::class) @Config(sdk = [34])@@ -40,7 +41,7 @@ class Slice3Pass3NavTest { private fun location(lat: Double, lon: Double): Location = Location(LocationManager.GPS_PROVIDER).apply { latitude = lat; longitude = lon; accuracy = 5f- time = System.currentTimeMillis()+ time = FIXED_NOW_EPOCH_MS elapsedRealtimeNanos = System.nanoTime() }