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

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

Issue 385963003: [Password Manager] Don't prompt to save credentials used to sync passwords (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments Created 6 years, 5 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_manager.cc ('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_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 d4ed8cb27a3e610a8207e96469776c16b674ec43..c5cb481350dbeafc7b7c9df1a3e8ff3434461dbd 100644
--- a/components/password_manager/core/browser/password_manager_unittest.cc
+++ b/components/password_manager/core/browser/password_manager_unittest.cc
@@ -43,6 +43,8 @@ namespace {
class MockPasswordManagerClient : public StubPasswordManagerClient {
public:
MOCK_CONST_METHOD0(IsPasswordManagerEnabledForCurrentPage, bool());
+ MOCK_CONST_METHOD2(IsPasswordSyncAccountCredential,
+ bool(const std::string&, const std::string&));
MOCK_METHOD1(PromptUserToSavePassword, void(PasswordFormManager*));
MOCK_METHOD0(GetPasswordStore, PasswordStore*());
MOCK_METHOD0(GetPrefs, PrefService*());
@@ -85,6 +87,8 @@ class PasswordManagerTest : public testing::Test {
EXPECT_CALL(client_, IsPasswordManagerEnabledForCurrentPage())
.WillRepeatedly(Return(true));
+ EXPECT_CALL(client_, IsPasswordSyncAccountCredential(_, _))
+ .WillRepeatedly(Return(false));
EXPECT_CALL(client_, GetPasswordStore()).WillRepeatedly(Return(store_));
EXPECT_CALL(client_, GetPrefs()).WillRepeatedly(Return(&prefs_));
EXPECT_CALL(client_, GetDriver()).WillRepeatedly(Return(&driver_));
@@ -648,4 +652,31 @@ TEST_F(PasswordManagerTest, AutofillingDisabledIfManagerDisabled) {
manager()->OnPasswordFormsParsed(forms);
}
+TEST_F(PasswordManagerTest, SyncCredentialsNotSaved) {
+ EXPECT_CALL(client_, IsPasswordSyncAccountCredential(_, _))
+ .WillRepeatedly(Return(true));
+
+ // Simulate loading a simple form with no existing stored password.
+ std::vector<PasswordForm*> result; // Empty password store.
+ EXPECT_CALL(driver_, FillPasswordForm(_)).Times(Exactly(0));
+ EXPECT_CALL(*store_.get(), GetLogins(_, _, _))
+ .WillOnce(DoAll(WithArg<2>(InvokeConsumer(result)), Return()));
+ std::vector<PasswordForm> observed;
+ PasswordForm form(MakeSimpleForm());
+ form.password_autocomplete_set = false;
+ observed.push_back(form);
+ manager()->OnPasswordFormsParsed(observed); // The initial load.
+ manager()->OnPasswordFormsRendered(observed, true); // The initial layout.
+
+ // User should not be prompted and password should not be saved.
+ EXPECT_CALL(client_, PromptUserToSavePassword(_)).Times(Exactly(0));
+ EXPECT_CALL(*store_.get(), AddLogin(FormMatches(form))).Times(Exactly(0));
+
+ // Submit form and finish navigation.
+ manager()->ProvisionallySavePassword(form);
+ observed.clear();
+ manager()->OnPasswordFormsParsed(observed);
+ manager()->OnPasswordFormsRendered(observed, true);
+}
+
} // namespace password_manager
« no previous file with comments | « components/password_manager/core/browser/password_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698