diff --git a/core/model/src/commonMain/kotlin/io/github/droidkaigi/confsched2023/model/AchievementAnimation.kt b/core/model/src/commonMain/kotlin/io/github/droidkaigi/confsched2023/model/AchievementAnimation.kt index e45775b1e..8fb5a00d9 100644 --- a/core/model/src/commonMain/kotlin/io/github/droidkaigi/confsched2023/model/AchievementAnimation.kt +++ b/core/model/src/commonMain/kotlin/io/github/droidkaigi/confsched2023/model/AchievementAnimation.kt @@ -6,6 +6,7 @@ data class AchievementAnimation( val notHasDrawableResId: Int, val hasAchievement: Boolean = false, val contentDescription: String, + val testTag: String, ) { fun getDrawableResId() = if (hasAchievement) hasDrawableResId else notHasDrawableResId } diff --git a/core/testing/src/main/java/io/github/droidkaigi/confsched2023/testing/LottieTestRule.kt b/core/testing/src/main/java/io/github/droidkaigi/confsched2023/testing/LottieTestRule.kt new file mode 100644 index 000000000..058d58046 --- /dev/null +++ b/core/testing/src/main/java/io/github/droidkaigi/confsched2023/testing/LottieTestRule.kt @@ -0,0 +1,19 @@ +package io.github.droidkaigi.confsched2023.testing + +import com.airbnb.lottie.LottieTask +import org.junit.rules.TestWatcher +import org.junit.runner.Description +import java.util.concurrent.Executor +import java.util.concurrent.Executors + +class LottieTestRule : TestWatcher() { + private val defaultExecutor = Executors.newCachedThreadPool() + + override fun starting(description: Description) { + LottieTask.EXECUTOR = Executor(Runnable::run) + } + + override fun finished(description: Description) { + LottieTask.EXECUTOR = defaultExecutor + } +} diff --git a/core/testing/src/main/java/io/github/droidkaigi/confsched2023/testing/RobotTestRule.kt b/core/testing/src/main/java/io/github/droidkaigi/confsched2023/testing/RobotTestRule.kt index 9ef4ca353..18410b299 100644 --- a/core/testing/src/main/java/io/github/droidkaigi/confsched2023/testing/RobotTestRule.kt +++ b/core/testing/src/main/java/io/github/droidkaigi/confsched2023/testing/RobotTestRule.kt @@ -61,6 +61,7 @@ class RobotTestRule( .outerRule(HiltAndroidAutoInjectRule(testInstance)) .around(CoroutinesTestRule()) .around(TimeZoneTestRule()) + .around(LottieTestRule()) .around(object : TestWatcher() { override fun starting(description: Description) { // To see logs in the console diff --git a/core/testing/src/main/java/io/github/droidkaigi/confsched2023/testing/robot/AchievementsScreenRobot.kt b/core/testing/src/main/java/io/github/droidkaigi/confsched2023/testing/robot/AchievementsScreenRobot.kt index a5cdc2512..609533d98 100644 --- a/core/testing/src/main/java/io/github/droidkaigi/confsched2023/testing/robot/AchievementsScreenRobot.kt +++ b/core/testing/src/main/java/io/github/droidkaigi/confsched2023/testing/robot/AchievementsScreenRobot.kt @@ -1,16 +1,26 @@ 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.onFirst +import androidx.compose.ui.test.performClick import androidx.compose.ui.test.performTouchInput import androidx.compose.ui.test.swipeUp import com.github.takahirom.roborazzi.captureRoboImage import io.github.droidkaigi.confsched2023.achievements.AchievementsScreen +import io.github.droidkaigi.confsched2023.achievements.component.AchievementImageATestTag +import io.github.droidkaigi.confsched2023.achievements.component.AchievementImageBTestTag +import io.github.droidkaigi.confsched2023.achievements.component.AchievementImageCTestTag +import io.github.droidkaigi.confsched2023.achievements.component.AchievementImageDTestTag +import io.github.droidkaigi.confsched2023.achievements.component.AchievementImageETestTag +import io.github.droidkaigi.confsched2023.data.achievements.AchievementsDataStore import io.github.droidkaigi.confsched2023.designsystem.theme.KaigiTheme +import io.github.droidkaigi.confsched2023.model.Achievement import io.github.droidkaigi.confsched2023.testing.RobotTestRule import io.github.droidkaigi.confsched2023.testing.coroutines.runTestWithLogging import kotlinx.coroutines.test.TestDispatcher +import kotlinx.coroutines.test.runTest import javax.inject.Inject import kotlin.time.Duration.Companion.seconds @@ -19,6 +29,9 @@ class AchievementsScreenRobot @Inject constructor( ) { @Inject lateinit var robotTestRule: RobotTestRule private lateinit var composeTestRule: AndroidComposeTestRule<*, *> + + @Inject lateinit var achievementsDataStore: AchievementsDataStore + operator fun invoke( block: AchievementsScreenRobot.() -> Unit, ) { @@ -49,6 +62,35 @@ class AchievementsScreenRobot @Inject constructor( } } + fun setupSavedAchievement(achievement: Achievement) = runTest(testDispatcher) { + achievementsDataStore.saveAchievements(achievement) + } + + fun clickAchievementImageA() { + composeTestRule.onNode(hasTestTag(AchievementImageATestTag)) + .performClick() + } + + fun clickAchievementImageB() { + composeTestRule.onNode(hasTestTag(AchievementImageBTestTag)) + .performClick() + } + + fun clickAchievementImageC() { + composeTestRule.onNode(hasTestTag(AchievementImageCTestTag)) + .performClick() + } + + fun clickAchievementImageD() { + composeTestRule.onNode(hasTestTag(AchievementImageDTestTag)) + .performClick() + } + + fun clickAchievementImageE() { + composeTestRule.onNode(hasTestTag(AchievementImageETestTag)) + .performClick() + } + fun checkScreenCapture() { composeTestRule .onAllNodes(isRoot()) diff --git a/feature/achievements/src/main/java/io/github/droidkaigi/confsched2023/achievements/AchievementsScreen.kt b/feature/achievements/src/main/java/io/github/droidkaigi/confsched2023/achievements/AchievementsScreen.kt index 8489b00c8..b1d2341df 100644 --- a/feature/achievements/src/main/java/io/github/droidkaigi/confsched2023/achievements/AchievementsScreen.kt +++ b/feature/achievements/src/main/java/io/github/droidkaigi/confsched2023/achievements/AchievementsScreen.kt @@ -1,12 +1,14 @@ package io.github.droidkaigi.confsched2023.achievements import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.WindowInsets import androidx.compose.foundation.layout.calculateEndPadding import androidx.compose.foundation.layout.calculateStartPadding +import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.width import androidx.compose.foundation.rememberScrollState @@ -16,8 +18,10 @@ import androidx.compose.material3.MaterialTheme import androidx.compose.material3.Scaffold import androidx.compose.material3.SnackbarHost import androidx.compose.material3.SnackbarHostState +import androidx.compose.material3.Surface import androidx.compose.material3.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue import androidx.compose.runtime.remember @@ -31,8 +35,11 @@ import androidx.navigation.NavController import androidx.navigation.NavGraph.Companion.findStartDestination import androidx.navigation.NavGraphBuilder import androidx.navigation.compose.composable +import io.github.droidkaigi.confsched2023.achievements.AchievementAnimationState.Animating +import io.github.droidkaigi.confsched2023.achievements.component.AchievementHighlightAnimation import io.github.droidkaigi.confsched2023.achievements.section.AchievementList import io.github.droidkaigi.confsched2023.achievements.section.AchievementListUiState +import io.github.droidkaigi.confsched2023.model.Achievement import io.github.droidkaigi.confsched2023.ui.SnackbarMessageEffect const val achievementsScreenRoute = "achievements" @@ -83,6 +90,8 @@ fun AchievementsScreen( snackbarHostState = snackbarHostState, contentPadding = contentPadding, onReset = viewModel::onReset, + onAchievementClick = { achievement -> viewModel.onAchievementClick(achievement) }, + onAnimationFinish = viewModel::onAnimationFinish, onDisplayedInitialDialog = viewModel::onDisplayedInitialDialog, ) } @@ -90,44 +99,76 @@ fun AchievementsScreen( data class AchievementsScreenUiState( val achievementListUiState: AchievementListUiState, val isShowInitialDialog: Boolean, + val achievementAnimationState: AchievementAnimationState, ) +sealed interface AchievementAnimationState { + data class Animating( + val achievement: Achievement, + val animationRawId: Int, + ) : AchievementAnimationState + data object NotAnimating : AchievementAnimationState +} + @Composable private fun AchievementsScreen( uiState: AchievementsScreenUiState, snackbarHostState: SnackbarHostState, contentPadding: PaddingValues, onReset: () -> Unit, + onAchievementClick: (Achievement) -> Unit, + onAnimationFinish: () -> Unit, onDisplayedInitialDialog: () -> Unit, ) { val layoutDirection = LocalLayoutDirection.current - Scaffold( - modifier = Modifier.testTag(AchievementsScreenTestTag), - snackbarHost = { SnackbarHost(snackbarHostState) }, - contentWindowInsets = WindowInsets( - left = contentPadding.calculateLeftPadding(layoutDirection), - top = contentPadding.calculateTopPadding(), - right = contentPadding.calculateRightPadding(layoutDirection), - bottom = contentPadding.calculateBottomPadding(), - ), - content = { innerPadding -> - if (uiState.isShowInitialDialog) { - AchievementScreenDialog( - onDismissRequest = onDisplayedInitialDialog, + Box { + Scaffold( + modifier = Modifier.testTag(AchievementsScreenTestTag), + snackbarHost = { SnackbarHost(snackbarHostState) }, + contentWindowInsets = WindowInsets( + left = contentPadding.calculateLeftPadding(layoutDirection), + top = contentPadding.calculateTopPadding(), + right = contentPadding.calculateRightPadding(layoutDirection), + bottom = contentPadding.calculateBottomPadding(), + ), + content = { innerPadding -> + if (uiState.isShowInitialDialog) { + AchievementScreenDialog( + onDismissRequest = onDisplayedInitialDialog, + ) + } + AchievementList( + uiState = uiState.achievementListUiState, + contentPadding = innerPadding, + onReset = onReset, + onAchievementClick = onAchievementClick, + modifier = Modifier.padding( + top = innerPadding.calculateTopPadding(), + start = innerPadding.calculateStartPadding(layoutDirection), + end = innerPadding.calculateEndPadding(layoutDirection), + ), ) + }, + ) + if (uiState.achievementAnimationState is Animating) { + DisposableEffect(uiState.achievementAnimationState) { + onDispose { + onAnimationFinish() + } } - AchievementList( - uiState = uiState.achievementListUiState, - contentPadding = innerPadding, - onReset = onReset, - modifier = Modifier.padding( - top = innerPadding.calculateTopPadding(), - start = innerPadding.calculateStartPadding(layoutDirection), - end = innerPadding.calculateEndPadding(layoutDirection), - ), - ) - }, - ) + Surface( + modifier = Modifier.fillMaxSize(), + color = MaterialTheme.colorScheme.background.copy(alpha = 0.6F), + ) { + AchievementHighlightAnimation( + animationRawId = uiState.achievementAnimationState.animationRawId, + onAnimationFinish = { + onAnimationFinish() + }, + ) + } + } + } } @Composable diff --git a/feature/achievements/src/main/java/io/github/droidkaigi/confsched2023/achievements/AchievementsScreenViewModel.kt b/feature/achievements/src/main/java/io/github/droidkaigi/confsched2023/achievements/AchievementsScreenViewModel.kt index d73759add..b7424dc21 100644 --- a/feature/achievements/src/main/java/io/github/droidkaigi/confsched2023/achievements/AchievementsScreenViewModel.kt +++ b/feature/achievements/src/main/java/io/github/droidkaigi/confsched2023/achievements/AchievementsScreenViewModel.kt @@ -3,6 +3,11 @@ package io.github.droidkaigi.confsched2023.achievements import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import dagger.hilt.android.lifecycle.HiltViewModel +import io.github.droidkaigi.confsched2023.achievements.component.AchievementImageATestTag +import io.github.droidkaigi.confsched2023.achievements.component.AchievementImageBTestTag +import io.github.droidkaigi.confsched2023.achievements.component.AchievementImageCTestTag +import io.github.droidkaigi.confsched2023.achievements.component.AchievementImageDTestTag +import io.github.droidkaigi.confsched2023.achievements.component.AchievementImageETestTag import io.github.droidkaigi.confsched2023.achievements.section.AchievementListUiState import io.github.droidkaigi.confsched2023.data.contributors.AchievementRepository import io.github.droidkaigi.confsched2023.designsystem.strings.AppStrings @@ -15,6 +20,7 @@ import io.github.droidkaigi.confsched2023.ui.handleErrorAndRetry import kotlinx.collections.immutable.PersistentSet import kotlinx.collections.immutable.persistentListOf import kotlinx.collections.immutable.persistentSetOf +import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.SharingStarted import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.stateIn @@ -85,6 +91,7 @@ class AchievementsScreenViewModel @Inject constructor( notHasDrawableResId = R.drawable.img_achievement_a_off, hasAchievement = achievements.contains(Achievement.ArcticFox), contentDescription = "AchievementA image", + testTag = AchievementImageATestTag, ), AchievementAnimation( achievement = Achievement.Bumblebee, @@ -92,6 +99,7 @@ class AchievementsScreenViewModel @Inject constructor( notHasDrawableResId = R.drawable.img_achievement_b_off, hasAchievement = achievements.contains(Achievement.Bumblebee), contentDescription = "AchievementB image", + testTag = AchievementImageBTestTag, ), AchievementAnimation( achievement = Achievement.Chipmunk, @@ -99,6 +107,7 @@ class AchievementsScreenViewModel @Inject constructor( notHasDrawableResId = R.drawable.img_achievement_c_off, hasAchievement = achievements.contains(Achievement.Chipmunk), contentDescription = "AchievementC image", + testTag = AchievementImageCTestTag, ), AchievementAnimation( achievement = Achievement.Dolphin, @@ -106,6 +115,7 @@ class AchievementsScreenViewModel @Inject constructor( notHasDrawableResId = R.drawable.img_achievement_d_off, hasAchievement = achievements.contains(Achievement.Dolphin), contentDescription = "AchievementD image", + testTag = AchievementImageDTestTag, ), AchievementAnimation( achievement = Achievement.ElectricEel, @@ -113,6 +123,7 @@ class AchievementsScreenViewModel @Inject constructor( notHasDrawableResId = R.drawable.img_achievement_e_off, hasAchievement = achievements.contains(Achievement.ElectricEel), contentDescription = "AchievementE image", + testTag = AchievementImageETestTag, ), ), detailDescription = detailDescription, @@ -120,13 +131,18 @@ class AchievementsScreenViewModel @Inject constructor( ) } + private val achievementAnimationState = + MutableStateFlow(AchievementAnimationState.NotAnimating) + val uiState = buildUiState( achievementAnimationListState, isInitialDialogDisplayFlow, - ) { achievementListUiState, isDisplayedInitialDialog -> + achievementAnimationState, + ) { achievementListUiState, isDisplayedInitialDialog, achievementAnimationState -> AchievementsScreenUiState( achievementListUiState = achievementListUiState, isShowInitialDialog = isDisplayedInitialDialog?.not() ?: false, + achievementAnimationState = achievementAnimationState, ) } @@ -141,4 +157,22 @@ class AchievementsScreenViewModel @Inject constructor( achievementRepository.displayedInitialDialog() } } + + fun onAchievementClick(clickedAchievement: Achievement) { + val animationRawId: Int = when (clickedAchievement) { + Achievement.ArcticFox -> R.raw.achievement_a_lottie + Achievement.Bumblebee -> R.raw.achievement_b_lottie + Achievement.Chipmunk -> R.raw.achievement_c_lottie + Achievement.Dolphin -> R.raw.achievement_d_lottie + Achievement.ElectricEel -> R.raw.achievement_e_lottie + } + this.achievementAnimationState.value = AchievementAnimationState.Animating( + achievement = clickedAchievement, + animationRawId = animationRawId, + ) + } + + fun onAnimationFinish() { + this.achievementAnimationState.value = AchievementAnimationState.NotAnimating + } } diff --git a/feature/achievements/src/main/java/io/github/droidkaigi/confsched2023/achievements/animation/AchievementAnimationScreen.kt b/feature/achievements/src/main/java/io/github/droidkaigi/confsched2023/achievements/animation/AchievementAnimationScreen.kt index 7c8eb73d9..40898553c 100644 --- a/feature/achievements/src/main/java/io/github/droidkaigi/confsched2023/achievements/animation/AchievementAnimationScreen.kt +++ b/feature/achievements/src/main/java/io/github/droidkaigi/confsched2023/achievements/animation/AchievementAnimationScreen.kt @@ -10,10 +10,7 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.hilt.navigation.compose.hiltViewModel -import com.airbnb.lottie.compose.LottieAnimation -import com.airbnb.lottie.compose.LottieCompositionSpec.RawRes -import com.airbnb.lottie.compose.animateLottieCompositionAsState -import com.airbnb.lottie.compose.rememberLottieComposition +import io.github.droidkaigi.confsched2023.achievements.component.AchievementHighlightAnimation import io.github.droidkaigi.confsched2023.ui.SnackbarMessageEffect data class AnimationScreenUiState( @@ -59,19 +56,12 @@ fun AchievementAnimationScreen( .fillMaxSize(), ) { if (uiState.rawId != null) { - val lottieComposition by rememberLottieComposition(RawRes(uiState.rawId)) - val progress by animateLottieCompositionAsState( - composition = lottieComposition, - isPlaying = true, - restartOnPlay = true, - ) - if (progress == 1f) { - onReachAnimationEnd() - onFinished() - } - LottieAnimation( - composition = lottieComposition, - progress = { progress }, + AchievementHighlightAnimation( + animationRawId = uiState.rawId, + onAnimationFinish = { + onReachAnimationEnd() + onFinished() + }, ) } } diff --git a/feature/achievements/src/main/java/io/github/droidkaigi/confsched2023/achievements/component/AchievementHighlightAnimation.kt b/feature/achievements/src/main/java/io/github/droidkaigi/confsched2023/achievements/component/AchievementHighlightAnimation.kt new file mode 100644 index 000000000..4d9a8dcba --- /dev/null +++ b/feature/achievements/src/main/java/io/github/droidkaigi/confsched2023/achievements/component/AchievementHighlightAnimation.kt @@ -0,0 +1,29 @@ +package io.github.droidkaigi.confsched2023.achievements.component + +import androidx.compose.runtime.Composable +import androidx.compose.runtime.getValue +import com.airbnb.lottie.compose.LottieAnimation +import com.airbnb.lottie.compose.LottieCompositionSpec.RawRes +import com.airbnb.lottie.compose.animateLottieCompositionAsState +import com.airbnb.lottie.compose.rememberLottieComposition +import io.github.droidkaigi.confsched2023.ui.isTest + +@Composable +fun AchievementHighlightAnimation( + animationRawId: Int, + onAnimationFinish: () -> Unit, +) { + val lottieComposition by rememberLottieComposition(RawRes(animationRawId)) + val progress by animateLottieCompositionAsState( + composition = lottieComposition, + isPlaying = true, + restartOnPlay = true, + ) + if (progress == 1f && !isTest()) { + onAnimationFinish() + } + LottieAnimation( + composition = lottieComposition, + progress = { progress }, + ) +} diff --git a/feature/achievements/src/main/java/io/github/droidkaigi/confsched2023/achievements/component/AchievementImage.kt b/feature/achievements/src/main/java/io/github/droidkaigi/confsched2023/achievements/component/AchievementImage.kt index daf81996c..6af63f003 100644 --- a/feature/achievements/src/main/java/io/github/droidkaigi/confsched2023/achievements/component/AchievementImage.kt +++ b/feature/achievements/src/main/java/io/github/droidkaigi/confsched2023/achievements/component/AchievementImage.kt @@ -1,25 +1,52 @@ package io.github.droidkaigi.confsched2023.achievements.component import androidx.compose.foundation.Image +import androidx.compose.foundation.clickable +import androidx.compose.foundation.interaction.MutableInteractionSource import androidx.compose.foundation.layout.size import androidx.compose.runtime.Composable +import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalConfiguration +import androidx.compose.ui.platform.testTag import androidx.compose.ui.res.painterResource import androidx.compose.ui.unit.dp +import io.github.droidkaigi.confsched2023.model.Achievement import io.github.droidkaigi.confsched2023.model.AchievementAnimation +const val AchievementImageATestTag = "AchievementImageATestTag" +const val AchievementImageBTestTag = "AchievementImageBTestTag" +const val AchievementImageCTestTag = "AchievementImageCTestTag" +const val AchievementImageDTestTag = "AchievementImageDTestTag" +const val AchievementImageETestTag = "AchievementImageETestTag" + @Composable fun AchievementImage( achievementAnimation: AchievementAnimation, modifier: Modifier = Modifier, + onAchievementClick: (Achievement) -> Unit, ) { + val interactionSource = remember { MutableInteractionSource() } val configuration = LocalConfiguration.current val screenWidth = configuration.screenWidthDp.dp Image( painter = painterResource(id = achievementAnimation.getDrawableResId()), contentDescription = achievementAnimation.contentDescription, - modifier = modifier.size(screenWidth / 3), + modifier = modifier + .size(screenWidth / 3) + .testTag(achievementAnimation.testTag) + .then( + if (achievementAnimation.hasAchievement) { + Modifier.clickable( + interactionSource = interactionSource, + indication = null, + ) { + onAchievementClick(achievementAnimation.achievement) + } + } else { + Modifier + }, + ), ) } diff --git a/feature/achievements/src/main/java/io/github/droidkaigi/confsched2023/achievements/section/AchievementList.kt b/feature/achievements/src/main/java/io/github/droidkaigi/confsched2023/achievements/section/AchievementList.kt index ccb367325..d41d4ee6a 100644 --- a/feature/achievements/src/main/java/io/github/droidkaigi/confsched2023/achievements/section/AchievementList.kt +++ b/feature/achievements/src/main/java/io/github/droidkaigi/confsched2023/achievements/section/AchievementList.kt @@ -19,6 +19,7 @@ import androidx.compose.ui.platform.LocalLayoutDirection import androidx.compose.ui.unit.dp import io.github.droidkaigi.confsched2023.achievements.component.AchievementImage import io.github.droidkaigi.confsched2023.achievements.component.AchievementsDetail +import io.github.droidkaigi.confsched2023.model.Achievement import io.github.droidkaigi.confsched2023.model.AchievementAnimation import kotlinx.collections.immutable.ImmutableList @@ -37,6 +38,7 @@ fun AchievementList( uiState: AchievementListUiState, contentPadding: PaddingValues, onReset: () -> Unit, + onAchievementClick: (Achievement) -> Unit, modifier: Modifier = Modifier, ) { val layoutDirection = LocalLayoutDirection.current @@ -77,6 +79,7 @@ fun AchievementList( ) { achievementAnimation -> AchievementImage( achievementAnimation = achievementAnimation, + onAchievementClick = onAchievementClick, ) } if (uiState.isResetButtonEnabled) { diff --git a/feature/achievements/src/test/java/io/github/droidkaigi/confsched2023/achievements/AchievementsScreenTest.kt b/feature/achievements/src/test/java/io/github/droidkaigi/confsched2023/achievements/AchievementsScreenTest.kt index 92f1af66e..0697dc0f3 100644 --- a/feature/achievements/src/test/java/io/github/droidkaigi/confsched2023/achievements/AchievementsScreenTest.kt +++ b/feature/achievements/src/test/java/io/github/droidkaigi/confsched2023/achievements/AchievementsScreenTest.kt @@ -4,6 +4,11 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import com.github.takahirom.roborazzi.RobolectricDeviceQualifiers import dagger.hilt.android.testing.BindValue import dagger.hilt.android.testing.HiltAndroidTest +import io.github.droidkaigi.confsched2023.model.Achievement.ArcticFox +import io.github.droidkaigi.confsched2023.model.Achievement.Bumblebee +import io.github.droidkaigi.confsched2023.model.Achievement.Chipmunk +import io.github.droidkaigi.confsched2023.model.Achievement.Dolphin +import io.github.droidkaigi.confsched2023.model.Achievement.ElectricEel import io.github.droidkaigi.confsched2023.testing.HiltTestActivity import io.github.droidkaigi.confsched2023.testing.RobotTestRule import io.github.droidkaigi.confsched2023.testing.category.ScreenshotTests @@ -40,4 +45,59 @@ class AchievementsScreenTest { checkScreenCapture() } } + + @Test + @Category(ScreenshotTests::class) + fun checkHighlightImageA() { + achievementsScreenRobot { + setupSavedAchievement(ArcticFox) + setupScreenContent() + clickAchievementImageA() + checkScreenCapture() + } + } + + @Test + @Category(ScreenshotTests::class) + fun checkHighlightImageB() { + achievementsScreenRobot { + setupSavedAchievement(Bumblebee) + setupScreenContent() + clickAchievementImageB() + checkScreenCapture() + } + } + + @Test + @Category(ScreenshotTests::class) + fun checkHighlightImageC() { + achievementsScreenRobot { + setupSavedAchievement(Chipmunk) + setupScreenContent() + clickAchievementImageC() + checkScreenCapture() + } + } + + @Test + @Category(ScreenshotTests::class) + fun checkHighlightImageD() { + achievementsScreenRobot { + setupSavedAchievement(Dolphin) + setupScreenContent() + clickAchievementImageD() + checkScreenCapture() + } + } + + @Test + @Category(ScreenshotTests::class) + fun checkHighlightImageE() { + achievementsScreenRobot { + setupSavedAchievement(ElectricEel) + setupScreenContent() + clickAchievementImageE() + checkScreenCapture() + } + } }