| 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 } | 122 } |
| 123 | 123 |
| 124 void SetUp() override { | 124 void SetUp() override { |
| 125 ASSERT_TRUE(db_thread_.Start()); | 125 ASSERT_TRUE(db_thread_.Start()); |
| 126 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 126 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 127 | 127 |
| 128 profile_.reset(new TestingProfile()); | 128 profile_.reset(new TestingProfile()); |
| 129 | 129 |
| 130 base::FilePath path = temp_dir_.path().AppendASCII("web_data_test"); | 130 base::FilePath path = temp_dir_.path().AppendASCII("web_data_test"); |
| 131 wdbs_ = new WebDatabaseService( | 131 wdbs_ = new WebDatabaseService( |
| 132 path, BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), | 132 path, BrowserThread::GetTaskRunnerForThread(BrowserThread::UI), |
| 133 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB)); | 133 BrowserThread::GetTaskRunnerForThread(BrowserThread::DB)); |
| 134 // Need to add at least one table so the database gets created. | 134 // Need to add at least one table so the database gets created. |
| 135 wdbs_->AddTable(std::unique_ptr<WebDatabaseTable>(new LoginsTable())); | 135 wdbs_->AddTable(std::unique_ptr<WebDatabaseTable>(new LoginsTable())); |
| 136 wdbs_->LoadDatabase(); | 136 wdbs_->LoadDatabase(); |
| 137 wds_ = new PasswordWebDataService( | 137 wds_ = new PasswordWebDataService( |
| 138 wdbs_, BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), | 138 wdbs_, BrowserThread::GetTaskRunnerForThread(BrowserThread::UI), |
| 139 WebDataServiceBase::ProfileErrorCallback()); | 139 WebDataServiceBase::ProfileErrorCallback()); |
| 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 if (wds_) { | 146 if (wds_) { |
| 147 wds_->ShutdownOnUIThread(); | 147 wds_->ShutdownOnUIThread(); |
| 148 wds_ = nullptr; | 148 wds_ = nullptr; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 163 db_thread_.Stop(); | 163 db_thread_.Stop(); |
| 164 } | 164 } |
| 165 | 165 |
| 166 base::FilePath test_login_db_file_path() const { | 166 base::FilePath test_login_db_file_path() const { |
| 167 return temp_dir_.path().Append(FILE_PATH_LITERAL("login_test")); | 167 return temp_dir_.path().Append(FILE_PATH_LITERAL("login_test")); |
| 168 } | 168 } |
| 169 | 169 |
| 170 PasswordStoreWin* CreatePasswordStore() { | 170 PasswordStoreWin* CreatePasswordStore() { |
| 171 return new PasswordStoreWin( | 171 return new PasswordStoreWin( |
| 172 base::ThreadTaskRunnerHandle::Get(), | 172 base::ThreadTaskRunnerHandle::Get(), |
| 173 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB), | 173 BrowserThread::GetTaskRunnerForThread(BrowserThread::DB), |
| 174 base::WrapUnique(new LoginDatabase(test_login_db_file_path())), | 174 base::WrapUnique(new LoginDatabase(test_login_db_file_path())), |
| 175 wds_.get()); | 175 wds_.get()); |
| 176 } | 176 } |
| 177 | 177 |
| 178 base::MessageLoopForUI message_loop_; | 178 base::MessageLoopForUI message_loop_; |
| 179 content::TestBrowserThread ui_thread_; | 179 content::TestBrowserThread ui_thread_; |
| 180 // PasswordStore, WDS schedule work on this thread. | 180 // PasswordStore, WDS schedule work on this thread. |
| 181 content::TestBrowserThread db_thread_; | 181 content::TestBrowserThread db_thread_; |
| 182 | 182 |
| 183 base::ScopedTempDir temp_dir_; | 183 base::ScopedTempDir temp_dir_; |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 | 452 |
| 453 // Make sure we quit the MessageLoop even if the test fails. | 453 // Make sure we quit the MessageLoop even if the test fails. |
| 454 ON_CALL(consumer, OnGetPasswordStoreResultsConstRef(_)) | 454 ON_CALL(consumer, OnGetPasswordStoreResultsConstRef(_)) |
| 455 .WillByDefault(QuitUIMessageLoop()); | 455 .WillByDefault(QuitUIMessageLoop()); |
| 456 | 456 |
| 457 EXPECT_CALL(consumer, OnGetPasswordStoreResultsConstRef(IsEmpty())); | 457 EXPECT_CALL(consumer, OnGetPasswordStoreResultsConstRef(IsEmpty())); |
| 458 | 458 |
| 459 store_->GetAutofillableLogins(&consumer); | 459 store_->GetAutofillableLogins(&consumer); |
| 460 base::MessageLoop::current()->Run(); | 460 base::MessageLoop::current()->Run(); |
| 461 } | 461 } |
| OLD | NEW |