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

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

Issue 2906383003: Teach PasswordAutofillAgent sometimes match prefixes of usernames (Closed)
Patch Set: more browser tests 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
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..01a54ef516df32c6e5a908b8461a1bff7ab8f6c6 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 TokenBoundaryPrefixCase {
vabr (Chromium) 2017/06/19 12:54:15 nit: TokenBoundary -> AtSign ? Let's get rid of me
melandory 2017/06/21 12:00:42 Done.
+ const char* const field_suggestion;
+ const char* const field_contents;
+ const bool expected_result;
+};
+
+class PrefixEndingOnTokenBoundaryTest
+ : public testing::TestWithParam<TokenBoundaryPrefixCase> {};
+
+TEST_P(PrefixEndingOnTokenBoundaryTest, IsPrefixOfEmailEndingAtSign) {
+ auto test_case = GetParam();
+ SCOPED_TRACE(testing::Message()
+ << "suggestion = " << test_case.field_suggestion
+ << ", contents = " << test_case.field_contents);
+
+ EXPECT_EQ(test_case.expected_result,
+ IsPrefixOfEmailEndingAtSign(
+ base::ASCIIToUTF16(test_case.field_suggestion),
+ base::ASCIIToUTF16(test_case.field_contents)));
+}
+
+INSTANTIATE_TEST_CASE_P(
+ AutofillUtilTest,
+ PrefixEndingOnTokenBoundaryTest,
+ testing::Values(TokenBoundaryPrefixCase{"ab@cd.b", "a", false},
+ TokenBoundaryPrefixCase{"ab@cd.b", "b", false},
+ TokenBoundaryPrefixCase{"ab@cd.b", "Ab", false},
+ TokenBoundaryPrefixCase{"ab@cd.b", "cd", false},
+ TokenBoundaryPrefixCase{"ab@cd.b", "d", false},
+ TokenBoundaryPrefixCase{"ab@cd.b", "b@", false},
+ TokenBoundaryPrefixCase{"ab@cd.b", "cd.b", false},
+ TokenBoundaryPrefixCase{"ab@cd.b", "b@cd", false},
+ TokenBoundaryPrefixCase{"ab@cd.b", "ab@c", false},
+ TokenBoundaryPrefixCase{"ba.a.ab", "a.a", false},
+ TokenBoundaryPrefixCase{"", "ab", false},
+ TokenBoundaryPrefixCase{"ab@c", "ab@", false},
+ TokenBoundaryPrefixCase{"ab@cd@g", "ab", false},
+ TokenBoundaryPrefixCase{"ab@cd@g", "ab@cd", false},
+ TokenBoundaryPrefixCase{"abc", "abc", false},
+ TokenBoundaryPrefixCase{"ab", "", false},
+ TokenBoundaryPrefixCase{"ab@cd.b", "ab", true}));
+
// Tests for GetTextSelectionStart().
struct GetTextSelectionStartCase {
const char* const field_suggestion;

Powered by Google App Engine
This is Rietveld 408576698