Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(574)

Unified Diff: components/autofill/core/common/autofill_util_unittest.cc

Issue 2906383003: Teach PasswordAutofillAgent sometimes match prefixes of usernames (Closed)
Patch Set: . Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/autofill/core/common/autofill_util.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/autofill/core/common/autofill_util_unittest.cc
diff --git a/components/autofill/core/common/autofill_util_unittest.cc b/components/autofill/core/common/autofill_util_unittest.cc
index 6e04dc76031f980e818546f76d3881012c25a7bc..6a59b0d618f49920a5f65612b050db65a82ac417 100644
--- a/components/autofill/core/common/autofill_util_unittest.cc
+++ b/components/autofill/core/common/autofill_util_unittest.cc
@@ -70,6 +70,48 @@ INSTANTIATE_TEST_CASE_P(
FieldIsTokenBoundarySubstringCase{"ab", "", false, true},
FieldIsTokenBoundarySubstringCase{"ab", "", true, true}));
+struct AtSignPrefixCase {
+ const char* const field_suggestion;
+ const char* const field_contents;
+ const bool expected_result;
+};
+
+class PrefixEndingOnTokenBoundaryTest
+ : public testing::TestWithParam<AtSignPrefixCase> {};
+
+TEST_P(PrefixEndingOnTokenBoundaryTest, IsPrefixOfEmailEndingWithAtSign) {
+ auto test_case = GetParam();
+ SCOPED_TRACE(testing::Message()
+ << "suggestion = " << test_case.field_suggestion
+ << ", contents = " << test_case.field_contents);
+
+ EXPECT_EQ(test_case.expected_result,
+ IsPrefixOfEmailEndingWithAtSign(
+ base::ASCIIToUTF16(test_case.field_suggestion),
+ base::ASCIIToUTF16(test_case.field_contents)));
+}
+
+INSTANTIATE_TEST_CASE_P(
+ AutofillUtilTest,
+ PrefixEndingOnTokenBoundaryTest,
+ testing::Values(AtSignPrefixCase{"ab@cd.b", "a", false},
+ AtSignPrefixCase{"ab@cd.b", "b", false},
+ AtSignPrefixCase{"ab@cd.b", "Ab", false},
+ AtSignPrefixCase{"ab@cd.b", "cd", false},
+ AtSignPrefixCase{"ab@cd.b", "d", false},
+ AtSignPrefixCase{"ab@cd.b", "b@", false},
+ AtSignPrefixCase{"ab@cd.b", "cd.b", false},
+ AtSignPrefixCase{"ab@cd.b", "b@cd", false},
+ AtSignPrefixCase{"ab@cd.b", "ab@c", false},
+ AtSignPrefixCase{"ba.a.ab", "a.a", false},
+ AtSignPrefixCase{"", "ab", false},
+ AtSignPrefixCase{"ab@c", "ab@", false},
+ AtSignPrefixCase{"ab@cd@g", "ab", true},
+ AtSignPrefixCase{"ab@cd@g", "ab@cd", true},
+ AtSignPrefixCase{"abc", "abc", false},
+ AtSignPrefixCase{"ab", "", false},
+ AtSignPrefixCase{"ab@cd.b", "ab", true}));
+
// Tests for GetTextSelectionStart().
struct GetTextSelectionStartCase {
const char* const field_suggestion;
« no previous file with comments | « components/autofill/core/common/autofill_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698