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/gmock/include/gmock/gmock.h" |
| 10 #include "testing/gmock_mutant.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "ui/base/models/combobox_model_observer.h" |
| 13 |
| 14 namespace autofill { |
| 15 |
| 16 namespace { |
| 17 |
| 18 const char kTestCountry[] = "AQ"; |
| 19 |
| 20 class MockObserver : public ui::ComboboxModelObserver { |
| 21 public: |
| 22 MOCK_METHOD1(OnComboboxModelChanged, void(ui::ComboboxModel* model)); |
| 23 }; |
| 24 |
| 25 } // namespace |
| 26 |
| 27 TEST(CountryComboboxModel, SetAndResetDefaultCountry) { |
| 28 TestPersonalDataManager manager; |
| 29 CountryComboboxModel model(manager); |
| 30 |
| 31 MockObserver observer; |
| 32 model.AddObserver(&observer); |
| 33 EXPECT_CALL(observer, OnComboboxModelChanged(&model)).Times(2); |
| 34 |
| 35 std::string default_country = model.GetDefaultCountryCode(); |
| 36 ASSERT_NE(default_country, kTestCountry); |
| 37 |
| 38 model.SetDefaultCountry(kTestCountry); |
| 39 EXPECT_EQ(kTestCountry, model.GetDefaultCountryCode()); |
| 40 |
| 41 model.ResetDefault(); |
| 42 EXPECT_EQ(default_country, model.GetDefaultCountryCode()); |
| 43 } |
| 44 |
| 45 TEST(CountryComboboxModel, RespectsManagerDefaultCountry) { |
| 46 TestPersonalDataManager manager; |
| 47 manager.set_timezone_country_code(kTestCountry); |
| 48 |
| 49 CountryComboboxModel model(manager); |
| 50 EXPECT_EQ(kTestCountry, model.GetDefaultCountryCode()); |
| 51 } |
| 52 |
| 53 } // namespace autofill |
OLD | NEW |