-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Check the launch of CropImageScreen
- Loading branch information
Showing
3 changed files
with
106 additions
and
1 deletion.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
...esting/src/main/java/io/github/droidkaigi/confsched/testing/robot/CropImageScreenRobot.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,31 @@ | ||
package io.github.droidkaigi.confsched.testing.robot | ||
|
||
import androidx.compose.ui.test.assertIsDisplayed | ||
import androidx.compose.ui.test.hasTestTag | ||
import io.github.droidkaigi.confsched.designsystem.theme.KaigiTheme | ||
import io.github.droidkaigi.confsched.profilecard.CropImageScreen | ||
import io.github.droidkaigi.confsched.profilecard.CropImageScreenTestTag | ||
import javax.inject.Inject | ||
|
||
class CropImageScreenRobot @Inject constructor( | ||
screenRobot: DefaultScreenRobot, | ||
) : ScreenRobot by screenRobot { | ||
|
||
fun setupScreenContent() { | ||
robotTestRule.setContent { | ||
KaigiTheme { | ||
CropImageScreen( | ||
onNavigationIconClick = {}, | ||
onBackWithConfirm = {}, | ||
) | ||
} | ||
} | ||
waitUntilIdle() | ||
} | ||
|
||
fun checkScreenDisplayed() { | ||
composeTestRule | ||
.onNode(hasTestTag(CropImageScreenTestTag)) | ||
.assertIsDisplayed() | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
.../androidUnitTest/kotlin/io/github/droidkaigi/confsched/profilecard/CropImageScreenTest.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,55 @@ | ||
package io.github.droidkaigi.confsched.profilecard | ||
|
||
import dagger.hilt.android.testing.BindValue | ||
import dagger.hilt.android.testing.HiltAndroidTest | ||
import io.github.droidkaigi.confsched.testing.DescribedBehavior | ||
import io.github.droidkaigi.confsched.testing.describeBehaviors | ||
import io.github.droidkaigi.confsched.testing.execute | ||
import io.github.droidkaigi.confsched.testing.robot.CropImageScreenRobot | ||
import io.github.droidkaigi.confsched.testing.robot.runRobot | ||
import io.github.droidkaigi.confsched.testing.rules.RobotTestRule | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.robolectric.ParameterizedRobolectricTestRunner | ||
import javax.inject.Inject | ||
|
||
@RunWith(ParameterizedRobolectricTestRunner::class) | ||
@HiltAndroidTest | ||
class CropImageScreenTest( | ||
private val testCase: DescribedBehavior<CropImageScreenRobot>, | ||
) { | ||
|
||
@get:Rule | ||
@BindValue | ||
val robotTestRule: RobotTestRule = RobotTestRule(testInstance = this) | ||
|
||
@Inject | ||
lateinit var cropImageScreenRobot: CropImageScreenRobot | ||
|
||
@Test | ||
fun runTest() { | ||
runRobot(cropImageScreenRobot) { | ||
testCase.execute(cropImageScreenRobot) | ||
} | ||
} | ||
|
||
companion object { | ||
@JvmStatic | ||
@ParameterizedRobolectricTestRunner.Parameters(name = "{0}") | ||
fun behaviors(): List<DescribedBehavior<CropImageScreenRobot>> { | ||
return describeBehaviors(name = "CropImageScreen") { | ||
describe("when launch") { | ||
doIt { | ||
setupScreenContent() | ||
} | ||
itShould("show screen") { | ||
captureScreenWithChecks { | ||
checkScreenDisplayed() | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
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