Remove scaffolding for identity autofill (#563)

This commit is contained in:
Lucas Kivi
2024-01-10 13:00:31 -06:00
committed by GitHub
parent d90f79ed2d
commit 451599b85a
7 changed files with 7 additions and 219 deletions

View File

@@ -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()

View File

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

View File

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