From 1f1dd7ec63b715ac2ded1bd7d50f7b2d4b2a9523 Mon Sep 17 00:00:00 2001 From: takathemax Date: Thu, 17 Aug 2023 13:57:31 +0900 Subject: [PATCH] added a scroll screenshot test. --- .../testing/robot/SponsorsScreenRobot.kt | 15 +++++++++++++++ .../confsched2023/SponsorsScreenTest.kt | 12 ++++++++++++ 2 files changed, 27 insertions(+) diff --git a/core/testing/src/main/java/io/github/droidkaigi/confsched2023/testing/robot/SponsorsScreenRobot.kt b/core/testing/src/main/java/io/github/droidkaigi/confsched2023/testing/robot/SponsorsScreenRobot.kt index 2305315d8..1caae1be1 100644 --- a/core/testing/src/main/java/io/github/droidkaigi/confsched2023/testing/robot/SponsorsScreenRobot.kt +++ b/core/testing/src/main/java/io/github/droidkaigi/confsched2023/testing/robot/SponsorsScreenRobot.kt @@ -1,10 +1,14 @@ package io.github.droidkaigi.confsched2023.testing.robot +import androidx.compose.ui.test.hasTestTag import androidx.compose.ui.test.isRoot import androidx.compose.ui.test.junit4.AndroidComposeTestRule +import androidx.compose.ui.test.performTouchInput +import androidx.compose.ui.test.swipeUp import com.github.takahirom.roborazzi.captureRoboImage import io.github.droidkaigi.confsched2023.designsystem.theme.KaigiTheme import io.github.droidkaigi.confsched2023.sponsors.SponsorsScreen +import io.github.droidkaigi.confsched2023.sponsors.SponsorsScreenTestTag import io.github.droidkaigi.confsched2023.testing.RobotTestRule import io.github.droidkaigi.confsched2023.testing.coroutines.runTestWithLogging import kotlinx.coroutines.test.TestDispatcher @@ -37,6 +41,17 @@ class SponsorsScreenRobot @Inject constructor( waitUntilIdle() } + fun scrollSponsorScreen() { + composeTestRule + .onNode(hasTestTag(SponsorsScreenTestTag)) + .performTouchInput { + swipeUp( + startY = visibleSize.height * 3F / 4, + endY = visibleSize.height / 3F, + ) + } + } + fun checkScreenCapture() { composeTestRule .onNode(isRoot()) diff --git a/feature/sponsors/src/test/java/io/github/droidkaigi/confsched2023/SponsorsScreenTest.kt b/feature/sponsors/src/test/java/io/github/droidkaigi/confsched2023/SponsorsScreenTest.kt index e681756de..f52233601 100644 --- a/feature/sponsors/src/test/java/io/github/droidkaigi/confsched2023/SponsorsScreenTest.kt +++ b/feature/sponsors/src/test/java/io/github/droidkaigi/confsched2023/SponsorsScreenTest.kt @@ -38,4 +38,16 @@ class SponsorsScreenTest { checkScreenCapture() } } + + @Test + @Category(ScreenshotTests::class) + fun checkScrollShot() { + sponsorsScreenRobot { + setupScreenContent() + scrollSponsorScreen() + checkScreenCapture() + scrollSponsorScreen() + checkScreenCapture() + } + } }