pedrovgs / Shot

Screenshot testing library for Android
Apache License 2.0
1.18k stars 115 forks source link

Removing the Toolbar shadow (elevation) #328

Open ivannarino opened 1 year ago

ivannarino commented 1 year ago

Expected behaviour

When doing screenshots of composables, the screenshot should not have display the shadow of the Toolbar

Actual behaviour

When doing screenshots of composables there is gradient (shadow) at the top of the image.

image

Steps to reproduce

@get:org.junit.Rule
val composeRule = androidx.compose.ui.test.junit4.createComposeRule()

@org.junit.Test
fun testContent() {
    composeRule.setContent { $PREVIEW_NAME$() }
    compareScreenshot(composeRule)
}

Version of the library

5.14.1

Using emulator with Android 32

ivannarino commented 1 year ago

The workaround I found is to remove the Toolbar setting a theme to the test application via the src/androidTest/AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

    <application android:theme="@android:style/Theme.Material.Light.NoActionBar" />
</manifest>