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

Side by Side Diff: components/password_manager/core/browser/password_form_manager_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 "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 669 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 // We expect to see this form eventually sent to the Password store. It 680 // We expect to see this form eventually sent to the Password store. It
681 // has password/username values from the store and 'username_element', 681 // has password/username values from the store and 'username_element',
682 // 'password_element', 'submit_element' and 'action' fields copied from 682 // 'password_element', 'submit_element' and 'action' fields copied from
683 // the encountered form. 683 // the encountered form.
684 PasswordForm complete_form(*incomplete_form); 684 PasswordForm complete_form(*incomplete_form);
685 complete_form.action = encountered_form.action; 685 complete_form.action = encountered_form.action;
686 complete_form.password_element = encountered_form.password_element; 686 complete_form.password_element = encountered_form.password_element;
687 complete_form.username_element = encountered_form.username_element; 687 complete_form.username_element = encountered_form.username_element;
688 complete_form.submit_element = encountered_form.submit_element; 688 complete_form.submit_element = encountered_form.submit_element;
689 689
690 PasswordForm obsolete_form(*incomplete_form);
691 obsolete_form.action = encountered_form.action;
692
690 // Feed the incomplete credentials to the manager. 693 // Feed the incomplete credentials to the manager.
691 std::vector<PasswordForm*> results; 694 std::vector<PasswordForm*> results;
692 results.push_back(incomplete_form); // Takes ownership. 695 results.push_back(incomplete_form); // Takes ownership.
693 form_manager.OnRequestDone(results); 696 form_manager.OnRequestDone(results);
694 697
695 form_manager.ProvisionallySave( 698 form_manager.ProvisionallySave(
696 complete_form, PasswordFormManager::IGNORE_OTHER_POSSIBLE_USERNAMES); 699 complete_form, PasswordFormManager::IGNORE_OTHER_POSSIBLE_USERNAMES);
697 // By now that form has been used once. 700 // By now that form has been used once.
698 complete_form.times_used = 1; 701 complete_form.times_used = 1;
702 obsolete_form.times_used = 1;
699 703
700 // Check that PasswordStore receives an update request with the complete form. 704 // Check that PasswordStore receives an update request with the complete form.
701 EXPECT_CALL(*mock_store(), UpdateLogin(complete_form)); 705 EXPECT_CALL(*mock_store(), RemoveLogin(obsolete_form));
706 EXPECT_CALL(*mock_store(), AddLogin(complete_form));
702 form_manager.Save(); 707 form_manager.Save();
703 } 708 }
704 709
705 TEST_F(PasswordFormManagerTest, TestScoringPublicSuffixMatch) { 710 TEST_F(PasswordFormManagerTest, TestScoringPublicSuffixMatch) {
706 base::MessageLoop message_loop; 711 base::MessageLoop message_loop;
707 712
708 TestPasswordManagerClient client(NULL); 713 TestPasswordManagerClient client(NULL);
709 MockPasswordManagerDriver driver; 714 MockPasswordManagerDriver driver;
710 EXPECT_CALL(driver, IsOffTheRecord()).WillRepeatedly(Return(false)); 715 EXPECT_CALL(driver, IsOffTheRecord()).WillRepeatedly(Return(false));
711 EXPECT_CALL(driver, AllowPasswordGenerationForForm(_)); 716 EXPECT_CALL(driver, AllowPasswordGenerationForForm(_));
(...skipping 14 matching lines...) Expand all
726 results[1]->origin = GURL("http://accounts.google.com/a/ServiceLoginAuth2"); 731 results[1]->origin = GURL("http://accounts.google.com/a/ServiceLoginAuth2");
727 results[1]->action = GURL("http://accounts.google.com/a/ServiceLogin2"); 732 results[1]->action = GURL("http://accounts.google.com/a/ServiceLogin2");
728 SimulateFetchMatchingLoginsFromPasswordStore(manager.get()); 733 SimulateFetchMatchingLoginsFromPasswordStore(manager.get());
729 SimulateResponseFromPasswordStore(manager.get(), results); 734 SimulateResponseFromPasswordStore(manager.get(), results);
730 EXPECT_EQ(1u, password_manager.GetLatestBestMatches().size()); 735 EXPECT_EQ(1u, password_manager.GetLatestBestMatches().size());
731 EXPECT_EQ("", password_manager.GetLatestBestMatches().begin() 736 EXPECT_EQ("", password_manager.GetLatestBestMatches().begin()
732 ->second->original_signon_realm); 737 ->second->original_signon_realm);
733 } 738 }
734 739
735 } // namespace password_manager 740 } // namespace password_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698