Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / autofill / autofill_dialog_i18n_input_unittest.cc
blobaacbb9966e2b0881efed379276d62639793bad8a
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 "base/command_line.h"
8 #include "chrome/common/chrome_switches.h"
9 #include "components/autofill/core/browser/field_types.h"
10 #include "testing/gtest/include/gtest/gtest.h"
12 namespace autofill {
13 namespace i18ninput {
15 namespace {
17 const size_t kNumberOfAddressLinesUS = 7;
19 } // namespace
21 TEST(AutofillDialogI18nInput, DisabledByDefaultEnabledByFlag) {
22 EXPECT_FALSE(Enabled());
24 CommandLine* command_line = CommandLine::ForCurrentProcess();
25 command_line->AppendSwitch(::switches::kEnableAutofillAddressI18n);
27 EXPECT_TRUE(Enabled());
30 TEST(AutofillDialogI18nInput, USShippingAddress) {
31 DetailInputs inputs;
32 BuildAddressInputs(common::ADDRESS_TYPE_SHIPPING, "US", &inputs);
34 ASSERT_EQ(kNumberOfAddressLinesUS, inputs.size());
35 EXPECT_EQ(NAME_FULL, inputs[0].type);
36 EXPECT_EQ(ADDRESS_HOME_COUNTRY, inputs[kNumberOfAddressLinesUS - 1].type);
39 TEST(AutofillDialogI18nInput, USBillingAddress) {
40 DetailInputs inputs;
41 BuildAddressInputs(common::ADDRESS_TYPE_BILLING, "US", &inputs);
43 ASSERT_EQ(kNumberOfAddressLinesUS, inputs.size());
44 EXPECT_EQ(NAME_BILLING_FULL, inputs[0].type);
45 EXPECT_EQ(ADDRESS_BILLING_COUNTRY, inputs[kNumberOfAddressLinesUS - 1].type);
48 TEST(AutofillDialogI18nInput, USCityStateAndZipCodeShareInputRow) {
49 DetailInputs inputs;
50 BuildAddressInputs(common::ADDRESS_TYPE_SHIPPING, "US", &inputs);
51 ASSERT_EQ(kNumberOfAddressLinesUS, inputs.size());
53 // Inputs before or after [ City ] [ State ] [ Zip ] should be on other lines.
54 EXPECT_NE(inputs[2].length, DetailInput::SHORT);
56 const DetailInput& city = inputs[3];
57 ASSERT_EQ(ADDRESS_HOME_CITY, city.type);
58 EXPECT_EQ(city.length, DetailInput::SHORT);
60 const DetailInput& state = inputs[4];
61 ASSERT_EQ(ADDRESS_HOME_STATE, state.type);
62 EXPECT_EQ(state.length, DetailInput::SHORT);
64 const DetailInput& zip = inputs[5];
65 ASSERT_EQ(ADDRESS_HOME_ZIP, zip.type);
66 EXPECT_EQ(zip.length, DetailInput::SHORT);
68 EXPECT_NE(inputs[6].length, DetailInput::SHORT);
71 TEST(AutofillDialogI18nInput, IvoryCoastNoStreetLine2) {
72 DetailInputs inputs;
73 BuildAddressInputs(common::ADDRESS_TYPE_SHIPPING, "CI", &inputs);
74 for (size_t i = 0; i < inputs.size(); ++i) {
75 EXPECT_NE(ADDRESS_HOME_LINE2, inputs[i].type);
79 } // namespace i18ninput
80 } // namespace autofill