From 118bcf2e116f956ee827d09fa586a76c4d1c092e Mon Sep 17 00:00:00 2001 From: Geoff Powell Date: Fri, 22 Mar 2024 13:25:02 -0400 Subject: [PATCH] Add support for render mode SHRINK for AccessibilityRenderExtension --- .../paparazzi/gradle/PaparazziPluginTest.kt | 24 +++++++++++ .../build.gradle | 32 ++++++++++++++ .../AccessibilityRenderExtensionShrinkTest.kt | 29 +++++++++++++ .../test}/AccessibilityRenderExtensionTest.kt | 39 ++---------------- .../test/resources/accessibility-new-view.png | Bin .../test/resources/accessibility-shrink.png | Bin 0 -> 9911 bytes .../src/test/resources/accessibility.png | Bin .../AccessibilityRenderExtension.kt | 5 ++- 8 files changed, 92 insertions(+), 37 deletions(-) create mode 100644 paparazzi-gradle-plugin/src/test/projects/verify-accessibility-render-extension/build.gradle create mode 100644 paparazzi-gradle-plugin/src/test/projects/verify-accessibility-render-extension/src/test/java/app/cash/paparazzi/plugin/test/AccessibilityRenderExtensionShrinkTest.kt rename {paparazzi/src/test/java/app/cash/paparazzi/accessibility => paparazzi-gradle-plugin/src/test/projects/verify-accessibility-render-extension/src/test/java/app/cash/paparazzi/plugin/test}/AccessibilityRenderExtensionTest.kt (72%) rename {paparazzi => paparazzi-gradle-plugin/src/test/projects/verify-accessibility-render-extension}/src/test/resources/accessibility-new-view.png (100%) create mode 100644 paparazzi-gradle-plugin/src/test/projects/verify-accessibility-render-extension/src/test/resources/accessibility-shrink.png rename {paparazzi => paparazzi-gradle-plugin/src/test/projects/verify-accessibility-render-extension}/src/test/resources/accessibility.png (100%) diff --git a/paparazzi-gradle-plugin/src/test/java/app/cash/paparazzi/gradle/PaparazziPluginTest.kt b/paparazzi-gradle-plugin/src/test/java/app/cash/paparazzi/gradle/PaparazziPluginTest.kt index 5bef3864b0..7fc2f37be6 100644 --- a/paparazzi-gradle-plugin/src/test/java/app/cash/paparazzi/gradle/PaparazziPluginTest.kt +++ b/paparazzi-gradle-plugin/src/test/java/app/cash/paparazzi/gradle/PaparazziPluginTest.kt @@ -10,6 +10,7 @@ import okio.buffer import okio.source import org.gradle.testkit.runner.BuildResult import org.gradle.testkit.runner.GradleRunner +import org.gradle.testkit.runner.TaskOutcome import org.gradle.testkit.runner.TaskOutcome.FROM_CACHE import org.gradle.testkit.runner.TaskOutcome.SUCCESS import org.junit.After @@ -626,6 +627,29 @@ class PaparazziPluginTest { assertThat(result.task(":testDebugUnitTest")).isNotNull() } + @Test + fun verifyAccessibilityRenderExtension() { + val fixtureRoot = File("src/test/projects/verify-accessibility-render-extension") + + gradleRunner + .withArguments("testDebug", "--stacktrace") + .forwardOutput() + .runFixture(fixtureRoot) { build() } + + val snapshotsDir = File(fixtureRoot, "build/reports/paparazzi/debug/images") + val snapshots = snapshotsDir.listFiles() + assertThat(snapshots!!).hasLength(2) + + var snapshotImage = snapshots[0] + var goldenImage = File(fixtureRoot, "src/test/resources/accessibility-shrink.png") + assertThat(snapshotImage).isSimilarTo(goldenImage).withDefaultThreshold() + snapshotImage = snapshots[1] + goldenImage = File(fixtureRoot, "src/test/resources/accessibility-new-view.png") + assertThat(snapshotImage).isSimilarTo(goldenImage).withDefaultThreshold() + goldenImage = File(fixtureRoot, "src/test/resources/accessibility.png") + assertThat(snapshotImage).isSimilarTo(goldenImage).withDefaultThreshold() + } + @Test fun verifyAllVariants() { val fixtureRoot = File("src/test/projects/verify-mode-success") diff --git a/paparazzi-gradle-plugin/src/test/projects/verify-accessibility-render-extension/build.gradle b/paparazzi-gradle-plugin/src/test/projects/verify-accessibility-render-extension/build.gradle new file mode 100644 index 0000000000..5847ed5eaf --- /dev/null +++ b/paparazzi-gradle-plugin/src/test/projects/verify-accessibility-render-extension/build.gradle @@ -0,0 +1,32 @@ +plugins { + id 'com.android.library' + id 'kotlin-android' + id 'app.cash.paparazzi' +} + +android { + namespace 'app.cash.paparazzi.plugin.test' + compileSdk libs.versions.compileSdk.get() as int + defaultConfig { + minSdk libs.versions.minSdk.get() as int + } + compileOptions { + sourceCompatibility = libs.versions.javaTarget.get() + targetCompatibility = libs.versions.javaTarget.get() + } + kotlinOptions { + jvmTarget = libs.versions.javaTarget.get() + } + buildFeatures { + compose true + } + composeOptions { + kotlinCompilerExtensionVersion libs.versions.composeCompiler.get() + } +} + +dependencies { + implementation libs.androidx.appcompat +} + +apply from: '../guava-fix.gradle' diff --git a/paparazzi-gradle-plugin/src/test/projects/verify-accessibility-render-extension/src/test/java/app/cash/paparazzi/plugin/test/AccessibilityRenderExtensionShrinkTest.kt b/paparazzi-gradle-plugin/src/test/projects/verify-accessibility-render-extension/src/test/java/app/cash/paparazzi/plugin/test/AccessibilityRenderExtensionShrinkTest.kt new file mode 100644 index 0000000000..4d9987f216 --- /dev/null +++ b/paparazzi-gradle-plugin/src/test/projects/verify-accessibility-render-extension/src/test/java/app/cash/paparazzi/plugin/test/AccessibilityRenderExtensionShrinkTest.kt @@ -0,0 +1,29 @@ +package app.cash.paparazzi.plugin.test + +import android.widget.TextView +import app.cash.paparazzi.DeviceConfig +import app.cash.paparazzi.Paparazzi +import app.cash.paparazzi.accessibility.AccessibilityRenderExtension +import com.android.ide.common.rendering.api.SessionParams +import org.junit.Rule +import org.junit.Test + +class AccessibilityRenderExtensionShrinkTest { + + @get:Rule + val paparazzi = Paparazzi( + deviceConfig = DeviceConfig.NEXUS_5, + renderExtensions = setOf(AccessibilityRenderExtension()), + renderingMode = SessionParams.RenderingMode.SHRINK + ) + + @Test + fun `verify baseline`() { + val view = TextView(paparazzi.context).apply { + id = 1 + text = "Text View Sample" + setPadding(50, 50, 50, 50) + } + paparazzi.snapshot(view, name = "accessibility-shrink") + } +} diff --git a/paparazzi/src/test/java/app/cash/paparazzi/accessibility/AccessibilityRenderExtensionTest.kt b/paparazzi-gradle-plugin/src/test/projects/verify-accessibility-render-extension/src/test/java/app/cash/paparazzi/plugin/test/AccessibilityRenderExtensionTest.kt similarity index 72% rename from paparazzi/src/test/java/app/cash/paparazzi/accessibility/AccessibilityRenderExtensionTest.kt rename to paparazzi-gradle-plugin/src/test/projects/verify-accessibility-render-extension/src/test/java/app/cash/paparazzi/plugin/test/AccessibilityRenderExtensionTest.kt index 8e6e56109c..900efd627e 100644 --- a/paparazzi/src/test/java/app/cash/paparazzi/accessibility/AccessibilityRenderExtensionTest.kt +++ b/paparazzi-gradle-plugin/src/test/projects/verify-accessibility-render-extension/src/test/java/app/cash/paparazzi/plugin/test/AccessibilityRenderExtensionTest.kt @@ -1,4 +1,4 @@ -package app.cash.paparazzi.accessibility +package app.cash.paparazzi.plugin.test import android.content.Context import android.graphics.Color @@ -13,22 +13,15 @@ import android.widget.LinearLayout import android.widget.TextView import app.cash.paparazzi.DeviceConfig import app.cash.paparazzi.Paparazzi -import app.cash.paparazzi.Snapshot -import app.cash.paparazzi.SnapshotHandler -import app.cash.paparazzi.internal.ImageUtils +import app.cash.paparazzi.accessibility.AccessibilityRenderExtension import org.junit.Rule import org.junit.Test -import java.awt.image.BufferedImage -import java.io.File -import javax.imageio.ImageIO class AccessibilityRenderExtensionTest { - private val snapshotHandler = TestSnapshotVerifier() @get:Rule val paparazzi = Paparazzi( deviceConfig = DeviceConfig.NEXUS_5, - snapshotHandler = snapshotHandler, renderExtensions = setOf(AccessibilityRenderExtension()) ) @@ -81,7 +74,7 @@ class AccessibilityRenderExtensionTest { View(context).apply { id = 3 layoutParams = LinearLayout.LayoutParams(100, 100).apply { - setMarginsRelative(20, 20, 20, 20) + setMargins(20, 20, 20, 20) } contentDescription = "Margin Sample" } @@ -91,7 +84,7 @@ class AccessibilityRenderExtensionTest { View(context).apply { id = 4 layoutParams = LinearLayout.LayoutParams(100, 100).apply { - setMarginsRelative(20, 20, 20, 20) + setMargins(20, 20, 20, 20) } foreground = GradientDrawable(TL_BR, intArrayOf(Color.YELLOW, Color.BLUE)).apply { shape = OVAL @@ -113,28 +106,4 @@ class AccessibilityRenderExtensionTest { } ) } - - private class TestSnapshotVerifier : SnapshotHandler { - override fun newFrameHandler( - snapshot: Snapshot, - frameCount: Int, - fps: Int - ): SnapshotHandler.FrameHandler { - return object : SnapshotHandler.FrameHandler { - override fun handle(image: BufferedImage) { - val expected = File("src/test/resources/${snapshot.name}.png") - ImageUtils.assertImageSimilar( - relativePath = expected.path, - image = image, - goldenImage = ImageIO.read(expected), - maxPercentDifferent = 0.1 - ) - } - - override fun close() = Unit - } - } - - override fun close() = Unit - } } diff --git a/paparazzi/src/test/resources/accessibility-new-view.png b/paparazzi-gradle-plugin/src/test/projects/verify-accessibility-render-extension/src/test/resources/accessibility-new-view.png similarity index 100% rename from paparazzi/src/test/resources/accessibility-new-view.png rename to paparazzi-gradle-plugin/src/test/projects/verify-accessibility-render-extension/src/test/resources/accessibility-new-view.png diff --git a/paparazzi-gradle-plugin/src/test/projects/verify-accessibility-render-extension/src/test/resources/accessibility-shrink.png b/paparazzi-gradle-plugin/src/test/projects/verify-accessibility-render-extension/src/test/resources/accessibility-shrink.png new file mode 100644 index 0000000000000000000000000000000000000000..acba682fb1149d960840ff5e8cab40cded85a0bb GIT binary patch literal 9911 zcmeHtc{r5s+xJZ+4U(e8S}8)73T13Xk+Ni&Y+n~VM1CLDBnaf-`HS=e&V zo;@!wy(y3t6ucsHHLY|1iDZj+oFMr)&ZD-kisFi7Wo6f&m%qbhJ$?RM4kVl9`8?~} zL!PXq5n7enMB?ZiBQXfY^w35%OV=ZP$?Zt>k4qu#YPHrb!&4Ngr%#`bYzKga&){|K z!oImR;foh9p50pq0CjTPl`dZNljh(BfGQn8_u|EX|4(AF-_C+Ce!TQflI|nw<_G^# zD0AlN*^nn%l(7$(j$SnYxUbC(efo5|eFg;W;Kh&b#s}?8=DR#G;i(UPK!zZ^_%b92_Ui>ko7 zJ_7zpF>I}Mj-atnx6MC5K1Som<&}{jTJ_l=7Fm1i-raUJ^0BfJga;APHkRm;YEZM* z<}HW!_`()YHj z`%hZEoU2-DuLyFUAFA*O;g-CAf%jMB4FHdk^+_iQrd97fqRkrv@(#to3yA!k;(_mm zdpXi=Jt^{wC2-{d(4%2V5;7sWE zz*QH~mu;6aN#G~tQ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-gradle-plugin/src/test/projects/verify-accessibility-render-extension/src/test/resources/accessibility.png similarity index 100% rename from paparazzi/src/test/resources/accessibility.png rename to paparazzi-gradle-plugin/src/test/projects/verify-accessibility-render-extension/src/test/resources/accessibility.png diff --git a/paparazzi/src/main/java/app/cash/paparazzi/accessibility/AccessibilityRenderExtension.kt b/paparazzi/src/main/java/app/cash/paparazzi/accessibility/AccessibilityRenderExtension.kt index eb17ce3465..49fc5af4e3 100644 --- a/paparazzi/src/main/java/app/cash/paparazzi/accessibility/AccessibilityRenderExtension.kt +++ b/paparazzi/src/main/java/app/cash/paparazzi/accessibility/AccessibilityRenderExtension.kt @@ -40,16 +40,17 @@ public class AccessibilityRenderExtension : RenderExtension { orientation = LinearLayout.HORIZONTAL weightSum = 2f layoutParams = ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT) + isMeasureWithLargestChildEnabled = true // Allows for snapshot with SHRINK render mode val overlay = AccessibilityOverlayView(context).apply { addView(contentView, FrameLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT)) } val contentLayoutParams = contentView.layoutParams ?: generateLayoutParams(null) - addView(overlay, LinearLayout.LayoutParams(contentLayoutParams.width, contentLayoutParams.height, 1f)) + addView(overlay, LinearLayout.LayoutParams(0, contentLayoutParams.height, 1f)) val overlayDetailsView = AccessibilityOverlayDetailsView(context) - addView(overlayDetailsView, LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT, 1f)) + addView(overlayDetailsView, LinearLayout.LayoutParams(0, MATCH_PARENT, 1f)) OneShotPreDrawListener.add(this) { val elements = buildList {