Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: replace deprecated Accompanist Test Harness with official DeviceConfigurationOverride #989

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion catalog/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
23 changes: 13 additions & 10 deletions catalog/src/main/kotlin/com/adevinta/spark/catalog/CatalogApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -146,15 +150,14 @@ 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(),
Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand All @@ -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" }
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" }
Expand Down

This file was deleted.

This file was deleted.

4 changes: 2 additions & 2 deletions spark/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Loading