diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 739a00d..9d05b60 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -34,6 +34,9 @@ tripletPlugin = "3.8.1" # 3.8.3 # https://github.com/pinterest/ktlint ktlint = "0.48.2" # 0.49.1 +# https://github.com/cashapp/paparazzi/ +paparazzi = "1.3.1" + @@ -230,3 +233,4 @@ kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" } spotless = { id = "com.diffplug.spotless", version.ref = "spotless" } grgit = { id = "org.ajoberstar.grgit", version.ref = "grgit" } triplet = { id = "com.github.triplet.play", version.ref = "tripletPlugin" } +paparazzi = { id = "app.cash.paparazzi", version.ref = "paparazzi" } diff --git a/ui/settings/build.gradle.kts b/ui/settings/build.gradle.kts index a635c9f..37be3f8 100644 --- a/ui/settings/build.gradle.kts +++ b/ui/settings/build.gradle.kts @@ -5,6 +5,7 @@ plugins { alias(libs.plugins.detekt) alias(libs.plugins.kover) alias(libs.plugins.spotless) + alias(libs.plugins.paparazzi) } spotless { diff --git a/ui/settings/src/test/kotlin/photos/network/ui/settings/composable/SettingsHeader.kt b/ui/settings/src/test/kotlin/photos/network/ui/settings/composable/SettingsHeader.kt new file mode 100644 index 0000000..ee2db2b --- /dev/null +++ b/ui/settings/src/test/kotlin/photos/network/ui/settings/composable/SettingsHeader.kt @@ -0,0 +1,110 @@ +/* + * Copyright 2020-2023 Photos.network developers + * + * 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 + * + * https://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 photos.network.ui.settings.composable + +import app.cash.paparazzi.DeviceConfig +import app.cash.paparazzi.InstantAnimationsRule +import app.cash.paparazzi.Paparazzi +import com.android.ide.common.rendering.api.SessionParams +import org.junit.Rule +import org.junit.Test +import photos.network.api.ServerStatus +import photos.network.ui.common.theme.AppTheme + +class SettingsHeader { + @get:Rule + val instantAnimationsRule = InstantAnimationsRule() + + @get:Rule + val paparazzi = Paparazzi( + deviceConfig = DeviceConfig.PIXEL_5, + showSystemUi = false, + supportsRtl = true, + renderingMode = SessionParams.RenderingMode.SHRINK, + ) + + @Test + fun unauthorized_dark() { + paparazzi.snapshot { + AppTheme(useDarkTheme = true) { + SettingsHeader(serverStatus = ServerStatus.UNAUTHORIZED) + } + } + } + + @Test + fun unauthorized_light() { + paparazzi.snapshot { + AppTheme(useDarkTheme = false) { + SettingsHeader(serverStatus = ServerStatus.UNAUTHORIZED) + } + } + } + + @Test + fun unavailable_dark() { + paparazzi.snapshot { + AppTheme(useDarkTheme = true) { + SettingsHeader(serverStatus = ServerStatus.UNAVAILABLE) + } + } + } + + @Test + fun unavailable_light() { + paparazzi.snapshot { + AppTheme(useDarkTheme = false) { + SettingsHeader(serverStatus = ServerStatus.UNAVAILABLE) + } + } + } + + @Test + fun progress_dark() { + paparazzi.snapshot { + AppTheme(useDarkTheme = true) { + SettingsHeader(serverStatus = ServerStatus.PROGRESS) + } + } + } + + @Test + fun progress_light() { + paparazzi.snapshot { + AppTheme(useDarkTheme = false) { + SettingsHeader(serverStatus = ServerStatus.PROGRESS) + } + } + } + + @Test + fun available_dark() { + paparazzi.snapshot { + AppTheme(useDarkTheme = true) { + SettingsHeader(serverStatus = ServerStatus.AVAILABLE) + } + } + } + + @Test + fun available_light() { + paparazzi.snapshot { + AppTheme(useDarkTheme = false) { + SettingsHeader(serverStatus = ServerStatus.AVAILABLE) + } + } + } +} diff --git a/ui/settings/src/test/snapshots/images/photos.network.ui.settings.composable_SettingsHeader_available_dark.png b/ui/settings/src/test/snapshots/images/photos.network.ui.settings.composable_SettingsHeader_available_dark.png new file mode 100644 index 0000000..7178572 Binary files /dev/null and b/ui/settings/src/test/snapshots/images/photos.network.ui.settings.composable_SettingsHeader_available_dark.png differ diff --git a/ui/settings/src/test/snapshots/images/photos.network.ui.settings.composable_SettingsHeader_available_light.png b/ui/settings/src/test/snapshots/images/photos.network.ui.settings.composable_SettingsHeader_available_light.png new file mode 100644 index 0000000..eb1707c Binary files /dev/null and b/ui/settings/src/test/snapshots/images/photos.network.ui.settings.composable_SettingsHeader_available_light.png differ diff --git a/ui/settings/src/test/snapshots/images/photos.network.ui.settings.composable_SettingsHeader_progress_dark.png b/ui/settings/src/test/snapshots/images/photos.network.ui.settings.composable_SettingsHeader_progress_dark.png new file mode 100644 index 0000000..4b9a373 Binary files /dev/null and b/ui/settings/src/test/snapshots/images/photos.network.ui.settings.composable_SettingsHeader_progress_dark.png differ diff --git a/ui/settings/src/test/snapshots/images/photos.network.ui.settings.composable_SettingsHeader_progress_light.png b/ui/settings/src/test/snapshots/images/photos.network.ui.settings.composable_SettingsHeader_progress_light.png new file mode 100644 index 0000000..45d80bc Binary files /dev/null and b/ui/settings/src/test/snapshots/images/photos.network.ui.settings.composable_SettingsHeader_progress_light.png differ diff --git a/ui/settings/src/test/snapshots/images/photos.network.ui.settings.composable_SettingsHeader_unauthorized_dark.png b/ui/settings/src/test/snapshots/images/photos.network.ui.settings.composable_SettingsHeader_unauthorized_dark.png new file mode 100644 index 0000000..62cc310 Binary files /dev/null and b/ui/settings/src/test/snapshots/images/photos.network.ui.settings.composable_SettingsHeader_unauthorized_dark.png differ diff --git a/ui/settings/src/test/snapshots/images/photos.network.ui.settings.composable_SettingsHeader_unauthorized_light.png b/ui/settings/src/test/snapshots/images/photos.network.ui.settings.composable_SettingsHeader_unauthorized_light.png new file mode 100644 index 0000000..21dea4d Binary files /dev/null and b/ui/settings/src/test/snapshots/images/photos.network.ui.settings.composable_SettingsHeader_unauthorized_light.png differ diff --git a/ui/settings/src/test/snapshots/images/photos.network.ui.settings.composable_SettingsHeader_unavailable_dark.png b/ui/settings/src/test/snapshots/images/photos.network.ui.settings.composable_SettingsHeader_unavailable_dark.png new file mode 100644 index 0000000..5fb467e Binary files /dev/null and b/ui/settings/src/test/snapshots/images/photos.network.ui.settings.composable_SettingsHeader_unavailable_dark.png differ diff --git a/ui/settings/src/test/snapshots/images/photos.network.ui.settings.composable_SettingsHeader_unavailable_light.png b/ui/settings/src/test/snapshots/images/photos.network.ui.settings.composable_SettingsHeader_unavailable_light.png new file mode 100644 index 0000000..65332a8 Binary files /dev/null and b/ui/settings/src/test/snapshots/images/photos.network.ui.settings.composable_SettingsHeader_unavailable_light.png differ