mirror of
https://github.com/bitwarden/android.git
synced 2024-11-27 12:00:19 +03:00
Remove scaffolding for identity autofill (#563)
This commit is contained in:
parent
9c023bca9e
commit
75a08e72a6
7 changed files with 7 additions and 219 deletions
|
@ -16,13 +16,6 @@ sealed class AutofillPartition {
|
|||
override val views: List<AutofillView.Card>,
|
||||
) : AutofillPartition()
|
||||
|
||||
/**
|
||||
* The identity [AutofillPartition] data.
|
||||
*/
|
||||
data class Identity(
|
||||
override val views: List<AutofillView.Identity>,
|
||||
) : AutofillPartition()
|
||||
|
||||
/**
|
||||
* The login [AutofillPartition] data.
|
||||
*/
|
||||
|
|
|
@ -54,44 +54,6 @@ sealed class AutofillView {
|
|||
) : Card()
|
||||
}
|
||||
|
||||
/**
|
||||
* A view that corresponds to the personal info data partition for autofill fields.
|
||||
*/
|
||||
sealed class Identity : AutofillView() {
|
||||
|
||||
/**
|
||||
* The name [AutofillView] for the [Identity] data partition.
|
||||
*/
|
||||
data class Name(
|
||||
override val autofillId: AutofillId,
|
||||
override val isFocused: Boolean,
|
||||
) : Identity()
|
||||
|
||||
/**
|
||||
* The phone number [AutofillView] for the [Identity] data partition.
|
||||
*/
|
||||
data class PhoneNumber(
|
||||
override val autofillId: AutofillId,
|
||||
override val isFocused: Boolean,
|
||||
) : Identity()
|
||||
|
||||
/**
|
||||
* The postal address [AutofillView] for the [Identity] data partition.
|
||||
*/
|
||||
data class PostalAddress(
|
||||
override val autofillId: AutofillId,
|
||||
override val isFocused: Boolean,
|
||||
) : Identity()
|
||||
|
||||
/**
|
||||
* The postal code [AutofillView] for the [Identity] data partition.
|
||||
*/
|
||||
data class PostalCode(
|
||||
override val autofillId: AutofillId,
|
||||
override val isFocused: Boolean,
|
||||
) : Identity()
|
||||
}
|
||||
|
||||
/**
|
||||
* A view that corresponds to the login data partition for autofill fields.
|
||||
*/
|
||||
|
|
|
@ -33,12 +33,6 @@ class AutofillParserImpl : AutofillParser {
|
|||
)
|
||||
}
|
||||
|
||||
is AutofillView.Identity -> {
|
||||
AutofillPartition.Identity(
|
||||
views = autofillViews.filterIsInstance<AutofillView.Identity>(),
|
||||
)
|
||||
}
|
||||
|
||||
is AutofillView.Login -> {
|
||||
AutofillPartition.Login(
|
||||
views = autofillViews.filterIsInstance<AutofillView.Login>(),
|
||||
|
|
|
@ -68,13 +68,6 @@ private fun buildAutofillView(
|
|||
)
|
||||
}
|
||||
|
||||
View.AUTOFILL_HINT_NAME -> {
|
||||
AutofillView.Identity.Name(
|
||||
autofillId = autofillId,
|
||||
isFocused = isFocused,
|
||||
)
|
||||
}
|
||||
|
||||
View.AUTOFILL_HINT_PASSWORD -> {
|
||||
AutofillView.Login.Password(
|
||||
autofillId = autofillId,
|
||||
|
@ -82,27 +75,6 @@ private fun buildAutofillView(
|
|||
)
|
||||
}
|
||||
|
||||
View.AUTOFILL_HINT_PHONE -> {
|
||||
AutofillView.Identity.PhoneNumber(
|
||||
autofillId = autofillId,
|
||||
isFocused = isFocused,
|
||||
)
|
||||
}
|
||||
|
||||
View.AUTOFILL_HINT_POSTAL_ADDRESS -> {
|
||||
AutofillView.Identity.PostalAddress(
|
||||
autofillId = autofillId,
|
||||
isFocused = isFocused,
|
||||
)
|
||||
}
|
||||
|
||||
View.AUTOFILL_HINT_POSTAL_CODE -> {
|
||||
AutofillView.Identity.PostalCode(
|
||||
autofillId = autofillId,
|
||||
isFocused = isFocused,
|
||||
)
|
||||
}
|
||||
|
||||
View.AUTOFILL_HINT_USERNAME -> {
|
||||
AutofillView.Login.Username(
|
||||
autofillId = autofillId,
|
||||
|
@ -122,10 +94,6 @@ private val SUPPORTED_HINTS: List<String> = listOf(
|
|||
View.AUTOFILL_HINT_CREDIT_CARD_NUMBER,
|
||||
View.AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE,
|
||||
View.AUTOFILL_HINT_EMAIL_ADDRESS,
|
||||
View.AUTOFILL_HINT_NAME,
|
||||
View.AUTOFILL_HINT_PASSWORD,
|
||||
View.AUTOFILL_HINT_PHONE,
|
||||
View.AUTOFILL_HINT_POSTAL_ADDRESS,
|
||||
View.AUTOFILL_HINT_POSTAL_CODE,
|
||||
View.AUTOFILL_HINT_USERNAME,
|
||||
)
|
||||
|
|
|
@ -24,11 +24,11 @@ class FilledDataBuilderTest {
|
|||
fun `build should return FilledData with FilledItems and ignored AutofillIds`() = runTest {
|
||||
// Setup
|
||||
val autofillId: AutofillId = mockk()
|
||||
val autofillView = AutofillView.Identity.PostalCode(
|
||||
val autofillView = AutofillView.Login.Username(
|
||||
autofillId = autofillId,
|
||||
isFocused = false,
|
||||
)
|
||||
val autofillPartition = AutofillPartition.Identity(
|
||||
val autofillPartition = AutofillPartition.Login(
|
||||
views = listOf(autofillView),
|
||||
)
|
||||
val ignoreAutofillIds: List<AutofillId> = mockk()
|
||||
|
|
|
@ -27,13 +27,6 @@ class AutofillParserTests {
|
|||
every { this@mockk.autofillId } returns cardAutofillId
|
||||
every { this@mockk.childCount } returns 0
|
||||
}
|
||||
private val identityAutofillHint = View.AUTOFILL_HINT_NAME
|
||||
private val identityAutofillId: AutofillId = mockk()
|
||||
private val identityViewNode: AssistStructure.ViewNode = mockk {
|
||||
every { this@mockk.autofillHints } returns arrayOf(identityAutofillHint)
|
||||
every { this@mockk.autofillId } returns identityAutofillId
|
||||
every { this@mockk.childCount } returns 0
|
||||
}
|
||||
private val loginAutofillHint = View.AUTOFILL_HINT_USERNAME
|
||||
private val loginAutofillId: AutofillId = mockk()
|
||||
private val loginViewNode: AssistStructure.ViewNode = mockk {
|
||||
|
@ -44,9 +37,6 @@ class AutofillParserTests {
|
|||
private val cardWindowNode: AssistStructure.WindowNode = mockk {
|
||||
every { this@mockk.rootViewNode } returns cardViewNode
|
||||
}
|
||||
private val identityWindowNode: AssistStructure.WindowNode = mockk {
|
||||
every { this@mockk.rootViewNode } returns identityViewNode
|
||||
}
|
||||
private val loginWindowNode: AssistStructure.WindowNode = mockk {
|
||||
every { this@mockk.rootViewNode } returns loginViewNode
|
||||
}
|
||||
|
@ -128,10 +118,6 @@ class AutofillParserTests {
|
|||
autofillId = cardAutofillId,
|
||||
isFocused = true,
|
||||
)
|
||||
val identityAutofillView: AutofillView.Identity = AutofillView.Identity.Name(
|
||||
autofillId = identityAutofillId,
|
||||
isFocused = false,
|
||||
)
|
||||
val loginAutofillView: AutofillView.Login = AutofillView.Login.Username(
|
||||
autofillId = loginAutofillId,
|
||||
isFocused = false,
|
||||
|
@ -144,41 +130,6 @@ class AutofillParserTests {
|
|||
partition = autofillPartition,
|
||||
)
|
||||
every { cardViewNode.toAutofillView() } returns cardAutofillView
|
||||
every { identityViewNode.toAutofillView() } returns identityAutofillView
|
||||
every { loginViewNode.toAutofillView() } returns loginAutofillView
|
||||
|
||||
// Test
|
||||
val actual = parser.parse(assistStructure)
|
||||
|
||||
// Verify
|
||||
assertEquals(expected, actual)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `parse should choose AutofillPartition Identity when an Identity view is focused`() {
|
||||
// Setup
|
||||
setupAssistStructureWithAllAutofillViewTypes()
|
||||
val cardAutofillView: AutofillView.Card = AutofillView.Card.ExpirationMonth(
|
||||
autofillId = cardAutofillId,
|
||||
isFocused = false,
|
||||
)
|
||||
val identityAutofillView: AutofillView.Identity = AutofillView.Identity.Name(
|
||||
autofillId = identityAutofillId,
|
||||
isFocused = true,
|
||||
)
|
||||
val loginAutofillView: AutofillView.Login = AutofillView.Login.Username(
|
||||
autofillId = loginAutofillId,
|
||||
isFocused = false,
|
||||
)
|
||||
val autofillPartition = AutofillPartition.Identity(
|
||||
views = listOf(identityAutofillView),
|
||||
)
|
||||
val expected = AutofillRequest.Fillable(
|
||||
ignoreAutofillIds = emptyList(),
|
||||
partition = autofillPartition,
|
||||
)
|
||||
every { cardViewNode.toAutofillView() } returns cardAutofillView
|
||||
every { identityViewNode.toAutofillView() } returns identityAutofillView
|
||||
every { loginViewNode.toAutofillView() } returns loginAutofillView
|
||||
|
||||
// Test
|
||||
|
@ -196,10 +147,6 @@ class AutofillParserTests {
|
|||
autofillId = cardAutofillId,
|
||||
isFocused = false,
|
||||
)
|
||||
val identityAutofillView: AutofillView.Identity = AutofillView.Identity.Name(
|
||||
autofillId = identityAutofillId,
|
||||
isFocused = false,
|
||||
)
|
||||
val loginAutofillView: AutofillView.Login = AutofillView.Login.Username(
|
||||
autofillId = loginAutofillId,
|
||||
isFocused = true,
|
||||
|
@ -212,7 +159,6 @@ class AutofillParserTests {
|
|||
partition = autofillPartition,
|
||||
)
|
||||
every { cardViewNode.toAutofillView() } returns cardAutofillView
|
||||
every { identityViewNode.toAutofillView() } returns identityAutofillView
|
||||
every { loginViewNode.toAutofillView() } returns loginAutofillView
|
||||
|
||||
// Test
|
||||
|
@ -230,13 +176,9 @@ class AutofillParserTests {
|
|||
autofillId = cardAutofillId,
|
||||
isFocused = true,
|
||||
)
|
||||
val identityAutofillView: AutofillView.Identity = AutofillView.Identity.Name(
|
||||
autofillId = identityAutofillId,
|
||||
isFocused = true,
|
||||
)
|
||||
val loginAutofillView: AutofillView.Login = AutofillView.Login.Username(
|
||||
autofillId = loginAutofillId,
|
||||
isFocused = false,
|
||||
isFocused = true,
|
||||
)
|
||||
val autofillPartition = AutofillPartition.Card(
|
||||
views = listOf(cardAutofillView),
|
||||
|
@ -246,7 +188,6 @@ class AutofillParserTests {
|
|||
partition = autofillPartition,
|
||||
)
|
||||
every { cardViewNode.toAutofillView() } returns cardAutofillView
|
||||
every { identityViewNode.toAutofillView() } returns identityAutofillView
|
||||
every { loginViewNode.toAutofillView() } returns loginAutofillView
|
||||
|
||||
// Test
|
||||
|
@ -257,14 +198,12 @@ class AutofillParserTests {
|
|||
}
|
||||
|
||||
/**
|
||||
* Setup [assistStructure] to return window nodes with each [AutofillView] type (card, identity,
|
||||
* and login) so we can test how different window node configurations produce different
|
||||
* partitions.
|
||||
* Setup [assistStructure] to return window nodes with each [AutofillView] type (card and login)
|
||||
* so we can test how different window node configurations produce different partitions.
|
||||
*/
|
||||
private fun setupAssistStructureWithAllAutofillViewTypes() {
|
||||
every { assistStructure.windowNodeCount } returns 3
|
||||
every { assistStructure.windowNodeCount } returns 2
|
||||
every { assistStructure.getWindowNodeAt(0) } returns cardWindowNode
|
||||
every { assistStructure.getWindowNodeAt(1) } returns identityWindowNode
|
||||
every { assistStructure.getWindowNodeAt(2) } returns loginWindowNode
|
||||
every { assistStructure.getWindowNodeAt(1) } returns loginWindowNode
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,23 +104,6 @@ class ViewNodeExtensionsTest {
|
|||
assertEquals(expected, actual)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `toAutofillView should return AutofillView Identity Name when hint matches`() {
|
||||
// Setup
|
||||
val autofillHint = View.AUTOFILL_HINT_NAME
|
||||
val expected = AutofillView.Identity.Name(
|
||||
autofillId = expectedAutofillId,
|
||||
isFocused = expectedIsFocused,
|
||||
)
|
||||
every { viewNode.autofillHints } returns arrayOf(autofillHint)
|
||||
|
||||
// Test
|
||||
val actual = viewNode.toAutofillView()
|
||||
|
||||
// Verify
|
||||
assertEquals(expected, actual)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `toAutofillView should return AutofillView Login Password when hint matches`() {
|
||||
// Setup
|
||||
|
@ -138,57 +121,6 @@ class ViewNodeExtensionsTest {
|
|||
assertEquals(expected, actual)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `toAutofillView should return AutofillView Identity PhoneNumber when hint matches`() {
|
||||
// Setup
|
||||
val autofillHint = View.AUTOFILL_HINT_PHONE
|
||||
val expected = AutofillView.Identity.PhoneNumber(
|
||||
autofillId = expectedAutofillId,
|
||||
isFocused = expectedIsFocused,
|
||||
)
|
||||
every { viewNode.autofillHints } returns arrayOf(autofillHint)
|
||||
|
||||
// Test
|
||||
val actual = viewNode.toAutofillView()
|
||||
|
||||
// Verify
|
||||
assertEquals(expected, actual)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `toAutofillView should return AutofillView Identity PostalAddress when hint matches`() {
|
||||
// Setup
|
||||
val autofillHint = View.AUTOFILL_HINT_POSTAL_ADDRESS
|
||||
val expected = AutofillView.Identity.PostalAddress(
|
||||
autofillId = expectedAutofillId,
|
||||
isFocused = expectedIsFocused,
|
||||
)
|
||||
every { viewNode.autofillHints } returns arrayOf(autofillHint)
|
||||
|
||||
// Test
|
||||
val actual = viewNode.toAutofillView()
|
||||
|
||||
// Verify
|
||||
assertEquals(expected, actual)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `toAutofillView should return AutofillView Identity PostalCOde when hint matches`() {
|
||||
// Setup
|
||||
val autofillHint = View.AUTOFILL_HINT_POSTAL_CODE
|
||||
val expected = AutofillView.Identity.PostalCode(
|
||||
autofillId = expectedAutofillId,
|
||||
isFocused = expectedIsFocused,
|
||||
)
|
||||
every { viewNode.autofillHints } returns arrayOf(autofillHint)
|
||||
|
||||
// Test
|
||||
val actual = viewNode.toAutofillView()
|
||||
|
||||
// Verify
|
||||
assertEquals(expected, actual)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `toAutofillView should return AutofillView Login Username when hint matches`() {
|
||||
// Setup
|
||||
|
|
Loading…
Reference in a new issue