Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Side by Side Diff: chrome/browser/password_manager/password_store_proxy_mac_unittest.cc

Issue 2010463002: Mocker for OSCrypt (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated doc Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "chrome/browser/password_manager/password_store_proxy_mac.h" 5 #include "chrome/browser/password_manager/password_store_proxy_mac.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/scoped_observer.h" 12 #include "base/scoped_observer.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "base/test/histogram_tester.h" 14 #include "base/test/histogram_tester.h"
15 #include "chrome/browser/password_manager/password_store_mac.h" 15 #include "chrome/browser/password_manager/password_store_mac.h"
16 #include "chrome/browser/password_manager/password_store_mac_internal.h" 16 #include "chrome/browser/password_manager/password_store_mac_internal.h"
17 #include "chrome/browser/prefs/browser_prefs.h" 17 #include "chrome/browser/prefs/browser_prefs.h"
18 #include "components/os_crypt/os_crypt.h" 18 #include "components/os_crypt/os_crypt_mocker.h"
19 #include "components/password_manager/core/browser/login_database.h" 19 #include "components/password_manager/core/browser/login_database.h"
20 #include "components/password_manager/core/browser/password_manager_test_utils.h " 20 #include "components/password_manager/core/browser/password_manager_test_utils.h "
21 #include "components/password_manager/core/browser/password_store_consumer.h" 21 #include "components/password_manager/core/browser/password_store_consumer.h"
22 #include "components/password_manager/core/common/password_manager_pref_names.h" 22 #include "components/password_manager/core/common/password_manager_pref_names.h"
23 #include "components/syncable_prefs/testing_pref_service_syncable.h" 23 #include "components/syncable_prefs/testing_pref_service_syncable.h"
24 #include "content/public/browser/browser_thread.h" 24 #include "content/public/browser/browser_thread.h"
25 #include "content/public/test/test_browser_thread_bundle.h" 25 #include "content/public/test/test_browser_thread_bundle.h"
26 #include "crypto/mock_apple_keychain.h" 26 #include "crypto/mock_apple_keychain.h"
27 #include "testing/gmock/include/gmock/gmock.h" 27 #include "testing/gmock/include/gmock/gmock.h"
28 #include "testing/gtest/include/gtest/gtest.h" 28 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 syncable_prefs::TestingPrefServiceSyncable testing_prefs_; 133 syncable_prefs::TestingPrefServiceSyncable testing_prefs_;
134 }; 134 };
135 135
136 PasswordStoreProxyMacTest::PasswordStoreProxyMacTest() { 136 PasswordStoreProxyMacTest::PasswordStoreProxyMacTest() {
137 EXPECT_TRUE(db_dir_.CreateUniqueTempDir()); 137 EXPECT_TRUE(db_dir_.CreateUniqueTempDir());
138 chrome::RegisterUserProfilePrefs(testing_prefs_.registry()); 138 chrome::RegisterUserProfilePrefs(testing_prefs_.registry());
139 testing_prefs_.SetInteger(password_manager::prefs::kKeychainMigrationStatus, 139 testing_prefs_.SetInteger(password_manager::prefs::kKeychainMigrationStatus,
140 static_cast<int>(GetParam())); 140 static_cast<int>(GetParam()));
141 // Ensure that LoginDatabase will use the mock keychain if it needs to 141 // Ensure that LoginDatabase will use the mock keychain if it needs to
142 // encrypt/decrypt a password. 142 // encrypt/decrypt a password.
143 OSCrypt::UseMockKeychain(true); 143 OSCryptMocker::SetUpWithSingleton();
144 } 144 }
145 145
146 PasswordStoreProxyMacTest::~PasswordStoreProxyMacTest() { 146 PasswordStoreProxyMacTest::~PasswordStoreProxyMacTest() {
147 } 147 }
148 148
149 void PasswordStoreProxyMacTest::SetUp() { 149 void PasswordStoreProxyMacTest::SetUp() {
150 std::unique_ptr<password_manager::LoginDatabase> login_db( 150 std::unique_ptr<password_manager::LoginDatabase> login_db(
151 new password_manager::LoginDatabase(test_login_db_file_path())); 151 new password_manager::LoginDatabase(test_login_db_file_path()));
152 CreateAndInitPasswordStore(std::move(login_db)); 152 CreateAndInitPasswordStore(std::move(login_db));
153 } 153 }
154 154
155 void PasswordStoreProxyMacTest::TearDown() { 155 void PasswordStoreProxyMacTest::TearDown() {
156 ClosePasswordStore(); 156 ClosePasswordStore();
157 OSCryptMocker::TearDown();
157 } 158 }
158 159
159 void PasswordStoreProxyMacTest::CreateAndInitPasswordStore( 160 void PasswordStoreProxyMacTest::CreateAndInitPasswordStore(
160 std::unique_ptr<password_manager::LoginDatabase> login_db) { 161 std::unique_ptr<password_manager::LoginDatabase> login_db) {
161 store_ = new PasswordStoreProxyMac( 162 store_ = new PasswordStoreProxyMac(
162 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), 163 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
163 base::WrapUnique(new crypto::MockAppleKeychain), std::move(login_db), 164 base::WrapUnique(new crypto::MockAppleKeychain), std::move(login_db),
164 &testing_prefs_); 165 &testing_prefs_);
165 ASSERT_TRUE(store_->Init(syncer::SyncableService::StartSyncFlare())); 166 ASSERT_TRUE(store_->Init(syncer::SyncableService::StartSyncFlare()));
166 } 167 }
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 } 491 }
491 492
492 INSTANTIATE_TEST_CASE_P(, 493 INSTANTIATE_TEST_CASE_P(,
493 PasswordStoreProxyMacMigrationTest, 494 PasswordStoreProxyMacMigrationTest,
494 testing::Values(MigrationStatus::NOT_STARTED, 495 testing::Values(MigrationStatus::NOT_STARTED,
495 MigrationStatus::MIGRATED, 496 MigrationStatus::MIGRATED,
496 MigrationStatus::FAILED_ONCE, 497 MigrationStatus::FAILED_ONCE,
497 MigrationStatus::FAILED_TWICE)); 498 MigrationStatus::FAILED_TWICE));
498 499
499 } // namespace 500 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698