BookmarkManager: Fix 'new folder text field size changes on clicking it' issue.
[chromium-blink-merge.git] / chrome / browser / ui / autofill / country_combobox_model_unittest.cc
blob8c0d88e536668dfc95aa52692626df7da76df49a
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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/autofill/country_combobox_model.h"
7 #include "base/memory/scoped_ptr.h"
8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/signin/account_tracker_service_factory.h"
10 #include "chrome/test/base/testing_profile.h"
11 #include "components/autofill/core/browser/autofill_country.h"
12 #include "components/autofill/core/browser/test_personal_data_manager.h"
13 #include "components/signin/core/browser/account_tracker_service.h"
14 #include "content/public/test/test_browser_thread_bundle.h"
15 #include "testing/gtest/include/gtest/gtest.h"
16 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_ui.h"
17 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_ui_component.h"
18 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/localization.h"
20 namespace autofill {
22 class CountryComboboxModelTest : public testing::Test {
23 public:
24 CountryComboboxModelTest() {
25 manager_.Init(
26 NULL, profile_.GetPrefs(),
27 AccountTrackerServiceFactory::GetForProfile(&profile_), false);
28 manager_.set_timezone_country_code("KR");
29 model_.reset(new CountryComboboxModel());
30 model_->SetCountries(manager_, base::Callback<bool(const std::string&)>());
33 TestPersonalDataManager* manager() { return &manager_; }
34 CountryComboboxModel* model() { return model_.get(); }
36 private:
37 // NB: order is important here - |profile_| must go down after |manager_|.
38 content::TestBrowserThreadBundle thread_bundle_;
39 TestingProfile profile_;
40 TestPersonalDataManager manager_;
41 scoped_ptr<CountryComboboxModel> model_;
44 TEST_F(CountryComboboxModelTest, DefaultCountryCode) {
45 std::string default_country = model()->GetDefaultCountryCode();
46 EXPECT_EQ(manager()->GetDefaultCountryCodeForNewAddress(), default_country);
48 AutofillCountry country(default_country,
49 g_browser_process->GetApplicationLocale());
50 EXPECT_EQ(country.name(), model()->GetItemAt(0));
53 TEST_F(CountryComboboxModelTest, AllCountriesHaveComponents) {
54 ::i18n::addressinput::Localization localization;
55 std::string unused;
56 for (int i = 0; i < model()->GetItemCount(); ++i) {
57 if (model()->IsItemSeparatorAt(i))
58 continue;
60 std::string country_code = model()->countries()[i]->country_code();
61 std::vector< ::i18n::addressinput::AddressUiComponent> components =
62 ::i18n::addressinput::BuildComponents(
63 country_code, localization, std::string(), &unused);
64 EXPECT_FALSE(components.empty());
68 } // namespace autofill