OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/message_loop.h" |
6 #include "base/string16.h" | 6 #include "base/string16.h" |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "components/autofill/browser/phone_number_i18n.h" | 8 #include "components/autofill/browser/phone_number_i18n.h" |
9 #include "content/public/test/test_browser_thread.h" | 9 #include "content/public/test/test_browser_thread.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 ASCIIToUTF16("2345678901"), | 325 ASCIIToUTF16("2345678901"), |
326 "DE", | 326 "DE", |
327 &number)); | 327 &number)); |
328 EXPECT_EQ(number, ASCIIToUTF16("02423/45678901")); | 328 EXPECT_EQ(number, ASCIIToUTF16("02423/45678901")); |
329 } | 329 } |
330 | 330 |
331 TEST(PhoneNumberI18NTest, PhoneNumbersMatch) { | 331 TEST(PhoneNumberI18NTest, PhoneNumbersMatch) { |
332 // Same numbers, defined country code. | 332 // Same numbers, defined country code. |
333 EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("4158889999"), | 333 EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("4158889999"), |
334 ASCIIToUTF16("4158889999"), | 334 ASCIIToUTF16("4158889999"), |
335 "US")); | 335 "US", |
| 336 "en-US")); |
336 // Same numbers, undefined country code. | 337 // Same numbers, undefined country code. |
337 EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("4158889999"), | 338 EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("4158889999"), |
338 ASCIIToUTF16("4158889999"), | 339 ASCIIToUTF16("4158889999"), |
339 "")); | 340 "", |
| 341 "en-US")); |
340 | 342 |
341 // Numbers differ by country code only. | 343 // Numbers differ by country code only. |
342 EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("14158889999"), | 344 EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("14158889999"), |
343 ASCIIToUTF16("4158889999"), | 345 ASCIIToUTF16("4158889999"), |
344 "US")); | 346 "US", |
| 347 "en-US")); |
345 | 348 |
346 // Same numbers, different formats. | 349 // Same numbers, different formats. |
347 EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("4158889999"), | 350 EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("4158889999"), |
348 ASCIIToUTF16("415-888-9999"), | 351 ASCIIToUTF16("415-888-9999"), |
349 "US")); | 352 "US", |
| 353 "en-US")); |
350 EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("4158889999"), | 354 EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("4158889999"), |
351 ASCIIToUTF16("(415)888-9999"), | 355 ASCIIToUTF16("(415)888-9999"), |
352 "US")); | 356 "US", |
| 357 "en-US")); |
353 EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("4158889999"), | 358 EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("4158889999"), |
354 ASCIIToUTF16("415 888 9999"), | 359 ASCIIToUTF16("415 888 9999"), |
355 "US")); | 360 "US", |
| 361 "en-US")); |
356 EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("4158889999"), | 362 EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("4158889999"), |
357 ASCIIToUTF16("415 TUV WXYZ"), | 363 ASCIIToUTF16("415 TUV WXYZ"), |
358 "US")); | 364 "US", |
| 365 "en-US")); |
359 EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("1(415)888-99-99"), | 366 EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("1(415)888-99-99"), |
360 ASCIIToUTF16("+14158889999"), | 367 ASCIIToUTF16("+14158889999"), |
361 "US")); | 368 "US", |
| 369 "en-US")); |
362 | 370 |
363 // Partial matches don't count. | 371 // Partial matches don't count. |
364 EXPECT_FALSE(PhoneNumbersMatch(ASCIIToUTF16("14158889999"), | 372 EXPECT_FALSE(PhoneNumbersMatch(ASCIIToUTF16("14158889999"), |
365 ASCIIToUTF16("8889999"), | 373 ASCIIToUTF16("8889999"), |
366 "US")); | 374 "US", |
| 375 "en-US")); |
367 | 376 |
368 // Different numbers don't match. | 377 // Different numbers don't match. |
369 EXPECT_FALSE(PhoneNumbersMatch(ASCIIToUTF16("14158889999"), | 378 EXPECT_FALSE(PhoneNumbersMatch(ASCIIToUTF16("14158889999"), |
370 ASCIIToUTF16("1415888"), | 379 ASCIIToUTF16("1415888"), |
371 "US")); | 380 "US", |
| 381 "en-US")); |
372 } | 382 } |
OLD | NEW |