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

Unified Diff: components/password_manager/core/browser/password_form_manager_unittest.cc

Issue 1336193002: Implement SimulateMatchingPhase by real calls to PasswordFormManager::FetchMatchingLoginsFromPasswo… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments addressed 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/password_manager/core/browser/password_form_manager.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/password_manager/core/browser/password_form_manager_unittest.cc
diff --git a/components/password_manager/core/browser/password_form_manager_unittest.cc b/components/password_manager/core/browser/password_form_manager_unittest.cc
index c7e3b76dd962775698831d86fd74c014ac33d7ef..b9f8aacf938b6b68cf1071df560edb84938d22de 100644
--- a/components/password_manager/core/browser/password_form_manager_unittest.cc
+++ b/components/password_manager/core/browser/password_form_manager_unittest.cc
@@ -264,17 +264,19 @@ class PasswordFormManagerTest : public testing::Test {
void SimulateMatchingPhase(PasswordFormManager* p,
ResultOfSimulatedMatching result) {
- // TODO(vabr): This should use the mock store instead of private methods of
- // PasswordFormManager.
- // Roll up the state to mock out the matching phase.
- p->state_ = PasswordFormManager::POST_MATCHING_PHASE;
- if (result == RESULT_NO_MATCH)
+ const PasswordStore::AuthorizationPromptPolicy auth_policy =
+ PasswordStore::DISALLOW_PROMPT;
+ EXPECT_CALL(*mock_store(), GetLogins(p->observed_form(), auth_policy, p));
+ p->FetchMatchingLoginsFromPasswordStore(auth_policy);
+ if (result == RESULT_NO_MATCH) {
+ p->OnGetPasswordStoreResults(ScopedVector<PasswordForm>());
return;
+ }
scoped_ptr<PasswordForm> match(new PasswordForm(saved_match_));
- p->preferred_match_ = match.get();
- base::string16 username = match->username_value;
- p->best_matches_.insert(username, match.Pass());
+ ScopedVector<PasswordForm> result_form;
+ result_form.push_back(match.Pass());
+ p->OnGetPasswordStoreResults(result_form.Pass());
}
// Save saved_match() for observed_form() where |observed_form_data|,
@@ -395,7 +397,9 @@ TEST_F(PasswordFormManagerTest, TestNewLogin) {
EXPECT_TRUE(
form_manager()->pending_credentials().new_password_element.empty());
EXPECT_TRUE(form_manager()->pending_credentials().new_password_value.empty());
+}
+TEST_F(PasswordFormManagerTest, TestAdditionalLogin) {
// Now, suppose the user re-visits the site and wants to save an additional
// login for the site with a new username. In this case, the matching phase
// will yield the previously saved login.
@@ -403,8 +407,12 @@ TEST_F(PasswordFormManagerTest, TestNewLogin) {
// Set up the new login.
base::string16 new_user = ASCIIToUTF16("newuser");
base::string16 new_pass = ASCIIToUTF16("newpass");
+
+ PasswordForm credentials = *observed_form();
credentials.username_value = new_user;
credentials.password_value = new_pass;
+ credentials.preferred = true;
+
form_manager()->ProvisionallySave(
credentials, PasswordFormManager::IGNORE_OTHER_POSSIBLE_USERNAMES);
« no previous file with comments | « components/password_manager/core/browser/password_form_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698