OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/utf_string_conversions.h" | 5 #include "base/utf_string_conversions.h" |
6 #include "chrome/browser/autofill/phone_number_i18n.h" | 6 #include "chrome/browser/autofill/phone_number_i18n.h" |
7 #include "chrome/test/base/testing_browser_process_test.h" | |
8 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
9 | 8 |
10 using autofill_i18n::NormalizePhoneNumber; | 9 using autofill_i18n::NormalizePhoneNumber; |
11 using autofill_i18n::ParsePhoneNumber; | 10 using autofill_i18n::ParsePhoneNumber; |
12 using autofill_i18n::ConstructPhoneNumber; | 11 using autofill_i18n::ConstructPhoneNumber; |
13 using autofill_i18n::FormatPhone; | 12 using autofill_i18n::FormatPhone; |
14 using autofill_i18n::ComparePhones; | 13 using autofill_i18n::ComparePhones; |
15 using autofill_i18n::PhoneNumbersMatch; | 14 using autofill_i18n::PhoneNumbersMatch; |
16 | 15 |
17 typedef TestingBrowserProcessTest PhoneNumberI18NTest; | 16 typedef testing::Test PhoneNumberI18NTest; |
18 | 17 |
19 TEST_F(PhoneNumberI18NTest, NormalizePhoneNumber) { | 18 TEST_F(PhoneNumberI18NTest, NormalizePhoneNumber) { |
20 // "Large" digits. | 19 // "Large" digits. |
21 string16 phone1(UTF8ToUTF16("\xEF\xBC\x91\xEF\xBC\x96\xEF\xBC\x95\xEF\xBC\x90" | 20 string16 phone1(UTF8ToUTF16("\xEF\xBC\x91\xEF\xBC\x96\xEF\xBC\x95\xEF\xBC\x90" |
22 "\xEF\xBC\x97\xEF\xBC\x94\xEF\xBC\x99\xEF\xBC\x98" | 21 "\xEF\xBC\x97\xEF\xBC\x94\xEF\xBC\x99\xEF\xBC\x98" |
23 "\xEF\xBC\x93\xEF\xBC\x92\xEF\xBC\x93")); | 22 "\xEF\xBC\x93\xEF\xBC\x92\xEF\xBC\x93")); |
24 EXPECT_EQ(NormalizePhoneNumber(phone1, "US"), ASCIIToUTF16("16507498323")); | 23 EXPECT_EQ(NormalizePhoneNumber(phone1, "US"), ASCIIToUTF16("16507498323")); |
25 | 24 |
26 // Devanagari script digits. | 25 // Devanagari script digits. |
27 string16 phone2(UTF8ToUTF16("\xD9\xA1\xD9\xA6\xD9\xA5\xD9\xA0\xD9\xA8\xD9\xA3" | 26 string16 phone2(UTF8ToUTF16("\xD9\xA1\xD9\xA6\xD9\xA5\xD9\xA0\xD9\xA8\xD9\xA3" |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 "US")); | 398 "US")); |
400 EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("4158889999"), | 399 EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("4158889999"), |
401 ASCIIToUTF16("415 TUV WXYZ"), | 400 ASCIIToUTF16("415 TUV WXYZ"), |
402 "US")); | 401 "US")); |
403 | 402 |
404 // Partial matches don't count. | 403 // Partial matches don't count. |
405 EXPECT_FALSE(PhoneNumbersMatch(ASCIIToUTF16("14158889999"), | 404 EXPECT_FALSE(PhoneNumbersMatch(ASCIIToUTF16("14158889999"), |
406 ASCIIToUTF16("8889999"), | 405 ASCIIToUTF16("8889999"), |
407 "US")); | 406 "US")); |
408 } | 407 } |
OLD | NEW |