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

Side by Side Diff: components/password_manager/core/browser/password_form_manager_unittest.cc

Issue 241033002: Fix for scoring password autofill candidates: (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Indexing fix 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
« no previous file with comments | « components/password_manager/core/browser/password_form_manager.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 "base/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "base/message_loop/message_loop.h" 6 #include "base/message_loop/message_loop.h"
7 #include "base/prefs/pref_registry_simple.h" 7 #include "base/prefs/pref_registry_simple.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/prefs/testing_pref_service.h" 9 #include "base/prefs/testing_pref_service.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 form_manager.ProvisionallySave( 695 form_manager.ProvisionallySave(
696 complete_form, PasswordFormManager::IGNORE_OTHER_POSSIBLE_USERNAMES); 696 complete_form, PasswordFormManager::IGNORE_OTHER_POSSIBLE_USERNAMES);
697 // By now that form has been used once. 697 // By now that form has been used once.
698 complete_form.times_used = 1; 698 complete_form.times_used = 1;
699 699
700 // Check that PasswordStore receives an update request with the complete form. 700 // Check that PasswordStore receives an update request with the complete form.
701 EXPECT_CALL(*mock_store(), UpdateLogin(complete_form)); 701 EXPECT_CALL(*mock_store(), UpdateLogin(complete_form));
702 form_manager.Save(); 702 form_manager.Save();
703 } 703 }
704 704
705 TEST_F(PasswordFormManagerTest, TestScoringPublicSuffixMatch) {
706 base::MessageLoop message_loop;
707
708 TestPasswordManagerClient client(NULL);
709 MockPasswordManagerDriver driver;
710 EXPECT_CALL(driver, IsOffTheRecord()).WillRepeatedly(Return(false));
711 EXPECT_CALL(driver, AllowPasswordGenerationForForm(_));
712
713 TestPasswordManager password_manager(&client);
714 scoped_ptr<PasswordFormManager> manager(new PasswordFormManager(
715 &password_manager, &client, &driver, *observed_form(), false));
716
717 // Simulate having two matches for this form, first comes from different
718 // signon realm, but reports the same origin and action as matched form.
719 // Second candidate has the same signon realm as the form, but has a different
720 // origin and action. Public suffix match is the most important criterion so
721 // the second candidate should be selected.
722 std::vector<PasswordForm*> results;
723 results.push_back(CreateSavedMatch(false));
724 results.push_back(CreateSavedMatch(false));
725 results[0]->original_signon_realm = "http://accounts2.google.com";
726 results[1]->origin = GURL("http://accounts.google.com/a/ServiceLoginAuth2");
727 results[1]->action = GURL("http://accounts.google.com/a/ServiceLogin2");
728 SimulateFetchMatchingLoginsFromPasswordStore(manager.get());
729 SimulateResponseFromPasswordStore(manager.get(), results);
730 EXPECT_EQ(1u, password_manager.GetLatestBestMatches().size());
731 EXPECT_EQ("", password_manager.GetLatestBestMatches().begin()
732 ->second->original_signon_realm);
733 }
734
705 } // namespace password_manager 735 } // namespace password_manager
OLDNEW
« no previous file with comments | « components/password_manager/core/browser/password_form_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698