Skip to content

Commit 9af18c9

Browse files
committed
chore: replace deprecated Accompanist Test Harness with official DeviceConfigurationOverride
Docs: https://google.github.io/accompanist/testharness/
1 parent 6231630 commit 9af18c9

File tree

4 files changed

+14
-21
lines changed

4 files changed

+14
-21
lines changed

catalog/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ dependencies {
7171

7272
implementation(libs.airbnb.showkase)
7373

74-
implementation(libs.accompanist.testharness)
7574
implementation(libs.accompanist.drawablepainter)
7675

7776
implementation(libs.androidx.compose.foundation)
7877
implementation(libs.androidx.compose.ui)
78+
implementation(libs.androidx.compose.ui.test)
7979
implementation(libs.androidx.compose.ui.tooling.preview)
8080
implementation(libs.androidx.compose.material.iconsExtended)
8181
implementation(libs.androidx.compose.material3)

catalog/src/main/kotlin/com/adevinta/spark/catalog/CatalogApp.kt

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import androidx.activity.SystemBarStyle
2626
import androidx.activity.enableEdgeToEdge
2727
import androidx.compose.animation.core.FastOutSlowInEasing
2828
import androidx.compose.animation.core.tween
29-
import androidx.compose.foundation.ExperimentalFoundationApi
3029
import androidx.compose.foundation.isSystemInDarkTheme
3130
import androidx.compose.foundation.layout.Box
3231
import androidx.compose.foundation.layout.PaddingValues
@@ -58,13 +57,16 @@ import androidx.compose.runtime.mutableStateOf
5857
import androidx.compose.runtime.remember
5958
import androidx.compose.runtime.rememberCoroutineScope
6059
import androidx.compose.runtime.saveable.rememberSaveable
61-
import androidx.compose.runtime.setValue
6260
import androidx.compose.ui.Alignment
63-
import androidx.compose.ui.ExperimentalComposeUiApi
6461
import androidx.compose.ui.Modifier
6562
import androidx.compose.ui.graphics.Color
6663
import androidx.compose.ui.platform.LocalDensity
6764
import androidx.compose.ui.platform.LocalLayoutDirection
65+
import androidx.compose.ui.test.DarkMode
66+
import androidx.compose.ui.test.DeviceConfigurationOverride
67+
import androidx.compose.ui.test.FontScale
68+
import androidx.compose.ui.test.LayoutDirection
69+
import androidx.compose.ui.test.then
6870
import androidx.compose.ui.unit.LayoutDirection
6971
import androidx.compose.ui.unit.dp
7072
import androidx.navigation.compose.NavHost
@@ -96,13 +98,8 @@ import com.adevinta.spark.catalog.themes.themeprovider.leboncoin.LeboncoinTheme
9698
import com.adevinta.spark.catalog.themes.themeprovider.milanuncios.MilanunciosTheme
9799
import com.adevinta.spark.catalog.themes.themeprovider.subito.SubitoTheme
98100
import com.airbnb.android.showkase.models.ShowkaseBrowserComponent
99-
import com.google.accompanist.testharness.TestHarness
100101
import kotlinx.coroutines.launch
101102

102-
@OptIn(
103-
ExperimentalFoundationApi::class,
104-
ExperimentalComposeUiApi::class,
105-
)
106103
@Composable
107104
internal fun ComponentActivity.CatalogApp(
108105
theme: Theme,
@@ -157,14 +154,10 @@ internal fun ComponentActivity.CatalogApp(
157154
onDispose {}
158155
}
159156

160-
TestHarness(
161-
darkMode = useDark,
162-
layoutDirection = layoutDirection,
163-
fontScale = if (theme.fontScaleMode == FontScaleMode.System) {
164-
LocalDensity.current.fontScale
165-
} else {
166-
theme.fontScale
167-
},
157+
DeviceConfigurationOverride(
158+
override = DeviceConfigurationOverride.DarkMode(useDark)
159+
then DeviceConfigurationOverride.LayoutDirection(layoutDirection)
160+
then DeviceConfigurationOverride.FontScale(theme.fontScale.takeUnless { theme.fontScaleMode == FontScaleMode.System } ?: LocalDensity.current.fontScale),
168161
) {
169162
Box(
170163
modifier = Modifier.fillMaxSize(),

gradle/libs.versions.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ accompanist-flowlayout = { module = "com.google.accompanist:accompanist-flowlayo
3737
accompanist-pager = { module = "com.google.accompanist:accompanist-pager", version.ref = "accompanist" }
3838
accompanist-permissions = { module = "com.google.accompanist:accompanist-permissions", version.ref = "accompanist" }
3939
accompanist-swiperefresh = { module = "com.google.accompanist:accompanist-swiperefresh", version.ref = "accompanist" }
40-
accompanist-testharness = { module = "com.google.accompanist:accompanist-testharness", version.ref = "accompanist" }
4140

4241
airbnb-showkase = { module = "com.airbnb.android:showkase", version.ref = "showkase" }
4342
airbnb-showkase-processor = { module = "com.airbnb.android:showkase-processor", version.ref = "showkase" }
@@ -59,7 +58,8 @@ androidx-compose-runtime-livedata = { module = "androidx.compose.runtime:runtime
5958
androidx-compose-ui = { module = "androidx.compose.ui:ui" }
6059
# https://developer.android.com/reference/kotlin/androidx/compose/ui/text/googlefonts/package-summary
6160
androidx-compose-ui-text = { module = "androidx.compose.ui:ui-text-google-fonts" }
62-
androidx-compose-ui-test = { module = "androidx.compose.ui:ui-test-junit4" }
61+
androidx-compose-ui-test = { module = "androidx.compose.ui:ui-test", version = "1.7.0-alpha02" }
62+
androidx-compose-ui-testJUnit = { module = "androidx.compose.ui:ui-test-junit4" }
6363
androidx-compose-ui-testManifest = { module = "androidx.compose.ui:ui-test-manifest" }
6464
androidx-compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling" }
6565
androidx-compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview" }

spark/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,13 @@ dependencies {
8585
testImplementation(libs.androidx.test.runner)
8686
testImplementation(libs.testParameterInjector)
8787
testImplementation(libs.robolectric)
88-
testImplementation(libs.androidx.compose.ui.test)
88+
testImplementation(libs.androidx.compose.ui.testJUnit)
8989
testImplementation(libs.androidx.compose.ui.testManifest)
9090

9191
androidTestImplementation(libs.junit)
9292
androidTestImplementation(libs.kotlin.test)
9393
androidTestImplementation(libs.androidx.test.truth)
9494
androidTestImplementation(libs.androidx.test.runner)
95-
androidTestImplementation(libs.androidx.compose.ui.test)
95+
androidTestImplementation(libs.androidx.compose.ui.testJUnit)
9696
androidTestImplementation(libs.androidx.compose.ui.testManifest)
9797
}

0 commit comments

Comments
 (0)