OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/prefs/pref_service.h" | 5 #include "base/prefs/pref_service.h" |
6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
7 #include "chrome/browser/ui/autofill/account_chooser_model.h" | 7 #include "chrome/browser/ui/autofill/account_chooser_model.h" |
8 #include "chrome/common/pref_names.h" | 8 #include "chrome/common/pref_names.h" |
9 #include "chrome/test/base/testing_profile.h" | 9 #include "chrome/test/base/testing_profile.h" |
10 #include "components/autofill/core/browser/autofill_metrics.h" | 10 #include "components/autofill/core/browser/autofill_metrics.h" |
| 11 #include "content/public/test/test_browser_thread_bundle.h" |
11 #include "testing/gmock/include/gmock/gmock.h" | 12 #include "testing/gmock/include/gmock/gmock.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
13 | 14 |
14 namespace autofill { | 15 namespace autofill { |
15 | 16 |
16 namespace { | 17 namespace { |
17 | 18 |
18 class TestAccountChooserModel : public AccountChooserModel { | 19 class TestAccountChooserModel : public AccountChooserModel { |
19 public: | 20 public: |
20 TestAccountChooserModel(AccountChooserModelDelegate* delegate, | 21 TestAccountChooserModel(AccountChooserModelDelegate* delegate, |
(...skipping 24 matching lines...) Expand all Loading... |
45 AccountChooserModelTest() | 46 AccountChooserModelTest() |
46 : model_(&delegate_, profile_.GetPrefs(), metric_logger_) {} | 47 : model_(&delegate_, profile_.GetPrefs(), metric_logger_) {} |
47 virtual ~AccountChooserModelTest() {} | 48 virtual ~AccountChooserModelTest() {} |
48 | 49 |
49 Profile* profile() { return &profile_; } | 50 Profile* profile() { return &profile_; } |
50 MockAccountChooserModelDelegate* delegate() { return &delegate_; } | 51 MockAccountChooserModelDelegate* delegate() { return &delegate_; } |
51 TestAccountChooserModel* model() { return &model_; } | 52 TestAccountChooserModel* model() { return &model_; } |
52 const AutofillMetrics& metric_logger() { return metric_logger_; } | 53 const AutofillMetrics& metric_logger() { return metric_logger_; } |
53 | 54 |
54 private: | 55 private: |
| 56 content::TestBrowserThreadBundle thread_bundle_; |
55 TestingProfile profile_; | 57 TestingProfile profile_; |
56 MockAccountChooserModelDelegate delegate_; | 58 MockAccountChooserModelDelegate delegate_; |
57 TestAccountChooserModel model_; | 59 TestAccountChooserModel model_; |
58 AutofillMetrics metric_logger_; | 60 AutofillMetrics metric_logger_; |
59 }; | 61 }; |
60 | 62 |
61 } // namespace | 63 } // namespace |
62 | 64 |
63 TEST_F(AccountChooserModelTest, ObeysPref) { | 65 TEST_F(AccountChooserModelTest, ObeysPref) { |
64 // When "Pay without wallet" is false, use Wallet by default. | 66 // When "Pay without wallet" is false, use Wallet by default. |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 EXPECT_CALL(*delegate(), AccountChoiceChanged()).Times(2); | 151 EXPECT_CALL(*delegate(), AccountChoiceChanged()).Times(2); |
150 | 152 |
151 model()->ExecuteCommand(TestAccountChooserModel::kAutofillItemId, 0); | 153 model()->ExecuteCommand(TestAccountChooserModel::kAutofillItemId, 0); |
152 EXPECT_FALSE(model()->WalletIsSelected()); | 154 EXPECT_FALSE(model()->WalletIsSelected()); |
153 | 155 |
154 model()->ExecuteCommand(TestAccountChooserModel::kActiveWalletItemId, 0); | 156 model()->ExecuteCommand(TestAccountChooserModel::kActiveWalletItemId, 0); |
155 EXPECT_TRUE(model()->WalletIsSelected()); | 157 EXPECT_TRUE(model()->WalletIsSelected()); |
156 } | 158 } |
157 | 159 |
158 } // namespace autofill | 160 } // namespace autofill |
OLD | NEW |