diff options
| author | 2024-06-13 22:02:50 +0000 | |
|---|---|---|
| committer | 2024-06-13 22:06:46 +0000 | |
| commit | ab3d4836831ef5ab6dba724ac7af0afc41d8f0af (patch) | |
| tree | 22452a7ed27f177d57a5fd06026a535d66c572ba | |
| parent | e8c685669989f37f1416cd09d288b992ae32e850 (diff) | |
[SB][Screen Chips] Remove context.mainExecutor from tests.
I had originally added `context.mainExecutor` because I was trying to
use a real version of `DialogTransitionAnimator`, which seemed to need
that to work correctly (based on `DialogTransitionAnimatorTest`). But,
it turns out that `context.mainExecutor` makes the mock live beyond the
lifetime of the test. Once a test is done, we clear out all our mocks to
have nulls everywhere, which means that subsequent tests will see null
values when they shouldn't.
Since I'm now using a mock version of `DialogTransitionAnimator`, we
don't need these calls anyway so this CL removes them.
Fixes: 346932645
Test: atest CastToOtherDeviceChipViewModelTest
ScreenRecordChipViewModelTest ShareToAppChipViewModelTest
Flag: NONE Fixing tests
Change-Id: I248867da9856007d7539c0654e86321d4ac240a1
3 files changed, 59 insertions, 80 deletions
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/casttootherdevice/ui/viewmodel/CastToOtherDeviceChipViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/casttootherdevice/ui/viewmodel/CastToOtherDeviceChipViewModelTest.kt index 142f5ab34f8c..93d781f6817e 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/casttootherdevice/ui/viewmodel/CastToOtherDeviceChipViewModelTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/casttootherdevice/ui/viewmodel/CastToOtherDeviceChipViewModelTest.kt @@ -175,17 +175,14 @@ class CastToOtherDeviceChipViewModelTest : SysuiTestCase() { val clickListener = ((latest as OngoingActivityChipModel.Shown).onClickListener) - // Dialogs must be created on the main thread - context.mainExecutor.execute { - clickListener.onClick(chipView) - verify(kosmos.mockDialogTransitionAnimator) - .showFromView( - eq(mockCastDialog), - eq(chipBackgroundView), - eq(null), - ArgumentMatchers.anyBoolean(), - ) - } + clickListener.onClick(chipView) + verify(kosmos.mockDialogTransitionAnimator) + .showFromView( + eq(mockCastDialog), + eq(chipBackgroundView), + eq(null), + ArgumentMatchers.anyBoolean(), + ) } @Test @@ -201,16 +198,13 @@ class CastToOtherDeviceChipViewModelTest : SysuiTestCase() { val clickListener = ((latest as OngoingActivityChipModel.Shown).onClickListener) - // Dialogs must be created on the main thread - context.mainExecutor.execute { - clickListener.onClick(chipView) - verify(kosmos.mockDialogTransitionAnimator) - .showFromView( - eq(mockCastDialog), - eq(chipBackgroundView), - eq(null), - ArgumentMatchers.anyBoolean(), - ) - } + clickListener.onClick(chipView) + verify(kosmos.mockDialogTransitionAnimator) + .showFromView( + eq(mockCastDialog), + eq(chipBackgroundView), + eq(null), + ArgumentMatchers.anyBoolean(), + ) } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/screenrecord/ui/viewmodel/ScreenRecordChipViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/screenrecord/ui/viewmodel/ScreenRecordChipViewModelTest.kt index 85b46ed12740..45044f74e864 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/screenrecord/ui/viewmodel/ScreenRecordChipViewModelTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/screenrecord/ui/viewmodel/ScreenRecordChipViewModelTest.kt @@ -138,18 +138,15 @@ class ScreenRecordChipViewModelTest : SysuiTestCase() { val clickListener = ((latest as OngoingActivityChipModel.Shown).onClickListener) - // Dialogs must be created on the main thread - context.mainExecutor.execute { - clickListener.onClick(chipView) - // EndScreenRecordingDialogDelegate will test that the dialog has the right message - verify(kosmos.mockDialogTransitionAnimator) - .showFromView( - eq(mockSystemUIDialog), - eq(chipBackgroundView), - eq(null), - ArgumentMatchers.anyBoolean(), - ) - } + clickListener.onClick(chipView) + // EndScreenRecordingDialogDelegate will test that the dialog has the right message + verify(kosmos.mockDialogTransitionAnimator) + .showFromView( + eq(mockSystemUIDialog), + eq(chipBackgroundView), + eq(null), + ArgumentMatchers.anyBoolean(), + ) } @Test @@ -162,18 +159,15 @@ class ScreenRecordChipViewModelTest : SysuiTestCase() { val clickListener = ((latest as OngoingActivityChipModel.Shown).onClickListener) - // Dialogs must be created on the main thread - context.mainExecutor.execute { - clickListener.onClick(chipView) - // EndScreenRecordingDialogDelegate will test that the dialog has the right message - verify(kosmos.mockDialogTransitionAnimator) - .showFromView( - eq(mockSystemUIDialog), - eq(chipBackgroundView), - eq(null), - ArgumentMatchers.anyBoolean(), - ) - } + clickListener.onClick(chipView) + // EndScreenRecordingDialogDelegate will test that the dialog has the right message + verify(kosmos.mockDialogTransitionAnimator) + .showFromView( + eq(mockSystemUIDialog), + eq(chipBackgroundView), + eq(null), + ArgumentMatchers.anyBoolean(), + ) } @Test @@ -189,17 +183,14 @@ class ScreenRecordChipViewModelTest : SysuiTestCase() { val clickListener = ((latest as OngoingActivityChipModel.Shown).onClickListener) - // Dialogs must be created on the main thread - context.mainExecutor.execute { - clickListener.onClick(chipView) - // EndScreenRecordingDialogDelegate will test that the dialog has the right message - verify(kosmos.mockDialogTransitionAnimator) - .showFromView( - eq(mockSystemUIDialog), - eq(chipBackgroundView), - eq(null), - ArgumentMatchers.anyBoolean(), - ) - } + clickListener.onClick(chipView) + // EndScreenRecordingDialogDelegate will test that the dialog has the right message + verify(kosmos.mockDialogTransitionAnimator) + .showFromView( + eq(mockSystemUIDialog), + eq(chipBackgroundView), + eq(null), + ArgumentMatchers.anyBoolean(), + ) } } diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/sharetoapp/ui/viewmodel/ShareToAppChipViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/sharetoapp/ui/viewmodel/ShareToAppChipViewModelTest.kt index 9e54d9985549..9aef526932df 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/sharetoapp/ui/viewmodel/ShareToAppChipViewModelTest.kt +++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/chips/sharetoapp/ui/viewmodel/ShareToAppChipViewModelTest.kt @@ -178,17 +178,14 @@ class ShareToAppChipViewModelTest : SysuiTestCase() { val clickListener = ((latest as OngoingActivityChipModel.Shown).onClickListener) - // Dialogs must be created on the main thread - context.mainExecutor.execute { - clickListener.onClick(chipView) - verify(kosmos.mockDialogTransitionAnimator) - .showFromView( - eq(mockShareDialog), - eq(chipBackgroundView), - eq(null), - ArgumentMatchers.anyBoolean(), - ) - } + clickListener.onClick(chipView) + verify(kosmos.mockDialogTransitionAnimator) + .showFromView( + eq(mockShareDialog), + eq(chipBackgroundView), + eq(null), + ArgumentMatchers.anyBoolean(), + ) } @Test @@ -203,16 +200,13 @@ class ShareToAppChipViewModelTest : SysuiTestCase() { val clickListener = ((latest as OngoingActivityChipModel.Shown).onClickListener) - // Dialogs must be created on the main thread - context.mainExecutor.execute { - clickListener.onClick(chipView) - verify(kosmos.mockDialogTransitionAnimator) - .showFromView( - eq(mockShareDialog), - eq(chipBackgroundView), - eq(null), - ArgumentMatchers.anyBoolean(), - ) - } + clickListener.onClick(chipView) + verify(kosmos.mockDialogTransitionAnimator) + .showFromView( + eq(mockShareDialog), + eq(chipBackgroundView), + eq(null), + ArgumentMatchers.anyBoolean(), + ) } } |