Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(244)

Side by Side Diff: chrome/browser/password_manager/password_store_x_unittest.cc

Issue 16296002: Update chrome/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/bind_helpers.h" 7 #include "base/bind_helpers.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/platform_file.h" 10 #include "base/platform_file.h"
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 "http://bar.example.com/action", 335 "http://bar.example.com/action",
336 L"submit_element", 336 L"submit_element",
337 L"username_element", 337 L"username_element",
338 L"password_element", 338 L"password_element",
339 L"username_value", 339 L"username_value",
340 L"password_value", 340 L"password_value",
341 true, false, 1 }; 341 true, false, 1 };
342 scoped_ptr<PasswordForm> form(CreatePasswordFormFromData(form_data)); 342 scoped_ptr<PasswordForm> form(CreatePasswordFormFromData(form_data));
343 343
344 scoped_refptr<DBThreadObserverHelper> helper = new DBThreadObserverHelper; 344 scoped_refptr<DBThreadObserverHelper> helper = new DBThreadObserverHelper;
345 helper->Init(store); 345 helper->Init(store.get());
346 346
347 const PasswordStoreChange expected_add_changes[] = { 347 const PasswordStoreChange expected_add_changes[] = {
348 PasswordStoreChange(PasswordStoreChange::ADD, *form), 348 PasswordStoreChange(PasswordStoreChange::ADD, *form),
349 }; 349 };
350 350
351 EXPECT_CALL(helper->observer(), 351 EXPECT_CALL(
352 helper->observer(),
352 Observe(int(chrome::NOTIFICATION_LOGINS_CHANGED), 353 Observe(int(chrome::NOTIFICATION_LOGINS_CHANGED),
353 content::Source<PasswordStore>(store), 354 content::Source<PasswordStore>(store.get()),
354 Property(&content::Details<const PasswordStoreChangeList>::ptr, 355 Property(&content::Details<const PasswordStoreChangeList>::ptr,
355 Pointee(ElementsAreArray( 356 Pointee(ElementsAreArray(expected_add_changes)))));
356 expected_add_changes)))));
357 357
358 // Adding a login should trigger a notification. 358 // Adding a login should trigger a notification.
359 store->AddLogin(*form); 359 store->AddLogin(*form);
360 360
361 // The PasswordStore schedules tasks to run on the DB thread so we schedule 361 // The PasswordStore schedules tasks to run on the DB thread so we schedule
362 // yet another task to notify us that it's safe to carry on with the test. 362 // yet another task to notify us that it's safe to carry on with the test.
363 WaitableEvent done(false, false); 363 WaitableEvent done(false, false);
364 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, 364 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
365 base::Bind(&WaitableEvent::Signal, base::Unretained(&done))); 365 base::Bind(&WaitableEvent::Signal, base::Unretained(&done)));
366 done.Wait(); 366 done.Wait();
367 367
368 // Change the password. 368 // Change the password.
369 form->password_value = WideToUTF16(L"a different password"); 369 form->password_value = WideToUTF16(L"a different password");
370 370
371 const PasswordStoreChange expected_update_changes[] = { 371 const PasswordStoreChange expected_update_changes[] = {
372 PasswordStoreChange(PasswordStoreChange::UPDATE, *form), 372 PasswordStoreChange(PasswordStoreChange::UPDATE, *form),
373 }; 373 };
374 374
375 EXPECT_CALL(helper->observer(), 375 EXPECT_CALL(
376 helper->observer(),
376 Observe(int(chrome::NOTIFICATION_LOGINS_CHANGED), 377 Observe(int(chrome::NOTIFICATION_LOGINS_CHANGED),
377 content::Source<PasswordStore>(store), 378 content::Source<PasswordStore>(store.get()),
378 Property(&content::Details<const PasswordStoreChangeList>::ptr, 379 Property(&content::Details<const PasswordStoreChangeList>::ptr,
379 Pointee(ElementsAreArray( 380 Pointee(ElementsAreArray(expected_update_changes)))));
380 expected_update_changes)))));
381 381
382 // Updating the login with the new password should trigger a notification. 382 // Updating the login with the new password should trigger a notification.
383 store->UpdateLogin(*form); 383 store->UpdateLogin(*form);
384 384
385 // Wait for PasswordStore to send the notification. 385 // Wait for PasswordStore to send the notification.
386 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, 386 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
387 base::Bind(&WaitableEvent::Signal, base::Unretained(&done))); 387 base::Bind(&WaitableEvent::Signal, base::Unretained(&done)));
388 done.Wait(); 388 done.Wait();
389 389
390 const PasswordStoreChange expected_delete_changes[] = { 390 const PasswordStoreChange expected_delete_changes[] = {
391 PasswordStoreChange(PasswordStoreChange::REMOVE, *form), 391 PasswordStoreChange(PasswordStoreChange::REMOVE, *form),
392 }; 392 };
393 393
394 EXPECT_CALL(helper->observer(), 394 EXPECT_CALL(
395 helper->observer(),
395 Observe(int(chrome::NOTIFICATION_LOGINS_CHANGED), 396 Observe(int(chrome::NOTIFICATION_LOGINS_CHANGED),
396 content::Source<PasswordStore>(store), 397 content::Source<PasswordStore>(store.get()),
397 Property(&content::Details<const PasswordStoreChangeList>::ptr, 398 Property(&content::Details<const PasswordStoreChangeList>::ptr,
398 Pointee(ElementsAreArray( 399 Pointee(ElementsAreArray(expected_delete_changes)))));
399 expected_delete_changes)))));
400 400
401 // Deleting the login should trigger a notification. 401 // Deleting the login should trigger a notification.
402 store->RemoveLogin(*form); 402 store->RemoveLogin(*form);
403 403
404 // Wait for PasswordStore to send the notification. 404 // Wait for PasswordStore to send the notification.
405 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, 405 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
406 base::Bind(&WaitableEvent::Signal, base::Unretained(&done))); 406 base::Bind(&WaitableEvent::Signal, base::Unretained(&done)));
407 done.Wait(); 407 done.Wait();
408 408
409 // Public in PasswordStore, protected in PasswordStoreX. 409 // Public in PasswordStore, protected in PasswordStoreX.
410 static_cast<PasswordStore*>(store)->ShutdownOnUIThread(); 410 static_cast<PasswordStore*>(store.get())->ShutdownOnUIThread();
411 } 411 }
412 412
413 TEST_P(PasswordStoreXTest, NativeMigration) { 413 TEST_P(PasswordStoreXTest, NativeMigration) {
414 VectorOfForms expected_autofillable; 414 VectorOfForms expected_autofillable;
415 InitExpectedForms(true, 50, &expected_autofillable); 415 InitExpectedForms(true, 50, &expected_autofillable);
416 416
417 VectorOfForms expected_blacklisted; 417 VectorOfForms expected_blacklisted;
418 InitExpectedForms(false, 50, &expected_blacklisted); 418 InitExpectedForms(false, 50, &expected_blacklisted);
419 419
420 // Get the initial size of the login DB file, before we populate it. 420 // Get the initial size of the login DB file, before we populate it.
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 // larger after populating it. 537 // larger after populating it.
538 base::PlatformFileInfo db_file_end_info; 538 base::PlatformFileInfo db_file_end_info;
539 ASSERT_TRUE(file_util::GetFileInfo(login_db_file, &db_file_end_info)); 539 ASSERT_TRUE(file_util::GetFileInfo(login_db_file, &db_file_end_info));
540 EXPECT_EQ(db_file_start_info.size, db_file_end_info.size); 540 EXPECT_EQ(db_file_start_info.size, db_file_end_info.size);
541 } 541 }
542 542
543 STLDeleteElements(&expected_autofillable); 543 STLDeleteElements(&expected_autofillable);
544 STLDeleteElements(&expected_blacklisted); 544 STLDeleteElements(&expected_blacklisted);
545 545
546 // Public in PasswordStore, protected in PasswordStoreX. 546 // Public in PasswordStore, protected in PasswordStoreX.
547 static_cast<PasswordStore*>(store)->ShutdownOnUIThread(); 547 static_cast<PasswordStore*>(store.get())->ShutdownOnUIThread();
548 } 548 }
549 549
550 INSTANTIATE_TEST_CASE_P(NoBackend, 550 INSTANTIATE_TEST_CASE_P(NoBackend,
551 PasswordStoreXTest, 551 PasswordStoreXTest,
552 testing::Values(NO_BACKEND)); 552 testing::Values(NO_BACKEND));
553 INSTANTIATE_TEST_CASE_P(FailingBackend, 553 INSTANTIATE_TEST_CASE_P(FailingBackend,
554 PasswordStoreXTest, 554 PasswordStoreXTest,
555 testing::Values(FAILING_BACKEND)); 555 testing::Values(FAILING_BACKEND));
556 INSTANTIATE_TEST_CASE_P(WorkingBackend, 556 INSTANTIATE_TEST_CASE_P(WorkingBackend,
557 PasswordStoreXTest, 557 PasswordStoreXTest,
558 testing::Values(WORKING_BACKEND)); 558 testing::Values(WORKING_BACKEND));
OLDNEW
« no previous file with comments | « chrome/browser/password_manager/password_store_factory.cc ('k') | chrome/browser/plugins/plugin_status_pref_setter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698