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

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: Created 7 years, 9 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,60 +48,44 @@
// 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",
- "USA",
- "US",
- "United states",
- "us"
- };
- for (size_t i = 0; i < arraysize(kValidMatches); ++i) {
- SCOPED_TRACE(kValidMatches[i]);
- FieldTypeSet matching_types;
- address.GetMatchingTypes(ASCIIToUTF16(kValidMatches[i]), "US",
- &matching_types);
- ASSERT_EQ(1U, matching_types.size());
- EXPECT_EQ(ADDRESS_HOME_COUNTRY, *matching_types.begin());
- }
Ilya Sherman 2013/04/05 05:18:01 Hmm, why did you remove this test coverage?
jam 2013/04/05 06:45:54 it seemed that that test coverate was for Address:
Ilya Sherman 2013/04/05 07:18:41 Ah, I missed that you'd removed that code. I'm pr
jam 2013/04/05 07:35:35 Done.
-
const char* const kInvalidMatches[] = {
"United",
"Garbage"
@@ -126,8 +98,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, ASCIIToUTF16(""));
Ilya Sherman 2013/04/05 05:18:01 nit: string16() rather than ASCIIToUTF16("")
jam 2013/04/05 06:45:54 Done.
+ EXPECT_EQ(string16(), address.GetRawInfo(ADDRESS_HOME_COUNTRY));
FieldTypeSet matching_types;
address.GetMatchingTypes(ASCIIToUTF16("Garbage"), "US", &matching_types);
EXPECT_EQ(0U, matching_types.size());

Powered by Google App Engine
This is Rietveld 408576698