Skip to content

Commit

Permalink
fixing lint
Browse files Browse the repository at this point in the history
  • Loading branch information
cmonfortep committed Feb 4, 2025
1 parent 42f098a commit fc50c76
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,11 @@ class AutofillServiceViewNodeClassifier @Inject constructor() : ViewNodeClassifi

private fun isTextPasswordField(inputType: Int): Boolean {
return (inputType and InputType.TYPE_MASK_CLASS) == InputType.TYPE_CLASS_TEXT &&
(inputType and InputType.TYPE_MASK_VARIATION) == InputType.TYPE_TEXT_VARIATION_PASSWORD
(
(inputType and InputType.TYPE_MASK_VARIATION) == InputType.TYPE_TEXT_VARIATION_PASSWORD ||
(inputType and InputType.TYPE_MASK_VARIATION) == InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD ||
(inputType and InputType.TYPE_MASK_VARIATION) == InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD
)
}

private fun getType(autofillHints: Array<String>?): AutofillFieldType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ fun viewNode(): ViewNode {
return mock()
}

fun ViewNode.inputType(inputType: Int): ViewNode {
whenever(this.inputType).thenReturn(inputType)
return this
}

fun ViewNode.webDomain(domain: String): ViewNode {
whenever(this.webDomain).thenReturn(domain)
return this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package com.duckduckgo.autofill.impl.service

import android.text.InputType.TYPE_CLASS_TEXT
import android.text.InputType.TYPE_TEXT_VARIATION_PASSWORD
import android.util.Pair
import android.view.View
import androidx.test.ext.junit.runners.AndroidJUnit4
Expand Down Expand Up @@ -85,7 +87,7 @@ class AutofillServiceViewNodeClassifierTest {
assertEquals(
"$usernameCombination failed",
USERNAME,
testee.classify(viewNode().hint(usernameCombination)),
testee.classify(viewNode().inputType(TYPE_CLASS_TEXT).hint(usernameCombination)),
)
}

Expand All @@ -100,7 +102,7 @@ class AutofillServiceViewNodeClassifierTest {
assertEquals(
"$usernameCombination failed",
USERNAME,
testee.classify(viewNode().idEntry(usernameCombination)),
testee.classify(viewNode().inputType(TYPE_CLASS_TEXT).idEntry(usernameCombination)),
)
}

Expand All @@ -116,7 +118,7 @@ class AutofillServiceViewNodeClassifierTest {
assertEquals(
"$passwordCombination failed",
PASSWORD,
testee.classify(viewNode().hint(passwordCombination)),
testee.classify(viewNode().inputType(TYPE_CLASS_TEXT or TYPE_TEXT_VARIATION_PASSWORD).hint(passwordCombination)),
)
}

Expand All @@ -132,7 +134,7 @@ class AutofillServiceViewNodeClassifierTest {
assertEquals(
"$passwordCombination failed",
PASSWORD,
testee.classify(viewNode().idEntry(passwordCombination)),
testee.classify(viewNode().inputType(TYPE_CLASS_TEXT or TYPE_TEXT_VARIATION_PASSWORD).idEntry(passwordCombination)),
)
}

Expand Down

0 comments on commit fc50c76

Please sign in to comment.