| 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 using base::ASCIIToUTF16; | 15 using base::ASCIIToUTF16; |
| 15 | 16 |
| 16 namespace autofill { | 17 namespace autofill { |
| 17 | 18 |
| 18 namespace { | 19 namespace { |
| 19 | 20 |
| 20 class TestAccountChooserModel : public AccountChooserModel { | 21 class TestAccountChooserModel : public AccountChooserModel { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 46 class AccountChooserModelTest : public testing::Test { | 47 class AccountChooserModelTest : public testing::Test { |
| 47 public: | 48 public: |
| 48 AccountChooserModelTest() : model_(&delegate_, &profile_, false) {} | 49 AccountChooserModelTest() : model_(&delegate_, &profile_, false) {} |
| 49 virtual ~AccountChooserModelTest() {} | 50 virtual ~AccountChooserModelTest() {} |
| 50 | 51 |
| 51 TestingProfile* profile() { return &profile_; } | 52 TestingProfile* profile() { return &profile_; } |
| 52 MockAccountChooserModelDelegate* delegate() { return &delegate_; } | 53 MockAccountChooserModelDelegate* delegate() { return &delegate_; } |
| 53 TestAccountChooserModel* model() { return &model_; } | 54 TestAccountChooserModel* model() { return &model_; } |
| 54 | 55 |
| 55 private: | 56 private: |
| 57 content::TestBrowserThreadBundle thread_bundle_; |
| 56 TestingProfile profile_; | 58 TestingProfile profile_; |
| 57 testing::NiceMock<MockAccountChooserModelDelegate> delegate_; | 59 testing::NiceMock<MockAccountChooserModelDelegate> delegate_; |
| 58 TestAccountChooserModel model_; | 60 TestAccountChooserModel model_; |
| 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. |
| 65 { | 67 { |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 EXPECT_EQ(ASCIIToUTF16(accounts[1]), model()->GetActiveWalletAccountName()); | 204 EXPECT_EQ(ASCIIToUTF16(accounts[1]), model()->GetActiveWalletAccountName()); |
| 203 | 205 |
| 204 // Setting the wallet accounts forces the switch to wallet. | 206 // Setting the wallet accounts forces the switch to wallet. |
| 205 model()->ExecuteCommand(TestAccountChooserModel::kAutofillItemId, 0); | 207 model()->ExecuteCommand(TestAccountChooserModel::kAutofillItemId, 0); |
| 206 EXPECT_FALSE(model()->WalletIsSelected()); | 208 EXPECT_FALSE(model()->WalletIsSelected()); |
| 207 model()->SetWalletAccounts(accounts, 1U); | 209 model()->SetWalletAccounts(accounts, 1U); |
| 208 EXPECT_TRUE(model()->WalletIsSelected()); | 210 EXPECT_TRUE(model()->WalletIsSelected()); |
| 209 } | 211 } |
| 210 | 212 |
| 211 } // namespace autofill | 213 } // namespace autofill |
| OLD | NEW |