| 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" |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 // When the |disable_wallet| argument is true, use Autofill regardless | 88 // When the |disable_wallet| argument is true, use Autofill regardless |
| 89 // of the pref. | 89 // of the pref. |
| 90 { | 90 { |
| 91 profile()->GetPrefs()->SetBoolean( | 91 profile()->GetPrefs()->SetBoolean( |
| 92 ::prefs::kAutofillDialogPayWithoutWallet, false); | 92 ::prefs::kAutofillDialogPayWithoutWallet, false); |
| 93 TestAccountChooserModel model(delegate(), profile(), true, metric_logger()); | 93 TestAccountChooserModel model(delegate(), profile(), true, metric_logger()); |
| 94 EXPECT_FALSE(model.WalletIsSelected()); | 94 EXPECT_FALSE(model.WalletIsSelected()); |
| 95 } | 95 } |
| 96 // In incognito, use local data regardless of the pref. | 96 // In incognito, use local data regardless of the pref. |
| 97 { | 97 { |
| 98 TestingProfile::Builder builder; | 98 Profile* incognito = profile()->GetOffTheRecordProfile(); |
| 99 builder.SetIncognito(); | |
| 100 scoped_ptr<TestingProfile> incognito = builder.Build(); | |
| 101 incognito->SetOriginalProfile(profile()); | |
| 102 profile()->GetPrefs()->SetBoolean( | 99 profile()->GetPrefs()->SetBoolean( |
| 103 ::prefs::kAutofillDialogPayWithoutWallet, false); | 100 ::prefs::kAutofillDialogPayWithoutWallet, false); |
| 104 incognito->GetPrefs()->SetBoolean( | 101 incognito->GetPrefs()->SetBoolean( |
| 105 ::prefs::kAutofillDialogPayWithoutWallet, false); | 102 ::prefs::kAutofillDialogPayWithoutWallet, false); |
| 106 | 103 |
| 107 TestAccountChooserModel model(delegate(), | 104 TestAccountChooserModel model( |
| 108 incognito.get(), | 105 delegate(), incognito, false, metric_logger()); |
| 109 false, | |
| 110 metric_logger()); | |
| 111 EXPECT_FALSE(model.WalletIsSelected()); | 106 EXPECT_FALSE(model.WalletIsSelected()); |
| 112 } | 107 } |
| 113 } | 108 } |
| 114 | 109 |
| 115 TEST_F(AccountChooserModelTest, IgnoresPrefChanges) { | 110 TEST_F(AccountChooserModelTest, IgnoresPrefChanges) { |
| 116 ASSERT_FALSE(profile()->GetPrefs()->GetBoolean( | 111 ASSERT_FALSE(profile()->GetPrefs()->GetBoolean( |
| 117 ::prefs::kAutofillDialogPayWithoutWallet)); | 112 ::prefs::kAutofillDialogPayWithoutWallet)); |
| 118 EXPECT_TRUE(model()->WalletIsSelected()); | 113 EXPECT_TRUE(model()->WalletIsSelected()); |
| 119 | 114 |
| 120 // Check that nothing changes while this dialog is running if a pref changes | 115 // Check that nothing changes while this dialog is running if a pref changes |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 EXPECT_EQ(ASCIIToUTF16(accounts[1]), model()->GetActiveWalletAccountName()); | 213 EXPECT_EQ(ASCIIToUTF16(accounts[1]), model()->GetActiveWalletAccountName()); |
| 219 | 214 |
| 220 // Setting the wallet accounts forces the switch to wallet. | 215 // Setting the wallet accounts forces the switch to wallet. |
| 221 model()->ExecuteCommand(TestAccountChooserModel::kAutofillItemId, 0); | 216 model()->ExecuteCommand(TestAccountChooserModel::kAutofillItemId, 0); |
| 222 EXPECT_FALSE(model()->WalletIsSelected()); | 217 EXPECT_FALSE(model()->WalletIsSelected()); |
| 223 model()->SetWalletAccounts(accounts, 1U); | 218 model()->SetWalletAccounts(accounts, 1U); |
| 224 EXPECT_TRUE(model()->WalletIsSelected()); | 219 EXPECT_TRUE(model()->WalletIsSelected()); |
| 225 } | 220 } |
| 226 | 221 |
| 227 } // namespace autofill | 222 } // namespace autofill |
| OLD | NEW |