Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If provide RoborazziRule.CaptureType.Gif to the RoborazziRule then verifyRoborazziDebug doesn't fails #465

Open
september669 opened this issue Aug 12, 2024 · 3 comments

Comments

@september669
Copy link

september669 commented Aug 12, 2024

I'm trying the example from the Readme and noticed that if I provide RoborazziRule.CaptureType.Gif() to the RoborazziRule then verifyRoborazziDebug task doesn't fail if any changes were applied to the UI. Also RoborazziRule.CaptureType.Gif() generates gifs on recordRoborazziDebug runs, if it matters.
In case I provide RoborazziRule.CaptureType.AllImage() task works well.

import androidx.activity.ComponentActivity
import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.onRoot
import androidx.compose.ui.test.performClick
import com.github.takahirom.roborazzi.RoborazziRule
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.annotation.Config
import org.robolectric.annotation.GraphicsMode

@RunWith(RobolectricTestRunner::class)
@GraphicsMode(GraphicsMode.Mode.NATIVE)
@Config(manifest = Config.NONE)
class ComposeTest {
    @get:Rule
    val composeTestRule = createAndroidComposeRule<ComponentActivity>()

    @get:Rule
    val roborazziRule = RoborazziRule(
        composeRule = composeTestRule,
        captureRoot = composeTestRule.onRoot(),
        options = RoborazziRule.Options(
            // RoborazziRule.CaptureType.Gif() // < -- If I provide this then verifyRoborazziDebug doesn't recognize any difference in the screenshots
            RoborazziRule.CaptureType.AllImage()
        )
    )

    @Test
    fun composable() {
        composeTestRule.setContent {
            SampleComposableFunction()
        }
        repeat(3) {
            composeTestRule
                .onNodeWithTag("AddBoxButton")
                .performClick()
        }
    }
}

@Composable
fun SampleComposableFunction() {
    var count by remember { mutableIntStateOf(0) }
    Column(
        Modifier
            .size(300.dp)
    ) {
        Box(
            Modifier
                .testTag("AddBoxButton")
                .size(50.dp)
                .background(color = Color.Green)
                .clickable {
                    count++
                }
        )
        repeat(count) {
            Spacer(modifier = Modifier.height(1.dp))
            Box(
                Modifier
                    .background(color = Color.Black)
                    .size(30.dp)
            )
        }
    }
}
@takahirom
Copy link
Owner

Thank you for reporting this. Yes, we currently don't have a way to compare the GIFs. This would be a significant feature, as it would involve comparing frame counts, images, or other aspects. However, I'm not sure if this feature would be used frequently.

@september669
Copy link
Author

Thanks for the clarification and for your lib!
But it's quite strange to see a non-working example in the Readme.
Maybe add some notes about it to the Readme?

@takahirom
Copy link
Owner

Thank you. I agree. The GIF feature was created at a very early stage of the library development, so the comparison feature did not exist at that time. It should be noted that we do not currently support comparison for GIFs. Thank you for your feedback.

@takahirom takahirom reopened this Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants