From 4eec47debaed312c093135607b4fecf469855d88 Mon Sep 17 00:00:00 2001 From: Simon Marquis Date: Wed, 21 Feb 2024 14:39:48 +0100 Subject: [PATCH 1/4] chore: replace deprecated Accompanist Test Harness with official `DeviceConfigurationOverride` Docs: https://google.github.io/accompanist/testharness/ --- catalog/build.gradle.kts | 2 +- .../com/adevinta/spark/catalog/CatalogApp.kt | 19 +++++++++---------- gradle/libs.versions.toml | 4 ++-- spark/build.gradle.kts | 4 ++-- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/catalog/build.gradle.kts b/catalog/build.gradle.kts index 783f7787d..b0d57cfd0 100644 --- a/catalog/build.gradle.kts +++ b/catalog/build.gradle.kts @@ -73,11 +73,11 @@ dependencies { implementation(libs.airbnb.showkase) - implementation(libs.accompanist.testharness) implementation(libs.accompanist.drawablepainter) implementation(libs.androidx.compose.foundation) implementation(libs.androidx.compose.ui) + implementation(libs.androidx.compose.ui.test) implementation(libs.androidx.compose.ui.tooling.preview) implementation(libs.androidx.compose.material.iconsExtended) implementation(libs.androidx.compose.material3) diff --git a/catalog/src/main/kotlin/com/adevinta/spark/catalog/CatalogApp.kt b/catalog/src/main/kotlin/com/adevinta/spark/catalog/CatalogApp.kt index 2467f10ce..350290174 100644 --- a/catalog/src/main/kotlin/com/adevinta/spark/catalog/CatalogApp.kt +++ b/catalog/src/main/kotlin/com/adevinta/spark/catalog/CatalogApp.kt @@ -56,6 +56,11 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.graphics.Color import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.platform.LocalLayoutDirection +import androidx.compose.ui.test.DarkMode +import androidx.compose.ui.test.DeviceConfigurationOverride +import androidx.compose.ui.test.FontScale +import androidx.compose.ui.test.LayoutDirection +import androidx.compose.ui.test.then import androidx.compose.ui.unit.LayoutDirection import androidx.compose.ui.unit.dp import androidx.navigation.compose.NavHost @@ -87,7 +92,6 @@ import com.adevinta.spark.catalog.ui.BackdropScaffoldDefaults import com.adevinta.spark.catalog.ui.BackdropValue import com.adevinta.spark.catalog.ui.rememberBackdropScaffoldState import com.airbnb.android.showkase.models.ShowkaseBrowserComponent -import com.google.accompanist.testharness.TestHarness import kotlinx.coroutines.launch @Composable @@ -146,15 +150,10 @@ internal fun ComponentActivity.CatalogApp( onDispose {} } - @Suppress("DEPRECATION") - TestHarness( - darkMode = useDark, - layoutDirection = layoutDirection, - fontScale = if (theme.fontScaleMode == FontScaleMode.System) { - LocalDensity.current.fontScale - } else { - theme.fontScale - }, + DeviceConfigurationOverride( + override = DeviceConfigurationOverride.DarkMode(useDark) + then DeviceConfigurationOverride.LayoutDirection(layoutDirection) + then DeviceConfigurationOverride.FontScale(theme.fontScale.takeUnless { theme.fontScaleMode == FontScaleMode.System } ?: LocalDensity.current.fontScale), ) { Box( modifier = Modifier.fillMaxSize(), diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index ca74ad568..a345442b1 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -39,7 +39,6 @@ accompanist-flowlayout = { module = "com.google.accompanist:accompanist-flowlayo accompanist-pager = { module = "com.google.accompanist:accompanist-pager", version.ref = "accompanist" } accompanist-permissions = { module = "com.google.accompanist:accompanist-permissions", version.ref = "accompanist" } accompanist-swiperefresh = { module = "com.google.accompanist:accompanist-swiperefresh", version.ref = "accompanist" } -accompanist-testharness = { module = "com.google.accompanist:accompanist-testharness", version.ref = "accompanist" } airbnb-showkase = { module = "com.airbnb.android:showkase", version.ref = "showkase" } airbnb-showkase-processor = { module = "com.airbnb.android:showkase-processor", version.ref = "showkase" } @@ -62,7 +61,8 @@ androidx-compose-ui = { module = "androidx.compose.ui:ui" } androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" } androidx-constraintlayoutCompose = { group = "androidx.constraintlayout", name = "constraintlayout-compose", version.ref = "constraintlayoutCompose" } androidx-compose-ui-text = { module = "androidx.compose.ui:ui-text-google-fonts" } -androidx-compose-ui-test = { module = "androidx.compose.ui:ui-test-junit4" } +androidx-compose-ui-test = { module = "androidx.compose.ui:ui-test", version = "1.7.0-alpha02" } +androidx-compose-ui-testJUnit = { module = "androidx.compose.ui:ui-test-junit4" } androidx-compose-ui-testManifest = { module = "androidx.compose.ui:ui-test-manifest" } androidx-compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling" } androidx-compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview" } diff --git a/spark/build.gradle.kts b/spark/build.gradle.kts index 5942a9634..7384bd80b 100644 --- a/spark/build.gradle.kts +++ b/spark/build.gradle.kts @@ -86,13 +86,13 @@ dependencies { testImplementation(libs.androidx.test.runner) testImplementation(libs.testParameterInjector) testImplementation(libs.robolectric) - testImplementation(libs.androidx.compose.ui.test) + testImplementation(libs.androidx.compose.ui.testJUnit) testImplementation(libs.androidx.compose.ui.testManifest) androidTestImplementation(libs.junit) androidTestImplementation(libs.kotlin.test) androidTestImplementation(libs.androidx.test.truth) androidTestImplementation(libs.androidx.test.runner) - androidTestImplementation(libs.androidx.compose.ui.test) + androidTestImplementation(libs.androidx.compose.ui.testJUnit) androidTestImplementation(libs.androidx.compose.ui.testManifest) } From 6ea52b0ce51b26b209689fed1b9285756b3c250e Mon Sep 17 00:00:00 2001 From: Simon Marquis Date: Wed, 21 Feb 2024 14:45:54 +0100 Subject: [PATCH 2/4] spotless --- .../main/kotlin/com/adevinta/spark/catalog/CatalogApp.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/catalog/src/main/kotlin/com/adevinta/spark/catalog/CatalogApp.kt b/catalog/src/main/kotlin/com/adevinta/spark/catalog/CatalogApp.kt index 350290174..f2e8042ec 100644 --- a/catalog/src/main/kotlin/com/adevinta/spark/catalog/CatalogApp.kt +++ b/catalog/src/main/kotlin/com/adevinta/spark/catalog/CatalogApp.kt @@ -153,7 +153,11 @@ internal fun ComponentActivity.CatalogApp( DeviceConfigurationOverride( override = DeviceConfigurationOverride.DarkMode(useDark) then DeviceConfigurationOverride.LayoutDirection(layoutDirection) - then DeviceConfigurationOverride.FontScale(theme.fontScale.takeUnless { theme.fontScaleMode == FontScaleMode.System } ?: LocalDensity.current.fontScale), + then DeviceConfigurationOverride.FontScale( + theme.fontScale.takeUnless { + theme.fontScaleMode == FontScaleMode.System + } ?: LocalDensity.current.fontScale, + ), ) { Box( modifier = Modifier.fillMaxSize(), From 151f22192fa6dacc194afa2db3264439c643fd05 Mon Sep 17 00:00:00 2001 From: Simon Marquis Date: Thu, 22 Feb 2024 14:54:07 +0100 Subject: [PATCH 3/4] Update libs.versions.toml --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index a345442b1..0e3d4ddeb 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -61,7 +61,7 @@ androidx-compose-ui = { module = "androidx.compose.ui:ui" } androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" } androidx-constraintlayoutCompose = { group = "androidx.constraintlayout", name = "constraintlayout-compose", version.ref = "constraintlayoutCompose" } androidx-compose-ui-text = { module = "androidx.compose.ui:ui-text-google-fonts" } -androidx-compose-ui-test = { module = "androidx.compose.ui:ui-test", version = "1.7.0-alpha02" } +androidx-compose-ui-test = { module = "androidx.compose.ui:ui-test", version = "1.7.0-alpha03" } androidx-compose-ui-testJUnit = { module = "androidx.compose.ui:ui-test-junit4" } androidx-compose-ui-testManifest = { module = "androidx.compose.ui:ui-test-manifest" } androidx-compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling" } From 5663f3296f8cc16544bdab236c56040bb23ea839 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Rayapoull=C3=A9?= Date: Thu, 26 Sep 2024 13:48:34 +0200 Subject: [PATCH 4/4] Apply spotless --- .../com/adevinta/spark/catalog/CatalogApp.kt | 16 ++++++++-------- gradle/libs.versions.toml | 2 +- ...cScreenshot_selectTextFieldShowcase__dark.png | 3 --- ...Screenshot_selectTextFieldShowcase__light.png | 3 --- 4 files changed, 9 insertions(+), 15 deletions(-) delete mode 100644 spark-screenshot-testing/src/test/snapshots/images/com.adevinta.spark.textfields_TextFieldDocScreenshot_selectTextFieldShowcase__dark.png delete mode 100644 spark-screenshot-testing/src/test/snapshots/images/com.adevinta.spark.textfields_TextFieldDocScreenshot_selectTextFieldShowcase__light.png diff --git a/catalog/src/main/kotlin/com/adevinta/spark/catalog/CatalogApp.kt b/catalog/src/main/kotlin/com/adevinta/spark/catalog/CatalogApp.kt index f2e8042ec..55a0616bd 100644 --- a/catalog/src/main/kotlin/com/adevinta/spark/catalog/CatalogApp.kt +++ b/catalog/src/main/kotlin/com/adevinta/spark/catalog/CatalogApp.kt @@ -150,14 +150,14 @@ internal fun ComponentActivity.CatalogApp( onDispose {} } - DeviceConfigurationOverride( - override = DeviceConfigurationOverride.DarkMode(useDark) - then DeviceConfigurationOverride.LayoutDirection(layoutDirection) - then DeviceConfigurationOverride.FontScale( - theme.fontScale.takeUnless { - theme.fontScaleMode == FontScaleMode.System - } ?: LocalDensity.current.fontScale, - ), + DeviceConfigurationOverride( + override = DeviceConfigurationOverride.DarkMode(useDark) + then DeviceConfigurationOverride.LayoutDirection(layoutDirection) + then DeviceConfigurationOverride.FontScale( + theme.fontScale.takeUnless { + theme.fontScaleMode == FontScaleMode.System + } ?: LocalDensity.current.fontScale, + ), ) { Box( modifier = Modifier.fillMaxSize(), diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 0e3d4ddeb..2e951e7e1 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -61,7 +61,7 @@ androidx-compose-ui = { module = "androidx.compose.ui:ui" } androidx-constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" } androidx-constraintlayoutCompose = { group = "androidx.constraintlayout", name = "constraintlayout-compose", version.ref = "constraintlayoutCompose" } androidx-compose-ui-text = { module = "androidx.compose.ui:ui-text-google-fonts" } -androidx-compose-ui-test = { module = "androidx.compose.ui:ui-test", version = "1.7.0-alpha03" } +androidx-compose-ui-test = { module = "androidx.compose.ui:ui-test" } androidx-compose-ui-testJUnit = { module = "androidx.compose.ui:ui-test-junit4" } androidx-compose-ui-testManifest = { module = "androidx.compose.ui:ui-test-manifest" } androidx-compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling" } diff --git a/spark-screenshot-testing/src/test/snapshots/images/com.adevinta.spark.textfields_TextFieldDocScreenshot_selectTextFieldShowcase__dark.png b/spark-screenshot-testing/src/test/snapshots/images/com.adevinta.spark.textfields_TextFieldDocScreenshot_selectTextFieldShowcase__dark.png deleted file mode 100644 index 4b4159aaf..000000000 --- a/spark-screenshot-testing/src/test/snapshots/images/com.adevinta.spark.textfields_TextFieldDocScreenshot_selectTextFieldShowcase__dark.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:c701a72e0c196b1af8636fc319dc2d4f3be9bf7db8025391e750c906b828f05c -size 72955 diff --git a/spark-screenshot-testing/src/test/snapshots/images/com.adevinta.spark.textfields_TextFieldDocScreenshot_selectTextFieldShowcase__light.png b/spark-screenshot-testing/src/test/snapshots/images/com.adevinta.spark.textfields_TextFieldDocScreenshot_selectTextFieldShowcase__light.png deleted file mode 100644 index 1a89e1598..000000000 --- a/spark-screenshot-testing/src/test/snapshots/images/com.adevinta.spark.textfields_TextFieldDocScreenshot_selectTextFieldShowcase__light.png +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:5eb91cf06020fb659cddfe42375c354094312ed98d8b3bb09de570e5cea3b8eb -size 74696