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

Commit 849aceb1 authored by David Saff's avatar David Saff Committed by Android (Google) Code Review
Browse files

Merge "Thread guard teardown to prevent crash" into main

parents 786cb576 3ad486a5
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -148,7 +148,7 @@ class TileServiceRequestControllerTestComposeOn : SysuiTestCase() {
    @Test
    fun showAllUsers_set() =
        kosmos.runTest {
            val dialog = runOnMainThreadAndWaitForIdleSync {
            val dialog = createDialog {
                underTest.requestTileAdd(
                    TEST_UID,
                    TEST_COMPONENT,
@@ -158,7 +158,6 @@ class TileServiceRequestControllerTestComposeOn : SysuiTestCase() {
                    Callback(),
                )!!
            }
            onTeardown { dialog.cancel() }

            assertThat(dialog.isShowForAllUsers).isTrue()
        }
@@ -166,7 +165,7 @@ class TileServiceRequestControllerTestComposeOn : SysuiTestCase() {
    @Test
    fun cancelOnTouchOutside_set() =
        kosmos.runTest {
            val dialog = runOnMainThreadAndWaitForIdleSync {
            val dialog = createDialog {
                underTest.requestTileAdd(
                    TEST_UID,
                    TEST_COMPONENT,
@@ -176,11 +175,16 @@ class TileServiceRequestControllerTestComposeOn : SysuiTestCase() {
                    Callback(),
                )!!
            }
            onTeardown { dialog.cancel() }

            assertThat(dialog.isCancelOnTouchOutside).isTrue()
        }

    fun <T : DialogInterface> createDialog(constructor: () -> T): T {
        val dialog = runOnMainThreadAndWaitForIdleSync { constructor() }
        onTeardown { runOnMainThreadAndWaitForIdleSync { dialog.cancel() } }
        return dialog
    }

    @Test
    fun positiveAction_tileAdded() =
        kosmos.runTest {