Small improvements to dialogScreenshotTest {} am: 61d27419aa
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19134647 Change-Id: I1a9f7e074ec36ff9f55cbacbadc6fe67b6a32d70 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
committed by
Automerger Merge Worker
commit
73053860e2
@@ -60,11 +60,17 @@ class ViewScreenshotTestRule(testSpec: ScreenshotTestSpec) : TestRule {
|
|||||||
) {
|
) {
|
||||||
var dialog: Dialog? = null
|
var dialog: Dialog? = null
|
||||||
activityRule.scenario.onActivity { activity ->
|
activityRule.scenario.onActivity { activity ->
|
||||||
// Make sure that the dialog draws full screen and fits the whole display instead of the
|
|
||||||
// system bars.
|
|
||||||
dialog =
|
dialog =
|
||||||
dialogProvider(activity).apply {
|
dialogProvider(activity).apply {
|
||||||
|
// Make sure that the dialog draws full screen and fits the whole display
|
||||||
|
// instead of the system bars.
|
||||||
window.setDecorFitsSystemWindows(false)
|
window.setDecorFitsSystemWindows(false)
|
||||||
|
|
||||||
|
// Disable enter/exit animations.
|
||||||
|
create()
|
||||||
|
window.setWindowAnimations(0)
|
||||||
|
|
||||||
|
// Show the dialog.
|
||||||
show()
|
show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -74,7 +80,11 @@ class ViewScreenshotTestRule(testSpec: ScreenshotTestSpec) : TestRule {
|
|||||||
activityRule.scenario.onActivity {
|
activityRule.scenario.onActivity {
|
||||||
// Check that the content is what we expected.
|
// Check that the content is what we expected.
|
||||||
val dialog = dialog ?: error("dialog is null")
|
val dialog = dialog ?: error("dialog is null")
|
||||||
|
try {
|
||||||
screenshotRule.screenshotTest(goldenIdentifier, dialog.window.decorView)
|
screenshotRule.screenshotTest(goldenIdentifier, dialog.window.decorView)
|
||||||
|
} finally {
|
||||||
|
dialog.dismiss()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user