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