OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #include "chrome/browser/ui/autofill/country_combobox_model.h" |
| 6 |
| 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 |
| 11 namespace autofill { |
| 12 |
| 13 TEST(CountryComboboxModel, SelectIndexes) { |
| 14 TestPersonalDataManager manager; |
| 15 CountryComboboxModel model(manager); |
| 16 EXPECT_TRUE(model.IsDefaultIndexSelected()); |
| 17 |
| 18 const std::string default_country = model.GetSelectedCountryCode(); |
| 19 |
| 20 model.SelectIndex(5); |
| 21 EXPECT_NE(default_country, model.GetSelectedCountryCode()); |
| 22 EXPECT_FALSE(model.IsDefaultIndexSelected()); |
| 23 |
| 24 model.SelectDefaultIndex(); |
| 25 EXPECT_EQ(default_country, model.GetSelectedCountryCode()); |
| 26 EXPECT_TRUE(model.IsDefaultIndexSelected()); |
| 27 } |
| 28 |
| 29 TEST(CountryComboboxModel, SelectCountry) { |
| 30 TestPersonalDataManager manager; |
| 31 CountryComboboxModel model(manager); |
| 32 |
| 33 EXPECT_NE("AQ", model.GetSelectedCountryCode()); |
| 34 model.SelectCountry("AQ"); |
| 35 EXPECT_EQ("AQ", model.GetSelectedCountryCode()); |
| 36 } |
| 37 |
| 38 TEST(CountryComboboxModel, DefaultCountry) { |
| 39 TestPersonalDataManager manager; |
| 40 ASSERT_NE("AQ", manager.GetDefaultCountryCodeForNewAddress()); |
| 41 manager.set_default_country_code("AQ"); |
| 42 |
| 43 CountryComboboxModel model(manager); |
| 44 EXPECT_EQ("AQ", model.countries()[model.GetDefaultIndex()]->country_code()); |
| 45 EXPECT_EQ("AQ", model.GetSelectedCountryCode()); |
| 46 } |
| 47 |
| 48 } // namespace autofill |
OLD | NEW |