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

Unified Diff: chrome/browser/ui/autofill/data_model_wrapper_unittest.cc

Issue 355823007: Adjust autofill phone number format. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update android test. Created 6 years, 5 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: chrome/browser/ui/autofill/data_model_wrapper_unittest.cc
diff --git a/chrome/browser/ui/autofill/data_model_wrapper_unittest.cc b/chrome/browser/ui/autofill/data_model_wrapper_unittest.cc
index 2df388eaed52c096572778edd0673a915bc0f810..050cba76d0c53ad7756179ab25d9dbf836266a9b 100644
--- a/chrome/browser/ui/autofill/data_model_wrapper_unittest.cc
+++ b/chrome/browser/ui/autofill/data_model_wrapper_unittest.cc
@@ -98,19 +98,19 @@ TEST(DataModelWrapperTest, GetDisplayText) {
base::string16 vertical, horizontal;
EXPECT_TRUE(
AutofillProfileWrapper(&profile).GetDisplayText(&horizontal, &vertical));
- EXPECT_EQ(
- ASCIIToUTF16("John H. Doe, 666 Erebus St., Apt 8, Elysium, CA 91111\n"
- "johndoe@hades.com\n"
- "+1 650-211-1111"),
- horizontal);
- EXPECT_EQ(
- ASCIIToUTF16("John H. Doe\n"
- "666 Erebus St.\n"
- "Apt 8\n"
- "Elysium, CA 91111\n"
- "johndoe@hades.com\n"
- "+1 650-211-1111"),
- vertical);
+ EXPECT_EQ(ASCIIToUTF16(
+ "John H. Doe, 666 Erebus St., Apt 8, Elysium, CA 91111\n"
+ "johndoe@hades.com\n"
+ "1 650-211-1111"),
+ horizontal);
+ EXPECT_EQ(ASCIIToUTF16(
+ "John H. Doe\n"
+ "666 Erebus St.\n"
+ "Apt 8\n"
+ "Elysium, CA 91111\n"
+ "johndoe@hades.com\n"
+ "1 650-211-1111"),
+ vertical);
// A Japanese address.
AutofillProfile foreign_profile(
@@ -170,8 +170,9 @@ TEST(DataModelWrapperTest, GetDisplayPhoneNumber) {
const base::string16 national_unformatted = ASCIIToUTF16("3104567890");
const base::string16 national_formatted = ASCIIToUTF16("(310) 456-7890");
const base::string16 international_unformatted = ASCIIToUTF16("13104567890");
- const base::string16 international_formatted =
- ASCIIToUTF16("+1 310-456-7890");
+ const base::string16 international_unformatted_with_plus =
+ ASCIIToUTF16("+13104567890");
+ const base::string16 international_formatted = ASCIIToUTF16("1 310-456-7890");
const base::string16 user_formatted = ASCIIToUTF16("310.456 78 90");
scoped_ptr<wallet::WalletItems::MaskedInstrument> instrument(
@@ -210,6 +211,15 @@ TEST(DataModelWrapperTest, GetDisplayPhoneNumber) {
address_wrapper.GetInfoForDisplay(
AutofillType(PHONE_HOME_WHOLE_NUMBER)));
+ const_cast<wallet::Address*>(&instrument->address())
+ ->SetPhoneNumber(international_unformatted_with_plus);
+ EXPECT_EQ(national_formatted,
+ instrument_wrapper.GetInfoForDisplay(
+ AutofillType(PHONE_HOME_WHOLE_NUMBER)));
+ EXPECT_EQ(
+ national_formatted,
+ address_wrapper.GetInfoForDisplay(AutofillType(PHONE_HOME_WHOLE_NUMBER)));
+
// Autofill numbers that are unformatted get formatted either nationally or
// internationally depending on the presence of a country code. Formatted
// numbers stay formatted.
@@ -217,6 +227,11 @@ TEST(DataModelWrapperTest, GetDisplayPhoneNumber) {
EXPECT_EQ(international_formatted,
profile_wrapper.GetInfoForDisplay(
AutofillType(PHONE_HOME_WHOLE_NUMBER)));
+ profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER,
+ international_unformatted_with_plus);
+ EXPECT_EQ(
+ international_formatted,
+ profile_wrapper.GetInfoForDisplay(AutofillType(PHONE_HOME_WHOLE_NUMBER)));
profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, national_unformatted);
EXPECT_EQ(national_formatted,
profile_wrapper.GetInfoForDisplay(
@@ -229,7 +244,6 @@ TEST(DataModelWrapperTest, GetDisplayPhoneNumber) {
EXPECT_EQ(user_formatted,
profile_wrapper.GetInfoForDisplay(
AutofillType(PHONE_HOME_WHOLE_NUMBER)));
-
}
} // namespace autofill

Powered by Google App Engine
This is Rietveld 408576698