Modern Apps git

← Modern-Apps.git

auto: fix FixtureDeterminism and route screenshot lint errors

Commit
c12b7d76e449dacd9608579b67cc3294f97eb865
Author
Vayun Mathur <[email protected]>
When
2026-12-02 05:16 UTC (4 days ago)
Parents
9aed148
Fresh :auto:lintVitalRelease (--rerun-tasks) reported 7 errors:
4 FixtureDeterminism (System.currentTimeMillis() in AutoSessionCardTest
and Y3AutoServiceTest GPS fixtures) and 3 RouteScreenshotCoverage
(Home, LauncherHome, App had no capture under src/screenshotTest).

Fixture timestamps are now named fixed constants. No assertion reads
the wall-clock-derived rows: SessionCard only derives ack-age/elapsed
text from them, and NavGuidanceMonitor forwards Location.time
untouched, so fixed instants keep the fixtures deterministic without
seeding relative to the real clock (no exception marker needed).

Screenshot captures: rename 1-status to 1-home-status so it counts
for Route.Home, add 4-launcher-home rendering LauncherHomeGrid, and
add 5-app rendering a representative HostTemplate through the same
CarTemplateView renderer AppScreen uses, both at head-unit geometry.
Update auto/AGENTS.md preview summary to match.

Verified fresh in this worktree: :auto:lint, :auto:lintVitalRelease
(--rerun-tasks, report: No issues found), :auto:testDevUnitTest
(377 tests, 0 failures), :auto:compileDevScreenshotTestKotlin.

Diff

