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