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

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

Issue 707173004: Refactor Autofill for out of process iframes (OOPIF). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix merge fallout, android_webview Created 6 years, 1 month 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
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 c38ed9aad5b183094dcd6875c38404fc82e57dcc..59068b01b441dbd65407cb23b54e94d754392886 100644
--- a/components/password_manager/core/browser/password_form_manager_unittest.cc
+++ b/components/password_manager/core/browser/password_form_manager_unittest.cc
@@ -106,7 +106,6 @@ class TestPasswordManagerClient : public StubPasswordManagerClient {
virtual PrefService* GetPrefs() override { return &prefs_; }
virtual PasswordStore* GetPasswordStore() override { return password_store_; }
- virtual PasswordManagerDriver* GetDriver() override { return &driver_; }
void SetFormToFilter(const autofill::PasswordForm& form) {
form_to_filter_ = form;
@@ -124,10 +123,11 @@ class TestPasswordManagerClient : public StubPasswordManagerClient {
class TestPasswordManager : public PasswordManager {
public:
- explicit TestPasswordManager(PasswordManagerClient* client)
+ explicit TestPasswordManager(TestPasswordManagerClient* client)
: PasswordManager(client) {}
- void Autofill(const autofill::PasswordForm& form_for_autofill,
+ void Autofill(password_manager::PasswordManagerDriver* driver,
+ const autofill::PasswordForm& form_for_autofill,
const autofill::PasswordFormMap& best_matches,
const autofill::PasswordForm& preferred_match,
bool wait_for_username) const override {
@@ -411,10 +411,8 @@ TEST_F(PasswordFormManagerTest, TestUpdatePasswordFromNewPasswordElement) {
saved_match()->submit_element.clear();
TestPasswordManagerClient client_with_store(mock_store());
- PasswordFormManager manager(NULL,
- &client_with_store,
- client_with_store.GetDriver(),
- *observed_form(),
+ PasswordFormManager manager(NULL, &client_with_store,
+ client_with_store.mock_driver(), *observed_form(),
false);
EXPECT_CALL(*client_with_store.mock_driver(), IsOffTheRecord())
.WillRepeatedly(Return(false));
@@ -533,10 +531,8 @@ TEST_F(PasswordFormManagerTest, TestAlternateUsername) {
TestPasswordManagerClient client_with_store(password_store.get());
TestPasswordManager password_manager(&client_with_store);
- PasswordFormManager manager(&password_manager,
- &client_with_store,
- client_with_store.GetDriver(),
- *observed_form(),
+ PasswordFormManager manager(&password_manager, &client_with_store,
+ client_with_store.mock_driver(), *observed_form(),
false);
EXPECT_CALL(*client_with_store.mock_driver(),
AllowPasswordGenerationForForm(_)).Times(1);
@@ -571,11 +567,9 @@ TEST_F(PasswordFormManagerTest, TestAlternateUsername) {
.other_possible_usernames.size());
// This time use an alternate username
- PasswordFormManager manager_alt(&password_manager,
- &client_with_store,
- client_with_store.GetDriver(),
- *observed_form(),
- false);
+ PasswordFormManager manager_alt(&password_manager, &client_with_store,
+ client_with_store.mock_driver(),
+ *observed_form(), false);
EXPECT_CALL(*client_with_store.mock_driver(),
AllowPasswordGenerationForForm(_)).Times(1);
password_store->Clear();
@@ -695,11 +689,9 @@ TEST_F(PasswordFormManagerTest, TestValidFormsBasic) {
TEST_F(PasswordFormManagerTest, TestSendNotBlacklistedMessage) {
TestPasswordManager password_manager(client());
- PasswordFormManager manager_no_creds(&password_manager,
- client(),
- client()->GetDriver(),
- *observed_form(),
- false);
+ PasswordFormManager manager_no_creds(&password_manager, client(),
+ client()->mock_driver(),
+ *observed_form(), false);
// First time sign-up attempt. Password store does not contain matching
// credentials. AllowPasswordGenerationForForm should be called to send the
@@ -714,10 +706,8 @@ TEST_F(PasswordFormManagerTest, TestSendNotBlacklistedMessage) {
// Signing up on a previously visited site. Credentials are found in the
// password store, and are not blacklisted. AllowPasswordGenerationForForm
// should be called to send the "not blacklisted" message.
- PasswordFormManager manager_creds(&password_manager,
- client(),
- client()->GetDriver(),
- *observed_form(),
+ PasswordFormManager manager_creds(&password_manager, client(),
+ client()->mock_driver(), *observed_form(),
false);
EXPECT_CALL(*(client()->mock_driver()), AllowPasswordGenerationForForm(_))
.Times(1);
@@ -735,11 +725,8 @@ TEST_F(PasswordFormManagerTest, TestSendNotBlacklistedMessage) {
PasswordForm signup_form(*observed_form());
signup_form.new_password_element = base::ASCIIToUTF16("new_password_field");
- PasswordFormManager manager_dropped_creds(&password_manager,
- client(),
- client()->GetDriver(),
- signup_form,
- false);
+ PasswordFormManager manager_dropped_creds(
+ &password_manager, client(), client()->mock_driver(), signup_form, false);
EXPECT_CALL(*(client()->mock_driver()), AllowPasswordGenerationForForm(_))
.Times(1);
EXPECT_CALL(*(client()->mock_driver()), IsOffTheRecord())
@@ -753,11 +740,9 @@ TEST_F(PasswordFormManagerTest, TestSendNotBlacklistedMessage) {
// Signing up on a previously visited site. Credentials are found in the
// password store, but they are blacklisted. AllowPasswordGenerationForForm
// should not be called and no "not blacklisted" message sent.
- PasswordFormManager manager_blacklisted(&password_manager,
- client(),
- client()->GetDriver(),
- *observed_form(),
- false);
+ PasswordFormManager manager_blacklisted(&password_manager, client(),
+ client()->mock_driver(),
+ *observed_form(), false);
EXPECT_CALL(*(client()->mock_driver()), AllowPasswordGenerationForForm(_))
.Times(0);
SimulateFetchMatchingLoginsFromPasswordStore(&manager_blacklisted);
@@ -772,10 +757,8 @@ TEST_F(PasswordFormManagerTest, TestForceInclusionOfGeneratedPasswords) {
// with different HTML tags for elements. Because of scoring differences,
// only the first form will be sent to Autofill().
TestPasswordManager password_manager(client());
- PasswordFormManager manager_match(&password_manager,
- client(),
- client()->GetDriver(),
- *observed_form(),
+ PasswordFormManager manager_match(&password_manager, client(),
+ client()->mock_driver(), *observed_form(),
false);
EXPECT_CALL(*(client()->mock_driver()), AllowPasswordGenerationForForm(_))
.Times(1);
@@ -795,11 +778,9 @@ TEST_F(PasswordFormManagerTest, TestForceInclusionOfGeneratedPasswords) {
// Same thing, except this time the credentials that don't match quite as
// well are generated. They should now be sent to Autofill().
- PasswordFormManager manager_no_match(&password_manager,
- client(),
- client()->GetDriver(),
- *observed_form(),
- false);
+ PasswordFormManager manager_no_match(&password_manager, client(),
+ client()->mock_driver(),
+ *observed_form(), false);
EXPECT_CALL(*(client()->mock_driver()), AllowPasswordGenerationForForm(_))
.Times(1);
@@ -1085,11 +1066,9 @@ TEST_F(PasswordFormManagerTest, CorrectlyUpdatePasswordsWithSameUsername) {
second.preferred = false;
password_store->AddLogin(second);
- PasswordFormManager storing_manager(&password_manager,
- &client_with_store,
- client_with_store.GetDriver(),
- *observed_form(),
- false);
+ PasswordFormManager storing_manager(&password_manager, &client_with_store,
+ client_with_store.mock_driver(),
+ *observed_form(), false);
storing_manager.FetchMatchingLoginsFromPasswordStore(
PasswordStore::ALLOW_PROMPT);
RunAllPendingTasks();
@@ -1110,11 +1089,9 @@ TEST_F(PasswordFormManagerTest, CorrectlyUpdatePasswordsWithSameUsername) {
storing_manager.Save();
RunAllPendingTasks();
- PasswordFormManager retrieving_manager(&password_manager,
- &client_with_store,
- client_with_store.GetDriver(),
- *observed_form(),
- false);
+ PasswordFormManager retrieving_manager(&password_manager, &client_with_store,
+ client_with_store.mock_driver(),
+ *observed_form(), false);
retrieving_manager.FetchMatchingLoginsFromPasswordStore(
PasswordStore::ALLOW_PROMPT);
@@ -1151,10 +1128,8 @@ TEST_F(PasswordFormManagerTest, UploadFormData_NewPassword) {
form.form_data.fields.push_back(field);
// For newly saved passwords, upload a vote for autofill::PASSWORD.
- PasswordFormManager form_manager(&password_manager,
- &client_with_store,
- client_with_store.GetDriver(),
- form,
+ PasswordFormManager form_manager(&password_manager, &client_with_store,
+ client_with_store.mock_driver(), form,
false);
SimulateMatchingPhase(&form_manager, RESULT_NO_MATCH);
@@ -1172,11 +1147,9 @@ TEST_F(PasswordFormManagerTest, UploadFormData_NewPassword) {
Mock::VerifyAndClearExpectations(&form_manager);
// Do not upload a vote if the user is blacklisting the form.
- PasswordFormManager blacklist_form_manager(&password_manager,
- &client_with_store,
- client_with_store.GetDriver(),
- form,
- false);
+ PasswordFormManager blacklist_form_manager(
+ &password_manager, &client_with_store, client_with_store.mock_driver(),
+ form, false);
SimulateMatchingPhase(&blacklist_form_manager, RESULT_NO_MATCH);
EXPECT_CALL(*client_with_store.mock_driver()->mock_autofill_manager(),
@@ -1204,10 +1177,8 @@ TEST_F(PasswordFormManagerTest, UploadFormData_AccountCreationPassword) {
field.form_control_type = "password";
form.form_data.fields.push_back(field);
- PasswordFormManager form_manager(&password_manager,
- &client_with_store,
- client_with_store.GetDriver(),
- form,
+ PasswordFormManager form_manager(&password_manager, &client_with_store,
+ client_with_store.mock_driver(), form,
false);
std::vector<PasswordForm*> result;
result.push_back(CreateSavedMatch(false));
@@ -1260,11 +1231,9 @@ TEST_F(PasswordFormManagerTest, CorrectlySavePasswordWithoutUsernameFields) {
form.password_value = ASCIIToUTF16("password");
form.preferred = true;
- PasswordFormManager storing_manager(&password_manager,
- &client_with_store,
- client_with_store.GetDriver(),
- *observed_form(),
- false);
+ PasswordFormManager storing_manager(&password_manager, &client_with_store,
+ client_with_store.mock_driver(),
+ *observed_form(), false);
storing_manager.FetchMatchingLoginsFromPasswordStore(
PasswordStore::ALLOW_PROMPT);
RunAllPendingTasks();
@@ -1276,11 +1245,9 @@ TEST_F(PasswordFormManagerTest, CorrectlySavePasswordWithoutUsernameFields) {
storing_manager.Save();
RunAllPendingTasks();
- PasswordFormManager retrieving_manager(&password_manager,
- &client_with_store,
- client_with_store.GetDriver(),
- *observed_form(),
- false);
+ PasswordFormManager retrieving_manager(&password_manager, &client_with_store,
+ client_with_store.mock_driver(),
+ *observed_form(), false);
retrieving_manager.FetchMatchingLoginsFromPasswordStore(
PasswordStore::ALLOW_PROMPT);

Powered by Google App Engine
This is Rietveld 408576698