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 kNumberOfAdderssLinesUS = 7; | |
Evan Stade
2013/10/08 23:44:51
spelling of this variable
| |
20 | |
21 } // namespace | |
22 | |
23 TEST(AutofillDialogI18nInput, I18nAddressInputIsDisabledByDefault) { | |
24 EXPECT_FALSE(IsI18nAddressInputEnabled()); | |
25 CommandLine::ForCurrentProcess()->AppendSwitch( | |
26 ::switches::kEnableAutofillAddressInternationalization); | |
27 EXPECT_TRUE(IsI18nAddressInputEnabled()); | |
28 } | |
29 | |
30 TEST(AutofillDialogI18nInput, USShippingAddress) { | |
31 DetailInputs inputs; | |
32 BuildI18nInputs(ADDRESS_TYPE_SHIPPING, "US", 0, &inputs); | |
33 | |
34 ASSERT_EQ(kNumberOfAdderssLinesUS, inputs.size()); | |
35 EXPECT_EQ(NAME_FULL, inputs[0].type); | |
36 EXPECT_EQ(ADDRESS_HOME_COUNTRY, inputs[kNumberOfAdderssLinesUS - 1].type); | |
37 } | |
38 | |
39 TEST(AutofillDialogI18nInput, USBillingAddress) { | |
40 DetailInputs inputs; | |
41 BuildI18nInputs(ADDRESS_TYPE_BILLING, "US", 0, &inputs); | |
42 | |
43 ASSERT_EQ(kNumberOfAdderssLinesUS, inputs.size()); | |
44 EXPECT_EQ(NAME_BILLING_FULL, inputs[0].type); | |
45 EXPECT_EQ(ADDRESS_BILLING_COUNTRY, inputs[kNumberOfAdderssLinesUS - 1].type); | |
46 } | |
47 | |
48 TEST(AutofillDialogI18nInput, USStateAndZipCodeShareInputRow) { | |
49 static const int kStateInputIndex = 4; | |
50 static const int kZipCodeInputIndex = 5; | |
51 | |
52 DetailInputs inputs; | |
53 BuildI18nInputs(ADDRESS_TYPE_SHIPPING, "US", 0, &inputs); | |
54 | |
55 ASSERT_EQ(kNumberOfAdderssLinesUS, inputs.size()); | |
56 | |
57 EXPECT_EQ(ADDRESS_HOME_STATE, inputs[kStateInputIndex].type); | |
58 EXPECT_EQ(ADDRESS_HOME_ZIP, inputs[kZipCodeInputIndex].type); | |
59 | |
60 EXPECT_EQ(inputs[kStateInputIndex].row_id, inputs[kZipCodeInputIndex].row_id); | |
61 | |
62 EXPECT_NE(inputs[kStateInputIndex].row_id, | |
63 inputs[kStateInputIndex - 1].row_id); | |
64 EXPECT_NE(inputs[kZipCodeInputIndex].row_id, | |
65 inputs[kZipCodeInputIndex + 1].row_id); | |
66 } | |
67 | |
68 } // namespace i18ninput | |
69 } // namespace autofill | |
OLD | NEW |