Loading packages/SystemUI/src/com/android/systemui/keyguard/data/quickaffordance/QuickAccessWalletKeyguardQuickAffordanceConfig.kt +2 −2 Original line number Diff line number Diff line Loading @@ -100,9 +100,9 @@ constructor( override suspend fun getPickerScreenState(): KeyguardQuickAffordanceConfig.PickerScreenState { return when { !walletController.isWalletEnabled -> !walletController.walletClient.isWalletServiceAvailable -> KeyguardQuickAffordanceConfig.PickerScreenState.UnavailableOnDevice walletController.walletClient.tileIcon == null || queryCards().isEmpty() -> { !walletController.isWalletEnabled || queryCards().isEmpty() -> { val componentName = walletController.walletClient.createWalletSettingsIntent().toComponentName() val actionText = Loading packages/SystemUI/tests/src/com/android/systemui/keyguard/data/quickaffordance/QuickAccessWalletKeyguardQuickAffordanceConfigTest.kt +8 −24 Original line number Diff line number Diff line Loading @@ -113,21 +113,9 @@ class QuickAccessWalletKeyguardQuickAffordanceConfigTest : SysuiTestCase() { job.cancel() } @Test fun `affordance - missing icon - model is none`() = runBlockingTest { setUpState(hasWalletIcon = false) var latest: KeyguardQuickAffordanceConfig.LockScreenState? = null val job = underTest.lockScreenState.onEach { latest = it }.launchIn(this) assertThat(latest).isEqualTo(KeyguardQuickAffordanceConfig.LockScreenState.Hidden) job.cancel() } @Test fun `affordance - no selected card - model is none`() = runBlockingTest { setUpState(hasWalletIcon = false) setUpState(hasSelectedCard = false) var latest: KeyguardQuickAffordanceConfig.LockScreenState? = null val job = underTest.lockScreenState.onEach { latest = it }.launchIn(this) Loading Loading @@ -165,7 +153,7 @@ class QuickAccessWalletKeyguardQuickAffordanceConfigTest : SysuiTestCase() { @Test fun `getPickerScreenState - unavailable`() = runTest { setUpState( isWalletEnabled = false, isWalletServiceAvailable = false, ) assertThat(underTest.getPickerScreenState()) Loading @@ -173,9 +161,9 @@ class QuickAccessWalletKeyguardQuickAffordanceConfigTest : SysuiTestCase() { } @Test fun `getPickerScreenState - disabled when there is no icon`() = runTest { fun `getPickerScreenState - disabled when the feature is not enabled`() = runTest { setUpState( hasWalletIcon = false, isWalletEnabled = false, ) assertThat(underTest.getPickerScreenState()) Loading @@ -194,20 +182,16 @@ class QuickAccessWalletKeyguardQuickAffordanceConfigTest : SysuiTestCase() { private fun setUpState( isWalletEnabled: Boolean = true, isWalletServiceAvailable: Boolean = true, isWalletQuerySuccessful: Boolean = true, hasWalletIcon: Boolean = true, hasSelectedCard: Boolean = true, ) { whenever(walletController.isWalletEnabled).thenReturn(isWalletEnabled) val walletClient: QuickAccessWalletClient = mock() val icon: Drawable? = if (hasWalletIcon) { ICON } else { null } whenever(walletClient.tileIcon).thenReturn(icon) whenever(walletClient.tileIcon).thenReturn(ICON) whenever(walletClient.isWalletServiceAvailable).thenReturn(isWalletServiceAvailable) whenever(walletController.walletClient).thenReturn(walletClient) whenever(walletController.queryWalletCards(any())).thenAnswer { invocation -> Loading Loading
packages/SystemUI/src/com/android/systemui/keyguard/data/quickaffordance/QuickAccessWalletKeyguardQuickAffordanceConfig.kt +2 −2 Original line number Diff line number Diff line Loading @@ -100,9 +100,9 @@ constructor( override suspend fun getPickerScreenState(): KeyguardQuickAffordanceConfig.PickerScreenState { return when { !walletController.isWalletEnabled -> !walletController.walletClient.isWalletServiceAvailable -> KeyguardQuickAffordanceConfig.PickerScreenState.UnavailableOnDevice walletController.walletClient.tileIcon == null || queryCards().isEmpty() -> { !walletController.isWalletEnabled || queryCards().isEmpty() -> { val componentName = walletController.walletClient.createWalletSettingsIntent().toComponentName() val actionText = Loading
packages/SystemUI/tests/src/com/android/systemui/keyguard/data/quickaffordance/QuickAccessWalletKeyguardQuickAffordanceConfigTest.kt +8 −24 Original line number Diff line number Diff line Loading @@ -113,21 +113,9 @@ class QuickAccessWalletKeyguardQuickAffordanceConfigTest : SysuiTestCase() { job.cancel() } @Test fun `affordance - missing icon - model is none`() = runBlockingTest { setUpState(hasWalletIcon = false) var latest: KeyguardQuickAffordanceConfig.LockScreenState? = null val job = underTest.lockScreenState.onEach { latest = it }.launchIn(this) assertThat(latest).isEqualTo(KeyguardQuickAffordanceConfig.LockScreenState.Hidden) job.cancel() } @Test fun `affordance - no selected card - model is none`() = runBlockingTest { setUpState(hasWalletIcon = false) setUpState(hasSelectedCard = false) var latest: KeyguardQuickAffordanceConfig.LockScreenState? = null val job = underTest.lockScreenState.onEach { latest = it }.launchIn(this) Loading Loading @@ -165,7 +153,7 @@ class QuickAccessWalletKeyguardQuickAffordanceConfigTest : SysuiTestCase() { @Test fun `getPickerScreenState - unavailable`() = runTest { setUpState( isWalletEnabled = false, isWalletServiceAvailable = false, ) assertThat(underTest.getPickerScreenState()) Loading @@ -173,9 +161,9 @@ class QuickAccessWalletKeyguardQuickAffordanceConfigTest : SysuiTestCase() { } @Test fun `getPickerScreenState - disabled when there is no icon`() = runTest { fun `getPickerScreenState - disabled when the feature is not enabled`() = runTest { setUpState( hasWalletIcon = false, isWalletEnabled = false, ) assertThat(underTest.getPickerScreenState()) Loading @@ -194,20 +182,16 @@ class QuickAccessWalletKeyguardQuickAffordanceConfigTest : SysuiTestCase() { private fun setUpState( isWalletEnabled: Boolean = true, isWalletServiceAvailable: Boolean = true, isWalletQuerySuccessful: Boolean = true, hasWalletIcon: Boolean = true, hasSelectedCard: Boolean = true, ) { whenever(walletController.isWalletEnabled).thenReturn(isWalletEnabled) val walletClient: QuickAccessWalletClient = mock() val icon: Drawable? = if (hasWalletIcon) { ICON } else { null } whenever(walletClient.tileIcon).thenReturn(icon) whenever(walletClient.tileIcon).thenReturn(ICON) whenever(walletClient.isWalletServiceAvailable).thenReturn(isWalletServiceAvailable) whenever(walletController.walletClient).thenReturn(walletClient) whenever(walletController.queryWalletCards(any())).thenAnswer { invocation -> Loading