summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCatherine Liang <cathliang@google.com>2023-10-06 19:22:08 +0000
committerCatherine Liang <cathliang@google.com>2023-10-06 19:33:33 +0000
commit0df3e12b96e9940f863a89f24ea0e0e5f034e0be (patch)
tree444d3129ebabafe8cec1aca061236b5158e9a6bb /tests
parent81d4ddbac7f68cfd403b7f91d460dc8b2d999745 (diff)
downloadThemePicker-0df3e12b96e9940f863a89f24ea0e0e5f034e0be.tar.gz
Adjust quick affordance section controller to use base flags (2/3)
The quick affordance section controller currently calls runBlocking when initializing to query flags and check if the feature is available. However, fragments and section controllers should be getting System UI flags using base flags, which queries and caches the flags when a flag is first needed. In addition, the runBlocking function is suspected to be the cause of the reported crash within the bug. In this CL, the quick affordance section controller, interactor & repository are adjusted to remove the flag querying, and the flag is read from base flags instead in the section controller. Bug: 296856318 Bug: 290849013 Test: adjusted unit tests for this change and made sure they still pass, verified manually that quick affordance section controller remains Change-Id: Ic469396f4a959a339efebec7cfbaaf37f8b404e3
Diffstat (limited to 'tests')
-rw-r--r--tests/robotests/src/com/android/customization/model/picker/quickaffordance/data/repository/KeyguardQuickAffordancePickerRepositoryTest.kt39
-rw-r--r--tests/robotests/src/com/android/customization/model/picker/quickaffordance/domain/interactor/KeyguardQuickAffordancePickerInteractorTest.kt1
-rw-r--r--tests/robotests/src/com/android/customization/model/picker/quickaffordance/ui/viewmodel/KeyguardQuickAffordancePickerViewModelTest.kt1
3 files changed, 0 insertions, 41 deletions
diff --git a/tests/robotests/src/com/android/customization/model/picker/quickaffordance/data/repository/KeyguardQuickAffordancePickerRepositoryTest.kt b/tests/robotests/src/com/android/customization/model/picker/quickaffordance/data/repository/KeyguardQuickAffordancePickerRepositoryTest.kt
index 35dbadd5..8a5d582b 100644
--- a/tests/robotests/src/com/android/customization/model/picker/quickaffordance/data/repository/KeyguardQuickAffordancePickerRepositoryTest.kt
+++ b/tests/robotests/src/com/android/customization/model/picker/quickaffordance/data/repository/KeyguardQuickAffordancePickerRepositoryTest.kt
@@ -19,21 +19,15 @@ package com.android.customization.model.picker.quickaffordance.data.repository
import androidx.test.filters.SmallTest
import com.android.customization.picker.quickaffordance.data.repository.KeyguardQuickAffordancePickerRepository
-import com.android.systemui.shared.customization.data.content.CustomizationProviderContract
import com.android.systemui.shared.customization.data.content.FakeCustomizationProviderClient
-import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.Dispatchers
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.resetMain
-import kotlinx.coroutines.test.runTest
import kotlinx.coroutines.test.setMain
import org.junit.After
import org.junit.Before
-import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
@@ -57,7 +51,6 @@ class KeyguardQuickAffordancePickerRepositoryTest {
underTest =
KeyguardQuickAffordancePickerRepository(
client = client,
- backgroundDispatcher = coroutineDispatcher,
)
}
@@ -65,36 +58,4 @@ class KeyguardQuickAffordancePickerRepositoryTest {
fun tearDown() {
Dispatchers.resetMain()
}
-
- @Test
- fun `isFeatureEnabled - enabled`() =
- testScope.runTest {
- client.setFlag(
- CustomizationProviderContract.FlagsTable
- .FLAG_NAME_CUSTOM_LOCK_SCREEN_QUICK_AFFORDANCES_ENABLED,
- true,
- )
- val values = mutableListOf<Boolean>()
- val job = launch { underTest.isFeatureEnabled.toList(values) }
-
- assertThat(values.last()).isTrue()
-
- job.cancel()
- }
-
- @Test
- fun `isFeatureEnabled - not enabled`() =
- testScope.runTest {
- client.setFlag(
- CustomizationProviderContract.FlagsTable
- .FLAG_NAME_CUSTOM_LOCK_SCREEN_QUICK_AFFORDANCES_ENABLED,
- false,
- )
- val values = mutableListOf<Boolean>()
- val job = launch { underTest.isFeatureEnabled.toList(values) }
-
- assertThat(values.last()).isFalse()
-
- job.cancel()
- }
}
diff --git a/tests/robotests/src/com/android/customization/model/picker/quickaffordance/domain/interactor/KeyguardQuickAffordancePickerInteractorTest.kt b/tests/robotests/src/com/android/customization/model/picker/quickaffordance/domain/interactor/KeyguardQuickAffordancePickerInteractorTest.kt
index efe9f64d..11098ec6 100644
--- a/tests/robotests/src/com/android/customization/model/picker/quickaffordance/domain/interactor/KeyguardQuickAffordancePickerInteractorTest.kt
+++ b/tests/robotests/src/com/android/customization/model/picker/quickaffordance/domain/interactor/KeyguardQuickAffordancePickerInteractorTest.kt
@@ -62,7 +62,6 @@ class KeyguardQuickAffordancePickerInteractorTest {
repository =
KeyguardQuickAffordancePickerRepository(
client = client,
- backgroundDispatcher = testDispatcher,
),
client = client,
snapshotRestorer = {
diff --git a/tests/robotests/src/com/android/customization/model/picker/quickaffordance/ui/viewmodel/KeyguardQuickAffordancePickerViewModelTest.kt b/tests/robotests/src/com/android/customization/model/picker/quickaffordance/ui/viewmodel/KeyguardQuickAffordancePickerViewModelTest.kt
index f71bfc7d..43b872ea 100644
--- a/tests/robotests/src/com/android/customization/model/picker/quickaffordance/ui/viewmodel/KeyguardQuickAffordancePickerViewModelTest.kt
+++ b/tests/robotests/src/com/android/customization/model/picker/quickaffordance/ui/viewmodel/KeyguardQuickAffordancePickerViewModelTest.kt
@@ -86,7 +86,6 @@ class KeyguardQuickAffordancePickerViewModelTest {
repository =
KeyguardQuickAffordancePickerRepository(
client = client,
- backgroundDispatcher = testDispatcher,
),
client = client,
snapshotRestorer = {