Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 61d27419 authored by Jordan Demeulenaere's avatar Jordan Demeulenaere
Browse files

Small improvements to dialogScreenshotTest {}

This CL disables the enter/exit animations of the dialog about to be
screenshot tested, and ensures that the dialog is dismissed at the end
of the test.

Test: atest SystemUIGoogleScreenshotTests
Bug: 230832101
Change-Id: I30e26411042bc42181cab38ec706b8ed2a2808f7
parent df74b6dd
Loading
Loading
Loading
Loading
+13 −3
Original line number Diff line number Diff line
@@ -60,11 +60,17 @@ class ViewScreenshotTestRule(testSpec: ScreenshotTestSpec) : TestRule {
    ) {
        var dialog: Dialog? = null
        activityRule.scenario.onActivity { activity ->
            // Make sure that the dialog draws full screen and fits the whole display instead of the
            // system bars.
            dialog =
                dialogProvider(activity).apply {
                    // Make sure that the dialog draws full screen and fits the whole display
                    // instead of the system bars.
                    window.setDecorFitsSystemWindows(false)

                    // Disable enter/exit animations.
                    create()
                    window.setWindowAnimations(0)

                    // Show the dialog.
                    show()
                }
        }
@@ -74,7 +80,11 @@ class ViewScreenshotTestRule(testSpec: ScreenshotTestSpec) : TestRule {
        activityRule.scenario.onActivity {
            // Check that the content is what we expected.
            val dialog = dialog ?: error("dialog is null")
            try {
                screenshotRule.screenshotTest(goldenIdentifier, dialog.window.decorView)
            } finally {
                dialog.dismiss()
            }
        }
    }
}