| 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/autofill_profile.h" | 6 #include "chrome/browser/autofill/autofill_profile.h" |
| 7 #include "chrome/browser/autofill/field_types.h" | 7 #include "chrome/browser/autofill/field_types.h" |
| 8 #include "chrome/browser/autofill/phone_number.h" | 8 #include "chrome/browser/autofill/phone_number.h" |
| 9 #include "chrome/browser/autofill/phone_number_i18n.h" | 9 #include "chrome/browser/autofill/phone_number_i18n.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 11 |
| 12 TEST(PhoneNumberTest, Matcher) { | 12 TEST(PhoneNumberTest, Matcher) { |
| 13 AutofillProfile profile; | 13 AutofillProfile profile; |
| 14 profile.SetCountryCode("US"); | 14 profile.SetCountryCode("US"); |
| 15 // Set phone number so country_code == 1, city_code = 650, number = 2345678. | 15 // Set phone number so country_code == 1, city_code = 650, number = 2345678. |
| 16 string16 phone(ASCIIToUTF16("1 [650] 234-5678")); | 16 string16 phone(ASCIIToUTF16("1 [650] 234-5678")); |
| 17 PhoneNumber phone_number(&profile); | 17 PhoneNumber phone_number(&profile); |
| 18 phone_number.SetInfo(PHONE_HOME_WHOLE_NUMBER, phone); | 18 phone_number.SetCanonicalizedInfo(PHONE_HOME_WHOLE_NUMBER, phone); |
| 19 phone_number.NormalizePhone(); | |
| 20 | 19 |
| 21 FieldTypeSet matching_types; | 20 FieldTypeSet matching_types; |
| 22 phone_number.GetMatchingTypes(ASCIIToUTF16(""), &matching_types); | 21 phone_number.GetMatchingTypes(ASCIIToUTF16(""), &matching_types); |
| 23 EXPECT_EQ(1U, matching_types.size()); | 22 EXPECT_EQ(1U, matching_types.size()); |
| 24 EXPECT_TRUE(matching_types.find(EMPTY_TYPE) != matching_types.end()); | 23 EXPECT_TRUE(matching_types.find(EMPTY_TYPE) != matching_types.end()); |
| 25 matching_types.clear(); | 24 matching_types.clear(); |
| 26 phone_number.GetMatchingTypes(ASCIIToUTF16("1"), &matching_types); | 25 phone_number.GetMatchingTypes(ASCIIToUTF16("1"), &matching_types); |
| 27 EXPECT_EQ(1U, matching_types.size()); | 26 EXPECT_EQ(1U, matching_types.size()); |
| 28 EXPECT_TRUE(matching_types.find(PHONE_HOME_COUNTRY_CODE) != | 27 EXPECT_TRUE(matching_types.find(PHONE_HOME_COUNTRY_CODE) != |
| 29 matching_types.end()); | 28 matching_types.end()); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 PhoneNumber::PhoneCombineHelper number6; | 117 PhoneNumber::PhoneCombineHelper number6; |
| 119 EXPECT_TRUE(number6.SetInfo(PHONE_HOME_CITY_CODE, | 118 EXPECT_TRUE(number6.SetInfo(PHONE_HOME_CITY_CODE, |
| 120 ASCIIToUTF16("650"))); | 119 ASCIIToUTF16("650"))); |
| 121 EXPECT_TRUE(number6.SetInfo(PHONE_HOME_NUMBER, | 120 EXPECT_TRUE(number6.SetInfo(PHONE_HOME_NUMBER, |
| 122 ASCIIToUTF16("234"))); | 121 ASCIIToUTF16("234"))); |
| 123 EXPECT_TRUE(number6.SetInfo(PHONE_HOME_NUMBER, | 122 EXPECT_TRUE(number6.SetInfo(PHONE_HOME_NUMBER, |
| 124 ASCIIToUTF16("5682"))); | 123 ASCIIToUTF16("5682"))); |
| 125 EXPECT_TRUE(number6.ParseNumber("US", &parsed_phone)); | 124 EXPECT_TRUE(number6.ParseNumber("US", &parsed_phone)); |
| 126 EXPECT_EQ(ASCIIToUTF16("(650) 234-5682"), parsed_phone); | 125 EXPECT_EQ(ASCIIToUTF16("(650) 234-5682"), parsed_phone); |
| 127 } | 126 } |
| OLD | NEW |