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

Side by Side Diff: components/autofill/core/browser/phone_number_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 unified diff | Download patch
OLDNEW
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 "base/strings/string16.h" 5 #include "base/strings/string16.h"
6 #include "base/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "components/autofill/core/browser/autofill_profile.h" 7 #include "components/autofill/core/browser/autofill_profile.h"
8 #include "components/autofill/core/browser/autofill_type.h" 8 #include "components/autofill/core/browser/autofill_type.h"
9 #include "components/autofill/core/browser/field_types.h" 9 #include "components/autofill/core/browser/field_types.h"
10 #include "components/autofill/core/browser/phone_number.h" 10 #include "components/autofill/core/browser/phone_number.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 phone.GetRawInfo(PHONE_HOME_WHOLE_NUMBER)); 100 phone.GetRawInfo(PHONE_HOME_WHOLE_NUMBER));
101 101
102 // Unformatted numbers should be formatted. 102 // Unformatted numbers should be formatted.
103 EXPECT_TRUE(phone.SetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER), 103 EXPECT_TRUE(phone.SetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER),
104 ASCIIToUTF16("8887776666"), "US")); 104 ASCIIToUTF16("8887776666"), "US"));
105 EXPECT_EQ(ASCIIToUTF16("(888) 777-6666"), 105 EXPECT_EQ(ASCIIToUTF16("(888) 777-6666"),
106 phone.GetRawInfo(PHONE_HOME_WHOLE_NUMBER)); 106 phone.GetRawInfo(PHONE_HOME_WHOLE_NUMBER));
107 EXPECT_TRUE(phone.SetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER), 107 EXPECT_TRUE(phone.SetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER),
108 ASCIIToUTF16("+18887776666"), 108 ASCIIToUTF16("+18887776666"),
109 "US")); 109 "US"));
110 EXPECT_EQ(ASCIIToUTF16("+1 888-777-6666"), 110 EXPECT_EQ(ASCIIToUTF16("1 888-777-6666"),
111 phone.GetRawInfo(PHONE_HOME_WHOLE_NUMBER)); 111 phone.GetRawInfo(PHONE_HOME_WHOLE_NUMBER));
112 112
113 // Differently formatted numbers should be left alone. 113 // Differently formatted numbers should be left alone.
114 EXPECT_TRUE(phone.SetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER), 114 EXPECT_TRUE(phone.SetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER),
115 ASCIIToUTF16("800-432-8765"), "US")); 115 ASCIIToUTF16("800-432-8765"), "US"));
116 EXPECT_EQ(ASCIIToUTF16("800-432-8765"), 116 EXPECT_EQ(ASCIIToUTF16("800-432-8765"),
117 phone.GetRawInfo(PHONE_HOME_WHOLE_NUMBER)); 117 phone.GetRawInfo(PHONE_HOME_WHOLE_NUMBER));
118 118
119 // SetRawInfo should not try to format. 119 // SetRawInfo should not try to format.
120 phone.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("8004328765")); 120 phone.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("8004328765"));
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 ASCIIToUTF16("1"))); 166 ASCIIToUTF16("1")));
167 EXPECT_TRUE(number1.SetInfo(AutofillType(PHONE_HOME_COUNTRY_CODE), 167 EXPECT_TRUE(number1.SetInfo(AutofillType(PHONE_HOME_COUNTRY_CODE),
168 ASCIIToUTF16("1"))); 168 ASCIIToUTF16("1")));
169 EXPECT_TRUE(number1.SetInfo(AutofillType(PHONE_HOME_CITY_CODE), 169 EXPECT_TRUE(number1.SetInfo(AutofillType(PHONE_HOME_CITY_CODE),
170 ASCIIToUTF16("650"))); 170 ASCIIToUTF16("650")));
171 EXPECT_TRUE(number1.SetInfo(AutofillType(PHONE_HOME_NUMBER), 171 EXPECT_TRUE(number1.SetInfo(AutofillType(PHONE_HOME_NUMBER),
172 ASCIIToUTF16("2345678"))); 172 ASCIIToUTF16("2345678")));
173 base::string16 parsed_phone; 173 base::string16 parsed_phone;
174 EXPECT_TRUE(number1.ParseNumber(profile, "en-US", &parsed_phone)); 174 EXPECT_TRUE(number1.ParseNumber(profile, "en-US", &parsed_phone));
175 // International format as it has a country code. 175 // International format as it has a country code.
176 EXPECT_EQ(ASCIIToUTF16("+1 650-234-5678"), parsed_phone); 176 EXPECT_EQ(ASCIIToUTF16("1 650-234-5678"), parsed_phone);
177 177
178 PhoneNumber::PhoneCombineHelper number3; 178 PhoneNumber::PhoneCombineHelper number3;
179 EXPECT_TRUE(number3.SetInfo(AutofillType(PHONE_HOME_CITY_CODE), 179 EXPECT_TRUE(number3.SetInfo(AutofillType(PHONE_HOME_CITY_CODE),
180 ASCIIToUTF16("650"))); 180 ASCIIToUTF16("650")));
181 EXPECT_TRUE(number3.SetInfo(AutofillType(PHONE_HOME_NUMBER), 181 EXPECT_TRUE(number3.SetInfo(AutofillType(PHONE_HOME_NUMBER),
182 ASCIIToUTF16("2345680"))); 182 ASCIIToUTF16("2345680")));
183 EXPECT_TRUE(number3.ParseNumber(profile, "en-US", &parsed_phone)); 183 EXPECT_TRUE(number3.ParseNumber(profile, "en-US", &parsed_phone));
184 // National format as it does not have a country code. 184 // National format as it does not have a country code.
185 EXPECT_EQ(ASCIIToUTF16("(650) 234-5680"), parsed_phone); 185 EXPECT_EQ(ASCIIToUTF16("(650) 234-5680"), parsed_phone);
186 186
(...skipping 28 matching lines...) Expand all
215 ASCIIToUTF16("650"))); 215 ASCIIToUTF16("650")));
216 EXPECT_TRUE(number7.SetInfo(AutofillType(PHONE_HOME_NUMBER), 216 EXPECT_TRUE(number7.SetInfo(AutofillType(PHONE_HOME_NUMBER),
217 ASCIIToUTF16("234"))); 217 ASCIIToUTF16("234")));
218 EXPECT_TRUE(number7.SetInfo(AutofillType(PHONE_HOME_NUMBER), 218 EXPECT_TRUE(number7.SetInfo(AutofillType(PHONE_HOME_NUMBER),
219 ASCIIToUTF16("5682"))); 219 ASCIIToUTF16("5682")));
220 EXPECT_TRUE(number7.ParseNumber(AutofillProfile(), "en-US", &parsed_phone)); 220 EXPECT_TRUE(number7.ParseNumber(AutofillProfile(), "en-US", &parsed_phone));
221 EXPECT_EQ(ASCIIToUTF16("(650) 234-5682"), parsed_phone); 221 EXPECT_EQ(ASCIIToUTF16("(650) 234-5682"), parsed_phone);
222 } 222 }
223 223
224 } // namespace autofill 224 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/phone_number_i18n_unittest.cc ('k') | components/test/data/autofill/OWNERS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698