rAc: hide countries with no address components.
[chromium-blink-merge.git] / chrome / browser / ui / autofill / country_combobox_model_unittest.cc
blobe8574d4b63a91c246cfe474417d52abd9650b08e
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 "components/autofill/core/browser/autofill_country.h"
8 #include "components/autofill/core/browser/test_personal_data_manager.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/address_ui.h"
11 #include "third_party/libaddressinput/chromium/cpp/include/libaddressinput/address_ui_component.h"
13 namespace autofill {
15 namespace {
16 const char kTestCountry[] = "AQ";
19 TEST(CountryComboboxModel, RespectsManagerDefaultCountry) {
20 TestPersonalDataManager manager;
21 manager.set_timezone_country_code(kTestCountry);
23 CountryComboboxModel model(manager);
24 EXPECT_EQ(kTestCountry, model.GetDefaultCountryCode());
27 TEST(CountryComboboxModel, AllCountriesHaveComponents) {
28 TestPersonalDataManager manager;
29 CountryComboboxModel model(manager);
31 for (int i = 0; i < model.GetItemCount(); ++i) {
32 if (model.IsItemSeparatorAt(i))
33 continue;
35 std::string country_code = model.countries()[i]->country_code();
36 std::vector< ::i18n::addressinput::AddressUiComponent> components =
37 ::i18n::addressinput::BuildComponents(country_code);
38 EXPECT_FALSE(components.empty());
42 } // namespace autofill