| 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/browser/signin/account_tracker_service_factory.h" | 9 #include "chrome/browser/signin/account_tracker_service_factory.h" |
| 10 #include "chrome/test/base/testing_profile.h" | 10 #include "chrome/test/base/testing_profile.h" |
| 11 #include "components/autofill/core/browser/autofill_country.h" | 11 #include "components/autofill/core/browser/autofill_country.h" |
| 12 #include "components/autofill/core/browser/test_personal_data_manager.h" | 12 #include "components/autofill/core/browser/test_personal_data_manager.h" |
| 13 #include "components/signin/core/browser/account_tracker_service.h" | 13 #include "components/signin/core/browser/account_tracker_service.h" |
| 14 #include "content/public/test/test_browser_thread_bundle.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 15 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_ui
.h" | 16 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_ui
.h" |
| 16 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_ui
_component.h" | 17 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_ui
_component.h" |
| 17 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/localizati
on.h" | 18 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/localizati
on.h" |
| 18 | 19 |
| 19 namespace autofill { | 20 namespace autofill { |
| 20 | 21 |
| 21 class CountryComboboxModelTest : public testing::Test { | 22 class CountryComboboxModelTest : public testing::Test { |
| 22 public: | 23 public: |
| 23 CountryComboboxModelTest() { | 24 CountryComboboxModelTest() { |
| 24 manager_.Init( | 25 manager_.Init( |
| 25 NULL, profile_.GetPrefs(), | 26 NULL, profile_.GetPrefs(), |
| 26 AccountTrackerServiceFactory::GetForProfile(&profile_), false); | 27 AccountTrackerServiceFactory::GetForProfile(&profile_), false); |
| 27 manager_.set_timezone_country_code("KR"); | 28 manager_.set_timezone_country_code("KR"); |
| 28 model_.reset(new CountryComboboxModel()); | 29 model_.reset(new CountryComboboxModel()); |
| 29 model_->SetCountries(manager_, base::Callback<bool(const std::string&)>()); | 30 model_->SetCountries(manager_, base::Callback<bool(const std::string&)>()); |
| 30 } | 31 } |
| 31 | 32 |
| 32 TestPersonalDataManager* manager() { return &manager_; } | 33 TestPersonalDataManager* manager() { return &manager_; } |
| 33 CountryComboboxModel* model() { return model_.get(); } | 34 CountryComboboxModel* model() { return model_.get(); } |
| 34 | 35 |
| 35 private: | 36 private: |
| 36 // NB: order is important here - |profile_| must go down after |manager_|. | 37 // NB: order is important here - |profile_| must go down after |manager_|. |
| 38 content::TestBrowserThreadBundle thread_bundle_; |
| 37 TestingProfile profile_; | 39 TestingProfile profile_; |
| 38 TestPersonalDataManager manager_; | 40 TestPersonalDataManager manager_; |
| 39 scoped_ptr<CountryComboboxModel> model_; | 41 scoped_ptr<CountryComboboxModel> model_; |
| 40 }; | 42 }; |
| 41 | 43 |
| 42 TEST_F(CountryComboboxModelTest, DefaultCountryCode) { | 44 TEST_F(CountryComboboxModelTest, DefaultCountryCode) { |
| 43 std::string default_country = model()->GetDefaultCountryCode(); | 45 std::string default_country = model()->GetDefaultCountryCode(); |
| 44 EXPECT_EQ(manager()->GetDefaultCountryCodeForNewAddress(), default_country); | 46 EXPECT_EQ(manager()->GetDefaultCountryCodeForNewAddress(), default_country); |
| 45 | 47 |
| 46 AutofillCountry country(default_country, | 48 AutofillCountry country(default_country, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 57 | 59 |
| 58 std::string country_code = model()->countries()[i]->country_code(); | 60 std::string country_code = model()->countries()[i]->country_code(); |
| 59 std::vector< ::i18n::addressinput::AddressUiComponent> components = | 61 std::vector< ::i18n::addressinput::AddressUiComponent> components = |
| 60 ::i18n::addressinput::BuildComponents( | 62 ::i18n::addressinput::BuildComponents( |
| 61 country_code, localization, std::string(), &unused); | 63 country_code, localization, std::string(), &unused); |
| 62 EXPECT_FALSE(components.empty()); | 64 EXPECT_FALSE(components.empty()); |
| 63 } | 65 } |
| 64 } | 66 } |
| 65 | 67 |
| 66 } // namespace autofill | 68 } // namespace autofill |
| OLD | NEW |