OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 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 "chrome/browser/ui/autofill/autofill_dialog_i18n_input.h" |
| 6 |
| 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" |
| 11 |
| 12 namespace autofill { |
| 13 namespace i18ninput { |
| 14 |
| 15 namespace { |
| 16 |
| 17 const size_t kNumberOfAddressLinesUS = 7; |
| 18 |
| 19 void AppendSwitch() { |
| 20 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 21 command_line->AppendSwitch(::switches::kEnableAutofillAddressI18n); |
| 22 ASSERT_TRUE(Enabled()); |
| 23 } |
| 24 |
| 25 } // namespace |
| 26 |
| 27 TEST(AutofillDialogI18nInput, DisabledByDefault) { |
| 28 EXPECT_FALSE(Enabled()); |
| 29 } |
| 30 |
| 31 TEST(AutofillDialogI18nInput, USShippingAddress) { |
| 32 AppendSwitch(); |
| 33 |
| 34 DetailInputs inputs; |
| 35 BuildAddressInputs(common::ADDRESS_TYPE_SHIPPING, "US", &inputs); |
| 36 |
| 37 ASSERT_EQ(kNumberOfAddressLinesUS, inputs.size()); |
| 38 EXPECT_EQ(NAME_FULL, inputs[0].type); |
| 39 EXPECT_EQ(ADDRESS_HOME_COUNTRY, inputs[kNumberOfAddressLinesUS - 1].type); |
| 40 } |
| 41 |
| 42 TEST(AutofillDialogI18nInput, USBillingAddress) { |
| 43 AppendSwitch(); |
| 44 |
| 45 DetailInputs inputs; |
| 46 BuildAddressInputs(common::ADDRESS_TYPE_BILLING, "US", &inputs); |
| 47 |
| 48 ASSERT_EQ(kNumberOfAddressLinesUS, inputs.size()); |
| 49 EXPECT_EQ(NAME_BILLING_FULL, inputs[0].type); |
| 50 EXPECT_EQ(ADDRESS_BILLING_COUNTRY, inputs[kNumberOfAddressLinesUS - 1].type); |
| 51 } |
| 52 |
| 53 TEST(AutofillDialogI18nInput, USCityStateAndZipCodeShareInputRow) { |
| 54 AppendSwitch(); |
| 55 |
| 56 DetailInputs inputs; |
| 57 BuildAddressInputs(common::ADDRESS_TYPE_SHIPPING, "US", &inputs); |
| 58 ASSERT_EQ(kNumberOfAddressLinesUS, inputs.size()); |
| 59 |
| 60 // Inputs before or after [ City ] [ State ] [ Zip ] should be on other lines. |
| 61 EXPECT_NE(inputs[2].length, DetailInput::SHORT); |
| 62 |
| 63 const DetailInput& city = inputs[3]; |
| 64 ASSERT_EQ(ADDRESS_HOME_CITY, city.type); |
| 65 EXPECT_EQ(city.length, DetailInput::SHORT); |
| 66 |
| 67 const DetailInput& state = inputs[4]; |
| 68 ASSERT_EQ(ADDRESS_HOME_STATE, state.type); |
| 69 EXPECT_EQ(state.length, DetailInput::SHORT); |
| 70 |
| 71 const DetailInput& zip = inputs[5]; |
| 72 ASSERT_EQ(ADDRESS_HOME_ZIP, zip.type); |
| 73 EXPECT_EQ(zip.length, DetailInput::SHORT); |
| 74 |
| 75 EXPECT_NE(inputs[6].length, DetailInput::SHORT); |
| 76 } |
| 77 |
| 78 } // namespace i18ninput |
| 79 } // namespace autofill |
OLD | NEW |