Merge "Use runTest for AppListRepositoryTest"

This commit is contained in:
Chaohui Wang
2022-10-18 06:00:04 +00:00
committed by Android (Google) Code Review
3 changed files with 6 additions and 9 deletions

View File

@@ -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.

View File

@@ -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",
],
}

View File

@@ -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))