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

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

Issue 7712024: Linux: support append to password list in the GNOME keyring backend to fix initial password sync. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 4 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 &NativeBackendGnome::AddLogin, 532 &NativeBackendGnome::AddLogin,
533 form_google_)); 533 form_google_));
534 534
535 RunBothThreads(); 535 RunBothThreads();
536 536
537 EXPECT_EQ(1u, mock_keyring_items.size()); 537 EXPECT_EQ(1u, mock_keyring_items.size());
538 if (mock_keyring_items.size() > 0) 538 if (mock_keyring_items.size() > 0)
539 CheckMockKeyringItem(&mock_keyring_items[0], form_google_, "chrome-42"); 539 CheckMockKeyringItem(&mock_keyring_items[0], form_google_, "chrome-42");
540 } 540 }
541 541
542 TEST_F(NativeBackendGnomeTest, ListLoginsAppends) {
543 // Pretend that the migration has already taken place.
544 profile_->GetPrefs()->SetBoolean(prefs::kPasswordsUseLocalProfileId, true);
545
546 NativeBackendGnome backend(42, profile_->GetPrefs());
547 backend.Init();
548
549 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
550 NewRunnableMethod(&backend,
551 &NativeBackendGnome::AddLogin,
552 form_google_));
553
554 // Send the same request twice with the same list both times.
555 std::vector<PasswordForm*> form_list;
556 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
557 NewRunnableMethod(&backend,
558 &NativeBackendGnome::GetAutofillableLogins,
559 &form_list));
560 BrowserThread::PostTask(BrowserThread::DB, FROM_HERE,
561 NewRunnableMethod(&backend,
562 &NativeBackendGnome::GetAutofillableLogins,
563 &form_list));
564
565 RunBothThreads();
566
567 // Quick check that we got two results back.
568 EXPECT_EQ(2u, form_list.size());
569 STLDeleteElements(&form_list);
570
571 EXPECT_EQ(1u, mock_keyring_items.size());
572 if (mock_keyring_items.size() > 0)
573 CheckMockKeyringItem(&mock_keyring_items[0], form_google_, "chrome-42");
574 }
575
542 // TODO(mdm): add more basic (i.e. non-migration) tests here at some point. 576 // TODO(mdm): add more basic (i.e. non-migration) tests here at some point.
543 577
544 TEST_F(NativeBackendGnomeTest, MigrateOneLogin) { 578 TEST_F(NativeBackendGnomeTest, MigrateOneLogin) {
545 // Reject attempts to migrate so we can populate the store. 579 // Reject attempts to migrate so we can populate the store.
546 mock_keyring_reject_local_ids = true; 580 mock_keyring_reject_local_ids = true;
547 581
548 { 582 {
549 NativeBackendGnome backend(42, profile_->GetPrefs()); 583 NativeBackendGnome backend(42, profile_->GetPrefs());
550 backend.Init(); 584 backend.Init();
551 585
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 RunBothThreads(); 894 RunBothThreads();
861 895
862 // The other two copies of the password in different profiles should remain. 896 // The other two copies of the password in different profiles should remain.
863 EXPECT_EQ(2u, mock_keyring_items.size()); 897 EXPECT_EQ(2u, mock_keyring_items.size());
864 if (mock_keyring_items.size() > 0) 898 if (mock_keyring_items.size() > 0)
865 CheckMockKeyringItem(&mock_keyring_items[0], form_google_, "chrome"); 899 CheckMockKeyringItem(&mock_keyring_items[0], form_google_, "chrome");
866 if (mock_keyring_items.size() > 1) 900 if (mock_keyring_items.size() > 1)
867 CheckMockKeyringItem(&mock_keyring_items[1], form_google_, "chrome-42"); 901 CheckMockKeyringItem(&mock_keyring_items[1], form_google_, "chrome-42");
868 } 902 }
869 } 903 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698