Merge "Add post content description for preview" into main
diff --git a/res/values-eu/strings.xml b/res/values-eu/strings.xml
index 4502fb6..8c2b406 100644
--- a/res/values-eu/strings.xml
+++ b/res/values-eu/strings.xml
@@ -35,7 +35,7 @@
     <string name="clock_color_indigo" msgid="8910855386698452917">"Indigoa"</string>
     <string name="clock_color_violet" msgid="3454503847169375826">"Bioleta"</string>
     <string name="clock_color_gray" msgid="9221530636948859231">"Grisa"</string>
-    <string name="clock_color_teal" msgid="7499223425741344251">"Anila"</string>
+    <string name="clock_color_teal" msgid="7499223425741344251">"Berde urdinxka"</string>
     <string name="clock_size" msgid="5028923902364418263">"Tamaina"</string>
     <string name="clock_size_dynamic" msgid="1023930312455061642">"Dinamikoa"</string>
     <string name="clock_size_dynamic_description" msgid="2776620745774561662">"Erlojuaren tamaina pantaila blokeatuko edukiaren arabera aldatzen da"</string>
diff --git a/res/values-ml/strings.xml b/res/values-ml/strings.xml
index 5454f05..685f8f6 100644
--- a/res/values-ml/strings.xml
+++ b/res/values-ml/strings.xml
@@ -105,7 +105,7 @@
     <string name="accessibility_custom_name_title" msgid="5494460518085463262">"ഇഷ്‌ടാനുസൃത സ്‌റ്റൈലിന്റെ പേര്"</string>
     <string name="accessibility_clock_slider_description" msgid="8374135133110681332">"വർണ തീവ്രത"</string>
     <string name="mode_title" msgid="2394873501427436055">"ഡാർക്ക് തീം"</string>
-    <string name="mode_disabled_msg" msgid="9196245518435936512">"ബാറ്ററി ലാഭിക്കൽ കാരണം തൽക്കാലം പ്രവർത്തനരഹിതമാണ്"</string>
+    <string name="mode_disabled_msg" msgid="9196245518435936512">"ബാറ്ററി സേവർ കാരണം തൽക്കാലം പ്രവർത്തനരഹിതമാണ്"</string>
     <string name="mode_changed" msgid="2243581369395418584">"തീം മാറ്റി"</string>
     <string name="themed_icon_title" msgid="7312460430471956558">"തീമുള്ള ഐക്കണുകൾ"</string>
     <string name="beta_title" msgid="8703819523760746458">"ബീറ്റ"</string>
diff --git a/res/values-ne/strings.xml b/res/values-ne/strings.xml
index bc7e8e6..8e664ea 100644
--- a/res/values-ne/strings.xml
+++ b/res/values-ne/strings.xml
@@ -77,8 +77,8 @@
     <string name="custom_theme_next" msgid="6235420097213197301">"अर्को"</string>
     <string name="custom_theme_previous" msgid="4941132112640503022">"अघिल्लो"</string>
     <string name="custom_theme" msgid="1618351922263478163">"रोजेको"</string>
-    <string name="custom_theme_title" msgid="2192300350332693631">"आफू अनुकूल <xliff:g id="ID_1">%1$d</xliff:g>"</string>
-    <string name="custom_theme_fragment_title" msgid="6615547284702040280">"आफू अनुकूल शैली"</string>
+    <string name="custom_theme_title" msgid="2192300350332693631">" कस्टम <xliff:g id="ID_1">%1$d</xliff:g>"</string>
+    <string name="custom_theme_fragment_title" msgid="6615547284702040280">" कस्टम शैली"</string>
     <string name="custom_theme_delete" msgid="4744494663184126202">"मेट्नुहोस्"</string>
     <string name="font_component_title" msgid="8800340833695292049">"फन्ट छनौट गर्नुहोस्"</string>
     <string name="icon_component_title" msgid="5779787138399083903">"आइकनहरू छनौट गर्नुहोस्"</string>
@@ -86,7 +86,7 @@
     <string name="shape_component_title" msgid="8366847436022025538">"आकार छनौट गर्नुहोस्"</string>
     <string name="name_component_title" msgid="532425087968663437">"आफ्नो शैलीको नाम राख्नुहोस्"</string>
     <string name="icon_component_label" msgid="2625784884001407944">"आइकनहरू <xliff:g id="ID_1">%1$d</xliff:g>"</string>
