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 "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/test/base/testing_profile.h" | 9 #include "chrome/test/base/testing_profile.h" |
10 #include "components/autofill/core/browser/autofill_country.h" | 10 #include "components/autofill/core/browser/autofill_country.h" |
11 #include "components/autofill/core/browser/test_personal_data_manager.h" | 11 #include "components/autofill/core/browser/test_personal_data_manager.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
13 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_ui
.h" | 13 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/addre
ss_ui.h" |
14 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_ui
_component.h" | 14 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/addre
ss_ui_component.h" |
15 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/localizati
on.h" | |
16 | 15 |
17 namespace autofill { | 16 namespace autofill { |
18 | 17 |
19 class CountryComboboxModelTest : public testing::Test { | 18 class CountryComboboxModelTest : public testing::Test { |
20 public: | 19 public: |
21 CountryComboboxModelTest() { | 20 CountryComboboxModelTest() { |
22 manager_.Init(NULL, profile_.GetPrefs(), false); | 21 manager_.Init(NULL, profile_.GetPrefs(), false); |
23 manager_.set_timezone_country_code("KR"); | 22 manager_.set_timezone_country_code("KR"); |
24 model_.reset(new CountryComboboxModel()); | 23 model_.reset(new CountryComboboxModel()); |
25 model_->SetCountries(manager_, base::Callback<bool(const std::string&)>()); | 24 model_->SetCountries(manager_, base::Callback<bool(const std::string&)>()); |
(...skipping 12 matching lines...) Expand all Loading... |
38 TEST_F(CountryComboboxModelTest, DefaultCountryCode) { | 37 TEST_F(CountryComboboxModelTest, DefaultCountryCode) { |
39 std::string default_country = model()->GetDefaultCountryCode(); | 38 std::string default_country = model()->GetDefaultCountryCode(); |
40 EXPECT_EQ(manager()->GetDefaultCountryCodeForNewAddress(), default_country); | 39 EXPECT_EQ(manager()->GetDefaultCountryCodeForNewAddress(), default_country); |
41 | 40 |
42 AutofillCountry country(default_country, | 41 AutofillCountry country(default_country, |
43 g_browser_process->GetApplicationLocale()); | 42 g_browser_process->GetApplicationLocale()); |
44 EXPECT_EQ(country.name(), model()->GetItemAt(0)); | 43 EXPECT_EQ(country.name(), model()->GetItemAt(0)); |
45 } | 44 } |
46 | 45 |
47 TEST_F(CountryComboboxModelTest, AllCountriesHaveComponents) { | 46 TEST_F(CountryComboboxModelTest, AllCountriesHaveComponents) { |
48 ::i18n::addressinput::Localization localization; | |
49 std::string unused; | |
50 for (int i = 0; i < model()->GetItemCount(); ++i) { | 47 for (int i = 0; i < model()->GetItemCount(); ++i) { |
51 if (model()->IsItemSeparatorAt(i)) | 48 if (model()->IsItemSeparatorAt(i)) |
52 continue; | 49 continue; |
53 | 50 |
54 std::string country_code = model()->countries()[i]->country_code(); | 51 std::string country_code = model()->countries()[i]->country_code(); |
55 std::vector< ::i18n::addressinput::AddressUiComponent> components = | 52 std::vector< ::i18n::addressinput::AddressUiComponent> components = |
56 ::i18n::addressinput::BuildComponents( | 53 ::i18n::addressinput::BuildComponents( |
57 country_code, localization, std::string(), &unused); | 54 country_code, std::string(), NULL); |
58 EXPECT_FALSE(components.empty()); | 55 EXPECT_FALSE(components.empty()); |
59 } | 56 } |
60 } | 57 } |
61 | 58 |
62 } // namespace autofill | 59 } // namespace autofill |
OLD | NEW |