Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/autofill/core/common/autofill_util.h" | 5 #include "components/autofill/core/common/autofill_util.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 92 << ", case_sensitive = " << kTestCases[i].case_sensitive); | 92 << ", case_sensitive = " << kTestCases[i].case_sensitive); |
| 93 | 93 |
| 94 EXPECT_EQ(kTestCases[i].expected_start, | 94 EXPECT_EQ(kTestCases[i].expected_start, |
| 95 GetTextSelectionStart( | 95 GetTextSelectionStart( |
| 96 base::ASCIIToUTF16(kTestCases[i].field_suggestion), | 96 base::ASCIIToUTF16(kTestCases[i].field_suggestion), |
| 97 base::ASCIIToUTF16(kTestCases[i].field_contents), | 97 base::ASCIIToUTF16(kTestCases[i].field_contents), |
| 98 kTestCases[i].case_sensitive)); | 98 kTestCases[i].case_sensitive)); |
| 99 } | 99 } |
| 100 } | 100 } |
| 101 | 101 |
| 102 // Tests for LowercaseAndTokenizeAttributeString | |
| 103 TEST(AutofillUtilTest, LowercaseAndTokenizeAttributeString) { | |
| 104 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.
| |
| 105 | |
| 106 const struct { | |
| 107 const char* const attribute; | |
| 108 std::vector<std::string> tokens; | |
| 109 } kTestCases[] = { | |
| 110 // Test leading and trailing whitespace, test tabs and newlines | |
| 111 {"foo bar baz", {"foo", "bar", "baz"}}, | |
| 112 {" foo bar baz ", {"foo", "bar", "baz"}}, | |
| 113 {"foo\tbar baz ", {"foo", "bar", "baz"}}, | |
| 114 {"foo\nbar baz ", {"foo", "bar", "baz"}}, | |
| 115 | |
| 116 // Test different forms of capitalization | |
| 117 {"FOO BAR BAZ", {"foo", "bar", "baz"}}, | |
| 118 {"foO baR bAz", {"foo", "bar", "baz"}}, | |
| 119 | |
| 120 // Test collapsing of multiple whitespace characters in a row | |
| 121 {" \t\t\n\n ", empty_vector}, | |
| 122 {"foO baR bAz", {"foo", "bar", "baz"}}, | |
| 123 }; | |
| 124 | |
| 125 for (size_t i = 0; i < arraysize(kTestCases); ++i) { | |
| 126 SCOPED_TRACE(testing::Message() << "attribute = " | |
| 127 << kTestCases[i].attribute); | |
| 128 | |
| 129 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.
| |
| 130 kTestCases[i].tokens); | |
| 131 } | |
| 132 } | |
| 102 } // namespace autofill | 133 } // namespace autofill |
| OLD | NEW |