Modern Apps git

← Modern-Apps.git

maps: add Android Auto car view screenshot test

Commit
07c0ed7144b432b75bf32f6c9010da35c56c9445
Author
vayun-mathur <[email protected]>
When
2026-09-20 02:01 UTC (2 months ago)
Parents
1ef345d

Diff

maps/build.gradle.kts
diff --git a/maps/build.gradle.kts b/maps/build.gradle.ktsindex 31cd11d6ca..5e0008f4b0 100644--- a/maps/build.gradle.kts+++ b/maps/build.gradle.kts@@ -43,4 +43,7 @@ dependencies {     // code path — the phone UI is untouched.     implementation(libs.androidx.car.app)     implementation(libs.androidx.car.app.projected)++    // Car-view store-listing screenshots render through the shared host renderer.+    add("screenshotTestImplementation", project(":library:carhost")) }
maps/src/screenshotTest/kotlin/com/vayunmathur/maps/ui/CarMetadataPreviews.kt
diff --git a/maps/src/screenshotTest/kotlin/com/vayunmathur/maps/ui/CarMetadataPreviews.kt b/maps/src/screenshotTest/kotlin/com/vayunmathur/maps/ui/CarMetadataPreviews.ktnew file mode 100644index 0000000000..51f184f2a4--- /dev/null+++ b/maps/src/screenshotTest/kotlin/com/vayunmathur/maps/ui/CarMetadataPreviews.kt@@ -0,0 +1,77 @@+package com.vayunmathur.maps.ui++import androidx.compose.foundation.layout.fillMaxSize+import androidx.compose.runtime.Composable+import androidx.compose.ui.Modifier+import androidx.compose.ui.tooling.preview.Preview+import com.android.tools.screenshot.PreviewTest+import com.vayunmathur.library.carhost.CarTemplateView+import com.vayunmathur.library.carhost.HostTemplate+import com.vayunmathur.library.carhost.HostUiAction+import com.vayunmathur.library.carhost.HostUiRow+import com.vayunmathur.library.carhost.HostUiSection+import com.vayunmathur.library.ui.DynamicTheme+import com.vayunmathur.library.ui.Surface++/** Landscape head-unit display, ~Android Auto reference. */+private const val CAR = "spec:width=1024dp,height=600dp,dpi=160"++/**+ * Store-listing screenshots of the Android Auto car views for `:maps`.+ *+ * Car Templates cannot render in Layoutlib, so these feed representative+ * [HostTemplate]s (the parsed shape the head unit renders) to the shared+ * [CarTemplateView] renderer from `:library:carhost` — the same renderer MA Auto+ * uses. Numbered after the phone previews in [MetadataPreviews] so the listing+ * order stays phone-first. See `common-conventions-preview-metadata`.+ */+class CarMetadataPreviews {++    @PreviewTest+    @Preview(name = "6-car-navigation", device = CAR, showSystemUi = false)+    @Composable+    fun Preview6CarNavigation() {+        DynamicTheme(darkTheme = true) {+            Surface(Modifier.fillMaxSize()) {+                CarTemplateView(+                    HostTemplate.Navigation(+                        navigating = true,+                        cue = "Turn right onto 16th St",+                        road = "16th St",+                        distanceText = "280 m",+                        etaText = "11 min",+                        lanesText = "← ↑ →",+                        actions = listOf(HostUiAction("End") {}),+                    ),+                )+            }+        }+    }++    @PreviewTest+    @Preview(name = "7-car-search", device = CAR, showSystemUi = false)+    @Composable+    fun Preview7CarSearch() {+        DynamicTheme(darkTheme = true) {+            Surface(Modifier.fillMaxSize()) {+                CarTemplateView(+                    HostTemplate.MapWithContent(+                        content = HostTemplate.TemplateList(+                            title = "Search",+                            sections = listOf(+                                HostUiSection(+                                    rows = listOf(+                                        HostUiRow("Ferry Building Marketplace", listOf("1 Ferry Building, San Francisco"), browse = true) {},+                                        HostUiRow("Ferry Plaza Farmers Market", listOf("1 Ferry Building, San Francisco"), browse = true) {},+                                        HostUiRow("Golden Gate Ferry Terminal", listOf("Pier 1, San Francisco"), browse = true) {},+                                        HostUiRow("Oakland Ferry Dock", listOf("Clay St, Oakland"), browse = true) {},+                                    ),+                                ),+                            ),+                        ),+                    ),+                )+            }+        }+    }+}