OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 Address address; | 125 Address address; |
126 address.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US")); | 126 address.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US")); |
127 | 127 |
128 const char* const kValidMatches[] = { | 128 const char* const kValidMatches[] = { |
129 "United States", | 129 "United States", |
130 "USA", | 130 "USA", |
131 "US", | 131 "US", |
132 "United states", | 132 "United states", |
133 "us" | 133 "us" |
134 }; | 134 }; |
135 for (const char* valid_match : kValidMatches) { | 135 for (size_t i = 0; i < arraysize(kValidMatches); ++i) { |
136 SCOPED_TRACE(valid_match); | 136 SCOPED_TRACE(kValidMatches[i]); |
137 ServerFieldTypeSet matching_types; | 137 ServerFieldTypeSet matching_types; |
138 address.GetMatchingTypes(ASCIIToUTF16(valid_match), "US", &matching_types); | 138 address.GetMatchingTypes(ASCIIToUTF16(kValidMatches[i]), "US", |
| 139 &matching_types); |
139 ASSERT_EQ(1U, matching_types.size()); | 140 ASSERT_EQ(1U, matching_types.size()); |
140 EXPECT_EQ(ADDRESS_HOME_COUNTRY, *matching_types.begin()); | 141 EXPECT_EQ(ADDRESS_HOME_COUNTRY, *matching_types.begin()); |
141 } | 142 } |
142 | 143 |
143 const char* const kInvalidMatches[] = { | 144 const char* const kInvalidMatches[] = { |
144 "United", | 145 "United", |
145 "Garbage" | 146 "Garbage" |
146 }; | 147 }; |
147 for (const char* invalid_match : kInvalidMatches) { | 148 for (size_t i = 0; i < arraysize(kInvalidMatches); ++i) { |
148 ServerFieldTypeSet matching_types; | 149 ServerFieldTypeSet matching_types; |
149 address.GetMatchingTypes(ASCIIToUTF16(invalid_match), "US", | 150 address.GetMatchingTypes(ASCIIToUTF16(kInvalidMatches[i]), "US", |
150 &matching_types); | 151 &matching_types); |
151 EXPECT_EQ(0U, matching_types.size()); | 152 EXPECT_EQ(0U, matching_types.size()); |
152 } | 153 } |
153 | 154 |
154 // Make sure that garbage values don't match when the country code is empty. | 155 // Make sure that garbage values don't match when the country code is empty. |
155 address.SetRawInfo(ADDRESS_HOME_COUNTRY, base::string16()); | 156 address.SetRawInfo(ADDRESS_HOME_COUNTRY, base::string16()); |
156 EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_COUNTRY)); | 157 EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_COUNTRY)); |
157 ServerFieldTypeSet matching_types; | 158 ServerFieldTypeSet matching_types; |
158 address.GetMatchingTypes(ASCIIToUTF16("Garbage"), "US", &matching_types); | 159 address.GetMatchingTypes(ASCIIToUTF16("Garbage"), "US", &matching_types); |
159 EXPECT_EQ(0U, matching_types.size()); | 160 EXPECT_EQ(0U, matching_types.size()); |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 ASCIIToUTF16("Address line 1" | 378 ASCIIToUTF16("Address line 1" |
378 "Address line 2" | 379 "Address line 2" |
379 "\n"), | 380 "\n"), |
380 "en-US")); | 381 "en-US")); |
381 EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_LINE1)); | 382 EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_LINE1)); |
382 EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_LINE2)); | 383 EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_LINE2)); |
383 EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_STREET_ADDRESS)); | 384 EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_STREET_ADDRESS)); |
384 } | 385 } |
385 | 386 |
386 } // namespace autofill | 387 } // namespace autofill |
OLD | NEW |