mirror of
https://github.com/bitwarden/android.git
synced 2026-04-30 12:59:02 -05:00
PM-26896: Fix Autofill ancestry
This commit is contained in:
@@ -160,9 +160,7 @@ class AutofillParserImpl(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Flatten the ignorable autofill ids.
|
// Flatten the ignorable autofill ids.
|
||||||
val ignoreAutofillIds = traversalDataList
|
val ignoreAutofillIds = traversalDataList.flatMap { it.ignoreAutofillIds }
|
||||||
.map { it.ignoreAutofillIds }
|
|
||||||
.flatten()
|
|
||||||
|
|
||||||
// Get inline information if available
|
// Get inline information if available
|
||||||
val isInlineAutofillEnabled = settingsRepository.isInlineAutofillEnabled
|
val isInlineAutofillEnabled = settingsRepository.isInlineAutofillEnabled
|
||||||
@@ -196,7 +194,7 @@ private fun AssistStructure.traverse(): List<ViewNodeTraversalData> =
|
|||||||
.mapNotNull { windowNode ->
|
.mapNotNull { windowNode ->
|
||||||
windowNode
|
windowNode
|
||||||
.rootViewNode
|
.rootViewNode
|
||||||
?.traverse(parentWebsite = null)
|
?.traverse()
|
||||||
?.updateForMissingPasswordFields()
|
?.updateForMissingPasswordFields()
|
||||||
?.updateForMissingUsernameFields()
|
?.updateForMissingUsernameFields()
|
||||||
}
|
}
|
||||||
@@ -274,9 +272,7 @@ private fun ViewNodeTraversalData.copyAndMapAutofillViews(
|
|||||||
* Recursively traverse this [AssistStructure.ViewNode] and all of its descendants. Convert the
|
* Recursively traverse this [AssistStructure.ViewNode] and all of its descendants. Convert the
|
||||||
* data into [ViewNodeTraversalData].
|
* data into [ViewNodeTraversalData].
|
||||||
*/
|
*/
|
||||||
private fun AssistStructure.ViewNode.traverse(
|
private fun AssistStructure.ViewNode.traverse(): ViewNodeTraversalData {
|
||||||
parentWebsite: String?,
|
|
||||||
): ViewNodeTraversalData {
|
|
||||||
// Set up mutable lists for collecting valid AutofillViews and ignorable view ids.
|
// Set up mutable lists for collecting valid AutofillViews and ignorable view ids.
|
||||||
val mutableAutofillViewList: MutableList<AutofillView> = mutableListOf()
|
val mutableAutofillViewList: MutableList<AutofillView> = mutableListOf()
|
||||||
val mutableIgnoreAutofillIdList: MutableList<AutofillId> = mutableListOf()
|
val mutableIgnoreAutofillIdList: MutableList<AutofillId> = mutableListOf()
|
||||||
@@ -292,7 +288,7 @@ private fun AssistStructure.ViewNode.traverse(
|
|||||||
|
|
||||||
// Try converting this `ViewNode` into an `AutofillView`. If a valid instance is returned, add
|
// Try converting this `ViewNode` into an `AutofillView`. If a valid instance is returned, add
|
||||||
// it to the list. Otherwise, ignore the `AutofillId` associated with this `ViewNode`.
|
// it to the list. Otherwise, ignore the `AutofillId` associated with this `ViewNode`.
|
||||||
toAutofillView(parentWebsite = parentWebsite)
|
toAutofillView()
|
||||||
?.run(mutableAutofillViewList::add)
|
?.run(mutableAutofillViewList::add)
|
||||||
?: autofillId?.run(mutableIgnoreAutofillIdList::add)
|
?: autofillId?.run(mutableIgnoreAutofillIdList::add)
|
||||||
|
|
||||||
@@ -300,7 +296,7 @@ private fun AssistStructure.ViewNode.traverse(
|
|||||||
for (i in 0 until childCount) {
|
for (i in 0 until childCount) {
|
||||||
// Extract the traversal data from each child view node and add it to the lists.
|
// Extract the traversal data from each child view node and add it to the lists.
|
||||||
getChildAt(i)
|
getChildAt(i)
|
||||||
.traverse(parentWebsite = website)
|
.traverse()
|
||||||
.let { viewNodeTraversalData ->
|
.let { viewNodeTraversalData ->
|
||||||
viewNodeTraversalData.autofillViews.forEach(mutableAutofillViewList::add)
|
viewNodeTraversalData.autofillViews.forEach(mutableAutofillViewList::add)
|
||||||
viewNodeTraversalData.ignoreAutofillIds.forEach(mutableIgnoreAutofillIdList::add)
|
viewNodeTraversalData.ignoreAutofillIds.forEach(mutableIgnoreAutofillIdList::add)
|
||||||
|
|||||||
@@ -49,9 +49,7 @@ private val AssistStructure.ViewNode.isInputField: Boolean
|
|||||||
* doesn't contain a valid autofillId, it isn't an a view setup for autofill, so we return null. If
|
* doesn't contain a valid autofillId, it isn't an a view setup for autofill, so we return null. If
|
||||||
* it doesn't have a supported hint and isn't an input field, we also return null.
|
* it doesn't have a supported hint and isn't an input field, we also return null.
|
||||||
*/
|
*/
|
||||||
fun AssistStructure.ViewNode.toAutofillView(
|
fun AssistStructure.ViewNode.toAutofillView(): AutofillView? {
|
||||||
parentWebsite: String?,
|
|
||||||
): AutofillView? {
|
|
||||||
val nonNullAutofillId = this.autofillId ?: return null
|
val nonNullAutofillId = this.autofillId ?: return null
|
||||||
if (this.supportedAutofillHint == null && !this.isInputField) return null
|
if (this.supportedAutofillHint == null && !this.isInputField) return null
|
||||||
val autofillOptions = this
|
val autofillOptions = this
|
||||||
@@ -65,7 +63,7 @@ fun AssistStructure.ViewNode.toAutofillView(
|
|||||||
isFocused = this.isFocused,
|
isFocused = this.isFocused,
|
||||||
textValue = this.autofillValue?.extractTextValue(),
|
textValue = this.autofillValue?.extractTextValue(),
|
||||||
hasPasswordTerms = this.hasPasswordTerms(),
|
hasPasswordTerms = this.hasPasswordTerms(),
|
||||||
website = this.website ?: parentWebsite,
|
website = this.website,
|
||||||
)
|
)
|
||||||
return buildAutofillView(
|
return buildAutofillView(
|
||||||
autofillOptions = autofillOptions,
|
autofillOptions = autofillOptions,
|
||||||
|
|||||||
@@ -211,7 +211,7 @@ class AutofillParserTests {
|
|||||||
website = null,
|
website = null,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
every { loginViewNode.toAutofillView(parentWebsite = any()) } returns loginAutofillView
|
every { loginViewNode.toAutofillView() } returns loginAutofillView
|
||||||
val autofillPartition = AutofillPartition.Login(
|
val autofillPartition = AutofillPartition.Login(
|
||||||
views = listOf(
|
views = listOf(
|
||||||
loginAutofillView.copy(data = loginAutofillView.data.copy(website = website)),
|
loginAutofillView.copy(data = loginAutofillView.data.copy(website = website)),
|
||||||
@@ -259,7 +259,7 @@ class AutofillParserTests {
|
|||||||
every { this@mockk.childCount } returns 0
|
every { this@mockk.childCount } returns 0
|
||||||
every { this@mockk.idPackage } returns null
|
every { this@mockk.idPackage } returns null
|
||||||
every { this@mockk.isFocused } returns false
|
every { this@mockk.isFocused } returns false
|
||||||
every { this@mockk.toAutofillView(parentWebsite = any()) } returns null
|
every { this@mockk.toAutofillView() } returns null
|
||||||
every { this@mockk.website } returns null
|
every { this@mockk.website } returns null
|
||||||
}
|
}
|
||||||
// `invalidChildViewNode` simulates the OS assigning a node's idPackage to "android", which
|
// `invalidChildViewNode` simulates the OS assigning a node's idPackage to "android", which
|
||||||
@@ -272,7 +272,7 @@ class AutofillParserTests {
|
|||||||
every { this@mockk.childCount } returns 0
|
every { this@mockk.childCount } returns 0
|
||||||
every { this@mockk.idPackage } returns ID_PACKAGE_ANDROID
|
every { this@mockk.idPackage } returns ID_PACKAGE_ANDROID
|
||||||
every { this@mockk.isFocused } returns false
|
every { this@mockk.isFocused } returns false
|
||||||
every { this@mockk.toAutofillView(parentWebsite = any()) } returns null
|
every { this@mockk.toAutofillView() } returns null
|
||||||
every { this@mockk.website } returns null
|
every { this@mockk.website } returns null
|
||||||
}
|
}
|
||||||
val parentAutofillHint = View.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR
|
val parentAutofillHint = View.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR
|
||||||
@@ -293,7 +293,7 @@ class AutofillParserTests {
|
|||||||
every { this@mockk.autofillHints } returns arrayOf(parentAutofillHint)
|
every { this@mockk.autofillHints } returns arrayOf(parentAutofillHint)
|
||||||
every { this@mockk.autofillId } returns parentAutofillId
|
every { this@mockk.autofillId } returns parentAutofillId
|
||||||
every { this@mockk.idPackage } returns null
|
every { this@mockk.idPackage } returns null
|
||||||
every { this@mockk.toAutofillView(parentWebsite = any()) } returns parentAutofillView
|
every { this@mockk.toAutofillView() } returns parentAutofillView
|
||||||
every { this@mockk.childCount } returns 2
|
every { this@mockk.childCount } returns 2
|
||||||
every { this@mockk.getChildAt(0) } returns childViewNode
|
every { this@mockk.getChildAt(0) } returns childViewNode
|
||||||
every { this@mockk.getChildAt(1) } returns invalidChildViewNode
|
every { this@mockk.getChildAt(1) } returns invalidChildViewNode
|
||||||
@@ -379,8 +379,8 @@ class AutofillParserTests {
|
|||||||
partition = autofillPartition,
|
partition = autofillPartition,
|
||||||
uri = URI,
|
uri = URI,
|
||||||
)
|
)
|
||||||
every { cardViewNode.toAutofillView(parentWebsite = any()) } returns cardAutofillView
|
every { cardViewNode.toAutofillView() } returns cardAutofillView
|
||||||
every { loginViewNode.toAutofillView(parentWebsite = any()) } returns loginAutofillView
|
every { loginViewNode.toAutofillView() } returns loginAutofillView
|
||||||
|
|
||||||
// Test
|
// Test
|
||||||
val actual = parser.parse(
|
val actual = parser.parse(
|
||||||
@@ -442,8 +442,8 @@ class AutofillParserTests {
|
|||||||
partition = autofillPartition,
|
partition = autofillPartition,
|
||||||
uri = URI,
|
uri = URI,
|
||||||
)
|
)
|
||||||
every { cardViewNode.toAutofillView(parentWebsite = any()) } returns cardAutofillView
|
every { cardViewNode.toAutofillView() } returns cardAutofillView
|
||||||
every { loginViewNode.toAutofillView(parentWebsite = any()) } returns loginAutofillView
|
every { loginViewNode.toAutofillView() } returns loginAutofillView
|
||||||
|
|
||||||
// Test
|
// Test
|
||||||
val actual = parser.parse(
|
val actual = parser.parse(
|
||||||
@@ -498,7 +498,7 @@ class AutofillParserTests {
|
|||||||
partition = autofillPartition,
|
partition = autofillPartition,
|
||||||
uri = URI,
|
uri = URI,
|
||||||
)
|
)
|
||||||
every { loginViewNode.toAutofillView(parentWebsite = any()) } returns unusedAutofillView
|
every { loginViewNode.toAutofillView() } returns unusedAutofillView
|
||||||
|
|
||||||
// Test
|
// Test
|
||||||
val actual = parser.parse(
|
val actual = parser.parse(
|
||||||
@@ -601,13 +601,9 @@ class AutofillParserTests {
|
|||||||
partition = autofillPartition,
|
partition = autofillPartition,
|
||||||
uri = URI,
|
uri = URI,
|
||||||
)
|
)
|
||||||
every { rootViewNode.toAutofillView(parentWebsite = any()) } returns null
|
every { rootViewNode.toAutofillView() } returns null
|
||||||
every {
|
every { hiddenUserNameViewNode.toAutofillView() } returns unusedAutofillView
|
||||||
hiddenUserNameViewNode.toAutofillView(parentWebsite = any())
|
every { passwordViewNode.toAutofillView() } returns loginPasswordAutofillView
|
||||||
} returns unusedAutofillView
|
|
||||||
every {
|
|
||||||
passwordViewNode.toAutofillView(parentWebsite = any())
|
|
||||||
} returns loginPasswordAutofillView
|
|
||||||
|
|
||||||
// Test
|
// Test
|
||||||
val actual = parser.parse(
|
val actual = parser.parse(
|
||||||
@@ -669,8 +665,8 @@ class AutofillParserTests {
|
|||||||
partition = autofillPartition,
|
partition = autofillPartition,
|
||||||
uri = URI,
|
uri = URI,
|
||||||
)
|
)
|
||||||
every { cardViewNode.toAutofillView(parentWebsite = any()) } returns cardAutofillView
|
every { cardViewNode.toAutofillView() } returns cardAutofillView
|
||||||
every { loginViewNode.toAutofillView(parentWebsite = any()) } returns loginAutofillView
|
every { loginViewNode.toAutofillView() } returns loginAutofillView
|
||||||
|
|
||||||
// Test
|
// Test
|
||||||
val actual = parser.parse(
|
val actual = parser.parse(
|
||||||
@@ -733,8 +729,8 @@ class AutofillParserTests {
|
|||||||
partition = autofillPartition,
|
partition = autofillPartition,
|
||||||
uri = URI,
|
uri = URI,
|
||||||
)
|
)
|
||||||
every { cardViewNode.toAutofillView(parentWebsite = any()) } returns cardAutofillView
|
every { cardViewNode.toAutofillView() } returns cardAutofillView
|
||||||
every { loginViewNode.toAutofillView(parentWebsite = any()) } returns loginAutofillView
|
every { loginViewNode.toAutofillView() } returns loginAutofillView
|
||||||
|
|
||||||
// Test
|
// Test
|
||||||
val actual = parser.parse(
|
val actual = parser.parse(
|
||||||
@@ -797,8 +793,8 @@ class AutofillParserTests {
|
|||||||
partition = autofillPartition,
|
partition = autofillPartition,
|
||||||
uri = URI,
|
uri = URI,
|
||||||
)
|
)
|
||||||
every { cardViewNode.toAutofillView(parentWebsite = any()) } returns cardAutofillView
|
every { cardViewNode.toAutofillView() } returns cardAutofillView
|
||||||
every { loginViewNode.toAutofillView(parentWebsite = any()) } returns loginAutofillView
|
every { loginViewNode.toAutofillView() } returns loginAutofillView
|
||||||
|
|
||||||
// Test
|
// Test
|
||||||
val actual = parser.parse(
|
val actual = parser.parse(
|
||||||
@@ -861,8 +857,8 @@ class AutofillParserTests {
|
|||||||
partition = autofillPartition,
|
partition = autofillPartition,
|
||||||
uri = URI,
|
uri = URI,
|
||||||
)
|
)
|
||||||
every { cardViewNode.toAutofillView(parentWebsite = any()) } returns cardAutofillView
|
every { cardViewNode.toAutofillView() } returns cardAutofillView
|
||||||
every { loginViewNode.toAutofillView(parentWebsite = any()) } returns loginAutofillView
|
every { loginViewNode.toAutofillView() } returns loginAutofillView
|
||||||
|
|
||||||
// Test
|
// Test
|
||||||
val actual = parser.parse(
|
val actual = parser.parse(
|
||||||
@@ -917,8 +913,8 @@ class AutofillParserTests {
|
|||||||
"blockListedUri.com",
|
"blockListedUri.com",
|
||||||
"blockListedAgainUri.com",
|
"blockListedAgainUri.com",
|
||||||
)
|
)
|
||||||
every { cardViewNode.toAutofillView(parentWebsite = any()) } returns cardAutofillView
|
every { cardViewNode.toAutofillView() } returns cardAutofillView
|
||||||
every { loginViewNode.toAutofillView(parentWebsite = any()) } returns loginAutofillView
|
every { loginViewNode.toAutofillView() } returns loginAutofillView
|
||||||
every { settingsRepository.blockedAutofillUris } returns remoteBlockList
|
every { settingsRepository.blockedAutofillUris } returns remoteBlockList
|
||||||
|
|
||||||
// A function for asserting that a block listed URI results in an unfillable request.
|
// A function for asserting that a block listed URI results in an unfillable request.
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ class ViewNodeExtensionsTest {
|
|||||||
every { viewNode.autofillHints } returns arrayOf(autofillHint)
|
every { viewNode.autofillHints } returns arrayOf(autofillHint)
|
||||||
|
|
||||||
// Test
|
// Test
|
||||||
val actual = viewNode.toAutofillView(parentWebsite = null)
|
val actual = viewNode.toAutofillView()
|
||||||
|
|
||||||
// Verify
|
// Verify
|
||||||
assertEquals(expected, actual)
|
assertEquals(expected, actual)
|
||||||
@@ -125,7 +125,7 @@ class ViewNodeExtensionsTest {
|
|||||||
} returns monthValue
|
} returns monthValue
|
||||||
|
|
||||||
// Test
|
// Test
|
||||||
val actual = viewNode.toAutofillView(parentWebsite = null)
|
val actual = viewNode.toAutofillView()
|
||||||
|
|
||||||
// Verify
|
// Verify
|
||||||
assertEquals(expected, actual)
|
assertEquals(expected, actual)
|
||||||
@@ -141,7 +141,7 @@ class ViewNodeExtensionsTest {
|
|||||||
)
|
)
|
||||||
every { viewNode.htmlInfo.hints() } returns SUPPORTED_RAW_CARD_EXP_MONTH_HINTS
|
every { viewNode.htmlInfo.hints() } returns SUPPORTED_RAW_CARD_EXP_MONTH_HINTS
|
||||||
|
|
||||||
val actual = viewNode.toAutofillView(parentWebsite = null)
|
val actual = viewNode.toAutofillView()
|
||||||
|
|
||||||
assertEquals(expected, actual)
|
assertEquals(expected, actual)
|
||||||
}
|
}
|
||||||
@@ -156,7 +156,7 @@ class ViewNodeExtensionsTest {
|
|||||||
SUPPORTED_RAW_CARD_EXP_MONTH_HINTS.forEach { idEntry ->
|
SUPPORTED_RAW_CARD_EXP_MONTH_HINTS.forEach { idEntry ->
|
||||||
every { viewNode.idEntry } returns idEntry
|
every { viewNode.idEntry } returns idEntry
|
||||||
|
|
||||||
val actual = viewNode.toAutofillView(parentWebsite = null)
|
val actual = viewNode.toAutofillView()
|
||||||
|
|
||||||
assertEquals(expected, actual, "Failed for idEntry: $idEntry")
|
assertEquals(expected, actual, "Failed for idEntry: $idEntry")
|
||||||
}
|
}
|
||||||
@@ -171,7 +171,7 @@ class ViewNodeExtensionsTest {
|
|||||||
)
|
)
|
||||||
SUPPORTED_RAW_CARD_EXP_MONTH_HINTS.forEach { hint ->
|
SUPPORTED_RAW_CARD_EXP_MONTH_HINTS.forEach { hint ->
|
||||||
every { viewNode.hint } returns hint
|
every { viewNode.hint } returns hint
|
||||||
val actual = viewNode.toAutofillView(parentWebsite = null)
|
val actual = viewNode.toAutofillView()
|
||||||
assertEquals(expected, actual, "Failed for hint: $hint")
|
assertEquals(expected, actual, "Failed for hint: $hint")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -186,7 +186,7 @@ class ViewNodeExtensionsTest {
|
|||||||
)
|
)
|
||||||
every { viewNode.autofillHints } returns arrayOf(autofillHint)
|
every { viewNode.autofillHints } returns arrayOf(autofillHint)
|
||||||
|
|
||||||
val actual = viewNode.toAutofillView(parentWebsite = null)
|
val actual = viewNode.toAutofillView()
|
||||||
|
|
||||||
assertEquals(expected, actual)
|
assertEquals(expected, actual)
|
||||||
}
|
}
|
||||||
@@ -201,7 +201,7 @@ class ViewNodeExtensionsTest {
|
|||||||
SUPPORTED_RAW_CARD_EXP_YEAR_HINTS.forEach { hint ->
|
SUPPORTED_RAW_CARD_EXP_YEAR_HINTS.forEach { hint ->
|
||||||
every { viewNode.hint } returns hint
|
every { viewNode.hint } returns hint
|
||||||
|
|
||||||
val actual = viewNode.toAutofillView(parentWebsite = null)
|
val actual = viewNode.toAutofillView()
|
||||||
|
|
||||||
assertEquals(expected, actual, "Failed for hint: $hint")
|
assertEquals(expected, actual, "Failed for hint: $hint")
|
||||||
}
|
}
|
||||||
@@ -217,7 +217,7 @@ class ViewNodeExtensionsTest {
|
|||||||
)
|
)
|
||||||
every { viewNode.htmlInfo.hints() } returns SUPPORTED_RAW_CARD_EXP_YEAR_HINTS
|
every { viewNode.htmlInfo.hints() } returns SUPPORTED_RAW_CARD_EXP_YEAR_HINTS
|
||||||
|
|
||||||
val actual = viewNode.toAutofillView(parentWebsite = null)
|
val actual = viewNode.toAutofillView()
|
||||||
|
|
||||||
assertEquals(expected, actual)
|
assertEquals(expected, actual)
|
||||||
}
|
}
|
||||||
@@ -231,7 +231,7 @@ class ViewNodeExtensionsTest {
|
|||||||
every { viewNode.autofillHints } returns arrayOf(autofillHint)
|
every { viewNode.autofillHints } returns arrayOf(autofillHint)
|
||||||
every { mockHtmlInfo.isInputField } returns true
|
every { mockHtmlInfo.isInputField } returns true
|
||||||
|
|
||||||
val actual = viewNode.toAutofillView(parentWebsite = null)
|
val actual = viewNode.toAutofillView()
|
||||||
|
|
||||||
assertEquals(expected, actual)
|
assertEquals(expected, actual)
|
||||||
}
|
}
|
||||||
@@ -245,7 +245,7 @@ class ViewNodeExtensionsTest {
|
|||||||
SUPPORTED_RAW_CARD_EXP_DATE_HINTS.forEach { hint ->
|
SUPPORTED_RAW_CARD_EXP_DATE_HINTS.forEach { hint ->
|
||||||
every { viewNode.hint } returns hint
|
every { viewNode.hint } returns hint
|
||||||
|
|
||||||
val actual = viewNode.toAutofillView(parentWebsite = null)
|
val actual = viewNode.toAutofillView()
|
||||||
|
|
||||||
assertEquals(expected, actual, "Failed for hint: $hint")
|
assertEquals(expected, actual, "Failed for hint: $hint")
|
||||||
}
|
}
|
||||||
@@ -260,7 +260,7 @@ class ViewNodeExtensionsTest {
|
|||||||
)
|
)
|
||||||
every { viewNode.htmlInfo.hints() } returns SUPPORTED_RAW_CARD_EXP_DATE_HINTS
|
every { viewNode.htmlInfo.hints() } returns SUPPORTED_RAW_CARD_EXP_DATE_HINTS
|
||||||
|
|
||||||
val actual = viewNode.toAutofillView(parentWebsite = null)
|
val actual = viewNode.toAutofillView()
|
||||||
|
|
||||||
assertEquals(expected, actual)
|
assertEquals(expected, actual)
|
||||||
}
|
}
|
||||||
@@ -275,7 +275,7 @@ class ViewNodeExtensionsTest {
|
|||||||
every { viewNode.autofillHints } returns arrayOf(autofillHint)
|
every { viewNode.autofillHints } returns arrayOf(autofillHint)
|
||||||
|
|
||||||
// Test
|
// Test
|
||||||
val actual = viewNode.toAutofillView(parentWebsite = null)
|
val actual = viewNode.toAutofillView()
|
||||||
|
|
||||||
// Verify
|
// Verify
|
||||||
assertEquals(expected, actual)
|
assertEquals(expected, actual)
|
||||||
@@ -290,7 +290,7 @@ class ViewNodeExtensionsTest {
|
|||||||
SUPPORTED_RAW_CARD_NUMBER_HINTS.forEach { hint ->
|
SUPPORTED_RAW_CARD_NUMBER_HINTS.forEach { hint ->
|
||||||
every { viewNode.hint } returns hint
|
every { viewNode.hint } returns hint
|
||||||
|
|
||||||
val actual = viewNode.toAutofillView(parentWebsite = null)
|
val actual = viewNode.toAutofillView()
|
||||||
|
|
||||||
assertEquals(expected, actual, "Failed for hint: $hint")
|
assertEquals(expected, actual, "Failed for hint: $hint")
|
||||||
}
|
}
|
||||||
@@ -304,7 +304,7 @@ class ViewNodeExtensionsTest {
|
|||||||
)
|
)
|
||||||
every { viewNode.htmlInfo.hints() } returns SUPPORTED_RAW_CARD_NUMBER_HINTS
|
every { viewNode.htmlInfo.hints() } returns SUPPORTED_RAW_CARD_NUMBER_HINTS
|
||||||
|
|
||||||
val actual = viewNode.toAutofillView(parentWebsite = null)
|
val actual = viewNode.toAutofillView()
|
||||||
|
|
||||||
assertEquals(expected, actual)
|
assertEquals(expected, actual)
|
||||||
}
|
}
|
||||||
@@ -319,7 +319,7 @@ class ViewNodeExtensionsTest {
|
|||||||
every { viewNode.autofillHints } returns arrayOf(autofillHint)
|
every { viewNode.autofillHints } returns arrayOf(autofillHint)
|
||||||
|
|
||||||
// Test
|
// Test
|
||||||
val actual = viewNode.toAutofillView(parentWebsite = null)
|
val actual = viewNode.toAutofillView()
|
||||||
|
|
||||||
// Verify
|
// Verify
|
||||||
assertEquals(expected, actual)
|
assertEquals(expected, actual)
|
||||||
@@ -334,7 +334,7 @@ class ViewNodeExtensionsTest {
|
|||||||
SUPPORTED_RAW_CARD_SECURITY_CODE_HINTS.forEach { hint ->
|
SUPPORTED_RAW_CARD_SECURITY_CODE_HINTS.forEach { hint ->
|
||||||
every { viewNode.hint } returns hint
|
every { viewNode.hint } returns hint
|
||||||
|
|
||||||
val actual = viewNode.toAutofillView(parentWebsite = null)
|
val actual = viewNode.toAutofillView()
|
||||||
|
|
||||||
assertEquals(expected, actual, "Failed for hint: $hint")
|
assertEquals(expected, actual, "Failed for hint: $hint")
|
||||||
}
|
}
|
||||||
@@ -348,7 +348,7 @@ class ViewNodeExtensionsTest {
|
|||||||
data = autofillViewData,
|
data = autofillViewData,
|
||||||
)
|
)
|
||||||
every { viewNode.htmlInfo.hints() } returns SUPPORTED_RAW_CARD_SECURITY_CODE_HINTS
|
every { viewNode.htmlInfo.hints() } returns SUPPORTED_RAW_CARD_SECURITY_CODE_HINTS
|
||||||
val actual = viewNode.toAutofillView(parentWebsite = null)
|
val actual = viewNode.toAutofillView()
|
||||||
assertEquals(expected, actual)
|
assertEquals(expected, actual)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -361,7 +361,7 @@ class ViewNodeExtensionsTest {
|
|||||||
SUPPORTED_RAW_CARDHOLDER_NAME_HINTS.forEach { idEntry ->
|
SUPPORTED_RAW_CARDHOLDER_NAME_HINTS.forEach { idEntry ->
|
||||||
every { viewNode.idEntry } returns idEntry
|
every { viewNode.idEntry } returns idEntry
|
||||||
|
|
||||||
val actual = viewNode.toAutofillView(parentWebsite = null)
|
val actual = viewNode.toAutofillView()
|
||||||
|
|
||||||
assertEquals(expected, actual, "Failed for idEntry: $idEntry")
|
assertEquals(expected, actual, "Failed for idEntry: $idEntry")
|
||||||
}
|
}
|
||||||
@@ -376,7 +376,7 @@ class ViewNodeExtensionsTest {
|
|||||||
SUPPORTED_RAW_CARDHOLDER_NAME_HINTS.forEach { hint ->
|
SUPPORTED_RAW_CARDHOLDER_NAME_HINTS.forEach { hint ->
|
||||||
every { viewNode.hint } returns hint
|
every { viewNode.hint } returns hint
|
||||||
|
|
||||||
val actual = viewNode.toAutofillView(parentWebsite = null)
|
val actual = viewNode.toAutofillView()
|
||||||
|
|
||||||
assertEquals(expected, actual, "Failed for hint: $hint")
|
assertEquals(expected, actual, "Failed for hint: $hint")
|
||||||
}
|
}
|
||||||
@@ -390,7 +390,7 @@ class ViewNodeExtensionsTest {
|
|||||||
data = autofillViewData,
|
data = autofillViewData,
|
||||||
)
|
)
|
||||||
every { viewNode.htmlInfo.hints() } returns SUPPORTED_RAW_CARDHOLDER_NAME_HINTS
|
every { viewNode.htmlInfo.hints() } returns SUPPORTED_RAW_CARDHOLDER_NAME_HINTS
|
||||||
val actual = viewNode.toAutofillView(parentWebsite = null)
|
val actual = viewNode.toAutofillView()
|
||||||
assertEquals(expected, actual)
|
assertEquals(expected, actual)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -403,7 +403,7 @@ class ViewNodeExtensionsTest {
|
|||||||
)
|
)
|
||||||
every { viewNode.autofillHints } returns arrayOf(autofillHint)
|
every { viewNode.autofillHints } returns arrayOf(autofillHint)
|
||||||
|
|
||||||
val actual = viewNode.toAutofillView(parentWebsite = null)
|
val actual = viewNode.toAutofillView()
|
||||||
|
|
||||||
assertEquals(expected, actual)
|
assertEquals(expected, actual)
|
||||||
}
|
}
|
||||||
@@ -417,7 +417,7 @@ class ViewNodeExtensionsTest {
|
|||||||
SUPPORTED_RAW_PASSWORD_HINTS.forEach { hint ->
|
SUPPORTED_RAW_PASSWORD_HINTS.forEach { hint ->
|
||||||
every { viewNode.hint } returns hint
|
every { viewNode.hint } returns hint
|
||||||
|
|
||||||
val actual = viewNode.toAutofillView(parentWebsite = null)
|
val actual = viewNode.toAutofillView()
|
||||||
|
|
||||||
assertEquals(expected, actual, "Failed for hint: $hint")
|
assertEquals(expected, actual, "Failed for hint: $hint")
|
||||||
}
|
}
|
||||||
@@ -432,7 +432,7 @@ class ViewNodeExtensionsTest {
|
|||||||
)
|
)
|
||||||
every { viewNode.htmlInfo.isPasswordField() } returns true
|
every { viewNode.htmlInfo.isPasswordField() } returns true
|
||||||
|
|
||||||
val actual = viewNode.toAutofillView(parentWebsite = null)
|
val actual = viewNode.toAutofillView()
|
||||||
|
|
||||||
assertEquals(expected, actual)
|
assertEquals(expected, actual)
|
||||||
}
|
}
|
||||||
@@ -451,26 +451,7 @@ class ViewNodeExtensionsTest {
|
|||||||
every { any<Int>().isUsernameInputType } returns true
|
every { any<Int>().isUsernameInputType } returns true
|
||||||
|
|
||||||
// Test
|
// Test
|
||||||
val actual = viewNode.toAutofillView(parentWebsite = null)
|
val actual = viewNode.toAutofillView()
|
||||||
|
|
||||||
// Verify
|
|
||||||
assertEquals(expected, actual)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun `toAutofillView should return AutofillView Login Username with external website`() {
|
|
||||||
// Setup
|
|
||||||
val website = "website"
|
|
||||||
val expected = AutofillView.Login.Username(
|
|
||||||
data = autofillViewData.copy(website = website),
|
|
||||||
)
|
|
||||||
setupUnsupportedInputFieldViewNode()
|
|
||||||
every { viewNode.className } returns "android.widget.EditText"
|
|
||||||
every { any<Int>().isPasswordInputType } returns false
|
|
||||||
every { any<Int>().isUsernameInputType } returns true
|
|
||||||
|
|
||||||
// Test
|
|
||||||
val actual = viewNode.toAutofillView(parentWebsite = website)
|
|
||||||
|
|
||||||
// Verify
|
// Verify
|
||||||
assertEquals(expected, actual)
|
assertEquals(expected, actual)
|
||||||
@@ -489,7 +470,7 @@ class ViewNodeExtensionsTest {
|
|||||||
every { any<Int>().isUsernameInputType } returns true
|
every { any<Int>().isUsernameInputType } returns true
|
||||||
|
|
||||||
// Test
|
// Test
|
||||||
val actual = viewNode.toAutofillView(parentWebsite = null)
|
val actual = viewNode.toAutofillView()
|
||||||
|
|
||||||
// Verify
|
// Verify
|
||||||
assertEquals(expected, actual)
|
assertEquals(expected, actual)
|
||||||
@@ -508,7 +489,7 @@ class ViewNodeExtensionsTest {
|
|||||||
every { any<Int>().isUsernameInputType } returns true
|
every { any<Int>().isUsernameInputType } returns true
|
||||||
|
|
||||||
// Test
|
// Test
|
||||||
val actual = viewNode.toAutofillView(parentWebsite = null)
|
val actual = viewNode.toAutofillView()
|
||||||
|
|
||||||
// Verify
|
// Verify
|
||||||
assertEquals(expected, actual)
|
assertEquals(expected, actual)
|
||||||
@@ -523,7 +504,7 @@ class ViewNodeExtensionsTest {
|
|||||||
every { viewNode.htmlInfo.isInputField } returns false
|
every { viewNode.htmlInfo.isInputField } returns false
|
||||||
|
|
||||||
// Test
|
// Test
|
||||||
val actual = viewNode.toAutofillView(parentWebsite = null)
|
val actual = viewNode.toAutofillView()
|
||||||
|
|
||||||
// Verify
|
// Verify
|
||||||
assertNull(actual)
|
assertNull(actual)
|
||||||
@@ -537,7 +518,7 @@ class ViewNodeExtensionsTest {
|
|||||||
data = autofillViewData,
|
data = autofillViewData,
|
||||||
)
|
)
|
||||||
|
|
||||||
val actual = viewNode.toAutofillView(parentWebsite = null)
|
val actual = viewNode.toAutofillView()
|
||||||
|
|
||||||
assertEquals(expected, actual)
|
assertEquals(expected, actual)
|
||||||
}
|
}
|
||||||
@@ -554,7 +535,7 @@ class ViewNodeExtensionsTest {
|
|||||||
every { viewNode.autofillHints } returns arrayOf(autofillHintOne, autofillHintTwo)
|
every { viewNode.autofillHints } returns arrayOf(autofillHintOne, autofillHintTwo)
|
||||||
|
|
||||||
// Test
|
// Test
|
||||||
val actual = viewNode.toAutofillView(parentWebsite = null)
|
val actual = viewNode.toAutofillView()
|
||||||
|
|
||||||
// Verify
|
// Verify
|
||||||
assertEquals(expected, actual)
|
assertEquals(expected, actual)
|
||||||
|
|||||||
Reference in New Issue
Block a user