auto/AGENTS.md
diff --git a/auto/AGENTS.md b/auto/AGENTS.mdindex f8cfc50a8e..830189494e 100644--- a/auto/AGENTS.md+++ b/auto/AGENTS.md@@ -8,7 +8,7 @@ _Install: ./install auto (dev by default)._ - Entry files: MainActivity.kt, Route.kt, Navigation.kt - Deps: :auto:protocol (`:library:carhost` only if the build file says so โ€” verify before adding) - Metadata: metadata_data/auto.md (present)-- Rust: no / screenshotTest: yes (phone status/pairing/pinned-apps previews)+- Rust: no / screenshotTest: yes (phone home-status/pairing/pinned-apps previews + car launcher-home/hosted-app previews in `ui/MetadataPreviews.kt`)  ## Overview **Purpose:** Car head-unit projection (Android Auto compatible) โ€” NOT a phone app. Projects driving-safe nav/media/call UI to the car display over USB or wireless; test with `./dhu` (Desktop Head Unit loopback), not on a phone screen.
auto/src/screenshotTest/kotlin/com/vayunmathur/auto/ui/MetadataPreviews.kt
diff --git a/auto/src/screenshotTest/kotlin/com/vayunmathur/auto/ui/MetadataPreviews.kt b/auto/src/screenshotTest/kotlin/com/vayunmathur/auto/ui/MetadataPreviews.ktindex eef6faca49..bbcbc18bba 100644--- a/auto/src/screenshotTest/kotlin/com/vayunmathur/auto/ui/MetadataPreviews.kt+++ b/auto/src/screenshotTest/kotlin/com/vayunmathur/auto/ui/MetadataPreviews.kt@@ -18,11 +18,18 @@ import com.vayunmathur.auto.protocol.UsbSessionState import com.vayunmathur.auto.protocol.VideoFocus import com.vayunmathur.auto.protocol.WirelessSessionState import com.vayunmathur.auto.protocol.gal.AudioFocusState+import com.vayunmathur.library.carhost.CarTemplateView+import com.vayunmathur.library.carhost.HostTemplate+import com.vayunmathur.library.carhost.HostUiRow+import com.vayunmathur.library.carhost.HostUiSection import com.vayunmathur.library.ui.DynamicTheme  /** Phone-shaped, roughly 1080x2340 at xxhdpi โ€” comfortably above the F-Droid minimum. */ private const val PHONE = "spec:width=411dp,height=891dp,dpi=420" +/** Landscape head-unit display, ~Android Auto reference. */+private const val CAR = "spec:width=1024dp,height=600dp,dpi=160"+ /**  * Store-listing images for `:auto`, rendered from Compose previews instead of an  * instrumented test on a device (projection needs a car or the Desktop Head Unit@@ -33,8 +40,12 @@ private const val PHONE = "spec:width=411dp,height=891dp,dpi=420"  *  * Each preview must carry @PreviewTest as well as @Preview and be a member of a class  * (not a top-level function) or the screenshot engine silently skips it. Everything is- * a literal so the output is reproducible from a clean checkout. The car templates- * (AppScreen/LauncherRoot) are out of scope: their geometry comes from the head unit.+ * a literal so the output is reproducible from a clean checkout. Car-side routes+ * use the head-unit geometry ([CAR]): the launcher grid renders directly, and a+ * hosted app renders a representative [HostTemplate] through the same+ * [CarTemplateView] renderer `AppScreen` uses (its live template and map+ * surface come from the head unit, so the headless capture feeds the parsed+ * shape with the flat map placeholder).  */ class MetadataPreviews { @@ -131,7 +142,7 @@ class MetadataPreviews {     )      @PreviewTest-    @Preview(name = "1-status", device = PHONE, group = "phone", showSystemUi = true)+    @Preview(name = "1-home-status", device = PHONE, group = "phone", showSystemUi = true)     @Composable     fun Preview1Status() {         DynamicTheme(darkTheme = true) {@@ -180,4 +191,38 @@ class MetadataPreviews {             )         }     }++    @PreviewTest+    @Preview(name = "4-launcher-home", device = CAR, group = "phone", showSystemUi = false)+    @Composable+    fun Preview4LauncherHome() {+        DynamicTheme(darkTheme = true) {+            LauncherHomeGrid(+                apps = pinnedRows.map { it.app },+                onOpen = {},+            )+        }+    }++    @PreviewTest+    @Preview(name = "5-app", device = CAR, group = "phone", showSystemUi = false)+    @Composable+    fun Preview5App() {+        DynamicTheme(darkTheme = true) {+            CarTemplateView(+                HostTemplate.TemplateList(+                    title = "Maps",+                    sections = listOf(+                        HostUiSection(+                            rows = listOf(+                                HostUiRow("Home", listOf("123 Demo Street")),+                                HostUiRow("Work", listOf("456 Demo Avenue")),+                                HostUiRow("Recent places", listOf("Ferry Building")),+                            ),+                        ),+                    ),+                ),+            )+        }+    } }
auto/src/test/java/com/vayunmathur/auto/Y3AutoServiceTest.kt
diff --git a/auto/src/test/java/com/vayunmathur/auto/Y3AutoServiceTest.kt b/auto/src/test/java/com/vayunmathur/auto/Y3AutoServiceTest.ktindex 9bb4d7e9e9..3e5612644e 100644--- a/auto/src/test/java/com/vayunmathur/auto/Y3AutoServiceTest.kt+++ b/auto/src/test/java/com/vayunmathur/auto/Y3AutoServiceTest.kt@@ -31,6 +31,12 @@ class Y3AutoServiceTest {     private val app get() = ApplicationProvider.getApplicationContext<Application>()     private val ctx: Context get() = app +    // Fixed GPS fix instants: NavGuidanceMonitor forwards Location.time+    // untouched and no assertion reads it, so fixed instants keep the+    // fixture deterministic without seeding relative to the real clock.+    private val fixedFixTimeMs = 1_786_500_000_000L+    private val fixedLiveFixTimeMs = fixedFixTimeMs + 60_000L+     @Test fun projectionServiceStartDestroyLifecycle() {         val controller = Robolectric.buildService(ProjectionService::class.java)         val service = controller.create().get()@@ -148,7 +154,7 @@ class Y3AutoServiceTest {         val shadow = Shadows.shadowOf(manager)         shadow.setProviderEnabled(android.location.LocationManager.GPS_PROVIDER, true)         val fix = android.location.Location(android.location.LocationManager.GPS_PROVIDER).apply {-            latitude = 37.7749; longitude = -122.4194; accuracy = 5f; speed = 12f; bearing = 90f; time = System.currentTimeMillis()+            latitude = 37.7749; longitude = -122.4194; accuracy = 5f; speed = 12f; bearing = 90f; time = fixedFixTimeMs         }         shadow.setLastKnownLocation(android.location.LocationManager.GPS_PROVIDER, fix)         val updates = mutableListOf<com.vayunmathur.auto.protocol.NavSnapshot>()@@ -166,7 +172,7 @@ class Y3AutoServiceTest {         val listeners = shadow.getRequestLocationUpdateListeners()         assertTrue(listeners.isNotEmpty())         val fix2 = android.location.Location(android.location.LocationManager.GPS_PROVIDER).apply {-            latitude = 37.8; longitude = -122.5; speed = 0f; time = System.currentTimeMillis()+            latitude = 37.8; longitude = -122.5; speed = 0f; time = fixedLiveFixTimeMs         }         listeners.forEach { it.onLocationChanged(fix2) }         assertEquals(378_000_000L, monitor.snapshots.value?.latitudeE7)
auto/src/test/java/com/vayunmathur/auto/ui/AutoSessionCardTest.kt
diff --git a/auto/src/test/java/com/vayunmathur/auto/ui/AutoSessionCardTest.kt b/auto/src/test/java/com/vayunmathur/auto/ui/AutoSessionCardTest.ktindex 6d7a886012..19e4bd35a0 100644--- a/auto/src/test/java/com/vayunmathur/auto/ui/AutoSessionCardTest.kt+++ b/auto/src/test/java/com/vayunmathur/auto/ui/AutoSessionCardTest.kt@@ -32,6 +32,12 @@ class AutoSessionCardTest {     private val appContext: android.content.Context         get() = ApplicationProvider.getApplicationContext() +    // Fixed fixture instants: SessionCard derives ack-age/elapsed from the+    // wall clock, but no assertion reads those rows, so fixed instants keep+    // the fixture deterministic without seeding relative to the real clock.+    private val fixedLastAckAt = 1_786_500_000_000L+    private val fixedSessionStartedAt = fixedLastAckAt - 65_000L+     private fun bareSnapshot() = SessionSnapshot(         video = null,         focusMode = null,@@ -77,13 +83,13 @@ class AutoSessionCardTest {         ackMismatches = 2L,         encodedFps = 30.0,         ackFps = 29.5,-        lastAckAt = System.currentTimeMillis(),+        lastAckAt = fixedLastAckAt,         lastAckSeq = 77L,         avgEncodeLatencyUs = 1500L,         encoderDrains = 4L,         surfaceValid = true,         credentialDaysLeft = 5L,-        sessionStartedAt = System.currentTimeMillis() - 65_000L,+        sessionStartedAt = fixedSessionStartedAt,         nowPlaying = NowPlayingInfo(             title = "Test Song",             artist = "Test Band",