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

DropdownMenu not appearing in snapshots #1693

Open
corentin-stamper opened this issue Nov 15, 2024 · 1 comment
Open

DropdownMenu not appearing in snapshots #1693

corentin-stamper opened this issue Nov 15, 2024 · 1 comment
Assignees
Labels
bug Something isn't working
Milestone

Comments

@corentin-stamper
Copy link

Description
DropdownMenu not appearing in snapshots

Steps to Reproduce

package paparazzi.dropdown_menu

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.DropdownMenu
import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.unit.dp
import app.cash.paparazzi.Paparazzi
import com.google.testing.junit.testparameterinjector.TestParameterInjector
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(TestParameterInjector::class)
class DropdownMenuTest {

    @get:Rule
    val paparazzi = Paparazzi()

    @Test
    fun test() {
        paparazzi.snapshot {
            MaterialTheme {
                Column(
                    modifier = Modifier
                        .fillMaxSize()
                        .background(Color.White)
                        .padding(8.dp)
                ) {
                    Box {
                        Text(
                            text = "Label 1",
                        )

                        DropdownMenu(
                            expanded = true,
                            onDismissRequest = {},
                        ) {
                            DropdownMenuItem(
                                text = {
                                    Text(
                                        text = "Label 1",
                                    )
                                },
                                onClick = {}
                            )
                            DropdownMenuItem(
                                text = {
                                    Text(
                                        text = "Label 2",
                                    )
                                },
                                onClick = {}
                            )
                            DropdownMenuItem(
                                text = {
                                    Text(
                                        text = "Label 3",
                                    )
                                },
                                onClick = {}
                            )
                        }
                    }
                }
            }
        }
    }
}

Expected behavior
The DropdownMenu appears

Additional information:

  • Paparazzi Version: 1.3.5
  • OS:
  • Compile SDK: 35
  • Gradle Version: 8.9
  • Android Gradle Plugin Version: 8.7.2

Screenshots

Image

@corentin-stamper corentin-stamper added the bug Something isn't working label Nov 15, 2024
@geoff-powell geoff-powell self-assigned this Nov 15, 2024
@geoff-powell
Copy link
Collaborator

geoff-powell commented Nov 15, 2024

Thanks for logging this issue! I need to dig in to how LayoutLib in Android studio gets this to render but it looks like the issue is due to animation of the drop down.

Paparazzi

Used accessibility render extension to better identify the dropdown items. (video is 120 fps, 1 sec slowed to show the animation better)
Image

Android Studio

Android Studio Preview shows this with your example (I added the button for my own testing)
Image

Emulator

Image

So this is rendering mostly as expected. Since we have an issue where compose animations aren't timed correctly using offsetMillis param in paparazzi.snapshot() my suggestion would be to use paparazzi.snapshot(view, ..., offsetMillis = 5000) where 5000 is arbitrary to expected result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants