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

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: Added test Created 6 years, 8 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 "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, one of which was from different
718 // signon realm, and latter had a different origin and action. Public suffix
719 // match should force higher score, so the second one should be preserved.
Garrett Casto 2014/04/24 22:35:29 I think the ordering of the results doesn't match
720 std::vector<PasswordForm*> results;
721 results.push_back(CreateSavedMatch(false));
722 results.push_back(CreateSavedMatch(false));
723 results[0]->origin = GURL("http://accounts.google.com/a/ServiceLoginAuth2");
724 results[0]->action = GURL("http://accounts.google.com/a/ServiceLogin2");
725 results[1]->original_signon_realm = "http://accounts2.google.com";
726 SimulateFetchMatchingLoginsFromPasswordStore(manager.get());
727 SimulateResponseFromPasswordStore(manager.get(), results);
728 EXPECT_EQ(1u, password_manager.GetLatestBestMatches().size());
729 EXPECT_EQ("", password_manager.GetLatestBestMatches().begin()
730 ->second->original_signon_realm);
731 }
732
705 } // namespace password_manager 733 } // namespace password_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698