| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_win.h" | 5 #include "chrome/browser/password_manager/password_store_win.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 wds_->Init(); | 140 wds_->Init(); |
| 141 } | 141 } |
| 142 | 142 |
| 143 void TearDown() override { | 143 void TearDown() override { |
| 144 if (store_.get()) | 144 if (store_.get()) |
| 145 store_->ShutdownOnUIThread(); | 145 store_->ShutdownOnUIThread(); |
| 146 wds_->ShutdownOnUIThread(); | 146 wds_->ShutdownOnUIThread(); |
| 147 wdbs_->ShutdownDatabase(); | 147 wdbs_->ShutdownDatabase(); |
| 148 wds_ = nullptr; | 148 wds_ = nullptr; |
| 149 wdbs_ = nullptr; | 149 wdbs_ = nullptr; |
| 150 base::WaitableEvent done(false, false); | 150 base::WaitableEvent done(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 151 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 151 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, | 152 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, |
| 152 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&done))); | 153 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&done))); |
| 153 done.Wait(); | 154 done.Wait(); |
| 154 base::ThreadTaskRunnerHandle::Get()->PostTask( | 155 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 155 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); | 156 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); |
| 156 base::MessageLoop::current()->Run(); | 157 base::MessageLoop::current()->Run(); |
| 157 db_thread_.Stop(); | 158 db_thread_.Stop(); |
| 158 } | 159 } |
| 159 | 160 |
| 160 base::FilePath test_login_db_file_path() const { | 161 base::FilePath test_login_db_file_path() const { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 &password_info)); | 204 &password_info)); |
| 204 // Verify the URL hash | 205 // Verify the URL hash |
| 205 ASSERT_EQ(L"39471418FF5453FEEB3731E382DEB5D53E14FAF9B5", | 206 ASSERT_EQ(L"39471418FF5453FEEB3731E382DEB5D53E14FAF9B5", |
| 206 password_info.url_hash); | 207 password_info.url_hash); |
| 207 | 208 |
| 208 // This IE7 password will be retrieved by the GetLogins call. | 209 // This IE7 password will be retrieved by the GetLogins call. |
| 209 wds_->AddIE7Login(password_info); | 210 wds_->AddIE7Login(password_info); |
| 210 | 211 |
| 211 // The WDS schedules tasks to run on the DB thread so we schedule yet another | 212 // The WDS schedules tasks to run on the DB thread so we schedule yet another |
| 212 // task to notify us that it's safe to carry on with the test. | 213 // task to notify us that it's safe to carry on with the test. |
| 213 WaitableEvent done(false, false); | 214 WaitableEvent done(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 215 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 214 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, | 216 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, |
| 215 base::Bind(&WaitableEvent::Signal, base::Unretained(&done))); | 217 base::Bind(&WaitableEvent::Signal, base::Unretained(&done))); |
| 216 done.Wait(); | 218 done.Wait(); |
| 217 | 219 |
| 218 store_ = CreatePasswordStore(); | 220 store_ = CreatePasswordStore(); |
| 219 EXPECT_TRUE(store_->Init(syncer::SyncableService::StartSyncFlare())); | 221 EXPECT_TRUE(store_->Init(syncer::SyncableService::StartSyncFlare())); |
| 220 | 222 |
| 221 MockPasswordStoreConsumer consumer; | 223 MockPasswordStoreConsumer consumer; |
| 222 | 224 |
| 223 // Make sure we quit the MessageLoop even if the test fails. | 225 // Make sure we quit the MessageLoop even if the test fails. |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 // Hangs flakily, see http://crbug.com/43836. | 302 // Hangs flakily, see http://crbug.com/43836. |
| 301 TEST_F(PasswordStoreWinTest, DISABLED_MultipleWDSQueriesOnDifferentThreads) { | 303 TEST_F(PasswordStoreWinTest, DISABLED_MultipleWDSQueriesOnDifferentThreads) { |
| 302 IE7PasswordInfo password_info; | 304 IE7PasswordInfo password_info; |
| 303 ASSERT_TRUE(CreateIE7PasswordInfo(L"http://example.com/origin", | 305 ASSERT_TRUE(CreateIE7PasswordInfo(L"http://example.com/origin", |
| 304 base::Time::FromDoubleT(1), | 306 base::Time::FromDoubleT(1), |
| 305 &password_info)); | 307 &password_info)); |
| 306 wds_->AddIE7Login(password_info); | 308 wds_->AddIE7Login(password_info); |
| 307 | 309 |
| 308 // The WDS schedules tasks to run on the DB thread so we schedule yet another | 310 // The WDS schedules tasks to run on the DB thread so we schedule yet another |
| 309 // task to notify us that it's safe to carry on with the test. | 311 // task to notify us that it's safe to carry on with the test. |
| 310 WaitableEvent done(false, false); | 312 WaitableEvent done(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 313 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 311 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, | 314 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, |
| 312 base::Bind(&WaitableEvent::Signal, base::Unretained(&done))); | 315 base::Bind(&WaitableEvent::Signal, base::Unretained(&done))); |
| 313 done.Wait(); | 316 done.Wait(); |
| 314 | 317 |
| 315 store_ = CreatePasswordStore(); | 318 store_ = CreatePasswordStore(); |
| 316 EXPECT_TRUE(store_->Init(syncer::SyncableService::StartSyncFlare())); | 319 EXPECT_TRUE(store_->Init(syncer::SyncableService::StartSyncFlare())); |
| 317 | 320 |
| 318 MockPasswordStoreConsumer password_consumer; | 321 MockPasswordStoreConsumer password_consumer; |
| 319 // Make sure we quit the MessageLoop even if the test fails. | 322 // Make sure we quit the MessageLoop even if the test fails. |
| 320 ON_CALL(password_consumer, OnGetPasswordStoreResultsConstRef(_)) | 323 ON_CALL(password_consumer, OnGetPasswordStoreResultsConstRef(_)) |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 | 430 |
| 428 // Make sure we quit the MessageLoop even if the test fails. | 431 // Make sure we quit the MessageLoop even if the test fails. |
| 429 ON_CALL(consumer, OnGetPasswordStoreResultsConstRef(_)) | 432 ON_CALL(consumer, OnGetPasswordStoreResultsConstRef(_)) |
| 430 .WillByDefault(QuitUIMessageLoop()); | 433 .WillByDefault(QuitUIMessageLoop()); |
| 431 | 434 |
| 432 EXPECT_CALL(consumer, OnGetPasswordStoreResultsConstRef(IsEmpty())); | 435 EXPECT_CALL(consumer, OnGetPasswordStoreResultsConstRef(IsEmpty())); |
| 433 | 436 |
| 434 store_->GetAutofillableLogins(&consumer); | 437 store_->GetAutofillableLogins(&consumer); |
| 435 base::MessageLoop::current()->Run(); | 438 base::MessageLoop::current()->Run(); |
| 436 } | 439 } |
| OLD | NEW |