Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / ui / autofill / country_combobox_model_unittest.cc
blobc243d8e9b277f6d9eb2944575dc7bee40fcd8711
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/test/base/testing_profile.h"
10 #include "components/autofill/core/browser/autofill_country.h"
11 #include "components/autofill/core/browser/test_personal_data_manager.h"
12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_ui.h"
14 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_ui_component.h"
15 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/localization.h"
17 namespace autofill {
19 class CountryComboboxModelTest : public testing::Test {
20 public:
21 CountryComboboxModelTest() {
22 manager_.Init(NULL, profile_.GetPrefs(), false);
23 manager_.set_timezone_country_code("KR");
24 model_.reset(new CountryComboboxModel());
25 model_->SetCountries(manager_, base::Callback<bool(const std::string&)>());
28 TestPersonalDataManager* manager() { return &manager_; }
29 CountryComboboxModel* model() { return model_.get(); }
31 private:
32 // NB: order is important here - |profile_| must go down after |manager_|.
33 TestingProfile profile_;
34 TestPersonalDataManager manager_;
35 scoped_ptr<CountryComboboxModel> model_;
38 TEST_F(CountryComboboxModelTest, DefaultCountryCode) {
39 std::string default_country = model()->GetDefaultCountryCode();
40 EXPECT_EQ(manager()->GetDefaultCountryCodeForNewAddress(), default_country);
42 AutofillCountry country(default_country,
43 g_browser_process->GetApplicationLocale());
44 EXPECT_EQ(country.name(), model()->GetItemAt(0));
47 TEST_F(CountryComboboxModelTest, AllCountriesHaveComponents) {
48 ::i18n::addressinput::Localization localization;
49 std::string unused;
50 for (int i = 0; i < model()->GetItemCount(); ++i) {
51 if (model()->IsItemSeparatorAt(i))
52 continue;
54 std::string country_code = model()->countries()[i]->country_code();
55 std::vector< ::i18n::addressinput::AddressUiComponent> components =
56 ::i18n::addressinput::BuildComponents(
57 country_code, localization, std::string(), &unused);
58 EXPECT_FALSE(components.empty());
62 } // namespace autofill