| 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/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/string16.h" |
| 7 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/autofill/address_field.h" | 9 #include "chrome/browser/autofill/address_field.h" |
| 9 #include "chrome/browser/autofill/autofill_field.h" | 10 #include "chrome/browser/autofill/autofill_field.h" |
| 10 #include "chrome/browser/autofill/autofill_scanner.h" | 11 #include "chrome/browser/autofill/autofill_scanner.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "webkit/glue/form_field.h" | 13 #include "webkit/glue/form_field.h" |
| 13 | 14 |
| 14 class AddressFieldTest : public testing::Test { | 15 class AddressFieldTest : public testing::Test { |
| 15 public: | 16 public: |
| 16 AddressFieldTest() {} | 17 AddressFieldTest() {} |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 } | 251 } |
| 251 | 252 |
| 252 TEST_F(AddressFieldTest, ParseTwoLineAddressMissingLabel) { | 253 TEST_F(AddressFieldTest, ParseTwoLineAddressMissingLabel) { |
| 253 webkit_glue::FormField field; | 254 webkit_glue::FormField field; |
| 254 field.form_control_type = ASCIIToUTF16("text"); | 255 field.form_control_type = ASCIIToUTF16("text"); |
| 255 | 256 |
| 256 field.label = ASCIIToUTF16("Address"); | 257 field.label = ASCIIToUTF16("Address"); |
| 257 field.name = ASCIIToUTF16("address"); | 258 field.name = ASCIIToUTF16("address"); |
| 258 list_.push_back(new AutofillField(field, ASCIIToUTF16("addr1"))); | 259 list_.push_back(new AutofillField(field, ASCIIToUTF16("addr1"))); |
| 259 | 260 |
| 260 field.label = ASCIIToUTF16(""); | 261 field.label = string16(); |
| 261 field.name = ASCIIToUTF16("bogus"); | 262 field.name = ASCIIToUTF16("bogus"); |
| 262 list_.push_back(new AutofillField(field, ASCIIToUTF16("addr2"))); | 263 list_.push_back(new AutofillField(field, ASCIIToUTF16("addr2"))); |
| 263 | 264 |
| 264 AutofillScanner scanner(list_.get()); | 265 AutofillScanner scanner(list_.get()); |
| 265 field_.reset(Parse(&scanner)); | 266 field_.reset(Parse(&scanner)); |
| 266 ASSERT_NE(static_cast<AddressField*>(NULL), field_.get()); | 267 ASSERT_NE(static_cast<AddressField*>(NULL), field_.get()); |
| 267 EXPECT_EQ(AddressField::kGenericAddress, field_->FindType()); | 268 EXPECT_EQ(AddressField::kGenericAddress, field_->FindType()); |
| 268 ASSERT_TRUE(field_->ClassifyField(&field_type_map_)); | 269 ASSERT_TRUE(field_->ClassifyField(&field_type_map_)); |
| 269 ASSERT_TRUE( | 270 ASSERT_TRUE( |
| 270 field_type_map_.find(ASCIIToUTF16("addr1")) != field_type_map_.end()); | 271 field_type_map_.find(ASCIIToUTF16("addr1")) != field_type_map_.end()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 284 | 285 |
| 285 AutofillScanner scanner(list_.get()); | 286 AutofillScanner scanner(list_.get()); |
| 286 field_.reset(Parse(&scanner)); | 287 field_.reset(Parse(&scanner)); |
| 287 ASSERT_NE(static_cast<AddressField*>(NULL), field_.get()); | 288 ASSERT_NE(static_cast<AddressField*>(NULL), field_.get()); |
| 288 EXPECT_EQ(AddressField::kGenericAddress, field_->FindType()); | 289 EXPECT_EQ(AddressField::kGenericAddress, field_->FindType()); |
| 289 ASSERT_TRUE(field_->ClassifyField(&field_type_map_)); | 290 ASSERT_TRUE(field_->ClassifyField(&field_type_map_)); |
| 290 ASSERT_TRUE( | 291 ASSERT_TRUE( |
| 291 field_type_map_.find(ASCIIToUTF16("company1")) != field_type_map_.end()); | 292 field_type_map_.find(ASCIIToUTF16("company1")) != field_type_map_.end()); |
| 292 EXPECT_EQ(COMPANY_NAME, field_type_map_[ASCIIToUTF16("company1")]); | 293 EXPECT_EQ(COMPANY_NAME, field_type_map_[ASCIIToUTF16("company1")]); |
| 293 } | 294 } |
| OLD | NEW |