summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jordan Demeulenaere <jdemeulenaere@google.com> 2022-06-30 13:02:31 +0200
committer Jordan Demeulenaere <jdemeulenaere@google.com> 2022-06-30 13:22:00 +0200
commit61d27419aaddc7d09f00532a1a26b48aa1f5a3c2 (patch)
tree1999d850172d3bd3f2fb0f77bff8619408a23d55
parentdf74b6ddbcb4dbca8d81f807ed1fc21b3647d28e (diff)
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
-rw-r--r--packages/SystemUI/screenshot/src/com/android/systemui/testing/screenshot/ViewScreenshotTestRule.kt16
1 files changed, 13 insertions, 3 deletions
diff --git a/packages/SystemUI/screenshot/src/com/android/systemui/testing/screenshot/ViewScreenshotTestRule.kt b/packages/SystemUI/screenshot/src/com/android/systemui/testing/screenshot/ViewScreenshotTestRule.kt
index 35812e39677d..6a80c486d515 100644
--- a/packages/SystemUI/screenshot/src/com/android/systemui/testing/screenshot/ViewScreenshotTestRule.kt
+++ b/packages/SystemUI/screenshot/src/com/android/systemui/testing/screenshot/ViewScreenshotTestRule.kt
@@ -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")
- screenshotRule.screenshotTest(goldenIdentifier, dialog.window.decorView)
+ try {
+ screenshotRule.screenshotTest(goldenIdentifier, dialog.window.decorView)
+ } finally {
+ dialog.dismiss()
+ }
}
}
}