Merge "Show wallet option in picker even if not set up." into tm-qpr-dev

This commit is contained in:
Ale Nijamkin
2023-01-19 00:50:03 +00:00
committed by Android (Google) Code Review
2 changed files with 10 additions and 26 deletions

View File

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

View File

@@ -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)
@@ -165,7 +153,7 @@ class QuickAccessWalletKeyguardQuickAffordanceConfigTest : SysuiTestCase() {
@Test
fun `getPickerScreenState - unavailable`() = runTest {
setUpState(
isWalletEnabled = false,
isWalletServiceAvailable = false,
)
assertThat(underTest.getPickerScreenState())
@@ -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())
@@ -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 ->