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

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: Fixups Created 6 years, 8 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 BuildAddressInputs(common::ADDRESS_TYPE_BILLING, "US", &inputs, NULL);
36 39
37 ASSERT_EQ(kNumberOfAddressLinesUS, inputs.size()); 40 ASSERT_EQ(kNumberOfAddressLinesUS, inputs.size());
38 EXPECT_EQ(NAME_BILLING_FULL, inputs[0].type); 41 EXPECT_EQ(NAME_BILLING_FULL, inputs[0].type);
39 EXPECT_EQ(ADDRESS_BILLING_COUNTRY, inputs[kNumberOfAddressLinesUS - 1].type); 42 EXPECT_EQ(ADDRESS_BILLING_COUNTRY, inputs[kNumberOfAddressLinesUS - 1].type);
40 } 43 }
41 44
42 TEST(AutofillDialogI18nInput, USCityStateAndZipCodeShareInputRow) { 45 TEST(AutofillDialogI18nInput, USCityStateAndZipCodeShareInputRow) {
43 DetailInputs inputs; 46 DetailInputs inputs;
44 BuildAddressInputs(common::ADDRESS_TYPE_SHIPPING, "US", &inputs); 47 BuildAddressInputs(common::ADDRESS_TYPE_SHIPPING, "US", &inputs, NULL);
45 ASSERT_EQ(kNumberOfAddressLinesUS, inputs.size()); 48 ASSERT_EQ(kNumberOfAddressLinesUS, inputs.size());
46 49
47 #if defined(OS_MACOSX) 50 #if defined(OS_MACOSX)
48 int input_index = 3; 51 int input_index = 3;
49 #else 52 #else
50 int input_index = 2; 53 int input_index = 2;
51 #endif 54 #endif
52 55
53 // Inputs before or after [ City ] [ State ] [ Zip ] should be on other lines. 56 // Inputs before or after [ City ] [ State ] [ Zip ] should be on other lines.
54 EXPECT_NE(inputs[input_index - 1].length, DetailInput::SHORT); 57 EXPECT_NE(inputs[input_index - 1].length, DetailInput::SHORT);
55 58
56 const DetailInput& city = inputs[input_index++]; 59 const DetailInput& city = inputs[input_index++];
57 EXPECT_EQ(ADDRESS_HOME_CITY, city.type); 60 EXPECT_EQ(ADDRESS_HOME_CITY, city.type);
58 EXPECT_EQ(city.length, DetailInput::SHORT); 61 EXPECT_EQ(city.length, DetailInput::SHORT);
59 62
60 const DetailInput& state = inputs[input_index++]; 63 const DetailInput& state = inputs[input_index++];
61 EXPECT_EQ(ADDRESS_HOME_STATE, state.type); 64 EXPECT_EQ(ADDRESS_HOME_STATE, state.type);
62 EXPECT_EQ(state.length, DetailInput::SHORT); 65 EXPECT_EQ(state.length, DetailInput::SHORT);
63 66
64 const DetailInput& zip = inputs[input_index++]; 67 const DetailInput& zip = inputs[input_index++];
65 EXPECT_EQ(ADDRESS_HOME_ZIP, zip.type); 68 EXPECT_EQ(ADDRESS_HOME_ZIP, zip.type);
66 EXPECT_EQ(zip.length, DetailInput::SHORT); 69 EXPECT_EQ(zip.length, DetailInput::SHORT);
67 70
68 EXPECT_NE(inputs[input_index].length, DetailInput::SHORT); 71 EXPECT_NE(inputs[input_index].length, DetailInput::SHORT);
69 } 72 }
70 73
71 TEST(AutofillDialogI18nInput, IvoryCoastNoStreetLine2) { 74 TEST(AutofillDialogI18nInput, IvoryCoastNoStreetLine2) {
72 DetailInputs inputs; 75 DetailInputs inputs;
73 BuildAddressInputs(common::ADDRESS_TYPE_SHIPPING, "CI", &inputs); 76 std::string language_code;
77 BuildAddressInputs(common::ADDRESS_TYPE_SHIPPING, "CI", &inputs,
78 &language_code);
74 for (size_t i = 0; i < inputs.size(); ++i) { 79 for (size_t i = 0; i < inputs.size(); ++i) {
75 EXPECT_NE(ADDRESS_HOME_LINE2, inputs[i].type); 80 EXPECT_NE(ADDRESS_HOME_LINE2, inputs[i].type);
76 } 81 }
82 EXPECT_EQ("fr", language_code);
77 } 83 }
78 84
79 TEST(AutofillDialogI18nInput, FullySupportedCountries) { 85 TEST(AutofillDialogI18nInput, FullySupportedCountries) {
80 const std::vector<std::string>& regions = 86 const std::vector<std::string>& regions =
81 ::i18n::addressinput::GetRegionCodes(); 87 ::i18n::addressinput::GetRegionCodes();
82 for (size_t i = 0; i < regions.size(); ++i) { 88 for (size_t i = 0; i < regions.size(); ++i) {
83 bool should_be_supported = !(regions[i] == "KR" || regions[i] == "CN"); 89 bool should_be_supported = !(regions[i] == "KR" || regions[i] == "CN");
84 EXPECT_EQ(should_be_supported, CountryIsFullySupported(regions[i])); 90 EXPECT_EQ(should_be_supported, CountryIsFullySupported(regions[i]));
85 } 91 }
86 } 92 }
87 93
88 } // namespace i18ninput 94 } // namespace i18ninput
89 } // namespace autofill 95 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/ui/autofill/autofill_dialog_i18n_input.cc ('k') | chrome/browser/ui/autofill/data_model_wrapper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698