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

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

Issue 298863012: Use upstream libaddressinput in Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Initial. Created 6 years, 7 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 "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;
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 24 matching lines...) Expand all
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 (size_t i = 0; i < regions.size(); ++i) {
81 bool should_be_supported = !(regions[i] == "KR" || regions[i] == "CN"); 85 bool should_be_supported = !(regions[i] == "KR" || regions[i] == "CN");
82 EXPECT_EQ(should_be_supported, CountryIsFullySupported(regions[i])); 86 EXPECT_EQ(should_be_supported, CountryIsFullySupported(regions[i]));
83 } 87 }
84 } 88 }
85 89
86 } // namespace i18ninput 90 } // namespace i18ninput
87 } // namespace autofill 91 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698