Loading packages/SystemUI/tests/utils/src/com/android/systemui/SysuiTestCaseExt.kt +30 −4 Original line number Diff line number Diff line Loading @@ -19,14 +19,40 @@ package com.android.systemui import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testCase import com.android.systemui.kosmos.useStandardTestDispatcher import com.android.systemui.kosmos.useUnconfinedTestDispatcher fun SysuiTestCase.testKosmos(): Kosmos = Kosmos().apply { testCase = this@testKosmos } /** * This definition, which uses standard dispatcher, is eventually going away. * * If you are calling this method, and want the new default behavior, call `testKosmosNew`, and you * will be migrated to the new behavior (unconfined dispatcher). If you want to maintain the old * behavior, directly call testKosmosNew().useStandardTestDispatcher(). * * The migration will proceed in multiple steps: * 1. All calls to testKosmos will be converted to testKosmosLegacy, maybe over several CLs. * 2. When there are zero references to testKosmos, it will be briefly deleted * 3. A new testKosmos will be introduced that uses unconfined test dispatcher * 4. All callers to testKosmosNew that have been introduced since step 1 will be migrated to this * new definition of testKosmos * 5. testKosmosNew will be deleted * 6. Over time, test authors will be encouraged to migrate away from testKosmosLegacy * * For details, see go/thetiger */ // TODO(b/342622417) fun SysuiTestCase.testKosmos(): Kosmos = testKosmosLegacy() /** * Create a new Kosmos instance using the unconfined test dispatcher. See migration notes on * [testKosmos] */ fun SysuiTestCase.testKosmosNew(): Kosmos = Kosmos().apply { testCase = this@testKosmosNew }.useUnconfinedTestDispatcher() /** * 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 * - testKosmosNew().useStandardTestDispatcher() to explicitly choose the standard dispatcher * - testKosmosNew() to explicitly choose the unconfined dispatcher (which is the new sysui default) * * For details, see go/thetiger */ Loading Loading
packages/SystemUI/tests/utils/src/com/android/systemui/SysuiTestCaseExt.kt +30 −4 Original line number Diff line number Diff line Loading @@ -19,14 +19,40 @@ package com.android.systemui import com.android.systemui.kosmos.Kosmos import com.android.systemui.kosmos.testCase import com.android.systemui.kosmos.useStandardTestDispatcher import com.android.systemui.kosmos.useUnconfinedTestDispatcher fun SysuiTestCase.testKosmos(): Kosmos = Kosmos().apply { testCase = this@testKosmos } /** * This definition, which uses standard dispatcher, is eventually going away. * * If you are calling this method, and want the new default behavior, call `testKosmosNew`, and you * will be migrated to the new behavior (unconfined dispatcher). If you want to maintain the old * behavior, directly call testKosmosNew().useStandardTestDispatcher(). * * The migration will proceed in multiple steps: * 1. All calls to testKosmos will be converted to testKosmosLegacy, maybe over several CLs. * 2. When there are zero references to testKosmos, it will be briefly deleted * 3. A new testKosmos will be introduced that uses unconfined test dispatcher * 4. All callers to testKosmosNew that have been introduced since step 1 will be migrated to this * new definition of testKosmos * 5. testKosmosNew will be deleted * 6. Over time, test authors will be encouraged to migrate away from testKosmosLegacy * * For details, see go/thetiger */ // TODO(b/342622417) fun SysuiTestCase.testKosmos(): Kosmos = testKosmosLegacy() /** * Create a new Kosmos instance using the unconfined test dispatcher. See migration notes on * [testKosmos] */ fun SysuiTestCase.testKosmosNew(): Kosmos = Kosmos().apply { testCase = this@testKosmosNew }.useUnconfinedTestDispatcher() /** * 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 * - testKosmosNew().useStandardTestDispatcher() to explicitly choose the standard dispatcher * - testKosmosNew() to explicitly choose the unconfined dispatcher (which is the new sysui default) * * For details, see go/thetiger */ Loading