mirror of
https://github.com/bitwarden/android.git
synced 2026-03-11 20:54:58 -05:00
[PM-11139] Setting icon on passkeys (#4409)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.x8bit.bitwarden.data.autofill.fido2.processor
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.drawable.Icon
|
||||
import android.os.Build
|
||||
import android.os.CancellationSignal
|
||||
import android.os.OutcomeReceiver
|
||||
@@ -266,6 +267,13 @@ class Fido2ProviderProcessorImpl(
|
||||
),
|
||||
beginGetPublicKeyCredentialOption = option,
|
||||
)
|
||||
.setIcon(
|
||||
Icon
|
||||
.createWithResource(
|
||||
context,
|
||||
R.drawable.ic_bw_passkey,
|
||||
),
|
||||
)
|
||||
.build()
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.x8bit.bitwarden.ui.autofill.fido2.manager
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.graphics.drawable.Icon
|
||||
import android.os.Build
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.credentials.CreatePublicKeyCredentialResponse
|
||||
@@ -117,6 +118,13 @@ class Fido2CompletionManagerImpl(
|
||||
pendingIntent = pendingIntent,
|
||||
beginGetPublicKeyCredentialOption = result.options,
|
||||
)
|
||||
.setIcon(
|
||||
Icon
|
||||
.createWithResource(
|
||||
activity,
|
||||
R.drawable.ic_bw_passkey,
|
||||
),
|
||||
)
|
||||
.build()
|
||||
}
|
||||
PendingIntentHandler
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.x8bit.bitwarden.data.autofill.fido2.processor
|
||||
|
||||
import android.app.PendingIntent
|
||||
import android.content.Context
|
||||
import android.graphics.drawable.Icon
|
||||
import android.os.Bundle
|
||||
import android.os.CancellationSignal
|
||||
import android.os.OutcomeReceiver
|
||||
@@ -46,12 +47,15 @@ import io.mockk.every
|
||||
import io.mockk.just
|
||||
import io.mockk.mockk
|
||||
import io.mockk.mockkConstructor
|
||||
import io.mockk.mockkStatic
|
||||
import io.mockk.runs
|
||||
import io.mockk.slot
|
||||
import io.mockk.unmockkConstructor
|
||||
import io.mockk.unmockkStatic
|
||||
import io.mockk.verify
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.serialization.encodeToString
|
||||
import org.junit.jupiter.api.AfterEach
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.BeforeEach
|
||||
import org.junit.jupiter.api.Test
|
||||
@@ -99,6 +103,13 @@ class Fido2ProviderProcessorTest {
|
||||
clock,
|
||||
dispatcherManager,
|
||||
)
|
||||
|
||||
mockkStatic(Icon::class)
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
fun tearDown() {
|
||||
unmockkStatic(Icon::class)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -477,6 +488,7 @@ class Fido2ProviderProcessorTest {
|
||||
every {
|
||||
anyConstructed<PublicKeyCredentialEntry.Builder>().build()
|
||||
} returns mockPublicKeyCredentialEntry
|
||||
every { Icon.createWithResource(context, any()) } returns mockk<Icon>()
|
||||
|
||||
fido2Processor.processGetCredentialRequest(request, cancellationSignal, callback)
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.x8bit.bitwarden.ui.autofill.fido2.manager
|
||||
import android.app.Activity
|
||||
import android.app.PendingIntent
|
||||
import android.content.Intent
|
||||
import android.graphics.drawable.Icon
|
||||
import androidx.credentials.provider.BeginGetCredentialResponse
|
||||
import androidx.credentials.provider.PendingIntentHandler
|
||||
import androidx.credentials.provider.PublicKeyCredentialEntry
|
||||
@@ -92,6 +93,7 @@ class Fido2CompletionManagerTest {
|
||||
fido2CompletionManager = Fido2CompletionManagerImpl(mockActivity, mockIntentManager)
|
||||
mockkConstructor(Intent::class)
|
||||
mockkObject(PendingIntentHandler.Companion)
|
||||
mockkStatic(Icon::class)
|
||||
every {
|
||||
PendingIntentHandler.setCreateCredentialException(any(), any())
|
||||
} just runs
|
||||
@@ -105,6 +107,7 @@ class Fido2CompletionManagerTest {
|
||||
unmockkConstructor(Intent::class, PublicKeyCredentialEntry.Builder::class)
|
||||
unmockkObject(PendingIntentHandler.Companion)
|
||||
unmockkStatic(PendingIntent::class)
|
||||
unmockkStatic(Icon::class)
|
||||
}
|
||||
|
||||
@Suppress("MaxLineLength")
|
||||
@@ -206,6 +209,7 @@ class Fido2CompletionManagerTest {
|
||||
)
|
||||
} returns mockk()
|
||||
every { mockActivity.getString(any()) } returns "No username"
|
||||
every { Icon.createWithResource(mockActivity, any()) } returns mockk<Icon>()
|
||||
|
||||
fido2CompletionManager
|
||||
.completeFido2GetCredentialRequest(
|
||||
@@ -256,6 +260,7 @@ class Fido2CompletionManagerTest {
|
||||
)
|
||||
} returns mockk()
|
||||
every { mockActivity.getString(any()) } returns "No Username"
|
||||
every { Icon.createWithResource(mockActivity, any()) } returns mockk<Icon>()
|
||||
|
||||
fido2CompletionManager
|
||||
.completeFido2GetCredentialRequest(
|
||||
|
||||
Reference in New Issue
Block a user