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 2beda99ea..f6a615601 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 @@ -56,6 +56,7 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.testTag import androidx.compose.ui.res.stringResource import androidx.compose.ui.semantics.semantics +import androidx.compose.ui.semantics.testTag import androidx.compose.ui.semantics.testTagsAsResourceId import androidx.compose.ui.unit.dp import androidx.lifecycle.compose.collectAsStateWithLifecycle @@ -89,6 +90,7 @@ fun NiaApp( windowSizeClass: WindowSizeClass, networkMonitor: NetworkMonitor, userNewsResourceRepository: UserNewsResourceRepository, + modifier: Modifier = Modifier, appState: NiaAppState = rememberNiaAppState( networkMonitor = networkMonitor, windowSizeClass = windowSizeClass, @@ -99,7 +101,7 @@ fun NiaApp( 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 61e88286f..8f9707f7e 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,15 +17,16 @@ 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.Modifier import androidx.compose.ui.platform.LocalInspectionMode +import androidx.compose.ui.platform.testTag 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.test.onNodeWithTag import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.DpSize import androidx.compose.ui.unit.dp @@ -136,6 +137,9 @@ class NiaAppScreenSizesScreenshotTests { } private fun testNiaAppScreenshotWithSize(width: Dp, height: Dp, screenshotName: String) { + // TODO: Remove this when https://b.corp.google.com/issues/327149166 is fixed + val appTestTag = "APP" + composeTestRule.setContent { CompositionLocalProvider( LocalInspectionMode provides true, @@ -150,13 +154,14 @@ class NiaAppScreenSizesScreenshotTests { ), networkMonitor = networkMonitor, userNewsResourceRepository = userNewsResourceRepository, + modifier = Modifier.testTag(appTestTag), ) } } } } - composeTestRule.onRoot() + composeTestRule.onNodeWithTag(appTestTag) .captureRoboImage( "src/testDemo/screenshots/$screenshotName.png", roborazziOptions = DefaultRoborazziOptions, diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 7781d142b..5b64a6801 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -8,7 +8,7 @@ androidxActivity = "1.8.0" androidxAppCompat = "1.6.1" androidxBrowser = "1.6.0" androidxComposeBom = "2024.02.00" -androidxComposeUiTest = "1.7.0-alpha02" +androidxComposeUiTest = "1.7.0-alpha03" androidxComposeCompiler = "1.5.7" androidxComposeRuntimeTracing = "1.0.0-beta01" androidxCore = "1.12.0"