OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/message_loop.h" | 5 #include "base/message_loop/message_loop.h" |
6 #include "base/strings/string16.h" | 6 #include "base/strings/string16.h" |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "components/autofill/core/browser/phone_number_i18n.h" | 8 #include "components/autofill/core/browser/phone_number_i18n.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "third_party/libphonenumber/src/phonenumber_api.h" | 10 #include "third_party/libphonenumber/src/phonenumber_api.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 // Parses vanity numbers. | 114 // Parses vanity numbers. |
115 {true, "1-650-FLOWERS", "US", "3569377", "650", "1", "US"}, | 115 {true, "1-650-FLOWERS", "US", "3569377", "650", "1", "US"}, |
116 // 800 is not an area code, but the destination code. In our library | 116 // 800 is not an area code, but the destination code. In our library |
117 // these | 117 // these |
118 // codes should be treated the same as area codes. | 118 // codes should be treated the same as area codes. |
119 {true, "1-800-FLOWERS", "US", "3569377", "800", "1", "US"}, | 119 {true, "1-800-FLOWERS", "US", "3569377", "800", "1", "US"}, |
120 // Don't add a country code where there was none. | 120 // Don't add a country code where there was none. |
121 {true, "(08) 450 777 7777", "DE", "7777777", "8450", "", "DE"}, | 121 {true, "(08) 450 777 7777", "DE", "7777777", "8450", "", "DE"}, |
122 }; | 122 }; |
123 | 123 |
124 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); ++i) { | 124 for (size_t i = 0; i < arraysize(test_cases); ++i) { |
125 SCOPED_TRACE("Testing phone number " + test_cases[i].input); | 125 SCOPED_TRACE("Testing phone number " + test_cases[i].input); |
126 | 126 |
127 base::string16 country_code, city_code, number; | 127 base::string16 country_code, city_code, number; |
128 std::string deduced_region; | 128 std::string deduced_region; |
129 ::i18n::phonenumbers::PhoneNumber unused_i18n_number; | 129 ::i18n::phonenumbers::PhoneNumber unused_i18n_number; |
130 EXPECT_EQ(test_cases[i].valid, | 130 EXPECT_EQ(test_cases[i].valid, |
131 ParsePhoneNumber(ASCIIToUTF16(test_cases[i].input), | 131 ParsePhoneNumber(ASCIIToUTF16(test_cases[i].input), |
132 test_cases[i].assumed_region, | 132 test_cases[i].assumed_region, |
133 &country_code, | 133 &country_code, |
134 &city_code, | 134 &city_code, |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 "en-US")); | 250 "en-US")); |
251 | 251 |
252 // Different numbers don't match. | 252 // Different numbers don't match. |
253 EXPECT_FALSE(PhoneNumbersMatch(ASCIIToUTF16("14158889999"), | 253 EXPECT_FALSE(PhoneNumbersMatch(ASCIIToUTF16("14158889999"), |
254 ASCIIToUTF16("1415888"), | 254 ASCIIToUTF16("1415888"), |
255 "US", | 255 "US", |
256 "en-US")); | 256 "en-US")); |
257 } | 257 } |
258 | 258 |
259 } // namespace autofill | 259 } // namespace autofill |
OLD | NEW |