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

Commit ab3d4836 authored by Caitlin Shkuratov's avatar Caitlin Shkuratov
Browse files

[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
parent e8c68566
Loading
Loading
Loading
Loading
+16 −22
Original line number Diff line number Diff line
@@ -175,8 +175,6 @@ 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(
@@ -186,7 +184,6 @@ class CastToOtherDeviceChipViewModelTest : SysuiTestCase() {
                    ArgumentMatchers.anyBoolean(),
                )
        }
        }

    @Test
    fun chip_singleTask_clickListenerShowsCastDialog() =
@@ -201,8 +198,6 @@ 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(
@@ -213,4 +208,3 @@ class CastToOtherDeviceChipViewModelTest : SysuiTestCase() {
                )
        }
}
}
+27 −36
Original line number Diff line number Diff line
@@ -138,8 +138,6 @@ 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)
@@ -150,7 +148,6 @@ class ScreenRecordChipViewModelTest : SysuiTestCase() {
                    ArgumentMatchers.anyBoolean(),
                )
        }
        }

    @Test
    fun chip_projectingEntireScreen_clickListenerShowsDialog() =
@@ -162,8 +159,6 @@ 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)
@@ -174,7 +169,6 @@ class ScreenRecordChipViewModelTest : SysuiTestCase() {
                    ArgumentMatchers.anyBoolean(),
                )
        }
        }

    @Test
    fun chip_projectingSingleTask_clickListenerShowsDialog() =
@@ -189,8 +183,6 @@ 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)
@@ -202,4 +194,3 @@ class ScreenRecordChipViewModelTest : SysuiTestCase() {
                )
        }
}
}
+16 −22
Original line number Diff line number Diff line
@@ -178,8 +178,6 @@ 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(
@@ -189,7 +187,6 @@ class ShareToAppChipViewModelTest : SysuiTestCase() {
                    ArgumentMatchers.anyBoolean(),
                )
        }
        }

    @Test
    fun chip_singleTask_clickListenerShowsShareDialog() =
@@ -203,8 +200,6 @@ 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(
@@ -215,4 +210,3 @@ class ShareToAppChipViewModelTest : SysuiTestCase() {
                )
        }
}
}