Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(835)

Side by Side Diff: chrome/browser/ui/autofill/autofill_dialog_i18n_input_unittest.cc

Issue 124533003: Add country combobox to change country and rebuild address inputs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/autofill/autofill_dialog_i18n_input.h" 5 #include "chrome/browser/ui/autofill/autofill_dialog_i18n_input.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "chrome/common/chrome_switches.h" 8 #include "chrome/common/chrome_switches.h"
9 #include "components/autofill/core/browser/field_types.h" 9 #include "components/autofill/core/browser/field_types.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 11
12 namespace autofill { 12 namespace autofill {
13 namespace i18ninput { 13 namespace i18ninput {
14 14
15 namespace { 15 namespace {
16 16
17 const size_t kNumberOfAddressLinesUS = 7; 17 const size_t kNumberOfAddressLinesUS = 7;
18 18
19 void AppendSwitch() { 19 } // namespace
20
21 TEST(AutofillDialogI18nInput, DisabledByDefaultEnabledByFlag) {
22 EXPECT_FALSE(Enabled());
23
20 CommandLine* command_line = CommandLine::ForCurrentProcess(); 24 CommandLine* command_line = CommandLine::ForCurrentProcess();
21 command_line->AppendSwitch(::switches::kEnableAutofillAddressI18n); 25 command_line->AppendSwitch(::switches::kEnableAutofillAddressI18n);
22 ASSERT_TRUE(Enabled());
23 }
24 26
25 } // namespace 27 EXPECT_TRUE(Enabled());
26
27 TEST(AutofillDialogI18nInput, DisabledByDefault) {
28 EXPECT_FALSE(Enabled());
29 } 28 }
30 29
31 TEST(AutofillDialogI18nInput, USShippingAddress) { 30 TEST(AutofillDialogI18nInput, USShippingAddress) {
32 AppendSwitch();
33
34 DetailInputs inputs; 31 DetailInputs inputs;
35 BuildAddressInputs(common::ADDRESS_TYPE_SHIPPING, "US", &inputs); 32 BuildAddressInputs(common::ADDRESS_TYPE_SHIPPING, "US", &inputs);
36 33
37 ASSERT_EQ(kNumberOfAddressLinesUS, inputs.size()); 34 ASSERT_EQ(kNumberOfAddressLinesUS, inputs.size());
38 EXPECT_EQ(NAME_FULL, inputs[0].type); 35 EXPECT_EQ(NAME_FULL, inputs[0].type);
39 EXPECT_EQ(ADDRESS_HOME_COUNTRY, inputs[kNumberOfAddressLinesUS - 1].type); 36 EXPECT_EQ(ADDRESS_HOME_COUNTRY, inputs[kNumberOfAddressLinesUS - 1].type);
40 } 37 }
41 38
42 TEST(AutofillDialogI18nInput, USBillingAddress) { 39 TEST(AutofillDialogI18nInput, USBillingAddress) {
43 AppendSwitch();
44
45 DetailInputs inputs; 40 DetailInputs inputs;
46 BuildAddressInputs(common::ADDRESS_TYPE_BILLING, "US", &inputs); 41 BuildAddressInputs(common::ADDRESS_TYPE_BILLING, "US", &inputs);
47 42
48 ASSERT_EQ(kNumberOfAddressLinesUS, inputs.size()); 43 ASSERT_EQ(kNumberOfAddressLinesUS, inputs.size());
49 EXPECT_EQ(NAME_BILLING_FULL, inputs[0].type); 44 EXPECT_EQ(NAME_BILLING_FULL, inputs[0].type);
50 EXPECT_EQ(ADDRESS_BILLING_COUNTRY, inputs[kNumberOfAddressLinesUS - 1].type); 45 EXPECT_EQ(ADDRESS_BILLING_COUNTRY, inputs[kNumberOfAddressLinesUS - 1].type);
51 } 46 }
52 47
53 TEST(AutofillDialogI18nInput, USCityStateAndZipCodeShareInputRow) { 48 TEST(AutofillDialogI18nInput, USCityStateAndZipCodeShareInputRow) {
54 AppendSwitch();
55
56 DetailInputs inputs; 49 DetailInputs inputs;
57 BuildAddressInputs(common::ADDRESS_TYPE_SHIPPING, "US", &inputs); 50 BuildAddressInputs(common::ADDRESS_TYPE_SHIPPING, "US", &inputs);
58 ASSERT_EQ(kNumberOfAddressLinesUS, inputs.size()); 51 ASSERT_EQ(kNumberOfAddressLinesUS, inputs.size());
59 52
60 // Inputs before or after [ City ] [ State ] [ Zip ] should be on other lines. 53 // Inputs before or after [ City ] [ State ] [ Zip ] should be on other lines.
61 EXPECT_NE(inputs[2].length, DetailInput::SHORT); 54 EXPECT_NE(inputs[2].length, DetailInput::SHORT);
62 55
63 const DetailInput& city = inputs[3]; 56 const DetailInput& city = inputs[3];
64 ASSERT_EQ(ADDRESS_HOME_CITY, city.type); 57 ASSERT_EQ(ADDRESS_HOME_CITY, city.type);
65 EXPECT_EQ(city.length, DetailInput::SHORT); 58 EXPECT_EQ(city.length, DetailInput::SHORT);
66 59
67 const DetailInput& state = inputs[4]; 60 const DetailInput& state = inputs[4];
68 ASSERT_EQ(ADDRESS_HOME_STATE, state.type); 61 ASSERT_EQ(ADDRESS_HOME_STATE, state.type);
69 EXPECT_EQ(state.length, DetailInput::SHORT); 62 EXPECT_EQ(state.length, DetailInput::SHORT);
70 63
71 const DetailInput& zip = inputs[5]; 64 const DetailInput& zip = inputs[5];
72 ASSERT_EQ(ADDRESS_HOME_ZIP, zip.type); 65 ASSERT_EQ(ADDRESS_HOME_ZIP, zip.type);
73 EXPECT_EQ(zip.length, DetailInput::SHORT); 66 EXPECT_EQ(zip.length, DetailInput::SHORT);
74 67
75 EXPECT_NE(inputs[6].length, DetailInput::SHORT); 68 EXPECT_NE(inputs[6].length, DetailInput::SHORT);
76 } 69 }
77 70
78 } // namespace i18ninput 71 } // namespace i18ninput
79 } // namespace autofill 72 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698