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

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

Issue 2911433003: Refactor SuppressedHTTPSFormsFetcher to use GetLoginsForSameOrganizationName. (Closed)
Patch Set: Comment + rebase. Created 3 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 side-by-side diff with in-line comments
Download patch
Index: components/password_manager/core/browser/password_manager_unittest.cc
diff --git a/components/password_manager/core/browser/password_manager_unittest.cc b/components/password_manager/core/browser/password_manager_unittest.cc
index 734d2e56caff5ebe1bfbc9deeeac0f5aa8d68d38..d0895e8c8b57054d7f483067314842dc94073955 100644
--- a/components/password_manager/core/browser/password_manager_unittest.cc
+++ b/components/password_manager/core/browser/password_manager_unittest.cc
@@ -119,6 +119,8 @@ class PasswordManagerTest : public testing::Test {
void SetUp() override {
store_ = new testing::StrictMock<MockPasswordStore>;
EXPECT_CALL(*store_, ReportMetrics(_, _)).Times(AnyNumber());
+ EXPECT_CALL(*store_, GetLoginsForSameOrganizationName(_, _))
+ .Times(AnyNumber());
CHECK(store_->Init(syncer::SyncableService::StartSyncFlare(), nullptr));
EXPECT_CALL(client_, GetPasswordStore())
@@ -339,8 +341,7 @@ TEST_F(PasswordManagerTest, FormSubmitNoGoodMatch) {
observed.push_back(form);
EXPECT_CALL(driver_, FillPasswordForm(_)).Times(2);
EXPECT_CALL(*store_, GetLogins(_, _))
- .WillOnce(WithArg<1>(InvokeConsumer(existing_different)))
- .WillOnce(WithArg<1>(InvokeEmptyConsumerWithForms()));
+ .WillOnce(WithArg<1>(InvokeConsumer(existing_different)));
manager()->OnPasswordFormsParsed(&driver_, observed);
manager()->OnPasswordFormsRendered(&driver_, observed, true);
EXPECT_CALL(client_, IsSavingAndFillingEnabledForCurrentPage())
@@ -498,8 +499,7 @@ TEST_F(PasswordManagerTest, InitiallyInvisibleForm) {
observed.push_back(form);
EXPECT_CALL(driver_, FillPasswordForm(_));
EXPECT_CALL(*store_, GetLogins(_, _))
- .WillOnce(WithArg<1>(InvokeConsumer(form)))
- .WillOnce(WithArg<1>(InvokeEmptyConsumerWithForms()));
+ .WillOnce(WithArg<1>(InvokeConsumer(form)));
manager()->OnPasswordFormsParsed(&driver_, observed);
observed.clear();
manager()->OnPasswordFormsRendered(&driver_, observed, true);
@@ -516,8 +516,7 @@ TEST_F(PasswordManagerTest, FillPasswordsOnDisabledManager) {
observed.push_back(form);
EXPECT_CALL(driver_, FillPasswordForm(_));
EXPECT_CALL(*store_, GetLogins(_, _))
- .WillOnce(WithArg<1>(InvokeConsumer(form)))
- .WillOnce(WithArg<1>(InvokeEmptyConsumerWithForms()));
+ .WillOnce(WithArg<1>(InvokeConsumer(form)));
manager()->OnPasswordFormsParsed(&driver_, observed);
}
@@ -858,8 +857,7 @@ TEST_F(PasswordManagerTest, DoNotSaveWithEmptyNewPasswordAndNonemptyPassword) {
form.new_password_value.clear();
observed.push_back(form);
EXPECT_CALL(*store_, GetLogins(_, _))
- .Times(2)
- .WillRepeatedly(WithArg<1>(InvokeEmptyConsumerWithForms()));
+ .WillOnce(WithArg<1>(InvokeEmptyConsumerWithForms()));
manager()->OnPasswordFormsParsed(&driver_, observed);
manager()->OnPasswordFormsRendered(&driver_, observed, true);
@@ -892,8 +890,7 @@ TEST_F(PasswordManagerTest, FormSubmitWithOnlyPasswordField) {
PasswordForm form(MakeSimpleFormWithOnlyPasswordField());
observed.push_back(form);
EXPECT_CALL(*store_, GetLogins(_, _))
- .Times(2)
- .WillRepeatedly(WithArg<1>(InvokeEmptyConsumerWithForms()));
+ .WillOnce(WithArg<1>(InvokeEmptyConsumerWithForms()));
manager()->OnPasswordFormsParsed(&driver_, observed);
manager()->OnPasswordFormsRendered(&driver_, observed, true);
@@ -925,8 +922,7 @@ TEST_F(PasswordManagerTest, FillPasswordOnManyFrames) {
observed.push_back(form);
EXPECT_CALL(driver_, FillPasswordForm(_));
EXPECT_CALL(*store_, GetLogins(_, _))
- .WillOnce(WithArg<1>(InvokeConsumer(form)))
- .WillOnce(WithArg<1>(InvokeEmptyConsumerWithForms()));
+ .WillOnce(WithArg<1>(InvokeConsumer(form)));
manager()->OnPasswordFormsParsed(&driver_, observed);
// Now the form will be seen the second time, in a different frame. The driver
@@ -945,8 +941,7 @@ TEST_F(PasswordManagerTest, InPageNavigation) {
PasswordForm form(MakeSimpleForm());
observed.push_back(form);
EXPECT_CALL(*store_, GetLogins(_, _))
- .Times(2)
- .WillRepeatedly(WithArg<1>(InvokeEmptyConsumerWithForms()));
+ .WillOnce(WithArg<1>(InvokeEmptyConsumerWithForms()));
manager()->OnPasswordFormsParsed(&driver_, observed);
manager()->OnPasswordFormsRendered(&driver_, observed, true);
@@ -976,8 +971,7 @@ TEST_F(PasswordManagerTest, InPageNavigationBlacklistedSite) {
blacklisted_form.username_value = ASCIIToUTF16("");
blacklisted_form.blacklisted_by_user = true;
EXPECT_CALL(*store_, GetLogins(_, _))
- .WillOnce(WithArg<1>(InvokeConsumer(blacklisted_form)))
- .WillOnce(WithArg<1>(InvokeEmptyConsumerWithForms()));
+ .WillOnce(WithArg<1>(InvokeConsumer(blacklisted_form)));
manager()->OnPasswordFormsParsed(&driver_, observed);
manager()->OnPasswordFormsRendered(&driver_, observed, true);
@@ -1149,8 +1143,7 @@ TEST_F(PasswordManagerTest, FormSubmittedUnchangedNotifiesClient) {
observed.push_back(form);
EXPECT_CALL(driver_, FillPasswordForm(_)).Times(2);
EXPECT_CALL(*store_, GetLogins(_, _))
- .WillOnce(WithArg<1>(InvokeConsumer(form)))
- .WillOnce(WithArg<1>(InvokeEmptyConsumerWithForms()));
+ .WillOnce(WithArg<1>(InvokeConsumer(form)));
manager()->OnPasswordFormsParsed(&driver_, observed);
manager()->OnPasswordFormsRendered(&driver_, observed, true);
@@ -1183,7 +1176,7 @@ TEST_F(PasswordManagerTest, SaveFormFetchedAfterSubmit) {
// No call-back from store after GetLogins is called emulates that
// PasswordStore did not fetch a form in time before submission.
- EXPECT_CALL(*store_, GetLogins(_, _)).Times(2);
+ EXPECT_CALL(*store_, GetLogins(_, _));
manager()->OnPasswordFormsParsed(&driver_, observed);
manager()->OnPasswordFormsRendered(&driver_, observed, true);
ASSERT_EQ(1u, manager()->pending_login_managers().size());
@@ -1413,10 +1406,12 @@ TEST_F(PasswordManagerTest, PasswordGenerationPresavePasswordAndLogin) {
if (found_matched_logins_in_store) {
EXPECT_CALL(*store_, GetLogins(_, _))
.WillRepeatedly(WithArg<1>(InvokeConsumer(form)));
+ EXPECT_CALL(*store_, GetLoginsForSameOrganizationName(_, _));
EXPECT_CALL(driver_, FillPasswordForm(_)).Times(2);
} else {
EXPECT_CALL(*store_, GetLogins(_, _))
.WillRepeatedly(WithArg<1>(InvokeEmptyConsumerWithForms()));
+ EXPECT_CALL(*store_, GetLoginsForSameOrganizationName(_, _));
}
std::unique_ptr<PasswordFormManager> form_manager;
if (found_matched_logins_in_store) {
@@ -1575,8 +1570,7 @@ TEST_F(PasswordManagerTest, AutofillingOfAffiliatedCredentials) {
autofill::PasswordFormFillData form_data;
EXPECT_CALL(driver_, FillPasswordForm(_)).WillOnce(SaveArg<0>(&form_data));
EXPECT_CALL(*store_, GetLogins(_, _))
- .WillOnce(WithArg<1>(InvokeConsumer(android_form)))
- .WillOnce(WithArg<1>(InvokeEmptyConsumerWithForms()));
+ .WillOnce(WithArg<1>(InvokeConsumer(android_form)));
manager()->OnPasswordFormsParsed(&driver_, observed_forms);
observed_forms.clear();
manager()->OnPasswordFormsRendered(&driver_, observed_forms, true);
@@ -1622,8 +1616,7 @@ TEST_F(PasswordManagerTest, UpdatePasswordOfAffiliatedCredential) {
autofill::PasswordFormFillData form_data;
EXPECT_CALL(driver_, FillPasswordForm(_)).WillOnce(SaveArg<0>(&form_data));
EXPECT_CALL(*store_, GetLogins(_, _))
- .WillOnce(WithArg<1>(InvokeConsumer(android_form)))
- .WillOnce(WithArg<1>(InvokeEmptyConsumerWithForms()));
+ .WillOnce(WithArg<1>(InvokeConsumer(android_form)));
manager()->OnPasswordFormsParsed(&driver_, observed_forms);
observed_forms.clear();
manager()->OnPasswordFormsRendered(&driver_, observed_forms, true);
@@ -1666,7 +1659,7 @@ TEST_F(PasswordManagerTest, ClearedFieldsSuccessCriteria) {
observed.push_back(form);
// Emulate page load.
- EXPECT_CALL(*store_, GetLogins(_, _)).Times(3);
+ EXPECT_CALL(*store_, GetLogins(_, _)).Times(2);
manager()->OnPasswordFormsParsed(&driver_, observed);
manager()->OnPasswordFormsRendered(&driver_, observed, true);
ASSERT_EQ(1u, manager()->pending_login_managers().size());

Powered by Google App Engine
This is Rietveld 408576698