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

Unified Diff: components/autofill/core/browser/phone_number_unittest.cc

Issue 374053007: Change PhoneNumber::SetInfo to only apply formatting where there is none (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: better way 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
« no previous file with comments | « components/autofill/core/browser/phone_number_i18n_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/autofill/core/browser/phone_number_unittest.cc
diff --git a/components/autofill/core/browser/phone_number_unittest.cc b/components/autofill/core/browser/phone_number_unittest.cc
index 29b1694803b9739ae4306a9f6d732911544fcdc8..b858768eb87a264a091c18dd4c53176572f3535e 100644
--- a/components/autofill/core/browser/phone_number_unittest.cc
+++ b/components/autofill/core/browser/phone_number_unittest.cc
@@ -104,11 +104,21 @@ TEST(PhoneNumberTest, SetInfo) {
ASCIIToUTF16("8887776666"), "US"));
EXPECT_EQ(ASCIIToUTF16("(888) 777-6666"),
phone.GetRawInfo(PHONE_HOME_WHOLE_NUMBER));
+ EXPECT_TRUE(phone.SetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER),
+ ASCIIToUTF16("+18887776666"),
+ "US"));
+ EXPECT_EQ(ASCIIToUTF16("+1 888-777-6666"),
+ phone.GetRawInfo(PHONE_HOME_WHOLE_NUMBER));
- // Differently formatted numbers should be re-formatted.
+ // Differently formatted numbers should be left alone.
EXPECT_TRUE(phone.SetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER),
ASCIIToUTF16("800-432-8765"), "US"));
- EXPECT_EQ(ASCIIToUTF16("(800) 432-8765"),
+ EXPECT_EQ(ASCIIToUTF16("800-432-8765"),
+ phone.GetRawInfo(PHONE_HOME_WHOLE_NUMBER));
+
+ // SetRawInfo should not try to format.
+ phone.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("8004328765"));
+ EXPECT_EQ(ASCIIToUTF16("8004328765"),
phone.GetRawInfo(PHONE_HOME_WHOLE_NUMBER));
// Invalid numbers should not be stored. In the US, phone numbers cannot
« no previous file with comments | « components/autofill/core/browser/phone_number_i18n_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698