| 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" |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 ASCIIToUTF16("1"))); | 156 ASCIIToUTF16("1"))); |
| 157 EXPECT_TRUE(number1.SetInfo(AutofillType(PHONE_HOME_COUNTRY_CODE), | 157 EXPECT_TRUE(number1.SetInfo(AutofillType(PHONE_HOME_COUNTRY_CODE), |
| 158 ASCIIToUTF16("1"))); | 158 ASCIIToUTF16("1"))); |
| 159 EXPECT_TRUE(number1.SetInfo(AutofillType(PHONE_HOME_CITY_CODE), | 159 EXPECT_TRUE(number1.SetInfo(AutofillType(PHONE_HOME_CITY_CODE), |
| 160 ASCIIToUTF16("650"))); | 160 ASCIIToUTF16("650"))); |
| 161 EXPECT_TRUE(number1.SetInfo(AutofillType(PHONE_HOME_NUMBER), | 161 EXPECT_TRUE(number1.SetInfo(AutofillType(PHONE_HOME_NUMBER), |
| 162 ASCIIToUTF16("2345678"))); | 162 ASCIIToUTF16("2345678"))); |
| 163 base::string16 parsed_phone; | 163 base::string16 parsed_phone; |
| 164 EXPECT_TRUE(number1.ParseNumber(profile, "en-US", &parsed_phone)); | 164 EXPECT_TRUE(number1.ParseNumber(profile, "en-US", &parsed_phone)); |
| 165 // International format as it has a country code. | 165 // International format as it has a country code. |
| 166 EXPECT_EQ(ASCIIToUTF16("+1 650-234-5678"), parsed_phone); | 166 EXPECT_EQ(ASCIIToUTF16("1 650-234-5678"), parsed_phone); |
| 167 | 167 |
| 168 PhoneNumber::PhoneCombineHelper number3; | 168 PhoneNumber::PhoneCombineHelper number3; |
| 169 EXPECT_TRUE(number3.SetInfo(AutofillType(PHONE_HOME_CITY_CODE), | 169 EXPECT_TRUE(number3.SetInfo(AutofillType(PHONE_HOME_CITY_CODE), |
| 170 ASCIIToUTF16("650"))); | 170 ASCIIToUTF16("650"))); |
| 171 EXPECT_TRUE(number3.SetInfo(AutofillType(PHONE_HOME_NUMBER), | 171 EXPECT_TRUE(number3.SetInfo(AutofillType(PHONE_HOME_NUMBER), |
| 172 ASCIIToUTF16("2345680"))); | 172 ASCIIToUTF16("2345680"))); |
| 173 EXPECT_TRUE(number3.ParseNumber(profile, "en-US", &parsed_phone)); | 173 EXPECT_TRUE(number3.ParseNumber(profile, "en-US", &parsed_phone)); |
| 174 // National format as it does not have a country code. | 174 // National format as it does not have a country code. |
| 175 EXPECT_EQ(ASCIIToUTF16("(650) 234-5680"), parsed_phone); | 175 EXPECT_EQ(ASCIIToUTF16("(650) 234-5680"), parsed_phone); |
| 176 | 176 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 205 ASCIIToUTF16("650"))); | 205 ASCIIToUTF16("650"))); |
| 206 EXPECT_TRUE(number7.SetInfo(AutofillType(PHONE_HOME_NUMBER), | 206 EXPECT_TRUE(number7.SetInfo(AutofillType(PHONE_HOME_NUMBER), |
| 207 ASCIIToUTF16("234"))); | 207 ASCIIToUTF16("234"))); |
| 208 EXPECT_TRUE(number7.SetInfo(AutofillType(PHONE_HOME_NUMBER), | 208 EXPECT_TRUE(number7.SetInfo(AutofillType(PHONE_HOME_NUMBER), |
| 209 ASCIIToUTF16("5682"))); | 209 ASCIIToUTF16("5682"))); |
| 210 EXPECT_TRUE(number7.ParseNumber(AutofillProfile(), "en-US", &parsed_phone)); | 210 EXPECT_TRUE(number7.ParseNumber(AutofillProfile(), "en-US", &parsed_phone)); |
| 211 EXPECT_EQ(ASCIIToUTF16("(650) 234-5682"), parsed_phone); | 211 EXPECT_EQ(ASCIIToUTF16("(650) 234-5682"), parsed_phone); |
| 212 } | 212 } |
| 213 | 213 |
| 214 } // namespace autofill | 214 } // namespace autofill |
| OLD | NEW |