Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 324ae340 authored by Ale Nijamkin's avatar Ale Nijamkin Committed by Android (Google) Code Review
Browse files

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

parents 4c1411e0 bd86eae9
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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 =
+8 −24
Original line number Diff line number Diff line
@@ -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 ->