| Index: components/autofill/browser/phone_number_i18n_unittest.cc
|
| diff --git a/components/autofill/browser/phone_number_i18n_unittest.cc b/components/autofill/browser/phone_number_i18n_unittest.cc
|
| index 05475206cb2dd1eb6be843d53f33e7b60107073a..4872a35f1f2f51223986a9312c815df18d2e5371 100644
|
| --- a/components/autofill/browser/phone_number_i18n_unittest.cc
|
| +++ b/components/autofill/browser/phone_number_i18n_unittest.cc
|
| @@ -18,127 +18,129 @@ using content::BrowserThread;
|
|
|
| TEST(PhoneNumberI18NTest, NormalizePhoneNumber) {
|
| // "Large" digits.
|
| - 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"));
|
| + base::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"));
|
|
|
| // 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"));
|
| + base::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"));
|
|
|
| - string16 phone3(UTF8ToUTF16("16503334\xef\xbc\x92\x35\xd9\xa5"));
|
| + base::string16 phone3(UTF8ToUTF16("16503334\xef\xbc\x92\x35\xd9\xa5"));
|
| EXPECT_EQ(NormalizePhoneNumber(phone3, "US"), ASCIIToUTF16("16503334255"));
|
|
|
| - string16 phone4(UTF8ToUTF16("+1(650)2346789"));
|
| + base::string16 phone4(UTF8ToUTF16("+1(650)2346789"));
|
| EXPECT_EQ(NormalizePhoneNumber(phone4, "US"), ASCIIToUTF16("16502346789"));
|
|
|
| - string16 phone5(UTF8ToUTF16("6502346789"));
|
| + base::string16 phone5(UTF8ToUTF16("6502346789"));
|
| EXPECT_EQ(NormalizePhoneNumber(phone5, "US"), ASCIIToUTF16("6502346789"));
|
| }
|
|
|
| TEST(PhoneNumberI18NTest, ParsePhoneNumber) {
|
| - string16 number;
|
| - string16 city_code;
|
| - string16 country_code;
|
| + base::string16 number;
|
| + base::string16 city_code;
|
| + base::string16 country_code;
|
| i18n::phonenumbers::PhoneNumber unused_i18n_number;
|
|
|
| // Test for empty string. Should give back empty strings.
|
| - string16 phone0;
|
| + base::string16 phone0;
|
| EXPECT_FALSE(ParsePhoneNumber(phone0, "US",
|
| &country_code,
|
| &city_code,
|
| &number,
|
| &unused_i18n_number));
|
| - EXPECT_EQ(string16(), number);
|
| - EXPECT_EQ(string16(), city_code);
|
| - EXPECT_EQ(string16(), country_code);
|
| + EXPECT_EQ(base::string16(), number);
|
| + EXPECT_EQ(base::string16(), city_code);
|
| + EXPECT_EQ(base::string16(), country_code);
|
|
|
| // Test for string with less than 7 digits. Should give back empty strings.
|
| - string16 phone1(ASCIIToUTF16("1234"));
|
| + base::string16 phone1(ASCIIToUTF16("1234"));
|
| EXPECT_FALSE(ParsePhoneNumber(phone1, "US",
|
| &country_code,
|
| &city_code,
|
| &number,
|
| &unused_i18n_number));
|
| - EXPECT_EQ(string16(), number);
|
| - EXPECT_EQ(string16(), city_code);
|
| - EXPECT_EQ(string16(), country_code);
|
| + EXPECT_EQ(base::string16(), number);
|
| + EXPECT_EQ(base::string16(), city_code);
|
| + EXPECT_EQ(base::string16(), country_code);
|
|
|
| // Test for string with exactly 7 digits.
|
| // Not a valid number - starts with 1
|
| - string16 phone2(ASCIIToUTF16("1234567"));
|
| + base::string16 phone2(ASCIIToUTF16("1234567"));
|
| EXPECT_FALSE(ParsePhoneNumber(phone2, "US",
|
| &country_code,
|
| &city_code,
|
| &number,
|
| &unused_i18n_number));
|
| - EXPECT_EQ(string16(), number);
|
| - EXPECT_EQ(string16(), city_code);
|
| - EXPECT_EQ(string16(), country_code);
|
| + EXPECT_EQ(base::string16(), number);
|
| + EXPECT_EQ(base::string16(), city_code);
|
| + EXPECT_EQ(base::string16(), country_code);
|
|
|
| // Not a valid number - does not have area code.
|
| - string16 phone3(ASCIIToUTF16("2234567"));
|
| + base::string16 phone3(ASCIIToUTF16("2234567"));
|
| EXPECT_FALSE(ParsePhoneNumber(phone3, "US",
|
| &country_code,
|
| &city_code,
|
| &number,
|
| &unused_i18n_number));
|
| - EXPECT_EQ(string16(), number);
|
| - EXPECT_EQ(string16(), city_code);
|
| - EXPECT_EQ(string16(), country_code);
|
| + EXPECT_EQ(base::string16(), number);
|
| + EXPECT_EQ(base::string16(), city_code);
|
| + EXPECT_EQ(base::string16(), country_code);
|
|
|
| // Test for string with greater than 7 digits but less than 10 digits.
|
| // Should fail parsing in US.
|
| - string16 phone4(ASCIIToUTF16("123456789"));
|
| + base::string16 phone4(ASCIIToUTF16("123456789"));
|
| EXPECT_FALSE(ParsePhoneNumber(phone4, "US",
|
| &country_code,
|
| &city_code,
|
| &number,
|
| &unused_i18n_number));
|
| - EXPECT_EQ(string16(), number);
|
| - EXPECT_EQ(string16(), city_code);
|
| - EXPECT_EQ(string16(), country_code);
|
| + EXPECT_EQ(base::string16(), number);
|
| + EXPECT_EQ(base::string16(), city_code);
|
| + EXPECT_EQ(base::string16(), country_code);
|
|
|
| // Test for string with greater than 7 digits but less than 10 digits and
|
| // separators.
|
| // Should fail parsing in US.
|
| - string16 phone_separator4(ASCIIToUTF16("12.345-6789"));
|
| + base::string16 phone_separator4(ASCIIToUTF16("12.345-6789"));
|
| EXPECT_FALSE(ParsePhoneNumber(phone_separator4, "US",
|
| &country_code,
|
| &city_code,
|
| &number,
|
| &unused_i18n_number));
|
| - EXPECT_EQ(string16(), number);
|
| - EXPECT_EQ(string16(), city_code);
|
| - EXPECT_EQ(string16(), country_code);
|
| + EXPECT_EQ(base::string16(), number);
|
| + EXPECT_EQ(base::string16(), city_code);
|
| + EXPECT_EQ(base::string16(), country_code);
|
|
|
| // Test for string with exactly 10 digits.
|
| // Should give back phone number and city code.
|
| // This one going to fail because of the incorrect area code.
|
| - string16 phone5(ASCIIToUTF16("1234567890"));
|
| + base::string16 phone5(ASCIIToUTF16("1234567890"));
|
| EXPECT_FALSE(ParsePhoneNumber(phone5, "US",
|
| &country_code,
|
| &city_code,
|
| &number,
|
| &unused_i18n_number));
|
| - EXPECT_EQ(string16(), number);
|
| - EXPECT_EQ(string16(), city_code);
|
| - EXPECT_EQ(string16(), country_code);
|
| + EXPECT_EQ(base::string16(), number);
|
| + EXPECT_EQ(base::string16(), city_code);
|
| + EXPECT_EQ(base::string16(), country_code);
|
|
|
| - string16 phone6(ASCIIToUTF16("6501567890"));
|
| + base::string16 phone6(ASCIIToUTF16("6501567890"));
|
| // This one going to fail because of the incorrect number (starts with 1).
|
| EXPECT_FALSE(ParsePhoneNumber(phone6, "US",
|
| &country_code,
|
| &city_code,
|
| &number,
|
| &unused_i18n_number));
|
| - EXPECT_EQ(string16(), number);
|
| - EXPECT_EQ(string16(), city_code);
|
| - EXPECT_EQ(string16(), country_code);
|
| + EXPECT_EQ(base::string16(), number);
|
| + EXPECT_EQ(base::string16(), city_code);
|
| + EXPECT_EQ(base::string16(), country_code);
|
|
|
| - string16 phone7(ASCIIToUTF16("6504567890"));
|
| + base::string16 phone7(ASCIIToUTF16("6504567890"));
|
| EXPECT_TRUE(ParsePhoneNumber(phone7, "US",
|
| &country_code,
|
| &city_code,
|
| @@ -146,11 +148,11 @@ TEST(PhoneNumberI18NTest, ParsePhoneNumber) {
|
| &unused_i18n_number));
|
| EXPECT_EQ(ASCIIToUTF16("4567890"), number);
|
| EXPECT_EQ(ASCIIToUTF16("650"), city_code);
|
| - EXPECT_EQ(string16(), country_code);
|
| + EXPECT_EQ(base::string16(), country_code);
|
|
|
| // Test for string with exactly 10 digits and separators.
|
| // Should give back phone number and city code.
|
| - string16 phone_separator7(ASCIIToUTF16("(650) 456-7890"));
|
| + base::string16 phone_separator7(ASCIIToUTF16("(650) 456-7890"));
|
| EXPECT_TRUE(ParsePhoneNumber(phone_separator7, "US",
|
| &country_code,
|
| &city_code,
|
| @@ -158,23 +160,23 @@ TEST(PhoneNumberI18NTest, ParsePhoneNumber) {
|
| &unused_i18n_number));
|
| EXPECT_EQ(ASCIIToUTF16("4567890"), number);
|
| EXPECT_EQ(ASCIIToUTF16("650"), city_code);
|
| - EXPECT_EQ(string16(), country_code);
|
| + EXPECT_EQ(base::string16(), country_code);
|
|
|
| // Tests for string with over 10 digits.
|
| // 01 is incorrect prefix in the USA, and if we interpret 011 as prefix, the
|
| // rest is too short for international number - the parsing should fail.
|
| - string16 phone8(ASCIIToUTF16("0116504567890"));
|
| + base::string16 phone8(ASCIIToUTF16("0116504567890"));
|
| EXPECT_FALSE(ParsePhoneNumber(phone8, "US",
|
| &country_code,
|
| &city_code,
|
| &number,
|
| &unused_i18n_number));
|
| - EXPECT_EQ(string16(), number);
|
| - EXPECT_EQ(string16(), city_code);
|
| - EXPECT_EQ(string16(), country_code);
|
| + EXPECT_EQ(base::string16(), number);
|
| + EXPECT_EQ(base::string16(), city_code);
|
| + EXPECT_EQ(base::string16(), country_code);
|
|
|
| // 011 is a correct "dial out" prefix in the USA - the parsing should succeed.
|
| - string16 phone9(ASCIIToUTF16("01116504567890"));
|
| + base::string16 phone9(ASCIIToUTF16("01116504567890"));
|
| EXPECT_TRUE(ParsePhoneNumber(phone9, "US",
|
| &country_code,
|
| &city_code,
|
| @@ -185,7 +187,7 @@ TEST(PhoneNumberI18NTest, ParsePhoneNumber) {
|
| EXPECT_EQ(ASCIIToUTF16("1"), country_code);
|
|
|
| // 011 is a correct "dial out" prefix in the USA - the parsing should succeed.
|
| - string16 phone10(ASCIIToUTF16("01178124567890"));
|
| + base::string16 phone10(ASCIIToUTF16("01178124567890"));
|
| EXPECT_TRUE(ParsePhoneNumber(phone10, "US",
|
| &country_code,
|
| &city_code,
|
| @@ -198,7 +200,7 @@ TEST(PhoneNumberI18NTest, ParsePhoneNumber) {
|
| // Test for string with over 10 digits with separator characters.
|
| // Should give back phone number, city code, and country code. "011" is
|
| // US "dial out" code, which is discarded.
|
| - string16 phone11(ASCIIToUTF16("(0111) 650-456.7890"));
|
| + base::string16 phone11(ASCIIToUTF16("(0111) 650-456.7890"));
|
| EXPECT_TRUE(ParsePhoneNumber(phone11, "US",
|
| &country_code,
|
| &city_code,
|
| @@ -210,7 +212,7 @@ TEST(PhoneNumberI18NTest, ParsePhoneNumber) {
|
|
|
| // Now try phone from Chech republic - it has 00 dial out code, 420 country
|
| // code and variable length area codes.
|
| - string16 phone12(ASCIIToUTF16("+420 27-89.10.112"));
|
| + base::string16 phone12(ASCIIToUTF16("+420 27-89.10.112"));
|
| EXPECT_TRUE(ParsePhoneNumber(phone12, "US",
|
| &country_code,
|
| &city_code,
|
| @@ -229,7 +231,7 @@ TEST(PhoneNumberI18NTest, ParsePhoneNumber) {
|
| EXPECT_EQ(ASCIIToUTF16("278"), city_code);
|
| EXPECT_EQ(ASCIIToUTF16("420"), country_code);
|
|
|
| - string16 phone13(ASCIIToUTF16("420 57-89.10.112"));
|
| + base::string16 phone13(ASCIIToUTF16("420 57-89.10.112"));
|
| EXPECT_FALSE(ParsePhoneNumber(phone13, "US",
|
| &country_code,
|
| &city_code,
|
| @@ -244,7 +246,7 @@ TEST(PhoneNumberI18NTest, ParsePhoneNumber) {
|
| EXPECT_EQ(ASCIIToUTF16("578"), city_code);
|
| EXPECT_EQ(ASCIIToUTF16("420"), country_code);
|
|
|
| - string16 phone14(ASCIIToUTF16("1-650-FLOWERS"));
|
| + base::string16 phone14(ASCIIToUTF16("1-650-FLOWERS"));
|
| EXPECT_TRUE(ParsePhoneNumber(phone14, "US",
|
| &country_code,
|
| &city_code,
|
| @@ -256,7 +258,7 @@ TEST(PhoneNumberI18NTest, ParsePhoneNumber) {
|
|
|
| // 800 is not an area code, but the destination code. In our library these
|
| // codes should be treated the same as area codes.
|
| - string16 phone15(ASCIIToUTF16("1-800-FLOWERS"));
|
| + base::string16 phone15(ASCIIToUTF16("1-800-FLOWERS"));
|
| EXPECT_TRUE(ParsePhoneNumber(phone15, "US",
|
| &country_code,
|
| &city_code,
|
| @@ -268,38 +270,38 @@ TEST(PhoneNumberI18NTest, ParsePhoneNumber) {
|
| }
|
|
|
| TEST(PhoneNumberI18NTest, ConstructPhoneNumber) {
|
| - string16 number;
|
| + base::string16 number;
|
| EXPECT_TRUE(ConstructPhoneNumber(ASCIIToUTF16("1"),
|
| ASCIIToUTF16("650"),
|
| ASCIIToUTF16("2345678"),
|
| "US",
|
| &number));
|
| EXPECT_EQ(number, ASCIIToUTF16("+1 650-234-5678"));
|
| - EXPECT_TRUE(ConstructPhoneNumber(string16(),
|
| + EXPECT_TRUE(ConstructPhoneNumber(base::string16(),
|
| ASCIIToUTF16("650"),
|
| ASCIIToUTF16("2345678"),
|
| "US",
|
| &number));
|
| EXPECT_EQ(number, ASCIIToUTF16("(650) 234-5678"));
|
| EXPECT_TRUE(ConstructPhoneNumber(ASCIIToUTF16("1"),
|
| - string16(),
|
| + base::string16(),
|
| ASCIIToUTF16("6502345678"),
|
| "US",
|
| &number));
|
| EXPECT_EQ(number, ASCIIToUTF16("+1 650-234-5678"));
|
| - EXPECT_TRUE(ConstructPhoneNumber(string16(),
|
| - string16(),
|
| + EXPECT_TRUE(ConstructPhoneNumber(base::string16(),
|
| + base::string16(),
|
| ASCIIToUTF16("6502345678"),
|
| "US",
|
| &number));
|
| EXPECT_EQ(number, ASCIIToUTF16("(650) 234-5678"));
|
|
|
| - EXPECT_FALSE(ConstructPhoneNumber(string16(),
|
| + EXPECT_FALSE(ConstructPhoneNumber(base::string16(),
|
| ASCIIToUTF16("650"),
|
| ASCIIToUTF16("234567890"),
|
| "US",
|
| &number));
|
| - EXPECT_EQ(number, string16());
|
| + EXPECT_EQ(number, base::string16());
|
| // Italian number
|
| EXPECT_TRUE(ConstructPhoneNumber(ASCIIToUTF16("39"),
|
| ASCIIToUTF16("347"),
|
| @@ -307,7 +309,7 @@ TEST(PhoneNumberI18NTest, ConstructPhoneNumber) {
|
| "IT",
|
| &number));
|
| EXPECT_EQ(number, ASCIIToUTF16("+39 347 234 5678"));
|
| - EXPECT_TRUE(ConstructPhoneNumber(string16(),
|
| + EXPECT_TRUE(ConstructPhoneNumber(base::string16(),
|
| ASCIIToUTF16("347"),
|
| ASCIIToUTF16("2345678"),
|
| "IT",
|
| @@ -320,7 +322,7 @@ TEST(PhoneNumberI18NTest, ConstructPhoneNumber) {
|
| "DE",
|
| &number));
|
| EXPECT_EQ(number, ASCIIToUTF16("+49 2423/45678901"));
|
| - EXPECT_TRUE(ConstructPhoneNumber(string16(),
|
| + EXPECT_TRUE(ConstructPhoneNumber(base::string16(),
|
| ASCIIToUTF16("024"),
|
| ASCIIToUTF16("2345678901"),
|
| "DE",
|
|
|