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

Screenshot doesn't render icons in MaterialButtons. Screenshots only shows button text. #275

Open
oluwasanmiAderibigbePapershift opened this issue Jan 11, 2021 · 0 comments

Comments

@oluwasanmiAderibigbePapershift
Copy link

oluwasanmiAderibigbePapershift commented Jan 11, 2021

Explanation

I'm trying to generate screenshots for a Material components button, but I noticed button icons are missing in the screenshot. The screenshots only show the button text instead of the button text and icon.

The rendered screenshot below

ScreenEdgePrimaryButton_Enabled

The screenshot is supposed to look like this.
image

Steps to reproduce

  1. I followed the steps from The style on this component requires your app theme to be Theme.MaterialComponents (or a descendant) #253 to setup screenshots-tets-for-android for material components.
  2. wrote my activity_main.xml
<com.google.android.material.button.MaterialButton
        android:id="@+id/primaryButton"
        style="@style/ScreenEdgePrimaryButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:icon="@drawable/ic_lock_filled_18"
        tools:text="Edit Password" />
  1. And finally wrote my test case
@RunWith(AndroidJUnit4::class)
class ScreenEdgePrimaryButtonTest {
    private val context: Context = InstrumentationRegistry.getInstrumentation().targetContext


    @Test
    fun designSizeVariantShouldMatchScreenshot() {
        val themedContext = ContextThemeWrapper(context, R.style.Base_DesignTheme)
        val view = ScreenEdgePrimaryButton(themedContext)

        view.setupWithState(
            ScreenEdgePrimaryButtonState(
                icon = R.drawable.ic_lock_filled_24,
                label = "Edit Password",
                onClick = { /* no-op */ }
            )
        )
        ViewHelpers.setupView(view).setExactWidthDp(180).setExactHeightDp(50).layout()
        screenshot(view, "Enabled")

        view.updateState { enabled = false }
        ViewHelpers.setupView(view).setExactWidthDp(180).setExactHeightDp(50).layout()
        screenshot(view, "Disabled")
    }
}

Did I miss something

Briefly

Everything works fine except the icons are missing when taking screenshots of the MaterialButton

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

1 participant