Home | History | Annotate | Download | only in autofill
      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
      3 // found in the LICENSE file.
      4 
      5 #include "base/memory/scoped_ptr.h"
      6 #include "base/memory/scoped_vector.h"
      7 #include "base/utf_string_conversions.h"
      8 #include "chrome/browser/autofill/address_field.h"
      9 #include "chrome/browser/autofill/autofill_field.h"
     10 #include "testing/gtest/include/gtest/gtest.h"
     11 #include "webkit/glue/form_field.h"
     12 
     13 namespace {
     14 
     15 class AddressFieldTest : public testing::Test {
     16  public:
     17   AddressFieldTest() {}
     18 
     19  protected:
     20   ScopedVector<AutofillField> list_;
     21   scoped_ptr<AddressField> field_;
     22   FieldTypeMap field_type_map_;
     23   std::vector<AutofillField*>::const_iterator iter_;
     24 
     25  private:
     26   DISALLOW_COPY_AND_ASSIGN(AddressFieldTest);
     27 };
     28 
     29 TEST_F(AddressFieldTest, Empty) {
     30   list_.push_back(NULL);
     31   iter_ = list_.begin();
     32   field_.reset(AddressField::Parse(&iter_, false));
     33   ASSERT_EQ(static_cast<AddressField*>(NULL), field_.get());
     34 }
     35 
     36 TEST_F(AddressFieldTest, NonParse) {
     37   list_.push_back(new AutofillField);
     38   list_.push_back(NULL);
     39   iter_ = list_.begin();
     40   field_.reset(AddressField::Parse(&iter_, false));
     41   ASSERT_EQ(static_cast<AddressField*>(NULL), field_.get());
     42 }
     43 
     44 TEST_F(AddressFieldTest, ParseOneLineAddress) {
     45   list_.push_back(
     46       new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Address"),
     47                                                ASCIIToUTF16("address"),
     48                                                string16(),
     49                                                ASCIIToUTF16("text"),
     50                                                0,
     51                                                false),
     52                         ASCIIToUTF16("addr1")));
     53   list_.push_back(NULL);
     54   iter_ = list_.begin();
     55   field_.reset(AddressField::Parse(&iter_, false));
     56   ASSERT_NE(static_cast<AddressField*>(NULL), field_.get());
     57   EXPECT_EQ(kGenericAddress, field_->FindType());
     58   EXPECT_TRUE(field_->IsFullAddress());
     59   ASSERT_TRUE(field_->GetFieldInfo(&field_type_map_));
     60   ASSERT_TRUE(
     61       field_type_map_.find(ASCIIToUTF16("addr1")) != field_type_map_.end());
     62   EXPECT_EQ(ADDRESS_HOME_LINE1, field_type_map_[ASCIIToUTF16("addr1")]);
     63 }
     64 
     65 TEST_F(AddressFieldTest, ParseOneLineAddressBilling) {
     66   list_.push_back(
     67       new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Address"),
     68                                                ASCIIToUTF16("billingAddress"),
     69                                                string16(),
     70                                                ASCIIToUTF16("text"),
     71                                                0,
     72                                                false),
     73                         ASCIIToUTF16("addr1")));
     74   list_.push_back(NULL);
     75   iter_ = list_.begin();
     76   field_.reset(AddressField::Parse(&iter_, false));
     77   ASSERT_NE(static_cast<AddressField*>(NULL), field_.get());
     78   EXPECT_EQ(kBillingAddress, field_->FindType());
     79   EXPECT_TRUE(field_->IsFullAddress());
     80   ASSERT_TRUE(field_->GetFieldInfo(&field_type_map_));
     81   ASSERT_TRUE(
     82       field_type_map_.find(ASCIIToUTF16("addr1")) != field_type_map_.end());
     83   EXPECT_EQ(ADDRESS_HOME_LINE1, field_type_map_[ASCIIToUTF16("addr1")]);
     84 }
     85 
     86 TEST_F(AddressFieldTest, ParseOneLineAddressShipping) {
     87   list_.push_back(
     88       new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Address"),
     89                                                ASCIIToUTF16("shippingAddress"),
     90                                                string16(),
     91                                                ASCIIToUTF16("text"),
     92                                                0,
     93                                                false),
     94                         ASCIIToUTF16("addr1")));
     95   list_.push_back(NULL);
     96   iter_ = list_.begin();
     97   field_.reset(AddressField::Parse(&iter_, false));
     98   ASSERT_NE(static_cast<AddressField*>(NULL), field_.get());
     99   EXPECT_EQ(kShippingAddress, field_->FindType());
    100   EXPECT_TRUE(field_->IsFullAddress());
    101   ASSERT_TRUE(field_->GetFieldInfo(&field_type_map_));
    102   ASSERT_TRUE(
    103       field_type_map_.find(ASCIIToUTF16("addr1")) != field_type_map_.end());
    104   EXPECT_EQ(ADDRESS_HOME_LINE1, field_type_map_[ASCIIToUTF16("addr1")]);
    105 }
    106 
    107 TEST_F(AddressFieldTest, ParseOneLineAddressEcml) {
    108   list_.push_back(
    109       new AutofillField(
    110           webkit_glue::FormField(ASCIIToUTF16("Address"),
    111                                  ASCIIToUTF16(kEcmlShipToAddress1),
    112                                  string16(),
    113                                  ASCIIToUTF16("text"),
    114                                  0,
    115                                  false),
    116           ASCIIToUTF16("addr1")));
    117   list_.push_back(NULL);
    118   iter_ = list_.begin();
    119   field_.reset(AddressField::Parse(&iter_, true));
    120   ASSERT_NE(static_cast<AddressField*>(NULL), field_.get());
    121   EXPECT_EQ(kShippingAddress, field_->FindType());
    122   EXPECT_TRUE(field_->IsFullAddress());
    123   ASSERT_TRUE(field_->GetFieldInfo(&field_type_map_));
    124   ASSERT_TRUE(
    125       field_type_map_.find(ASCIIToUTF16("addr1")) != field_type_map_.end());
    126   EXPECT_EQ(ADDRESS_HOME_LINE1, field_type_map_[ASCIIToUTF16("addr1")]);
    127 }
    128 
    129 TEST_F(AddressFieldTest, ParseTwoLineAddress) {
    130   list_.push_back(
    131       new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Address"),
    132                                                ASCIIToUTF16("address"),
    133                                                string16(),
    134                                                ASCIIToUTF16("text"),
    135                                                0,
    136                                                false),
    137                         ASCIIToUTF16("addr1")));
    138   list_.push_back(
    139       new AutofillField(webkit_glue::FormField(string16(),
    140                                                string16(),
    141                                                string16(),
    142                                                ASCIIToUTF16("text"),
    143                                                0,
    144                                                false),
    145                         ASCIIToUTF16("addr2")));
    146   list_.push_back(NULL);
    147   iter_ = list_.begin();
    148   field_.reset(AddressField::Parse(&iter_, false));
    149   ASSERT_NE(static_cast<AddressField*>(NULL), field_.get());
    150   EXPECT_EQ(kGenericAddress, field_->FindType());
    151   EXPECT_TRUE(field_->IsFullAddress());
    152   ASSERT_TRUE(field_->GetFieldInfo(&field_type_map_));
    153   ASSERT_TRUE(
    154       field_type_map_.find(ASCIIToUTF16("addr1")) != field_type_map_.end());
    155   EXPECT_EQ(ADDRESS_HOME_LINE1, field_type_map_[ASCIIToUTF16("addr1")]);
    156   ASSERT_TRUE(
    157       field_type_map_.find(ASCIIToUTF16("addr2")) != field_type_map_.end());
    158   EXPECT_EQ(ADDRESS_HOME_LINE2, field_type_map_[ASCIIToUTF16("addr2")]);
    159 }
    160 
    161 TEST_F(AddressFieldTest, ParseThreeLineAddress) {
    162   list_.push_back(
    163       new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Address Line1"),
    164                                                ASCIIToUTF16("Address"),
    165                                                string16(),
    166                                                ASCIIToUTF16("text"),
    167                                                0,
    168                                                false),
    169                         ASCIIToUTF16("addr1")));
    170   list_.push_back(
    171       new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Address Line2"),
    172                                                ASCIIToUTF16("Address"),
    173                                                string16(),
    174                                                ASCIIToUTF16("text"),
    175                                                0,
    176                                                false),
    177                         ASCIIToUTF16("addr2")));
    178   list_.push_back(
    179       new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Address Line3"),
    180                                                ASCIIToUTF16("Address"),
    181                                                string16(),
    182                                                ASCIIToUTF16("text"),
    183                                                0,
    184                                                false),
    185                         ASCIIToUTF16("addr3")));
    186   list_.push_back(NULL);
    187   iter_ = list_.begin();
    188   field_.reset(AddressField::Parse(&iter_, false));
    189   ASSERT_NE(static_cast<AddressField*>(NULL), field_.get());
    190   EXPECT_EQ(kGenericAddress, field_->FindType());
    191   EXPECT_TRUE(field_->IsFullAddress());
    192   ASSERT_TRUE(field_->GetFieldInfo(&field_type_map_));
    193   ASSERT_TRUE(
    194       field_type_map_.find(ASCIIToUTF16("addr1")) != field_type_map_.end());
    195   EXPECT_EQ(ADDRESS_HOME_LINE1, field_type_map_[ASCIIToUTF16("addr1")]);
    196   ASSERT_TRUE(
    197       field_type_map_.find(ASCIIToUTF16("addr2")) != field_type_map_.end());
    198   EXPECT_EQ(ADDRESS_HOME_LINE2, field_type_map_[ASCIIToUTF16("addr2")]);
    199   ASSERT_TRUE(
    200       field_type_map_.find(ASCIIToUTF16("addr3")) == field_type_map_.end());
    201 }
    202 
    203 TEST_F(AddressFieldTest, ParseTwoLineAddressEcml) {
    204   list_.push_back(
    205       new AutofillField(
    206           webkit_glue::FormField(ASCIIToUTF16("Address"),
    207                                  ASCIIToUTF16(kEcmlShipToAddress1),
    208                                  string16(),
    209                                  ASCIIToUTF16("text"),
    210                                  0,
    211                                  false),
    212           ASCIIToUTF16("addr1")));
    213   list_.push_back(
    214       new AutofillField(
    215           webkit_glue::FormField(string16(),
    216                                  ASCIIToUTF16(kEcmlShipToAddress2),
    217                                  string16(),
    218                                  ASCIIToUTF16("text"),
    219                                  0,
    220                                  false),
    221           ASCIIToUTF16("addr2")));
    222   list_.push_back(NULL);
    223   iter_ = list_.begin();
    224   field_.reset(AddressField::Parse(&iter_, true));
    225   ASSERT_NE(static_cast<AddressField*>(NULL), field_.get());
    226   EXPECT_EQ(kShippingAddress, field_->FindType());
    227   EXPECT_TRUE(field_->IsFullAddress());
    228   ASSERT_TRUE(field_->GetFieldInfo(&field_type_map_));
    229   ASSERT_TRUE(
    230       field_type_map_.find(ASCIIToUTF16("addr1")) != field_type_map_.end());
    231   EXPECT_EQ(ADDRESS_HOME_LINE1, field_type_map_[ASCIIToUTF16("addr1")]);
    232   ASSERT_TRUE(
    233       field_type_map_.find(ASCIIToUTF16("addr2")) != field_type_map_.end());
    234   EXPECT_EQ(ADDRESS_HOME_LINE2, field_type_map_[ASCIIToUTF16("addr2")]);
    235 }
    236 
    237 TEST_F(AddressFieldTest, ParseCity) {
    238   list_.push_back(
    239       new AutofillField(webkit_glue::FormField(ASCIIToUTF16("City"),
    240                                                ASCIIToUTF16("city"),
    241                                                string16(),
    242                                                ASCIIToUTF16("text"),
    243                                                0,
    244                                                false),
    245                         ASCIIToUTF16("city1")));
    246   list_.push_back(NULL);
    247   iter_ = list_.begin();
    248   field_.reset(AddressField::Parse(&iter_, false));
    249   ASSERT_NE(static_cast<AddressField*>(NULL), field_.get());
    250   EXPECT_EQ(kGenericAddress, field_->FindType());
    251   EXPECT_FALSE(field_->IsFullAddress());
    252   ASSERT_TRUE(field_->GetFieldInfo(&field_type_map_));
    253   ASSERT_TRUE(
    254       field_type_map_.find(ASCIIToUTF16("city1")) != field_type_map_.end());
    255   EXPECT_EQ(ADDRESS_HOME_CITY, field_type_map_[ASCIIToUTF16("city1")]);
    256 }
    257 
    258 TEST_F(AddressFieldTest, ParseCityEcml) {
    259   list_.push_back(
    260       new AutofillField(webkit_glue::FormField(ASCIIToUTF16("City"),
    261                                                ASCIIToUTF16(kEcmlShipToCity),
    262                                                string16(),
    263                                                ASCIIToUTF16("text"),
    264                                                0,
    265                                                false),
    266                         ASCIIToUTF16("city1")));
    267   list_.push_back(NULL);
    268   iter_ = list_.begin();
    269   field_.reset(AddressField::Parse(&iter_, true));
    270   ASSERT_NE(static_cast<AddressField*>(NULL), field_.get());
    271   EXPECT_EQ(kGenericAddress, field_->FindType());
    272   EXPECT_FALSE(field_->IsFullAddress());
    273   ASSERT_TRUE(field_->GetFieldInfo(&field_type_map_));
    274   ASSERT_TRUE(
    275       field_type_map_.find(ASCIIToUTF16("city1")) != field_type_map_.end());
    276   EXPECT_EQ(ADDRESS_HOME_CITY, field_type_map_[ASCIIToUTF16("city1")]);
    277 }
    278 
    279 TEST_F(AddressFieldTest, ParseState) {
    280   list_.push_back(
    281       new AutofillField(webkit_glue::FormField(ASCIIToUTF16("State"),
    282                                                ASCIIToUTF16("state"),
    283                                                string16(),
    284                                                ASCIIToUTF16("text"),
    285                                                0,
    286                                                false),
    287                         ASCIIToUTF16("state1")));
    288   list_.push_back(NULL);
    289   iter_ = list_.begin();
    290   field_.reset(AddressField::Parse(&iter_, false));
    291   ASSERT_NE(static_cast<AddressField*>(NULL), field_.get());
    292   EXPECT_EQ(kGenericAddress, field_->FindType());
    293   EXPECT_FALSE(field_->IsFullAddress());
    294   ASSERT_TRUE(field_->GetFieldInfo(&field_type_map_));
    295   ASSERT_TRUE(
    296       field_type_map_.find(ASCIIToUTF16("state1")) != field_type_map_.end());
    297   EXPECT_EQ(ADDRESS_HOME_STATE, field_type_map_[ASCIIToUTF16("state1")]);
    298 }
    299 
    300 TEST_F(AddressFieldTest, ParseStateEcml) {
    301   list_.push_back(
    302       new AutofillField(
    303           webkit_glue::FormField(ASCIIToUTF16("State"),
    304                                  ASCIIToUTF16(kEcmlShipToStateProv),
    305                                  string16(),
    306                                  ASCIIToUTF16("text"),
    307                                  0,
    308                                  false),
    309           ASCIIToUTF16("state1")));
    310   list_.push_back(NULL);
    311   iter_ = list_.begin();
    312   field_.reset(AddressField::Parse(&iter_, true));
    313   ASSERT_NE(static_cast<AddressField*>(NULL), field_.get());
    314   EXPECT_EQ(kGenericAddress, field_->FindType());
    315   EXPECT_FALSE(field_->IsFullAddress());
    316   ASSERT_TRUE(field_->GetFieldInfo(&field_type_map_));
    317   ASSERT_TRUE(
    318       field_type_map_.find(ASCIIToUTF16("state1")) != field_type_map_.end());
    319   EXPECT_EQ(ADDRESS_HOME_STATE, field_type_map_[ASCIIToUTF16("state1")]);
    320 }
    321 
    322 TEST_F(AddressFieldTest, ParseZip) {
    323   list_.push_back(
    324       new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Zip"),
    325                                                ASCIIToUTF16("zip"),
    326                                                string16(),
    327                                                ASCIIToUTF16("text"),
    328                                                0,
    329                                                false),
    330                         ASCIIToUTF16("zip1")));
    331   list_.push_back(NULL);
    332   iter_ = list_.begin();
    333   field_.reset(AddressField::Parse(&iter_, false));
    334   ASSERT_NE(static_cast<AddressField*>(NULL), field_.get());
    335   EXPECT_EQ(kGenericAddress, field_->FindType());
    336   EXPECT_FALSE(field_->IsFullAddress());
    337   ASSERT_TRUE(field_->GetFieldInfo(&field_type_map_));
    338   ASSERT_TRUE(
    339       field_type_map_.find(ASCIIToUTF16("zip1")) != field_type_map_.end());
    340   EXPECT_EQ(ADDRESS_HOME_ZIP, field_type_map_[ASCIIToUTF16("zip1")]);
    341 }
    342 
    343 TEST_F(AddressFieldTest, ParseZipEcml) {
    344   list_.push_back(
    345       new AutofillField(
    346           webkit_glue::FormField(ASCIIToUTF16("Zip"),
    347                                  ASCIIToUTF16(kEcmlShipToPostalCode),
    348                                  string16(),
    349                                  ASCIIToUTF16("text"),
    350                                  0,
    351                                  false),
    352                         ASCIIToUTF16("zip1")));
    353   list_.push_back(NULL);
    354   iter_ = list_.begin();
    355   field_.reset(AddressField::Parse(&iter_, true));
    356   ASSERT_NE(static_cast<AddressField*>(NULL), field_.get());
    357   EXPECT_EQ(kGenericAddress, field_->FindType());
    358   EXPECT_FALSE(field_->IsFullAddress());
    359   ASSERT_TRUE(field_->GetFieldInfo(&field_type_map_));
    360   ASSERT_TRUE(
    361       field_type_map_.find(ASCIIToUTF16("zip1")) != field_type_map_.end());
    362   EXPECT_EQ(ADDRESS_HOME_ZIP, field_type_map_[ASCIIToUTF16("zip1")]);
    363 }
    364 
    365 TEST_F(AddressFieldTest, ParseStateAndZipOneLabel) {
    366   list_.push_back(
    367       new AutofillField(
    368           webkit_glue::FormField(
    369               ASCIIToUTF16("State/Province, Zip/Postal Code"),
    370               ASCIIToUTF16("state"),
    371               string16(),
    372               ASCIIToUTF16("text"),
    373               0,
    374               false),
    375           ASCIIToUTF16("state")));
    376   list_.push_back(
    377       new AutofillField(
    378           webkit_glue::FormField(
    379               ASCIIToUTF16("State/Province, Zip/Postal Code"),
    380               ASCIIToUTF16("zip"),
    381               string16(),
    382               ASCIIToUTF16("text"),
    383               0,
    384               false),
    385           ASCIIToUTF16("zip")));
    386   list_.push_back(NULL);
    387   iter_ = list_.begin();
    388   field_.reset(AddressField::Parse(&iter_, false));
    389   ASSERT_NE(static_cast<AddressField*>(NULL), field_.get());
    390   EXPECT_EQ(kGenericAddress, field_->FindType());
    391   EXPECT_FALSE(field_->IsFullAddress());
    392   ASSERT_TRUE(field_->GetFieldInfo(&field_type_map_));
    393   ASSERT_TRUE(
    394       field_type_map_.find(ASCIIToUTF16("state")) != field_type_map_.end());
    395   EXPECT_EQ(ADDRESS_HOME_STATE, field_type_map_[ASCIIToUTF16("state")]);
    396   ASSERT_TRUE(
    397       field_type_map_.find(ASCIIToUTF16("zip")) != field_type_map_.end());
    398   EXPECT_EQ(ADDRESS_HOME_ZIP, field_type_map_[ASCIIToUTF16("zip")]);
    399 }
    400 
    401 TEST_F(AddressFieldTest, ParseCountry) {
    402   list_.push_back(
    403       new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Country"),
    404                                                ASCIIToUTF16("country"),
    405                                                string16(),
    406                                                ASCIIToUTF16("text"),
    407                                                0,
    408                                                false),
    409                         ASCIIToUTF16("country1")));
    410   list_.push_back(NULL);
    411   iter_ = list_.begin();
    412   field_.reset(AddressField::Parse(&iter_, false));
    413   ASSERT_NE(static_cast<AddressField*>(NULL), field_.get());
    414   EXPECT_EQ(kGenericAddress, field_->FindType());
    415   EXPECT_FALSE(field_->IsFullAddress());
    416   ASSERT_TRUE(field_->GetFieldInfo(&field_type_map_));
    417   ASSERT_TRUE(
    418       field_type_map_.find(ASCIIToUTF16("country1")) != field_type_map_.end());
    419   EXPECT_EQ(ADDRESS_HOME_COUNTRY, field_type_map_[ASCIIToUTF16("country1")]);
    420 }
    421 
    422 TEST_F(AddressFieldTest, ParseCountryEcml) {
    423   list_.push_back(
    424       new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Country"),
    425                                                ASCIIToUTF16(kEcmlShipToCountry),
    426                                                string16(),
    427                                                ASCIIToUTF16("text"),
    428                                                0,
    429                                                false),
    430                         ASCIIToUTF16("country1")));
    431   list_.push_back(NULL);
    432   iter_ = list_.begin();
    433   field_.reset(AddressField::Parse(&iter_, true));
    434   ASSERT_NE(static_cast<AddressField*>(NULL), field_.get());
    435   EXPECT_EQ(kGenericAddress, field_->FindType());
    436   EXPECT_FALSE(field_->IsFullAddress());
    437   ASSERT_TRUE(field_->GetFieldInfo(&field_type_map_));
    438   ASSERT_TRUE(
    439       field_type_map_.find(ASCIIToUTF16("country1")) != field_type_map_.end());
    440   EXPECT_EQ(ADDRESS_HOME_COUNTRY, field_type_map_[ASCIIToUTF16("country1")]);
    441 }
    442 
    443 TEST_F(AddressFieldTest, ParseTwoLineAddressMissingLabel) {
    444   list_.push_back(
    445       new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Address"),
    446                                                ASCIIToUTF16("address"),
    447                                                string16(),
    448                                                ASCIIToUTF16("text"),
    449                                                0,
    450                                                false),
    451                         ASCIIToUTF16("addr1")));
    452   list_.push_back(
    453       new AutofillField(webkit_glue::FormField(string16(),
    454                                                ASCIIToUTF16("bogus"),
    455                                                string16(),
    456                                                ASCIIToUTF16("text"),
    457                                                0,
    458                                                false),
    459                         ASCIIToUTF16("addr2")));
    460   list_.push_back(NULL);
    461   iter_ = list_.begin();
    462   field_.reset(AddressField::Parse(&iter_, false));
    463   ASSERT_NE(static_cast<AddressField*>(NULL), field_.get());
    464   EXPECT_EQ(kGenericAddress, field_->FindType());
    465   EXPECT_TRUE(field_->IsFullAddress());
    466   ASSERT_TRUE(field_->GetFieldInfo(&field_type_map_));
    467   ASSERT_TRUE(
    468       field_type_map_.find(ASCIIToUTF16("addr1")) != field_type_map_.end());
    469   EXPECT_EQ(ADDRESS_HOME_LINE1, field_type_map_[ASCIIToUTF16("addr1")]);
    470   ASSERT_TRUE(
    471       field_type_map_.find(ASCIIToUTF16("addr2")) != field_type_map_.end());
    472   EXPECT_EQ(ADDRESS_HOME_LINE2, field_type_map_[ASCIIToUTF16("addr2")]);
    473 }
    474 
    475 TEST_F(AddressFieldTest, ParseCompany) {
    476   list_.push_back(
    477       new AutofillField(webkit_glue::FormField(ASCIIToUTF16("Company"),
    478                                                ASCIIToUTF16("company"),
    479                                                string16(),
    480                                                ASCIIToUTF16("text"),
    481                                                0,
    482                                                false),
    483                         ASCIIToUTF16("company1")));
    484   list_.push_back(NULL);
    485   iter_ = list_.begin();
    486   field_.reset(AddressField::Parse(&iter_, false));
    487   ASSERT_NE(static_cast<AddressField*>(NULL), field_.get());
    488   EXPECT_EQ(kGenericAddress, field_->FindType());
    489   EXPECT_FALSE(field_->IsFullAddress());
    490   ASSERT_TRUE(field_->GetFieldInfo(&field_type_map_));
    491   ASSERT_TRUE(
    492       field_type_map_.find(ASCIIToUTF16("company1")) != field_type_map_.end());
    493   EXPECT_EQ(COMPANY_NAME, field_type_map_[ASCIIToUTF16("company1")]);
    494 }
    495 
    496 TEST_F(AddressFieldTest, ParseCompanyEcml) {
    497   list_.push_back(
    498       new AutofillField(
    499           webkit_glue::FormField(ASCIIToUTF16("Company"),
    500                                  ASCIIToUTF16(kEcmlShipToCompanyName),
    501                                  string16(),
    502                                  ASCIIToUTF16("text"),
    503                                  0,
    504                                  false),
    505           ASCIIToUTF16("company1")));
    506   list_.push_back(NULL);
    507   iter_ = list_.begin();
    508   field_.reset(AddressField::Parse(&iter_, true));
    509   ASSERT_NE(static_cast<AddressField*>(NULL), field_.get());
    510   EXPECT_EQ(kGenericAddress, field_->FindType());
    511   EXPECT_FALSE(field_->IsFullAddress());
    512   ASSERT_TRUE(field_->GetFieldInfo(&field_type_map_));
    513   ASSERT_TRUE(
    514       field_type_map_.find(ASCIIToUTF16("company1")) != field_type_map_.end());
    515   EXPECT_EQ(COMPANY_NAME, field_type_map_[ASCIIToUTF16("company1")]);
    516 }
    517 
    518 }  // namespace
    519