mirror of
https://github.com/bitwarden/android.git
synced 2024-10-31 15:15:34 +03:00
Consolidate username and email autofill views (#757)
This commit is contained in:
parent
ee8b9563a3
commit
be8608e53a
5 changed files with 7 additions and 42 deletions
|
@ -126,10 +126,7 @@ class FilledDataBuilderImpl(
|
|||
val filledItems = autofillViews
|
||||
.map { autofillView ->
|
||||
val value = when (autofillView) {
|
||||
is AutofillView.Login.EmailAddress,
|
||||
is AutofillView.Login.Username,
|
||||
-> autofillCipher.username
|
||||
|
||||
is AutofillView.Login.Username -> autofillCipher.username
|
||||
is AutofillView.Login.Password -> autofillCipher.password
|
||||
}
|
||||
autofillView.buildFilledItemOrNull(
|
||||
|
|
|
@ -68,13 +68,6 @@ sealed class AutofillView {
|
|||
*/
|
||||
sealed class Login : AutofillView() {
|
||||
|
||||
/**
|
||||
* The email address [AutofillView] for the [Login] data partition.
|
||||
*/
|
||||
data class EmailAddress(
|
||||
override val data: Data,
|
||||
) : Login()
|
||||
|
||||
/**
|
||||
* The password [AutofillView] for the [Login] data partition.
|
||||
*/
|
||||
|
|
|
@ -60,19 +60,15 @@ private fun buildAutofillView(
|
|||
)
|
||||
}
|
||||
|
||||
View.AUTOFILL_HINT_EMAIL_ADDRESS -> {
|
||||
AutofillView.Login.EmailAddress(
|
||||
data = autofillViewData,
|
||||
)
|
||||
}
|
||||
|
||||
View.AUTOFILL_HINT_PASSWORD -> {
|
||||
AutofillView.Login.Password(
|
||||
data = autofillViewData,
|
||||
)
|
||||
}
|
||||
|
||||
View.AUTOFILL_HINT_USERNAME -> {
|
||||
View.AUTOFILL_HINT_EMAIL_ADDRESS,
|
||||
View.AUTOFILL_HINT_USERNAME,
|
||||
-> {
|
||||
AutofillView.Login.Username(
|
||||
data = autofillViewData,
|
||||
)
|
||||
|
|
|
@ -67,9 +67,6 @@ class FilledDataBuilderTest {
|
|||
username = username,
|
||||
subtitle = "Subtitle",
|
||||
)
|
||||
val autofillViewEmail = AutofillView.Login.EmailAddress(
|
||||
data = autofillViewData,
|
||||
)
|
||||
val autofillViewPassword = AutofillView.Login.Password(
|
||||
data = autofillViewData,
|
||||
)
|
||||
|
@ -78,7 +75,6 @@ class FilledDataBuilderTest {
|
|||
)
|
||||
val autofillPartition = AutofillPartition.Login(
|
||||
views = listOf(
|
||||
autofillViewEmail,
|
||||
autofillViewPassword,
|
||||
autofillViewUsername,
|
||||
),
|
||||
|
@ -91,13 +87,11 @@ class FilledDataBuilderTest {
|
|||
partition = autofillPartition,
|
||||
uri = URI,
|
||||
)
|
||||
val filledItemEmail: FilledItem = mockk()
|
||||
val filledItemPassword: FilledItem = mockk()
|
||||
val filledItemUsername: FilledItem = mockk()
|
||||
val filledPartition = FilledPartition(
|
||||
autofillCipher = autofillCipher,
|
||||
filledItems = listOf(
|
||||
filledItemEmail,
|
||||
filledItemPassword,
|
||||
filledItemUsername,
|
||||
),
|
||||
|
@ -118,7 +112,6 @@ class FilledDataBuilderTest {
|
|||
uri = URI,
|
||||
)
|
||||
} returns listOf(autofillCipher)
|
||||
every { autofillViewEmail.buildFilledItemOrNull(username) } returns filledItemEmail
|
||||
every { autofillViewPassword.buildFilledItemOrNull(password) } returns filledItemPassword
|
||||
every { autofillViewUsername.buildFilledItemOrNull(username) } returns filledItemUsername
|
||||
|
||||
|
@ -135,7 +128,6 @@ class FilledDataBuilderTest {
|
|||
)
|
||||
}
|
||||
verify(exactly = 1) {
|
||||
autofillViewEmail.buildFilledItemOrNull(username)
|
||||
autofillViewPassword.buildFilledItemOrNull(password)
|
||||
autofillViewUsername.buildFilledItemOrNull(username)
|
||||
}
|
||||
|
@ -145,9 +137,6 @@ class FilledDataBuilderTest {
|
|||
fun `build should return no partitions and ignored AutofillIds when Login and no URI`() =
|
||||
runTest {
|
||||
// Setup
|
||||
val autofillViewEmail = AutofillView.Login.EmailAddress(
|
||||
data = autofillViewData,
|
||||
)
|
||||
val autofillViewPassword = AutofillView.Login.Password(
|
||||
data = autofillViewData,
|
||||
)
|
||||
|
@ -156,7 +145,6 @@ class FilledDataBuilderTest {
|
|||
)
|
||||
val autofillPartition = AutofillPartition.Login(
|
||||
views = listOf(
|
||||
autofillViewEmail,
|
||||
autofillViewPassword,
|
||||
autofillViewUsername,
|
||||
),
|
||||
|
@ -293,9 +281,6 @@ class FilledDataBuilderTest {
|
|||
username = username,
|
||||
subtitle = "Subtitle",
|
||||
)
|
||||
val autofillViewEmail = AutofillView.Login.EmailAddress(
|
||||
data = autofillViewData,
|
||||
)
|
||||
val autofillViewPassword = AutofillView.Login.Password(
|
||||
data = autofillViewData,
|
||||
)
|
||||
|
@ -304,7 +289,6 @@ class FilledDataBuilderTest {
|
|||
)
|
||||
val autofillPartition = AutofillPartition.Login(
|
||||
views = listOf(
|
||||
autofillViewEmail,
|
||||
autofillViewPassword,
|
||||
autofillViewUsername,
|
||||
),
|
||||
|
@ -319,13 +303,11 @@ class FilledDataBuilderTest {
|
|||
partition = autofillPartition,
|
||||
uri = URI,
|
||||
)
|
||||
val filledItemEmail: FilledItem = mockk()
|
||||
val filledItemPassword: FilledItem = mockk()
|
||||
val filledItemUsername: FilledItem = mockk()
|
||||
val filledPartitionOne = FilledPartition(
|
||||
autofillCipher = autofillCipher,
|
||||
filledItems = listOf(
|
||||
filledItemEmail,
|
||||
filledItemPassword,
|
||||
filledItemUsername,
|
||||
),
|
||||
|
@ -335,7 +317,6 @@ class FilledDataBuilderTest {
|
|||
val filledPartitionThree = FilledPartition(
|
||||
autofillCipher = autofillCipher,
|
||||
filledItems = listOf(
|
||||
filledItemEmail,
|
||||
filledItemPassword,
|
||||
filledItemUsername,
|
||||
),
|
||||
|
@ -358,7 +339,6 @@ class FilledDataBuilderTest {
|
|||
uri = URI,
|
||||
)
|
||||
} returns listOf(autofillCipher, autofillCipher, autofillCipher)
|
||||
every { autofillViewEmail.buildFilledItemOrNull(username) } returns filledItemEmail
|
||||
every {
|
||||
autofillViewPassword.buildFilledItemOrNull(password)
|
||||
} returns filledItemPassword
|
||||
|
@ -379,7 +359,6 @@ class FilledDataBuilderTest {
|
|||
)
|
||||
}
|
||||
verify(exactly = 3) {
|
||||
autofillViewEmail.buildFilledItemOrNull(username)
|
||||
autofillViewPassword.buildFilledItemOrNull(password)
|
||||
autofillViewUsername.buildFilledItemOrNull(username)
|
||||
}
|
||||
|
|
|
@ -94,10 +94,10 @@ class ViewNodeExtensionsTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `toAutofillView should return AutofillView Login EmailAddress when hint matches`() {
|
||||
fun `toAutofillView should return AutofillView Login Username when hint is EMAIL`() {
|
||||
// Setup
|
||||
val autofillHint = View.AUTOFILL_HINT_EMAIL_ADDRESS
|
||||
val expected = AutofillView.Login.EmailAddress(
|
||||
val expected = AutofillView.Login.Username(
|
||||
data = autofillViewData,
|
||||
)
|
||||
every { viewNode.autofillHints } returns arrayOf(autofillHint)
|
||||
|
@ -126,7 +126,7 @@ class ViewNodeExtensionsTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `toAutofillView should return AutofillView Login Username when hint matches`() {
|
||||
fun `toAutofillView should return AutofillView Login Username when hint is USERNAME`() {
|
||||
// Setup
|
||||
val autofillHint = View.AUTOFILL_HINT_USERNAME
|
||||
val expected = AutofillView.Login.Username(
|
||||
|
|
Loading…
Reference in a new issue