Merge "Make DialogLaunchAnimator.showFromDialog more lenient" into tm-qpr-dev

This commit is contained in:
Jordan Demeulenaere
2023-02-07 09:30:18 +00:00
committed by Android (Google) Code Review
2 changed files with 16 additions and 4 deletions

View File

@@ -304,10 +304,16 @@ constructor(
) {
val view =
openedDialogs.firstOrNull { it.dialog == animateFrom }?.dialogContentWithBackground
?: throw IllegalStateException(
"The animateFrom dialog was not animated using " +
"DialogLaunchAnimator.showFrom(View|Dialog)"
)
if (view == null) {
Log.w(
TAG,
"Showing dialog $dialog normally as the dialog it is shown from was not shown " +
"using DialogLaunchAnimator"
)
dialog.show()
return
}
showFromView(
dialog,
view,

View File

@@ -268,6 +268,12 @@ class DialogLaunchAnimatorTest : SysuiTestCase() {
}
}
@Test
fun showFromDialogDoesNotCrashWhenShownFromRandomDialog() {
val dialog = createDialogAndShowFromDialog(animateFrom = TestDialog(context))
dialog.dismiss()
}
private fun createAndShowDialog(
animator: DialogLaunchAnimator = dialogLaunchAnimator,
): TestDialog {