Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1162)

Unified Diff: components/autofill/browser/address_unittest.cc

Issue 13697002: Make autofill's Address store country using the country code so that app locale isn't needed for th… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix remaining tests Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/autofill/browser/address_unittest.cc
===================================================================
--- components/autofill/browser/address_unittest.cc (revision 192389)
+++ components/autofill/browser/address_unittest.cc (working copy)
@@ -27,32 +27,20 @@
DISALLOW_COPY_AND_ASSIGN(AddressTest);
};
-// Test that the getters and setters for country code are working.
-TEST_F(AddressTest, CountryCode) {
- Address address;
- EXPECT_EQ(std::string(), address.country_code());
-
- address.set_country_code("US");
- EXPECT_EQ("US", address.country_code());
-
- address.set_country_code("CA");
- EXPECT_EQ("CA", address.country_code());
-}
-
// Test that country codes are properly decoded as country names.
TEST_F(AddressTest, GetCountry) {
Address address;
- EXPECT_EQ(std::string(), address.country_code());
+ EXPECT_EQ(string16(), address.GetRawInfo(ADDRESS_HOME_COUNTRY));
// Make sure that nothing breaks when the country code is missing.
string16 country = address.GetInfo(ADDRESS_HOME_COUNTRY, "en-US");
EXPECT_EQ(string16(), country);
- address.set_country_code("US");
+ address.SetInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US"), "en-US");
country = address.GetInfo(ADDRESS_HOME_COUNTRY, "en-US");
EXPECT_EQ(ASCIIToUTF16("United States"), country);
- address.set_country_code("CA");
+ address.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("CA"));
country = address.GetInfo(ADDRESS_HOME_COUNTRY, "en-US");
EXPECT_EQ(ASCIIToUTF16("Canada"), country);
}
@@ -60,43 +48,43 @@
// Test that we properly detect country codes appropriate for each country.
TEST_F(AddressTest, SetCountry) {
Address address;
- EXPECT_EQ(std::string(), address.country_code());
+ EXPECT_EQ(string16(), address.GetRawInfo(ADDRESS_HOME_COUNTRY));
// Test basic conversion.
address.SetInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("United States"), "en-US");
string16 country = address.GetInfo(ADDRESS_HOME_COUNTRY, "en-US");
- EXPECT_EQ("US", address.country_code());
+ EXPECT_EQ(ASCIIToUTF16("US"), address.GetRawInfo(ADDRESS_HOME_COUNTRY));
EXPECT_EQ(ASCIIToUTF16("United States"), country);
// Test basic synonym detection.
address.SetInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("USA"), "en-US");
country = address.GetInfo(ADDRESS_HOME_COUNTRY, "en-US");
- EXPECT_EQ("US", address.country_code());
+ EXPECT_EQ(ASCIIToUTF16("US"), address.GetRawInfo(ADDRESS_HOME_COUNTRY));
EXPECT_EQ(ASCIIToUTF16("United States"), country);
// Test case-insensitivity.
address.SetInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("canADA"), "en-US");
country = address.GetInfo(ADDRESS_HOME_COUNTRY, "en-US");
- EXPECT_EQ("CA", address.country_code());
+ EXPECT_EQ(ASCIIToUTF16("CA"), address.GetRawInfo(ADDRESS_HOME_COUNTRY));
EXPECT_EQ(ASCIIToUTF16("Canada"), country);
// Test country code detection.
address.SetInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("JP"), "en-US");
country = address.GetInfo(ADDRESS_HOME_COUNTRY, "en-US");
- EXPECT_EQ("JP", address.country_code());
+ EXPECT_EQ(ASCIIToUTF16("JP"), address.GetRawInfo(ADDRESS_HOME_COUNTRY));
EXPECT_EQ(ASCIIToUTF16("Japan"), country);
// Test that we ignore unknown countries.
address.SetInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("Unknown"), "en-US");
country = address.GetInfo(ADDRESS_HOME_COUNTRY, "en-US");
- EXPECT_EQ(std::string(), address.country_code());
+ EXPECT_EQ(string16(), address.GetRawInfo(ADDRESS_HOME_COUNTRY));
EXPECT_EQ(string16(), country);
}
// Test that we properly match typed values to stored country data.
TEST_F(AddressTest, IsCountry) {
Address address;
- address.set_country_code("US");
+ address.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US"));
const char* const kValidMatches[] = {
"United States",
@@ -126,8 +114,8 @@
}
// Make sure that garbage values don't match when the country code is empty.
- address.set_country_code("");
- EXPECT_EQ(std::string(), address.country_code());
+ address.SetRawInfo(ADDRESS_HOME_COUNTRY, string16());
+ EXPECT_EQ(string16(), address.GetRawInfo(ADDRESS_HOME_COUNTRY));
FieldTypeSet matching_types;
address.GetMatchingTypes(ASCIIToUTF16("Garbage"), "US", &matching_types);
EXPECT_EQ(0U, matching_types.size());
« no previous file with comments | « components/autofill/browser/address.cc ('k') | components/autofill/browser/android/auxiliary_profile_unittest_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698