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

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

Issue 11647041: Revert "Linux: add library loader for GNOME keyring." (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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
« no previous file with comments | « chrome/browser/password_manager/native_backend_gnome_x.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stdarg.h> 5 #include <stdarg.h>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 element = g_list_next(element); 250 element = g_list_next(element);
251 } 251 }
252 g_list_free(results); 252 g_list_free(results);
253 return NULL; 253 return NULL;
254 } 254 }
255 255
256 const gchar* mock_gnome_keyring_result_to_message(GnomeKeyringResult res) { 256 const gchar* mock_gnome_keyring_result_to_message(GnomeKeyringResult res) {
257 return "mock keyring simulating failure"; 257 return "mock keyring simulating failure";
258 } 258 }
259 259
260 } // namespace 260 // Inherit to get access to protected fields.
261 class MockGnomeKeyringLoader : public GnomeKeyringLoader {
262 public:
263 static bool LoadMockGnomeKeyring() {
264 #define GNOME_KEYRING_ASSIGN_POINTER(name) \
265 gnome_keyring_##name = &mock_gnome_keyring_##name;
266 GNOME_KEYRING_FOR_EACH_FUNC(GNOME_KEYRING_ASSIGN_POINTER)
267 #undef GNOME_KEYRING_ASSIGN_POINTER
268 keyring_loaded = true;
269 // Reset the state of the mock library.
270 mock_keyring_items.clear();
271 mock_keyring_reject_local_ids = false;
272 return true;
273 }
274 };
275
276 } // anonymous namespace
261 277
262 class NativeBackendGnomeTest : public testing::Test { 278 class NativeBackendGnomeTest : public testing::Test {
263 protected: 279 protected:
264 NativeBackendGnomeTest() 280 NativeBackendGnomeTest()
265 : ui_thread_(BrowserThread::UI, &message_loop_), 281 : ui_thread_(BrowserThread::UI, &message_loop_),
266 db_thread_(BrowserThread::DB) { 282 db_thread_(BrowserThread::DB) {
267 } 283 }
268 284
269 virtual void SetUp() { 285 virtual void SetUp() {
270 ASSERT_TRUE(db_thread_.Start()); 286 ASSERT_TRUE(db_thread_.Start());
271 287
288 MockGnomeKeyringLoader::LoadMockGnomeKeyring();
289
272 form_google_.origin = GURL("http://www.google.com/"); 290 form_google_.origin = GURL("http://www.google.com/");
273 form_google_.action = GURL("http://www.google.com/login"); 291 form_google_.action = GURL("http://www.google.com/login");
274 form_google_.username_element = UTF8ToUTF16("user"); 292 form_google_.username_element = UTF8ToUTF16("user");
275 form_google_.username_value = UTF8ToUTF16("joeschmoe"); 293 form_google_.username_value = UTF8ToUTF16("joeschmoe");
276 form_google_.password_element = UTF8ToUTF16("pass"); 294 form_google_.password_element = UTF8ToUTF16("pass");
277 form_google_.password_value = UTF8ToUTF16("seekrit"); 295 form_google_.password_value = UTF8ToUTF16("seekrit");
278 form_google_.submit_element = UTF8ToUTF16("submit"); 296 form_google_.submit_element = UTF8ToUTF16("submit");
279 form_google_.signon_realm = "Google"; 297 form_google_.signon_realm = "Google";
280 298
281 form_isc_.origin = GURL("http://www.isc.org/"); 299 form_isc_.origin = GURL("http://www.isc.org/");
282 form_isc_.action = GURL("http://www.isc.org/auth"); 300 form_isc_.action = GURL("http://www.isc.org/auth");
283 form_isc_.username_element = UTF8ToUTF16("id"); 301 form_isc_.username_element = UTF8ToUTF16("id");
284 form_isc_.username_value = UTF8ToUTF16("janedoe"); 302 form_isc_.username_value = UTF8ToUTF16("janedoe");
285 form_isc_.password_element = UTF8ToUTF16("passwd"); 303 form_isc_.password_element = UTF8ToUTF16("passwd");
286 form_isc_.password_value = UTF8ToUTF16("ihazabukkit"); 304 form_isc_.password_value = UTF8ToUTF16("ihazabukkit");
287 form_isc_.submit_element = UTF8ToUTF16("login"); 305 form_isc_.submit_element = UTF8ToUTF16("login");
288 form_isc_.signon_realm = "ISC"; 306 form_isc_.signon_realm = "ISC";
289 } 307 }
290 308
291 virtual void TearDown() { 309 virtual void TearDown() {
292 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); 310 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
293 MessageLoop::current()->Run(); 311 MessageLoop::current()->Run();
294 db_thread_.Stop(); 312 db_thread_.Stop();
295 } 313 }
296 314
297 static void SetUpMockKeyring(NativeBackendGnome* backend) {
298 LibGnomeKeyringLoader* loader = backend->libgnome_keyring_loader();
299 loader->gnome_keyring_is_available = &mock_gnome_keyring_is_available;
300 loader->gnome_keyring_store_password = &mock_gnome_keyring_store_password;
301 loader->gnome_keyring_delete_password = &mock_gnome_keyring_delete_password;
302 loader->gnome_keyring_find_itemsv = &mock_gnome_keyring_find_itemsv;
303 loader->gnome_keyring_result_to_message =
304 &mock_gnome_keyring_result_to_message;
305
306 // Reset the state of the mock library.
307 mock_keyring_items.clear();
308 mock_keyring_reject_local_ids = false;
309 }
310
311 void RunBothThreads() { 315 void RunBothThreads() {
312 // First we post a message to the DB thread that will run after all other 316 // First we post a message to the DB thread that will run after all other
313 // messages that have been posted to the DB thread (we don't expect more 317 // messages that have been posted to the DB thread (we don't expect more
314 // to be posted), which posts a message to the UI thread to quit the loop. 318 // to be posted), which posts a message to the UI thread to quit the loop.
315 // That way we can run both loops and be sure that the UI thread loop will 319 // That way we can run both loops and be sure that the UI thread loop will
316 // quit so we can get on with the rest of the test. 320 // quit so we can get on with the rest of the test.
317 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, 321 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
318 base::Bind(&PostQuitTask, &message_loop_)); 322 base::Bind(&PostQuitTask, &message_loop_));
319 MessageLoop::current()->Run(); 323 MessageLoop::current()->Run();
320 } 324 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 PasswordForm form_google_; 388 PasswordForm form_google_;
385 PasswordForm form_isc_; 389 PasswordForm form_isc_;
386 }; 390 };
387 391
388 TEST_F(NativeBackendGnomeTest, BasicAddLogin) { 392 TEST_F(NativeBackendGnomeTest, BasicAddLogin) {
389 // Pretend that the migration has already taken place. 393 // Pretend that the migration has already taken place.
390 profile_.GetPrefs()->SetBoolean(prefs::kPasswordsUseLocalProfileId, true); 394 profile_.GetPrefs()->SetBoolean(prefs::kPasswordsUseLocalProfileId, true);
391 395
392 NativeBackendGnome backend(42, profile_.GetPrefs()); 396 NativeBackendGnome backend(42, profile_.GetPrefs());
393 backend.Init(); 397 backend.Init();
394 SetUpMockKeyring(&backend);
395 398
396 BrowserThread::PostTask( 399 BrowserThread::PostTask(
397 BrowserThread::DB, FROM_HERE, 400 BrowserThread::DB, FROM_HERE,
398 base::Bind(base::IgnoreResult(&NativeBackendGnome::AddLogin), 401 base::Bind(base::IgnoreResult(&NativeBackendGnome::AddLogin),
399 base::Unretained(&backend), form_google_)); 402 base::Unretained(&backend), form_google_));
400 403
401 RunBothThreads(); 404 RunBothThreads();
402 405
403 EXPECT_EQ(1u, mock_keyring_items.size()); 406 EXPECT_EQ(1u, mock_keyring_items.size());
404 if (mock_keyring_items.size() > 0) 407 if (mock_keyring_items.size() > 0)
405 CheckMockKeyringItem(&mock_keyring_items[0], form_google_, "chrome-42"); 408 CheckMockKeyringItem(&mock_keyring_items[0], form_google_, "chrome-42");
406 } 409 }
407 410
408 TEST_F(NativeBackendGnomeTest, BasicListLogins) { 411 TEST_F(NativeBackendGnomeTest, BasicListLogins) {
409 // Pretend that the migration has already taken place. 412 // Pretend that the migration has already taken place.
410 profile_.GetPrefs()->SetBoolean(prefs::kPasswordsUseLocalProfileId, true); 413 profile_.GetPrefs()->SetBoolean(prefs::kPasswordsUseLocalProfileId, true);
411 414
412 NativeBackendGnome backend(42, profile_.GetPrefs()); 415 NativeBackendGnome backend(42, profile_.GetPrefs());
413 backend.Init(); 416 backend.Init();
414 SetUpMockKeyring(&backend);
415 417
416 BrowserThread::PostTask( 418 BrowserThread::PostTask(
417 BrowserThread::DB, FROM_HERE, 419 BrowserThread::DB, FROM_HERE,
418 base::Bind(base::IgnoreResult( &NativeBackendGnome::AddLogin), 420 base::Bind(base::IgnoreResult( &NativeBackendGnome::AddLogin),
419 base::Unretained(&backend), form_google_)); 421 base::Unretained(&backend), form_google_));
420 422
421 std::vector<PasswordForm*> form_list; 423 std::vector<PasswordForm*> form_list;
422 BrowserThread::PostTask( 424 BrowserThread::PostTask(
423 BrowserThread::DB, FROM_HERE, 425 BrowserThread::DB, FROM_HERE,
424 base::Bind( 426 base::Bind(
(...skipping 10 matching lines...) Expand all
435 if (mock_keyring_items.size() > 0) 437 if (mock_keyring_items.size() > 0)
436 CheckMockKeyringItem(&mock_keyring_items[0], form_google_, "chrome-42"); 438 CheckMockKeyringItem(&mock_keyring_items[0], form_google_, "chrome-42");
437 } 439 }
438 440
439 TEST_F(NativeBackendGnomeTest, BasicRemoveLogin) { 441 TEST_F(NativeBackendGnomeTest, BasicRemoveLogin) {
440 // Pretend that the migration has already taken place. 442 // Pretend that the migration has already taken place.
441 profile_.GetPrefs()->SetBoolean(prefs::kPasswordsUseLocalProfileId, true); 443 profile_.GetPrefs()->SetBoolean(prefs::kPasswordsUseLocalProfileId, true);
442 444
443 NativeBackendGnome backend(42, profile_.GetPrefs()); 445 NativeBackendGnome backend(42, profile_.GetPrefs());
444 backend.Init(); 446 backend.Init();
445 SetUpMockKeyring(&backend);
446 447
447 BrowserThread::PostTask( 448 BrowserThread::PostTask(
448 BrowserThread::DB, FROM_HERE, 449 BrowserThread::DB, FROM_HERE,
449 base::Bind(base::IgnoreResult(&NativeBackendGnome::AddLogin), 450 base::Bind(base::IgnoreResult(&NativeBackendGnome::AddLogin),
450 base::Unretained(&backend), form_google_)); 451 base::Unretained(&backend), form_google_));
451 452
452 RunBothThreads(); 453 RunBothThreads();
453 454
454 EXPECT_EQ(1u, mock_keyring_items.size()); 455 EXPECT_EQ(1u, mock_keyring_items.size());
455 if (mock_keyring_items.size() > 0) 456 if (mock_keyring_items.size() > 0)
456 CheckMockKeyringItem(&mock_keyring_items[0], form_google_, "chrome-42"); 457 CheckMockKeyringItem(&mock_keyring_items[0], form_google_, "chrome-42");
457 458
458 BrowserThread::PostTask( 459 BrowserThread::PostTask(
459 BrowserThread::DB, FROM_HERE, 460 BrowserThread::DB, FROM_HERE,
460 base::Bind(base::IgnoreResult(&NativeBackendGnome::RemoveLogin), 461 base::Bind(base::IgnoreResult(&NativeBackendGnome::RemoveLogin),
461 base::Unretained(&backend), form_google_)); 462 base::Unretained(&backend), form_google_));
462 463
463 RunBothThreads(); 464 RunBothThreads();
464 465
465 EXPECT_EQ(0u, mock_keyring_items.size()); 466 EXPECT_EQ(0u, mock_keyring_items.size());
466 } 467 }
467 468
468 TEST_F(NativeBackendGnomeTest, RemoveNonexistentLogin) { 469 TEST_F(NativeBackendGnomeTest, RemoveNonexistentLogin) {
469 // Pretend that the migration has already taken place. 470 // Pretend that the migration has already taken place.
470 profile_.GetPrefs()->SetBoolean(prefs::kPasswordsUseLocalProfileId, true); 471 profile_.GetPrefs()->SetBoolean(prefs::kPasswordsUseLocalProfileId, true);
471 472
472 NativeBackendGnome backend(42, profile_.GetPrefs()); 473 NativeBackendGnome backend(42, profile_.GetPrefs());
473 backend.Init(); 474 backend.Init();
474 SetUpMockKeyring(&backend);
475 475
476 // First add an unrelated login. 476 // First add an unrelated login.
477 BrowserThread::PostTask( 477 BrowserThread::PostTask(
478 BrowserThread::DB, FROM_HERE, 478 BrowserThread::DB, FROM_HERE,
479 base::Bind(base::IgnoreResult(&NativeBackendGnome::AddLogin), 479 base::Bind(base::IgnoreResult(&NativeBackendGnome::AddLogin),
480 base::Unretained(&backend), form_google_)); 480 base::Unretained(&backend), form_google_));
481 481
482 RunBothThreads(); 482 RunBothThreads();
483 483
484 EXPECT_EQ(1u, mock_keyring_items.size()); 484 EXPECT_EQ(1u, mock_keyring_items.size());
(...skipping 24 matching lines...) Expand all
509 if (mock_keyring_items.size() > 0) 509 if (mock_keyring_items.size() > 0)
510 CheckMockKeyringItem(&mock_keyring_items[0], form_google_, "chrome-42"); 510 CheckMockKeyringItem(&mock_keyring_items[0], form_google_, "chrome-42");
511 } 511 }
512 512
513 TEST_F(NativeBackendGnomeTest, AddDuplicateLogin) { 513 TEST_F(NativeBackendGnomeTest, AddDuplicateLogin) {
514 // Pretend that the migration has already taken place. 514 // Pretend that the migration has already taken place.
515 profile_.GetPrefs()->SetBoolean(prefs::kPasswordsUseLocalProfileId, true); 515 profile_.GetPrefs()->SetBoolean(prefs::kPasswordsUseLocalProfileId, true);
516 516
517 NativeBackendGnome backend(42, profile_.GetPrefs()); 517 NativeBackendGnome backend(42, profile_.GetPrefs());
518 backend.Init(); 518 backend.Init();
519 SetUpMockKeyring(&backend);
520 519
521 BrowserThread::PostTask( 520 BrowserThread::PostTask(
522 BrowserThread::DB, FROM_HERE, 521 BrowserThread::DB, FROM_HERE,
523 base::Bind(base::IgnoreResult(&NativeBackendGnome::AddLogin), 522 base::Bind(base::IgnoreResult(&NativeBackendGnome::AddLogin),
524 base::Unretained(&backend), form_google_)); 523 base::Unretained(&backend), form_google_));
525 BrowserThread::PostTask( 524 BrowserThread::PostTask(
526 BrowserThread::DB, FROM_HERE, 525 BrowserThread::DB, FROM_HERE,
527 base::Bind(base::IgnoreResult(&NativeBackendGnome::AddLogin), 526 base::Bind(base::IgnoreResult(&NativeBackendGnome::AddLogin),
528 base::Unretained(&backend), form_google_)); 527 base::Unretained(&backend), form_google_));
529 528
530 RunBothThreads(); 529 RunBothThreads();
531 530
532 EXPECT_EQ(1u, mock_keyring_items.size()); 531 EXPECT_EQ(1u, mock_keyring_items.size());
533 if (mock_keyring_items.size() > 0) 532 if (mock_keyring_items.size() > 0)
534 CheckMockKeyringItem(&mock_keyring_items[0], form_google_, "chrome-42"); 533 CheckMockKeyringItem(&mock_keyring_items[0], form_google_, "chrome-42");
535 } 534 }
536 535
537 TEST_F(NativeBackendGnomeTest, ListLoginsAppends) { 536 TEST_F(NativeBackendGnomeTest, ListLoginsAppends) {
538 // Pretend that the migration has already taken place. 537 // Pretend that the migration has already taken place.
539 profile_.GetPrefs()->SetBoolean(prefs::kPasswordsUseLocalProfileId, true); 538 profile_.GetPrefs()->SetBoolean(prefs::kPasswordsUseLocalProfileId, true);
540 539
541 NativeBackendGnome backend(42, profile_.GetPrefs()); 540 NativeBackendGnome backend(42, profile_.GetPrefs());
542 backend.Init(); 541 backend.Init();
543 SetUpMockKeyring(&backend);
544 542
545 BrowserThread::PostTask( 543 BrowserThread::PostTask(
546 BrowserThread::DB, FROM_HERE, 544 BrowserThread::DB, FROM_HERE,
547 base::Bind(base::IgnoreResult(&NativeBackendGnome::AddLogin), 545 base::Bind(base::IgnoreResult(&NativeBackendGnome::AddLogin),
548 base::Unretained(&backend), form_google_)); 546 base::Unretained(&backend), form_google_));
549 547
550 // Send the same request twice with the same list both times. 548 // Send the same request twice with the same list both times.
551 std::vector<PasswordForm*> form_list; 549 std::vector<PasswordForm*> form_list;
552 BrowserThread::PostTask( 550 BrowserThread::PostTask(
553 BrowserThread::DB, FROM_HERE, 551 BrowserThread::DB, FROM_HERE,
(...skipping 19 matching lines...) Expand all
573 571
574 // TODO(mdm): add more basic (i.e. non-migration) tests here at some point. 572 // TODO(mdm): add more basic (i.e. non-migration) tests here at some point.
575 573
576 TEST_F(NativeBackendGnomeTest, DISABLED_MigrateOneLogin) { 574 TEST_F(NativeBackendGnomeTest, DISABLED_MigrateOneLogin) {
577 // Reject attempts to migrate so we can populate the store. 575 // Reject attempts to migrate so we can populate the store.
578 mock_keyring_reject_local_ids = true; 576 mock_keyring_reject_local_ids = true;
579 577
580 { 578 {
581 NativeBackendGnome backend(42, profile_.GetPrefs()); 579 NativeBackendGnome backend(42, profile_.GetPrefs());
582 backend.Init(); 580 backend.Init();
583 SetUpMockKeyring(&backend);
584 581
585 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE, 582 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
586 base::Bind(base::IgnoreResult(&NativeBackendGnome::AddLogin), 583 base::Bind(base::IgnoreResult(&NativeBackendGnome::AddLogin),
587 base::Unretained(&backend), form_google_)); 584 base::Unretained(&backend), form_google_));
588 585
589 // Make sure we can get the form back even when migration is failing. 586 // Make sure we can get the form back even when migration is failing.
590 std::vector<PasswordForm*> form_list; 587 std::vector<PasswordForm*> form_list;
591 BrowserThread::PostTask( 588 BrowserThread::PostTask(
592 BrowserThread::DB, FROM_HERE, 589 BrowserThread::DB, FROM_HERE,
593 base::Bind( 590 base::Bind(
(...skipping 10 matching lines...) Expand all
604 EXPECT_EQ(1u, mock_keyring_items.size()); 601 EXPECT_EQ(1u, mock_keyring_items.size());
605 if (mock_keyring_items.size() > 0) 602 if (mock_keyring_items.size() > 0)
606 CheckMockKeyringItem(&mock_keyring_items[0], form_google_, "chrome"); 603 CheckMockKeyringItem(&mock_keyring_items[0], form_google_, "chrome");
607 604
608 // Now allow the migration. 605 // Now allow the migration.
609 mock_keyring_reject_local_ids = false; 606 mock_keyring_reject_local_ids = false;
610 607
611 { 608 {
612 NativeBackendGnome backend(42, profile_.GetPrefs()); 609 NativeBackendGnome backend(42, profile_.GetPrefs());
613 backend.Init(); 610 backend.Init();
614 SetUpMockKeyring(&backend);
615 611
616 // This should not trigger migration because there will be no results. 612 // This should not trigger migration because there will be no results.
617 std::vector<PasswordForm*> form_list; 613 std::vector<PasswordForm*> form_list;
618 BrowserThread::PostTask( 614 BrowserThread::PostTask(
619 BrowserThread::DB, FROM_HERE, 615 BrowserThread::DB, FROM_HERE,
620 base::Bind(base::IgnoreResult(&NativeBackendGnome::GetBlacklistLogins), 616 base::Bind(base::IgnoreResult(&NativeBackendGnome::GetBlacklistLogins),
621 base::Unretained(&backend), &form_list)); 617 base::Unretained(&backend), &form_list));
622 618
623 RunBothThreads(); 619 RunBothThreads();
624 620
625 // Check that we got nothing back. 621 // Check that we got nothing back.
626 EXPECT_EQ(0u, form_list.size()); 622 EXPECT_EQ(0u, form_list.size());
627 STLDeleteElements(&form_list); 623 STLDeleteElements(&form_list);
628 } 624 }
629 625
630 // Check that the keyring is unmodified. 626 // Check that the keyring is unmodified.
631 EXPECT_EQ(1u, mock_keyring_items.size()); 627 EXPECT_EQ(1u, mock_keyring_items.size());
632 if (mock_keyring_items.size() > 0) 628 if (mock_keyring_items.size() > 0)
633 CheckMockKeyringItem(&mock_keyring_items[0], form_google_, "chrome"); 629 CheckMockKeyringItem(&mock_keyring_items[0], form_google_, "chrome");
634 630
635 // Check that we haven't set the persistent preference. 631 // Check that we haven't set the persistent preference.
636 EXPECT_FALSE( 632 EXPECT_FALSE(
637 profile_.GetPrefs()->GetBoolean(prefs::kPasswordsUseLocalProfileId)); 633 profile_.GetPrefs()->GetBoolean(prefs::kPasswordsUseLocalProfileId));
638 634
639 { 635 {
640 NativeBackendGnome backend(42, profile_.GetPrefs()); 636 NativeBackendGnome backend(42, profile_.GetPrefs());
641 backend.Init(); 637 backend.Init();
642 SetUpMockKeyring(&backend);
643 638
644 // Trigger the migration by looking something up. 639 // Trigger the migration by looking something up.
645 std::vector<PasswordForm*> form_list; 640 std::vector<PasswordForm*> form_list;
646 BrowserThread::PostTask( 641 BrowserThread::PostTask(
647 BrowserThread::DB, FROM_HERE, 642 BrowserThread::DB, FROM_HERE,
648 base::Bind( 643 base::Bind(
649 base::IgnoreResult(&NativeBackendGnome::GetAutofillableLogins), 644 base::IgnoreResult(&NativeBackendGnome::GetAutofillableLogins),
650 base::Unretained(&backend), &form_list)); 645 base::Unretained(&backend), &form_list));
651 646
652 RunBothThreads(); 647 RunBothThreads();
(...skipping 14 matching lines...) Expand all
667 profile_.GetPrefs()->GetBoolean(prefs::kPasswordsUseLocalProfileId)); 662 profile_.GetPrefs()->GetBoolean(prefs::kPasswordsUseLocalProfileId));
668 } 663 }
669 664
670 TEST_F(NativeBackendGnomeTest, DISABLED_MigrateToMultipleProfiles) { 665 TEST_F(NativeBackendGnomeTest, DISABLED_MigrateToMultipleProfiles) {
671 // Reject attempts to migrate so we can populate the store. 666 // Reject attempts to migrate so we can populate the store.
672 mock_keyring_reject_local_ids = true; 667 mock_keyring_reject_local_ids = true;
673 668
674 { 669 {
675 NativeBackendGnome backend(42, profile_.GetPrefs()); 670 NativeBackendGnome backend(42, profile_.GetPrefs());
676 backend.Init(); 671 backend.Init();
677 SetUpMockKeyring(&backend);
678 672
679 BrowserThread::PostTask( 673 BrowserThread::PostTask(
680 BrowserThread::DB, FROM_HERE, 674 BrowserThread::DB, FROM_HERE,
681 base::Bind(base::IgnoreResult(&NativeBackendGnome::AddLogin), 675 base::Bind(base::IgnoreResult(&NativeBackendGnome::AddLogin),
682 base::Unretained(&backend), form_google_)); 676 base::Unretained(&backend), form_google_));
683 677
684 RunBothThreads(); 678 RunBothThreads();
685 } 679 }
686 680
687 EXPECT_EQ(1u, mock_keyring_items.size()); 681 EXPECT_EQ(1u, mock_keyring_items.size());
688 if (mock_keyring_items.size() > 0) 682 if (mock_keyring_items.size() > 0)
689 CheckMockKeyringItem(&mock_keyring_items[0], form_google_, "chrome"); 683 CheckMockKeyringItem(&mock_keyring_items[0], form_google_, "chrome");
690 684
691 // Now allow the migration. 685 // Now allow the migration.
692 mock_keyring_reject_local_ids = false; 686 mock_keyring_reject_local_ids = false;
693 687
694 { 688 {
695 NativeBackendGnome backend(42, profile_.GetPrefs()); 689 NativeBackendGnome backend(42, profile_.GetPrefs());
696 backend.Init(); 690 backend.Init();
697 SetUpMockKeyring(&backend);
698 691
699 // Trigger the migration by looking something up. 692 // Trigger the migration by looking something up.
700 std::vector<PasswordForm*> form_list; 693 std::vector<PasswordForm*> form_list;
701 BrowserThread::PostTask( 694 BrowserThread::PostTask(
702 BrowserThread::DB, FROM_HERE, 695 BrowserThread::DB, FROM_HERE,
703 base::Bind( 696 base::Bind(
704 base::IgnoreResult(&NativeBackendGnome::GetAutofillableLogins), 697 base::IgnoreResult(&NativeBackendGnome::GetAutofillableLogins),
705 base::Unretained(&backend), &form_list)); 698 base::Unretained(&backend), &form_list));
706 699
707 RunBothThreads(); 700 RunBothThreads();
(...skipping 13 matching lines...) Expand all
721 EXPECT_TRUE( 714 EXPECT_TRUE(
722 profile_.GetPrefs()->GetBoolean(prefs::kPasswordsUseLocalProfileId)); 715 profile_.GetPrefs()->GetBoolean(prefs::kPasswordsUseLocalProfileId));
723 716
724 // Normally we'd actually have a different profile. But in the test just reset 717 // Normally we'd actually have a different profile. But in the test just reset
725 // the profile's persistent pref; we pass in the local profile id anyway. 718 // the profile's persistent pref; we pass in the local profile id anyway.
726 profile_.GetPrefs()->SetBoolean(prefs::kPasswordsUseLocalProfileId, false); 719 profile_.GetPrefs()->SetBoolean(prefs::kPasswordsUseLocalProfileId, false);
727 720
728 { 721 {
729 NativeBackendGnome backend(24, profile_.GetPrefs()); 722 NativeBackendGnome backend(24, profile_.GetPrefs());
730 backend.Init(); 723 backend.Init();
731 SetUpMockKeyring(&backend);
732 724
733 // Trigger the migration by looking something up. 725 // Trigger the migration by looking something up.
734 std::vector<PasswordForm*> form_list; 726 std::vector<PasswordForm*> form_list;
735 BrowserThread::PostTask( 727 BrowserThread::PostTask(
736 BrowserThread::DB, FROM_HERE, 728 BrowserThread::DB, FROM_HERE,
737 base::Bind( 729 base::Bind(
738 base::IgnoreResult(&NativeBackendGnome::GetAutofillableLogins), 730 base::IgnoreResult(&NativeBackendGnome::GetAutofillableLogins),
739 base::Unretained(&backend), &form_list)); 731 base::Unretained(&backend), &form_list));
740 732
741 RunBothThreads(); 733 RunBothThreads();
(...skipping 12 matching lines...) Expand all
754 CheckMockKeyringItem(&mock_keyring_items[2], form_google_, "chrome-24"); 746 CheckMockKeyringItem(&mock_keyring_items[2], form_google_, "chrome-24");
755 } 747 }
756 748
757 TEST_F(NativeBackendGnomeTest, DISABLED_NoMigrationWithPrefSet) { 749 TEST_F(NativeBackendGnomeTest, DISABLED_NoMigrationWithPrefSet) {
758 // Reject attempts to migrate so we can populate the store. 750 // Reject attempts to migrate so we can populate the store.
759 mock_keyring_reject_local_ids = true; 751 mock_keyring_reject_local_ids = true;
760 752
761 { 753 {
762 NativeBackendGnome backend(42, profile_.GetPrefs()); 754 NativeBackendGnome backend(42, profile_.GetPrefs());
763 backend.Init(); 755 backend.Init();
764 SetUpMockKeyring(&backend);
765 756
766 BrowserThread::PostTask( 757 BrowserThread::PostTask(
767 BrowserThread::DB, FROM_HERE, 758 BrowserThread::DB, FROM_HERE,
768 base::Bind(base::IgnoreResult(&NativeBackendGnome::AddLogin), 759 base::Bind(base::IgnoreResult(&NativeBackendGnome::AddLogin),
769 base::Unretained(&backend), form_google_)); 760 base::Unretained(&backend), form_google_));
770 761
771 RunBothThreads(); 762 RunBothThreads();
772 } 763 }
773 764
774 EXPECT_EQ(1u, mock_keyring_items.size()); 765 EXPECT_EQ(1u, mock_keyring_items.size());
775 if (mock_keyring_items.size() > 0) 766 if (mock_keyring_items.size() > 0)
776 CheckMockKeyringItem(&mock_keyring_items[0], form_google_, "chrome"); 767 CheckMockKeyringItem(&mock_keyring_items[0], form_google_, "chrome");
777 768
778 // Now allow migration, but also pretend that the it has already taken place. 769 // Now allow migration, but also pretend that the it has already taken place.
779 mock_keyring_reject_local_ids = false; 770 mock_keyring_reject_local_ids = false;
780 profile_.GetPrefs()->SetBoolean(prefs::kPasswordsUseLocalProfileId, true); 771 profile_.GetPrefs()->SetBoolean(prefs::kPasswordsUseLocalProfileId, true);
781 772
782 { 773 {
783 NativeBackendGnome backend(42, profile_.GetPrefs()); 774 NativeBackendGnome backend(42, profile_.GetPrefs());
784 backend.Init(); 775 backend.Init();
785 SetUpMockKeyring(&backend);
786 776
787 // Trigger the migration by adding a new login. 777 // Trigger the migration by adding a new login.
788 BrowserThread::PostTask( 778 BrowserThread::PostTask(
789 BrowserThread::DB, FROM_HERE, 779 BrowserThread::DB, FROM_HERE,
790 base::Bind(base::IgnoreResult(&NativeBackendGnome::AddLogin), 780 base::Bind(base::IgnoreResult(&NativeBackendGnome::AddLogin),
791 base::Unretained(&backend), form_isc_)); 781 base::Unretained(&backend), form_isc_));
792 782
793 // Look up all logins; we expect only the one we added. 783 // Look up all logins; we expect only the one we added.
794 std::vector<PasswordForm*> form_list; 784 std::vector<PasswordForm*> form_list;
795 BrowserThread::PostTask( 785 BrowserThread::PostTask(
(...skipping 18 matching lines...) Expand all
814 CheckMockKeyringItem(&mock_keyring_items[1], form_isc_, "chrome-42"); 804 CheckMockKeyringItem(&mock_keyring_items[1], form_isc_, "chrome-42");
815 } 805 }
816 806
817 TEST_F(NativeBackendGnomeTest, DISABLED_DeleteMigratedPasswordIsIsolated) { 807 TEST_F(NativeBackendGnomeTest, DISABLED_DeleteMigratedPasswordIsIsolated) {
818 // Reject attempts to migrate so we can populate the store. 808 // Reject attempts to migrate so we can populate the store.
819 mock_keyring_reject_local_ids = true; 809 mock_keyring_reject_local_ids = true;
820 810
821 { 811 {
822 NativeBackendGnome backend(42, profile_.GetPrefs()); 812 NativeBackendGnome backend(42, profile_.GetPrefs());
823 backend.Init(); 813 backend.Init();
824 SetUpMockKeyring(&backend);
825 814
826 BrowserThread::PostTask( 815 BrowserThread::PostTask(
827 BrowserThread::DB, FROM_HERE, 816 BrowserThread::DB, FROM_HERE,
828 base::Bind(base::IgnoreResult(&NativeBackendGnome::AddLogin), 817 base::Bind(base::IgnoreResult(&NativeBackendGnome::AddLogin),
829 base::Unretained(&backend), form_google_)); 818 base::Unretained(&backend), form_google_));
830 819
831 RunBothThreads(); 820 RunBothThreads();
832 } 821 }
833 822
834 EXPECT_EQ(1u, mock_keyring_items.size()); 823 EXPECT_EQ(1u, mock_keyring_items.size());
835 if (mock_keyring_items.size() > 0) 824 if (mock_keyring_items.size() > 0)
836 CheckMockKeyringItem(&mock_keyring_items[0], form_google_, "chrome"); 825 CheckMockKeyringItem(&mock_keyring_items[0], form_google_, "chrome");
837 826
838 // Now allow the migration. 827 // Now allow the migration.
839 mock_keyring_reject_local_ids = false; 828 mock_keyring_reject_local_ids = false;
840 829
841 { 830 {
842 NativeBackendGnome backend(42, profile_.GetPrefs()); 831 NativeBackendGnome backend(42, profile_.GetPrefs());
843 backend.Init(); 832 backend.Init();
844 SetUpMockKeyring(&backend);
845 833
846 // Trigger the migration by looking something up. 834 // Trigger the migration by looking something up.
847 std::vector<PasswordForm*> form_list; 835 std::vector<PasswordForm*> form_list;
848 BrowserThread::PostTask( 836 BrowserThread::PostTask(
849 BrowserThread::DB, FROM_HERE, 837 BrowserThread::DB, FROM_HERE,
850 base::Bind( 838 base::Bind(
851 base::IgnoreResult(&NativeBackendGnome::GetAutofillableLogins), 839 base::IgnoreResult(&NativeBackendGnome::GetAutofillableLogins),
852 base::Unretained(&backend), &form_list)); 840 base::Unretained(&backend), &form_list));
853 841
854 RunBothThreads(); 842 RunBothThreads();
(...skipping 13 matching lines...) Expand all
868 EXPECT_TRUE( 856 EXPECT_TRUE(
869 profile_.GetPrefs()->GetBoolean(prefs::kPasswordsUseLocalProfileId)); 857 profile_.GetPrefs()->GetBoolean(prefs::kPasswordsUseLocalProfileId));
870 858
871 // Normally we'd actually have a different profile. But in the test just reset 859 // Normally we'd actually have a different profile. But in the test just reset
872 // the profile's persistent pref; we pass in the local profile id anyway. 860 // the profile's persistent pref; we pass in the local profile id anyway.
873 profile_.GetPrefs()->SetBoolean(prefs::kPasswordsUseLocalProfileId, false); 861 profile_.GetPrefs()->SetBoolean(prefs::kPasswordsUseLocalProfileId, false);
874 862
875 { 863 {
876 NativeBackendGnome backend(24, profile_.GetPrefs()); 864 NativeBackendGnome backend(24, profile_.GetPrefs());
877 backend.Init(); 865 backend.Init();
878 SetUpMockKeyring(&backend);
879 866
880 // Trigger the migration by looking something up. 867 // Trigger the migration by looking something up.
881 std::vector<PasswordForm*> form_list; 868 std::vector<PasswordForm*> form_list;
882 BrowserThread::PostTask( 869 BrowserThread::PostTask(
883 BrowserThread::DB, FROM_HERE, 870 BrowserThread::DB, FROM_HERE,
884 base::Bind( 871 base::Bind(
885 base::IgnoreResult(&NativeBackendGnome::GetAutofillableLogins), 872 base::IgnoreResult(&NativeBackendGnome::GetAutofillableLogins),
886 base::Unretained(&backend), &form_list)); 873 base::Unretained(&backend), &form_list));
887 874
888 RunBothThreads(); 875 RunBothThreads();
(...skipping 20 matching lines...) Expand all
909 RunBothThreads(); 896 RunBothThreads();
910 897
911 // The other two copies of the password in different profiles should remain. 898 // The other two copies of the password in different profiles should remain.
912 EXPECT_EQ(2u, mock_keyring_items.size()); 899 EXPECT_EQ(2u, mock_keyring_items.size());
913 if (mock_keyring_items.size() > 0) 900 if (mock_keyring_items.size() > 0)
914 CheckMockKeyringItem(&mock_keyring_items[0], form_google_, "chrome"); 901 CheckMockKeyringItem(&mock_keyring_items[0], form_google_, "chrome");
915 if (mock_keyring_items.size() > 1) 902 if (mock_keyring_items.size() > 1)
916 CheckMockKeyringItem(&mock_keyring_items[1], form_google_, "chrome-42"); 903 CheckMockKeyringItem(&mock_keyring_items[1], form_google_, "chrome-42");
917 } 904 }
918 } 905 }
OLDNEW
« no previous file with comments | « chrome/browser/password_manager/native_backend_gnome_x.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698