1 // Copyright 2014 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.
5 #include "chrome/browser/ui/autofill/autofill_dialog_i18n_input.h"
7 #include "components/autofill/core/browser/field_types.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_ui.h"
16 const size_t kNumberOfAddressLinesUS
= 6;
20 TEST(AutofillDialogI18nInput
, USShippingAddress
) {
22 std::string language_code
;
23 BuildAddressInputs(common::ADDRESS_TYPE_SHIPPING
, "US", &inputs
,
26 ASSERT_EQ(kNumberOfAddressLinesUS
, inputs
.size());
27 EXPECT_EQ(NAME_FULL
, inputs
[0].type
);
28 EXPECT_EQ(ADDRESS_HOME_COUNTRY
, inputs
[kNumberOfAddressLinesUS
- 1].type
);
29 EXPECT_EQ("en", language_code
);
32 TEST(AutofillDialogI18nInput
, USBillingAddress
) {
34 BuildAddressInputs(common::ADDRESS_TYPE_BILLING
, "US", &inputs
, NULL
);
36 ASSERT_EQ(kNumberOfAddressLinesUS
, inputs
.size());
37 EXPECT_EQ(NAME_BILLING_FULL
, inputs
[0].type
);
38 EXPECT_EQ(ADDRESS_BILLING_COUNTRY
, inputs
[kNumberOfAddressLinesUS
- 1].type
);
41 TEST(AutofillDialogI18nInput
, USCityStateAndZipCodeShareInputRow
) {
43 BuildAddressInputs(common::ADDRESS_TYPE_SHIPPING
, "US", &inputs
, NULL
);
44 ASSERT_EQ(kNumberOfAddressLinesUS
, inputs
.size());
48 // Inputs before or after [ City ] [ State ] [ Zip ] should be on other lines.
49 EXPECT_NE(inputs
[input_index
- 1].length
, DetailInput::SHORT
);
51 const DetailInput
& city
= inputs
[input_index
++];
52 EXPECT_EQ(ADDRESS_HOME_CITY
, city
.type
);
53 EXPECT_EQ(city
.length
, DetailInput::SHORT
);
55 const DetailInput
& state
= inputs
[input_index
++];
56 EXPECT_EQ(ADDRESS_HOME_STATE
, state
.type
);
57 EXPECT_EQ(state
.length
, DetailInput::SHORT
);
59 const DetailInput
& zip
= inputs
[input_index
++];
60 EXPECT_EQ(ADDRESS_HOME_ZIP
, zip
.type
);
61 EXPECT_EQ(zip
.length
, DetailInput::SHORT
);
63 EXPECT_NE(inputs
[input_index
].length
, DetailInput::SHORT
);
66 TEST(AutofillDialogI18nInput
, IvoryCoastNoStreetLine2
) {
68 std::string language_code
;
69 BuildAddressInputs(common::ADDRESS_TYPE_SHIPPING
, "CI", &inputs
,
71 for (size_t i
= 0; i
< inputs
.size(); ++i
) {
72 EXPECT_NE(ADDRESS_HOME_LINE2
, inputs
[i
].type
);
74 EXPECT_EQ("fr", language_code
);
77 } // namespace i18ninput
78 } // namespace autofill