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

Commit c6b07c87 authored by Devarshi Bhatt's avatar Devarshi Bhatt
Browse files

Add scope and dispatcher for UnconfinedTestDispatcher in kosmos.

Similar to StandardTestDispatcher, add a test scope, test dispatcher and
test FakeSettings in kosmos for UnconfinedTestDispatcher.

Bug: 362666598
Test: NONE new kosmos variables
Flag: TEST_ONLY
Change-Id: Icae06c0c07650ad7143965db262136301343d0ae
parent 2af67b94
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -5,9 +5,12 @@ import com.android.systemui.kosmos.Kosmos.Fixture
import kotlin.coroutines.CoroutineContext
import kotlinx.coroutines.test.StandardTestDispatcher
import kotlinx.coroutines.test.TestScope
import kotlinx.coroutines.test.UnconfinedTestDispatcher

var Kosmos.testDispatcher by Fixture { StandardTestDispatcher() }
var Kosmos.unconfinedTestDispatcher by Fixture { UnconfinedTestDispatcher() }
var Kosmos.testScope by Fixture { TestScope(testDispatcher) }
var Kosmos.unconfinedTestScope by Fixture { TestScope(unconfinedTestDispatcher) }
var Kosmos.applicationCoroutineScope by Fixture { testScope.backgroundScope }
var Kosmos.testCase: SysuiTestCase by Fixture()
var Kosmos.backgroundCoroutineContext: CoroutineContext by Fixture {
+5 −0
Original line number Diff line number Diff line
@@ -19,5 +19,10 @@ package com.android.systemui.util.settings
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.Kosmos.Fixture
import com.android.systemui.kosmos.testDispatcher
import com.android.systemui.kosmos.unconfinedTestDispatcher

val Kosmos.fakeGlobalSettings: FakeGlobalSettings by Fixture { FakeGlobalSettings(testDispatcher) }

val Kosmos.unconfinedDispatcherFakeGlobalSettings: FakeGlobalSettings by Fixture {
    FakeGlobalSettings(unconfinedTestDispatcher)
}
+5 −0
Original line number Diff line number Diff line
@@ -19,8 +19,13 @@ package com.android.systemui.util.settings
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.Kosmos.Fixture
import com.android.systemui.kosmos.testDispatcher
import com.android.systemui.kosmos.unconfinedTestDispatcher
import com.android.systemui.settings.userTracker

val Kosmos.fakeSettings: FakeSettings by Fixture {
    FakeSettings(testDispatcher) { userTracker.userId }
}

val Kosmos.unconfinedDispatcherFakeSettings: FakeSettings by Fixture {
    FakeSettings(unconfinedTestDispatcher) { userTracker.userId }
}