Index: components/autofill/browser/phone_number_i18n_unittest.cc |
=================================================================== |
--- components/autofill/browser/phone_number_i18n_unittest.cc (revision 192175) |
+++ components/autofill/browser/phone_number_i18n_unittest.cc (working copy) |
@@ -21,21 +21,26 @@ |
string16 phone1(UTF8ToUTF16("\xEF\xBC\x91\xEF\xBC\x96\xEF\xBC\x95\xEF\xBC\x90" |
"\xEF\xBC\x97\xEF\xBC\x94\xEF\xBC\x99\xEF\xBC\x98" |
"\xEF\xBC\x93\xEF\xBC\x92\xEF\xBC\x93")); |
- EXPECT_EQ(NormalizePhoneNumber(phone1, "US"), ASCIIToUTF16("16507498323")); |
+ EXPECT_EQ(NormalizePhoneNumber(phone1, "US", "en-US"), |
+ ASCIIToUTF16("16507498323")); |
// Devanagari script digits. |
string16 phone2(UTF8ToUTF16("\xD9\xA1\xD9\xA6\xD9\xA5\xD9\xA0\xD9\xA8\xD9\xA3" |
"\xD9\xA2\xD9\xA3\xD9\xA7\xD9\xA4\xD9\xA9")); |
- EXPECT_EQ(NormalizePhoneNumber(phone2, "US"), ASCIIToUTF16("16508323749")); |
+ EXPECT_EQ(NormalizePhoneNumber(phone2, "US", "en-US"), |
+ ASCIIToUTF16("16508323749")); |
string16 phone3(UTF8ToUTF16("16503334\xef\xbc\x92\x35\xd9\xa5")); |
- EXPECT_EQ(NormalizePhoneNumber(phone3, "US"), ASCIIToUTF16("16503334255")); |
+ EXPECT_EQ(NormalizePhoneNumber(phone3, "US", "en-US"), |
+ ASCIIToUTF16("16503334255")); |
string16 phone4(UTF8ToUTF16("+1(650)2346789")); |
- EXPECT_EQ(NormalizePhoneNumber(phone4, "US"), ASCIIToUTF16("16502346789")); |
+ EXPECT_EQ(NormalizePhoneNumber(phone4, "US", "en-US"), |
+ ASCIIToUTF16("16502346789")); |
string16 phone5(UTF8ToUTF16("6502346789")); |
- EXPECT_EQ(NormalizePhoneNumber(phone5, "US"), ASCIIToUTF16("6502346789")); |
+ EXPECT_EQ(NormalizePhoneNumber(phone5, "US", "en-US"), |
+ ASCIIToUTF16("6502346789")); |
} |
TEST(PhoneNumberI18NTest, ParsePhoneNumber) { |
@@ -273,24 +278,28 @@ |
ASCIIToUTF16("650"), |
ASCIIToUTF16("2345678"), |
"US", |
+ "en-US", |
&number)); |
EXPECT_EQ(number, ASCIIToUTF16("+1 650-234-5678")); |
EXPECT_TRUE(ConstructPhoneNumber(string16(), |
ASCIIToUTF16("650"), |
ASCIIToUTF16("2345678"), |
"US", |
+ "en-US", |
&number)); |
EXPECT_EQ(number, ASCIIToUTF16("(650) 234-5678")); |
EXPECT_TRUE(ConstructPhoneNumber(ASCIIToUTF16("1"), |
string16(), |
ASCIIToUTF16("6502345678"), |
"US", |
+ "en-US", |
&number)); |
EXPECT_EQ(number, ASCIIToUTF16("+1 650-234-5678")); |
EXPECT_TRUE(ConstructPhoneNumber(string16(), |
string16(), |
ASCIIToUTF16("6502345678"), |
"US", |
+ "en-US", |
&number)); |
EXPECT_EQ(number, ASCIIToUTF16("(650) 234-5678")); |
@@ -298,6 +307,7 @@ |
ASCIIToUTF16("650"), |
ASCIIToUTF16("234567890"), |
"US", |
+ "en-US", |
&number)); |
EXPECT_EQ(number, string16()); |
// Italian number |
@@ -305,12 +315,14 @@ |
ASCIIToUTF16("347"), |
ASCIIToUTF16("2345678"), |
"IT", |
+ "en-US", |
&number)); |
EXPECT_EQ(number, ASCIIToUTF16("+39 347 234 5678")); |
EXPECT_TRUE(ConstructPhoneNumber(string16(), |
ASCIIToUTF16("347"), |
ASCIIToUTF16("2345678"), |
"IT", |
+ "en-US", |
&number)); |
EXPECT_EQ(number, ASCIIToUTF16("347 234 5678")); |
// German number. |
@@ -318,12 +330,14 @@ |
ASCIIToUTF16("024"), |
ASCIIToUTF16("2345678901"), |
"DE", |
+ "en-US", |
&number)); |
EXPECT_EQ(number, ASCIIToUTF16("+49 2423/45678901")); |
EXPECT_TRUE(ConstructPhoneNumber(string16(), |
ASCIIToUTF16("024"), |
ASCIIToUTF16("2345678901"), |
"DE", |
+ "en-US", |
&number)); |
EXPECT_EQ(number, ASCIIToUTF16("02423/45678901")); |
} |
@@ -332,41 +346,51 @@ |
// Same numbers, defined country code. |
EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("4158889999"), |
ASCIIToUTF16("4158889999"), |
- "US")); |
+ "US", |
+ "en-US")); |
// Same numbers, undefined country code. |
EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("4158889999"), |
ASCIIToUTF16("4158889999"), |
- "")); |
+ "", |
+ "en-US")); |
// Numbers differ by country code only. |
EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("14158889999"), |
ASCIIToUTF16("4158889999"), |
- "US")); |
+ "US", |
+ "en-US")); |
// Same numbers, different formats. |
EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("4158889999"), |
ASCIIToUTF16("415-888-9999"), |
- "US")); |
+ "US", |
+ "en-US")); |
EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("4158889999"), |
ASCIIToUTF16("(415)888-9999"), |
- "US")); |
+ "US", |
+ "en-US")); |
EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("4158889999"), |
ASCIIToUTF16("415 888 9999"), |
- "US")); |
+ "US", |
+ "en-US")); |
EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("4158889999"), |
ASCIIToUTF16("415 TUV WXYZ"), |
- "US")); |
+ "US", |
+ "en-US")); |
EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("1(415)888-99-99"), |
ASCIIToUTF16("+14158889999"), |
- "US")); |
+ "US", |
+ "en-US")); |
// Partial matches don't count. |
EXPECT_FALSE(PhoneNumbersMatch(ASCIIToUTF16("14158889999"), |
ASCIIToUTF16("8889999"), |
- "US")); |
+ "US", |
+ "en-US")); |
// Different numbers don't match. |
EXPECT_FALSE(PhoneNumbersMatch(ASCIIToUTF16("14158889999"), |
ASCIIToUTF16("1415888"), |
- "US")); |
+ "US", |
+ "en-US")); |
} |