Fixes failing CustomizationProviderTest.
The issue was the recent introduction of runBlocking { } calls in
ag/21396218. These block the logic on the current thread, causing unit
test runners to choke. Instead, we should use
runBlocking(CoroutineDispatcher) { } to make sure that the suspend
function yields back to the running test.
In addition to that change, we also needed to move the test onto an
UnconfinedTestDispatcher.
Fix: 269679515
Test: tests pass locally with atest
Change-Id: Iff661303af8791df7751fac7788681a105d47a75
This commit is contained in:
committed by
Ale Nijamkin
parent
788f62aed4
commit
3528f21216
@@ -131,7 +131,7 @@ class CustomizationProvider :
|
|||||||
throw UnsupportedOperationException()
|
throw UnsupportedOperationException()
|
||||||
}
|
}
|
||||||
|
|
||||||
return runBlocking { insertSelection(values) }
|
return runBlocking(mainDispatcher) { insertSelection(values) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun query(
|
override fun query(
|
||||||
@@ -171,7 +171,7 @@ class CustomizationProvider :
|
|||||||
throw UnsupportedOperationException()
|
throw UnsupportedOperationException()
|
||||||
}
|
}
|
||||||
|
|
||||||
return runBlocking { deleteSelection(uri, selectionArgs) }
|
return runBlocking(mainDispatcher) { deleteSelection(uri, selectionArgs) }
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun call(method: String, arg: String?, extras: Bundle?): Bundle? {
|
override fun call(method: String, arg: String?, extras: Bundle?): Bundle? {
|
||||||
|
|||||||
@@ -62,7 +62,6 @@ import com.android.systemui.util.mockito.whenever
|
|||||||
import com.android.systemui.util.settings.FakeSettings
|
import com.android.systemui.util.settings.FakeSettings
|
||||||
import com.google.common.truth.Truth.assertThat
|
import com.google.common.truth.Truth.assertThat
|
||||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||||
import kotlinx.coroutines.test.StandardTestDispatcher
|
|
||||||
import kotlinx.coroutines.test.TestScope
|
import kotlinx.coroutines.test.TestScope
|
||||||
import kotlinx.coroutines.test.UnconfinedTestDispatcher
|
import kotlinx.coroutines.test.UnconfinedTestDispatcher
|
||||||
import kotlinx.coroutines.test.runTest
|
import kotlinx.coroutines.test.runTest
|
||||||
@@ -104,7 +103,7 @@ class CustomizationProviderTest : SysuiTestCase() {
|
|||||||
whenever(backgroundHandler.looper).thenReturn(TestableLooper.get(this).looper)
|
whenever(backgroundHandler.looper).thenReturn(TestableLooper.get(this).looper)
|
||||||
|
|
||||||
underTest = CustomizationProvider()
|
underTest = CustomizationProvider()
|
||||||
val testDispatcher = StandardTestDispatcher()
|
val testDispatcher = UnconfinedTestDispatcher()
|
||||||
testScope = TestScope(testDispatcher)
|
testScope = TestScope(testDispatcher)
|
||||||
val localUserSelectionManager =
|
val localUserSelectionManager =
|
||||||
KeyguardQuickAffordanceLocalUserSelectionManager(
|
KeyguardQuickAffordanceLocalUserSelectionManager(
|
||||||
|
|||||||
Reference in New Issue
Block a user