| 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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 // The WDS schedules tasks to run on the DB thread so we schedule yet another | 213 // The WDS schedules tasks to run on the DB thread so we schedule yet another |
| 214 // task to notify us that it's safe to carry on with the test. | 214 // task to notify us that it's safe to carry on with the test. |
| 215 WaitableEvent done(base::WaitableEvent::ResetPolicy::AUTOMATIC, | 215 WaitableEvent done(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 216 base::WaitableEvent::InitialState::NOT_SIGNALED); | 216 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 217 BrowserThread::PostTask( | 217 BrowserThread::PostTask( |
| 218 BrowserThread::DB, FROM_HERE, | 218 BrowserThread::DB, FROM_HERE, |
| 219 base::Bind(&WaitableEvent::Signal, base::Unretained(&done))); | 219 base::Bind(&WaitableEvent::Signal, base::Unretained(&done))); |
| 220 done.Wait(); | 220 done.Wait(); |
| 221 | 221 |
| 222 store_ = CreatePasswordStore(); | 222 store_ = CreatePasswordStore(); |
| 223 EXPECT_TRUE(store_->Init(syncer::SyncableService::StartSyncFlare())); | 223 EXPECT_TRUE(store_->Init(syncer::SyncableService::StartSyncFlare(), nullptr)); |
| 224 | 224 |
| 225 MockPasswordStoreConsumer consumer; | 225 MockPasswordStoreConsumer consumer; |
| 226 | 226 |
| 227 // Make sure we quit the MessageLoop even if the test fails. | 227 // Make sure we quit the MessageLoop even if the test fails. |
| 228 ON_CALL(consumer, OnGetPasswordStoreResultsConstRef(_)) | 228 ON_CALL(consumer, OnGetPasswordStoreResultsConstRef(_)) |
| 229 .WillByDefault(QuitUIMessageLoop()); | 229 .WillByDefault(QuitUIMessageLoop()); |
| 230 | 230 |
| 231 PasswordFormData form_data = { | 231 PasswordFormData form_data = { |
| 232 PasswordForm::SCHEME_HTML, | 232 PasswordForm::SCHEME_HTML, |
| 233 "http://example.com/", | 233 "http://example.com/", |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 // The IE7 password should be returned. | 266 // The IE7 password should be returned. |
| 267 EXPECT_CALL(consumer, OnGetPasswordStoreResultsConstRef( | 267 EXPECT_CALL(consumer, OnGetPasswordStoreResultsConstRef( |
| 268 UnorderedPasswordFormElementsAre(&expected_forms))); | 268 UnorderedPasswordFormElementsAre(&expected_forms))); |
| 269 | 269 |
| 270 store_->GetLogins(form, &consumer); | 270 store_->GetLogins(form, &consumer); |
| 271 base::RunLoop().Run(); | 271 base::RunLoop().Run(); |
| 272 } | 272 } |
| 273 | 273 |
| 274 TEST_F(PasswordStoreWinTest, OutstandingWDSQueries) { | 274 TEST_F(PasswordStoreWinTest, OutstandingWDSQueries) { |
| 275 store_ = CreatePasswordStore(); | 275 store_ = CreatePasswordStore(); |
| 276 EXPECT_TRUE(store_->Init(syncer::SyncableService::StartSyncFlare())); | 276 EXPECT_TRUE(store_->Init(syncer::SyncableService::StartSyncFlare(), nullptr)); |
| 277 | 277 |
| 278 PasswordFormData form_data = { | 278 PasswordFormData form_data = { |
| 279 PasswordForm::SCHEME_HTML, | 279 PasswordForm::SCHEME_HTML, |
| 280 "http://example.com/", | 280 "http://example.com/", |
| 281 "http://example.com/origin", | 281 "http://example.com/origin", |
| 282 "http://example.com/action", | 282 "http://example.com/action", |
| 283 L"submit_element", | 283 L"submit_element", |
| 284 L"username_element", | 284 L"username_element", |
| 285 L"password_element", | 285 L"password_element", |
| 286 L"", | 286 L"", |
| (...skipping 29 matching lines...) Expand all Loading... |
| 316 // The WDS schedules tasks to run on the DB thread so we schedule yet another | 316 // The WDS schedules tasks to run on the DB thread so we schedule yet another |
| 317 // task to notify us that it's safe to carry on with the test. | 317 // task to notify us that it's safe to carry on with the test. |
| 318 WaitableEvent done(base::WaitableEvent::ResetPolicy::AUTOMATIC, | 318 WaitableEvent done(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 319 base::WaitableEvent::InitialState::NOT_SIGNALED); | 319 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 320 BrowserThread::PostTask( | 320 BrowserThread::PostTask( |
| 321 BrowserThread::DB, FROM_HERE, | 321 BrowserThread::DB, FROM_HERE, |
| 322 base::Bind(&WaitableEvent::Signal, base::Unretained(&done))); | 322 base::Bind(&WaitableEvent::Signal, base::Unretained(&done))); |
| 323 done.Wait(); | 323 done.Wait(); |
| 324 | 324 |
| 325 store_ = CreatePasswordStore(); | 325 store_ = CreatePasswordStore(); |
| 326 EXPECT_TRUE(store_->Init(syncer::SyncableService::StartSyncFlare())); | 326 EXPECT_TRUE(store_->Init(syncer::SyncableService::StartSyncFlare(), nullptr)); |
| 327 | 327 |
| 328 MockPasswordStoreConsumer password_consumer; | 328 MockPasswordStoreConsumer password_consumer; |
| 329 // Make sure we quit the MessageLoop even if the test fails. | 329 // Make sure we quit the MessageLoop even if the test fails. |
| 330 ON_CALL(password_consumer, OnGetPasswordStoreResultsConstRef(_)) | 330 ON_CALL(password_consumer, OnGetPasswordStoreResultsConstRef(_)) |
| 331 .WillByDefault(QuitUIMessageLoop()); | 331 .WillByDefault(QuitUIMessageLoop()); |
| 332 | 332 |
| 333 PasswordFormData form_data = { | 333 PasswordFormData form_data = { |
| 334 PasswordForm::SCHEME_HTML, | 334 PasswordForm::SCHEME_HTML, |
| 335 "http://example.com/", | 335 "http://example.com/", |
| 336 "http://example.com/origin", | 336 "http://example.com/origin", |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 | 379 |
| 380 // Run the MessageLoop twice: once for the GetIE7Login that PasswordStoreWin | 380 // Run the MessageLoop twice: once for the GetIE7Login that PasswordStoreWin |
| 381 // schedules on the DB thread and once for the one we just scheduled on the UI | 381 // schedules on the DB thread and once for the one we just scheduled on the UI |
| 382 // thread. | 382 // thread. |
| 383 base::RunLoop().Run(); | 383 base::RunLoop().Run(); |
| 384 base::RunLoop().Run(); | 384 base::RunLoop().Run(); |
| 385 } | 385 } |
| 386 | 386 |
| 387 TEST_F(PasswordStoreWinTest, EmptyLogins) { | 387 TEST_F(PasswordStoreWinTest, EmptyLogins) { |
| 388 store_ = CreatePasswordStore(); | 388 store_ = CreatePasswordStore(); |
| 389 store_->Init(syncer::SyncableService::StartSyncFlare()); | 389 store_->Init(syncer::SyncableService::StartSyncFlare(), nullptr); |
| 390 | 390 |
| 391 PasswordFormData form_data = { | 391 PasswordFormData form_data = { |
| 392 PasswordForm::SCHEME_HTML, | 392 PasswordForm::SCHEME_HTML, |
| 393 "http://example.com/", | 393 "http://example.com/", |
| 394 "http://example.com/origin", | 394 "http://example.com/origin", |
| 395 "http://example.com/action", | 395 "http://example.com/action", |
| 396 L"submit_element", | 396 L"submit_element", |
| 397 L"username_element", | 397 L"username_element", |
| 398 L"password_element", | 398 L"password_element", |
| 399 L"", | 399 L"", |
| (...skipping 11 matching lines...) Expand all Loading... |
| 411 .WillByDefault(QuitUIMessageLoop()); | 411 .WillByDefault(QuitUIMessageLoop()); |
| 412 | 412 |
| 413 EXPECT_CALL(consumer, OnGetPasswordStoreResultsConstRef(IsEmpty())); | 413 EXPECT_CALL(consumer, OnGetPasswordStoreResultsConstRef(IsEmpty())); |
| 414 | 414 |
| 415 store_->GetLogins(form, &consumer); | 415 store_->GetLogins(form, &consumer); |
| 416 base::RunLoop().Run(); | 416 base::RunLoop().Run(); |
| 417 } | 417 } |
| 418 | 418 |
| 419 TEST_F(PasswordStoreWinTest, EmptyBlacklistLogins) { | 419 TEST_F(PasswordStoreWinTest, EmptyBlacklistLogins) { |
| 420 store_ = CreatePasswordStore(); | 420 store_ = CreatePasswordStore(); |
| 421 store_->Init(syncer::SyncableService::StartSyncFlare()); | 421 store_->Init(syncer::SyncableService::StartSyncFlare(), nullptr); |
| 422 | 422 |
| 423 MockPasswordStoreConsumer consumer; | 423 MockPasswordStoreConsumer consumer; |
| 424 | 424 |
| 425 // Make sure we quit the MessageLoop even if the test fails. | 425 // Make sure we quit the MessageLoop even if the test fails. |
| 426 ON_CALL(consumer, OnGetPasswordStoreResultsConstRef(_)) | 426 ON_CALL(consumer, OnGetPasswordStoreResultsConstRef(_)) |
| 427 .WillByDefault(QuitUIMessageLoop()); | 427 .WillByDefault(QuitUIMessageLoop()); |
| 428 | 428 |
| 429 EXPECT_CALL(consumer, OnGetPasswordStoreResultsConstRef(IsEmpty())); | 429 EXPECT_CALL(consumer, OnGetPasswordStoreResultsConstRef(IsEmpty())); |
| 430 | 430 |
| 431 store_->GetBlacklistLogins(&consumer); | 431 store_->GetBlacklistLogins(&consumer); |
| 432 base::RunLoop().Run(); | 432 base::RunLoop().Run(); |
| 433 } | 433 } |
| 434 | 434 |
| 435 TEST_F(PasswordStoreWinTest, EmptyAutofillableLogins) { | 435 TEST_F(PasswordStoreWinTest, EmptyAutofillableLogins) { |
| 436 store_ = CreatePasswordStore(); | 436 store_ = CreatePasswordStore(); |
| 437 store_->Init(syncer::SyncableService::StartSyncFlare()); | 437 store_->Init(syncer::SyncableService::StartSyncFlare(), nullptr); |
| 438 | 438 |
| 439 MockPasswordStoreConsumer consumer; | 439 MockPasswordStoreConsumer consumer; |
| 440 | 440 |
| 441 // Make sure we quit the MessageLoop even if the test fails. | 441 // Make sure we quit the MessageLoop even if the test fails. |
| 442 ON_CALL(consumer, OnGetPasswordStoreResultsConstRef(_)) | 442 ON_CALL(consumer, OnGetPasswordStoreResultsConstRef(_)) |
| 443 .WillByDefault(QuitUIMessageLoop()); | 443 .WillByDefault(QuitUIMessageLoop()); |
| 444 | 444 |
| 445 EXPECT_CALL(consumer, OnGetPasswordStoreResultsConstRef(IsEmpty())); | 445 EXPECT_CALL(consumer, OnGetPasswordStoreResultsConstRef(IsEmpty())); |
| 446 | 446 |
| 447 store_->GetAutofillableLogins(&consumer); | 447 store_->GetAutofillableLogins(&consumer); |
| 448 base::RunLoop().Run(); | 448 base::RunLoop().Run(); |
| 449 } | 449 } |
| OLD | NEW |