| 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 "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 | 8 |
| 9 using autofill_i18n::NormalizePhoneNumber; | 9 using autofill_i18n::NormalizePhoneNumber; |
| 10 using autofill_i18n::ParsePhoneNumber; | 10 using autofill_i18n::ParsePhoneNumber; |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 EXPECT_EQ(number, ASCIIToUTF16("+1 650-234-5678")); | 276 EXPECT_EQ(number, ASCIIToUTF16("+1 650-234-5678")); |
| 277 | 277 |
| 278 EXPECT_FALSE(ConstructPhoneNumber(ASCIIToUTF16(""), | 278 EXPECT_FALSE(ConstructPhoneNumber(ASCIIToUTF16(""), |
| 279 ASCIIToUTF16("650"), | 279 ASCIIToUTF16("650"), |
| 280 ASCIIToUTF16("234567890"), | 280 ASCIIToUTF16("234567890"), |
| 281 "US", | 281 "US", |
| 282 autofill_i18n::INTERNATIONAL, | 282 autofill_i18n::INTERNATIONAL, |
| 283 &number)); | 283 &number)); |
| 284 EXPECT_EQ(number, string16()); | 284 EXPECT_EQ(number, string16()); |
| 285 // Italian number | 285 // Italian number |
| 286 EXPECT_TRUE(ConstructPhoneNumber(ASCIIToUTF16("39"), | 286 EXPECT_TRUE(ConstructPhoneNumber(ASCIIToUTF16(""), |
| 287 ASCIIToUTF16(""), | 287 ASCIIToUTF16("347"), |
| 288 ASCIIToUTF16("236618300"), | 288 ASCIIToUTF16("2345678"), |
| 289 "US", | 289 "IT", |
| 290 autofill_i18n::INTERNATIONAL, | 290 autofill_i18n::INTERNATIONAL, |
| 291 &number)); | 291 &number)); |
| 292 EXPECT_EQ(number, ASCIIToUTF16("+39 236618300")); | 292 EXPECT_EQ(number, ASCIIToUTF16("+39 347 234 5678")); |
| 293 EXPECT_TRUE(ConstructPhoneNumber(ASCIIToUTF16("39"), | 293 // German number. |
| 294 ASCIIToUTF16(""), | 294 EXPECT_TRUE(ConstructPhoneNumber(ASCIIToUTF16("49"), |
| 295 ASCIIToUTF16("236618300"), | 295 ASCIIToUTF16("024"), |
| 296 "US", | 296 ASCIIToUTF16("2345678901"), |
| 297 "DE", |
| 297 autofill_i18n::NATIONAL, | 298 autofill_i18n::NATIONAL, |
| 298 &number)); | 299 &number)); |
| 299 EXPECT_EQ(number, ASCIIToUTF16("236618300")); | 300 EXPECT_EQ(number, ASCIIToUTF16("02423/45678901")); |
| 301 |
| 302 EXPECT_TRUE(ConstructPhoneNumber(ASCIIToUTF16("49"), |
| 303 ASCIIToUTF16("024"), |
| 304 ASCIIToUTF16("2345678901"), |
| 305 "DE", |
| 306 autofill_i18n::INTERNATIONAL, |
| 307 &number)); |
| 308 EXPECT_EQ(number, ASCIIToUTF16("+49 2423/45678901")); |
| 300 } | 309 } |
| 301 | 310 |
| 302 TEST(PhoneNumberI18NTest, FormatPhone) { | 311 TEST(PhoneNumberI18NTest, FormatPhone) { |
| 303 EXPECT_EQ(FormatPhone(ASCIIToUTF16("1[650]234-56-78"), "US", | 312 EXPECT_EQ(FormatPhone(ASCIIToUTF16("1[650]234-56-78"), "US", |
| 304 autofill_i18n::NATIONAL), | 313 autofill_i18n::NATIONAL), |
| 305 ASCIIToUTF16("(650) 234-5678")); | 314 ASCIIToUTF16("(650) 234-5678")); |
| 306 EXPECT_EQ(FormatPhone(ASCIIToUTF16("(650)234-56-78"), "US", | 315 EXPECT_EQ(FormatPhone(ASCIIToUTF16("(650)234-56-78"), "US", |
| 307 autofill_i18n::NATIONAL), | 316 autofill_i18n::NATIONAL), |
| 308 ASCIIToUTF16("(650) 234-5678")); | 317 ASCIIToUTF16("(650) 234-5678")); |
| 309 EXPECT_EQ(FormatPhone(ASCIIToUTF16("(650)234-56-78"), "US", | 318 EXPECT_EQ(FormatPhone(ASCIIToUTF16("(650)234-56-78"), "US", |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 "US")); | 383 "US")); |
| 375 EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("4158889999"), | 384 EXPECT_TRUE(PhoneNumbersMatch(ASCIIToUTF16("4158889999"), |
| 376 ASCIIToUTF16("415 TUV WXYZ"), | 385 ASCIIToUTF16("415 TUV WXYZ"), |
| 377 "US")); | 386 "US")); |
| 378 | 387 |
| 379 // Partial matches don't count. | 388 // Partial matches don't count. |
| 380 EXPECT_FALSE(PhoneNumbersMatch(ASCIIToUTF16("14158889999"), | 389 EXPECT_FALSE(PhoneNumbersMatch(ASCIIToUTF16("14158889999"), |
| 381 ASCIIToUTF16("8889999"), | 390 ASCIIToUTF16("8889999"), |
| 382 "US")); | 391 "US")); |
| 383 } | 392 } |
| OLD | NEW |