| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <windows.h> | 5 #include <windows.h> |
| 6 #include <wincrypt.h> | 6 #include <wincrypt.h> |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 | 162 |
| 163 // The WDS schedules tasks to run on the DB thread so we schedule yet another | 163 // The WDS schedules tasks to run on the DB thread so we schedule yet another |
| 164 // task to notify us that it's safe to carry on with the test. | 164 // task to notify us that it's safe to carry on with the test. |
| 165 WaitableEvent done(false, false); | 165 WaitableEvent done(false, false); |
| 166 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, | 166 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, |
| 167 new SignalingTask(&done)); | 167 new SignalingTask(&done)); |
| 168 done.Wait(); | 168 done.Wait(); |
| 169 | 169 |
| 170 // Prentend that the migration has already taken place. | 170 // Prentend that the migration has already taken place. |
| 171 profile_->GetPrefs()->RegisterBooleanPref(prefs::kLoginDatabaseMigrated, | 171 profile_->GetPrefs()->RegisterBooleanPref(prefs::kLoginDatabaseMigrated, |
| 172 true); | 172 true, |
| 173 PrefService::UNSYNCABLE_PREF); |
| 173 | 174 |
| 174 // Initializing the PasswordStore shouldn't trigger a migration. | 175 // Initializing the PasswordStore shouldn't trigger a migration. |
| 175 scoped_refptr<PasswordStore> store( | 176 scoped_refptr<PasswordStore> store( |
| 176 new PasswordStoreWin(login_db_.release(), profile_.get(), wds_.get())); | 177 new PasswordStoreWin(login_db_.release(), profile_.get(), wds_.get())); |
| 177 EXPECT_TRUE(store->Init()); | 178 EXPECT_TRUE(store->Init()); |
| 178 | 179 |
| 179 MockPasswordStoreConsumer consumer; | 180 MockPasswordStoreConsumer consumer; |
| 180 | 181 |
| 181 // Make sure we quit the MessageLoop even if the test fails. | 182 // Make sure we quit the MessageLoop even if the test fails. |
| 182 ON_CALL(consumer, OnPasswordStoreRequestDone(_, _)) | 183 ON_CALL(consumer, OnPasswordStoreRequestDone(_, _)) |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 MessageLoop::current()->Run(); | 222 MessageLoop::current()->Run(); |
| 222 | 223 |
| 223 STLDeleteElements(&forms); | 224 STLDeleteElements(&forms); |
| 224 | 225 |
| 225 store->Shutdown(); | 226 store->Shutdown(); |
| 226 } | 227 } |
| 227 | 228 |
| 228 TEST_F(PasswordStoreWinTest, OutstandingWDSQueries) { | 229 TEST_F(PasswordStoreWinTest, OutstandingWDSQueries) { |
| 229 // Prentend that the migration has already taken place. | 230 // Prentend that the migration has already taken place. |
| 230 profile_->GetPrefs()->RegisterBooleanPref(prefs::kLoginDatabaseMigrated, | 231 profile_->GetPrefs()->RegisterBooleanPref(prefs::kLoginDatabaseMigrated, |
| 231 true); | 232 true, |
| 233 PrefService::UNSYNCABLE_PREF); |
| 232 | 234 |
| 233 // Initializing the PasswordStore shouldn't trigger a migration. | 235 // Initializing the PasswordStore shouldn't trigger a migration. |
| 234 scoped_refptr<PasswordStore> store( | 236 scoped_refptr<PasswordStore> store( |
| 235 new PasswordStoreWin(login_db_.release(), profile_.get(), wds_.get())); | 237 new PasswordStoreWin(login_db_.release(), profile_.get(), wds_.get())); |
| 236 EXPECT_TRUE(store->Init()); | 238 EXPECT_TRUE(store->Init()); |
| 237 | 239 |
| 238 PasswordFormData form_data = { | 240 PasswordFormData form_data = { |
| 239 PasswordForm::SCHEME_HTML, | 241 PasswordForm::SCHEME_HTML, |
| 240 "http://example.com/", | 242 "http://example.com/", |
| 241 "http://example.com/origin", | 243 "http://example.com/origin", |
| (...skipping 29 matching lines...) Expand all Loading... |
| 271 | 273 |
| 272 // The WDS schedules tasks to run on the DB thread so we schedule yet another | 274 // The WDS schedules tasks to run on the DB thread so we schedule yet another |
| 273 // task to notify us that it's safe to carry on with the test. | 275 // task to notify us that it's safe to carry on with the test. |
| 274 WaitableEvent done(false, false); | 276 WaitableEvent done(false, false); |
| 275 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, | 277 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, |
| 276 new SignalingTask(&done)); | 278 new SignalingTask(&done)); |
| 277 done.Wait(); | 279 done.Wait(); |
| 278 | 280 |
| 279 // Prentend that the migration has already taken place. | 281 // Prentend that the migration has already taken place. |
| 280 profile_->GetPrefs()->RegisterBooleanPref(prefs::kLoginDatabaseMigrated, | 282 profile_->GetPrefs()->RegisterBooleanPref(prefs::kLoginDatabaseMigrated, |
| 281 true); | 283 true, |
| 284 PrefService::UNSYNCABLE_PREF); |
| 282 | 285 |
| 283 // Initializing the PasswordStore shouldn't trigger a migration. | 286 // Initializing the PasswordStore shouldn't trigger a migration. |
| 284 scoped_refptr<PasswordStore> store( | 287 scoped_refptr<PasswordStore> store( |
| 285 new PasswordStoreWin(login_db_.release(), profile_.get(), wds_.get())); | 288 new PasswordStoreWin(login_db_.release(), profile_.get(), wds_.get())); |
| 286 EXPECT_TRUE(store->Init()); | 289 EXPECT_TRUE(store->Init()); |
| 287 | 290 |
| 288 MockPasswordStoreConsumer password_consumer; | 291 MockPasswordStoreConsumer password_consumer; |
| 289 // Make sure we quit the MessageLoop even if the test fails. | 292 // Make sure we quit the MessageLoop even if the test fails. |
| 290 ON_CALL(password_consumer, OnPasswordStoreRequestDone(_, _)) | 293 ON_CALL(password_consumer, OnPasswordStoreRequestDone(_, _)) |
| 291 .WillByDefault(QuitUIMessageLoop()); | 294 .WillByDefault(QuitUIMessageLoop()); |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 // expect that we get no results; | 590 // expect that we get no results; |
| 588 EXPECT_CALL(consumer, OnPasswordStoreRequestDone( | 591 EXPECT_CALL(consumer, OnPasswordStoreRequestDone( |
| 589 _, ContainsAllPasswordForms(expect_none))) | 592 _, ContainsAllPasswordForms(expect_none))) |
| 590 .WillOnce(DoAll(WithArg<1>(STLDeleteElements0()), QuitUIMessageLoop())); | 593 .WillOnce(DoAll(WithArg<1>(STLDeleteElements0()), QuitUIMessageLoop())); |
| 591 | 594 |
| 592 store->GetAutofillableLogins(&consumer); | 595 store->GetAutofillableLogins(&consumer); |
| 593 MessageLoop::current()->Run(); | 596 MessageLoop::current()->Run(); |
| 594 | 597 |
| 595 store->Shutdown(); | 598 store->Shutdown(); |
| 596 } | 599 } |
| OLD | NEW |