| 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/message_loop.h" |
| 5 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
| 6 #include "chrome/browser/autofill/phone_number_i18n.h" | 7 #include "chrome/browser/autofill/phone_number_i18n.h" |
| 8 #include "content/browser/browser_thread.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 8 | 10 |
| 9 using autofill_i18n::NormalizePhoneNumber; | 11 using autofill_i18n::NormalizePhoneNumber; |
| 10 using autofill_i18n::ParsePhoneNumber; | 12 using autofill_i18n::ParsePhoneNumber; |
| 11 using autofill_i18n::ConstructPhoneNumber; | 13 using autofill_i18n::ConstructPhoneNumber; |
| 12 using autofill_i18n::PhoneNumbersMatch; | 14 using autofill_i18n::PhoneNumbersMatch; |
| 13 | 15 |
| 14 typedef testing::Test PhoneNumberI18NTest; | 16 class PhoneNumberI18NTest : public testing::Test { |
| 17 public: |
| 18 // In order to access the application locale -- which the tested functions do |
| 19 // internally -- this test must run on the UI thread. |
| 20 PhoneNumberI18NTest() : ui_thread_(BrowserThread::UI, &message_loop_) {} |
| 21 |
| 22 private: |
| 23 MessageLoopForUI message_loop_; |
| 24 BrowserThread ui_thread_; |
| 25 |
| 26 DISALLOW_COPY_AND_ASSIGN(PhoneNumberI18NTest); |
| 27 }; |
| 15 | 28 |
| 16 TEST_F(PhoneNumberI18NTest, NormalizePhoneNumber) { | 29 TEST_F(PhoneNumberI18NTest, NormalizePhoneNumber) { |
| 17 // "Large" digits. | 30 // "Large" digits. |
| 18 string16 phone1(UTF8ToUTF16("\xEF\xBC\x91\xEF\xBC\x96\xEF\xBC\x95\xEF\xBC\x90" | 31 string16 phone1(UTF8ToUTF16("\xEF\xBC\x91\xEF\xBC\x96\xEF\xBC\x95\xEF\xBC\x90" |
| 19 "\xEF\xBC\x97\xEF\xBC\x94\xEF\xBC\x99\xEF\xBC\x98" | 32 "\xEF\xBC\x97\xEF\xBC\x94\xEF\xBC\x99\xEF\xBC\x98" |
| 20 "\xEF\xBC\x93\xEF\xBC\x92\xEF\xBC\x93")); | 33 "\xEF\xBC\x93\xEF\xBC\x92\xEF\xBC\x93")); |
| 21 EXPECT_EQ(NormalizePhoneNumber(phone1, "US"), ASCIIToUTF16("16507498323")); | 34 EXPECT_EQ(NormalizePhoneNumber(phone1, "US"), ASCIIToUTF16("16507498323")); |
| 22 | 35 |
| 23 // Devanagari script digits. | 36 // Devanagari script digits. |
| 24 string16 phone2(UTF8ToUTF16("\xD9\xA1\xD9\xA6\xD9\xA5\xD9\xA0\xD9\xA8\xD9\xA3" | 37 string16 phone2(UTF8ToUTF16("\xD9\xA1\xD9\xA6\xD9\xA5\xD9\xA0\xD9\xA8\xD9\xA3" |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 // Partial matches don't count. | 369 // Partial matches don't count. |
| 357 EXPECT_FALSE(PhoneNumbersMatch(ASCIIToUTF16("14158889999"), | 370 EXPECT_FALSE(PhoneNumbersMatch(ASCIIToUTF16("14158889999"), |
| 358 ASCIIToUTF16("8889999"), | 371 ASCIIToUTF16("8889999"), |
| 359 "US")); | 372 "US")); |
| 360 | 373 |
| 361 // Different numbers don't match. | 374 // Different numbers don't match. |
| 362 EXPECT_FALSE(PhoneNumbersMatch(ASCIIToUTF16("14158889999"), | 375 EXPECT_FALSE(PhoneNumbersMatch(ASCIIToUTF16("14158889999"), |
| 363 ASCIIToUTF16("1415888"), | 376 ASCIIToUTF16("1415888"), |
| 364 "US")); | 377 "US")); |
| 365 } | 378 } |
| OLD | NEW |