| 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 | 161 |
| 162 // The WDS schedules tasks to run on the DB thread so we schedule yet another | 162 // The WDS schedules tasks to run on the DB thread so we schedule yet another |
| 163 // task to notify us that it's safe to carry on with the test. | 163 // task to notify us that it's safe to carry on with the test. |
| 164 WaitableEvent done(false, false); | 164 WaitableEvent done(false, false); |
| 165 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, | 165 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, |
| 166 new SignalingTask(&done)); | 166 new SignalingTask(&done)); |
| 167 done.Wait(); | 167 done.Wait(); |
| 168 | 168 |
| 169 // Prentend that the migration has already taken place. | 169 // Prentend that the migration has already taken place. |
| 170 profile_->GetPrefs()->RegisterBooleanPref(prefs::kLoginDatabaseMigrated, | 170 profile_->GetPrefs()->RegisterBooleanPref(prefs::kLoginDatabaseMigrated, |
| 171 true); | 171 true, |
| 172 false /* don't sync pref */); |
| 172 | 173 |
| 173 // Initializing the PasswordStore shouldn't trigger a migration. | 174 // Initializing the PasswordStore shouldn't trigger a migration. |
| 174 scoped_refptr<PasswordStoreWin> store( | 175 scoped_refptr<PasswordStoreWin> store( |
| 175 new PasswordStoreWin(login_db_.release(), profile_.get(), wds_.get())); | 176 new PasswordStoreWin(login_db_.release(), profile_.get(), wds_.get())); |
| 176 EXPECT_TRUE(store->Init()); | 177 EXPECT_TRUE(store->Init()); |
| 177 | 178 |
| 178 MockPasswordStoreConsumer consumer; | 179 MockPasswordStoreConsumer consumer; |
| 179 | 180 |
| 180 // Make sure we quit the MessageLoop even if the test fails. | 181 // Make sure we quit the MessageLoop even if the test fails. |
| 181 ON_CALL(consumer, OnPasswordStoreRequestDone(_, _)) | 182 ON_CALL(consumer, OnPasswordStoreRequestDone(_, _)) |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 | 219 |
| 219 store->GetLogins(*form, &consumer); | 220 store->GetLogins(*form, &consumer); |
| 220 MessageLoop::current()->Run(); | 221 MessageLoop::current()->Run(); |
| 221 | 222 |
| 222 STLDeleteElements(&forms); | 223 STLDeleteElements(&forms); |
| 223 } | 224 } |
| 224 | 225 |
| 225 TEST_F(PasswordStoreWinTest, OutstandingWDSQueries) { | 226 TEST_F(PasswordStoreWinTest, OutstandingWDSQueries) { |
| 226 // Prentend that the migration has already taken place. | 227 // Prentend that the migration has already taken place. |
| 227 profile_->GetPrefs()->RegisterBooleanPref(prefs::kLoginDatabaseMigrated, | 228 profile_->GetPrefs()->RegisterBooleanPref(prefs::kLoginDatabaseMigrated, |
| 228 true); | 229 true, |
| 230 false /* don't sync pref */); |
| 229 | 231 |
| 230 // Initializing the PasswordStore shouldn't trigger a migration. | 232 // Initializing the PasswordStore shouldn't trigger a migration. |
| 231 scoped_refptr<PasswordStoreWin> store( | 233 scoped_refptr<PasswordStoreWin> store( |
| 232 new PasswordStoreWin(login_db_.release(), profile_.get(), wds_.get())); | 234 new PasswordStoreWin(login_db_.release(), profile_.get(), wds_.get())); |
| 233 EXPECT_TRUE(store->Init()); | 235 EXPECT_TRUE(store->Init()); |
| 234 | 236 |
| 235 PasswordFormData form_data = { | 237 PasswordFormData form_data = { |
| 236 PasswordForm::SCHEME_HTML, | 238 PasswordForm::SCHEME_HTML, |
| 237 "http://example.com/", | 239 "http://example.com/", |
| 238 "http://example.com/origin", | 240 "http://example.com/origin", |
| (...skipping 28 matching lines...) Expand all Loading... |
| 267 | 269 |
| 268 // The WDS schedules tasks to run on the DB thread so we schedule yet another | 270 // The WDS schedules tasks to run on the DB thread so we schedule yet another |
| 269 // task to notify us that it's safe to carry on with the test. | 271 // task to notify us that it's safe to carry on with the test. |
| 270 WaitableEvent done(false, false); | 272 WaitableEvent done(false, false); |
| 271 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, | 273 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, |
| 272 new SignalingTask(&done)); | 274 new SignalingTask(&done)); |
| 273 done.Wait(); | 275 done.Wait(); |
| 274 | 276 |
| 275 // Prentend that the migration has already taken place. | 277 // Prentend that the migration has already taken place. |
| 276 profile_->GetPrefs()->RegisterBooleanPref(prefs::kLoginDatabaseMigrated, | 278 profile_->GetPrefs()->RegisterBooleanPref(prefs::kLoginDatabaseMigrated, |
| 277 true); | 279 true, |
| 280 false /* don't sync pref */); |
| 278 | 281 |
| 279 // Initializing the PasswordStore shouldn't trigger a migration. | 282 // Initializing the PasswordStore shouldn't trigger a migration. |
| 280 scoped_refptr<PasswordStoreWin> store( | 283 scoped_refptr<PasswordStoreWin> store( |
| 281 new PasswordStoreWin(login_db_.release(), profile_.get(), wds_.get())); | 284 new PasswordStoreWin(login_db_.release(), profile_.get(), wds_.get())); |
| 282 EXPECT_TRUE(store->Init()); | 285 EXPECT_TRUE(store->Init()); |
| 283 | 286 |
| 284 MockPasswordStoreConsumer password_consumer; | 287 MockPasswordStoreConsumer password_consumer; |
| 285 // Make sure we quit the MessageLoop even if the test fails. | 288 // Make sure we quit the MessageLoop even if the test fails. |
| 286 ON_CALL(password_consumer, OnPasswordStoreRequestDone(_, _)) | 289 ON_CALL(password_consumer, OnPasswordStoreRequestDone(_, _)) |
| 287 .WillByDefault(QuitUIMessageLoop()); | 290 .WillByDefault(QuitUIMessageLoop()); |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 | 578 |
| 576 VectorOfForms expect_none; | 579 VectorOfForms expect_none; |
| 577 // expect that we get no results; | 580 // expect that we get no results; |
| 578 EXPECT_CALL(consumer, OnPasswordStoreRequestDone( | 581 EXPECT_CALL(consumer, OnPasswordStoreRequestDone( |
| 579 _, ContainsAllPasswordForms(expect_none))) | 582 _, ContainsAllPasswordForms(expect_none))) |
| 580 .WillOnce(DoAll(WithArg<1>(STLDeleteElements0()), QuitUIMessageLoop())); | 583 .WillOnce(DoAll(WithArg<1>(STLDeleteElements0()), QuitUIMessageLoop())); |
| 581 | 584 |
| 582 store->GetAutofillableLogins(&consumer); | 585 store->GetAutofillableLogins(&consumer); |
| 583 MessageLoop::current()->Run(); | 586 MessageLoop::current()->Run(); |
| 584 } | 587 } |
| OLD | NEW |