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

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

Issue 212873003: Store the language code for the address in autofill profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments. Created 6 years, 9 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/chromium/cpp/include/libaddressinput/addre ss_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 #if defined(OS_MACOSX) 16 #if defined(OS_MACOSX)
17 const size_t kNumberOfAddressLinesUS = 7; 17 const size_t kNumberOfAddressLinesUS = 7;
18 #else 18 #else
19 const size_t kNumberOfAddressLinesUS = 6; 19 const size_t kNumberOfAddressLinesUS = 6;
20 #endif 20 #endif
21 21
22 } // namespace 22 } // namespace
23 23
24 TEST(AutofillDialogI18nInput, USShippingAddress) { 24 TEST(AutofillDialogI18nInput, USShippingAddress) {
25 DetailInputs inputs; 25 DetailInputs inputs;
26 BuildAddressInputs(common::ADDRESS_TYPE_SHIPPING, "US", &inputs); 26 std::string language_code;
27 BuildAddressInputs(common::ADDRESS_TYPE_SHIPPING, "US", &inputs,
28 &language_code);
27 29
28 ASSERT_EQ(kNumberOfAddressLinesUS, inputs.size()); 30 ASSERT_EQ(kNumberOfAddressLinesUS, inputs.size());
29 EXPECT_EQ(NAME_FULL, inputs[0].type); 31 EXPECT_EQ(NAME_FULL, inputs[0].type);
30 EXPECT_EQ(ADDRESS_HOME_COUNTRY, inputs[kNumberOfAddressLinesUS - 1].type); 32 EXPECT_EQ(ADDRESS_HOME_COUNTRY, inputs[kNumberOfAddressLinesUS - 1].type);
33 EXPECT_EQ("en", language_code);
31 } 34 }
32 35
33 TEST(AutofillDialogI18nInput, USBillingAddress) { 36 TEST(AutofillDialogI18nInput, USBillingAddress) {
34 DetailInputs inputs; 37 DetailInputs inputs;
35 BuildAddressInputs(common::ADDRESS_TYPE_BILLING, "US", &inputs); 38 std::string language_code;
39 BuildAddressInputs(common::ADDRESS_TYPE_BILLING, "US", &inputs,
40 &language_code);
Ilya Sherman 2014/03/29 01:24:42 nit: Might as well either pass NULL or verify the
please use gerrit instead 2014/04/02 21:54:52 Done.
36 41
37 ASSERT_EQ(kNumberOfAddressLinesUS, inputs.size()); 42 ASSERT_EQ(kNumberOfAddressLinesUS, inputs.size());
38 EXPECT_EQ(NAME_BILLING_FULL, inputs[0].type); 43 EXPECT_EQ(NAME_BILLING_FULL, inputs[0].type);
39 EXPECT_EQ(ADDRESS_BILLING_COUNTRY, inputs[kNumberOfAddressLinesUS - 1].type); 44 EXPECT_EQ(ADDRESS_BILLING_COUNTRY, inputs[kNumberOfAddressLinesUS - 1].type);
40 } 45 }
41 46
42 TEST(AutofillDialogI18nInput, USCityStateAndZipCodeShareInputRow) { 47 TEST(AutofillDialogI18nInput, USCityStateAndZipCodeShareInputRow) {
43 DetailInputs inputs; 48 DetailInputs inputs;
44 BuildAddressInputs(common::ADDRESS_TYPE_SHIPPING, "US", &inputs); 49 BuildAddressInputs(common::ADDRESS_TYPE_SHIPPING, "US", &inputs, NULL);
45 ASSERT_EQ(kNumberOfAddressLinesUS, inputs.size()); 50 ASSERT_EQ(kNumberOfAddressLinesUS, inputs.size());
46 51
47 #if defined(OS_MACOSX) 52 #if defined(OS_MACOSX)
48 int input_index = 3; 53 int input_index = 3;
49 #else 54 #else
50 int input_index = 2; 55 int input_index = 2;
51 #endif 56 #endif
52 57
53 // Inputs before or after [ City ] [ State ] [ Zip ] should be on other lines. 58 // Inputs before or after [ City ] [ State ] [ Zip ] should be on other lines.
54 EXPECT_NE(inputs[input_index - 1].length, DetailInput::SHORT); 59 EXPECT_NE(inputs[input_index - 1].length, DetailInput::SHORT);
55 60
56 const DetailInput& city = inputs[input_index++]; 61 const DetailInput& city = inputs[input_index++];
57 EXPECT_EQ(ADDRESS_HOME_CITY, city.type); 62 EXPECT_EQ(ADDRESS_HOME_CITY, city.type);
58 EXPECT_EQ(city.length, DetailInput::SHORT); 63 EXPECT_EQ(city.length, DetailInput::SHORT);
59 64
60 const DetailInput& state = inputs[input_index++]; 65 const DetailInput& state = inputs[input_index++];
61 EXPECT_EQ(ADDRESS_HOME_STATE, state.type); 66 EXPECT_EQ(ADDRESS_HOME_STATE, state.type);
62 EXPECT_EQ(state.length, DetailInput::SHORT); 67 EXPECT_EQ(state.length, DetailInput::SHORT);
63 68
64 const DetailInput& zip = inputs[input_index++]; 69 const DetailInput& zip = inputs[input_index++];
65 EXPECT_EQ(ADDRESS_HOME_ZIP, zip.type); 70 EXPECT_EQ(ADDRESS_HOME_ZIP, zip.type);
66 EXPECT_EQ(zip.length, DetailInput::SHORT); 71 EXPECT_EQ(zip.length, DetailInput::SHORT);
67 72
68 EXPECT_NE(inputs[input_index].length, DetailInput::SHORT); 73 EXPECT_NE(inputs[input_index].length, DetailInput::SHORT);
69 } 74 }
70 75
71 TEST(AutofillDialogI18nInput, IvoryCoastNoStreetLine2) { 76 TEST(AutofillDialogI18nInput, IvoryCoastNoStreetLine2) {
72 DetailInputs inputs; 77 DetailInputs inputs;
73 BuildAddressInputs(common::ADDRESS_TYPE_SHIPPING, "CI", &inputs); 78 std::string language_code;
79 BuildAddressInputs(common::ADDRESS_TYPE_SHIPPING, "CI", &inputs,
80 &language_code);
74 for (size_t i = 0; i < inputs.size(); ++i) { 81 for (size_t i = 0; i < inputs.size(); ++i) {
75 EXPECT_NE(ADDRESS_HOME_LINE2, inputs[i].type); 82 EXPECT_NE(ADDRESS_HOME_LINE2, inputs[i].type);
76 } 83 }
84 EXPECT_EQ("fr", language_code);
77 } 85 }
78 86
79 TEST(AutofillDialogI18nInput, FullySupportedCountries) { 87 TEST(AutofillDialogI18nInput, FullySupportedCountries) {
80 const std::vector<std::string>& regions = 88 const std::vector<std::string>& regions =
81 ::i18n::addressinput::GetRegionCodes(); 89 ::i18n::addressinput::GetRegionCodes();
82 for (size_t i = 0; i < regions.size(); ++i) { 90 for (size_t i = 0; i < regions.size(); ++i) {
83 bool should_be_supported = !(regions[i] == "KR" || regions[i] == "CN"); 91 bool should_be_supported = !(regions[i] == "KR" || regions[i] == "CN");
84 EXPECT_EQ(should_be_supported, CountryIsFullySupported(regions[i])); 92 EXPECT_EQ(should_be_supported, CountryIsFullySupported(regions[i]));
85 } 93 }
86 } 94 }
87 95
88 } // namespace i18ninput 96 } // namespace i18ninput
89 } // namespace autofill 97 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698