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

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

Issue 1314903003: Updating of all entries in PasswordManager of the same credentials on password update (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed strings from progress loader Created 5 years, 3 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
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/location.h" 8 #include "base/location.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/single_thread_task_runner.h" 10 #include "base/single_thread_task_runner.h"
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 base::Bind(&NativeBackendGnome::GetLogins, 575 base::Bind(&NativeBackendGnome::GetLogins,
576 base::Unretained(&backend), 576 base::Unretained(&backend),
577 m_facebook_lookup, 577 m_facebook_lookup,
578 &form_list), 578 &form_list),
579 base::Bind(&CheckTrue)); 579 base::Bind(&CheckTrue));
580 RunBothThreads(); 580 RunBothThreads();
581 EXPECT_EQ(1u, mock_keyring_items.size()); 581 EXPECT_EQ(1u, mock_keyring_items.size());
582 EXPECT_EQ(1u, form_list.size()); 582 EXPECT_EQ(1u, form_list.size());
583 PasswordForm m_facebook = *form_list[0]; 583 PasswordForm m_facebook = *form_list[0];
584 form_list.clear(); 584 form_list.clear();
585 EXPECT_EQ(kMobileURL, m_facebook.origin); 585 m_facebook.origin = kMobileURL;
586 EXPECT_EQ(kMobileURL.spec(), m_facebook.signon_realm); 586 m_facebook.signon_realm = kMobileURL.spec();
587 587
588 // Add the PSL-matched copy to saved logins. 588 // Add the PSL-matched copy to saved logins.
589 BrowserThread::PostTask( 589 BrowserThread::PostTask(
590 BrowserThread::DB, 590 BrowserThread::DB,
591 FROM_HERE, 591 FROM_HERE,
592 base::Bind(base::IgnoreResult(&NativeBackendGnome::AddLogin), 592 base::Bind(base::IgnoreResult(&NativeBackendGnome::AddLogin),
593 base::Unretained(&backend), 593 base::Unretained(&backend),
594 m_facebook)); 594 m_facebook));
595 RunBothThreads(); 595 RunBothThreads();
596 EXPECT_EQ(2u, mock_keyring_items.size()); 596 EXPECT_EQ(2u, mock_keyring_items.size());
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 FROM_HERE, 641 FROM_HERE,
642 base::Bind(&NativeBackendGnome::GetLogins, 642 base::Bind(&NativeBackendGnome::GetLogins,
643 base::Unretained(&backend), 643 base::Unretained(&backend),
644 m_facebook_lookup, 644 m_facebook_lookup,
645 &form_list), 645 &form_list),
646 base::Bind(&CheckTrue)); 646 base::Bind(&CheckTrue));
647 RunBothThreads(); 647 RunBothThreads();
648 // There should be two results -- the exact one, and the PSL-matched one. 648 // There should be two results -- the exact one, and the PSL-matched one.
649 EXPECT_EQ(2u, form_list.size()); 649 EXPECT_EQ(2u, form_list.size());
650 size_t index_non_psl = 0; 650 size_t index_non_psl = 0;
651 if (!form_list[index_non_psl]->original_signon_realm.empty()) 651 if (form_list[index_non_psl]->IsPublicSuffixMatch())
652 index_non_psl = 1; 652 index_non_psl = 1;
653 EXPECT_EQ(kMobileURL, form_list[index_non_psl]->origin); 653 EXPECT_EQ(kMobileURL, form_list[index_non_psl]->origin);
654 EXPECT_EQ(kMobileURL.spec(), form_list[index_non_psl]->signon_realm); 654 EXPECT_EQ(kMobileURL.spec(), form_list[index_non_psl]->signon_realm);
655 EXPECT_EQ(kOldPassword, form_list[index_non_psl]->password_value); 655 EXPECT_EQ(kOldPassword, form_list[index_non_psl]->password_value);
656 form_list.clear(); 656 form_list.clear();
657 657
658 // Check that www.facebook.com login was modified by the update. 658 // Check that www.facebook.com login was modified by the update.
659 BrowserThread::PostTaskAndReplyWithResult( 659 BrowserThread::PostTaskAndReplyWithResult(
660 BrowserThread::DB, 660 BrowserThread::DB,
661 FROM_HERE, 661 FROM_HERE,
662 base::Bind(&NativeBackendGnome::GetLogins, 662 base::Bind(&NativeBackendGnome::GetLogins,
663 base::Unretained(&backend), 663 base::Unretained(&backend),
664 form_facebook_, 664 form_facebook_,
665 &form_list), 665 &form_list),
666 base::Bind(&CheckTrue)); 666 base::Bind(&CheckTrue));
667 RunBothThreads(); 667 RunBothThreads();
668 // There should be two results -- the exact one, and the PSL-matched one. 668 // There should be two results -- the exact one, and the PSL-matched one.
669 EXPECT_EQ(2u, form_list.size()); 669 EXPECT_EQ(2u, form_list.size());
670 index_non_psl = 0; 670 index_non_psl = 0;
671 if (!form_list[index_non_psl]->original_signon_realm.empty()) 671 if (form_list[index_non_psl]->IsPublicSuffixMatch())
672 index_non_psl = 1; 672 index_non_psl = 1;
673 EXPECT_EQ(form_facebook_.origin, form_list[index_non_psl]->origin); 673 EXPECT_EQ(form_facebook_.origin, form_list[index_non_psl]->origin);
674 EXPECT_EQ(form_facebook_.signon_realm, 674 EXPECT_EQ(form_facebook_.signon_realm,
675 form_list[index_non_psl]->signon_realm); 675 form_list[index_non_psl]->signon_realm);
676 EXPECT_EQ(kNewPassword, form_list[index_non_psl]->password_value); 676 EXPECT_EQ(kNewPassword, form_list[index_non_psl]->password_value);
677 } 677 }
678 678
679 void CheckMatchingWithScheme(const PasswordForm::Scheme& scheme) { 679 void CheckMatchingWithScheme(const PasswordForm::Scheme& scheme) {
680 other_auth_.scheme = scheme; 680 other_auth_.scheme = scheme;
681 681
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
824 if (mock_keyring_items.size() > 0) 824 if (mock_keyring_items.size() > 0)
825 CheckMockKeyringItem(&mock_keyring_items[0], form_google_, "chrome-42"); 825 CheckMockKeyringItem(&mock_keyring_items[0], form_google_, "chrome-42");
826 } 826 }
827 827
828 // Save a password for www.facebook.com and see it suggested for m.facebook.com. 828 // Save a password for www.facebook.com and see it suggested for m.facebook.com.
829 TEST_F(NativeBackendGnomeTest, PSLMatchingPositive) { 829 TEST_F(NativeBackendGnomeTest, PSLMatchingPositive) {
830 PasswordForm result; 830 PasswordForm result;
831 const GURL kMobileURL("http://m.facebook.com/"); 831 const GURL kMobileURL("http://m.facebook.com/");
832 EXPECT_TRUE(CheckCredentialAvailability( 832 EXPECT_TRUE(CheckCredentialAvailability(
833 form_facebook_, kMobileURL, PasswordForm::SCHEME_HTML, &result)); 833 form_facebook_, kMobileURL, PasswordForm::SCHEME_HTML, &result));
834 EXPECT_EQ(kMobileURL, result.origin); 834 EXPECT_EQ(form_facebook_.origin, result.origin);
835 EXPECT_EQ(kMobileURL.spec(), result.signon_realm); 835 EXPECT_EQ(form_facebook_.signon_realm, result.signon_realm);
836 } 836 }
837 837
838 // Save a password for www.facebook.com and see it not suggested for 838 // Save a password for www.facebook.com and see it not suggested for
839 // m-facebook.com. 839 // m-facebook.com.
840 TEST_F(NativeBackendGnomeTest, PSLMatchingNegativeDomainMismatch) { 840 TEST_F(NativeBackendGnomeTest, PSLMatchingNegativeDomainMismatch) {
841 EXPECT_FALSE(CheckCredentialAvailability( 841 EXPECT_FALSE(CheckCredentialAvailability(
842 form_facebook_, GURL("http://m-facebook.com/"), 842 form_facebook_, GURL("http://m-facebook.com/"),
843 PasswordForm::SCHEME_HTML, nullptr)); 843 PasswordForm::SCHEME_HTML, nullptr));
844 } 844 }
845 845
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
1197 1197
1198 EXPECT_EQ(1u, form_list.size()); 1198 EXPECT_EQ(1u, form_list.size());
1199 EXPECT_EQ(form_google_, *form_list[0]); 1199 EXPECT_EQ(form_google_, *form_list[0]);
1200 1200
1201 EXPECT_EQ(1u, mock_keyring_items.size()); 1201 EXPECT_EQ(1u, mock_keyring_items.size());
1202 if (mock_keyring_items.size() > 0) 1202 if (mock_keyring_items.size() > 0)
1203 CheckMockKeyringItem(&mock_keyring_items[0], form_google_, "chrome-42"); 1203 CheckMockKeyringItem(&mock_keyring_items[0], form_google_, "chrome-42");
1204 } 1204 }
1205 1205
1206 // TODO(mdm): add more basic tests here at some point. 1206 // TODO(mdm): add more basic tests here at some point.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698