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 676adb722f..5e404a063c 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 @@ -1,7 +1,6 @@ package app.cash.paparazzi.gradle import app.cash.paparazzi.gradle.ImageSubject.Companion.assertThat -import app.cash.paparazzi.gradle.ImageSubject.ImageAssert.Companion.DEFAULT_PERCENT_DIFFERENCE_THRESHOLD import app.cash.paparazzi.gradle.PrepareResourcesTask.Config import com.google.common.truth.Correspondence import com.google.common.truth.Truth.assertThat @@ -40,23 +39,11 @@ class PaparazziPluginTest { val fixtureRoot = File("src/test/projects/supports-application-modules") val result = gradleRunner - .withArguments("testDebug", "--stacktrace") + .withArguments("verifyPaparazziDebug", "--stacktrace") .runFixture(fixtureRoot) { build() } assertThat(result.task(":preparePaparazziDebugResources")).isNotNull() assertThat(result.task(":testDebugUnitTest")).isNotNull() - assertThat(result.output).doesNotContain( - "Currently, Paparazzi only works in Android library -- not application -- modules. " + - "See https://github.com/cashapp/paparazzi/issues/107" - ) - - val snapshotsDir = File(fixtureRoot, "build/reports/paparazzi/debug/images") - val snapshots = snapshotsDir.listFiles() - assertThat(snapshots!!).hasLength(1) - - val snapshotImage = snapshots[0] - val goldenImage = File(fixtureRoot, "src/test/resources/launch.png") - assertThat(snapshotImage).isSimilarTo(goldenImage).withDefaultThreshold() } @Test @@ -64,19 +51,11 @@ class PaparazziPluginTest { val fixtureRoot = File("src/test/projects/supports-dynamic-feature-modules") val result = gradleRunner - .withArguments(":dynamic_feature:testDebug", "--stacktrace") + .withArguments(":dynamic_feature:verifyPaparazziDebug", "--stacktrace") .runFixture(fixtureRoot) { build() } assertThat(result.task(":dynamic_feature:preparePaparazziDebugResources")).isNotNull() assertThat(result.task(":dynamic_feature:testDebugUnitTest")).isNotNull() - - val snapshotsDir = File(fixtureRoot, "dynamic_feature/build/reports/paparazzi/debug/images") - val snapshots = snapshotsDir.listFiles() - assertThat(snapshots!!).hasLength(1) - - val snapshotImage = snapshots[0] - val goldenImage = File(fixtureRoot, "dynamic_feature/src/test/resources/launch.png") - assertThat(snapshotImage).isSimilarTo(goldenImage).withDefaultThreshold() } @Test @@ -674,24 +653,8 @@ class PaparazziPluginTest { val fixtureRoot = File("src/test/projects/verify-rendering-modes") gradleRunner - .withArguments("testDebug", "--stacktrace") + .withArguments("verifyPaparazziDebug", "--stacktrace") .runFixture(fixtureRoot) { build() } - - val snapshotsDir = File(fixtureRoot, "build/reports/paparazzi/debug/images") - val snapshots = snapshotsDir.listFilesSorted() - assertThat(snapshots!!).hasSize(4) - - val normal = File(fixtureRoot, "src/test/resources/normal.png") - val horizontalScroll = File(fixtureRoot, "src/test/resources/horizontal_scroll.png") - val verticalScroll = File(fixtureRoot, "src/test/resources/vertical_scroll.png") - val shrink = File(fixtureRoot, "src/test/resources/shrink.png") - - assertThat(snapshots[0]).isSimilarTo(normal).withDefaultThreshold() - assertThat(snapshots[1]).isSimilarTo(horizontalScroll).withDefaultThreshold() - assertThat(snapshots[2]).isSimilarTo(verticalScroll).withDefaultThreshold() - // TODO: is this an issue with layoutlib or related to https://github.com/cashapp/paparazzi/issues/482? - assertThat(snapshots[3]).isSimilarTo(shrink) - .withThreshold(DEFAULT_PERCENT_DIFFERENCE_THRESHOLD + 0.007) } @Test @@ -756,17 +719,8 @@ class PaparazziPluginTest { val fixtureRoot = File("src/test/projects/widgets") gradleRunner - .withArguments("testDebug", "--stacktrace") + .withArguments("verifyPaparazziDebug", "--stacktrace") .runFixture(fixtureRoot) { build() } - - val snapshotsDir = File(fixtureRoot, "build/reports/paparazzi/debug/images") - val snapshots = snapshotsDir.listFilesSorted() - assertThat(snapshots!!).hasSize(2) - - val widgetImage = File(fixtureRoot, "src/test/resources/widget.png") - val fullScreenImage = File(fixtureRoot, "src/test/resources/full_screen.png") - assertThat(snapshots[0]).isSimilarTo(widgetImage).withDefaultThreshold() - assertThat(snapshots[1]).isSimilarTo(fullScreenImage).withDefaultThreshold() } @Test @@ -1218,19 +1172,11 @@ class PaparazziPluginTest { val fixtureRoot = File("src/test/projects/verify-snapshot") val result = gradleRunner - .withArguments("testDebug", "--stacktrace") + .withArguments("verifyPaparazziDebug", "--stacktrace") .runFixture(fixtureRoot) { build() } assertThat(result.task(":preparePaparazziDebugResources")).isNotNull() assertThat(result.task(":testDebugUnitTest")).isNotNull() - - val snapshotsDir = File(fixtureRoot, "build/reports/paparazzi/debug/images") - val snapshots = snapshotsDir.listFiles() - assertThat(snapshots!!).hasLength(1) - - val snapshotImage = snapshots[0] - val goldenImage = File(fixtureRoot, "src/test/resources/launch.png") - assertThat(snapshotImage).isSimilarTo(goldenImage).withDefaultThreshold() } @Test @@ -1238,15 +1184,11 @@ class PaparazziPluginTest { val fixtureRoot = File("src/test/projects/verify-gif") val result = gradleRunner - .withArguments("testDebug", "--stacktrace") + .withArguments("verifyPaparazziDebug", "--stacktrace") .runFixture(fixtureRoot) { build() } assertThat(result.task(":preparePaparazziDebugResources")).isNotNull() assertThat(result.task(":testDebugUnitTest")).isNotNull() - - val videoDir = File(fixtureRoot, "build/reports/paparazzi/debug/videos") - val videos = videoDir.listFiles() - assertThat(videos!!).hasLength(1) } @Test @@ -1254,16 +1196,8 @@ class PaparazziPluginTest { val fixtureRoot = File("src/test/projects/verify-svgs") gradleRunner - .withArguments("testDebug", "--stacktrace") + .withArguments("verifyPaparazziDebug", "--stacktrace") .runFixture(fixtureRoot) { build() } - - val snapshotsDir = File(fixtureRoot, "build/reports/paparazzi/debug/images") - val snapshots = snapshotsDir.listFiles() - assertThat(snapshots!!).hasLength(1) - - val snapshotImage = snapshots[0] - val goldenImage = File(fixtureRoot, "src/test/resources/arrow_up.png") - assertThat(snapshotImage).isSimilarTo(goldenImage).withDefaultThreshold() } @Test @@ -1271,16 +1205,8 @@ class PaparazziPluginTest { val fixtureRoot = File("src/test/projects/verify-recyclerview") gradleRunner - .withArguments("testDebug", "--stacktrace") + .withArguments("verifyPaparazziDebug", "--stacktrace") .runFixture(fixtureRoot) { build() } - - val snapshotsDir = File(fixtureRoot, "build/reports/paparazzi/debug/images") - val snapshots = snapshotsDir.listFiles() - assertThat(snapshots!!).hasLength(1) - - val snapshotImage = snapshots[0] - val goldenImage = File(fixtureRoot, "src/test/resources/recycler_view.png") - assertThat(snapshotImage).isSimilarTo(goldenImage).withDefaultThreshold() } @Test @@ -1288,15 +1214,8 @@ class PaparazziPluginTest { val fixtureRoot = File("src/test/projects/appcompat-missing") gradleRunner - .withArguments("testDebug", "--stacktrace") + .withArguments("verifyPaparazziDebug", "--stacktrace") .runFixture(fixtureRoot) { build() } - - val snapshotsDir = File(fixtureRoot, "build/reports/paparazzi/debug/images") - val snapshotFile = File(snapshotsDir, "a2095a4d9f78335277b48a4bda336c1437d44295.png") - assertThat(snapshotFile.exists()).isTrue() - - val goldenImage = File(fixtureRoot, "src/test/resources/arrow_missing.png") - assertThat(goldenImage).isSimilarTo(snapshotFile).withDefaultThreshold() } @Test @@ -1304,16 +1223,8 @@ class PaparazziPluginTest { val fixtureRoot = File("src/test/projects/appcompat-present") gradleRunner - .withArguments("testDebug", "--stacktrace") + .withArguments("verifyPaparazziDebug", "--stacktrace") .runFixture(fixtureRoot) { build() } - - val snapshotsDir = File(fixtureRoot, "build/reports/paparazzi/debug/images") - val snapshots = snapshotsDir.listFiles() - assertThat(snapshots!!).hasLength(1) - - val snapshotImage = snapshots[0] - val goldenImage = File(fixtureRoot, "src/test/resources/arrow_present.png") - assertThat(snapshotImage).isSimilarTo(goldenImage).withDefaultThreshold() } @Test @@ -1322,139 +1233,35 @@ class PaparazziPluginTest { val fixtureRoot = File("src/test/projects/material-components-present") gradleRunner - .withArguments("testDebug", "--stacktrace") - .runFixture(fixtureRoot) { build() } - - val snapshotsDir = File(fixtureRoot, "build/reports/paparazzi/debug/images") - val snapshots = snapshotsDir.listFiles() - assertThat(snapshots!!).hasLength(1) - - val snapshotImage = snapshots[0] - val goldenImage = File(fixtureRoot, "src/test/resources/button.png") - assertThat(snapshotImage).isSimilarTo(goldenImage).withDefaultThreshold() - } - - @Test - fun customFontsInXml() { - val fixtureRoot = File("src/test/projects/custom-fonts-xml") - - gradleRunner - .withArguments("testDebug", "--stacktrace") - .runFixture(fixtureRoot) { build() } - - val snapshotsDir = File(fixtureRoot, "build/reports/paparazzi/debug/images") - val snapshots = snapshotsDir.listFiles() - assertThat(snapshots!!).hasLength(1) - - val snapshotImage = snapshots[0] - val goldenImage = File(fixtureRoot, "src/test/resources/textviews.png") - assertThat(snapshotImage).isSimilarTo(goldenImage).withDefaultThreshold() - } - - @Test - fun customFontsInCode() { - val fixtureRoot = File("src/test/projects/custom-fonts-code") - - gradleRunner - .withArguments("testDebug", "--stacktrace") - .runFixture(fixtureRoot) { build() } - - val snapshotsDir = File(fixtureRoot, "build/reports/paparazzi/debug/images") - val snapshots = snapshotsDir.listFiles()?.sortedBy { it.lastModified() } - assertThat(snapshots!!).hasSize(2) - - var snapshotImage = snapshots[0] - var goldenImage = File(fixtureRoot, "src/test/resources/singleLine.png") - assertThat(snapshotImage).isSimilarTo(goldenImage).withDefaultThreshold() - - snapshotImage = snapshots[1] - goldenImage = File(fixtureRoot, "src/test/resources/textviews.png") - assertThat(snapshotImage).isSimilarTo(goldenImage).withDefaultThreshold() - } - - @Test - fun textAppearancesInCode() { - val fixtureRoot = File("src/test/projects/text-appearances-code") - - gradleRunner - .withArguments("testDebug", "--stacktrace") - .runFixture(fixtureRoot) { build() } - - val snapshotsDir = File(fixtureRoot, "build/reports/paparazzi/debug/images") - val snapshots = snapshotsDir.listFiles() - assertThat(snapshots!!).hasLength(1) - - val snapshotImage = snapshots[0] - val goldenImage = File(fixtureRoot, "src/test/resources/textappearances.png") - assertThat(snapshotImage).isSimilarTo(goldenImage).withDefaultThreshold() - } - - @Test - fun textAppearancesInXml() { - val fixtureRoot = File("src/test/projects/text-appearances-xml") - - gradleRunner - .withArguments("testDebug", "--stacktrace") + .withArguments("verifyPaparazziDebug", "--stacktrace") .runFixture(fixtureRoot) { build() } - - val snapshotsDir = File(fixtureRoot, "build/reports/paparazzi/debug/images") - val snapshots = snapshotsDir.listFiles() - assertThat(snapshots!!).hasLength(1) - - val snapshotImage = snapshots[0] - val goldenImage = File(fixtureRoot, "src/test/resources/textappearances.png") - assertThat(snapshotImage).isSimilarTo(goldenImage).withDefaultThreshold() } @Test - fun verifyAaptAttrResourceParsingInCode() { - val fixtureRoot = File("src/test/projects/verify-aapt-code") + fun customFonts() { + val fixtureRoot = File("src/test/projects/custom-fonts") gradleRunner - .withArguments("testDebug", "--stacktrace") + .withArguments("verifyPaparazziDebug", "--stacktrace") .runFixture(fixtureRoot) { build() } - - val snapshotsDir = File(fixtureRoot, "build/reports/paparazzi/debug/images") - val snapshots = snapshotsDir.listFiles() - assertThat(snapshots!!).hasLength(1) - - val snapshotImage = snapshots[0] - val goldenImage = File(fixtureRoot, "src/test/resources/card_chip.png") - assertThat(snapshotImage).isSimilarTo(goldenImage).withDefaultThreshold() } @Test - fun verifyAaptAttrResourceParsingInXml() { - val fixtureRoot = File("src/test/projects/verify-aapt-xml") + fun textAppearances() { + val fixtureRoot = File("src/test/projects/text-appearances") gradleRunner - .withArguments("testDebug", "--stacktrace") + .withArguments("verifyPaparazziDebug", "--stacktrace") .runFixture(fixtureRoot) { build() } - - val snapshotsDir = File(fixtureRoot, "build/reports/paparazzi/debug/images") - val snapshots = snapshotsDir.listFiles() - assertThat(snapshots!!).hasLength(1) - - val snapshotImage = snapshots[0] - val goldenImage = File(fixtureRoot, "src/test/resources/card_chip.png") - assertThat(snapshotImage).isSimilarTo(goldenImage).withDefaultThreshold() } @Test - fun verifyAaptAttrResourceParsingInCompose() { - val fixtureRoot = File("src/test/projects/verify-aapt-compose") + fun verifyAaptAttrResourceParsing() { + val fixtureRoot = File("src/test/projects/verify-aapt") gradleRunner - .withArguments("testDebug", "--stacktrace") + .withArguments("verifyPaparazziDebug", "--stacktrace") .runFixture(fixtureRoot) { build() } - - val snapshotsDir = File(fixtureRoot, "build/reports/paparazzi/debug/images") - val snapshots = snapshotsDir.listFiles() - assertThat(snapshots!!).hasLength(1) - - val snapshotImage = snapshots[0] - val goldenImage = File(fixtureRoot, "src/test/resources/compose_card_chip.png") - assertThat(snapshotImage).isSimilarTo(goldenImage).withDefaultThreshold() } @Test @@ -1462,50 +1269,34 @@ class PaparazziPluginTest { val fixtureRoot = File("src/test/projects/nine-patch") gradleRunner - .withArguments("testDebug", "--stacktrace") + .withArguments("verifyPaparazziDebug", "--stacktrace") .runFixture(fixtureRoot) { build() } - - val snapshotsDir = File(fixtureRoot, "build/reports/paparazzi/debug/images") - val snapshots = snapshotsDir.listFiles() - assertThat(snapshots!!).hasLength(1) - - val snapshotImage = snapshots[0] - val goldenImage = File(fixtureRoot, "src/test/resources/nine_patch.png") - assertThat(snapshotImage).isSimilarTo(goldenImage).withDefaultThreshold() } @Test fun transitiveResources() { val fixtureRoot = File("src/test/projects/transitive-resources") - val moduleRoot = File(fixtureRoot, "module") gradleRunner - .withArguments("module:testDebug", "--stacktrace") + .withArguments("module:verifyPaparazziDebug", "--stacktrace") .runFixture(fixtureRoot) { build() } - - val snapshotsDir = File(moduleRoot, "build/reports/paparazzi/debug/images") - val snapshots = snapshotsDir.listFiles() - assertThat(snapshots!!).hasLength(1) - - val snapshotImage = snapshots[0] - val goldenImage = File(moduleRoot, "src/test/resources/five_bucks.png") - assertThat(snapshotImage).isSimilarTo(goldenImage).withDefaultThreshold() } @Test fun compose() { val fixtureRoot = File("src/test/projects/compose") gradleRunner - .withArguments("testDebug", "--stacktrace") + .withArguments("verifyPaparazziDebug", "--stacktrace") .runFixture(fixtureRoot) { build() } + } - val snapshotsDir = File(fixtureRoot, "build/reports/paparazzi/debug/images") - val snapshots = snapshotsDir.listFiles() - assertThat(snapshots!!).hasLength(1) + @Test + fun composeLeaks() { + val fixtureRoot = File("src/test/projects/compose-leaks") - val snapshotImage = snapshots[0] - val goldenImage = File(fixtureRoot, "src/test/resources/compose_fonts.png") - assertThat(snapshotImage).isSimilarTo(goldenImage).withDefaultThreshold() + gradleRunner + .withArguments("testDebug", "--stacktrace") + .runFixture(fixtureRoot) { build() } } @Test @@ -1533,37 +1324,16 @@ class PaparazziPluginTest { fun composeWear() { val fixtureRoot = File("src/test/projects/compose-wear") gradleRunner - .withArguments("testDebug", "--stacktrace") + .withArguments("verifyPaparazziDebug", "--stacktrace") .runFixture(fixtureRoot) { build() } - - val snapshotsDir = File(fixtureRoot, "build/reports/paparazzi/debug/images") - val snapshots = snapshotsDir.listFiles() - assertThat(snapshots!!).hasLength(1) - - val snapshotImage = snapshots[0] - val goldenImage = File(fixtureRoot, "src/test/resources/compose_wear.png") - assertThat(snapshotImage).isSimilarTo(goldenImage).withDefaultThreshold() } @Test fun composeA11y() { val fixtureRoot = File("src/test/projects/compose-a11y") gradleRunner - .withArguments("testDebug", "--stacktrace") + .withArguments("verifyPaparazziDebug", "--stacktrace") .runFixture(fixtureRoot) { build() } - - val snapshotsDir = File(fixtureRoot, "build/reports/paparazzi/debug/images") - val snapshots = snapshotsDir.listFilesSorted() - assertThat(snapshots!!).hasSize(2) - - var snapshotImage = snapshots[0] - var goldenImage = File(fixtureRoot, "src/test/resources/compose_a11y_clear_and_set_semantics.png") - assertThat(snapshotImage).isSimilarTo(goldenImage).withDefaultThreshold() - snapshotImage = snapshots[1] - goldenImage = File(fixtureRoot, "src/test/resources/compose_a11y.png") - assertThat(snapshotImage).isSimilarTo(goldenImage).withDefaultThreshold() - goldenImage = File(fixtureRoot, "src/test/resources/compose_a11y_change_hierarchy_order.png") - assertThat(snapshotImage).isSimilarTo(goldenImage).withDefaultThreshold() } @Test @@ -1579,19 +1349,8 @@ class PaparazziPluginTest { val fixtureRoot = File("src/test/projects/update-paparazzi-config") gradleRunner - .withArguments("testDebug", "--stacktrace") + .withArguments("verifyPaparazziDebug", "--stacktrace") .runFixture(fixtureRoot) { build() } - - val snapshotsDir = File(fixtureRoot, "build/reports/paparazzi/debug/images") - val snapshots = snapshotsDir.listFilesSorted() - assertThat(snapshots!!).hasSize(2) - - val pixel3SnapshotImage = snapshots[0] - val nexus7SnapshotImage = snapshots[1] - val pixel3GoldenImage = File(fixtureRoot, "src/test/resources/pixel_3_launch.png") - val nexus7GoldenImage = File(fixtureRoot, "src/test/resources/nexus_7_launch.png") - assertThat(pixel3SnapshotImage).isSimilarTo(pixel3GoldenImage).withDefaultThreshold() - assertThat(nexus7SnapshotImage).isSimilarTo(nexus7GoldenImage).withDefaultThreshold() } @Test @@ -1599,23 +1358,8 @@ class PaparazziPluginTest { val fixtureRoot = File("src/test/projects/device-resolution") gradleRunner - .withArguments("testDebug", "--stacktrace") + .withArguments("verifyPaparazziDebug", "--stacktrace") .runFixture(fixtureRoot) { build() } - - val snapshotsDir = File(fixtureRoot, "build/reports/paparazzi/debug/images") - val snapshots = snapshotsDir.listFiles()?.sortedBy { it.lastModified() } - assertThat(snapshots!!).hasSize(2) - - val defaultSnapshotImage = snapshots[0] - val deviceResolutionSnapshotImage = snapshots[1] - val defaultGoldenImage = - File(fixtureRoot, "src/test/resources/default_resolution.png") - val deviceResolutionGoldenImage = - File(fixtureRoot, "src/test/resources/full_resolution.png") - assertThat(defaultSnapshotImage).isSimilarTo(defaultGoldenImage) - .withDefaultThreshold() - assertThat(deviceResolutionSnapshotImage).isSimilarTo(deviceResolutionGoldenImage) - .withDefaultThreshold() } @Test @@ -1623,19 +1367,8 @@ class PaparazziPluginTest { val fixtureRoot = File("src/test/projects/locale-qualifier") gradleRunner - .withArguments("testDebug", "--stacktrace") + .withArguments("verifyPaparazziDebug", "--stacktrace") .runFixture(fixtureRoot) { build() } - - val snapshotsDir = File(fixtureRoot, "build/reports/paparazzi/debug/images") - val snapshots = snapshotsDir.listFilesSorted() - assertThat(snapshots!!).hasSize(2) - - val localeDefaultSnapshotImage = snapshots[0] - val localeEnGBSnapshotImage = snapshots[1] - val localeDefaultGoldenImage = File(fixtureRoot, "src/test/resources/locale_default.png") - val localeEnGBGoldenImage = File(fixtureRoot, "src/test/resources/locale_en_gb.png") - assertThat(localeDefaultSnapshotImage).isSimilarTo(localeDefaultGoldenImage).withDefaultThreshold() - assertThat(localeEnGBSnapshotImage).isSimilarTo(localeEnGBGoldenImage).withDefaultThreshold() } @Test @@ -1643,59 +1376,17 @@ class PaparazziPluginTest { val fixtureRoot = File("src/test/projects/layout-direction") gradleRunner - .withArguments("testDebug", "--stacktrace") - .runFixture(fixtureRoot) { build() } - - val snapshotsDir = File(fixtureRoot, "build/reports/paparazzi/debug/images") - val snapshots = snapshotsDir.listFilesSorted() - assertThat(snapshots!!).hasSize(2) - - val localeDefaultRtlSnapshotImage = snapshots[0] - val localeArSnapshotImage = snapshots[1] - val localeDefaultRtlGoldenImage = File(fixtureRoot, "src/test/resources/locale_default_rtl.png") - val localeArGoldenImage = File(fixtureRoot, "src/test/resources/locale_ar.png") - assertThat(localeDefaultRtlSnapshotImage).isSimilarTo(localeDefaultRtlGoldenImage).withDefaultThreshold() - assertThat(localeArSnapshotImage).isSimilarTo(localeArGoldenImage).withDefaultThreshold() - } - - @Test - fun nightModeCompose() { - val fixtureRoot = File("src/test/projects/night-mode-compose") - - gradleRunner - .withArguments("testDebug", "--stacktrace") + .withArguments("verifyPaparazziDebug", "--stacktrace") .runFixture(fixtureRoot) { build() } - - val snapshotsDir = File(fixtureRoot, "build/reports/paparazzi/debug/images") - val snapshots = snapshotsDir.listFilesSorted() - assertThat(snapshots!!).hasSize(2) - - val lightModeSnapshotImage = snapshots[0] - val darkModeSnapshotImage = snapshots[1] - val lightModeGoldenImage = File(fixtureRoot, "src/test/resources/light_mode.png") - val darkModeGoldenImage = File(fixtureRoot, "src/test/resources/dark_mode.png") - assertThat(lightModeSnapshotImage).isSimilarTo(lightModeGoldenImage).withDefaultThreshold() - assertThat(darkModeSnapshotImage).isSimilarTo(darkModeGoldenImage).withDefaultThreshold() } @Test - fun nightModeXml() { - val fixtureRoot = File("src/test/projects/night-mode-xml") + fun nightMode() { + val fixtureRoot = File("src/test/projects/night-mode") gradleRunner - .withArguments("testDebug", "--stacktrace") + .withArguments("verifyPaparazziDebug", "--stacktrace") .runFixture(fixtureRoot) { build() } - - val snapshotsDir = File(fixtureRoot, "build/reports/paparazzi/debug/images") - val snapshots = snapshotsDir.listFilesSorted() - assertThat(snapshots!!).hasSize(2) - - val lightModeSnapshotImage = snapshots[0] - val darkModeSnapshotImage = snapshots[1] - val lightModeGoldenImage = File(fixtureRoot, "src/test/resources/light_mode.png") - val darkModeGoldenImage = File(fixtureRoot, "src/test/resources/dark_mode.png") - assertThat(lightModeSnapshotImage).isSimilarTo(lightModeGoldenImage).withDefaultThreshold() - assertThat(darkModeSnapshotImage).isSimilarTo(darkModeGoldenImage).withDefaultThreshold() } @Test @@ -1752,20 +1443,8 @@ class PaparazziPluginTest { val fixtureRoot = File("src/test/projects/verify-orientation") gradleRunner - .withArguments("testDebug", "--stacktrace") + .withArguments("verifyPaparazziDebug", "--stacktrace") .runFixture(fixtureRoot) { build() } - - val snapshotsDir = File(fixtureRoot, "build/reports/paparazzi/debug/images") - val snapshots = snapshotsDir.listFilesSorted() - assertThat(snapshots!!).hasSize(2) - - val portraitSnapshotImage = snapshots[0] - val portraitGoldenImage = File(fixtureRoot, "src/test/resources/portrait_orientation.png") - assertThat(portraitSnapshotImage).isSimilarTo(portraitGoldenImage).withDefaultThreshold() - - val landscapeSnapshotImage = snapshots[1] - val landscapeGoldenImage = File(fixtureRoot, "src/test/resources/landscape_orientation.png") - assertThat(landscapeSnapshotImage).isSimilarTo(landscapeGoldenImage).withDefaultThreshold() } @Test @@ -1773,20 +1452,8 @@ class PaparazziPluginTest { val fixtureRoot = File("src/test/projects/verify-screen-round") gradleRunner - .withArguments("testDebug", "--stacktrace") + .withArguments("verifyPaparazziDebug", "--stacktrace") .runFixture(fixtureRoot) { build() } - - val snapshotsDir = File(fixtureRoot, "build/reports/paparazzi/debug/images") - val snapshots = snapshotsDir.listFilesSorted() - assertThat(snapshots!!).hasSize(2) - - val roundSnapshot = snapshots[0] - val roundGoldenImage = File(fixtureRoot, "src/test/resources/round.png") - assertThat(roundSnapshot).isSimilarTo(roundGoldenImage).withDefaultThreshold() - - val notRoundSnapshot = snapshots[1] - val notRoundGoldenImage = File(fixtureRoot, "src/test/resources/not_round.png") - assertThat(notRoundSnapshot).isSimilarTo(notRoundGoldenImage).withDefaultThreshold() } private fun File.loadConfig() = source().buffer().use { CONFIG_ADAPTER.fromJson(it)!! } diff --git a/paparazzi-gradle-plugin/src/test/projects/appcompat-missing/src/test/java/app/cash/paparazzi/plugin/test/LaunchViewTest.kt b/paparazzi-gradle-plugin/src/test/projects/appcompat-missing/src/test/java/app/cash/paparazzi/plugin/test/LaunchViewTest.kt index 407a87ec32..6b96dda64d 100644 --- a/paparazzi-gradle-plugin/src/test/projects/appcompat-missing/src/test/java/app/cash/paparazzi/plugin/test/LaunchViewTest.kt +++ b/paparazzi-gradle-plugin/src/test/projects/appcompat-missing/src/test/java/app/cash/paparazzi/plugin/test/LaunchViewTest.kt @@ -25,8 +25,8 @@ class LaunchViewTest { val paparazzi = Paparazzi() @Test - fun testViews() { + fun test() { val launch = paparazzi.inflate(R.layout.launch) - paparazzi.snapshot(launch, "launch") + paparazzi.snapshot(launch, "arrow_missing") } } diff --git a/paparazzi-gradle-plugin/src/test/projects/appcompat-missing/src/test/resources/arrow_missing.png b/paparazzi-gradle-plugin/src/test/projects/appcompat-missing/src/test/snapshots/images/app.cash.paparazzi.plugin.test_LaunchViewTest_test_arrow_missing.png similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/appcompat-missing/src/test/resources/arrow_missing.png rename to paparazzi-gradle-plugin/src/test/projects/appcompat-missing/src/test/snapshots/images/app.cash.paparazzi.plugin.test_LaunchViewTest_test_arrow_missing.png diff --git a/paparazzi-gradle-plugin/src/test/projects/appcompat-present/src/test/java/app/cash/paparazzi/plugin/test/LaunchViewTest.kt b/paparazzi-gradle-plugin/src/test/projects/appcompat-present/src/test/java/app/cash/paparazzi/plugin/test/LaunchViewTest.kt index 407a87ec32..6bd69ffc61 100644 --- a/paparazzi-gradle-plugin/src/test/projects/appcompat-present/src/test/java/app/cash/paparazzi/plugin/test/LaunchViewTest.kt +++ b/paparazzi-gradle-plugin/src/test/projects/appcompat-present/src/test/java/app/cash/paparazzi/plugin/test/LaunchViewTest.kt @@ -25,8 +25,8 @@ class LaunchViewTest { val paparazzi = Paparazzi() @Test - fun testViews() { + fun test() { val launch = paparazzi.inflate(R.layout.launch) - paparazzi.snapshot(launch, "launch") + paparazzi.snapshot(launch, "arrow_present") } } diff --git a/paparazzi-gradle-plugin/src/test/projects/appcompat-present/src/test/resources/arrow_present.png b/paparazzi-gradle-plugin/src/test/projects/appcompat-present/src/test/snapshots/images/app.cash.paparazzi.plugin.test_LaunchViewTest_test_arrow_present.png similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/appcompat-present/src/test/resources/arrow_present.png rename to paparazzi-gradle-plugin/src/test/projects/appcompat-present/src/test/snapshots/images/app.cash.paparazzi.plugin.test_LaunchViewTest_test_arrow_present.png diff --git a/paparazzi-gradle-plugin/src/test/projects/compose-a11y/src/test/resources/compose_a11y.png b/paparazzi-gradle-plugin/src/test/projects/compose-a11y/src/test/snapshots/images/app.cash.paparazzi.plugin.test_ComposeA11yTest_mixed compose usage.png similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/compose-a11y/src/test/resources/compose_a11y.png rename to paparazzi-gradle-plugin/src/test/projects/compose-a11y/src/test/snapshots/images/app.cash.paparazzi.plugin.test_ComposeA11yTest_mixed compose usage.png diff --git a/paparazzi-gradle-plugin/src/test/projects/compose-a11y/src/test/resources/compose_a11y_change_hierarchy_order.png b/paparazzi-gradle-plugin/src/test/projects/compose-a11y/src/test/snapshots/images/app.cash.paparazzi.plugin.test_ComposeA11yTest_verify changing view hierarchy order doesn't change accessibility colors.png similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/compose-a11y/src/test/resources/compose_a11y_change_hierarchy_order.png rename to paparazzi-gradle-plugin/src/test/projects/compose-a11y/src/test/snapshots/images/app.cash.paparazzi.plugin.test_ComposeA11yTest_verify changing view hierarchy order doesn't change accessibility colors.png diff --git a/paparazzi-gradle-plugin/src/test/projects/compose-a11y/src/test/resources/compose_a11y_clear_and_set_semantics.png b/paparazzi-gradle-plugin/src/test/projects/compose-a11y/src/test/snapshots/images/app.cash.paparazzi.plugin.test_ComposeA11yTest_verify clear and set semantics.png similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/compose-a11y/src/test/resources/compose_a11y_clear_and_set_semantics.png rename to paparazzi-gradle-plugin/src/test/projects/compose-a11y/src/test/snapshots/images/app.cash.paparazzi.plugin.test_ComposeA11yTest_verify clear and set semantics.png diff --git a/paparazzi-gradle-plugin/src/test/projects/verify-aapt-compose/build.gradle b/paparazzi-gradle-plugin/src/test/projects/compose-leaks/build.gradle similarity index 99% rename from paparazzi-gradle-plugin/src/test/projects/verify-aapt-compose/build.gradle rename to paparazzi-gradle-plugin/src/test/projects/compose-leaks/build.gradle index c6f1ab3e72..1b31a0e543 100644 --- a/paparazzi-gradle-plugin/src/test/projects/verify-aapt-compose/build.gradle +++ b/paparazzi-gradle-plugin/src/test/projects/compose-leaks/build.gradle @@ -27,4 +27,3 @@ dependencies { implementation libs.composeUi.material } - diff --git a/paparazzi-gradle-plugin/src/test/projects/compose-leaks/src/main/java/app/cash/paparazzi/plugin/test/HelloPaparazzi.kt b/paparazzi-gradle-plugin/src/test/projects/compose-leaks/src/main/java/app/cash/paparazzi/plugin/test/HelloPaparazzi.kt new file mode 100644 index 0000000000..44044b8a42 --- /dev/null +++ b/paparazzi-gradle-plugin/src/test/projects/compose-leaks/src/main/java/app/cash/paparazzi/plugin/test/HelloPaparazzi.kt @@ -0,0 +1,48 @@ +package app.cash.paparazzi.plugin.test + +import androidx.compose.foundation.background +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.wrapContentSize +import androidx.compose.material.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.text.font.FontFamily +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.text.style.TextDecoration + +@Composable +fun HelloPaparazzi() { + val text = "Hello, Paparazzi" + Column( + Modifier + .background(Color.White) + .fillMaxSize() + .wrapContentSize() + ) { + Text(text) + Text(text, style = TextStyle(fontFamily = FontFamily.Cursive)) + Text( + text = text, + style = TextStyle(textDecoration = TextDecoration.LineThrough) + ) + Text( + text = text, + style = TextStyle(textDecoration = TextDecoration.Underline) + ) + Text( + text = text, + style = TextStyle( + textDecoration = TextDecoration.combine( + listOf( + TextDecoration.Underline, + TextDecoration.LineThrough + ) + ), + fontWeight = FontWeight.Bold + ) + ) + } +} diff --git a/paparazzi-gradle-plugin/src/test/projects/compose/src/test/java/app/cash/paparazzi/plugin/test/ComposeReferenceLeakTest.kt b/paparazzi-gradle-plugin/src/test/projects/compose-leaks/src/test/java/app/cash/paparazzi/plugin/test/ComposeReferenceLeakTest.kt similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/compose/src/test/java/app/cash/paparazzi/plugin/test/ComposeReferenceLeakTest.kt rename to paparazzi-gradle-plugin/src/test/projects/compose-leaks/src/test/java/app/cash/paparazzi/plugin/test/ComposeReferenceLeakTest.kt diff --git a/paparazzi-gradle-plugin/src/test/projects/compose/src/test/java/app/cash/paparazzi/plugin/test/LoggerLeakTest.kt b/paparazzi-gradle-plugin/src/test/projects/compose-leaks/src/test/java/app/cash/paparazzi/plugin/test/LoggerLeakTest.kt similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/compose/src/test/java/app/cash/paparazzi/plugin/test/LoggerLeakTest.kt rename to paparazzi-gradle-plugin/src/test/projects/compose-leaks/src/test/java/app/cash/paparazzi/plugin/test/LoggerLeakTest.kt diff --git a/paparazzi-gradle-plugin/src/test/projects/compose-wear/src/test/resources/compose_wear.png b/paparazzi-gradle-plugin/src/test/projects/compose-wear/src/test/snapshots/images/app.cash.paparazzi.plugin.test_ComposeTest_compose.png similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/compose-wear/src/test/resources/compose_wear.png rename to paparazzi-gradle-plugin/src/test/projects/compose-wear/src/test/snapshots/images/app.cash.paparazzi.plugin.test_ComposeTest_compose.png diff --git a/paparazzi-gradle-plugin/src/test/projects/compose/src/test/resources/compose_fonts.png b/paparazzi-gradle-plugin/src/test/projects/compose/src/test/snapshots/images/app.cash.paparazzi.plugin.test_ComposeTest_compose.png similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/compose/src/test/resources/compose_fonts.png rename to paparazzi-gradle-plugin/src/test/projects/compose/src/test/snapshots/images/app.cash.paparazzi.plugin.test_ComposeTest_compose.png diff --git a/paparazzi-gradle-plugin/src/test/projects/custom-fonts-xml/build.gradle b/paparazzi-gradle-plugin/src/test/projects/custom-fonts-xml/build.gradle deleted file mode 100644 index 4c9847cd79..0000000000 --- a/paparazzi-gradle-plugin/src/test/projects/custom-fonts-xml/build.gradle +++ /dev/null @@ -1,25 +0,0 @@ -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() - } -} - -dependencies { - implementation libs.androidx.appcompat -} - diff --git a/paparazzi-gradle-plugin/src/test/projects/custom-fonts-xml/src/main/res/font/cashmarket_medium.xml b/paparazzi-gradle-plugin/src/test/projects/custom-fonts-xml/src/main/res/font/cashmarket_medium.xml deleted file mode 100755 index 640db2cdfa..0000000000 --- a/paparazzi-gradle-plugin/src/test/projects/custom-fonts-xml/src/main/res/font/cashmarket_medium.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - diff --git a/paparazzi-gradle-plugin/src/test/projects/custom-fonts-xml/src/main/res/font/cashmarket_medium_italic.ttf b/paparazzi-gradle-plugin/src/test/projects/custom-fonts-xml/src/main/res/font/cashmarket_medium_italic.ttf deleted file mode 100755 index e27adc0ba0..0000000000 Binary files a/paparazzi-gradle-plugin/src/test/projects/custom-fonts-xml/src/main/res/font/cashmarket_medium_italic.ttf and /dev/null differ diff --git a/paparazzi-gradle-plugin/src/test/projects/custom-fonts-xml/src/main/res/font/cashmarket_medium_normal.otf b/paparazzi-gradle-plugin/src/test/projects/custom-fonts-xml/src/main/res/font/cashmarket_medium_normal.otf deleted file mode 100644 index 72ce91686e..0000000000 Binary files a/paparazzi-gradle-plugin/src/test/projects/custom-fonts-xml/src/main/res/font/cashmarket_medium_normal.otf and /dev/null differ diff --git a/paparazzi-gradle-plugin/src/test/projects/custom-fonts-xml/src/test/java/app/cash/paparazzi/plugin/test/CustomFontsTest.kt b/paparazzi-gradle-plugin/src/test/projects/custom-fonts-xml/src/test/java/app/cash/paparazzi/plugin/test/CustomFontsTest.kt deleted file mode 100644 index 6f677754ba..0000000000 --- a/paparazzi-gradle-plugin/src/test/projects/custom-fonts-xml/src/test/java/app/cash/paparazzi/plugin/test/CustomFontsTest.kt +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2019 Square, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package app.cash.paparazzi.plugin.test - -import android.view.View -import app.cash.paparazzi.Paparazzi -import org.junit.Rule -import org.junit.Test - -class CustomFontsTest { - @get:Rule - val paparazzi = Paparazzi() - - @Test - fun customFontInTextViewInXml() { - val view = paparazzi.inflate(R.layout.textviews) - paparazzi.snapshot(view, "text in xml") - } -} diff --git a/paparazzi-gradle-plugin/src/test/projects/custom-fonts-code/build.gradle b/paparazzi-gradle-plugin/src/test/projects/custom-fonts/build.gradle similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/custom-fonts-code/build.gradle rename to paparazzi-gradle-plugin/src/test/projects/custom-fonts/build.gradle diff --git a/paparazzi-gradle-plugin/src/test/projects/custom-fonts-code/src/main/res/font/cashmarket_medium.xml b/paparazzi-gradle-plugin/src/test/projects/custom-fonts/src/main/res/font/cashmarket_medium.xml similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/custom-fonts-code/src/main/res/font/cashmarket_medium.xml rename to paparazzi-gradle-plugin/src/test/projects/custom-fonts/src/main/res/font/cashmarket_medium.xml diff --git a/paparazzi-gradle-plugin/src/test/projects/custom-fonts-code/src/main/res/font/cashmarket_medium_italic.ttf b/paparazzi-gradle-plugin/src/test/projects/custom-fonts/src/main/res/font/cashmarket_medium_italic.ttf similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/custom-fonts-code/src/main/res/font/cashmarket_medium_italic.ttf rename to paparazzi-gradle-plugin/src/test/projects/custom-fonts/src/main/res/font/cashmarket_medium_italic.ttf diff --git a/paparazzi-gradle-plugin/src/test/projects/custom-fonts-code/src/main/res/font/cashmarket_medium_normal.otf b/paparazzi-gradle-plugin/src/test/projects/custom-fonts/src/main/res/font/cashmarket_medium_normal.otf similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/custom-fonts-code/src/main/res/font/cashmarket_medium_normal.otf rename to paparazzi-gradle-plugin/src/test/projects/custom-fonts/src/main/res/font/cashmarket_medium_normal.otf diff --git a/paparazzi-gradle-plugin/src/test/projects/custom-fonts-xml/src/main/res/layout/textviews.xml b/paparazzi-gradle-plugin/src/test/projects/custom-fonts/src/main/res/layout/textviews.xml similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/custom-fonts-xml/src/main/res/layout/textviews.xml rename to paparazzi-gradle-plugin/src/test/projects/custom-fonts/src/main/res/layout/textviews.xml diff --git a/paparazzi-gradle-plugin/src/test/projects/custom-fonts-code/src/test/java/app/cash/paparazzi/plugin/test/CustomFontsTest.kt b/paparazzi-gradle-plugin/src/test/projects/custom-fonts/src/test/java/app/cash/paparazzi/plugin/test/CustomFontsTest.kt similarity index 93% rename from paparazzi-gradle-plugin/src/test/projects/custom-fonts-code/src/test/java/app/cash/paparazzi/plugin/test/CustomFontsTest.kt rename to paparazzi-gradle-plugin/src/test/projects/custom-fonts/src/test/java/app/cash/paparazzi/plugin/test/CustomFontsTest.kt index 2768e46284..3faca3c00d 100644 --- a/paparazzi-gradle-plugin/src/test/projects/custom-fonts-code/src/test/java/app/cash/paparazzi/plugin/test/CustomFontsTest.kt +++ b/paparazzi-gradle-plugin/src/test/projects/custom-fonts/src/test/java/app/cash/paparazzi/plugin/test/CustomFontsTest.kt @@ -18,6 +18,7 @@ package app.cash.paparazzi.plugin.test import android.content.Context import android.graphics.Typeface import android.view.Gravity.CENTER +import android.view.View import android.view.ViewGroup.LayoutParams.MATCH_PARENT import android.view.ViewGroup.LayoutParams.WRAP_CONTENT import android.widget.LinearLayout @@ -35,7 +36,7 @@ class CustomFontsTest { val paparazzi = Paparazzi() @Test - fun customFontInTextViewInCode() { + fun inCode() { val context = paparazzi.context val root = LinearLayout(context).apply { @@ -74,7 +75,13 @@ class CustomFontsTest { ) } - paparazzi.snapshot(root, "text in code") + paparazzi.snapshot(root) + } + + @Test + fun inXml() { + val view = paparazzi.inflate(R.layout.textviews) + paparazzi.snapshot(view) } @Test @@ -89,7 +96,7 @@ class CustomFontsTest { gravity = CENTER } } - paparazzi.snapshot(text, "singleLine") + paparazzi.snapshot(text) } private fun createTextView(context: Context) = diff --git a/paparazzi-gradle-plugin/src/test/projects/custom-fonts-code/src/test/resources/textviews.png b/paparazzi-gradle-plugin/src/test/projects/custom-fonts/src/test/snapshots/images/app.cash.paparazzi.plugin.test_CustomFontsTest_inCode.png similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/custom-fonts-code/src/test/resources/textviews.png rename to paparazzi-gradle-plugin/src/test/projects/custom-fonts/src/test/snapshots/images/app.cash.paparazzi.plugin.test_CustomFontsTest_inCode.png diff --git a/paparazzi-gradle-plugin/src/test/projects/custom-fonts-xml/src/test/resources/textviews.png b/paparazzi-gradle-plugin/src/test/projects/custom-fonts/src/test/snapshots/images/app.cash.paparazzi.plugin.test_CustomFontsTest_inXml.png similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/custom-fonts-xml/src/test/resources/textviews.png rename to paparazzi-gradle-plugin/src/test/projects/custom-fonts/src/test/snapshots/images/app.cash.paparazzi.plugin.test_CustomFontsTest_inXml.png diff --git a/paparazzi-gradle-plugin/src/test/projects/custom-fonts-code/src/test/resources/singleLine.png b/paparazzi-gradle-plugin/src/test/projects/custom-fonts/src/test/snapshots/images/app.cash.paparazzi.plugin.test_CustomFontsTest_singleLine.png similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/custom-fonts-code/src/test/resources/singleLine.png rename to paparazzi-gradle-plugin/src/test/projects/custom-fonts/src/test/snapshots/images/app.cash.paparazzi.plugin.test_CustomFontsTest_singleLine.png diff --git a/paparazzi-gradle-plugin/src/test/projects/device-resolution/src/test/resources/default_resolution.png b/paparazzi-gradle-plugin/src/test/projects/device-resolution/src/test/snapshots/images/app.cash.paparazzi.plugin.test_DeviceResolutionTest_deviceResolution[false].png similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/device-resolution/src/test/resources/default_resolution.png rename to paparazzi-gradle-plugin/src/test/projects/device-resolution/src/test/snapshots/images/app.cash.paparazzi.plugin.test_DeviceResolutionTest_deviceResolution[false].png diff --git a/paparazzi-gradle-plugin/src/test/projects/device-resolution/src/test/resources/full_resolution.png b/paparazzi-gradle-plugin/src/test/projects/device-resolution/src/test/snapshots/images/app.cash.paparazzi.plugin.test_DeviceResolutionTest_deviceResolution[true].png similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/device-resolution/src/test/resources/full_resolution.png rename to paparazzi-gradle-plugin/src/test/projects/device-resolution/src/test/snapshots/images/app.cash.paparazzi.plugin.test_DeviceResolutionTest_deviceResolution[true].png diff --git a/paparazzi-gradle-plugin/src/test/projects/layout-direction/src/test/resources/locale_ar.png b/paparazzi-gradle-plugin/src/test/projects/layout-direction/src/test/snapshots/images/app.cash.paparazzi.plugin.test_LayoutDirectionTest_layoutDirection[AR].png similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/layout-direction/src/test/resources/locale_ar.png rename to paparazzi-gradle-plugin/src/test/projects/layout-direction/src/test/snapshots/images/app.cash.paparazzi.plugin.test_LayoutDirectionTest_layoutDirection[AR].png diff --git a/paparazzi-gradle-plugin/src/test/projects/layout-direction/src/test/resources/locale_default_rtl.png b/paparazzi-gradle-plugin/src/test/projects/layout-direction/src/test/snapshots/images/app.cash.paparazzi.plugin.test_LayoutDirectionTest_layoutDirection[DefaultRtl].png similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/layout-direction/src/test/resources/locale_default_rtl.png rename to paparazzi-gradle-plugin/src/test/projects/layout-direction/src/test/snapshots/images/app.cash.paparazzi.plugin.test_LayoutDirectionTest_layoutDirection[DefaultRtl].png diff --git a/paparazzi-gradle-plugin/src/test/projects/locale-qualifier/src/test/resources/locale_default.png b/paparazzi-gradle-plugin/src/test/projects/locale-qualifier/src/test/snapshots/images/app.cash.paparazzi.plugin.test_LocaleQualifierTest_locale[Default].png similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/locale-qualifier/src/test/resources/locale_default.png rename to paparazzi-gradle-plugin/src/test/projects/locale-qualifier/src/test/snapshots/images/app.cash.paparazzi.plugin.test_LocaleQualifierTest_locale[Default].png diff --git a/paparazzi-gradle-plugin/src/test/projects/locale-qualifier/src/test/resources/locale_en_gb.png b/paparazzi-gradle-plugin/src/test/projects/locale-qualifier/src/test/snapshots/images/app.cash.paparazzi.plugin.test_LocaleQualifierTest_locale[GB].png similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/locale-qualifier/src/test/resources/locale_en_gb.png rename to paparazzi-gradle-plugin/src/test/projects/locale-qualifier/src/test/snapshots/images/app.cash.paparazzi.plugin.test_LocaleQualifierTest_locale[GB].png diff --git a/paparazzi-gradle-plugin/src/test/projects/night-mode-compose/src/test/java/app/cash/paparazzi/plugin/test/NightModeTest.kt b/paparazzi-gradle-plugin/src/test/projects/night-mode-compose/src/test/java/app/cash/paparazzi/plugin/test/NightModeTest.kt deleted file mode 100644 index 4e2776c445..0000000000 --- a/paparazzi-gradle-plugin/src/test/projects/night-mode-compose/src/test/java/app/cash/paparazzi/plugin/test/NightModeTest.kt +++ /dev/null @@ -1,25 +0,0 @@ -package app.cash.paparazzi.plugin.test - -import app.cash.paparazzi.DeviceConfig -import app.cash.paparazzi.Paparazzi -import com.android.resources.NightMode -import com.google.testing.junit.testparameterinjector.TestParameter -import com.google.testing.junit.testparameterinjector.TestParameterInjector -import org.junit.Rule -import org.junit.Test -import org.junit.runner.RunWith - -@RunWith(TestParameterInjector::class) -class NightModeTest( - @TestParameter nightMode: NightMode -) { - @get:Rule - val paparazzi = Paparazzi( - deviceConfig = DeviceConfig.NEXUS_5.copy(nightMode = nightMode) - ) - - @Test - fun compose() { - paparazzi.snapshot { LightDark() } - } -} diff --git a/paparazzi-gradle-plugin/src/test/projects/night-mode-xml/src/test/resources/dark_mode.png b/paparazzi-gradle-plugin/src/test/projects/night-mode-xml/src/test/resources/dark_mode.png deleted file mode 100644 index fd3458c2d5..0000000000 Binary files a/paparazzi-gradle-plugin/src/test/projects/night-mode-xml/src/test/resources/dark_mode.png and /dev/null differ diff --git a/paparazzi-gradle-plugin/src/test/projects/night-mode-xml/src/test/resources/light_mode.png b/paparazzi-gradle-plugin/src/test/projects/night-mode-xml/src/test/resources/light_mode.png deleted file mode 100644 index 8f1ddca12d..0000000000 Binary files a/paparazzi-gradle-plugin/src/test/projects/night-mode-xml/src/test/resources/light_mode.png and /dev/null differ diff --git a/paparazzi-gradle-plugin/src/test/projects/night-mode-compose/build.gradle b/paparazzi-gradle-plugin/src/test/projects/night-mode/build.gradle similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/night-mode-compose/build.gradle rename to paparazzi-gradle-plugin/src/test/projects/night-mode/build.gradle diff --git a/paparazzi-gradle-plugin/src/test/projects/night-mode-compose/src/main/java/app/cash/paparazzi/plugin/test/LightDark.kt b/paparazzi-gradle-plugin/src/test/projects/night-mode/src/main/java/app/cash/paparazzi/plugin/test/LightDark.kt similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/night-mode-compose/src/main/java/app/cash/paparazzi/plugin/test/LightDark.kt rename to paparazzi-gradle-plugin/src/test/projects/night-mode/src/main/java/app/cash/paparazzi/plugin/test/LightDark.kt diff --git a/paparazzi-gradle-plugin/src/test/projects/night-mode-xml/src/main/res/layout-night/layout.xml b/paparazzi-gradle-plugin/src/test/projects/night-mode/src/main/res/layout-night/layout.xml similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/night-mode-xml/src/main/res/layout-night/layout.xml rename to paparazzi-gradle-plugin/src/test/projects/night-mode/src/main/res/layout-night/layout.xml diff --git a/paparazzi-gradle-plugin/src/test/projects/night-mode-xml/src/main/res/layout/layout.xml b/paparazzi-gradle-plugin/src/test/projects/night-mode/src/main/res/layout/layout.xml similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/night-mode-xml/src/main/res/layout/layout.xml rename to paparazzi-gradle-plugin/src/test/projects/night-mode/src/main/res/layout/layout.xml diff --git a/paparazzi-gradle-plugin/src/test/projects/night-mode-xml/src/test/java/app/cash/paparazzi/plugin/test/NightModeTest.kt b/paparazzi-gradle-plugin/src/test/projects/night-mode/src/test/java/app/cash/paparazzi/plugin/test/NightModeTest.kt similarity index 90% rename from paparazzi-gradle-plugin/src/test/projects/night-mode-xml/src/test/java/app/cash/paparazzi/plugin/test/NightModeTest.kt rename to paparazzi-gradle-plugin/src/test/projects/night-mode/src/test/java/app/cash/paparazzi/plugin/test/NightModeTest.kt index 009481bacd..15ffc27bd3 100644 --- a/paparazzi-gradle-plugin/src/test/projects/night-mode-xml/src/test/java/app/cash/paparazzi/plugin/test/NightModeTest.kt +++ b/paparazzi-gradle-plugin/src/test/projects/night-mode/src/test/java/app/cash/paparazzi/plugin/test/NightModeTest.kt @@ -22,4 +22,9 @@ class NightModeTest( fun xml() { paparazzi.snapshot(paparazzi.inflate(R.layout.layout)) } + + @Test + fun compose() { + paparazzi.snapshot { LightDark() } + } } diff --git a/paparazzi-gradle-plugin/src/test/projects/night-mode-compose/src/test/resources/dark_mode.png b/paparazzi-gradle-plugin/src/test/projects/night-mode/src/test/snapshots/images/app.cash.paparazzi.plugin.test_NightModeTest_compose[NIGHT].png similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/night-mode-compose/src/test/resources/dark_mode.png rename to paparazzi-gradle-plugin/src/test/projects/night-mode/src/test/snapshots/images/app.cash.paparazzi.plugin.test_NightModeTest_compose[NIGHT].png diff --git a/paparazzi-gradle-plugin/src/test/projects/night-mode-compose/src/test/resources/light_mode.png b/paparazzi-gradle-plugin/src/test/projects/night-mode/src/test/snapshots/images/app.cash.paparazzi.plugin.test_NightModeTest_compose[NOTNIGHT].png similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/night-mode-compose/src/test/resources/light_mode.png rename to paparazzi-gradle-plugin/src/test/projects/night-mode/src/test/snapshots/images/app.cash.paparazzi.plugin.test_NightModeTest_compose[NOTNIGHT].png diff --git a/paparazzi-gradle-plugin/src/test/projects/night-mode/src/test/snapshots/images/app.cash.paparazzi.plugin.test_NightModeTest_xml[NIGHT].png b/paparazzi-gradle-plugin/src/test/projects/night-mode/src/test/snapshots/images/app.cash.paparazzi.plugin.test_NightModeTest_xml[NIGHT].png new file mode 100644 index 0000000000..033d521146 Binary files /dev/null and b/paparazzi-gradle-plugin/src/test/projects/night-mode/src/test/snapshots/images/app.cash.paparazzi.plugin.test_NightModeTest_xml[NIGHT].png differ diff --git a/paparazzi-gradle-plugin/src/test/projects/night-mode/src/test/snapshots/images/app.cash.paparazzi.plugin.test_NightModeTest_xml[NOTNIGHT].png b/paparazzi-gradle-plugin/src/test/projects/night-mode/src/test/snapshots/images/app.cash.paparazzi.plugin.test_NightModeTest_xml[NOTNIGHT].png new file mode 100644 index 0000000000..4d5b0a74fe Binary files /dev/null and b/paparazzi-gradle-plugin/src/test/projects/night-mode/src/test/snapshots/images/app.cash.paparazzi.plugin.test_NightModeTest_xml[NOTNIGHT].png differ diff --git a/paparazzi-gradle-plugin/src/test/projects/nine-patch/src/test/resources/nine_patch.png b/paparazzi-gradle-plugin/src/test/projects/nine-patch/src/test/snapshots/images/app.cash.paparazzi.plugin.test_NinePatchTest_ninePatch.png similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/nine-patch/src/test/resources/nine_patch.png rename to paparazzi-gradle-plugin/src/test/projects/nine-patch/src/test/snapshots/images/app.cash.paparazzi.plugin.test_NinePatchTest_ninePatch.png diff --git a/paparazzi-gradle-plugin/src/test/projects/supports-application-modules/src/test/resources/launch.png b/paparazzi-gradle-plugin/src/test/projects/supports-application-modules/src/test/snapshots/images/app.cash.paparazzi.plugin.test_LaunchViewTest_testViews_launch.png similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/supports-application-modules/src/test/resources/launch.png rename to paparazzi-gradle-plugin/src/test/projects/supports-application-modules/src/test/snapshots/images/app.cash.paparazzi.plugin.test_LaunchViewTest_testViews_launch.png diff --git a/paparazzi-gradle-plugin/src/test/projects/supports-dynamic-feature-modules/dynamic_feature/src/test/resources/launch.png b/paparazzi-gradle-plugin/src/test/projects/supports-dynamic-feature-modules/dynamic_feature/src/test/snapshots/images/app.cash.paparazzi.plugin.test_LaunchViewTest_testViews_launch.png similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/supports-dynamic-feature-modules/dynamic_feature/src/test/resources/launch.png rename to paparazzi-gradle-plugin/src/test/projects/supports-dynamic-feature-modules/dynamic_feature/src/test/snapshots/images/app.cash.paparazzi.plugin.test_LaunchViewTest_testViews_launch.png diff --git a/paparazzi-gradle-plugin/src/test/projects/text-appearances-xml/build.gradle b/paparazzi-gradle-plugin/src/test/projects/text-appearances-xml/build.gradle deleted file mode 100644 index fef0312e73..0000000000 --- a/paparazzi-gradle-plugin/src/test/projects/text-appearances-xml/build.gradle +++ /dev/null @@ -1,21 +0,0 @@ -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() - } -} - diff --git a/paparazzi-gradle-plugin/src/test/projects/text-appearances-xml/src/main/res/values/colors.xml b/paparazzi-gradle-plugin/src/test/projects/text-appearances-xml/src/main/res/values/colors.xml deleted file mode 100644 index c42933e15d..0000000000 --- a/paparazzi-gradle-plugin/src/test/projects/text-appearances-xml/src/main/res/values/colors.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - #00D015 - diff --git a/paparazzi-gradle-plugin/src/test/projects/text-appearances-xml/src/main/res/values/styles.xml b/paparazzi-gradle-plugin/src/test/projects/text-appearances-xml/src/main/res/values/styles.xml deleted file mode 100644 index 2cb15baba3..0000000000 --- a/paparazzi-gradle-plugin/src/test/projects/text-appearances-xml/src/main/res/values/styles.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - diff --git a/paparazzi-gradle-plugin/src/test/projects/text-appearances-xml/src/test/java/app/cash/paparazzi/plugin/test/TextAppearanceTest.kt b/paparazzi-gradle-plugin/src/test/projects/text-appearances-xml/src/test/java/app/cash/paparazzi/plugin/test/TextAppearanceTest.kt deleted file mode 100644 index 13530e17cf..0000000000 --- a/paparazzi-gradle-plugin/src/test/projects/text-appearances-xml/src/test/java/app/cash/paparazzi/plugin/test/TextAppearanceTest.kt +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2020 Square, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package app.cash.paparazzi.plugin.test - -import android.widget.LinearLayout -import app.cash.paparazzi.Paparazzi -import org.junit.Rule -import org.junit.Test - -class TextAppearanceTest { - @get:Rule - val paparazzi = Paparazzi() - - @Test - fun verify() { - val view = paparazzi.inflate(R.layout.text_appearance_test) - paparazzi.snapshot(view) - } -} diff --git a/paparazzi-gradle-plugin/src/test/projects/text-appearances-code/build.gradle b/paparazzi-gradle-plugin/src/test/projects/text-appearances/build.gradle similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/text-appearances-code/build.gradle rename to paparazzi-gradle-plugin/src/test/projects/text-appearances/build.gradle diff --git a/paparazzi-gradle-plugin/src/test/projects/text-appearances-xml/src/main/res/layout/text_appearance_test.xml b/paparazzi-gradle-plugin/src/test/projects/text-appearances/src/main/res/layout/text_appearance_test.xml similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/text-appearances-xml/src/main/res/layout/text_appearance_test.xml rename to paparazzi-gradle-plugin/src/test/projects/text-appearances/src/main/res/layout/text_appearance_test.xml diff --git a/paparazzi-gradle-plugin/src/test/projects/text-appearances-code/src/main/res/values/colors.xml b/paparazzi-gradle-plugin/src/test/projects/text-appearances/src/main/res/values/colors.xml similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/text-appearances-code/src/main/res/values/colors.xml rename to paparazzi-gradle-plugin/src/test/projects/text-appearances/src/main/res/values/colors.xml diff --git a/paparazzi-gradle-plugin/src/test/projects/text-appearances-code/src/main/res/values/styles.xml b/paparazzi-gradle-plugin/src/test/projects/text-appearances/src/main/res/values/styles.xml similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/text-appearances-code/src/main/res/values/styles.xml rename to paparazzi-gradle-plugin/src/test/projects/text-appearances/src/main/res/values/styles.xml diff --git a/paparazzi-gradle-plugin/src/test/projects/text-appearances-code/src/test/java/app/cash/paparazzi/plugin/test/TextAppearanceTest.kt b/paparazzi-gradle-plugin/src/test/projects/text-appearances/src/test/java/app/cash/paparazzi/plugin/test/TextAppearanceTest.kt similarity index 92% rename from paparazzi-gradle-plugin/src/test/projects/text-appearances-code/src/test/java/app/cash/paparazzi/plugin/test/TextAppearanceTest.kt rename to paparazzi-gradle-plugin/src/test/projects/text-appearances/src/test/java/app/cash/paparazzi/plugin/test/TextAppearanceTest.kt index 09b1123971..d1d783569e 100644 --- a/paparazzi-gradle-plugin/src/test/projects/text-appearances-code/src/test/java/app/cash/paparazzi/plugin/test/TextAppearanceTest.kt +++ b/paparazzi-gradle-plugin/src/test/projects/text-appearances/src/test/java/app/cash/paparazzi/plugin/test/TextAppearanceTest.kt @@ -31,7 +31,7 @@ class TextAppearanceTest { val paparazzi = Paparazzi() @Test - fun verify() { + fun inCode() { val context = paparazzi.context val view = LinearLayout(context).apply { orientation = LinearLayout.VERTICAL @@ -54,6 +54,12 @@ class TextAppearanceTest { paparazzi.snapshot(view) } + @Test + fun inXml() { + val view = paparazzi.inflate(R.layout.text_appearance_test) + paparazzi.snapshot(view) + } + private fun createTextView(context: Context) = TextView(context, null, 0).apply { layoutParams = LinearLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT) diff --git a/paparazzi-gradle-plugin/src/test/projects/text-appearances-code/src/test/resources/textappearances.png b/paparazzi-gradle-plugin/src/test/projects/text-appearances/src/test/snapshots/images/app.cash.paparazzi.plugin.test_TextAppearanceTest_inCode.png similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/text-appearances-code/src/test/resources/textappearances.png rename to paparazzi-gradle-plugin/src/test/projects/text-appearances/src/test/snapshots/images/app.cash.paparazzi.plugin.test_TextAppearanceTest_inCode.png diff --git a/paparazzi-gradle-plugin/src/test/projects/text-appearances-xml/src/test/resources/textappearances.png b/paparazzi-gradle-plugin/src/test/projects/text-appearances/src/test/snapshots/images/app.cash.paparazzi.plugin.test_TextAppearanceTest_inXml.png similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/text-appearances-xml/src/test/resources/textappearances.png rename to paparazzi-gradle-plugin/src/test/projects/text-appearances/src/test/snapshots/images/app.cash.paparazzi.plugin.test_TextAppearanceTest_inXml.png diff --git a/paparazzi-gradle-plugin/src/test/projects/transitive-resources/module/src/test/java/app/cash/paparazzi/plugin/test/AmountViewTest.kt b/paparazzi-gradle-plugin/src/test/projects/transitive-resources/module/src/test/java/app/cash/paparazzi/plugin/test/AmountViewTest.kt index a5fe65bd46..2cfa4f5ce2 100644 --- a/paparazzi-gradle-plugin/src/test/projects/transitive-resources/module/src/test/java/app/cash/paparazzi/plugin/test/AmountViewTest.kt +++ b/paparazzi-gradle-plugin/src/test/projects/transitive-resources/module/src/test/java/app/cash/paparazzi/plugin/test/AmountViewTest.kt @@ -24,8 +24,8 @@ class AmountViewTest { val paparazzi = Paparazzi() @Test - fun testViews() { + fun amount() { val amount = AmountView(paparazzi.context) - paparazzi.snapshot(amount, "amount") + paparazzi.snapshot(amount, "five_bucks") } } diff --git a/paparazzi-gradle-plugin/src/test/projects/transitive-resources/module/src/test/resources/five_bucks.png b/paparazzi-gradle-plugin/src/test/projects/transitive-resources/module/src/test/snapshots/images/app.cash.paparazzi.plugin.test_AmountViewTest_amount_five_bucks.png similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/transitive-resources/module/src/test/resources/five_bucks.png rename to paparazzi-gradle-plugin/src/test/projects/transitive-resources/module/src/test/snapshots/images/app.cash.paparazzi.plugin.test_AmountViewTest_amount_five_bucks.png diff --git a/paparazzi-gradle-plugin/src/test/projects/update-paparazzi-config/src/test/resources/nexus_7_launch.png b/paparazzi-gradle-plugin/src/test/projects/update-paparazzi-config/src/test/snapshots/images/app.cash.paparazzi.plugin.test_LaunchViewTest_updatingConfigUpdatesResources_nexus7.png similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/update-paparazzi-config/src/test/resources/nexus_7_launch.png rename to paparazzi-gradle-plugin/src/test/projects/update-paparazzi-config/src/test/snapshots/images/app.cash.paparazzi.plugin.test_LaunchViewTest_updatingConfigUpdatesResources_nexus7.png diff --git a/paparazzi-gradle-plugin/src/test/projects/update-paparazzi-config/src/test/resources/pixel_3_launch.png b/paparazzi-gradle-plugin/src/test/projects/update-paparazzi-config/src/test/snapshots/images/app.cash.paparazzi.plugin.test_LaunchViewTest_updatingConfigUpdatesResources_pixel3.png similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/update-paparazzi-config/src/test/resources/pixel_3_launch.png rename to paparazzi-gradle-plugin/src/test/projects/update-paparazzi-config/src/test/snapshots/images/app.cash.paparazzi.plugin.test_LaunchViewTest_updatingConfigUpdatesResources_pixel3.png diff --git a/paparazzi-gradle-plugin/src/test/projects/verify-aapt-code/build.gradle b/paparazzi-gradle-plugin/src/test/projects/verify-aapt-code/build.gradle deleted file mode 100644 index d95de55f1b..0000000000 --- a/paparazzi-gradle-plugin/src/test/projects/verify-aapt-code/build.gradle +++ /dev/null @@ -1,26 +0,0 @@ -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 - vectorDrawables.useSupportLibrary = true - } - compileOptions { - sourceCompatibility = libs.versions.javaTarget.get() - targetCompatibility = libs.versions.javaTarget.get() - } - kotlinOptions { - jvmTarget = libs.versions.javaTarget.get() - } -} - -dependencies { - implementation libs.androidx.appcompat -} - diff --git a/paparazzi-gradle-plugin/src/test/projects/verify-aapt-compose/src/main/res/drawable/card_chip.xml b/paparazzi-gradle-plugin/src/test/projects/verify-aapt-compose/src/main/res/drawable/card_chip.xml deleted file mode 100644 index a9cb398978..0000000000 --- a/paparazzi-gradle-plugin/src/test/projects/verify-aapt-compose/src/main/res/drawable/card_chip.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/paparazzi-gradle-plugin/src/test/projects/verify-aapt-compose/src/test/java/app/cash/paparazzi/plugin/test/ComposeTest.kt b/paparazzi-gradle-plugin/src/test/projects/verify-aapt-compose/src/test/java/app/cash/paparazzi/plugin/test/ComposeTest.kt deleted file mode 100644 index 3ca4b14558..0000000000 --- a/paparazzi-gradle-plugin/src/test/projects/verify-aapt-compose/src/test/java/app/cash/paparazzi/plugin/test/ComposeTest.kt +++ /dev/null @@ -1,17 +0,0 @@ -package app.cash.paparazzi.plugin.test - -import app.cash.paparazzi.Paparazzi -import org.junit.Rule -import org.junit.Test - -class ComposeTest { - @get:Rule - val paparazzi = Paparazzi() - - @Test - fun compose() { - paparazzi.snapshot { - CardChip() - } - } -} diff --git a/paparazzi-gradle-plugin/src/test/projects/verify-aapt-compose/src/test/resources/compose_card_chip.png b/paparazzi-gradle-plugin/src/test/projects/verify-aapt-compose/src/test/resources/compose_card_chip.png deleted file mode 100644 index 88e49e2700..0000000000 Binary files a/paparazzi-gradle-plugin/src/test/projects/verify-aapt-compose/src/test/resources/compose_card_chip.png and /dev/null differ diff --git a/paparazzi-gradle-plugin/src/test/projects/verify-aapt-xml/build.gradle b/paparazzi-gradle-plugin/src/test/projects/verify-aapt-xml/build.gradle deleted file mode 100644 index d95de55f1b..0000000000 --- a/paparazzi-gradle-plugin/src/test/projects/verify-aapt-xml/build.gradle +++ /dev/null @@ -1,26 +0,0 @@ -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 - vectorDrawables.useSupportLibrary = true - } - compileOptions { - sourceCompatibility = libs.versions.javaTarget.get() - targetCompatibility = libs.versions.javaTarget.get() - } - kotlinOptions { - jvmTarget = libs.versions.javaTarget.get() - } -} - -dependencies { - implementation libs.androidx.appcompat -} - diff --git a/paparazzi-gradle-plugin/src/test/projects/verify-aapt-xml/src/main/res/drawable/card_chip.xml b/paparazzi-gradle-plugin/src/test/projects/verify-aapt-xml/src/main/res/drawable/card_chip.xml deleted file mode 100644 index a9cb398978..0000000000 --- a/paparazzi-gradle-plugin/src/test/projects/verify-aapt-xml/src/main/res/drawable/card_chip.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/paparazzi-gradle-plugin/src/test/projects/verify-aapt-xml/src/test/java/app/cash/paparazzi/plugin/test/AaptDrawableTest.kt b/paparazzi-gradle-plugin/src/test/projects/verify-aapt-xml/src/test/java/app/cash/paparazzi/plugin/test/AaptDrawableTest.kt deleted file mode 100644 index b5e16773c9..0000000000 --- a/paparazzi-gradle-plugin/src/test/projects/verify-aapt-xml/src/test/java/app/cash/paparazzi/plugin/test/AaptDrawableTest.kt +++ /dev/null @@ -1,20 +0,0 @@ -package app.cash.paparazzi.plugin.test - -import android.view.View -import android.widget.ImageView -import app.cash.paparazzi.Paparazzi -import org.junit.Rule -import org.junit.Test - -class AaptDrawableTest { - @get:Rule - val paparazzi = Paparazzi() - - @Test - fun aaptEmbeddedDrawable() { - val view = paparazzi.inflate(R.layout.aapt_drawable) - val imageView = view.findViewById(R.id.image) - imageView.setImageResource(R.drawable.card_chip) - paparazzi.snapshot(view) - } -} diff --git a/paparazzi-gradle-plugin/src/test/projects/night-mode-xml/build.gradle b/paparazzi-gradle-plugin/src/test/projects/verify-aapt/build.gradle similarity index 87% rename from paparazzi-gradle-plugin/src/test/projects/night-mode-xml/build.gradle rename to paparazzi-gradle-plugin/src/test/projects/verify-aapt/build.gradle index 2a58a31c5d..5da96fd086 100644 --- a/paparazzi-gradle-plugin/src/test/projects/night-mode-xml/build.gradle +++ b/paparazzi-gradle-plugin/src/test/projects/verify-aapt/build.gradle @@ -10,6 +10,7 @@ android { compileSdk libs.versions.compileSdk.get() as int defaultConfig { minSdk libs.versions.minSdk.get() as int + vectorDrawables.useSupportLibrary = true } compileOptions { sourceCompatibility = libs.versions.javaTarget.get() @@ -24,8 +25,6 @@ android { } dependencies { + implementation libs.androidx.appcompat implementation libs.composeUi.material - - testImplementation libs.testParameterInjector } - diff --git a/paparazzi-gradle-plugin/src/test/projects/verify-aapt-compose/src/main/java/app/cash/paparazzi/plugin/test/CardChip.kt b/paparazzi-gradle-plugin/src/test/projects/verify-aapt/src/main/java/app/cash/paparazzi/plugin/test/CardChip.kt similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/verify-aapt-compose/src/main/java/app/cash/paparazzi/plugin/test/CardChip.kt rename to paparazzi-gradle-plugin/src/test/projects/verify-aapt/src/main/java/app/cash/paparazzi/plugin/test/CardChip.kt diff --git a/paparazzi-gradle-plugin/src/test/projects/verify-aapt-code/src/main/res/drawable/card_chip.xml b/paparazzi-gradle-plugin/src/test/projects/verify-aapt/src/main/res/drawable/card_chip.xml similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/verify-aapt-code/src/main/res/drawable/card_chip.xml rename to paparazzi-gradle-plugin/src/test/projects/verify-aapt/src/main/res/drawable/card_chip.xml diff --git a/paparazzi-gradle-plugin/src/test/projects/verify-aapt-xml/src/main/res/layout/aapt_drawable.xml b/paparazzi-gradle-plugin/src/test/projects/verify-aapt/src/main/res/layout/aapt_drawable.xml similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/verify-aapt-xml/src/main/res/layout/aapt_drawable.xml rename to paparazzi-gradle-plugin/src/test/projects/verify-aapt/src/main/res/layout/aapt_drawable.xml diff --git a/paparazzi-gradle-plugin/src/test/projects/verify-aapt-code/src/test/java/app/cash/paparazzi/plugin/test/AaptDrawableTest.kt b/paparazzi-gradle-plugin/src/test/projects/verify-aapt/src/test/java/app/cash/paparazzi/plugin/test/AaptDrawableTest.kt similarity index 74% rename from paparazzi-gradle-plugin/src/test/projects/verify-aapt-code/src/test/java/app/cash/paparazzi/plugin/test/AaptDrawableTest.kt rename to paparazzi-gradle-plugin/src/test/projects/verify-aapt/src/test/java/app/cash/paparazzi/plugin/test/AaptDrawableTest.kt index c735fb0572..de4f225b10 100644 --- a/paparazzi-gradle-plugin/src/test/projects/verify-aapt-code/src/test/java/app/cash/paparazzi/plugin/test/AaptDrawableTest.kt +++ b/paparazzi-gradle-plugin/src/test/projects/verify-aapt/src/test/java/app/cash/paparazzi/plugin/test/AaptDrawableTest.kt @@ -6,6 +6,7 @@ import android.view.View import android.view.ViewGroup.LayoutParams.MATCH_PARENT import android.widget.FrameLayout import android.widget.FrameLayout.LayoutParams +import android.widget.ImageView import androidx.appcompat.widget.AppCompatImageView import app.cash.paparazzi.Paparazzi import org.junit.Rule @@ -16,7 +17,15 @@ class AaptDrawableTest { val paparazzi = Paparazzi() @Test - fun aaptEmbeddedDrawable() { + fun inXml() { + val view = paparazzi.inflate(R.layout.aapt_drawable) + val imageView = view.findViewById(R.id.image) + imageView.setImageResource(R.drawable.card_chip) + paparazzi.snapshot(view) + } + + @Test + fun inCode() { val imageView = AppCompatImageView(paparazzi.context).apply { layoutParams = LayoutParams(dip(140), dip(140)) .apply { gravity = CENTER } @@ -29,6 +38,11 @@ class AaptDrawableTest { paparazzi.snapshot(wrapped) } + @Test + fun inCompose() { + paparazzi.snapshot { CardChip() } + } + private fun View.dip(value: Int): Int = TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP, diff --git a/paparazzi-gradle-plugin/src/test/projects/verify-aapt-code/src/test/resources/card_chip.png b/paparazzi-gradle-plugin/src/test/projects/verify-aapt/src/test/snapshots/images/app.cash.paparazzi.plugin.test_AaptDrawableTest_inCode.png similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/verify-aapt-code/src/test/resources/card_chip.png rename to paparazzi-gradle-plugin/src/test/projects/verify-aapt/src/test/snapshots/images/app.cash.paparazzi.plugin.test_AaptDrawableTest_inCode.png diff --git a/paparazzi-gradle-plugin/src/test/projects/verify-aapt-xml/src/test/resources/card_chip.png b/paparazzi-gradle-plugin/src/test/projects/verify-aapt/src/test/snapshots/images/app.cash.paparazzi.plugin.test_AaptDrawableTest_inCompose.png similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/verify-aapt-xml/src/test/resources/card_chip.png rename to paparazzi-gradle-plugin/src/test/projects/verify-aapt/src/test/snapshots/images/app.cash.paparazzi.plugin.test_AaptDrawableTest_inCompose.png diff --git a/paparazzi-gradle-plugin/src/test/projects/verify-aapt/src/test/snapshots/images/app.cash.paparazzi.plugin.test_AaptDrawableTest_inXml.png b/paparazzi-gradle-plugin/src/test/projects/verify-aapt/src/test/snapshots/images/app.cash.paparazzi.plugin.test_AaptDrawableTest_inXml.png new file mode 100644 index 0000000000..afa00c86d5 Binary files /dev/null and b/paparazzi-gradle-plugin/src/test/projects/verify-aapt/src/test/snapshots/images/app.cash.paparazzi.plugin.test_AaptDrawableTest_inXml.png differ diff --git a/paparazzi-gradle-plugin/src/test/projects/verify-gif/src/test/snapshots/videos/app.cash.paparazzi.plugin.test_KeypadViewTest_testViews_spin.png b/paparazzi-gradle-plugin/src/test/projects/verify-gif/src/test/snapshots/videos/app.cash.paparazzi.plugin.test_KeypadViewTest_testViews_spin.png index 02009b96e8..48a45880db 100644 Binary files a/paparazzi-gradle-plugin/src/test/projects/verify-gif/src/test/snapshots/videos/app.cash.paparazzi.plugin.test_KeypadViewTest_testViews_spin.png and b/paparazzi-gradle-plugin/src/test/projects/verify-gif/src/test/snapshots/videos/app.cash.paparazzi.plugin.test_KeypadViewTest_testViews_spin.png differ diff --git a/paparazzi-gradle-plugin/src/test/projects/verify-recyclerview/src/test/resources/recycler_view.png b/paparazzi-gradle-plugin/src/test/projects/verify-recyclerview/src/test/snapshots/images/app.cash.paparazzi.plugin.test_RecyclerViewTest_test.png similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/verify-recyclerview/src/test/resources/recycler_view.png rename to paparazzi-gradle-plugin/src/test/projects/verify-recyclerview/src/test/snapshots/images/app.cash.paparazzi.plugin.test_RecyclerViewTest_test.png diff --git a/paparazzi-gradle-plugin/src/test/projects/verify-rendering-modes/src/test/java/app/cash/paparazzi/plugin/test/RenderingModesTest.kt b/paparazzi-gradle-plugin/src/test/projects/verify-rendering-modes/src/test/java/app/cash/paparazzi/plugin/test/RenderingModesTest.kt index 44d1c47b4e..8dce364ba6 100644 --- a/paparazzi-gradle-plugin/src/test/projects/verify-rendering-modes/src/test/java/app/cash/paparazzi/plugin/test/RenderingModesTest.kt +++ b/paparazzi-gradle-plugin/src/test/projects/verify-rendering-modes/src/test/java/app/cash/paparazzi/plugin/test/RenderingModesTest.kt @@ -32,13 +32,13 @@ class RenderingModesTest { ) } - paparazzi.snapshot(view = linearLayout) // defaults to NORMAL + paparazzi.snapshot(view = linearLayout, name = "normal") // defaults to NORMAL paparazzi.unsafeUpdateConfig(renderingMode = RenderingMode.H_SCROLL) - paparazzi.snapshot(view = linearLayout) + paparazzi.snapshot(view = linearLayout, name = "horizontal_scroll") paparazzi.unsafeUpdateConfig(renderingMode = RenderingMode.V_SCROLL) linearLayout.orientation = LinearLayout.VERTICAL - paparazzi.snapshot(view = linearLayout) + paparazzi.snapshot(view = linearLayout, name = "vertical_scroll") paparazzi.unsafeUpdateConfig(renderingMode = RenderingMode.SHRINK) paparazzi.snapshot( @@ -46,7 +46,8 @@ class RenderingModesTest { text = "0" textSize = 20f layoutParams = LayoutParams(WRAP_CONTENT, WRAP_CONTENT) - } + }, + name = "shrink" ) } } diff --git a/paparazzi-gradle-plugin/src/test/projects/verify-rendering-modes/src/test/resources/horizontal_scroll.png b/paparazzi-gradle-plugin/src/test/projects/verify-rendering-modes/src/test/snapshots/images/app.cash.paparazzi.plugin.test_RenderingModesTest_renderingModes_horizontal_scroll.png similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/verify-rendering-modes/src/test/resources/horizontal_scroll.png rename to paparazzi-gradle-plugin/src/test/projects/verify-rendering-modes/src/test/snapshots/images/app.cash.paparazzi.plugin.test_RenderingModesTest_renderingModes_horizontal_scroll.png diff --git a/paparazzi-gradle-plugin/src/test/projects/verify-rendering-modes/src/test/resources/normal.png b/paparazzi-gradle-plugin/src/test/projects/verify-rendering-modes/src/test/snapshots/images/app.cash.paparazzi.plugin.test_RenderingModesTest_renderingModes_normal.png similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/verify-rendering-modes/src/test/resources/normal.png rename to paparazzi-gradle-plugin/src/test/projects/verify-rendering-modes/src/test/snapshots/images/app.cash.paparazzi.plugin.test_RenderingModesTest_renderingModes_normal.png diff --git a/paparazzi-gradle-plugin/src/test/projects/verify-rendering-modes/src/test/resources/shrink.png b/paparazzi-gradle-plugin/src/test/projects/verify-rendering-modes/src/test/snapshots/images/app.cash.paparazzi.plugin.test_RenderingModesTest_renderingModes_shrink.png similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/verify-rendering-modes/src/test/resources/shrink.png rename to paparazzi-gradle-plugin/src/test/projects/verify-rendering-modes/src/test/snapshots/images/app.cash.paparazzi.plugin.test_RenderingModesTest_renderingModes_shrink.png diff --git a/paparazzi-gradle-plugin/src/test/projects/verify-rendering-modes/src/test/resources/vertical_scroll.png b/paparazzi-gradle-plugin/src/test/projects/verify-rendering-modes/src/test/snapshots/images/app.cash.paparazzi.plugin.test_RenderingModesTest_renderingModes_vertical_scroll.png similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/verify-rendering-modes/src/test/resources/vertical_scroll.png rename to paparazzi-gradle-plugin/src/test/projects/verify-rendering-modes/src/test/snapshots/images/app.cash.paparazzi.plugin.test_RenderingModesTest_renderingModes_vertical_scroll.png diff --git a/paparazzi-gradle-plugin/src/test/projects/verify-screen-round/src/test/java/app/cash/paparazzi/plugin/test/RoundViewTest.kt b/paparazzi-gradle-plugin/src/test/projects/verify-screen-round/src/test/java/app/cash/paparazzi/plugin/test/RoundViewTest.kt index a9ee401eef..2b4d5b57c3 100644 --- a/paparazzi-gradle-plugin/src/test/projects/verify-screen-round/src/test/java/app/cash/paparazzi/plugin/test/RoundViewTest.kt +++ b/paparazzi-gradle-plugin/src/test/projects/verify-screen-round/src/test/java/app/cash/paparazzi/plugin/test/RoundViewTest.kt @@ -22,22 +22,12 @@ class RoundViewTest( @Test fun test() { paparazzi.snapshot( - view = paparazzi.inflate(R.layout.custom_view), - name = configuration.testName + view = paparazzi.inflate(R.layout.custom_view) ) } } -enum class ScreenRoundTestConfiguration( - val round: ScreenRound, - val testName: String -) { - ROUND( - round = ScreenRound.ROUND, - testName = "round" - ), - NOT_ROUND( - round = ScreenRound.NOTROUND, - testName = "not_round" - ) +enum class ScreenRoundTestConfiguration(val round: ScreenRound) { + ROUND(round = ScreenRound.ROUND), + NOT_ROUND(round = ScreenRound.NOTROUND) } diff --git a/paparazzi-gradle-plugin/src/test/projects/verify-screen-round/src/test/resources/not_round.png b/paparazzi-gradle-plugin/src/test/projects/verify-screen-round/src/test/snapshots/images/app.cash.paparazzi.plugin.test_RoundViewTest_test[NOT_ROUND].png similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/verify-screen-round/src/test/resources/not_round.png rename to paparazzi-gradle-plugin/src/test/projects/verify-screen-round/src/test/snapshots/images/app.cash.paparazzi.plugin.test_RoundViewTest_test[NOT_ROUND].png diff --git a/paparazzi-gradle-plugin/src/test/projects/verify-screen-round/src/test/resources/round.png b/paparazzi-gradle-plugin/src/test/projects/verify-screen-round/src/test/snapshots/images/app.cash.paparazzi.plugin.test_RoundViewTest_test[ROUND].png similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/verify-screen-round/src/test/resources/round.png rename to paparazzi-gradle-plugin/src/test/projects/verify-screen-round/src/test/snapshots/images/app.cash.paparazzi.plugin.test_RoundViewTest_test[ROUND].png diff --git a/paparazzi-gradle-plugin/src/test/projects/verify-snapshot/src/test/resources/launch.png b/paparazzi-gradle-plugin/src/test/projects/verify-snapshot/src/test/snapshots/images/app.cash.paparazzi.plugin.test_LaunchViewTest_testViews_launch.png similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/verify-snapshot/src/test/resources/launch.png rename to paparazzi-gradle-plugin/src/test/projects/verify-snapshot/src/test/snapshots/images/app.cash.paparazzi.plugin.test_LaunchViewTest_testViews_launch.png diff --git a/paparazzi-gradle-plugin/src/test/projects/verify-svgs/src/test/resources/arrow_up.png b/paparazzi-gradle-plugin/src/test/projects/verify-svgs/src/test/snapshots/images/app.cash.paparazzi.plugin.test_VectorDrawableTest_vectorDrawable_arrow_up.png similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/verify-svgs/src/test/resources/arrow_up.png rename to paparazzi-gradle-plugin/src/test/projects/verify-svgs/src/test/snapshots/images/app.cash.paparazzi.plugin.test_VectorDrawableTest_vectorDrawable_arrow_up.png diff --git a/paparazzi-gradle-plugin/src/test/projects/widgets/src/test/resources/full_screen.png b/paparazzi-gradle-plugin/src/test/projects/widgets/src/test/snapshots/images/app.cash.paparazzi.plugin.test_RenderingModeTest_default[FULL_SCREEN].png similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/widgets/src/test/resources/full_screen.png rename to paparazzi-gradle-plugin/src/test/projects/widgets/src/test/snapshots/images/app.cash.paparazzi.plugin.test_RenderingModeTest_default[FULL_SCREEN].png diff --git a/paparazzi-gradle-plugin/src/test/projects/widgets/src/test/resources/widget.png b/paparazzi-gradle-plugin/src/test/projects/widgets/src/test/snapshots/images/app.cash.paparazzi.plugin.test_RenderingModeTest_default[WIDGET].png similarity index 100% rename from paparazzi-gradle-plugin/src/test/projects/widgets/src/test/resources/widget.png rename to paparazzi-gradle-plugin/src/test/projects/widgets/src/test/snapshots/images/app.cash.paparazzi.plugin.test_RenderingModeTest_default[WIDGET].png