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/strings/string16.h" | 5 #include "base/strings/string16.h" |
6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
7 #include "components/autofill/core/browser/autofill_profile.h" | 7 #include "components/autofill/core/browser/autofill_profile.h" |
8 #include "components/autofill/core/browser/autofill_type.h" | 8 #include "components/autofill/core/browser/autofill_type.h" |
9 #include "components/autofill/core/browser/field_types.h" | 9 #include "components/autofill/core/browser/field_types.h" |
10 #include "components/autofill/core/browser/phone_number.h" | 10 #include "components/autofill/core/browser/phone_number.h" |
11 #include "components/autofill/core/browser/phone_number_i18n.h" | 11 #include "components/autofill/core/browser/phone_number_i18n.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 | 13 |
| 14 using base::ASCIIToUTF16; |
| 15 |
14 namespace autofill { | 16 namespace autofill { |
15 | 17 |
16 TEST(PhoneNumberTest, Matcher) { | 18 TEST(PhoneNumberTest, Matcher) { |
17 AutofillProfile profile; | 19 AutofillProfile profile; |
18 profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US")); | 20 profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US")); |
19 // Set phone number so country_code == 1, city_code = 650, number = 2345678. | 21 // Set phone number so country_code == 1, city_code = 650, number = 2345678. |
20 base::string16 phone(ASCIIToUTF16("1 [650] 234-5678")); | 22 base::string16 phone(ASCIIToUTF16("1 [650] 234-5678")); |
21 PhoneNumber phone_number(&profile); | 23 PhoneNumber phone_number(&profile); |
22 phone_number.SetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER), phone, "US"); | 24 phone_number.SetInfo(AutofillType(PHONE_HOME_WHOLE_NUMBER), phone, "US"); |
23 | 25 |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 ASCIIToUTF16("650"))); | 205 ASCIIToUTF16("650"))); |
204 EXPECT_TRUE(number7.SetInfo(AutofillType(PHONE_HOME_NUMBER), | 206 EXPECT_TRUE(number7.SetInfo(AutofillType(PHONE_HOME_NUMBER), |
205 ASCIIToUTF16("234"))); | 207 ASCIIToUTF16("234"))); |
206 EXPECT_TRUE(number7.SetInfo(AutofillType(PHONE_HOME_NUMBER), | 208 EXPECT_TRUE(number7.SetInfo(AutofillType(PHONE_HOME_NUMBER), |
207 ASCIIToUTF16("5682"))); | 209 ASCIIToUTF16("5682"))); |
208 EXPECT_TRUE(number7.ParseNumber(AutofillProfile(), "en-US", &parsed_phone)); | 210 EXPECT_TRUE(number7.ParseNumber(AutofillProfile(), "en-US", &parsed_phone)); |
209 EXPECT_EQ(ASCIIToUTF16("(650) 234-5682"), parsed_phone); | 211 EXPECT_EQ(ASCIIToUTF16("(650) 234-5682"), parsed_phone); |
210 } | 212 } |
211 | 213 |
212 } // namespace autofill | 214 } // namespace autofill |
OLD | NEW |