diff --git a/app/src/main/kotlin/org/cru/godtools/ui/account/delete/DeleteAccountLayout.kt b/app/src/main/kotlin/org/cru/godtools/ui/account/delete/DeleteAccountLayout.kt index f68e6165f1..bac3f541a8 100644 --- a/app/src/main/kotlin/org/cru/godtools/ui/account/delete/DeleteAccountLayout.kt +++ b/app/src/main/kotlin/org/cru/godtools/ui/account/delete/DeleteAccountLayout.kt @@ -90,7 +90,9 @@ fun DeleteAccountLayout(state: State, modifier: Modifier = Modifier) { Text( stringResource(R.string.account_delete_description), style = MaterialTheme.typography.bodyLarge, - modifier = Modifier.padding(horizontal = MARGIN_HORIZONTAL, top = 8.dp, bottom = 32.dp) + modifier = Modifier + .padding(horizontal = MARGIN_HORIZONTAL, top = 8.dp, bottom = 32.dp) + .align(Alignment.Start) ) val actionsEnabled = state !is State.Deleting && state !is State.Error diff --git a/app/src/test/snapshots/images/org.cru.godtools.ui.account.delete_DeleteAccountLayoutPaparazziTest_DeleteAccountLayout() - Deleting[Nexus 5,NIGHT,NO_ACCESSIBILITY].png b/app/src/test/snapshots/images/org.cru.godtools.ui.account.delete_DeleteAccountLayoutPaparazziTest_DeleteAccountLayout() - Deleting[Nexus 5,NIGHT,NO_ACCESSIBILITY].png new file mode 100644 index 0000000000..1f5b412905 --- /dev/null +++ b/app/src/test/snapshots/images/org.cru.godtools.ui.account.delete_DeleteAccountLayoutPaparazziTest_DeleteAccountLayout() - Deleting[Nexus 5,NIGHT,NO_ACCESSIBILITY].png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:acede1ec253670ed38b86b51828f08caf8e5c664f154e38568fb3382eb01bbce +size 182838 diff --git a/app/src/test/snapshots/images/org.cru.godtools.ui.account.delete_DeleteAccountLayoutPaparazziTest_DeleteAccountLayout() - Deleting[Nexus 5,NOTNIGHT,ACCESSIBILITY].png b/app/src/test/snapshots/images/org.cru.godtools.ui.account.delete_DeleteAccountLayoutPaparazziTest_DeleteAccountLayout() - Deleting[Nexus 5,NOTNIGHT,ACCESSIBILITY].png new file mode 100644 index 0000000000..eb5619c352 --- /dev/null +++ b/app/src/test/snapshots/images/org.cru.godtools.ui.account.delete_DeleteAccountLayoutPaparazziTest_DeleteAccountLayout() - Deleting[Nexus 5,NOTNIGHT,ACCESSIBILITY].png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6df0ab425124f77bfb7c0ae25fa55e30e5ce724a0e0b0eb8aa0d3e7b22ee7e7e +size 185155 diff --git a/app/src/test/snapshots/images/org.cru.godtools.ui.account.delete_DeleteAccountLayoutPaparazziTest_DeleteAccountLayout() - Deleting[Nexus 5,NOTNIGHT,NO_ACCESSIBILITY].png b/app/src/test/snapshots/images/org.cru.godtools.ui.account.delete_DeleteAccountLayoutPaparazziTest_DeleteAccountLayout() - Deleting[Nexus 5,NOTNIGHT,NO_ACCESSIBILITY].png new file mode 100644 index 0000000000..7098686065 --- /dev/null +++ b/app/src/test/snapshots/images/org.cru.godtools.ui.account.delete_DeleteAccountLayoutPaparazziTest_DeleteAccountLayout() - Deleting[Nexus 5,NOTNIGHT,NO_ACCESSIBILITY].png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:70cbba13a6045788fb1345e74e92baf00649f813005793ff4b7edc41203855cb +size 181934 diff --git a/app/src/test/snapshots/images/org.cru.godtools.ui.account.delete_DeleteAccountLayoutPaparazziTest_DeleteAccountLayout() - Deleting[Pixel 6 Pro,NIGHT,NO_ACCESSIBILITY].png b/app/src/test/snapshots/images/org.cru.godtools.ui.account.delete_DeleteAccountLayoutPaparazziTest_DeleteAccountLayout() - Deleting[Pixel 6 Pro,NIGHT,NO_ACCESSIBILITY].png new file mode 100644 index 0000000000..306db78f31 --- /dev/null +++ b/app/src/test/snapshots/images/org.cru.godtools.ui.account.delete_DeleteAccountLayoutPaparazziTest_DeleteAccountLayout() - Deleting[Pixel 6 Pro,NIGHT,NO_ACCESSIBILITY].png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c1032ad338b59a9c2602594f925826b167205fc111c6ee3722f933a13bd8ce30 +size 130712 diff --git a/app/src/test/snapshots/images/org.cru.godtools.ui.account.delete_DeleteAccountLayoutPaparazziTest_DeleteAccountLayout() - Deleting[Pixel 6 Pro,NOTNIGHT,NO_ACCESSIBILITY].png b/app/src/test/snapshots/images/org.cru.godtools.ui.account.delete_DeleteAccountLayoutPaparazziTest_DeleteAccountLayout() - Deleting[Pixel 6 Pro,NOTNIGHT,NO_ACCESSIBILITY].png new file mode 100644 index 0000000000..a25349b900 --- /dev/null +++ b/app/src/test/snapshots/images/org.cru.godtools.ui.account.delete_DeleteAccountLayoutPaparazziTest_DeleteAccountLayout() - Deleting[Pixel 6 Pro,NOTNIGHT,NO_ACCESSIBILITY].png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9fefeb2b5ba77b1c673d63bf459c41fd9f732591c08623ec402537b93da794de +size 129821 diff --git a/app/src/test/snapshots/images/org.cru.godtools.ui.account.delete_DeleteAccountLayoutPaparazziTest_DeleteAccountLayout() - Display[Nexus 5,NIGHT,NO_ACCESSIBILITY].png b/app/src/test/snapshots/images/org.cru.godtools.ui.account.delete_DeleteAccountLayoutPaparazziTest_DeleteAccountLayout() - Display[Nexus 5,NIGHT,NO_ACCESSIBILITY].png new file mode 100644 index 0000000000..27a572377c --- /dev/null +++ b/app/src/test/snapshots/images/org.cru.godtools.ui.account.delete_DeleteAccountLayoutPaparazziTest_DeleteAccountLayout() - Display[Nexus 5,NIGHT,NO_ACCESSIBILITY].png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d574a5d1a780ff93b543fcd59bca64c70ad5ddfc2b1a97c4c92ab6fa26a27446 +size 184589 diff --git a/app/src/test/snapshots/images/org.cru.godtools.ui.account.delete_DeleteAccountLayoutPaparazziTest_DeleteAccountLayout() - Display[Nexus 5,NOTNIGHT,ACCESSIBILITY].png b/app/src/test/snapshots/images/org.cru.godtools.ui.account.delete_DeleteAccountLayoutPaparazziTest_DeleteAccountLayout() - Display[Nexus 5,NOTNIGHT,ACCESSIBILITY].png new file mode 100644 index 0000000000..30601e342d --- /dev/null +++ b/app/src/test/snapshots/images/org.cru.godtools.ui.account.delete_DeleteAccountLayoutPaparazziTest_DeleteAccountLayout() - Display[Nexus 5,NOTNIGHT,ACCESSIBILITY].png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d58a27cfd01ed36c760617c979a1d3d7518545bf90058f41bf1d0bd0c12fdae8 +size 186605 diff --git a/app/src/test/snapshots/images/org.cru.godtools.ui.account.delete_DeleteAccountLayoutPaparazziTest_DeleteAccountLayout() - Display[Nexus 5,NOTNIGHT,NO_ACCESSIBILITY].png b/app/src/test/snapshots/images/org.cru.godtools.ui.account.delete_DeleteAccountLayoutPaparazziTest_DeleteAccountLayout() - Display[Nexus 5,NOTNIGHT,NO_ACCESSIBILITY].png new file mode 100644 index 0000000000..ade6b5d726 --- /dev/null +++ b/app/src/test/snapshots/images/org.cru.godtools.ui.account.delete_DeleteAccountLayoutPaparazziTest_DeleteAccountLayout() - Display[Nexus 5,NOTNIGHT,NO_ACCESSIBILITY].png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6296b4c7617bbe6294ee236dbdb3dd2d9e7c193f8adc0d7437a92a88eb293d5c +size 183361 diff --git a/app/src/test/snapshots/images/org.cru.godtools.ui.account.delete_DeleteAccountLayoutPaparazziTest_DeleteAccountLayout() - Display[Pixel 6 Pro,NIGHT,NO_ACCESSIBILITY].png b/app/src/test/snapshots/images/org.cru.godtools.ui.account.delete_DeleteAccountLayoutPaparazziTest_DeleteAccountLayout() - Display[Pixel 6 Pro,NIGHT,NO_ACCESSIBILITY].png new file mode 100644 index 0000000000..407c9ffa43 --- /dev/null +++ b/app/src/test/snapshots/images/org.cru.godtools.ui.account.delete_DeleteAccountLayoutPaparazziTest_DeleteAccountLayout() - Display[Pixel 6 Pro,NIGHT,NO_ACCESSIBILITY].png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:16eaeefb917024168a521328ae5a6de74a4d06b5de0fd854ac0eef41530ebd53 +size 132020 diff --git a/app/src/test/snapshots/images/org.cru.godtools.ui.account.delete_DeleteAccountLayoutPaparazziTest_DeleteAccountLayout() - Display[Pixel 6 Pro,NOTNIGHT,NO_ACCESSIBILITY].png b/app/src/test/snapshots/images/org.cru.godtools.ui.account.delete_DeleteAccountLayoutPaparazziTest_DeleteAccountLayout() - Display[Pixel 6 Pro,NOTNIGHT,NO_ACCESSIBILITY].png new file mode 100644 index 0000000000..04e0def7b5 --- /dev/null +++ b/app/src/test/snapshots/images/org.cru.godtools.ui.account.delete_DeleteAccountLayoutPaparazziTest_DeleteAccountLayout() - Display[Pixel 6 Pro,NOTNIGHT,NO_ACCESSIBILITY].png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:375f027aa26f9ecc8be2aa96f8576dd1f046056144d2aba204986b23277c58d9 +size 130980 diff --git a/app/src/testDebug/kotlin/org/cru/godtools/ui/BasePaparazziTest.kt b/app/src/testDebug/kotlin/org/cru/godtools/ui/BasePaparazziTest.kt index 8514f99d6d..7c6a180878 100644 --- a/app/src/testDebug/kotlin/org/cru/godtools/ui/BasePaparazziTest.kt +++ b/app/src/testDebug/kotlin/org/cru/godtools/ui/BasePaparazziTest.kt @@ -17,6 +17,7 @@ import app.cash.paparazzi.Paparazzi import app.cash.paparazzi.accessibility.AccessibilityRenderExtension import com.android.ide.common.rendering.api.SessionParams.RenderingMode import com.android.resources.NightMode +import com.google.testing.junit.testparameterinjector.TestParameterValuesProvider import kotlin.test.BeforeTest import org.cru.godtools.base.ui.compose.LocalEventBus import org.cru.godtools.base.ui.theme.GodToolsTheme @@ -25,12 +26,20 @@ import org.junit.Assume.assumeFalse import org.junit.Rule abstract class BasePaparazziTest( + private val deviceConfig: DeviceConfig = DeviceConfig.NEXUS_5, private val nightMode: NightMode = NightMode.NOTNIGHT, private val accessibilityMode: AccessibilityMode = AccessibilityMode.NO_ACCESSIBILITY, renderingMode: RenderingMode = RenderingMode.NORMAL, private val excludeRedundantTests: Boolean = true, private val eventBus: EventBus = EventBus(), ) { + protected class DeviceConfigProvider : TestParameterValuesProvider() { + override fun provideValues(context: Context?) = listOf( + value(DeviceConfig.NEXUS_5).withName("Nexus 5"), +// value(DeviceConfig.NEXUS_10.copy(orientation = ScreenOrientation.PORTRAIT)).withName("Nexus 10 Portrait"), + value(DeviceConfig.PIXEL_6_PRO).withName("Pixel 6 Pro"), + ) + } enum class AccessibilityMode { ACCESSIBILITY, NO_ACCESSIBILITY } // HACK: workaround a "No OnBackPressedDispatcherOwner was provided via LocalOnBackPressedDispatcherOwner" error @@ -41,7 +50,7 @@ abstract class BasePaparazziTest( @get:Rule val paparazzi = Paparazzi( - deviceConfig = DeviceConfig.NEXUS_5.copy(nightMode = nightMode), + deviceConfig = deviceConfig.copy(nightMode = nightMode), renderingMode = when (accessibilityMode) { AccessibilityMode.ACCESSIBILITY -> when (renderingMode) { RenderingMode.SHRINK -> RenderingMode.NORMAL @@ -60,23 +69,30 @@ abstract class BasePaparazziTest( if (excludeRedundantTests) { // don't run accessibility mode for night mode, we already test it for Not Night assumeFalse(accessibilityMode == AccessibilityMode.ACCESSIBILITY && nightMode == NightMode.NIGHT) + + // don't run accessibility mode for devices other than the NEXUS_5 + assumeFalse(accessibilityMode == AccessibilityMode.ACCESSIBILITY && deviceConfig != DeviceConfig.NEXUS_5) } } - protected fun centerInSnapshot(content: @Composable BoxScope.() -> Unit) { + protected fun snapshot(content: @Composable () -> Unit) { paparazzi.snapshot { CompositionLocalProvider( LocalEventBus provides eventBus, LocalOnBackPressedDispatcherOwner provides backPressDispatcher ) { - GodToolsTheme { - Box( - contentAlignment = Alignment.Center, - modifier = Modifier.background(MaterialTheme.colorScheme.background), - content = content, - ) - } + GodToolsTheme(content = content) } } } + + protected fun centerInSnapshot(content: @Composable BoxScope.() -> Unit) { + snapshot { + Box( + contentAlignment = Alignment.Center, + modifier = Modifier.background(MaterialTheme.colorScheme.background), + content = content, + ) + } + } } diff --git a/app/src/testDebug/kotlin/org/cru/godtools/ui/account/delete/DeleteAccountLayoutPaparazziTest.kt b/app/src/testDebug/kotlin/org/cru/godtools/ui/account/delete/DeleteAccountLayoutPaparazziTest.kt new file mode 100644 index 0000000000..36e1a2919f --- /dev/null +++ b/app/src/testDebug/kotlin/org/cru/godtools/ui/account/delete/DeleteAccountLayoutPaparazziTest.kt @@ -0,0 +1,36 @@ +package org.cru.godtools.ui.account.delete + +import app.cash.paparazzi.DeviceConfig +import com.android.resources.NightMode +import com.google.testing.junit.testparameterinjector.TestParameter +import com.google.testing.junit.testparameterinjector.TestParameterInjector +import com.slack.circuit.test.TestEventSink +import kotlin.test.Ignore +import kotlin.test.Test +import org.cru.godtools.ui.BasePaparazziTest +import org.junit.runner.RunWith + +@RunWith(TestParameterInjector::class) +class DeleteAccountLayoutPaparazziTest( + @TestParameter(valuesProvider = DeviceConfigProvider::class) deviceConfig: DeviceConfig, + @TestParameter nightMode: NightMode, + @TestParameter accessibilityMode: AccessibilityMode, +) : BasePaparazziTest(deviceConfig = deviceConfig, nightMode = nightMode, accessibilityMode = accessibilityMode) { + private val events = TestEventSink() + + @Test + fun `DeleteAccountLayout() - Display`() { + snapshot { DeleteAccountLayout(DeleteAccountScreen.State.Display(events)) } + } + + @Test + fun `DeleteAccountLayout() - Deleting`() { + snapshot { DeleteAccountLayout(DeleteAccountScreen.State.Deleting(events)) } + } + + @Test + @Ignore("TODO: Disabled due to https://github.com/cashapp/paparazzi/issues/1025") + fun `DeleteAccountLayout() - Error`() { + snapshot { DeleteAccountLayout(DeleteAccountScreen.State.Error(events)) } + } +}