| 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 struct { |
| 105 const char* const attribute; |
| 106 std::vector<std::string> tokens; |
| 107 } kTestCases[] = { |
| 108 // Test leading and trailing whitespace, test tabs and newlines |
| 109 {"foo bar baz", {"foo", "bar", "baz"}}, |
| 110 {" foo bar baz ", {"foo", "bar", "baz"}}, |
| 111 {"foo\tbar baz ", {"foo", "bar", "baz"}}, |
| 112 {"foo\nbar baz ", {"foo", "bar", "baz"}}, |
| 113 |
| 114 // Test different forms of capitalization |
| 115 {"FOO BAR BAZ", {"foo", "bar", "baz"}}, |
| 116 {"foO baR bAz", {"foo", "bar", "baz"}}, |
| 117 |
| 118 // Test collapsing of multiple whitespace characters in a row |
| 119 {" \t\t\n\n ", std::vector<std::string>()}, |
| 120 {"foO baR bAz", {"foo", "bar", "baz"}}, |
| 121 }; |
| 122 |
| 123 for (size_t i = 0; i < arraysize(kTestCases); ++i) { |
| 124 SCOPED_TRACE(testing::Message() << "attribute = " |
| 125 << kTestCases[i].attribute); |
| 126 |
| 127 EXPECT_EQ(kTestCases[i].tokens, |
| 128 LowercaseAndTokenizeAttributeString(kTestCases[i].attribute)); |
| 129 } |
| 130 } |
| 102 } // namespace autofill | 131 } // namespace autofill |
| OLD | NEW |