Use runTest for AppListRepositoryTest
runTest could be used after kotlinx-coroutines-test 1.6.4 Also since default jvm memory is 4g now, no longer need to set it. Bug: 235727273 Test: atest SpaPrivilegedLibTests Change-Id: Ia987d8e8bdb3b79f205fcea1a53c3f75599effb9
This commit is contained in:
@@ -41,9 +41,6 @@ java_defaults {
|
||||
"SpaPrivilegedLib",
|
||||
],
|
||||
kotlincflags: ["-Xjvm-default=all"],
|
||||
javacflags: [
|
||||
"-J-Xmx4G",
|
||||
],
|
||||
}
|
||||
|
||||
// Expose the srcs to tests, so the tests can access the internal classes.
|
||||
|
||||
@@ -23,6 +23,7 @@ android_test {
|
||||
certificate: "platform",
|
||||
platform_apis: true,
|
||||
test_suites: ["device-tests"],
|
||||
defaults: ["SpaPrivilegedLib-defaults"],
|
||||
|
||||
srcs: [
|
||||
":SpaPrivilegedLib_srcs",
|
||||
@@ -30,8 +31,6 @@ android_test {
|
||||
],
|
||||
|
||||
static_libs: [
|
||||
"SpaPrivilegedLib",
|
||||
"androidx.compose.runtime_runtime",
|
||||
"androidx.compose.ui_ui-test-junit4",
|
||||
"androidx.compose.ui_ui-test-manifest",
|
||||
"androidx.test.ext.junit",
|
||||
@@ -40,7 +39,6 @@ android_test {
|
||||
"truth-prebuilt",
|
||||
],
|
||||
kotlincflags: [
|
||||
"-Xjvm-default=all",
|
||||
"-opt-in=kotlin.RequiresOptIn",
|
||||
],
|
||||
}
|
||||
|
||||
@@ -23,10 +23,11 @@ import android.content.pm.PackageManager.ApplicationInfoFlags
|
||||
import android.content.pm.PackageManager.ResolveInfoFlags
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.flow.flowOf
|
||||
import kotlinx.coroutines.flow.toList
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
@@ -41,6 +42,7 @@ import org.mockito.junit.MockitoRule
|
||||
|
||||
private const val USER_ID = 0
|
||||
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class AppListRepositoryTest {
|
||||
|
||||
@@ -82,7 +84,7 @@ class AppListRepositoryTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun notShowInstantApps(): Unit = runBlocking {
|
||||
fun notShowInstantApps() = runTest {
|
||||
val appListConfig = AppListConfig(userId = USER_ID, showInstantApps = false)
|
||||
|
||||
val appListFlow = repository.loadApps(flowOf(appListConfig))
|
||||
@@ -97,7 +99,7 @@ class AppListRepositoryTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun showInstantApps(): Unit = runBlocking {
|
||||
fun showInstantApps() = runTest {
|
||||
val appListConfig = AppListConfig(userId = USER_ID, showInstantApps = true)
|
||||
|
||||
val appListFlow = repository.loadApps(flowOf(appListConfig))
|
||||
|
||||
Reference in New Issue
Block a user