Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import androidx.compose.ui.test.captureToImage
import androidx.compose.ui.test.junit4.ComposeTestRule
import androidx.compose.ui.test.onRoot
import androidx.test.espresso.Espresso
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions.closeSoftKeyboard
import androidx.test.espresso.matcher.ViewMatchers.isRoot
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation
import androidx.test.runner.screenshot.Screenshot
Expand Down Expand Up @@ -68,9 +71,13 @@ public class ScreenshotsRule(
public fun compareScreenshot(
activity: Activity,
name: String? = null,
closeKeyboardFirst: Boolean = false,
) {
val view = activity.findViewById<View>(android.R.id.content)

if (closeKeyboardFirst) {
onView(isRoot()).perform(closeSoftKeyboard())
}
disableFlakyComponentsAndWaitForIdle(view)

val bitmap = Screenshot.capture(activity).bitmap
Expand Down