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