OLD | NEW |
---|---|
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 "components/autofill/core/browser/field_types.h" | 7 #include "components/autofill/core/browser/field_types.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/addre ss_ui.h" | 9 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_ui .h" |
10 | 10 |
11 namespace autofill { | 11 namespace autofill { |
12 namespace i18ninput { | 12 namespace i18ninput { |
13 | 13 |
14 namespace { | 14 namespace { |
15 | 15 |
16 const size_t kNumberOfAddressLinesUS = 6; | 16 const size_t kNumberOfAddressLinesUS = 6; |
17 | 17 |
18 } // namespace | 18 } // namespace |
19 | 19 |
20 TEST(AutofillDialogI18nInput, USShippingAddress) { | 20 TEST(AutofillDialogI18nInput, USShippingAddress) { |
21 DetailInputs inputs; | 21 DetailInputs inputs; |
22 std::string language_code; | 22 std::string language_code; |
23 BuildAddressInputs(common::ADDRESS_TYPE_SHIPPING, "US", &inputs, | 23 BuildAddressInputs(common::ADDRESS_TYPE_SHIPPING, "US", &inputs, |
24 &language_code); | 24 &language_code); |
25 | 25 |
26 ASSERT_EQ(kNumberOfAddressLinesUS, inputs.size()); | 26 ASSERT_EQ(kNumberOfAddressLinesUS, inputs.size()); |
27 EXPECT_EQ(NAME_FULL, inputs[0].type); | 27 EXPECT_EQ(NAME_FULL, inputs[0].type); |
28 EXPECT_EQ(ADDRESS_HOME_COUNTRY, inputs[kNumberOfAddressLinesUS - 1].type); | 28 EXPECT_EQ(ADDRESS_HOME_COUNTRY, inputs[kNumberOfAddressLinesUS - 1].type); |
29 EXPECT_EQ("en", language_code); | 29 EXPECT_EQ("en", language_code); |
30 } | 30 } |
31 | 31 |
32 TEST(AutofillDialogI18nInput, USBillingAddress) { | 32 TEST(AutofillDialogI18nInput, USBillingAddress) { |
33 DetailInputs inputs; | 33 DetailInputs inputs; |
34 BuildAddressInputs(common::ADDRESS_TYPE_BILLING, "US", &inputs, NULL); | 34 std::string language_code; |
please use gerrit instead
2014/06/05 22:22:48
To reduce reviewer burden: allow NULL for BuildAdd
please use gerrit instead
2014/06/09 23:28:16
Done.
| |
35 BuildAddressInputs(common::ADDRESS_TYPE_BILLING, "US", &inputs, | |
36 &language_code); | |
35 | 37 |
36 ASSERT_EQ(kNumberOfAddressLinesUS, inputs.size()); | 38 ASSERT_EQ(kNumberOfAddressLinesUS, inputs.size()); |
37 EXPECT_EQ(NAME_BILLING_FULL, inputs[0].type); | 39 EXPECT_EQ(NAME_BILLING_FULL, inputs[0].type); |
38 EXPECT_EQ(ADDRESS_BILLING_COUNTRY, inputs[kNumberOfAddressLinesUS - 1].type); | 40 EXPECT_EQ(ADDRESS_BILLING_COUNTRY, inputs[kNumberOfAddressLinesUS - 1].type); |
39 } | 41 } |
40 | 42 |
41 TEST(AutofillDialogI18nInput, USCityStateAndZipCodeShareInputRow) { | 43 TEST(AutofillDialogI18nInput, USCityStateAndZipCodeShareInputRow) { |
42 DetailInputs inputs; | 44 DetailInputs inputs; |
43 BuildAddressInputs(common::ADDRESS_TYPE_SHIPPING, "US", &inputs, NULL); | 45 std::string language_code; |
46 BuildAddressInputs(common::ADDRESS_TYPE_SHIPPING, "US", &inputs, | |
47 &language_code); | |
44 ASSERT_EQ(kNumberOfAddressLinesUS, inputs.size()); | 48 ASSERT_EQ(kNumberOfAddressLinesUS, inputs.size()); |
45 | 49 |
46 int input_index = 2; | 50 int input_index = 2; |
47 | 51 |
48 // Inputs before or after [ City ] [ State ] [ Zip ] should be on other lines. | 52 // Inputs before or after [ City ] [ State ] [ Zip ] should be on other lines. |
49 EXPECT_NE(inputs[input_index - 1].length, DetailInput::SHORT); | 53 EXPECT_NE(inputs[input_index - 1].length, DetailInput::SHORT); |
50 | 54 |
51 const DetailInput& city = inputs[input_index++]; | 55 const DetailInput& city = inputs[input_index++]; |
52 EXPECT_EQ(ADDRESS_HOME_CITY, city.type); | 56 EXPECT_EQ(ADDRESS_HOME_CITY, city.type); |
53 EXPECT_EQ(city.length, DetailInput::SHORT); | 57 EXPECT_EQ(city.length, DetailInput::SHORT); |
(...skipping 16 matching lines...) Expand all Loading... | |
70 &language_code); | 74 &language_code); |
71 for (size_t i = 0; i < inputs.size(); ++i) { | 75 for (size_t i = 0; i < inputs.size(); ++i) { |
72 EXPECT_NE(ADDRESS_HOME_LINE2, inputs[i].type); | 76 EXPECT_NE(ADDRESS_HOME_LINE2, inputs[i].type); |
73 } | 77 } |
74 EXPECT_EQ("fr", language_code); | 78 EXPECT_EQ("fr", language_code); |
75 } | 79 } |
76 | 80 |
77 TEST(AutofillDialogI18nInput, FullySupportedCountries) { | 81 TEST(AutofillDialogI18nInput, FullySupportedCountries) { |
78 const std::vector<std::string>& regions = | 82 const std::vector<std::string>& regions = |
79 ::i18n::addressinput::GetRegionCodes(); | 83 ::i18n::addressinput::GetRegionCodes(); |
80 for (size_t i = 0; i < regions.size(); ++i) { | 84 for (std::vector<std::string>::const_iterator |
81 bool should_be_supported = !(regions[i] == "KR" || regions[i] == "CN"); | 85 it = regions.begin(); it != regions.end(); ++it) { |
82 EXPECT_EQ(should_be_supported, CountryIsFullySupported(regions[i])); | 86 // http://crbug.com/340929 |
87 bool should_be_supported = | |
88 !(*it == "KR" || | |
89 *it == "CN" || | |
90 *it == "MX" || | |
91 *it == "TH"); | |
92 EXPECT_EQ(should_be_supported, CountryIsFullySupported(*it)) << *it; | |
83 } | 93 } |
84 } | 94 } |
85 | 95 |
86 } // namespace i18ninput | 96 } // namespace i18ninput |
87 } // namespace autofill | 97 } // namespace autofill |
OLD | NEW |