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

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

Issue 344033008: [Password Manager] Disable saving and filling on sync signup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
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 7b95a3c32cb87489efb56d97dfd9a5dc4551fcf2..558089cd46bd167fc76e5d82be646ccdc60b1f33 100644
--- a/components/password_manager/core/browser/password_manager_unittest.cc
+++ b/components/password_manager/core/browser/password_manager_unittest.cc
@@ -42,6 +42,7 @@ namespace {
class MockPasswordManagerClient : public StubPasswordManagerClient {
public:
+ MOCK_CONST_METHOD0(IsPasswordManagerEnabledForCurrentPage, bool());
MOCK_METHOD1(PromptUserToSavePassword, void(PasswordFormManager*));
MOCK_METHOD0(GetPasswordStore, PasswordStore*());
MOCK_METHOD0(GetPrefs, PrefService*());
@@ -82,6 +83,8 @@ class PasswordManagerTest : public testing::Test {
EXPECT_CALL(*store_, ReportMetrics()).Times(AnyNumber());
CHECK(store_->Init(syncer::SyncableService::StartSyncFlare()));
+ EXPECT_CALL(client_, IsPasswordManagerEnabledForCurrentPage())
+ .WillRepeatedly(Return(true));
EXPECT_CALL(client_, GetPasswordStore()).WillRepeatedly(Return(store_));
EXPECT_CALL(client_, GetPrefs()).WillRepeatedly(Return(&prefs_));
EXPECT_CALL(client_, GetDriver()).WillRepeatedly(Return(&driver_));
@@ -625,4 +628,24 @@ TEST_F(PasswordManagerTest, AutofillingNotEnabledOnSSLErrors) {
manager()->OnPasswordFormsParsed(forms);
}
+TEST_F(PasswordManagerTest, SavingDisabledIfManagerDisabled) {
+ EXPECT_CALL(client_, IsPasswordManagerEnabledForCurrentPage())
+ .WillRepeatedly(Return(false));
+ EXPECT_FALSE(manager()->IsSavingEnabledForCurrentPage());
+}
+
+TEST_F(PasswordManagerTest, AutofillingDisabledIfManagerDisabled) {
+ EXPECT_CALL(client_, IsPasswordManagerEnabledForCurrentPage())
+ .WillRepeatedly(Return(false));
+
+ // Let us pretend some forms were found on a website.
+ std::vector<PasswordForm> forms;
+ forms.push_back(MakeSimpleForm());
+
+ // Feed those forms to |manager()| and check that it does not try to find
+ // matching saved credentials for the forms.
+ EXPECT_CALL(*store_.get(), GetLogins(_, _, _)).Times(Exactly(0));
+ manager()->OnPasswordFormsParsed(forms);
+}
+
} // namespace password_manager

Powered by Google App Engine
This is Rietveld 408576698