-    <string name="delete_custom_theme_confirmation" msgid="4452137183628769394">"आफू अनुकूल शैली मेट्ने हो?"</string>
+    <string name="delete_custom_theme_confirmation" msgid="4452137183628769394">" कस्टम शैली मेट्ने हो?"</string>
     <string name="delete_custom_theme_button" msgid="5102462988130208824">"मेट्नुहोस्"</string>
     <string name="cancel" msgid="4651030493668562067">"रद्द गर्नुहोस्"</string>
     <string name="set_theme_wallpaper_dialog_message" msgid="2179661027350908003">"शैलीयुक्त वालपेपर सेट गर्नुहोस्"</string>
diff --git a/src/com/android/customization/model/color/ThemedWallpaperColorResources.kt b/src/com/android/customization/model/color/ThemedWallpaperColorResources.kt
index 7c89953..c426f9d 100644
--- a/src/com/android/customization/model/color/ThemedWallpaperColorResources.kt
+++ b/src/com/android/customization/model/color/ThemedWallpaperColorResources.kt
@@ -39,11 +39,11 @@
         withContext(Dispatchers.IO) {
             val wallpaperColorScheme =
                 ColorScheme(
-                    wallpaperColors = wallpaperColors,
-                    darkTheme = false,
-                    style = fetchThemeStyleFromSetting(),
+                    wallpaperColors,
+                    false,
+                    fetchThemeStyleFromSetting(),
                 )
-            with(wallpaperColorScheme) {
+            with<ColorScheme, Unit>(wallpaperColorScheme) {
                 addOverlayColor(neutral1, R.color.system_neutral1_10)
                 addOverlayColor(neutral2, R.color.system_neutral2_10)
                 addOverlayColor(accent1, R.color.system_accent1_10)
diff --git a/src_override/com/android/wallpaper/picker/di/modules/EffectsModule.kt b/src_override/com/android/wallpaper/picker/di/modules/EffectsModule.kt
index f49a273..4fc0fbb 100644
--- a/src_override/com/android/wallpaper/picker/di/modules/EffectsModule.kt
+++ b/src_override/com/android/wallpaper/picker/di/modules/EffectsModule.kt
@@ -26,7 +26,7 @@
 /** This class provides the singleton scoped effects controller for wallpaper picker. */
 @InstallIn(SingletonComponent::class)
 @Module
-internal abstract class EffectsModule {
+abstract class EffectsModule {
 
     @Binds
     @Singleton
diff --git a/tests/module/src/com/android/wallpaper/ThemePickerTestModule.kt b/tests/module/src/com/android/wallpaper/ThemePickerTestModule.kt
index f847aaa..f4376ee 100644
--- a/tests/module/src/com/android/wallpaper/ThemePickerTestModule.kt
+++ b/tests/module/src/com/android/wallpaper/ThemePickerTestModule.kt
@@ -24,16 +24,21 @@
 import com.android.customization.module.logging.ThemesUserEventLogger
 import com.android.customization.testing.TestCustomizationInjector
 import com.android.customization.testing.TestDefaultCustomizationPreferences
+import com.android.wallpaper.effects.EffectsController
+import com.android.wallpaper.effects.FakeEffectsController
 import com.android.wallpaper.module.Injector
 import com.android.wallpaper.module.PartnerProvider
 import com.android.wallpaper.module.WallpaperPreferences
 import com.android.wallpaper.module.logging.TestUserEventLogger
 import com.android.wallpaper.module.logging.UserEventLogger
 import com.android.wallpaper.modules.ThemePickerAppModule
-import com.android.wallpaper.picker.preview.data.util.DefaultLiveWallpaperDownloader
+import com.android.wallpaper.network.Requester
+import com.android.wallpaper.picker.di.modules.EffectsModule
+import com.android.wallpaper.picker.preview.data.util.FakeLiveWallpaperDownloader
 import com.android.wallpaper.picker.preview.data.util.LiveWallpaperDownloader
 import com.android.wallpaper.picker.preview.ui.util.DefaultImageEffectDialogUtil
 import com.android.wallpaper.picker.preview.ui.util.ImageEffectDialogUtil
+import com.android.wallpaper.testing.FakeDefaultRequester
 import com.android.wallpaper.testing.TestPartnerProvider
 import com.android.wallpaper.util.converter.DefaultWallpaperModelFactory
 import com.android.wallpaper.util.converter.WallpaperModelFactory
@@ -45,7 +50,10 @@
 import javax.inject.Singleton
 
 @Module
-@TestInstallIn(components = [SingletonComponent::class], replaces = [ThemePickerAppModule::class])
+@TestInstallIn(
+    components = [SingletonComponent::class],
+    replaces = [EffectsModule::class, ThemePickerAppModule::class]
+)
 abstract class ThemePickerTestModule {
     //// WallpaperPicker2 prod
 
@@ -53,6 +61,8 @@
 
     @Binds @Singleton abstract fun bindUserEventLogger(impl: TestUserEventLogger): UserEventLogger
 
+    @Binds @Singleton abstract fun bindFakeRequester(impl: FakeDefaultRequester): Requester
+
     @Binds
     @Singleton
     abstract fun bindThemesUserEventLogger(impl: TestThemesUserEventLogger): ThemesUserEventLogger
@@ -82,7 +92,7 @@
     @Binds
     @Singleton
     abstract fun bindLiveWallpaperDownloader(
-        impl: DefaultLiveWallpaperDownloader
+        impl: FakeLiveWallpaperDownloader
     ): LiveWallpaperDownloader
 
     @Binds
@@ -95,6 +105,10 @@
         impl: DefaultImageEffectDialogUtil
     ): ImageEffectDialogUtil
 
+    @Binds
+    @Singleton
+    abstract fun bindEffectsController(impl: FakeEffectsController): EffectsController
+
     companion object {
         @Provides
         @Singleton
diff --git a/tests/robotests/Android.bp b/tests/robotests/Android.bp
index 5c0f388..76a1dad 100644
--- a/tests/robotests/Android.bp
+++ b/tests/robotests/Android.bp
@@ -10,6 +10,7 @@
     static_libs: [
         "ThemePickerTestLib",
         "ThemePickerTestModule",
+        "WallpaperPicker2RoboLib",
     ],
 }
 
diff --git a/tests/robotests/src/com/android/customization/model/picker/settings/data/repository/ColorContrastSectionRepositoryTest.kt b/tests/robotests/src/com/android/customization/model/picker/settings/data/repository/ColorContrastSectionRepositoryTest.kt
index 54b7c6e..fb9477a 100644
--- a/tests/robotests/src/com/android/customization/model/picker/settings/data/repository/ColorContrastSectionRepositoryTest.kt
+++ b/tests/robotests/src/com/android/customization/model/picker/settings/data/repository/ColorContrastSectionRepositoryTest.kt
@@ -24,8 +24,10 @@
 import dagger.hilt.android.testing.HiltAndroidTest
 import javax.inject.Inject
 import kotlinx.coroutines.ExperimentalCoroutinesApi
+import kotlinx.coroutines.flow.toList
 import kotlinx.coroutines.launch
-import kotlinx.coroutines.test.runBlockingTest
+import kotlinx.coroutines.test.UnconfinedTestDispatcher
+import kotlinx.coroutines.test.runTest
 import org.junit.Before
 import org.junit.Rule
 import org.junit.Test
@@ -53,18 +55,21 @@
 
     @OptIn(ExperimentalCoroutinesApi::class)
     @Test
-    fun contrastFlowEmitsValues() = runBlockingTest {
+    fun contrastFlowEmitsValues() = runTest {
         val nextContrastValues = listOf(0.5f, 0.7f, 0.8f)
         // Set up a flow to collect all contrast values
         val flowCollector = mutableListOf<Float>()
-        // Start collecting values from the flow
-        val job = launch { underTest.contrast.collect { flowCollector.add(it) } }
+        // Start collecting values from the flow, using an unconfined dispatcher to start collecting
+        // from the flow right away (rather than explicitly calling `runCurrent`)
+        // See https://developer.android.com/kotlin/flow/test#continuous-collection
+        backgroundScope.launch(UnconfinedTestDispatcher(testScheduler)) {
+            underTest.contrast.toList(flowCollector)
+        }
 
         nextContrastValues.forEach { uiModeManager.setContrast(it) }
 
         // Ignore the first contrast value from constructing the repository
         val collectedValues = flowCollector.drop(1)
         assertThat(collectedValues).containsExactlyElementsIn(nextContrastValues)
-        job.cancel()
     }
 }
diff --git a/tests/robotests/src/com/android/customization/model/picker/settings/domain/interactor/ColorContrastSectionInteractorTest.kt b/tests/robotests/src/com/android/customization/model/picker/settings/domain/interactor/ColorContrastSectionInteractorTest.kt
index 2319eed..afa6427 100644
--- a/tests/robotests/src/com/android/customization/model/picker/settings/domain/interactor/ColorContrastSectionInteractorTest.kt
+++ b/tests/robotests/src/com/android/customization/model/picker/settings/domain/interactor/ColorContrastSectionInteractorTest.kt
@@ -19,12 +19,12 @@
 import androidx.test.filters.SmallTest
 import com.android.customization.picker.settings.domain.interactor.ColorContrastSectionInteractor
 import com.android.wallpaper.testing.FakeUiModeManager
+import com.google.common.truth.Truth.assertThat
 import dagger.hilt.android.testing.HiltAndroidRule
 import dagger.hilt.android.testing.HiltAndroidTest
 import javax.inject.Inject
 import kotlinx.coroutines.flow.first
-import kotlinx.coroutines.test.runBlockingTest
-import org.junit.Assert.assertEquals
+import kotlinx.coroutines.test.runTest
 import org.junit.Before
 import org.junit.Rule
 import org.junit.Test
@@ -46,12 +46,12 @@
     }
 
     @Test
-    fun contrastEmitCorrectValuesFromRepository() = runBlockingTest {
+    fun contrastEmitCorrectValuesFromRepository() = runTest {
         val expectedContrast = 1.5f
         uiModeManager.setContrast(expectedContrast)
 
         val result = interactor.contrast.first()
 
-        assertEquals(expectedContrast, result)
+        assertThat(result).isEqualTo(expectedContrast)
     }
 }
diff --git a/tests/robotests/src/com/android/customization/model/picker/settings/ui/viewmodel/ColorContrastSectionViewModelTest.kt b/tests/robotests/src/com/android/customization/model/picker/settings/ui/viewmodel/ColorContrastSectionViewModelTest.kt
index c06f8a3..bf02273 100644
--- a/tests/robotests/src/com/android/customization/model/picker/settings/ui/viewmodel/ColorContrastSectionViewModelTest.kt
+++ b/tests/robotests/src/com/android/customization/model/picker/settings/ui/viewmodel/ColorContrastSectionViewModelTest.kt
@@ -27,7 +27,7 @@
 import javax.inject.Inject
 import kotlinx.coroutines.flow.collect
 import kotlinx.coroutines.flow.first
-import kotlinx.coroutines.test.runBlockingTest
+import kotlinx.coroutines.test.runTest
 import org.junit.Assert.assertEquals
 import org.junit.Before
 import org.junit.Rule
@@ -52,7 +52,7 @@
     }
 
     @Test
-    fun summaryEmitsCorrectDataValueForStandard() = runBlockingTest {
+    fun summaryEmitsCorrectDataValueForStandard() = runTest {
         uiModeManager.setContrast(ColorContrastSectionViewModel.ContrastValue.STANDARD.value)
         val expected =
             ColorContrastSectionDataViewModel(
@@ -66,7 +66,7 @@
     }
 
     @Test
-    fun summaryEmitsCorrectDataValueForMedium() = runBlockingTest {
+    fun summaryEmitsCorrectDataValueForMedium() = runTest {
         uiModeManager.setContrast(ColorContrastSectionViewModel.ContrastValue.MEDIUM.value)
         val expected =
             ColorContrastSectionDataViewModel(
@@ -80,7 +80,7 @@
     }
 
     @Test
-    fun summaryEmitsCorrectDataValueForHigh() = runBlockingTest {
+    fun summaryEmitsCorrectDataValueForHigh() = runTest {
         uiModeManager.setContrast(ColorContrastSectionViewModel.ContrastValue.HIGH.value)
         val expected =
             ColorContrastSectionDataViewModel(
@@ -94,7 +94,7 @@
     }
 
     @Test(expected = IllegalArgumentException::class)
-    fun summaryThrowsIllegalArgumentExceptionForInvalidValue() = runBlockingTest {
+    fun summaryThrowsIllegalArgumentExceptionForInvalidValue() = runTest {
         uiModeManager.setContrast(999f)
 
         viewModel.summary.collect() // This should throw an IllegalArgumentException