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

Unified Diff: chrome/browser/password_manager/password_manager_unittest.cc

Issue 11361142: Fill passwords if password manager is disabled. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix lint warnings. Created 8 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: chrome/browser/password_manager/password_manager_unittest.cc
diff --git a/chrome/browser/password_manager/password_manager_unittest.cc b/chrome/browser/password_manager/password_manager_unittest.cc
index e59785040d148c26d47d133cd6f6fed05a24f6b6..66787df205537256646d3a02f931106b26963d3d 100644
--- a/chrome/browser/password_manager/password_manager_unittest.cc
+++ b/chrome/browser/password_manager/password_manager_unittest.cc
@@ -12,8 +12,10 @@
#include "chrome/browser/password_manager/password_manager_delegate.h"
#include "chrome/browser/password_manager/password_store.h"
#include "chrome/browser/password_manager/password_store_factory.h"
+#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/base/chrome_render_view_host_test_harness.h"
+#include "chrome/test/base/testing_pref_service.h"
#include "chrome/test/base/testing_profile.h"
#include "content/public/browser/navigation_details.h"
#include "content/public/common/frame_navigate_params.h"
@@ -54,11 +56,11 @@ class PasswordManagerTest : public ChromeRenderViewHostTestHarness {
protected:
virtual void SetUp() {
- TestingProfile* testing_profile = new TestingProfile;
+ testing_profile_ = new TestingProfile;
store_ = static_cast<MockPasswordStore*>(
PasswordStoreFactory::GetInstance()->SetTestingFactoryAndUse(
- testing_profile, MockPasswordStore::Build).get());
- browser_context_.reset(testing_profile);
+ testing_profile_, MockPasswordStore::Build).get());
+ browser_context_.reset(testing_profile_);
ChromeRenderViewHostTestHarness::SetUp();
EXPECT_CALL(delegate_, GetProfile()).WillRepeatedly(Return(profile()));
@@ -95,6 +97,8 @@ class PasswordManagerTest : public ChromeRenderViewHostTestHarness {
scoped_refptr<MockPasswordStore> store_;
MockPasswordManagerDelegate delegate_; // Owned by manager_.
+
+ TestingProfile* testing_profile_;
};
MATCHER_P(FormMatches, form, "") {
@@ -335,3 +339,25 @@ TEST_F(PasswordManagerTest, InitiallyInvisibleForm) {
manager()->OnPasswordFormsParsed(observed); // The post-navigation load.
manager()->OnPasswordFormsRendered(observed); // The post-navigation layout.
}
+
+TEST_F(PasswordManagerTest, SavingDependsOnManagerEnabledPreference) {
+ TestingPrefService* prefService = testing_profile_->GetTestingPrefService();
+ prefService->SetUserPref(prefs::kPasswordManagerEnabled,
+ Value::CreateBooleanValue(true));
+ EXPECT_TRUE(manager()->IsSavingEnabled());
+ prefService->SetUserPref(prefs::kPasswordManagerEnabled,
+ Value::CreateBooleanValue(false));
+ EXPECT_FALSE(manager()->IsSavingEnabled());
+}
+
+TEST_F(PasswordManagerTest, FillPasswordsOnDisabledManager) {
+ TestingPrefService* prefService = testing_profile_->GetTestingPrefService();
+ prefService->SetUserPref(prefs::kPasswordManagerEnabled,
+ Value::CreateBooleanValue(false));
+ EXPECT_CALL(*store_, GetLogins(_, _));
Ilya Sherman 2012/11/08 06:11:26 nit: It looks like the other tests also include "E
Timo Reimann 2012/11/08 13:36:06 Agreed -- it should make the unit tests look more
+ std::vector<PasswordForm> observed;
+ PasswordForm form(MakeSimpleForm());
+ observed.push_back(form);
+ manager()->OnPasswordFormsParsed(observed);
+}
+

Powered by Google App Engine
This is Rietveld 408576698