This source file includes following definitions.
- RunAllPendingTasks
- PromptUserToSavePassword
- GetPrefs
- GetPasswordStore
- GetDriver
- AuthenticateAutofillAndFillForm
- GetMockDriver
- Autofill
- GetLatestBestMatches
- SetUp
- TearDown
- InitializeMockStore
- mock_store
- GetPendingCredentials
- SimulateMatchingPhase
- SimulateFetchMatchingLoginsFromPasswordStore
- SimulateResponseFromPasswordStore
- SanitizePossibleUsernames
- IgnoredResult
- observed_form
- saved_match
- CreateSavedMatch
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
- TEST_F
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/prefs/pref_registry_simple.h"
#include "base/prefs/pref_service.h"
#include "base/prefs/testing_pref_service.h"
#include "base/run_loop.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "components/autofill/core/common/password_form.h"
#include "components/password_manager/core/browser/mock_password_store.h"
#include "components/password_manager/core/browser/password_form_manager.h"
#include "components/password_manager/core/browser/password_manager.h"
#include "components/password_manager/core/browser/password_manager_client.h"
#include "components/password_manager/core/browser/password_manager_driver.h"
#include "components/password_manager/core/browser/password_store.h"
#include "components/password_manager/core/browser/test_password_store.h"
#include "components/password_manager/core/common/password_manager_pref_names.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
using autofill::PasswordForm;
using base::ASCIIToUTF16;
using ::testing::_;
using ::testing::Eq;
using ::testing::Mock;
using ::testing::Return;
namespace autofill {
class AutofillManager;
}
namespace {
void RunAllPendingTasks() {
base::RunLoop run_loop;
base::MessageLoop::current()->PostTask(
FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
run_loop.Run();
}
class MockPasswordManagerDriver : public PasswordManagerDriver {
public:
MockPasswordManagerDriver() {}
virtual ~MockPasswordManagerDriver() {}
MOCK_METHOD1(FillPasswordForm, void(const autofill::PasswordFormFillData&));
MOCK_METHOD0(DidLastPageLoadEncounterSSLErrors, bool());
MOCK_METHOD0(IsOffTheRecord, bool());
MOCK_METHOD0(GetPasswordGenerationManager, PasswordGenerationManager*());
MOCK_METHOD0(GetPasswordManager, PasswordManager*());
MOCK_METHOD0(GetAutofillManager, autofill::AutofillManager*());
MOCK_METHOD1(AllowPasswordGenerationForForm, void(autofill::PasswordForm*));
MOCK_METHOD1(AccountCreationFormsFound,
void(const std::vector<autofill::FormData>&));
};
class TestPasswordManagerClient : public PasswordManagerClient {
public:
explicit TestPasswordManagerClient(PasswordStore* password_store)
: password_store_(password_store) {
prefs_.registry()->RegisterBooleanPref(prefs::kPasswordManagerEnabled,
true);
}
virtual void PromptUserToSavePassword(PasswordFormManager* form_to_save)
OVERRIDE {}
virtual PrefService* GetPrefs() OVERRIDE { return &prefs_; }
virtual PasswordStore* GetPasswordStore() OVERRIDE { return password_store_; }
virtual PasswordManagerDriver* GetDriver() OVERRIDE { return &driver_; }
virtual void AuthenticateAutofillAndFillForm(
scoped_ptr<autofill::PasswordFormFillData> fill_data) OVERRIDE {
driver_.FillPasswordForm(*fill_data.get());
}
MockPasswordManagerDriver* GetMockDriver() { return &driver_; }
private:
TestingPrefServiceSimple prefs_;
PasswordStore* password_store_;
MockPasswordManagerDriver driver_;
};
class TestPasswordManager : public PasswordManager {
public:
explicit TestPasswordManager(PasswordManagerClient* client)
: PasswordManager(client) {}
virtual void Autofill(const autofill::PasswordForm& form_for_autofill,
const autofill::PasswordFormMap& best_matches,
const autofill::PasswordForm& preferred_match,
bool wait_for_username) const OVERRIDE {
best_matches_ = best_matches;
}
const autofill::PasswordFormMap& GetLatestBestMatches() {
return best_matches_;
}
private:
mutable autofill::PasswordFormMap best_matches_;
};
}
class PasswordFormManagerTest : public testing::Test {
public:
PasswordFormManagerTest() {}
virtual void SetUp() {
observed_form_.origin = GURL("http://accounts.google.com/a/LoginAuth");
observed_form_.action = GURL("http://accounts.google.com/a/Login");
observed_form_.username_element = ASCIIToUTF16("Email");
observed_form_.password_element = ASCIIToUTF16("Passwd");
observed_form_.submit_element = ASCIIToUTF16("signIn");
observed_form_.signon_realm = "http://accounts.google.com";
saved_match_ = observed_form_;
saved_match_.origin = GURL("http://accounts.google.com/a/ServiceLoginAuth");
saved_match_.action = GURL("http://accounts.google.com/a/ServiceLogin");
saved_match_.preferred = true;
saved_match_.username_value = ASCIIToUTF16("test@gmail.com");
saved_match_.password_value = ASCIIToUTF16("test1");
saved_match_.other_possible_usernames.push_back(
ASCIIToUTF16("test2@gmail.com"));
}
virtual void TearDown() {
if (mock_store_)
mock_store_->Shutdown();
}
void InitializeMockStore() {
if (!mock_store_) {
mock_store_ = new MockPasswordStore();
ASSERT_TRUE(mock_store_);
}
}
MockPasswordStore* mock_store() const { return mock_store_.get(); }
PasswordForm* GetPendingCredentials(PasswordFormManager* p) {
return &p->pending_credentials_;
}
void SimulateMatchingPhase(PasswordFormManager* p, bool find_match) {
p->state_ = PasswordFormManager::POST_MATCHING_PHASE;
if (!find_match)
return;
PasswordForm* match = new PasswordForm(saved_match_);
p->best_matches_[match->username_value] = match;
p->preferred_match_ = match;
}
void SimulateFetchMatchingLoginsFromPasswordStore(
PasswordFormManager* manager) {
manager->state_ = PasswordFormManager::MATCHING_PHASE;
}
void SimulateResponseFromPasswordStore(
PasswordFormManager* manager,
const std::vector<PasswordForm*>& result) {
manager->OnGetPasswordStoreResults(result);
}
void SanitizePossibleUsernames(PasswordFormManager* p, PasswordForm* form) {
p->SanitizePossibleUsernames(form);
}
bool IgnoredResult(PasswordFormManager* p, PasswordForm* form) {
return p->IgnoreResult(*form);
}
PasswordForm* observed_form() { return &observed_form_; }
PasswordForm* saved_match() { return &saved_match_; }
PasswordForm* CreateSavedMatch(bool blacklisted) {
PasswordForm* match = new PasswordForm(saved_match_);
match->blacklisted_by_user = blacklisted;
return match;
}
private:
PasswordForm observed_form_;
PasswordForm saved_match_;
scoped_refptr<MockPasswordStore> mock_store_;
};
TEST_F(PasswordFormManagerTest, TestNewLogin) {
scoped_ptr<TestPasswordManagerClient> client(
new TestPasswordManagerClient(NULL));
scoped_ptr<MockPasswordManagerDriver> driver;
PasswordFormManager* manager = new PasswordFormManager(
NULL, client.get(), driver.get(), *observed_form(), false);
SimulateMatchingPhase(manager, false);
PasswordForm credentials = *observed_form();
credentials.username_value = saved_match()->username_value;
credentials.password_value = saved_match()->password_value;
credentials.preferred = true;
manager->ProvisionallySave(
credentials, PasswordFormManager::IGNORE_OTHER_POSSIBLE_USERNAMES);
EXPECT_TRUE(manager->IsNewLogin());
EXPECT_EQ(observed_form()->origin.spec(),
GetPendingCredentials(manager)->origin.spec());
EXPECT_EQ(observed_form()->signon_realm,
GetPendingCredentials(manager)->signon_realm);
EXPECT_EQ(observed_form()->action, GetPendingCredentials(manager)->action);
EXPECT_TRUE(GetPendingCredentials(manager)->preferred);
EXPECT_EQ(saved_match()->password_value,
GetPendingCredentials(manager)->password_value);
EXPECT_EQ(saved_match()->username_value,
GetPendingCredentials(manager)->username_value);
SimulateMatchingPhase(manager, true);
base::string16 new_user = ASCIIToUTF16("newuser");
base::string16 new_pass = ASCIIToUTF16("newpass");
credentials.username_value = new_user;
credentials.password_value = new_pass;
manager->ProvisionallySave(
credentials, PasswordFormManager::IGNORE_OTHER_POSSIBLE_USERNAMES);
EXPECT_TRUE(manager->IsNewLogin());
EXPECT_EQ(observed_form()->origin.spec(),
GetPendingCredentials(manager)->origin.spec());
EXPECT_EQ(observed_form()->signon_realm,
GetPendingCredentials(manager)->signon_realm);
EXPECT_TRUE(GetPendingCredentials(manager)->preferred);
EXPECT_EQ(new_pass, GetPendingCredentials(manager)->password_value);
EXPECT_EQ(new_user, GetPendingCredentials(manager)->username_value);
delete manager;
}
TEST_F(PasswordFormManagerTest, TestUpdatePassword) {
scoped_ptr<TestPasswordManagerClient> client(
new TestPasswordManagerClient(NULL));
scoped_ptr<MockPasswordManagerDriver> driver;
PasswordFormManager* manager = new PasswordFormManager(
NULL, client.get(), driver.get(), *observed_form(), false);
SimulateMatchingPhase(manager, true);
base::string16 new_pass = ASCIIToUTF16("newpassword");
PasswordForm credentials = *observed_form();
credentials.username_value = saved_match()->username_value;
credentials.password_value = new_pass;
credentials.preferred = true;
manager->ProvisionallySave(
credentials, PasswordFormManager::IGNORE_OTHER_POSSIBLE_USERNAMES);
EXPECT_FALSE(manager->IsNewLogin());
EXPECT_EQ(GetPendingCredentials(manager)->origin.spec(),
saved_match()->origin.spec());
EXPECT_EQ(GetPendingCredentials(manager)->signon_realm,
saved_match()->signon_realm);
EXPECT_TRUE(GetPendingCredentials(manager)->preferred);
EXPECT_EQ(new_pass, GetPendingCredentials(manager)->password_value);
delete manager;
}
TEST_F(PasswordFormManagerTest, TestIgnoreResult) {
scoped_ptr<TestPasswordManagerClient> client(
new TestPasswordManagerClient(NULL));
scoped_ptr<MockPasswordManagerDriver> driver;
PasswordFormManager* manager = new PasswordFormManager(
NULL, client.get(), driver.get(), *observed_form(), false);
saved_match()->ssl_valid = true;
EXPECT_TRUE(IgnoredResult(manager, saved_match()));
saved_match()->ssl_valid = false;
saved_match()->action = GURL("http://www.google.com/b/Login");
saved_match()->origin = GURL("http://www.google.com/foo");
EXPECT_FALSE(IgnoredResult(manager, saved_match()));
delete manager;
}
TEST_F(PasswordFormManagerTest, TestEmptyAction) {
scoped_ptr<TestPasswordManagerClient> client(
new TestPasswordManagerClient(NULL));
scoped_ptr<MockPasswordManagerDriver> driver;
scoped_ptr<PasswordFormManager> manager(new PasswordFormManager(
NULL, client.get(), driver.get(), *observed_form(), false));
saved_match()->action = GURL();
SimulateMatchingPhase(manager.get(), true);
PasswordForm login = *observed_form();
login.username_value = saved_match()->username_value;
login.password_value = saved_match()->password_value;
manager->ProvisionallySave(
login, PasswordFormManager::IGNORE_OTHER_POSSIBLE_USERNAMES);
EXPECT_FALSE(manager->IsNewLogin());
EXPECT_EQ(observed_form()->action,
GetPendingCredentials(manager.get())->action);
}
TEST_F(PasswordFormManagerTest, TestUpdateAction) {
scoped_ptr<TestPasswordManagerClient> client(
new TestPasswordManagerClient(NULL));
scoped_ptr<MockPasswordManagerDriver> driver;
scoped_ptr<PasswordFormManager> manager(new PasswordFormManager(
NULL, client.get(), driver.get(), *observed_form(), false));
SimulateMatchingPhase(manager.get(), true);
PasswordForm login = *observed_form();
login.username_value = saved_match()->username_value;
login.password_value = saved_match()->password_value;
manager->ProvisionallySave(
login, PasswordFormManager::IGNORE_OTHER_POSSIBLE_USERNAMES);
EXPECT_FALSE(manager->IsNewLogin());
EXPECT_NE(observed_form()->action, saved_match()->action);
EXPECT_EQ(observed_form()->action,
GetPendingCredentials(manager.get())->action);
}
TEST_F(PasswordFormManagerTest, TestDynamicAction) {
scoped_ptr<TestPasswordManagerClient> client(
new TestPasswordManagerClient(NULL));
scoped_ptr<MockPasswordManagerDriver> driver;
scoped_ptr<PasswordFormManager> manager(new PasswordFormManager(
NULL, client.get(), driver.get(), *observed_form(), false));
SimulateMatchingPhase(manager.get(), false);
PasswordForm login(*observed_form());
GURL new_action = GURL("http://www.google.com/new_action");
login.action = new_action;
manager->ProvisionallySave(
login, PasswordFormManager::IGNORE_OTHER_POSSIBLE_USERNAMES);
EXPECT_TRUE(manager->IsNewLogin());
EXPECT_EQ(new_action, GetPendingCredentials(manager.get())->action);
}
TEST_F(PasswordFormManagerTest, TestAlternateUsername) {
base::MessageLoop message_loop;
scoped_refptr<TestPasswordStore> password_store = new TestPasswordStore;
CHECK(password_store->Init(syncer::SyncableService::StartSyncFlare()));
TestPasswordManagerClient client(password_store.get());
TestPasswordManager password_manager(&client);
scoped_ptr<PasswordFormManager> manager(new PasswordFormManager(
&password_manager, &client, client.GetDriver(), *observed_form(), false));
password_store->AddLogin(*saved_match());
manager->FetchMatchingLoginsFromPasswordStore(PasswordStore::ALLOW_PROMPT);
RunAllPendingTasks();
PasswordForm login(*observed_form());
login.username_value = saved_match()->username_value;
login.password_value = saved_match()->password_value;
login.preferred = true;
manager->ProvisionallySave(
login, PasswordFormManager::ALLOW_OTHER_POSSIBLE_USERNAMES);
EXPECT_FALSE(manager->IsNewLogin());
manager->Save();
RunAllPendingTasks();
TestPasswordStore::PasswordMap passwords = password_store->stored_passwords();
EXPECT_EQ(1U, passwords.size());
ASSERT_EQ(1U, passwords[saved_match()->signon_realm].size());
EXPECT_EQ(saved_match()->username_value,
passwords[saved_match()->signon_realm][0].username_value);
EXPECT_EQ(0U,
passwords[saved_match()->signon_realm][0]
.other_possible_usernames.size());
manager.reset(new PasswordFormManager(
&password_manager, &client, client.GetDriver(), *observed_form(), false));
password_store->Clear();
password_store->AddLogin(*saved_match());
manager->FetchMatchingLoginsFromPasswordStore(PasswordStore::ALLOW_PROMPT);
RunAllPendingTasks();
base::string16 new_username = saved_match()->other_possible_usernames[0];
login.username_value = new_username;
manager->ProvisionallySave(
login, PasswordFormManager::ALLOW_OTHER_POSSIBLE_USERNAMES);
EXPECT_FALSE(manager->IsNewLogin());
manager->Save();
RunAllPendingTasks();
passwords = password_store->stored_passwords();
EXPECT_EQ(1U, passwords.size());
ASSERT_EQ(1U, passwords[saved_match()->signon_realm].size());
EXPECT_EQ(new_username,
passwords[saved_match()->signon_realm][0].username_value);
EXPECT_EQ(0U,
passwords[saved_match()->signon_realm][0]
.other_possible_usernames.size());
password_store->Shutdown();
}
TEST_F(PasswordFormManagerTest, TestValidForms) {
PasswordForm credentials = *observed_form();
credentials.scheme = PasswordForm::SCHEME_HTML;
credentials.username_value = saved_match()->username_value;
credentials.password_value = saved_match()->password_value;
PasswordFormManager manager1(NULL, NULL, NULL, credentials, false);
SimulateMatchingPhase(&manager1, false);
EXPECT_TRUE(manager1.HasValidPasswordForm());
credentials.username_element.clear();
PasswordFormManager manager2(NULL, NULL, NULL, credentials, false);
SimulateMatchingPhase(&manager2, false);
EXPECT_FALSE(manager2.HasValidPasswordForm());
credentials.username_element = saved_match()->username_element;
credentials.password_element.clear();
PasswordFormManager manager3(NULL, NULL, NULL, credentials, false);
SimulateMatchingPhase(&manager3, false);
EXPECT_FALSE(manager3.HasValidPasswordForm());
credentials.username_element.clear();
credentials.password_element.clear();
PasswordFormManager manager4(NULL, NULL, NULL, credentials, false);
SimulateMatchingPhase(&manager4, false);
EXPECT_FALSE(manager4.HasValidPasswordForm());
}
TEST_F(PasswordFormManagerTest, TestValidFormsBasic) {
PasswordForm credentials = *observed_form();
credentials.scheme = PasswordForm::SCHEME_BASIC;
credentials.username_value = saved_match()->username_value;
credentials.password_value = saved_match()->password_value;
PasswordFormManager manager1(NULL, NULL, NULL, credentials, false);
SimulateMatchingPhase(&manager1, false);
EXPECT_TRUE(manager1.HasValidPasswordForm());
credentials.username_element.clear();
PasswordFormManager manager2(NULL, NULL, NULL, credentials, false);
SimulateMatchingPhase(&manager2, false);
EXPECT_TRUE(manager2.HasValidPasswordForm());
credentials.username_element = saved_match()->username_element;
credentials.password_element.clear();
PasswordFormManager manager3(NULL, NULL, NULL, credentials, false);
SimulateMatchingPhase(&manager3, false);
EXPECT_TRUE(manager3.HasValidPasswordForm());
credentials.username_element.clear();
credentials.password_element.clear();
PasswordFormManager manager4(NULL, NULL, NULL, credentials, false);
SimulateMatchingPhase(&manager4, false);
EXPECT_TRUE(manager4.HasValidPasswordForm());
}
TEST_F(PasswordFormManagerTest, TestSendNotBlacklistedMessage) {
base::MessageLoop message_loop;
TestPasswordManagerClient client(NULL);
TestPasswordManager password_manager(&client);
scoped_ptr<PasswordFormManager> manager(new PasswordFormManager(
&password_manager, &client, client.GetDriver(), *observed_form(), false));
EXPECT_CALL(*client.GetMockDriver(), AllowPasswordGenerationForForm(_))
.Times(1);
SimulateFetchMatchingLoginsFromPasswordStore(manager.get());
std::vector<PasswordForm*> result;
SimulateResponseFromPasswordStore(manager.get(), result);
Mock::VerifyAndClearExpectations(client.GetMockDriver());
manager.reset(new PasswordFormManager(
&password_manager, &client, client.GetDriver(), *observed_form(), false));
EXPECT_CALL(*client.GetMockDriver(), AllowPasswordGenerationForForm(_))
.Times(1);
SimulateFetchMatchingLoginsFromPasswordStore(manager.get());
result.push_back(CreateSavedMatch(false));
SimulateResponseFromPasswordStore(manager.get(), result);
Mock::VerifyAndClearExpectations(client.GetMockDriver());
manager.reset(new PasswordFormManager(
&password_manager, &client, client.GetDriver(), *observed_form(), false));
EXPECT_CALL(*client.GetMockDriver(), AllowPasswordGenerationForForm(_))
.Times(0);
SimulateFetchMatchingLoginsFromPasswordStore(manager.get());
result.clear();
result.push_back(CreateSavedMatch(true));
SimulateResponseFromPasswordStore(manager.get(), result);
Mock::VerifyAndClearExpectations(client.GetMockDriver());
}
TEST_F(PasswordFormManagerTest, TestForceInclusionOfGeneratedPasswords) {
base::MessageLoop message_loop;
TestPasswordManagerClient client(NULL);
TestPasswordManager password_manager(&client);
scoped_ptr<PasswordFormManager> manager(new PasswordFormManager(
&password_manager, &client, client.GetDriver(), *observed_form(), false));
std::vector<PasswordForm*> results;
results.push_back(CreateSavedMatch(false));
results.push_back(CreateSavedMatch(false));
results[1]->username_value = ASCIIToUTF16("other@gmail.com");
results[1]->password_element = ASCIIToUTF16("signup_password");
results[1]->username_element = ASCIIToUTF16("signup_username");
SimulateFetchMatchingLoginsFromPasswordStore(manager.get());
SimulateResponseFromPasswordStore(manager.get(), results);
EXPECT_EQ(1u, password_manager.GetLatestBestMatches().size());
results.clear();
manager.reset(new PasswordFormManager(
&password_manager, &client, client.GetDriver(), *observed_form(), false));
results.push_back(CreateSavedMatch(false));
results.push_back(CreateSavedMatch(false));
results[1]->username_value = ASCIIToUTF16("other@gmail.com");
results[1]->password_element = ASCIIToUTF16("signup_password");
results[1]->username_element = ASCIIToUTF16("signup_username");
results[1]->type = PasswordForm::TYPE_GENERATED;
SimulateFetchMatchingLoginsFromPasswordStore(manager.get());
SimulateResponseFromPasswordStore(manager.get(), results);
EXPECT_EQ(2u, password_manager.GetLatestBestMatches().size());
}
TEST_F(PasswordFormManagerTest, TestSanitizePossibleUsernames) {
scoped_ptr<TestPasswordManagerClient> client(
new TestPasswordManagerClient(NULL));
scoped_ptr<MockPasswordManagerDriver> driver;
scoped_ptr<PasswordFormManager> manager(new PasswordFormManager(
NULL, client.get(), driver.get(), *observed_form(), false));
PasswordForm credentials(*observed_form());
credentials.other_possible_usernames.push_back(ASCIIToUTF16("543-43-1234"));
credentials.other_possible_usernames.push_back(
ASCIIToUTF16("378282246310005"));
credentials.other_possible_usernames.push_back(
ASCIIToUTF16("other username"));
credentials.username_value = ASCIIToUTF16("test@gmail.com");
SanitizePossibleUsernames(manager.get(), &credentials);
std::vector<base::string16> expected;
expected.push_back(ASCIIToUTF16("other username"));
EXPECT_THAT(credentials.other_possible_usernames, Eq(expected));
credentials.other_possible_usernames.clear();
credentials.other_possible_usernames.push_back(ASCIIToUTF16("511-32-9830"));
credentials.other_possible_usernames.push_back(ASCIIToUTF16("duplicate"));
credentials.other_possible_usernames.push_back(ASCIIToUTF16("duplicate"));
credentials.other_possible_usernames.push_back(ASCIIToUTF16("random"));
credentials.other_possible_usernames.push_back(
ASCIIToUTF16("test@gmail.com"));
SanitizePossibleUsernames(manager.get(), &credentials);
expected.clear();
expected.push_back(ASCIIToUTF16("duplicate"));
expected.push_back(ASCIIToUTF16("random"));
EXPECT_THAT(credentials.other_possible_usernames, Eq(expected));
}
TEST_F(PasswordFormManagerTest, TestUpdateIncompleteCredentials) {
InitializeMockStore();
PasswordForm encountered_form;
encountered_form.origin = GURL("http://accounts.google.com/LoginAuth");
encountered_form.signon_realm = "http://accounts.google.com/";
encountered_form.action = GURL("http://accounts.google.com/Login");
encountered_form.username_element = ASCIIToUTF16("Email");
encountered_form.password_element = ASCIIToUTF16("Passwd");
encountered_form.submit_element = ASCIIToUTF16("signIn");
TestPasswordManagerClient client(mock_store());
MockPasswordManagerDriver driver;
EXPECT_CALL(driver, IsOffTheRecord()).WillRepeatedly(Return(false));
EXPECT_CALL(driver, AllowPasswordGenerationForForm(_));
TestPasswordManager manager(&client);
PasswordFormManager form_manager(
&manager, &client, &driver, encountered_form, false);
const PasswordStore::AuthorizationPromptPolicy auth_policy =
PasswordStore::DISALLOW_PROMPT;
EXPECT_CALL(*mock_store(),
GetLogins(encountered_form, auth_policy, &form_manager));
form_manager.FetchMatchingLoginsFromPasswordStore(auth_policy);
PasswordForm* incomplete_form = new PasswordForm();
incomplete_form->origin = GURL("http://accounts.google.com/LoginAuth");
incomplete_form->signon_realm = "http://accounts.google.com/";
incomplete_form->password_value = ASCIIToUTF16("my_password");
incomplete_form->username_value = ASCIIToUTF16("my_username");
incomplete_form->preferred = true;
incomplete_form->ssl_valid = false;
incomplete_form->scheme = PasswordForm::SCHEME_HTML;
PasswordForm complete_form(*incomplete_form);
complete_form.action = encountered_form.action;
complete_form.password_element = encountered_form.password_element;
complete_form.username_element = encountered_form.username_element;
complete_form.submit_element = encountered_form.submit_element;
std::vector<PasswordForm*> results;
results.push_back(incomplete_form);
form_manager.OnRequestDone(results);
form_manager.ProvisionallySave(
complete_form, PasswordFormManager::IGNORE_OTHER_POSSIBLE_USERNAMES);
complete_form.times_used = 1;
EXPECT_CALL(*mock_store(), UpdateLogin(complete_form));
form_manager.Save();
}