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

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

Issue 172783003: rAc: don't show countries with partially supported address fields for now. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: compile Created 6 years, 10 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/country_combobox_model.h" 5 #include "chrome/browser/ui/autofill/country_combobox_model.h"
6 6
7 #include "components/autofill/core/browser/autofill_country.h" 7 #include "components/autofill/core/browser/autofill_country.h"
8 #include "components/autofill/core/browser/test_personal_data_manager.h" 8 #include "components/autofill/core/browser/test_personal_data_manager.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/addre ss_ui.h" 10 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/addre ss_ui.h"
11 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/addre ss_ui_component.h" 11 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/addre ss_ui_component.h"
12 12
13 namespace autofill { 13 namespace autofill {
14 14
15 TEST(CountryComboboxModel, RespectsManagerDefaultCountry) { 15 TEST(CountryComboboxModel, RespectsManagerDefaultCountry) {
16 const std::string test_country = "AQ"; 16 const std::string test_country = "AQ";
17 TestPersonalDataManager manager; 17 TestPersonalDataManager manager;
18 manager.set_timezone_country_code(test_country); 18 manager.set_timezone_country_code(test_country);
19 19
20 CountryComboboxModel model(manager); 20 CountryComboboxModel model(manager, true);
21 EXPECT_EQ(test_country, model.GetDefaultCountryCode()); 21 EXPECT_EQ(test_country, model.GetDefaultCountryCode());
22 } 22 }
23 23
24 TEST(CountryComboboxModel, AllCountriesHaveComponents) { 24 TEST(CountryComboboxModel, AllCountriesHaveComponents) {
25 TestPersonalDataManager manager; 25 TestPersonalDataManager manager;
26 CountryComboboxModel model(manager); 26 CountryComboboxModel model(manager, true);
27 27
28 for (int i = 0; i < model.GetItemCount(); ++i) { 28 for (int i = 0; i < model.GetItemCount(); ++i) {
29 if (model.IsItemSeparatorAt(i)) 29 if (model.IsItemSeparatorAt(i))
30 continue; 30 continue;
31 31
32 std::string country_code = model.countries()[i]->country_code(); 32 std::string country_code = model.countries()[i]->country_code();
33 std::vector< ::i18n::addressinput::AddressUiComponent> components = 33 std::vector< ::i18n::addressinput::AddressUiComponent> components =
34 ::i18n::addressinput::BuildComponents(country_code); 34 ::i18n::addressinput::BuildComponents(country_code);
35 EXPECT_FALSE(components.empty()); 35 EXPECT_FALSE(components.empty());
36 } 36 }
37 } 37 }
38 38
39 TEST(CountryComboboxModel, CountriesWithDependentLocalityNotShown) {
40 TestPersonalDataManager manager;
41 manager.set_timezone_country_code("KR");
42 CountryComboboxModel model(manager, false);
43 EXPECT_NE("KR", model.GetDefaultCountryCode());
44
45 for (int i = 0; i < model.GetItemCount(); ++i) {
46 ASSERT_FALSE(model.IsItemSeparatorAt(i));
47 std::string country_code = model.countries()[i]->country_code();
48 std::vector< ::i18n::addressinput::AddressUiComponent> components =
49 ::i18n::addressinput::BuildComponents(country_code);
50 ASSERT_FALSE(components.empty());
51 for (size_t j = 0; j < components.size(); ++j) {
52 EXPECT_NE(components[j].field, ::i18n::addressinput::DEPENDENT_LOCALITY);
53 }
54 }
55 }
56
39 } // namespace autofill 57 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/ui/autofill/country_combobox_model.cc ('k') | chrome/browser/ui/webui/options/autofill_options_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698