| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/scoped_ptr.h" | 5 #include "base/scoped_ptr.h" |
| 6 #include "base/scoped_vector.h" | 6 #include "base/scoped_vector.h" |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/autofill/address_field.h" | 8 #include "chrome/browser/autofill/address_field.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "webkit/glue/form_field.h" | 10 #include "webkit/glue/form_field.h" |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 list_.push_back(NULL); | 402 list_.push_back(NULL); |
| 403 iter_ = list_.begin(); | 403 iter_ = list_.begin(); |
| 404 field_.reset(AddressField::Parse(&iter_, false)); | 404 field_.reset(AddressField::Parse(&iter_, false)); |
| 405 ASSERT_NE(static_cast<AddressField*>(NULL), field_.get()); | 405 ASSERT_NE(static_cast<AddressField*>(NULL), field_.get()); |
| 406 EXPECT_EQ(kGenericAddress, field_->FindType()); | 406 EXPECT_EQ(kGenericAddress, field_->FindType()); |
| 407 EXPECT_TRUE(field_->IsFullAddress()); | 407 EXPECT_TRUE(field_->IsFullAddress()); |
| 408 ASSERT_TRUE(field_->GetFieldInfo(&field_type_map_)); | 408 ASSERT_TRUE(field_->GetFieldInfo(&field_type_map_)); |
| 409 ASSERT_TRUE( | 409 ASSERT_TRUE( |
| 410 field_type_map_.find(ASCIIToUTF16("addr1")) != field_type_map_.end()); | 410 field_type_map_.find(ASCIIToUTF16("addr1")) != field_type_map_.end()); |
| 411 EXPECT_EQ(ADDRESS_HOME_LINE1, field_type_map_[ASCIIToUTF16("addr1")]); | 411 EXPECT_EQ(ADDRESS_HOME_LINE1, field_type_map_[ASCIIToUTF16("addr1")]); |
| 412 ASSERT_FALSE( | 412 ASSERT_TRUE( |
| 413 field_type_map_.find(ASCIIToUTF16("addr2")) != field_type_map_.end()); | 413 field_type_map_.find(ASCIIToUTF16("addr2")) != field_type_map_.end()); |
| 414 // The second line of the address should not match if |name| is set but | 414 EXPECT_EQ(ADDRESS_HOME_LINE2, field_type_map_[ASCIIToUTF16("addr2")]); |
| 415 // |label| is empty. | |
| 416 EXPECT_NE(ADDRESS_HOME_LINE2, field_type_map_[ASCIIToUTF16("addr2")]); | |
| 417 } | 415 } |
| 418 | 416 |
| 419 TEST_F(AddressFieldTest, ParseCompany) { | 417 TEST_F(AddressFieldTest, ParseCompany) { |
| 420 list_.push_back( | 418 list_.push_back( |
| 421 new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Company"), | 419 new AutoFillField(webkit_glue::FormField(ASCIIToUTF16("Company"), |
| 422 ASCIIToUTF16("company"), | 420 ASCIIToUTF16("company"), |
| 423 string16(), | 421 string16(), |
| 424 ASCIIToUTF16("text"), | 422 ASCIIToUTF16("text"), |
| 425 0), | 423 0), |
| 426 ASCIIToUTF16("company1"))); | 424 ASCIIToUTF16("company1"))); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 451 ASSERT_NE(static_cast<AddressField*>(NULL), field_.get()); | 449 ASSERT_NE(static_cast<AddressField*>(NULL), field_.get()); |
| 452 EXPECT_EQ(kGenericAddress, field_->FindType()); | 450 EXPECT_EQ(kGenericAddress, field_->FindType()); |
| 453 EXPECT_FALSE(field_->IsFullAddress()); | 451 EXPECT_FALSE(field_->IsFullAddress()); |
| 454 ASSERT_TRUE(field_->GetFieldInfo(&field_type_map_)); | 452 ASSERT_TRUE(field_->GetFieldInfo(&field_type_map_)); |
| 455 ASSERT_TRUE( | 453 ASSERT_TRUE( |
| 456 field_type_map_.find(ASCIIToUTF16("company1")) != field_type_map_.end()); | 454 field_type_map_.find(ASCIIToUTF16("company1")) != field_type_map_.end()); |
| 457 EXPECT_EQ(COMPANY_NAME, field_type_map_[ASCIIToUTF16("company1")]); | 455 EXPECT_EQ(COMPANY_NAME, field_type_map_[ASCIIToUTF16("company1")]); |
| 458 } | 456 } |
| 459 | 457 |
| 460 } // namespace | 458 } // namespace |
| OLD | NEW |