diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 972f953890..afd37736f2 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -113,7 +113,7 @@ dependencies { testImplementation(projects.core.dataTest) testImplementation(projects.core.testing) - testImplementation(libs.accompanist.testharness) + testImplementation(libs.androidx.compose.ui.test) testImplementation(libs.hilt.android.testing) testImplementation(libs.work.testing) @@ -126,7 +126,7 @@ dependencies { androidTestImplementation(projects.core.datastoreTest) androidTestImplementation(libs.androidx.test.espresso.core) androidTestImplementation(libs.androidx.navigation.testing) - androidTestImplementation(libs.accompanist.testharness) + androidTestImplementation(libs.androidx.compose.ui.test) androidTestImplementation(libs.hilt.android.testing) baselineProfile(projects.benchmarks) diff --git a/app/src/androidTest/kotlin/com/google/samples/apps/nowinandroid/ui/NavigationUiTest.kt b/app/src/androidTest/kotlin/com/google/samples/apps/nowinandroid/ui/NavigationUiTest.kt index 5d2e12b5c5..03cf653aef 100644 --- a/app/src/androidTest/kotlin/com/google/samples/apps/nowinandroid/ui/NavigationUiTest.kt +++ b/app/src/androidTest/kotlin/com/google/samples/apps/nowinandroid/ui/NavigationUiTest.kt @@ -20,13 +20,14 @@ import androidx.compose.foundation.layout.BoxWithConstraints import androidx.compose.material3.windowsizeclass.ExperimentalMaterial3WindowSizeClassApi import androidx.compose.material3.windowsizeclass.WindowSizeClass import androidx.compose.runtime.Composable +import androidx.compose.ui.test.DeviceConfigurationOverride +import androidx.compose.ui.test.ForcedSize import androidx.compose.ui.test.assertIsDisplayed import androidx.compose.ui.test.junit4.createAndroidComposeRule import androidx.compose.ui.test.onNodeWithTag import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.DpSize import androidx.compose.ui.unit.dp -import com.google.accompanist.testharness.TestHarness import com.google.samples.apps.nowinandroid.core.data.repository.CompositeUserNewsResourceRepository import com.google.samples.apps.nowinandroid.core.data.util.NetworkMonitor import com.google.samples.apps.nowinandroid.core.data.util.TimeZoneMonitor @@ -95,7 +96,9 @@ class NavigationUiTest { @Test fun compactWidth_compactHeight_showsNavigationBar() { composeTestRule.setContent { - TestHarness(size = DpSize(400.dp, 400.dp)) { + DeviceConfigurationOverride( + DeviceConfigurationOverride.ForcedSize(DpSize(400.dp, 400.dp)), + ) { BoxWithConstraints { NiaApp(fakeAppState(maxWidth, maxHeight)) } @@ -109,7 +112,9 @@ class NavigationUiTest { @Test fun mediumWidth_compactHeight_showsNavigationRail() { composeTestRule.setContent { - TestHarness(size = DpSize(610.dp, 400.dp)) { + DeviceConfigurationOverride( + DeviceConfigurationOverride.ForcedSize(DpSize(610.dp, 400.dp)), + ) { BoxWithConstraints { NiaApp(fakeAppState(maxWidth, maxHeight)) } @@ -123,7 +128,9 @@ class NavigationUiTest { @Test fun expandedWidth_compactHeight_showsNavigationRail() { composeTestRule.setContent { - TestHarness(size = DpSize(900.dp, 400.dp)) { + DeviceConfigurationOverride( + DeviceConfigurationOverride.ForcedSize(DpSize(900.dp, 400.dp)), + ) { BoxWithConstraints { NiaApp(fakeAppState(maxWidth, maxHeight)) } @@ -137,7 +144,9 @@ class NavigationUiTest { @Test fun compactWidth_mediumHeight_showsNavigationBar() { composeTestRule.setContent { - TestHarness(size = DpSize(400.dp, 500.dp)) { + DeviceConfigurationOverride( + DeviceConfigurationOverride.ForcedSize(DpSize(400.dp, 500.dp)), + ) { BoxWithConstraints { NiaApp(fakeAppState(maxWidth, maxHeight)) } @@ -151,7 +160,9 @@ class NavigationUiTest { @Test fun mediumWidth_mediumHeight_showsNavigationRail() { composeTestRule.setContent { - TestHarness(size = DpSize(610.dp, 500.dp)) { + DeviceConfigurationOverride( + DeviceConfigurationOverride.ForcedSize(DpSize(610.dp, 500.dp)), + ) { BoxWithConstraints { NiaApp(fakeAppState(maxWidth, maxHeight)) } @@ -165,7 +176,9 @@ class NavigationUiTest { @Test fun expandedWidth_mediumHeight_showsNavigationRail() { composeTestRule.setContent { - TestHarness(size = DpSize(900.dp, 500.dp)) { + DeviceConfigurationOverride( + DeviceConfigurationOverride.ForcedSize(DpSize(900.dp, 500.dp)), + ) { BoxWithConstraints { NiaApp(fakeAppState(maxWidth, maxHeight)) } @@ -179,7 +192,9 @@ class NavigationUiTest { @Test fun compactWidth_expandedHeight_showsNavigationBar() { composeTestRule.setContent { - TestHarness(size = DpSize(400.dp, 1000.dp)) { + DeviceConfigurationOverride( + DeviceConfigurationOverride.ForcedSize(DpSize(400.dp, 1000.dp)), + ) { BoxWithConstraints { NiaApp(fakeAppState(maxWidth, maxHeight)) } @@ -193,7 +208,9 @@ class NavigationUiTest { @Test fun mediumWidth_expandedHeight_showsNavigationRail() { composeTestRule.setContent { - TestHarness(size = DpSize(610.dp, 1000.dp)) { + DeviceConfigurationOverride( + DeviceConfigurationOverride.ForcedSize(DpSize(610.dp, 1000.dp)), + ) { BoxWithConstraints { NiaApp(fakeAppState(maxWidth, maxHeight)) } @@ -207,7 +224,9 @@ class NavigationUiTest { @Test fun expandedWidth_expandedHeight_showsNavigationRail() { composeTestRule.setContent { - TestHarness(size = DpSize(900.dp, 1000.dp)) { + DeviceConfigurationOverride( + DeviceConfigurationOverride.ForcedSize(DpSize(900.dp, 1000.dp)), + ) { BoxWithConstraints { NiaApp(fakeAppState(maxWidth, maxHeight)) } diff --git a/app/src/main/kotlin/com/google/samples/apps/nowinandroid/ui/NiaApp.kt b/app/src/main/kotlin/com/google/samples/apps/nowinandroid/ui/NiaApp.kt index 51c98cec6f..8cbabc247b 100644 --- a/app/src/main/kotlin/com/google/samples/apps/nowinandroid/ui/NiaApp.kt +++ b/app/src/main/kotlin/com/google/samples/apps/nowinandroid/ui/NiaApp.kt @@ -76,12 +76,12 @@ import com.google.samples.apps.nowinandroid.navigation.TopLevelDestination import com.google.samples.apps.nowinandroid.feature.settings.R as settingsR @Composable -fun NiaApp(appState: NiaAppState) { +fun NiaApp(appState: NiaAppState, modifier: Modifier = Modifier) { val shouldShowGradientBackground = appState.currentTopLevelDestination == TopLevelDestination.FOR_YOU var showSettingsDialog by rememberSaveable { mutableStateOf(false) } - NiaBackground { + NiaBackground(modifier = modifier) { NiaGradientBackground( gradientColors = if (shouldShowGradientBackground) { LocalGradientColors.current diff --git a/app/src/testDemo/kotlin/com/google/samples/apps/nowinandroid/ui/NiaAppScreenSizesScreenshotTests.kt b/app/src/testDemo/kotlin/com/google/samples/apps/nowinandroid/ui/NiaAppScreenSizesScreenshotTests.kt index 83ca1bb3dc..e843352468 100644 --- a/app/src/testDemo/kotlin/com/google/samples/apps/nowinandroid/ui/NiaAppScreenSizesScreenshotTests.kt +++ b/app/src/testDemo/kotlin/com/google/samples/apps/nowinandroid/ui/NiaAppScreenSizesScreenshotTests.kt @@ -17,11 +17,12 @@ package com.google.samples.apps.nowinandroid.ui import android.util.Log -import androidx.compose.foundation.layout.BoxWithConstraints import androidx.compose.material3.windowsizeclass.ExperimentalMaterial3WindowSizeClassApi import androidx.compose.material3.windowsizeclass.WindowSizeClass import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.ui.platform.LocalInspectionMode +import androidx.compose.ui.test.DeviceConfigurationOverride +import androidx.compose.ui.test.ForcedSize import androidx.compose.ui.test.junit4.createAndroidComposeRule import androidx.compose.ui.test.onRoot import androidx.compose.ui.unit.Dp @@ -32,7 +33,6 @@ import androidx.work.Configuration import androidx.work.testing.SynchronousExecutor import androidx.work.testing.WorkManagerTestInitHelper import com.github.takahirom.roborazzi.captureRoboImage -import com.google.accompanist.testharness.TestHarness import com.google.samples.apps.nowinandroid.core.data.repository.TopicsRepository import com.google.samples.apps.nowinandroid.core.data.repository.UserDataRepository import com.google.samples.apps.nowinandroid.core.data.repository.UserNewsResourceRepository @@ -143,19 +143,19 @@ class NiaAppScreenSizesScreenshotTests { CompositionLocalProvider( LocalInspectionMode provides true, ) { - TestHarness(size = DpSize(width, height)) { - BoxWithConstraints { - NiaTheme { - val fakeAppState = rememberNiaAppState( - windowSizeClass = WindowSizeClass.calculateFromSize( - DpSize(maxWidth, maxHeight), - ), - networkMonitor = networkMonitor, - userNewsResourceRepository = userNewsResourceRepository, - timeZoneMonitor = timeZoneMonitor, - ) - NiaApp(fakeAppState) - } + DeviceConfigurationOverride( + override = DeviceConfigurationOverride.ForcedSize(DpSize(width, height)), + ) { + NiaTheme { + val fakeAppState = rememberNiaAppState( + windowSizeClass = WindowSizeClass.calculateFromSize( + DpSize(width, height), + ), + networkMonitor = networkMonitor, + userNewsResourceRepository = userNewsResourceRepository, + timeZoneMonitor = timeZoneMonitor, + ) + NiaApp(fakeAppState) } } } diff --git a/app/src/testDemo/kotlin/com/google/samples/apps/nowinandroid/ui/SnackbarScreenshotTests.kt b/app/src/testDemo/kotlin/com/google/samples/apps/nowinandroid/ui/SnackbarScreenshotTests.kt index fa1ba1036a..c3ad185912 100644 --- a/app/src/testDemo/kotlin/com/google/samples/apps/nowinandroid/ui/SnackbarScreenshotTests.kt +++ b/app/src/testDemo/kotlin/com/google/samples/apps/nowinandroid/ui/SnackbarScreenshotTests.kt @@ -23,6 +23,8 @@ import androidx.compose.material3.SnackbarHostState import androidx.compose.material3.windowsizeclass.ExperimentalMaterial3WindowSizeClassApi import androidx.compose.material3.windowsizeclass.WindowSizeClass import androidx.compose.runtime.rememberCoroutineScope +import androidx.compose.ui.test.DeviceConfigurationOverride +import androidx.compose.ui.test.ForcedSize import androidx.compose.ui.test.junit4.createAndroidComposeRule import androidx.compose.ui.test.onRoot import androidx.compose.ui.unit.Dp @@ -33,7 +35,6 @@ import androidx.work.Configuration import androidx.work.testing.SynchronousExecutor import androidx.work.testing.WorkManagerTestInitHelper import com.github.takahirom.roborazzi.captureRoboImage -import com.google.accompanist.testharness.TestHarness import com.google.samples.apps.nowinandroid.core.data.repository.TopicsRepository import com.google.samples.apps.nowinandroid.core.data.repository.UserNewsResourceRepository import com.google.samples.apps.nowinandroid.core.data.test.repository.FakeUserDataRepository @@ -208,7 +209,9 @@ class SnackbarScreenshotTests { composeTestRule.setContent { scope = rememberCoroutineScope() - TestHarness(size = DpSize(width, height)) { + DeviceConfigurationOverride( + DeviceConfigurationOverride.ForcedSize(DpSize(width, height)), + ) { BoxWithConstraints { val appState = rememberNiaAppState( windowSizeClass = WindowSizeClass.calculateFromSize( diff --git a/app/src/testDemo/screenshots/compactWidth_expandedHeight_showsNavigationBar.png b/app/src/testDemo/screenshots/compactWidth_expandedHeight_showsNavigationBar.png index 1c9213f3e5..279efe6d0e 100644 Binary files a/app/src/testDemo/screenshots/compactWidth_expandedHeight_showsNavigationBar.png and b/app/src/testDemo/screenshots/compactWidth_expandedHeight_showsNavigationBar.png differ diff --git a/app/src/testDemo/screenshots/expandedWidth_expandedHeight_showsNavigationRail.png b/app/src/testDemo/screenshots/expandedWidth_expandedHeight_showsNavigationRail.png index 70af31fa71..53bf6f3c5e 100644 Binary files a/app/src/testDemo/screenshots/expandedWidth_expandedHeight_showsNavigationRail.png and b/app/src/testDemo/screenshots/expandedWidth_expandedHeight_showsNavigationRail.png differ diff --git a/app/src/testDemo/screenshots/mediumWidth_expandedHeight_showsNavigationRail.png b/app/src/testDemo/screenshots/mediumWidth_expandedHeight_showsNavigationRail.png index 233718a57c..3e38938d63 100644 Binary files a/app/src/testDemo/screenshots/mediumWidth_expandedHeight_showsNavigationRail.png and b/app/src/testDemo/screenshots/mediumWidth_expandedHeight_showsNavigationRail.png differ diff --git a/core/designsystem/build.gradle.kts b/core/designsystem/build.gradle.kts index 548e635bb0..cf3e4c51f8 100644 --- a/core/designsystem/build.gradle.kts +++ b/core/designsystem/build.gradle.kts @@ -40,7 +40,6 @@ dependencies { implementation(libs.coil.kt.compose) testImplementation(libs.androidx.compose.ui.test) - testImplementation(libs.accompanist.testharness) testImplementation(libs.hilt.android.testing) testImplementation(libs.robolectric) testImplementation(libs.roborazzi) diff --git a/core/designsystem/src/main/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/icon/NiaIcons.kt b/core/designsystem/src/main/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/icon/NiaIcons.kt index 6b77f73943..dfa68e772b 100644 --- a/core/designsystem/src/main/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/icon/NiaIcons.kt +++ b/core/designsystem/src/main/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/icon/NiaIcons.kt @@ -23,7 +23,6 @@ import androidx.compose.material.icons.filled.MoreVert import androidx.compose.material.icons.outlined.Bookmarks import androidx.compose.material.icons.outlined.Upcoming import androidx.compose.material.icons.rounded.Add -import androidx.compose.material.icons.rounded.ArrowBack import androidx.compose.material.icons.rounded.Bookmark import androidx.compose.material.icons.rounded.BookmarkBorder import androidx.compose.material.icons.rounded.Bookmarks @@ -33,7 +32,6 @@ import androidx.compose.material.icons.rounded.Grid3x3 import androidx.compose.material.icons.rounded.Person import androidx.compose.material.icons.rounded.Search import androidx.compose.material.icons.rounded.Settings -import androidx.compose.material.icons.rounded.ShortText import androidx.compose.material.icons.rounded.Upcoming import androidx.compose.material.icons.rounded.ViewDay import androidx.compose.ui.graphics.vector.ImageVector diff --git a/core/designsystem/src/test/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/FilterChipScreenshotTests.kt b/core/designsystem/src/test/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/FilterChipScreenshotTests.kt index 92d5467aec..7a6a92a1d1 100644 --- a/core/designsystem/src/test/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/FilterChipScreenshotTests.kt +++ b/core/designsystem/src/test/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/FilterChipScreenshotTests.kt @@ -21,12 +21,15 @@ import androidx.compose.material3.Surface import androidx.compose.material3.Text import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.ui.platform.LocalInspectionMode +import androidx.compose.ui.test.DeviceConfigurationOverride +import androidx.compose.ui.test.FontScale +import androidx.compose.ui.test.ForcedSize import androidx.compose.ui.test.junit4.createAndroidComposeRule import androidx.compose.ui.test.onRoot +import androidx.compose.ui.test.then import androidx.compose.ui.unit.DpSize import androidx.compose.ui.unit.dp import com.github.takahirom.roborazzi.captureRoboImage -import com.google.accompanist.testharness.TestHarness import com.google.samples.apps.nowinandroid.core.designsystem.component.NiaBackground import com.google.samples.apps.nowinandroid.core.designsystem.component.NiaFilterChip import com.google.samples.apps.nowinandroid.core.designsystem.theme.NiaTheme @@ -78,7 +81,10 @@ class FilterChipScreenshotTests { CompositionLocalProvider( LocalInspectionMode provides true, ) { - TestHarness(fontScale = 2f, size = DpSize(80.dp, 40.dp)) { + DeviceConfigurationOverride( + DeviceConfigurationOverride.FontScale(2f) then + DeviceConfigurationOverride.ForcedSize(DpSize(80.dp, 40.dp)), + ) { NiaTheme { NiaBackground { NiaFilterChip(selected = true, onSelectedChange = {}) { diff --git a/core/designsystem/src/test/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/NavigationScreenshotTests.kt b/core/designsystem/src/test/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/NavigationScreenshotTests.kt index 1d1e70f7de..be2c6fa28a 100644 --- a/core/designsystem/src/test/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/NavigationScreenshotTests.kt +++ b/core/designsystem/src/test/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/NavigationScreenshotTests.kt @@ -23,10 +23,11 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.ui.platform.LocalInspectionMode +import androidx.compose.ui.test.DeviceConfigurationOverride +import androidx.compose.ui.test.FontScale import androidx.compose.ui.test.junit4.createAndroidComposeRule import androidx.compose.ui.test.onRoot import com.github.takahirom.roborazzi.captureRoboImage -import com.google.accompanist.testharness.TestHarness import com.google.samples.apps.nowinandroid.core.designsystem.component.NiaNavigationBar import com.google.samples.apps.nowinandroid.core.designsystem.component.NiaNavigationBarItem import com.google.samples.apps.nowinandroid.core.designsystem.icon.NiaIcons @@ -66,7 +67,9 @@ class NavigationScreenshotTests { CompositionLocalProvider( LocalInspectionMode provides true, ) { - TestHarness(fontScale = 2f) { + DeviceConfigurationOverride( + DeviceConfigurationOverride.FontScale(2f), + ) { NiaTheme { NiaNavigationBarExample("Looong item") } diff --git a/core/designsystem/src/test/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/TabsScreenshotTests.kt b/core/designsystem/src/test/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/TabsScreenshotTests.kt index 19f7bea876..8ab711505d 100644 --- a/core/designsystem/src/test/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/TabsScreenshotTests.kt +++ b/core/designsystem/src/test/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/TabsScreenshotTests.kt @@ -22,10 +22,11 @@ import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.ui.platform.LocalInspectionMode +import androidx.compose.ui.test.DeviceConfigurationOverride +import androidx.compose.ui.test.FontScale import androidx.compose.ui.test.junit4.createAndroidComposeRule import androidx.compose.ui.test.onRoot import com.github.takahirom.roborazzi.captureRoboImage -import com.google.accompanist.testharness.TestHarness import com.google.samples.apps.nowinandroid.core.designsystem.component.NiaTab import com.google.samples.apps.nowinandroid.core.designsystem.component.NiaTabRow import com.google.samples.apps.nowinandroid.core.designsystem.theme.NiaTheme @@ -62,7 +63,9 @@ class TabsScreenshotTests { CompositionLocalProvider( LocalInspectionMode provides true, ) { - TestHarness(fontScale = 2f) { + DeviceConfigurationOverride( + DeviceConfigurationOverride.FontScale(2f), + ) { NiaTheme { NiaTabsExample("Looooong item") } diff --git a/core/designsystem/src/test/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/TagScreenshotTests.kt b/core/designsystem/src/test/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/TagScreenshotTests.kt index d18f7dec59..8a519942dd 100644 --- a/core/designsystem/src/test/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/TagScreenshotTests.kt +++ b/core/designsystem/src/test/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/TagScreenshotTests.kt @@ -20,10 +20,11 @@ import androidx.activity.ComponentActivity import androidx.compose.material3.Text import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.ui.platform.LocalInspectionMode +import androidx.compose.ui.test.DeviceConfigurationOverride +import androidx.compose.ui.test.FontScale import androidx.compose.ui.test.junit4.createAndroidComposeRule import androidx.compose.ui.test.onRoot import com.github.takahirom.roborazzi.captureRoboImage -import com.google.accompanist.testharness.TestHarness import com.google.samples.apps.nowinandroid.core.designsystem.component.NiaTopicTag import com.google.samples.apps.nowinandroid.core.designsystem.theme.NiaTheme import com.google.samples.apps.nowinandroid.core.testing.util.DefaultRoborazziOptions @@ -61,7 +62,9 @@ class TagScreenshotTests { CompositionLocalProvider( LocalInspectionMode provides true, ) { - TestHarness(fontScale = 2f) { + DeviceConfigurationOverride( + DeviceConfigurationOverride.Companion.FontScale(2f), + ) { NiaTheme { NiaTopicTag(followed = true, onClick = {}) { Text("LOOOOONG TOPIC") diff --git a/core/designsystem/src/test/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/TopAppBarScreenshotTests.kt b/core/designsystem/src/test/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/TopAppBarScreenshotTests.kt index 325d9a501b..5988ed592c 100644 --- a/core/designsystem/src/test/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/TopAppBarScreenshotTests.kt +++ b/core/designsystem/src/test/kotlin/com/google/samples/apps/nowinandroid/core/designsystem/TopAppBarScreenshotTests.kt @@ -16,16 +16,16 @@ package com.google.samples.apps.nowinandroid.core.designsystem -import android.R.string import androidx.activity.ComponentActivity import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.ui.platform.LocalInspectionMode +import androidx.compose.ui.test.DeviceConfigurationOverride +import androidx.compose.ui.test.FontScale import androidx.compose.ui.test.junit4.createAndroidComposeRule import androidx.compose.ui.test.onRoot import com.github.takahirom.roborazzi.captureRoboImage -import com.google.accompanist.testharness.TestHarness import com.google.samples.apps.nowinandroid.core.designsystem.component.NiaTopAppBar import com.google.samples.apps.nowinandroid.core.designsystem.icon.NiaIcons import com.google.samples.apps.nowinandroid.core.designsystem.theme.NiaTheme @@ -63,7 +63,9 @@ class TopAppBarScreenshotTests { CompositionLocalProvider( LocalInspectionMode provides true, ) { - TestHarness(fontScale = 2f) { + DeviceConfigurationOverride( + DeviceConfigurationOverride.FontScale(2f), + ) { NiaTheme { NiaTopAppBarExample() } diff --git a/core/designsystem/src/test/screenshots/LoadingWheel/LoadingWheel_animation_115.png b/core/designsystem/src/test/screenshots/LoadingWheel/LoadingWheel_animation_115.png index 6d023a207e..5aa1eb89ad 100644 Binary files a/core/designsystem/src/test/screenshots/LoadingWheel/LoadingWheel_animation_115.png and b/core/designsystem/src/test/screenshots/LoadingWheel/LoadingWheel_animation_115.png differ diff --git a/core/designsystem/src/test/screenshots/LoadingWheel/LoadingWheel_animation_20.png b/core/designsystem/src/test/screenshots/LoadingWheel/LoadingWheel_animation_20.png index c125faccf6..74309056f7 100644 Binary files a/core/designsystem/src/test/screenshots/LoadingWheel/LoadingWheel_animation_20.png and b/core/designsystem/src/test/screenshots/LoadingWheel/LoadingWheel_animation_20.png differ diff --git a/core/screenshot-testing/build.gradle.kts b/core/screenshot-testing/build.gradle.kts index 4e9a931b02..fb23cf0577 100644 --- a/core/screenshot-testing/build.gradle.kts +++ b/core/screenshot-testing/build.gradle.kts @@ -25,7 +25,7 @@ android { dependencies { api(libs.roborazzi) - implementation(libs.accompanist.testharness) + implementation(libs.androidx.compose.ui.test) implementation(libs.androidx.activity.compose) implementation(libs.androidx.compose.ui.test) implementation(libs.robolectric) diff --git a/core/screenshot-testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/util/ScreenshotHelper.kt b/core/screenshot-testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/util/ScreenshotHelper.kt index 468fff8dfb..f11651220e 100644 --- a/core/screenshot-testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/util/ScreenshotHelper.kt +++ b/core/screenshot-testing/src/main/kotlin/com/google/samples/apps/nowinandroid/core/testing/util/ScreenshotHelper.kt @@ -25,6 +25,8 @@ import androidx.compose.runtime.key import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.setValue import androidx.compose.ui.platform.LocalInspectionMode +import androidx.compose.ui.test.DarkMode +import androidx.compose.ui.test.DeviceConfigurationOverride import androidx.compose.ui.test.junit4.AndroidComposeTestRule import androidx.compose.ui.test.onRoot import androidx.test.ext.junit.rules.ActivityScenarioRule @@ -32,7 +34,6 @@ import com.github.takahirom.roborazzi.RoborazziOptions import com.github.takahirom.roborazzi.RoborazziOptions.CompareOptions import com.github.takahirom.roborazzi.RoborazziOptions.RecordOptions import com.github.takahirom.roborazzi.captureRoboImage -import com.google.accompanist.testharness.TestHarness import com.google.samples.apps.nowinandroid.core.designsystem.theme.NiaTheme import org.robolectric.RuntimeEnvironment @@ -75,7 +76,9 @@ fun AndroidComposeTestRule, A>.c CompositionLocalProvider( LocalInspectionMode provides true, ) { - TestHarness(darkMode = darkMode) { + DeviceConfigurationOverride( + override = DeviceConfigurationOverride.Companion.DarkMode(darkMode), + ) { body() } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 0aff27c8c4..7c354432c4 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -9,6 +9,7 @@ androidxAppCompat = "1.6.1" androidxBrowser = "1.8.0" androidxComposeBom = "2024.02.02" androidxComposeCompiler = "1.5.8" +androidxComposeUiTest = "1.7.0-alpha06" androidxComposeMaterial3Adaptive = "1.0.0-alpha10" androidxComposeRuntimeTracing = "1.0.0-beta01" androidxCore = "1.12.0" @@ -61,7 +62,6 @@ turbine = "1.0.0" [libraries] accompanist-permissions = { group = "com.google.accompanist", name = "accompanist-permissions", version.ref = "accompanist" } -accompanist-testharness = { group = "com.google.accompanist", name = "accompanist-testharness", version.ref = "accompanist" } android-desugarJdkLibs = { group = "com.android.tools", name = "desugar_jdk_libs", version.ref = "androidDesugarJdkLibs" } androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "androidxActivity" } androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "androidxAppCompat" } @@ -78,7 +78,7 @@ androidx-compose-material3-adaptive-navigation = { group = "androidx.compose.mat androidx-compose-material3-windowSizeClass = { group = "androidx.compose.material3", name = "material3-window-size-class" } androidx-compose-runtime = { group = "androidx.compose.runtime", name = "runtime" } androidx-compose-runtime-tracing = { group = "androidx.compose.runtime", name = "runtime-tracing", version.ref = "androidxComposeRuntimeTracing" } -androidx-compose-ui-test = { group = "androidx.compose.ui", name = "ui-test-junit4" } +androidx-compose-ui-test = { group = "androidx.compose.ui", name = "ui-test-junit4", version.ref = "androidxComposeUiTest" } androidx-compose-ui-testManifest = { group = "androidx.compose.ui", name = "ui-test-manifest" } androidx-compose-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" } androidx-compose-ui-tooling-preview = { group = "androidx.compose.ui", name = "ui-tooling-preview" }