Modern Apps git

← Modern-Apps.git

music: add Android Auto car view screenshot test

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

Diff

music/build.gradle.kts
diff --git a/music/build.gradle.kts b/music/build.gradle.ktsindex 9e620b767c..354d189e09 100644--- a/music/build.gradle.kts+++ b/music/build.gradle.kts@@ -40,4 +40,7 @@ dependencies {     // Opus transcoder: every cast audio track is 48 kHz Opus, and most of the library is not.     implementation(project(":sdk:cast"))     implementation(project(":library:media"))++    // Car-view store-listing screenshots render through the shared host renderer.+    add("screenshotTestImplementation", project(":library:carhost")) }\ No newline at end of file
music/src/screenshotTest/kotlin/com/vayunmathur/music/ui/CarMetadataPreviews.kt
diff --git a/music/src/screenshotTest/kotlin/com/vayunmathur/music/ui/CarMetadataPreviews.kt b/music/src/screenshotTest/kotlin/com/vayunmathur/music/ui/CarMetadataPreviews.ktnew file mode 100644index 0000000000..3838f2bae9--- /dev/null+++ b/music/src/screenshotTest/kotlin/com/vayunmathur/music/ui/CarMetadataPreviews.kt@@ -0,0 +1,81 @@+package com.vayunmathur.music.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.HostUiRow+import com.vayunmathur.library.carhost.HostUiSection+import com.vayunmathur.library.carhost.HostUiTab+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 `:music`.+ *+ * Feeds representative [HostTemplate]s to the shared [CarTemplateView] renderer+ * from `:library:carhost` (the same renderer MA Auto uses). Shows the tabbed+ * library with a chip quick-action strip and the now-playing view.+ */+class CarMetadataPreviews {++    @PreviewTest+    @Preview(name = "5-car-browse", device = CAR, showSystemUi = false)+    @Composable+    fun Preview5CarBrowse() {+        DynamicTheme(darkTheme = true) {+            Surface(Modifier.fillMaxSize()) {+                CarTemplateView(+                    HostTemplate.Tabs(+                        tabs = listOf(+                            HostUiTab("Playlists", "tab_playlists"),+                            HostUiTab("Albums", "tab_albums"),+                            HostUiTab("Artists", "tab_artists"),+                            HostUiTab("Songs", "tab_songs"),+                            HostUiTab("Recent", "tab_recent"),+                        ),+                        activeContentId = "tab_songs",+                        content = HostTemplate.TemplateList(+                            sections = listOf(+                                HostUiSection(+                                    chips = true,+                                    rows = listOf(+                                        HostUiRow("Shuffle all") {},+                                        HostUiRow("Play all") {},+                                    ),+                                ),+                                HostUiSection(+                                    header = "Songs",+                                    rows = listOf(+                                        HostUiRow("Midnight City", listOf("M83 · Hurry Up, We're Dreaming")) {},+                                        HostUiRow("Redbone", listOf("Childish Gambino · Awaken, My Love!")) {},+                                        HostUiRow("Nightcall", listOf("Kavinsky · OutRun")) {},+                                        HostUiRow("Instant Crush", listOf("Daft Punk · Random Access Memories")) {},+                                        HostUiRow("The Less I Know the Better", listOf("Tame Impala · Currents")) {},+                                    ),+                                ),+                            ),+                        ),+                    ),+                )+            }+        }+    }++    @PreviewTest+    @Preview(name = "6-car-playback", device = CAR, showSystemUi = false)+    @Composable+    fun Preview6CarPlayback() {+        DynamicTheme(darkTheme = true) {+            Surface(Modifier.fillMaxSize()) {+                CarTemplateView(HostTemplate.MediaPlayback(title = "Midnight City"))+            }+        }+    }+}