| 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 <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/bind.h" | 10 #include "base/bind.h" |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 wds_->AddIE7Login(password_info); | 196 wds_->AddIE7Login(password_info); |
| 197 | 197 |
| 198 // The WDS schedules tasks to run on the DB thread so we schedule yet another | 198 // The WDS schedules tasks to run on the DB thread so we schedule yet another |
| 199 // task to notify us that it's safe to carry on with the test. | 199 // task to notify us that it's safe to carry on with the test. |
| 200 WaitableEvent done(false, false); | 200 WaitableEvent done(false, false); |
| 201 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, | 201 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, |
| 202 base::Bind(&WaitableEvent::Signal, base::Unretained(&done))); | 202 base::Bind(&WaitableEvent::Signal, base::Unretained(&done))); |
| 203 done.Wait(); | 203 done.Wait(); |
| 204 | 204 |
| 205 store_ = CreatePasswordStore(); | 205 store_ = CreatePasswordStore(); |
| 206 EXPECT_TRUE(store_->Init(syncer::SyncableService::StartSyncFlare())); | 206 EXPECT_TRUE(store_->Init(syncer::SyncableService::StartSyncFlare(), "")); |
| 207 | 207 |
| 208 MockPasswordStoreConsumer consumer; | 208 MockPasswordStoreConsumer consumer; |
| 209 | 209 |
| 210 // Make sure we quit the MessageLoop even if the test fails. | 210 // Make sure we quit the MessageLoop even if the test fails. |
| 211 ON_CALL(consumer, OnGetPasswordStoreResults(_)) | 211 ON_CALL(consumer, OnGetPasswordStoreResults(_)) |
| 212 .WillByDefault(QuitUIMessageLoop()); | 212 .WillByDefault(QuitUIMessageLoop()); |
| 213 | 213 |
| 214 PasswordFormData form_data = { | 214 PasswordFormData form_data = { |
| 215 PasswordForm::SCHEME_HTML, | 215 PasswordForm::SCHEME_HTML, |
| 216 "http://example.com/", | 216 "http://example.com/", |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 | 249 |
| 250 store_->GetLogins(*form, PasswordStore::DISALLOW_PROMPT, &consumer); | 250 store_->GetLogins(*form, PasswordStore::DISALLOW_PROMPT, &consumer); |
| 251 base::MessageLoop::current()->Run(); | 251 base::MessageLoop::current()->Run(); |
| 252 | 252 |
| 253 STLDeleteElements(&forms); | 253 STLDeleteElements(&forms); |
| 254 } | 254 } |
| 255 | 255 |
| 256 // Crashy. http://crbug.com/86558 | 256 // Crashy. http://crbug.com/86558 |
| 257 TEST_F(PasswordStoreWinTest, DISABLED_OutstandingWDSQueries) { | 257 TEST_F(PasswordStoreWinTest, DISABLED_OutstandingWDSQueries) { |
| 258 store_ = CreatePasswordStore(); | 258 store_ = CreatePasswordStore(); |
| 259 EXPECT_TRUE(store_->Init(syncer::SyncableService::StartSyncFlare())); | 259 EXPECT_TRUE(store_->Init(syncer::SyncableService::StartSyncFlare(), "")); |
| 260 | 260 |
| 261 PasswordFormData form_data = { | 261 PasswordFormData form_data = { |
| 262 PasswordForm::SCHEME_HTML, | 262 PasswordForm::SCHEME_HTML, |
| 263 "http://example.com/", | 263 "http://example.com/", |
| 264 "http://example.com/origin", | 264 "http://example.com/origin", |
| 265 "http://example.com/action", | 265 "http://example.com/action", |
| 266 L"submit_element", | 266 L"submit_element", |
| 267 L"username_element", | 267 L"username_element", |
| 268 L"password_element", | 268 L"password_element", |
| 269 L"", | 269 L"", |
| (...skipping 22 matching lines...) Expand all Loading... |
| 292 wds_->AddIE7Login(password_info); | 292 wds_->AddIE7Login(password_info); |
| 293 | 293 |
| 294 // The WDS schedules tasks to run on the DB thread so we schedule yet another | 294 // The WDS schedules tasks to run on the DB thread so we schedule yet another |
| 295 // task to notify us that it's safe to carry on with the test. | 295 // task to notify us that it's safe to carry on with the test. |
| 296 WaitableEvent done(false, false); | 296 WaitableEvent done(false, false); |
| 297 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, | 297 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, |
| 298 base::Bind(&WaitableEvent::Signal, base::Unretained(&done))); | 298 base::Bind(&WaitableEvent::Signal, base::Unretained(&done))); |
| 299 done.Wait(); | 299 done.Wait(); |
| 300 | 300 |
| 301 store_ = CreatePasswordStore(); | 301 store_ = CreatePasswordStore(); |
| 302 EXPECT_TRUE(store_->Init(syncer::SyncableService::StartSyncFlare())); | 302 EXPECT_TRUE(store_->Init(syncer::SyncableService::StartSyncFlare(), "")); |
| 303 | 303 |
| 304 MockPasswordStoreConsumer password_consumer; | 304 MockPasswordStoreConsumer password_consumer; |
| 305 // Make sure we quit the MessageLoop even if the test fails. | 305 // Make sure we quit the MessageLoop even if the test fails. |
| 306 ON_CALL(password_consumer, OnGetPasswordStoreResults(_)) | 306 ON_CALL(password_consumer, OnGetPasswordStoreResults(_)) |
| 307 .WillByDefault(QuitUIMessageLoop()); | 307 .WillByDefault(QuitUIMessageLoop()); |
| 308 | 308 |
| 309 PasswordFormData form_data = { | 309 PasswordFormData form_data = { |
| 310 PasswordForm::SCHEME_HTML, | 310 PasswordForm::SCHEME_HTML, |
| 311 "http://example.com/", | 311 "http://example.com/", |
| 312 "http://example.com/origin", | 312 "http://example.com/origin", |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 // schedules on the DB thread and once for the one we just scheduled on the UI | 354 // schedules on the DB thread and once for the one we just scheduled on the UI |
| 355 // thread. | 355 // thread. |
| 356 base::MessageLoop::current()->Run(); | 356 base::MessageLoop::current()->Run(); |
| 357 base::MessageLoop::current()->Run(); | 357 base::MessageLoop::current()->Run(); |
| 358 | 358 |
| 359 STLDeleteElements(&forms); | 359 STLDeleteElements(&forms); |
| 360 } | 360 } |
| 361 | 361 |
| 362 TEST_F(PasswordStoreWinTest, EmptyLogins) { | 362 TEST_F(PasswordStoreWinTest, EmptyLogins) { |
| 363 store_ = CreatePasswordStore(); | 363 store_ = CreatePasswordStore(); |
| 364 store_->Init(syncer::SyncableService::StartSyncFlare()); | 364 store_->Init(syncer::SyncableService::StartSyncFlare(), ""); |
| 365 | 365 |
| 366 PasswordFormData form_data = { | 366 PasswordFormData form_data = { |
| 367 PasswordForm::SCHEME_HTML, | 367 PasswordForm::SCHEME_HTML, |
| 368 "http://example.com/", | 368 "http://example.com/", |
| 369 "http://example.com/origin", | 369 "http://example.com/origin", |
| 370 "http://example.com/action", | 370 "http://example.com/action", |
| 371 L"submit_element", | 371 L"submit_element", |
| 372 L"username_element", | 372 L"username_element", |
| 373 L"password_element", | 373 L"password_element", |
| 374 L"", | 374 L"", |
| (...skipping 13 matching lines...) Expand all Loading... |
| 388 EXPECT_CALL(consumer, | 388 EXPECT_CALL(consumer, |
| 389 OnGetPasswordStoreResults(ContainsAllPasswordForms(expect_none))) | 389 OnGetPasswordStoreResults(ContainsAllPasswordForms(expect_none))) |
| 390 .WillOnce(DoAll(WithArg<0>(STLDeleteElements0()), QuitUIMessageLoop())); | 390 .WillOnce(DoAll(WithArg<0>(STLDeleteElements0()), QuitUIMessageLoop())); |
| 391 | 391 |
| 392 store_->GetLogins(*form, PasswordStore::DISALLOW_PROMPT, &consumer); | 392 store_->GetLogins(*form, PasswordStore::DISALLOW_PROMPT, &consumer); |
| 393 base::MessageLoop::current()->Run(); | 393 base::MessageLoop::current()->Run(); |
| 394 } | 394 } |
| 395 | 395 |
| 396 TEST_F(PasswordStoreWinTest, EmptyBlacklistLogins) { | 396 TEST_F(PasswordStoreWinTest, EmptyBlacklistLogins) { |
| 397 store_ = CreatePasswordStore(); | 397 store_ = CreatePasswordStore(); |
| 398 store_->Init(syncer::SyncableService::StartSyncFlare()); | 398 store_->Init(syncer::SyncableService::StartSyncFlare(), ""); |
| 399 | 399 |
| 400 MockPasswordStoreConsumer consumer; | 400 MockPasswordStoreConsumer consumer; |
| 401 | 401 |
| 402 // Make sure we quit the MessageLoop even if the test fails. | 402 // Make sure we quit the MessageLoop even if the test fails. |
| 403 ON_CALL(consumer, OnGetPasswordStoreResults(_)) | 403 ON_CALL(consumer, OnGetPasswordStoreResults(_)) |
| 404 .WillByDefault(QuitUIMessageLoop()); | 404 .WillByDefault(QuitUIMessageLoop()); |
| 405 | 405 |
| 406 VectorOfForms expect_none; | 406 VectorOfForms expect_none; |
| 407 // expect that we get no results; | 407 // expect that we get no results; |
| 408 EXPECT_CALL( | 408 EXPECT_CALL( |
| 409 consumer, | 409 consumer, |
| 410 OnGetPasswordStoreResults(ContainsAllPasswordForms(expect_none))) | 410 OnGetPasswordStoreResults(ContainsAllPasswordForms(expect_none))) |
| 411 .WillOnce(DoAll(WithArg<0>(STLDeleteElements0()), QuitUIMessageLoop())); | 411 .WillOnce(DoAll(WithArg<0>(STLDeleteElements0()), QuitUIMessageLoop())); |
| 412 | 412 |
| 413 store_->GetBlacklistLogins(&consumer); | 413 store_->GetBlacklistLogins(&consumer); |
| 414 base::MessageLoop::current()->Run(); | 414 base::MessageLoop::current()->Run(); |
| 415 } | 415 } |
| 416 | 416 |
| 417 TEST_F(PasswordStoreWinTest, EmptyAutofillableLogins) { | 417 TEST_F(PasswordStoreWinTest, EmptyAutofillableLogins) { |
| 418 store_ = CreatePasswordStore(); | 418 store_ = CreatePasswordStore(); |
| 419 store_->Init(syncer::SyncableService::StartSyncFlare()); | 419 store_->Init(syncer::SyncableService::StartSyncFlare(), ""); |
| 420 | 420 |
| 421 MockPasswordStoreConsumer consumer; | 421 MockPasswordStoreConsumer consumer; |
| 422 | 422 |
| 423 // Make sure we quit the MessageLoop even if the test fails. | 423 // Make sure we quit the MessageLoop even if the test fails. |
| 424 ON_CALL(consumer, OnGetPasswordStoreResults(_)) | 424 ON_CALL(consumer, OnGetPasswordStoreResults(_)) |
| 425 .WillByDefault(QuitUIMessageLoop()); | 425 .WillByDefault(QuitUIMessageLoop()); |
| 426 | 426 |
| 427 VectorOfForms expect_none; | 427 VectorOfForms expect_none; |
| 428 // expect that we get no results; | 428 // expect that we get no results; |
| 429 EXPECT_CALL( | 429 EXPECT_CALL( |
| 430 consumer, | 430 consumer, |
| 431 OnGetPasswordStoreResults(ContainsAllPasswordForms(expect_none))) | 431 OnGetPasswordStoreResults(ContainsAllPasswordForms(expect_none))) |
| 432 .WillOnce(DoAll(WithArg<0>(STLDeleteElements0()), QuitUIMessageLoop())); | 432 .WillOnce(DoAll(WithArg<0>(STLDeleteElements0()), QuitUIMessageLoop())); |
| 433 | 433 |
| 434 store_->GetAutofillableLogins(&consumer); | 434 store_->GetAutofillableLogins(&consumer); |
| 435 base::MessageLoop::current()->Run(); | 435 base::MessageLoop::current()->Run(); |
| 436 } | 436 } |
| OLD | NEW |