From b0b710f1b0622ed54217ac02c4c92e61d52849b1 Mon Sep 17 00:00:00 2001 From: Chaohui Wang Date: Wed, 9 Aug 2023 17:20:58 +0800 Subject: [PATCH] Clean up @OptIn(ExperimentalCoroutinesApi::class) After runTest get stable. Bug: 285231003 Test: unit test Change-Id: I200ba979727b900380b107bd82e1d0e43ab1d994 --- .../specialaccess/DataSaverControllerTest.kt | 2 -- .../DataUsagePreferenceControllerTest.kt | 2 -- .../TelephonyStatusControlSessionTest.kt | 2 -- .../settings/spa/app/AllAppListTest.kt | 2 -- .../UserAspectRatioAppsPageProviderTest.kt | 9 ++++----- .../app/appinfo/PackageInfoPresenterTest.kt | 2 -- ...BackgroundInstalledAppsPageProviderTest.kt | 5 ----- .../app/specialaccess/PictureInPictureTest.kt | 2 -- .../compat/PlatformCompatAppListModelTest.kt | 2 -- .../AppNotificationRepositoryTest.kt | 2 -- .../viewmodel/AutoCredentialViewModelTest.kt | 17 +--------------- ...ngerprintEnrollErrorDialogViewModelTest.kt | 6 ------ .../FingerprintEnrollIntroViewModelTest.kt | 20 ------------------- .../FingerprintEnrollmentViewModelTest.kt | 8 -------- 14 files changed, 5 insertions(+), 76 deletions(-) diff --git a/tests/spa_unit/src/com/android/settings/applications/specialaccess/DataSaverControllerTest.kt b/tests/spa_unit/src/com/android/settings/applications/specialaccess/DataSaverControllerTest.kt index c2413af7603..5d3c1c07e60 100644 --- a/tests/spa_unit/src/com/android/settings/applications/specialaccess/DataSaverControllerTest.kt +++ b/tests/spa_unit/src/com/android/settings/applications/specialaccess/DataSaverControllerTest.kt @@ -29,7 +29,6 @@ import com.android.settings.core.BasePreferenceController.AVAILABLE import com.android.settings.core.BasePreferenceController.UNSUPPORTED_ON_DEVICE import com.android.settingslib.spaprivileged.model.app.AppListRepository import com.google.common.truth.Truth.assertThat -import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.test.runTest @@ -43,7 +42,6 @@ import org.mockito.junit.MockitoJUnit import org.mockito.junit.MockitoRule import org.mockito.Mockito.`when` as whenever -@OptIn(ExperimentalCoroutinesApi::class) @RunWith(AndroidJUnit4::class) class DataSaverControllerTest { @get:Rule diff --git a/tests/spa_unit/src/com/android/settings/network/telephony/DataUsagePreferenceControllerTest.kt b/tests/spa_unit/src/com/android/settings/network/telephony/DataUsagePreferenceControllerTest.kt index 342ebeb03c2..a6d1531127e 100644 --- a/tests/spa_unit/src/com/android/settings/network/telephony/DataUsagePreferenceControllerTest.kt +++ b/tests/spa_unit/src/com/android/settings/network/telephony/DataUsagePreferenceControllerTest.kt @@ -37,7 +37,6 @@ import com.android.settingslib.net.DataUsageController import com.android.settingslib.net.DataUsageController.DataUsageInfo import com.android.settingslib.spa.testutils.waitUntil import com.google.common.truth.Truth.assertThat -import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runTest import org.junit.After import org.junit.Before @@ -53,7 +52,6 @@ import org.mockito.Spy import org.mockito.quality.Strictness import org.mockito.Mockito.`when` as whenever -@OptIn(ExperimentalCoroutinesApi::class) @RunWith(AndroidJUnit4::class) class DataUsagePreferenceControllerTest { diff --git a/tests/spa_unit/src/com/android/settings/network/telephony/TelephonyStatusControlSessionTest.kt b/tests/spa_unit/src/com/android/settings/network/telephony/TelephonyStatusControlSessionTest.kt index 7e6a91b8c65..cf6b919aa5e 100644 --- a/tests/spa_unit/src/com/android/settings/network/telephony/TelephonyStatusControlSessionTest.kt +++ b/tests/spa_unit/src/com/android/settings/network/telephony/TelephonyStatusControlSessionTest.kt @@ -23,12 +23,10 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import com.android.settings.core.BasePreferenceController import com.android.settingslib.spa.testutils.waitUntil import com.google.common.truth.Truth.assertThat -import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.test.runTest import org.junit.Test import org.junit.runner.RunWith -@OptIn(ExperimentalCoroutinesApi::class) @RunWith(AndroidJUnit4::class) class TelephonyStatusControlSessionTest { private val context: Context = ApplicationProvider.getApplicationContext() diff --git a/tests/spa_unit/src/com/android/settings/spa/app/AllAppListTest.kt b/tests/spa_unit/src/com/android/settings/spa/app/AllAppListTest.kt index 2e7752e4964..97a5a8179af 100644 --- a/tests/spa_unit/src/com/android/settings/spa/app/AllAppListTest.kt +++ b/tests/spa_unit/src/com/android/settings/spa/app/AllAppListTest.kt @@ -33,7 +33,6 @@ import com.android.settingslib.spa.testutils.firstWithTimeoutOrNull import com.android.settingslib.spaprivileged.template.app.AppListInput import com.android.settingslib.spaprivileged.template.app.AppListItemModel import com.google.common.truth.Truth.assertThat -import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.test.runTest import org.junit.Rule @@ -118,7 +117,6 @@ class AllAppListTest { .isEqualTo("AppInfoSettings/package.name/0") } - @OptIn(ExperimentalCoroutinesApi::class) @Test fun allAppListModel_transform() = runTest { val listModel = AllAppListModel(context) { stateOf(SUMMARY) } diff --git a/tests/spa_unit/src/com/android/settings/spa/app/appcompat/UserAspectRatioAppsPageProviderTest.kt b/tests/spa_unit/src/com/android/settings/spa/app/appcompat/UserAspectRatioAppsPageProviderTest.kt index 0d2869c6cdf..19176f882f1 100644 --- a/tests/spa_unit/src/com/android/settings/spa/app/appcompat/UserAspectRatioAppsPageProviderTest.kt +++ b/tests/spa_unit/src/com/android/settings/spa/app/appcompat/UserAspectRatioAppsPageProviderTest.kt @@ -34,7 +34,6 @@ import com.android.settingslib.spa.testutils.FakeNavControllerWrapper import com.android.settingslib.spa.testutils.firstWithTimeoutOrNull import com.android.settingslib.spaprivileged.template.app.AppListItemModel import com.google.common.truth.Truth.assertThat -import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.test.runTest import org.junit.Rule @@ -67,14 +66,16 @@ class UserAspectRatioAppsPageProviderTest { @Test fun injectEntry_summary() { setInjectEntry() - composeTestRule.onNodeWithText(context.getString(R.string.aspect_ratio_summary, Build.MODEL)) + composeTestRule + .onNodeWithText(context.getString(R.string.aspect_ratio_summary, Build.MODEL)) .assertIsDisplayed() } @Test fun injectEntry_onClick_navigate() { setInjectEntry() - composeTestRule.onNodeWithText(context.getString(R.string.aspect_ratio_title)).performClick() + composeTestRule.onNodeWithText(context.getString(R.string.aspect_ratio_title)) + .performClick() assertThat(fakeNavControllerWrapper.navigateCalledWith).isEqualTo("UserAspectRatioAppsPage") } @@ -103,7 +104,6 @@ class UserAspectRatioAppsPageProviderTest { composeTestRule.onNodeWithText(LABEL).assertIsDisplayed() } - @OptIn(ExperimentalCoroutinesApi::class) @Test fun aspectRatioAppListModel_transform() = runTest { val listModel = UserAspectRatioAppListModel(context) @@ -114,7 +114,6 @@ class UserAspectRatioAppsPageProviderTest { assertThat(recordList[0].app).isSameInstanceAs(APP) } - @OptIn(ExperimentalCoroutinesApi::class) @Test fun aspectRatioAppListModel_filter() = runTest { val listModel = UserAspectRatioAppListModel(context) diff --git a/tests/spa_unit/src/com/android/settings/spa/app/appinfo/PackageInfoPresenterTest.kt b/tests/spa_unit/src/com/android/settings/spa/app/appinfo/PackageInfoPresenterTest.kt index 3bfa90e2d9e..2648e089a1d 100644 --- a/tests/spa_unit/src/com/android/settings/spa/app/appinfo/PackageInfoPresenterTest.kt +++ b/tests/spa_unit/src/com/android/settings/spa/app/appinfo/PackageInfoPresenterTest.kt @@ -28,7 +28,6 @@ import com.android.settings.testutils.mockAsUser import com.android.settingslib.spaprivileged.framework.common.activityManager import com.android.settingslib.spaprivileged.model.app.IPackageManagers import com.google.common.truth.Truth.assertThat -import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.test.runTest import org.junit.Before @@ -45,7 +44,6 @@ import org.mockito.junit.MockitoJUnit import org.mockito.junit.MockitoRule import org.mockito.Mockito.`when` as whenever -@OptIn(ExperimentalCoroutinesApi::class) @RunWith(AndroidJUnit4::class) class PackageInfoPresenterTest { @get:Rule diff --git a/tests/spa_unit/src/com/android/settings/spa/app/backgroundinstall/BackgroundInstalledAppsPageProviderTest.kt b/tests/spa_unit/src/com/android/settings/spa/app/backgroundinstall/BackgroundInstalledAppsPageProviderTest.kt index b3e29af3e9e..68ad065e1d3 100644 --- a/tests/spa_unit/src/com/android/settings/spa/app/backgroundinstall/BackgroundInstalledAppsPageProviderTest.kt +++ b/tests/spa_unit/src/com/android/settings/spa/app/backgroundinstall/BackgroundInstalledAppsPageProviderTest.kt @@ -34,7 +34,6 @@ import com.android.settingslib.spa.testutils.FakeNavControllerWrapper import com.android.settingslib.spa.testutils.any import com.android.settingslib.spaprivileged.template.app.AppListItemModel import com.google.common.truth.Truth -import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.test.runTest @@ -171,7 +170,6 @@ class BackgroundInstalledAppsPageProviderTest { .isEqualTo("AppInfoSettings/package.name/0") } - @OptIn(ExperimentalCoroutinesApi::class) @Test fun backgroundInstalledAppsWithGroupingListModel_getGroupTitleOne() = runTest { val listModel = BackgroundInstalledAppsWithGroupingListModel(context) @@ -186,7 +184,6 @@ class BackgroundInstalledAppsPageProviderTest { Truth.assertThat(actualGroupTitle).isEqualTo("Apps installed in the last 6 months") } - @OptIn(ExperimentalCoroutinesApi::class) @Test fun backgroundInstalledAppsWithGroupingListModel_getGroupTitleTwo() = runTest { val listModel = BackgroundInstalledAppsWithGroupingListModel(context) @@ -201,7 +198,6 @@ class BackgroundInstalledAppsPageProviderTest { Truth.assertThat(actualGroupTitle).isEqualTo("Apps installed more than 6 months ago") } - @OptIn(ExperimentalCoroutinesApi::class) @Test fun backgroundInstalledAppsWithGroupingListModel_transform() = runTest { val listModel = BackgroundInstalledAppsWithGroupingListModel(mockContext) @@ -220,7 +216,6 @@ class BackgroundInstalledAppsPageProviderTest { Truth.assertThat(packageInfoFlagsCaptor.value.value).isEqualTo(EXPECTED_PACKAGE_INFO_FLAG) } - @OptIn(ExperimentalCoroutinesApi::class) @Test fun backgroundInstalledAppsWithGroupingListModel_filter() = runTest { val listModel = BackgroundInstalledAppsWithGroupingListModel(mockContext) diff --git a/tests/spa_unit/src/com/android/settings/spa/app/specialaccess/PictureInPictureTest.kt b/tests/spa_unit/src/com/android/settings/spa/app/specialaccess/PictureInPictureTest.kt index fb0fb698045..6054bb51bb8 100644 --- a/tests/spa_unit/src/com/android/settings/spa/app/specialaccess/PictureInPictureTest.kt +++ b/tests/spa_unit/src/com/android/settings/spa/app/specialaccess/PictureInPictureTest.kt @@ -29,7 +29,6 @@ import androidx.test.ext.junit.runners.AndroidJUnit4 import com.android.settings.R import com.android.settingslib.spaprivileged.model.app.AppOpsController import com.google.common.truth.Truth.assertThat -import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.test.runTest @@ -46,7 +45,6 @@ import org.mockito.junit.MockitoJUnit import org.mockito.junit.MockitoRule import org.mockito.Mockito.`when` as whenever -@OptIn(ExperimentalCoroutinesApi::class) @RunWith(AndroidJUnit4::class) class PictureInPictureTest { @get:Rule diff --git a/tests/spa_unit/src/com/android/settings/spa/development/compat/PlatformCompatAppListModelTest.kt b/tests/spa_unit/src/com/android/settings/spa/development/compat/PlatformCompatAppListModelTest.kt index 78aca852492..0cfdc7decc1 100644 --- a/tests/spa_unit/src/com/android/settings/spa/development/compat/PlatformCompatAppListModelTest.kt +++ b/tests/spa_unit/src/com/android/settings/spa/development/compat/PlatformCompatAppListModelTest.kt @@ -25,7 +25,6 @@ import androidx.compose.ui.test.junit4.createComposeRule import androidx.test.core.app.ApplicationProvider import androidx.test.ext.junit.runners.AndroidJUnit4 import com.google.common.truth.Truth.assertThat -import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.test.runTest @@ -41,7 +40,6 @@ import org.mockito.junit.MockitoJUnit import org.mockito.junit.MockitoRule import org.mockito.Mockito.`when` as whenever -@OptIn(ExperimentalCoroutinesApi::class) @RunWith(AndroidJUnit4::class) class PlatformCompatAppListModelTest { @get:Rule diff --git a/tests/spa_unit/src/com/android/settings/spa/notification/AppNotificationRepositoryTest.kt b/tests/spa_unit/src/com/android/settings/spa/notification/AppNotificationRepositoryTest.kt index 12fdc23ac30..87ff9ba84bd 100644 --- a/tests/spa_unit/src/com/android/settings/spa/notification/AppNotificationRepositoryTest.kt +++ b/tests/spa_unit/src/com/android/settings/spa/notification/AppNotificationRepositoryTest.kt @@ -34,7 +34,6 @@ import com.android.settingslib.spa.testutils.any import com.android.settingslib.spaprivileged.model.app.IPackageManagers import com.android.settingslib.spaprivileged.model.app.userId import com.google.common.truth.Truth.assertThat -import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.first import kotlinx.coroutines.flow.flowOf import kotlinx.coroutines.test.runTest @@ -49,7 +48,6 @@ import org.mockito.junit.MockitoJUnit import org.mockito.junit.MockitoRule import org.mockito.Mockito.`when` as whenever -@OptIn(ExperimentalCoroutinesApi::class) @RunWith(AndroidJUnit4::class) class AppNotificationRepositoryTest { @get:Rule diff --git a/tests/unit/src/com/android/settings/biometrics2/ui/viewmodel/AutoCredentialViewModelTest.kt b/tests/unit/src/com/android/settings/biometrics2/ui/viewmodel/AutoCredentialViewModelTest.kt index 3ae4951944b..c0a0a983254 100644 --- a/tests/unit/src/com/android/settings/biometrics2/ui/viewmodel/AutoCredentialViewModelTest.kt +++ b/tests/unit/src/com/android/settings/biometrics2/ui/viewmodel/AutoCredentialViewModelTest.kt @@ -35,7 +35,7 @@ import com.android.settings.biometrics2.ui.viewmodel.AutoCredentialViewModel.Cha import com.android.settings.password.ChooseLockPattern import com.android.settings.password.ChooseLockSettingsHelper import com.google.common.truth.Truth.assertThat -import kotlinx.coroutines.ExperimentalCoroutinesApi +import java.util.concurrent.atomic.AtomicBoolean import kotlinx.coroutines.flow.toList import kotlinx.coroutines.launch import kotlinx.coroutines.test.TestScope @@ -50,7 +50,6 @@ import org.mockito.Mock import org.mockito.Mockito import org.mockito.junit.MockitoJUnit import org.mockito.junit.MockitoRule -import java.util.concurrent.atomic.AtomicBoolean import org.mockito.Mockito.`when` as whenever @RunWith(AndroidJUnit4::class) @@ -86,7 +85,6 @@ class AutoCredentialViewModelTest { challengeGenerator.challenge = newChallenge } - @OptIn(ExperimentalCoroutinesApi::class) @Test fun testCheckCredential_validCredentialCase() = runTest { val userId = 99 @@ -109,7 +107,6 @@ class AutoCredentialViewModelTest { assertThat(viewModel.createGeneratingChallengeExtras()).isNull() } - @OptIn(ExperimentalCoroutinesApi::class) @Test fun testCheckCredential_needToChooseLock() = runTest { val userId = 100 @@ -132,7 +129,6 @@ class AutoCredentialViewModelTest { assertThat(viewModel.createGeneratingChallengeExtras()).isNull() } - @OptIn(ExperimentalCoroutinesApi::class) @Test fun testCheckCredential_needToConfirmLockForSomething() = runTest { val userId = 101 @@ -156,7 +152,6 @@ class AutoCredentialViewModelTest { assertThat(viewModel.createGeneratingChallengeExtras()).isNull() } - @OptIn(ExperimentalCoroutinesApi::class) @Test fun testCheckCredential_needToConfirmLockForNumeric() = runTest { val userId = 102 @@ -180,7 +175,6 @@ class AutoCredentialViewModelTest { assertThat(viewModel.createGeneratingChallengeExtras()).isNull() } - @OptIn(ExperimentalCoroutinesApi::class) @Test fun testCheckCredential_needToConfirmLockForAlphabetic() = runTest { val userId = 103 @@ -204,7 +198,6 @@ class AutoCredentialViewModelTest { assertThat(viewModel.createGeneratingChallengeExtras()).isNull() } - @OptIn(ExperimentalCoroutinesApi::class) @Test fun testCheckCredential_generateChallenge() = runTest { val userId = 104 @@ -258,7 +251,6 @@ class AutoCredentialViewModelTest { assertThat(tokens[0]).isEqualTo(1) } - @OptIn(ExperimentalCoroutinesApi::class) @Test fun testCheckCredential_generateChallengeFail() = runTest { backgroundScope.launch { @@ -306,7 +298,6 @@ class AutoCredentialViewModelTest { assertThat(viewModel.userId).isEqualTo(userId) } - @OptIn(ExperimentalCoroutinesApi::class) @Test fun testGenerateChallengeAsCredentialActivityResult_invalidChooseLock() = runTest { backgroundScope.launch { @@ -332,7 +323,6 @@ class AutoCredentialViewModelTest { } } - @OptIn(ExperimentalCoroutinesApi::class) @Test fun testGenerateChallengeAsCredentialActivityResult_invalidConfirmLock() = runTest { backgroundScope.launch { @@ -358,7 +348,6 @@ class AutoCredentialViewModelTest { } } - @OptIn(ExperimentalCoroutinesApi::class) @Test fun testGenerateChallengeAsCredentialActivityResult_nullDataChooseLock() = runTest { val userId = 108 @@ -380,7 +369,6 @@ class AutoCredentialViewModelTest { assertThat(generateFails.size).isEqualTo(0) } - @OptIn(ExperimentalCoroutinesApi::class) @Test fun testGenerateChallengeAsCredentialActivityResult_nullDataConfirmLock() = runTest { val userId = 109 @@ -401,7 +389,6 @@ class AutoCredentialViewModelTest { assertThat(generateFails.size).isEqualTo(0) } - @OptIn(ExperimentalCoroutinesApi::class) @Test fun testGenerateChallengeAsCredentialActivityResult_validChooseLock() = runTest { val userId = 108 @@ -447,7 +434,6 @@ class AutoCredentialViewModelTest { assertThat(hasCalledRemoveGkPwHandle.get()).isTrue() } - @OptIn(ExperimentalCoroutinesApi::class) @Test fun testGenerateChallengeAsCredentialActivityResult_validConfirmLock() = runTest { val userId = 109 @@ -493,7 +479,6 @@ class AutoCredentialViewModelTest { assertThat(hasCalledRemoveGkPwHandle.get()).isTrue() } - @OptIn(ExperimentalCoroutinesApi::class) private fun TestScope.listOfGenerateChallengeFailedFlow(): List = mutableListOf().also { backgroundScope.launch(UnconfinedTestDispatcher(testScheduler)) { diff --git a/tests/unit/src/com/android/settings/biometrics2/ui/viewmodel/FingerprintEnrollErrorDialogViewModelTest.kt b/tests/unit/src/com/android/settings/biometrics2/ui/viewmodel/FingerprintEnrollErrorDialogViewModelTest.kt index 3679dd291c9..379a5c1a30e 100644 --- a/tests/unit/src/com/android/settings/biometrics2/ui/viewmodel/FingerprintEnrollErrorDialogViewModelTest.kt +++ b/tests/unit/src/com/android/settings/biometrics2/ui/viewmodel/FingerprintEnrollErrorDialogViewModelTest.kt @@ -19,12 +19,9 @@ import android.app.Application import androidx.test.core.app.ApplicationProvider import androidx.test.ext.junit.runners.AndroidJUnit4 import com.android.settings.biometrics2.ui.viewmodel.FingerprintErrorDialogSetResultAction.FINGERPRINT_ERROR_DIALOG_ACTION_SET_RESULT_FINISH -import com.android.settings.biometrics2.ui.viewmodel.FingerprintErrorDialogSetResultAction.FINGERPRINT_ERROR_DIALOG_ACTION_SET_RESULT_TIMEOUT import com.google.common.truth.Truth.assertThat -import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.toList import kotlinx.coroutines.launch -import kotlinx.coroutines.test.TestScope import kotlinx.coroutines.test.UnconfinedTestDispatcher import kotlinx.coroutines.test.runCurrent import kotlinx.coroutines.test.runTest @@ -56,7 +53,6 @@ class FingerprintEnrollErrorDialogViewModelTest { assertThat(FingerprintEnrollErrorDialogViewModel(application, true).isSuw).isTrue() } - @OptIn(ExperimentalCoroutinesApi::class) @Test fun testNewDialog() = runTest { val newDialogs: List = mutableListOf().also { @@ -81,7 +77,6 @@ class FingerprintEnrollErrorDialogViewModelTest { assertThat(newDialogs[0]).isEqualTo(testErrorMsgId) } - @OptIn(ExperimentalCoroutinesApi::class) @Test fun testTriggerRetry() = runTest { val triggerRetries: List = mutableListOf().also { @@ -102,7 +97,6 @@ class FingerprintEnrollErrorDialogViewModelTest { assertThat(triggerRetries.size).isEqualTo(1) } - @OptIn(ExperimentalCoroutinesApi::class) @Test fun testSetResultFinish() = runTest { val setResults: List = diff --git a/tests/unit/src/com/android/settings/biometrics2/ui/viewmodel/FingerprintEnrollIntroViewModelTest.kt b/tests/unit/src/com/android/settings/biometrics2/ui/viewmodel/FingerprintEnrollIntroViewModelTest.kt index 08e5ac35d7f..7494aef23ea 100644 --- a/tests/unit/src/com/android/settings/biometrics2/ui/viewmodel/FingerprintEnrollIntroViewModelTest.kt +++ b/tests/unit/src/com/android/settings/biometrics2/ui/viewmodel/FingerprintEnrollIntroViewModelTest.kt @@ -38,7 +38,6 @@ import com.android.settings.biometrics2.utils.FingerprintRepositoryUtils.newFing import com.android.settings.biometrics2.utils.FingerprintRepositoryUtils.setupFingerprintEnrolledFingerprints import com.android.settings.biometrics2.utils.FingerprintRepositoryUtils.setupSuwMaxFingerprintsEnrollable import com.google.common.truth.Truth.assertThat -import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.toList import kotlinx.coroutines.launch import kotlinx.coroutines.test.TestScope @@ -78,7 +77,6 @@ class FingerprintEnrollIntroViewModelTest { application = ApplicationProvider.getApplicationContext() } - @OptIn(ExperimentalCoroutinesApi::class) @Test fun testPageStatusFlowDefaultAndUpdate() = runTest { val viewModel = newFingerprintEnrollIntroViewModel( @@ -105,7 +103,6 @@ class FingerprintEnrollIntroViewModelTest { assertThat(statusList[1].enrollableStatus).isEqualTo(FINGERPRINT_ENROLLABLE_ERROR_REACH_MAX) } - @OptIn(ExperimentalCoroutinesApi::class) fun testOnStartToUpdateEnrollableStatusOk_isSuw() = runTest { setupFingerprintEnrolledFingerprints(fingerprintManager, TEST_USER_ID, 0) setupSuwMaxFingerprintsEnrollable(application, resources, 1) @@ -122,7 +119,6 @@ class FingerprintEnrollIntroViewModelTest { assertThat(statusList[0].enrollableStatus).isEqualTo(FINGERPRINT_ENROLLABLE_OK) } - @OptIn(ExperimentalCoroutinesApi::class) @Test fun testOnStartToUpdateEnrollableStatusReachMax_isSuw() = runTest { setupFingerprintEnrolledFingerprints(fingerprintManager, TEST_USER_ID, 1) @@ -140,49 +136,41 @@ class FingerprintEnrollIntroViewModelTest { assertThat(statusList[0].enrollableStatus).isEqualTo(FINGERPRINT_ENROLLABLE_ERROR_REACH_MAX) } - @OptIn(ExperimentalCoroutinesApi::class) @Test fun testOnStartToUpdateEnrollableStatusOk_isNotSuw() = runTest { testOnStartToUpdateEnrollableStatusOk(newAllFalseRequest(application)) } - @OptIn(ExperimentalCoroutinesApi::class) @Test fun testOnStartToUpdateEnrollableStatusReachMax_isNotSuw() = runTest { testOnStartToUpdateEnrollableStatusReachMax(newAllFalseRequest(application)) } - @OptIn(ExperimentalCoroutinesApi::class) @Test fun testOnStartToUpdateEnrollableStatusOk_isSuwDeferred() = runTest { testOnStartToUpdateEnrollableStatusOk(newIsSuwDeferredRequest(application)) } - @OptIn(ExperimentalCoroutinesApi::class) @Test fun testOnStartToUpdateEnrollableStatusReachMax_isSuwDeferred() = runTest { testOnStartToUpdateEnrollableStatusReachMax(newIsSuwDeferredRequest(application)) } - @OptIn(ExperimentalCoroutinesApi::class) @Test fun testOnStartToUpdateEnrollableStatusOk_isSuwPortal() = runTest { testOnStartToUpdateEnrollableStatusOk(newIsSuwPortalRequest(application)) } - @OptIn(ExperimentalCoroutinesApi::class) @Test fun testOnStartToUpdateEnrollableStatusReachMax_isSuwPortal() = runTest { testOnStartToUpdateEnrollableStatusReachMax(newIsSuwPortalRequest(application)) } - @OptIn(ExperimentalCoroutinesApi::class) @Test fun testOnStartToUpdateEnrollableStatusOk_isSuwSuggestedActionFlow() = runTest { testOnStartToUpdateEnrollableStatusOk(newIsSuwSuggestedActionFlowRequest(application)) } - @OptIn(ExperimentalCoroutinesApi::class) @Test fun testOnStartToUpdateEnrollableStatusReachMax_isSuwSuggestedActionFlow() = runTest { testOnStartToUpdateEnrollableStatusReachMax( @@ -190,7 +178,6 @@ class FingerprintEnrollIntroViewModelTest { ) } - @OptIn(ExperimentalCoroutinesApi::class) private fun TestScope.testOnStartToUpdateEnrollableStatusOk(request: EnrollmentRequest) { setupFingerprintEnrolledFingerprints(fingerprintManager, TEST_USER_ID, 0) val viewModel = newFingerprintEnrollIntroViewModel( @@ -206,7 +193,6 @@ class FingerprintEnrollIntroViewModelTest { assertThat(statusList[0].enrollableStatus).isEqualTo(FINGERPRINT_ENROLLABLE_OK) } - @OptIn(ExperimentalCoroutinesApi::class) private fun TestScope.testOnStartToUpdateEnrollableStatusReachMax(request: EnrollmentRequest) { setupFingerprintEnrolledFingerprints(fingerprintManager, TEST_USER_ID, 5) val viewModel = newFingerprintEnrollIntroViewModel( @@ -268,7 +254,6 @@ class FingerprintEnrollIntroViewModelTest { assertThat(viewModel.isBiometricUnlockDisabledByAdmin).isEqualTo(false) } - @OptIn(ExperimentalCoroutinesApi::class) @Test fun testSetHasScrolledToBottom() = runTest { val viewModel = newFingerprintEnrollIntroViewModel( @@ -284,7 +269,6 @@ class FingerprintEnrollIntroViewModelTest { assertThat(pageStatusList[pageStatusList.size-1].hasScrollToBottom()).isEqualTo(true) } - @OptIn(ExperimentalCoroutinesApi::class) @Test fun testOnNextButtonClick_enrollNext() = runTest { // Set latest status to FINGERPRINT_ENROLLABLE_OK @@ -305,7 +289,6 @@ class FingerprintEnrollIntroViewModelTest { assertThat(actions[0]).isEqualTo(CONTINUE_ENROLL) } - @OptIn(ExperimentalCoroutinesApi::class) @Test fun testOnNextButtonClick_doneAndFinish() = runTest { // Set latest status to FINGERPRINT_ENROLLABLE_ERROR_REACH_MAX @@ -334,7 +317,6 @@ class FingerprintEnrollIntroViewModelTest { assertThat(actionList[0]).isEqualTo(DONE_AND_FINISH) } - @OptIn(ExperimentalCoroutinesApi::class) @Test fun testOnSkipOrCancelButtonClick() = runTest { val viewModel = newFingerprintEnrollIntroViewModel( @@ -351,7 +333,6 @@ class FingerprintEnrollIntroViewModelTest { assertThat(actions[0]).isEqualTo(SKIP_OR_CANCEL) } - @OptIn(ExperimentalCoroutinesApi::class) private fun TestScope.listOfActionFlow( viewModel: FingerprintEnrollIntroViewModel ): List = @@ -361,7 +342,6 @@ class FingerprintEnrollIntroViewModelTest { } } - @OptIn(ExperimentalCoroutinesApi::class) private fun TestScope.listOfPageStatusFlow( viewModel: FingerprintEnrollIntroViewModel ): List = diff --git a/tests/unit/src/com/android/settings/biometrics2/ui/viewmodel/FingerprintEnrollmentViewModelTest.kt b/tests/unit/src/com/android/settings/biometrics2/ui/viewmodel/FingerprintEnrollmentViewModelTest.kt index bee91c9bf6e..6d04f3563c2 100644 --- a/tests/unit/src/com/android/settings/biometrics2/ui/viewmodel/FingerprintEnrollmentViewModelTest.kt +++ b/tests/unit/src/com/android/settings/biometrics2/ui/viewmodel/FingerprintEnrollmentViewModelTest.kt @@ -30,7 +30,6 @@ import com.android.settings.biometrics2.utils.EnrollmentRequestUtils.newIsSuwReq import com.android.settings.biometrics2.utils.FingerprintRepositoryUtils.newFingerprintRepository import com.android.settings.biometrics2.utils.FingerprintRepositoryUtils.setupFingerprintEnrolledFingerprints import com.google.common.truth.Truth.assertThat -import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.toList import kotlinx.coroutines.launch import kotlinx.coroutines.test.TestScope @@ -226,7 +225,6 @@ class FingerprintEnrollmentViewModelTest { assertThat(viewModel.isMaxEnrolledReached(uid)).isTrue() } - @OptIn(ExperimentalCoroutinesApi::class) @Test fun testSetResultFlow_defaultEmpty() = runTest { val activityResults = listOfSetResultFlow() @@ -236,7 +234,6 @@ class FingerprintEnrollmentViewModelTest { assertThat(activityResults.size).isEqualTo(0) } - @OptIn(ExperimentalCoroutinesApi::class) @Test fun testCheckFinishActivityDuringOnPause_doNothingIfIsSuw() = runTest { viewModel = FingerprintEnrollmentViewModel( @@ -257,7 +254,6 @@ class FingerprintEnrollmentViewModelTest { assertThat(activityResults.size).isEqualTo(0) } - @OptIn(ExperimentalCoroutinesApi::class) @Test fun testCheckFinishActivityDuringOnPause_doNothingIfIsWaitingActivity() = runTest { val activityResults = listOfSetResultFlow() @@ -273,7 +269,6 @@ class FingerprintEnrollmentViewModelTest { assertThat(activityResults.size).isEqualTo(0) } - @OptIn(ExperimentalCoroutinesApi::class) @Test fun testCheckFinishActivityDuringOnPause_doNothingIfIsActivityFinishing() = runTest { val activityResults = listOfSetResultFlow() @@ -288,7 +283,6 @@ class FingerprintEnrollmentViewModelTest { assertThat(activityResults.size).isEqualTo(0) } - @OptIn(ExperimentalCoroutinesApi::class) @Test fun testCheckFinishActivityDuringOnPause_doNothingIfIsChangingConfigurations() = runTest { val activityResults = listOfSetResultFlow() @@ -303,7 +297,6 @@ class FingerprintEnrollmentViewModelTest { assertThat(activityResults.size).isEqualTo(0) } - @OptIn(ExperimentalCoroutinesApi::class) @Test fun testCheckFinishActivityDuringOnPause_defaultFinishSelf() = runTest { val activityResults = listOfSetResultFlow() @@ -320,7 +313,6 @@ class FingerprintEnrollmentViewModelTest { assertThat(activityResults[0].data).isEqualTo(null) } - @OptIn(ExperimentalCoroutinesApi::class) private fun TestScope.listOfSetResultFlow(): List = mutableListOf().also { backgroundScope.launch(UnconfinedTestDispatcher(testScheduler)) {