| 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/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
| 6 #include "base/memory/scoped_vector.h" | 6 #include "base/memory/scoped_vector.h" |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "components/autofill/core/browser/autofill_field.h" | 8 #include "components/autofill/core/browser/autofill_field.h" |
| 9 #include "components/autofill/core/browser/autofill_scanner.h" | 9 #include "components/autofill/core/browser/autofill_scanner.h" |
| 10 #include "components/autofill/core/browser/phone_field.h" | 10 #include "components/autofill/core/browser/phone_field.h" |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 // encountered in http://crbug.com/40694 with page | 135 // encountered in http://crbug.com/40694 with page |
| 136 // https://www.wrapables.com/jsp/Signup.jsp. | 136 // https://www.wrapables.com/jsp/Signup.jsp. |
| 137 TEST_F(PhoneFieldTest, ThreePartPhoneNumberPrefixSuffix) { | 137 TEST_F(PhoneFieldTest, ThreePartPhoneNumberPrefixSuffix) { |
| 138 FormFieldData field; | 138 FormFieldData field; |
| 139 field.form_control_type = "text"; | 139 field.form_control_type = "text"; |
| 140 | 140 |
| 141 field.label = ASCIIToUTF16("Phone:"); | 141 field.label = ASCIIToUTF16("Phone:"); |
| 142 field.name = ASCIIToUTF16("area"); | 142 field.name = ASCIIToUTF16("area"); |
| 143 list_.push_back(new AutofillField(field, ASCIIToUTF16("areacode1"))); | 143 list_.push_back(new AutofillField(field, ASCIIToUTF16("areacode1"))); |
| 144 | 144 |
| 145 field.label = string16(); | 145 field.label = base::string16(); |
| 146 field.name = ASCIIToUTF16("prefix"); | 146 field.name = ASCIIToUTF16("prefix"); |
| 147 list_.push_back(new AutofillField(field, ASCIIToUTF16("prefix2"))); | 147 list_.push_back(new AutofillField(field, ASCIIToUTF16("prefix2"))); |
| 148 | 148 |
| 149 field.label = string16(); | 149 field.label = base::string16(); |
| 150 field.name = ASCIIToUTF16("suffix"); | 150 field.name = ASCIIToUTF16("suffix"); |
| 151 list_.push_back(new AutofillField(field, ASCIIToUTF16("suffix3"))); | 151 list_.push_back(new AutofillField(field, ASCIIToUTF16("suffix3"))); |
| 152 | 152 |
| 153 AutofillScanner scanner(list_.get()); | 153 AutofillScanner scanner(list_.get()); |
| 154 field_.reset(Parse(&scanner)); | 154 field_.reset(Parse(&scanner)); |
| 155 ASSERT_NE(static_cast<PhoneField*>(NULL), field_.get()); | 155 ASSERT_NE(static_cast<PhoneField*>(NULL), field_.get()); |
| 156 ASSERT_TRUE(field_->ClassifyField(&field_type_map_)); | 156 ASSERT_TRUE(field_->ClassifyField(&field_type_map_)); |
| 157 ASSERT_TRUE( | 157 ASSERT_TRUE( |
| 158 field_type_map_.find(ASCIIToUTF16("areacode1")) != field_type_map_.end()); | 158 field_type_map_.find(ASCIIToUTF16("areacode1")) != field_type_map_.end()); |
| 159 EXPECT_EQ(PHONE_HOME_CITY_CODE, field_type_map_[ASCIIToUTF16("areacode1")]); | 159 EXPECT_EQ(PHONE_HOME_CITY_CODE, field_type_map_[ASCIIToUTF16("areacode1")]); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 172 field.label = ASCIIToUTF16("("); | 172 field.label = ASCIIToUTF16("("); |
| 173 field.name = ASCIIToUTF16("phone1"); | 173 field.name = ASCIIToUTF16("phone1"); |
| 174 field.max_length = 3; | 174 field.max_length = 3; |
| 175 list_.push_back(new AutofillField(field, ASCIIToUTF16("phone1"))); | 175 list_.push_back(new AutofillField(field, ASCIIToUTF16("phone1"))); |
| 176 | 176 |
| 177 field.label = ASCIIToUTF16(")"); | 177 field.label = ASCIIToUTF16(")"); |
| 178 field.name = ASCIIToUTF16("phone2"); | 178 field.name = ASCIIToUTF16("phone2"); |
| 179 field.max_length = 3; | 179 field.max_length = 3; |
| 180 list_.push_back(new AutofillField(field, ASCIIToUTF16("phone2"))); | 180 list_.push_back(new AutofillField(field, ASCIIToUTF16("phone2"))); |
| 181 | 181 |
| 182 field.label = string16(); | 182 field.label = base::string16(); |
| 183 field.name = ASCIIToUTF16("phone3"); | 183 field.name = ASCIIToUTF16("phone3"); |
| 184 field.max_length = 4; | 184 field.max_length = 4; |
| 185 list_.push_back(new AutofillField(field, ASCIIToUTF16("phone3"))); | 185 list_.push_back(new AutofillField(field, ASCIIToUTF16("phone3"))); |
| 186 | 186 |
| 187 AutofillScanner scanner(list_.get()); | 187 AutofillScanner scanner(list_.get()); |
| 188 field_.reset(Parse(&scanner)); | 188 field_.reset(Parse(&scanner)); |
| 189 ASSERT_NE(static_cast<PhoneField*>(NULL), field_.get()); | 189 ASSERT_NE(static_cast<PhoneField*>(NULL), field_.get()); |
| 190 ASSERT_TRUE(field_->ClassifyField(&field_type_map_)); | 190 ASSERT_TRUE(field_->ClassifyField(&field_type_map_)); |
| 191 ASSERT_TRUE( | 191 ASSERT_TRUE( |
| 192 field_type_map_.find(ASCIIToUTF16("phone1")) != field_type_map_.end()); | 192 field_type_map_.find(ASCIIToUTF16("phone1")) != field_type_map_.end()); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 221 ASSERT_TRUE(field_->ClassifyField(&field_type_map_)); | 221 ASSERT_TRUE(field_->ClassifyField(&field_type_map_)); |
| 222 ASSERT_TRUE( | 222 ASSERT_TRUE( |
| 223 field_type_map_.find(ASCIIToUTF16("country")) != field_type_map_.end()); | 223 field_type_map_.find(ASCIIToUTF16("country")) != field_type_map_.end()); |
| 224 EXPECT_EQ(PHONE_HOME_COUNTRY_CODE, field_type_map_[ASCIIToUTF16("country")]); | 224 EXPECT_EQ(PHONE_HOME_COUNTRY_CODE, field_type_map_[ASCIIToUTF16("country")]); |
| 225 ASSERT_TRUE( | 225 ASSERT_TRUE( |
| 226 field_type_map_.find(ASCIIToUTF16("phone")) != field_type_map_.end()); | 226 field_type_map_.find(ASCIIToUTF16("phone")) != field_type_map_.end()); |
| 227 EXPECT_EQ(PHONE_HOME_CITY_AND_NUMBER, field_type_map_[ASCIIToUTF16("phone")]); | 227 EXPECT_EQ(PHONE_HOME_CITY_AND_NUMBER, field_type_map_[ASCIIToUTF16("phone")]); |
| 228 } | 228 } |
| 229 | 229 |
| 230 } // namespace autofill | 230 } // namespace autofill |
| OLD | NEW |