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

Commit 18591a56 authored by David Saff's avatar David Saff
Browse files

Introduce testKosmosLegacy for dispatcher migration

See go/thetiger for strategy

Bug: 342622417
Test: presubmit
Flag: TEST_ONLY
Change-Id: I421adb401262fb3176b8685c1edf8b571f2addd2
parent d8593110
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -18,9 +18,22 @@ package com.android.systemui

import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.testCase
import com.android.systemui.kosmos.useStandardTestDispatcher

fun SysuiTestCase.testKosmos(): Kosmos = Kosmos().apply { testCase = this@testKosmos }

/**
 * This should not be called directly. Instead, you can use:
 * - testKosmos() to use the default dispatcher (which will soon be unconfined, see go/thetiger)
 * - testKosmos().useStandardTestDispatcher() to explicitly choose the standard dispatcher
 * - testKosmos().useUnconfinedTestDispatcher() to explicitly choose the unconfined dispatcher
 *
 * For details, see go/thetiger
 */
@Deprecated("Do not call this directly.  Use testKosmos() with dispatcher functions if needed.")
fun SysuiTestCase.testKosmosLegacy(): Kosmos =
    Kosmos().useStandardTestDispatcher().apply { testCase = this@testKosmosLegacy }

/** Run [f] on the main thread and return its result once completed. */
fun <T : Any> SysuiTestCase.runOnMainThreadAndWaitForIdleSync(f: () -> T): T {
    lateinit var result: T