| 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 (size_t i = 0; i < arraysize(kValidMatches); ++i) { | 135 for (const char* valid_match : kValidMatches) { |
| 136 SCOPED_TRACE(kValidMatches[i]); | 136 SCOPED_TRACE(valid_match); |
| 137 ServerFieldTypeSet matching_types; | 137 ServerFieldTypeSet matching_types; |
| 138 address.GetMatchingTypes(ASCIIToUTF16(kValidMatches[i]), "US", | 138 address.GetMatchingTypes(ASCIIToUTF16(valid_match), "US", &matching_types); |
| 139 &matching_types); | |
| 140 ASSERT_EQ(1U, matching_types.size()); | 139 ASSERT_EQ(1U, matching_types.size()); |
| 141 EXPECT_EQ(ADDRESS_HOME_COUNTRY, *matching_types.begin()); | 140 EXPECT_EQ(ADDRESS_HOME_COUNTRY, *matching_types.begin()); |
| 142 } | 141 } |
| 143 | 142 |
| 144 const char* const kInvalidMatches[] = { | 143 const char* const kInvalidMatches[] = { |
| 145 "United", | 144 "United", |
| 146 "Garbage" | 145 "Garbage" |
| 147 }; | 146 }; |
| 148 for (size_t i = 0; i < arraysize(kInvalidMatches); ++i) { | 147 for (const char* invalid_match : kInvalidMatches) { |
| 149 ServerFieldTypeSet matching_types; | 148 ServerFieldTypeSet matching_types; |
| 150 address.GetMatchingTypes(ASCIIToUTF16(kInvalidMatches[i]), "US", | 149 address.GetMatchingTypes(ASCIIToUTF16(invalid_match), "US", |
| 151 &matching_types); | 150 &matching_types); |
| 152 EXPECT_EQ(0U, matching_types.size()); | 151 EXPECT_EQ(0U, matching_types.size()); |
| 153 } | 152 } |
| 154 | 153 |
| 155 // Make sure that garbage values don't match when the country code is empty. | 154 // Make sure that garbage values don't match when the country code is empty. |
| 156 address.SetRawInfo(ADDRESS_HOME_COUNTRY, base::string16()); | 155 address.SetRawInfo(ADDRESS_HOME_COUNTRY, base::string16()); |
| 157 EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_COUNTRY)); | 156 EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_COUNTRY)); |
| 158 ServerFieldTypeSet matching_types; | 157 ServerFieldTypeSet matching_types; |
| 159 address.GetMatchingTypes(ASCIIToUTF16("Garbage"), "US", &matching_types); | 158 address.GetMatchingTypes(ASCIIToUTF16("Garbage"), "US", &matching_types); |
| 160 EXPECT_EQ(0U, matching_types.size()); | 159 EXPECT_EQ(0U, matching_types.size()); |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 ASCIIToUTF16("Address line 1" | 377 ASCIIToUTF16("Address line 1" |
| 379 "Address line 2" | 378 "Address line 2" |
| 380 "\n"), | 379 "\n"), |
| 381 "en-US")); | 380 "en-US")); |
| 382 EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_LINE1)); | 381 EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_LINE1)); |
| 383 EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_LINE2)); | 382 EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_LINE2)); |
| 384 EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_STREET_ADDRESS)); | 383 EXPECT_EQ(base::string16(), address.GetRawInfo(ADDRESS_HOME_STREET_ADDRESS)); |
| 385 } | 384 } |
| 386 | 385 |
| 387 } // namespace autofill | 386 } // namespace autofill |
| OLD | NEW |