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

Commit 3ca3c472 authored by Steve Elliott's avatar Steve Elliott
Browse files

Update Kosmos Fixtures for CoroutineContext

These Fixtures were incorrectly pulling the context from the TestScope,
which could cause unexpected behavior due to including the Job from the
TestScope.

In reality, these Contexts are meant to be used to launch code on the
appropriate thread (bg vs main), and so have been updated to just point
to the testDispatcher, which accomplishes this.

Flag: EXEMPT tests only
Test: atest SystemUITests
Change-Id: If0aa708f8ce677f5745b5967f83be28de6679246
parent 10770a27
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -57,12 +57,10 @@ fun Kosmos.useUnconfinedTestDispatcher() = apply { testDispatcher = UnconfinedTe

var Kosmos.testScope by Fixture { TestScope(testDispatcher) }
var Kosmos.backgroundScope by Fixture { testScope.backgroundScope }
var Kosmos.applicationCoroutineScope by Fixture { backgroundScope }
var Kosmos.applicationCoroutineScope by Fixture { testScope.backgroundScope }
var Kosmos.testCase: SysuiTestCase by Fixture()
var Kosmos.backgroundCoroutineContext: CoroutineContext by Fixture {
    backgroundScope.coroutineContext
}
var Kosmos.mainCoroutineContext: CoroutineContext by Fixture { testScope.coroutineContext }
var Kosmos.backgroundCoroutineContext: CoroutineContext by Fixture { testDispatcher }
var Kosmos.mainCoroutineContext: CoroutineContext by Fixture { testDispatcher }

/**
 * Run this test body with a [Kosmos] as receiver, and using the [testScope] currently installed in