| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/browser/autofill_data_util.h" | 5 #include "components/autofill/core/browser/autofill_data_util.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "components/autofill/core/browser/autofill_test_utils.h" | 8 #include "components/autofill/core/browser/autofill_test_utils.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 EXPECT_TRUE( | 191 EXPECT_TRUE( |
| 192 ProfileMatchesFullName(base::UTF8ToUTF16("Last First"), profile)); | 192 ProfileMatchesFullName(base::UTF8ToUTF16("Last First"), profile)); |
| 193 | 193 |
| 194 EXPECT_TRUE( | 194 EXPECT_TRUE( |
| 195 ProfileMatchesFullName(base::UTF8ToUTF16("LastFirst"), profile)); | 195 ProfileMatchesFullName(base::UTF8ToUTF16("LastFirst"), profile)); |
| 196 | 196 |
| 197 EXPECT_FALSE( | 197 EXPECT_FALSE( |
| 198 ProfileMatchesFullName(base::UTF8ToUTF16("Kirby Puckett"), profile)); | 198 ProfileMatchesFullName(base::UTF8ToUTF16("Kirby Puckett"), profile)); |
| 199 } | 199 } |
| 200 | 200 |
| 201 struct ValidCountryCodeTestCase { | |
| 202 std::string country_code; | |
| 203 bool expected_result; | |
| 204 }; | |
| 205 | |
| 206 class ValidCountryCodeTest | |
| 207 : public testing::TestWithParam<ValidCountryCodeTestCase> {}; | |
| 208 | |
| 209 TEST_P(ValidCountryCodeTest, ValidCountryCode) { | |
| 210 auto test_case = GetParam(); | |
| 211 EXPECT_EQ(test_case.expected_result, | |
| 212 IsValidCountryCode(test_case.country_code)); | |
| 213 } | |
| 214 | |
| 215 INSTANTIATE_TEST_CASE_P( | |
| 216 AutofillDataUtil, | |
| 217 ValidCountryCodeTest, | |
| 218 testing::Values( | |
| 219 // Valid country codes. | |
| 220 ValidCountryCodeTestCase{"US", true}, | |
| 221 ValidCountryCodeTestCase{"CA", true}, | |
| 222 ValidCountryCodeTestCase{"CN", true}, | |
| 223 | |
| 224 // Country names should not be considered valid. | |
| 225 ValidCountryCodeTestCase{"United States", false}, | |
| 226 ValidCountryCodeTestCase{"Canada", false}, | |
| 227 ValidCountryCodeTestCase{"China", false}, | |
| 228 | |
| 229 // Codes with numbers should not be considered valid. | |
| 230 ValidCountryCodeTestCase{"C2", false}, | |
| 231 | |
| 232 // Three letters abbreviations should not be considered valid. | |
| 233 ValidCountryCodeTestCase{"USA", false}, | |
| 234 ValidCountryCodeTestCase{"CAN", false}, | |
| 235 ValidCountryCodeTestCase{"CHN", false}, | |
| 236 | |
| 237 // Lowercase is invalid. | |
| 238 ValidCountryCodeTestCase{"us", false}, | |
| 239 ValidCountryCodeTestCase{"Ca", false}, | |
| 240 ValidCountryCodeTestCase{"cN", false})); | |
| 241 | |
| 242 } // namespace data_util | 201 } // namespace data_util |
| 243 } // namespace autofill | 202 } // namespace autofill |
| OLD | NEW |