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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/strings/string16.h" | 7 #include "base/strings/string16.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "components/autofill/core/browser/autofill_country.h" | 9 #include "components/autofill/core/browser/autofill_country.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 "nl")); | 82 "nl")); |
83 | 83 |
84 // Should fall back to "en_US" locale if all else fails. | 84 // Should fall back to "en_US" locale if all else fails. |
85 EXPECT_EQ("US", AutofillCountry::GetCountryCode(ASCIIToUTF16("United States"), | 85 EXPECT_EQ("US", AutofillCountry::GetCountryCode(ASCIIToUTF16("United States"), |
86 "es")); | 86 "es")); |
87 EXPECT_EQ("US", AutofillCountry::GetCountryCode(ASCIIToUTF16("united states"), | 87 EXPECT_EQ("US", AutofillCountry::GetCountryCode(ASCIIToUTF16("united states"), |
88 "es")); | 88 "es")); |
89 EXPECT_EQ("US", AutofillCountry::GetCountryCode(ASCIIToUTF16("USA"), "es")); | 89 EXPECT_EQ("US", AutofillCountry::GetCountryCode(ASCIIToUTF16("USA"), "es")); |
90 } | 90 } |
91 | 91 |
| 92 // Test mapping of empty country name to country code. |
| 93 TEST(AutofillCountryTest, EmptyCountryNameHasEmptyCountryCode) { |
| 94 EXPECT_TRUE(AutofillCountry::GetCountryCode(base::string16(), "en").empty()); |
| 95 } |
| 96 |
| 97 // Test mapping all country codes to country names. |
| 98 TEST(AutofillCountryTest, AllCountryCodesHaveCountryName) { |
| 99 std::vector<std::string> country_codes; |
| 100 AutofillCountry::GetAvailableCountries(&country_codes); |
| 101 for (size_t i = 0; i < country_codes.size(); ++i) { |
| 102 SCOPED_TRACE("Country code '" + country_codes[i] + "' should have a name."); |
| 103 EXPECT_NE(ASCIIToUTF16(country_codes[i]), |
| 104 AutofillCountry(country_codes[i], "en").name()); |
| 105 } |
| 106 } |
| 107 |
92 } // namespace autofill | 108 } // namespace autofill |
OLD | NEW |