-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3487 from CruGlobal/toolDetailsPaparazzi
create some Paparazzi tests for ToolDetailsLayout
- Loading branch information
Showing
36 changed files
with
240 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
...razziTest_ToolDetailsLayout() - Downloading[Nexus 5,NIGHT,NO_ACCESSIBILITY].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...razziTest_ToolDetailsLayout() - Downloading[Nexus 5,NOTNIGHT,ACCESSIBILITY].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...ziTest_ToolDetailsLayout() - Downloading[Nexus 5,NOTNIGHT,NO_ACCESSIBILITY].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...iTest_ToolDetailsLayout() - Downloading[Pixel 6 Pro,NIGHT,NO_ACCESSIBILITY].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...st_ToolDetailsLayout() - Downloading[Pixel 6 Pro,NOTNIGHT,NO_ACCESSIBILITY].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...razziTest_ToolDetailsLayout() - Drawer Open[Nexus 5,NIGHT,NO_ACCESSIBILITY].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...razziTest_ToolDetailsLayout() - Drawer Open[Nexus 5,NOTNIGHT,ACCESSIBILITY].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...ziTest_ToolDetailsLayout() - Drawer Open[Nexus 5,NOTNIGHT,NO_ACCESSIBILITY].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...iTest_ToolDetailsLayout() - Drawer Open[Pixel 6 Pro,NIGHT,NO_ACCESSIBILITY].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...st_ToolDetailsLayout() - Drawer Open[Pixel 6 Pro,NOTNIGHT,NO_ACCESSIBILITY].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...DetailsLayout() - Second Language Available[Nexus 5,NIGHT,NO_ACCESSIBILITY].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...DetailsLayout() - Second Language Available[Nexus 5,NOTNIGHT,ACCESSIBILITY].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...ailsLayout() - Second Language Available[Nexus 5,NOTNIGHT,NO_ACCESSIBILITY].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...ilsLayout() - Second Language Available[Pixel 6 Pro,NIGHT,NO_ACCESSIBILITY].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...Layout() - Second Language Available[Pixel 6 Pro,NOTNIGHT,NO_ACCESSIBILITY].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...aparazziTest_ToolDetailsLayout() - Variants[Nexus 5,NIGHT,NO_ACCESSIBILITY].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...aparazziTest_ToolDetailsLayout() - Variants[Nexus 5,NOTNIGHT,ACCESSIBILITY].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...razziTest_ToolDetailsLayout() - Variants[Nexus 5,NOTNIGHT,NO_ACCESSIBILITY].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...azziTest_ToolDetailsLayout() - Variants[Pixel 6 Pro,NIGHT,NO_ACCESSIBILITY].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...iTest_ToolDetailsLayout() - Variants[Pixel 6 Pro,NOTNIGHT,NO_ACCESSIBILITY].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...iTest_ToolDetailsLayout() - isFavorite=true[Nexus 5,NIGHT,NO_ACCESSIBILITY].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...iTest_ToolDetailsLayout() - isFavorite=true[Nexus 5,NOTNIGHT,ACCESSIBILITY].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...st_ToolDetailsLayout() - isFavorite=true[Nexus 5,NOTNIGHT,NO_ACCESSIBILITY].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...t_ToolDetailsLayout() - isFavorite=true[Pixel 6 Pro,NIGHT,NO_ACCESSIBILITY].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...oolDetailsLayout() - isFavorite=true[Pixel 6 Pro,NOTNIGHT,NO_ACCESSIBILITY].png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
...ailsLayoutPaparazziTest_ToolDetailsLayout()[Nexus 5,NIGHT,NO_ACCESSIBILITY].png
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
...ailsLayoutPaparazziTest_ToolDetailsLayout()[Nexus 5,NOTNIGHT,ACCESSIBILITY].png
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
...sLayoutPaparazziTest_ToolDetailsLayout()[Nexus 5,NOTNIGHT,NO_ACCESSIBILITY].png
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
...LayoutPaparazziTest_ToolDetailsLayout()[Pixel 6 Pro,NIGHT,NO_ACCESSIBILITY].png
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
...outPaparazziTest_ToolDetailsLayout()[Pixel 6 Pro,NOTNIGHT,NO_ACCESSIBILITY].png
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
app/src/testDebug/kotlin/org/cru/godtools/ui/drawer/DrawerMenuScreenStateTestData.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.cru.godtools.ui.drawer | ||
|
||
import androidx.compose.material3.DrawerState | ||
import androidx.compose.material3.DrawerValue | ||
import org.cru.godtools.ui.drawer.DrawerMenuScreen.State | ||
|
||
object DrawerMenuScreenStateTestData { | ||
val open = State( | ||
drawerState = DrawerState(DrawerValue.Open), | ||
versionName = "Paparazzi Snapshot", | ||
versionCode = 1 | ||
) | ||
} |
126 changes: 126 additions & 0 deletions
126
app/src/testDebug/kotlin/org/cru/godtools/ui/tooldetails/ToolDetailsLayoutPaparazziTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
package org.cru.godtools.ui.tooldetails | ||
|
||
import android.graphics.drawable.Drawable | ||
import app.cash.paparazzi.DeviceConfig | ||
import coil.Coil | ||
import coil.ImageLoader | ||
import coil.annotation.ExperimentalCoilApi | ||
import coil.test.FakeImageLoaderEngine | ||
import com.android.resources.NightMode | ||
import com.google.testing.junit.testparameterinjector.TestParameter | ||
import com.google.testing.junit.testparameterinjector.TestParameterInjector | ||
import java.util.Locale | ||
import kotlin.test.AfterTest | ||
import kotlin.test.BeforeTest | ||
import kotlin.test.Test | ||
import kotlinx.collections.immutable.ImmutableList | ||
import kotlinx.collections.immutable.persistentListOf | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.ExperimentalCoroutinesApi | ||
import kotlinx.coroutines.test.UnconfinedTestDispatcher | ||
import kotlinx.coroutines.test.resetMain | ||
import kotlinx.coroutines.test.setMain | ||
import org.cru.godtools.downloadmanager.DownloadProgress | ||
import org.cru.godtools.model.Language | ||
import org.cru.godtools.model.randomTool | ||
import org.cru.godtools.model.randomTranslation | ||
import org.cru.godtools.ui.BasePaparazziTest | ||
import org.cru.godtools.ui.drawer.DrawerMenuScreenStateTestData | ||
import org.cru.godtools.ui.tooldetails.ToolDetailsScreen.State | ||
import org.cru.godtools.ui.tools.ToolCard | ||
import org.cru.godtools.ui.tools.ToolCardStateTestData | ||
import org.junit.runner.RunWith | ||
|
||
@RunWith(TestParameterInjector::class) | ||
class ToolDetailsLayoutPaparazziTest( | ||
@TestParameter(valuesProvider = DeviceConfigProvider::class) deviceConfig: DeviceConfig, | ||
@TestParameter nightMode: NightMode, | ||
@TestParameter accessibilityMode: AccessibilityMode, | ||
) : BasePaparazziTest(deviceConfig = deviceConfig, nightMode = nightMode, accessibilityMode = accessibilityMode) { | ||
private val banner = ToolCardStateTestData.banner | ||
private val variants: ImmutableList<ToolCard.State> = persistentListOf( | ||
ToolCardStateTestData.tool.copy(secondLanguage = null), | ||
ToolCardStateTestData.tool.copy(secondLanguage = null) | ||
) | ||
|
||
private val state = State( | ||
tool = randomTool( | ||
detailsBannerYoutubeVideoId = null, | ||
shares = 123355, | ||
pendingShares = 101, | ||
isFavorite = false | ||
), | ||
translation = randomTranslation( | ||
name = "Tool", | ||
description = "Description", | ||
), | ||
banner = banner, | ||
) | ||
|
||
@BeforeTest | ||
@OptIn(ExperimentalCoilApi::class, ExperimentalCoroutinesApi::class) | ||
fun setup() { | ||
Dispatchers.setMain(UnconfinedTestDispatcher()) | ||
val file = Drawable.createFromStream(javaClass.getResourceAsStream("../tools/banner.jpg"), "banner.jpg")!! | ||
Coil.setImageLoader( | ||
ImageLoader.Builder(paparazzi.context) | ||
.components { | ||
add( | ||
FakeImageLoaderEngine.Builder() | ||
.intercept(banner, file) | ||
.build() | ||
) | ||
} | ||
.build() | ||
) | ||
} | ||
|
||
@AfterTest | ||
@OptIn(ExperimentalCoroutinesApi::class) | ||
fun cleanup() { | ||
Coil.reset() | ||
Dispatchers.resetMain() | ||
} | ||
|
||
@Test | ||
fun `ToolDetailsLayout()`() = snapshot { ToolDetailsLayout(state) } | ||
|
||
@Test | ||
fun `ToolDetailsLayout() - Drawer Open`() = snapshot { | ||
ToolDetailsLayout(state.copy(drawerState = DrawerMenuScreenStateTestData.open)) | ||
} | ||
|
||
@Test | ||
fun `ToolDetailsLayout() - isFavorite=true`() = snapshot { | ||
ToolDetailsLayout( | ||
state.copy( | ||
tool = randomTool( | ||
detailsBannerYoutubeVideoId = null, | ||
shares = 123456, | ||
pendingShares = 0, | ||
isFavorite = true | ||
) | ||
) | ||
) | ||
} | ||
|
||
@Test | ||
fun `ToolDetailsLayout() - Downloading`() = snapshot { | ||
ToolDetailsLayout(state.copy(downloadProgress = DownloadProgress(2, 5))) | ||
} | ||
|
||
@Test | ||
fun `ToolDetailsLayout() - Variants`() = snapshot { | ||
ToolDetailsLayout(state.copy(variants = variants, pages = persistentListOf(ToolDetailsScreen.Page.VARIANTS))) | ||
} | ||
|
||
@Test | ||
fun `ToolDetailsLayout() - Second Language Available`() = snapshot { | ||
ToolDetailsLayout( | ||
state.copy( | ||
secondLanguage = Language(Locale.FRENCH), | ||
secondTranslation = randomTranslation(), | ||
) | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters