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

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

Issue 299443002: Password Login Database: report correct changes from UpdateLogin(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added UpdateNonexistentLogin tests Created 6 years, 7 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 <algorithm> 5 #include <algorithm>
6 #include <map> 6 #include <map>
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 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 533
534 EXPECT_FALSE(wallet_.hasFolder("Chrome Form Data")); 534 EXPECT_FALSE(wallet_.hasFolder("Chrome Form Data"));
535 535
536 std::vector<const PasswordForm*> forms; 536 std::vector<const PasswordForm*> forms;
537 forms.push_back(&form_google_); 537 forms.push_back(&form_google_);
538 ExpectationArray expected; 538 ExpectationArray expected;
539 expected.push_back(make_pair(std::string(form_google_.signon_realm), forms)); 539 expected.push_back(make_pair(std::string(form_google_.signon_realm), forms));
540 CheckPasswordForms("Chrome Form Data (42)", expected); 540 CheckPasswordForms("Chrome Form Data (42)", expected);
541 } 541 }
542 542
543 TEST_F(NativeBackendKWalletTest, BasicUpdateLogin) {
544 NativeBackendKWalletStub backend(42);
545 EXPECT_TRUE(backend.InitWithBus(mock_session_bus_));
546
547 BrowserThread::PostTask(
548 BrowserThread::DB, FROM_HERE,
549 base::Bind(base::IgnoreResult(&NativeBackendKWalletStub::AddLogin),
550 base::Unretained(&backend), form_google_));
551
552 RunDBThread();
553
554 PasswordForm new_form_google(form_google_);
555 new_form_google.times_used = 10;
556 new_form_google.action = GURL("http://www.google.com/different/login");
557
558 // Update login
559 PasswordStoreChangeList changes;
560 BrowserThread::PostTask(
561 BrowserThread::DB, FROM_HERE,
562 base::Bind(base::IgnoreResult(&NativeBackendKWalletStub::UpdateLogin),
563 base::Unretained(&backend),
564 new_form_google,
565 base::Unretained(&changes)));
566 RunDBThread();
567
568 ASSERT_EQ(1u, changes.size());
569 EXPECT_EQ(PasswordStoreChange::UPDATE, changes.front().type());
570 EXPECT_EQ(new_form_google, changes.front().form());
571
572 std::vector<const PasswordForm*> forms;
573 forms.push_back(&new_form_google);
574 ExpectationArray expected;
575 expected.push_back(make_pair(std::string(form_google_.signon_realm), forms));
576 CheckPasswordForms("Chrome Form Data (42)", expected);
577 }
578
543 TEST_F(NativeBackendKWalletTest, BasicListLogins) { 579 TEST_F(NativeBackendKWalletTest, BasicListLogins) {
544 NativeBackendKWalletStub backend(42); 580 NativeBackendKWalletStub backend(42);
545 EXPECT_TRUE(backend.InitWithBus(mock_session_bus_)); 581 EXPECT_TRUE(backend.InitWithBus(mock_session_bus_));
546 582
547 BrowserThread::PostTask( 583 BrowserThread::PostTask(
548 BrowserThread::DB, FROM_HERE, 584 BrowserThread::DB, FROM_HERE,
549 base::Bind(base::IgnoreResult(&NativeBackendKWalletStub::AddLogin), 585 base::Bind(base::IgnoreResult(&NativeBackendKWalletStub::AddLogin),
550 base::Unretained(&backend), form_google_)); 586 base::Unretained(&backend), form_google_));
551 587
552 std::vector<PasswordForm*> form_list; 588 std::vector<PasswordForm*> form_list;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 BrowserThread::DB, FROM_HERE, 630 BrowserThread::DB, FROM_HERE,
595 base::Bind(base::IgnoreResult(&NativeBackendKWalletStub::RemoveLogin), 631 base::Bind(base::IgnoreResult(&NativeBackendKWalletStub::RemoveLogin),
596 base::Unretained(&backend), form_google_)); 632 base::Unretained(&backend), form_google_));
597 633
598 RunDBThread(); 634 RunDBThread();
599 635
600 expected.clear(); 636 expected.clear();
601 CheckPasswordForms("Chrome Form Data (42)", expected); 637 CheckPasswordForms("Chrome Form Data (42)", expected);
602 } 638 }
603 639
640 TEST_F(NativeBackendKWalletTest, UpdateNonexistentLogin) {
641 NativeBackendKWalletStub backend(42);
642 EXPECT_TRUE(backend.InitWithBus(mock_session_bus_));
643
644 // First add an unrelated login.
645 BrowserThread::PostTask(
646 BrowserThread::DB, FROM_HERE,
647 base::Bind(base::IgnoreResult(&NativeBackendKWalletStub::AddLogin),
648 base::Unretained(&backend), form_google_));
649
650 RunDBThread();
651
652 std::vector<const PasswordForm*> forms;
653 forms.push_back(&form_google_);
654 ExpectationArray expected;
655 expected.push_back(make_pair(std::string(form_google_.signon_realm), forms));
656 CheckPasswordForms("Chrome Form Data (42)", expected);
657
658 // Attempt to update a login that doesn't exist.
659 PasswordStoreChangeList changes;
660 BrowserThread::PostTask(
661 BrowserThread::DB, FROM_HERE,
662 base::Bind(base::IgnoreResult(&NativeBackendKWalletStub::UpdateLogin),
663 base::Unretained(&backend),
664 form_isc_,
665 base::Unretained(&changes)));
666
667 RunDBThread();
668
669 EXPECT_EQ(PasswordStoreChangeList(), changes);
670 CheckPasswordForms("Chrome Form Data (42)", expected);
671 }
672
604 TEST_F(NativeBackendKWalletTest, RemoveNonexistentLogin) { 673 TEST_F(NativeBackendKWalletTest, RemoveNonexistentLogin) {
605 NativeBackendKWalletStub backend(42); 674 NativeBackendKWalletStub backend(42);
606 EXPECT_TRUE(backend.InitWithBus(mock_session_bus_)); 675 EXPECT_TRUE(backend.InitWithBus(mock_session_bus_));
607 676
608 // First add an unrelated login. 677 // First add an unrelated login.
609 BrowserThread::PostTask( 678 BrowserThread::PostTask(
610 BrowserThread::DB, FROM_HERE, 679 BrowserThread::DB, FROM_HERE,
611 base::Bind(base::IgnoreResult(&NativeBackendKWalletStub::AddLogin), 680 base::Bind(base::IgnoreResult(&NativeBackendKWalletStub::AddLogin),
612 base::Unretained(&backend), form_google_)); 681 base::Unretained(&backend), form_google_));
613 682
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 CheckVersion0Pickle(false, PasswordForm::SCHEME_HTML); 890 CheckVersion0Pickle(false, PasswordForm::SCHEME_HTML);
822 } 891 }
823 892
824 TEST_F(NativeBackendKWalletPickleTest, ReadsOld64BitHTTPPickles) { 893 TEST_F(NativeBackendKWalletPickleTest, ReadsOld64BitHTTPPickles) {
825 CheckVersion0Pickle(false, PasswordForm::SCHEME_BASIC); 894 CheckVersion0Pickle(false, PasswordForm::SCHEME_BASIC);
826 } 895 }
827 896
828 TEST_F(NativeBackendKWalletPickleTest, CheckVersion1Pickle) { 897 TEST_F(NativeBackendKWalletPickleTest, CheckVersion1Pickle) {
829 CheckVersion1Pickle(); 898 CheckVersion1Pickle();
830 } 899 }
OLDNEW
« no previous file with comments | « chrome/browser/password_manager/native_backend_kwallet_x.cc ('k') | chrome/browser/password_manager/password_store_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698