| 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/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 namespace { | 15 TEST(CountryComboboxModel, RespectsManagerDefaultCountry) { |
| 16 const char kTestCountry[] = "AQ"; | 16 const std::string test_country = "AQ"; |
| 17 TestPersonalDataManager manager; |
| 18 manager.set_timezone_country_code(test_country); |
| 19 |
| 20 CountryComboboxModel model(manager); |
| 21 EXPECT_EQ(test_country, model.GetDefaultCountryCode()); |
| 17 } | 22 } |
| 18 | 23 |
| 19 TEST(CountryComboboxModel, RespectsManagerDefaultCountry) { | 24 TEST(CountryComboboxModel, AllCountriesHaveComponents) { |
| 20 TestPersonalDataManager manager; | |
| 21 manager.set_timezone_country_code(kTestCountry); | |
| 22 | |
| 23 CountryComboboxModel model(manager); | |
| 24 EXPECT_EQ(kTestCountry, model.GetDefaultCountryCode()); | |
| 25 } | |
| 26 | |
| 27 // http://crbug.com/341329 | |
| 28 #if defined(TOOLKIT_GTK) | |
| 29 #define MAYBE_AllCountriesHaveComponents DISABLED_AllCountriesHaveComponents | |
| 30 #else | |
| 31 #define MAYBE_AllCountriesHaveComponents AllCountriesHaveComponents | |
| 32 #endif | |
| 33 | |
| 34 TEST(CountryComboboxModel, MAYBE_AllCountriesHaveComponents) { | |
| 35 TestPersonalDataManager manager; | 25 TestPersonalDataManager manager; |
| 36 CountryComboboxModel model(manager); | 26 CountryComboboxModel model(manager); |
| 37 | 27 |
| 38 for (int i = 0; i < model.GetItemCount(); ++i) { | 28 for (int i = 0; i < model.GetItemCount(); ++i) { |
| 39 if (model.IsItemSeparatorAt(i)) | 29 if (model.IsItemSeparatorAt(i)) |
| 40 continue; | 30 continue; |
| 41 | 31 |
| 42 std::string country_code = model.countries()[i]->country_code(); | 32 std::string country_code = model.countries()[i]->country_code(); |
| 43 std::vector< ::i18n::addressinput::AddressUiComponent> components = | 33 std::vector< ::i18n::addressinput::AddressUiComponent> components = |
| 44 ::i18n::addressinput::BuildComponents(country_code); | 34 ::i18n::addressinput::BuildComponents(country_code); |
| 45 EXPECT_FALSE(components.empty()); | 35 EXPECT_FALSE(components.empty()); |
| 46 } | 36 } |
| 47 } | 37 } |
| 48 | 38 |
| 49 } // namespace autofill | 39 } // namespace autofill |
| OLD | NEW |