Skip to content

Commit 14557ce

Browse files
committed
Screenshot testing
1 parent 97c8cf8 commit 14557ce

4 files changed

Lines changed: 14 additions & 1 deletion

File tree

app/build.gradle.kts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ plugins {
33
alias(libs.plugins.kotlin.android)
44
alias(libs.plugins.kotlin.compose)
55
alias(libs.plugins.kotlin.serialization)
6+
alias(libs.plugins.screenshot)
67
id("kotlin-parcelize")
78
}
89

@@ -74,6 +75,12 @@ android {
7475
includeInApk = false
7576
includeInBundle = false
7677
}
78+
experimentalProperties["android.experimental.enableScreenshotTest"] = true
79+
testOptions {
80+
screenshotTests {
81+
imageDifferenceThreshold = 0.0001f // 0.01%
82+
}
83+
}
7784
}
7885

7986
dependencies {
@@ -135,4 +142,5 @@ dependencies {
135142
debugImplementation(libs.ui.test.manifest)
136143
debugImplementation(libs.androidx.ui.tooling)
137144
debugImplementation(libs.androidx.ui.test.manifest)
145+
screenshotTestImplementation(libs.androidx.compose.ui.tooling)
138146
}

build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ plugins {
33
alias(libs.plugins.android.application) apply false
44
alias(libs.plugins.kotlin.android) apply false
55
alias(libs.plugins.kotlin.compose) apply false
6+
alias(libs.plugins.screenshot) apply false
67
}

gradle.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ kotlin.code.style=official
2020
# Enables namespacing of each library's R class so that its R class includes only the
2121
# resources declared in the library itself and none from the library's dependencies,
2222
# thereby reducing the size of the R class for that library
23-
android.nonTransitiveRClass=true
23+
android.nonTransitiveRClass=true
24+
android.experimental.enableScreenshotTest=true

gradle/libs.versions.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ zoomable = "2.6.0"
3838
cameraCamera2 = "1.4.2"
3939
cameraView = "1.4.2"
4040
foundation = "1.8.1"
41+
screenshot = "0.0.1-alpha09"
4142

4243
[libraries]
4344
accompanist-permissions = { module = "com.google.accompanist:accompanist-permissions", version.ref = "accompanistPermissions" }
@@ -93,9 +94,11 @@ ui-test-junit4 = { module = "androidx.compose.ui:ui-test-junit4" }
9394
ui-test-manifest = { module = "androidx.compose.ui:ui-test-manifest" }
9495
zoomable = { module = "net.engawapg.lib:zoomable", version.ref = "zoomable" }
9596
androidx-work-runtime-ktx = { module = "androidx.work:work-runtime-ktx", version.ref = "workManager" }
97+
androidx-compose-ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" }
9698

9799
[plugins]
98100
android-application = { id = "com.android.application", version.ref = "agp" }
99101
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
100102
kotlin-compose = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
101103
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
104+
screenshot = { id = "com.android.compose.screenshot", version.ref = "screenshot" }

0 commit comments

Comments
 (0)