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

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

Issue 2411333004: Make HasAutocompleteAttributeValue handle multi-valued strings (Closed)
Patch Set: Created 4 years, 2 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 823be3d4fe068ce6d2600f75e48762970aea2c18..b97f58c0090f4accca3b365bc678b065b7742085 100644
--- a/components/autofill/core/common/autofill_util_unittest.cc
+++ b/components/autofill/core/common/autofill_util_unittest.cc
@@ -99,4 +99,35 @@ TEST(AutofillUtilTest, GetTextSelectionStart) {
}
}
+// Tests for LowercaseAndTokenizeAttributeString
+TEST(AutofillUtilTest, LowercaseAndTokenizeAttributeString) {
+ const std::vector<std::string> empty_vector;
vabr (Chromium) 2016/10/13 12:49:31 nit: Constants have a different naming scheme. Her
jdoerrie 2016/10/13 13:45:07 Done.
+
+ const struct {
+ const char* const attribute;
+ std::vector<std::string> tokens;
+ } kTestCases[] = {
+ // Test leading and trailing whitespace, test tabs and newlines
+ {"foo bar baz", {"foo", "bar", "baz"}},
+ {" foo bar baz ", {"foo", "bar", "baz"}},
+ {"foo\tbar baz ", {"foo", "bar", "baz"}},
+ {"foo\nbar baz ", {"foo", "bar", "baz"}},
+
+ // Test different forms of capitalization
+ {"FOO BAR BAZ", {"foo", "bar", "baz"}},
+ {"foO baR bAz", {"foo", "bar", "baz"}},
+
+ // Test collapsing of multiple whitespace characters in a row
+ {" \t\t\n\n ", empty_vector},
+ {"foO baR bAz", {"foo", "bar", "baz"}},
+ };
+
+ for (size_t i = 0; i < arraysize(kTestCases); ++i) {
+ SCOPED_TRACE(testing::Message() << "attribute = "
+ << kTestCases[i].attribute);
+
+ EXPECT_EQ(LowercaseAndTokenizeAttributeString(kTestCases[i].attribute),
vabr (Chromium) 2016/10/13 12:49:31 nit: Please reverse the order of the arguments of
jdoerrie 2016/10/13 13:45:07 Done.
+ kTestCases[i].tokens);
+ }
+}
} // namespace autofill

Powered by Google App Engine
This is Rietveld 408576698