| Index: chrome/browser/autofill/autofill_manager_unittest.cc
|
| diff --git a/chrome/browser/autofill/autofill_manager_unittest.cc b/chrome/browser/autofill/autofill_manager_unittest.cc
|
| index c9932bdb4f5c263a1ac6d991c773fcf1160245f4..a9f81cec4e8298290d1facd6530b265f7ce0bdaf 100644
|
| --- a/chrome/browser/autofill/autofill_manager_unittest.cc
|
| +++ b/chrome/browser/autofill/autofill_manager_unittest.cc
|
| @@ -624,7 +624,7 @@ class AutofillManagerTest : public ChromeRenderViewHostTestHarness {
|
| }
|
|
|
| virtual void SetUp() OVERRIDE {
|
| - Profile* profile = new TestingProfile();
|
| + Profile* profile = CreateProfile();
|
| browser_context_.reset(profile);
|
| PersonalDataManagerFactory::GetInstance()->SetTestingFactory(
|
| profile, TestPersonalDataManager::Build);
|
| @@ -650,6 +650,10 @@ class AutofillManagerTest : public ChromeRenderViewHostTestHarness {
|
| ChromeRenderViewHostTestHarness::TearDown();
|
| }
|
|
|
| + virtual TestingProfile* CreateProfile() {
|
| + return new TestingProfile();
|
| + }
|
| +
|
| void UpdatePasswordGenerationState(bool new_renderer) {
|
| autofill_manager_->UpdatePasswordGenerationState(NULL, new_renderer);
|
| }
|
| @@ -758,6 +762,19 @@ class AutofillManagerTest : public ChromeRenderViewHostTestHarness {
|
| DISALLOW_COPY_AND_ASSIGN(AutofillManagerTest);
|
| };
|
|
|
| +class IncognitoAutofillManagerTest : public AutofillManagerTest {
|
| + public:
|
| + IncognitoAutofillManagerTest() {}
|
| + virtual ~IncognitoAutofillManagerTest() {}
|
| +
|
| + virtual TestingProfile* CreateProfile() OVERRIDE {
|
| + // Create an incognito profile.
|
| + TestingProfile::Builder builder;
|
| + builder.SetOffTheRecord();
|
| + return builder.Build().release();
|
| + }
|
| +};
|
| +
|
| class TestFormStructure : public FormStructure {
|
| public:
|
| explicit TestFormStructure(const FormData& form) : FormStructure(form) {}
|
| @@ -3077,13 +3094,6 @@ TEST_F(AutofillManagerTest, UpdatePasswordSyncState) {
|
| EXPECT_FALSE(autofill_manager_->GetSentStates()[0]);
|
| autofill_manager_->ClearSentStates();
|
|
|
| - // Disable password manager by going incognito, and re-enable syncing. The
|
| - // feature should still be disabled, and nothing will be sent.
|
| - sync_service->SetSyncSetupCompleted();
|
| - profile()->set_incognito(true);
|
| - UpdatePasswordGenerationState(false);
|
| - EXPECT_EQ(0u, autofill_manager_->GetSentStates().size());
|
| -
|
| // When a new render_view is created, we send the state even if it's the
|
| // same.
|
| UpdatePasswordGenerationState(true);
|
| @@ -3092,6 +3102,28 @@ TEST_F(AutofillManagerTest, UpdatePasswordSyncState) {
|
| autofill_manager_->ClearSentStates();
|
| }
|
|
|
| +TEST_F(IncognitoAutofillManagerTest, UpdatePasswordSyncStateIncognito) {
|
| + // Disable password manager by going incognito, and enable syncing. The
|
| + // feature should still be disabled, and nothing will be sent.
|
| + PasswordManagerDelegateImpl::CreateForWebContents(web_contents());
|
| + PasswordManager::CreateForWebContentsAndDelegate(
|
| + web_contents(),
|
| + PasswordManagerDelegateImpl::FromWebContents(web_contents()));
|
| +
|
| + PrefServiceBase* prefs = PrefServiceBase::FromBrowserContext(profile());
|
| +
|
| + // Allow this test to control what should get synced.
|
| + prefs->SetBoolean(prefs::kSyncKeepEverythingSynced, false);
|
| + // Always set password generation enabled check box so we can test the
|
| + // behavior of password sync.
|
| + prefs->SetBoolean(prefs::kPasswordGenerationEnabled, true);
|
| +
|
| + browser_sync::SyncPrefs sync_prefs(profile()->GetPrefs());
|
| + sync_prefs.SetSyncSetupCompleted();
|
| + UpdatePasswordGenerationState(false);
|
| + EXPECT_EQ(0u, autofill_manager_->GetSentStates().size());
|
| +}
|
| +
|
| TEST_F(AutofillManagerTest, UpdatePasswordGenerationState) {
|
| PasswordManagerDelegateImpl::CreateForWebContents(web_contents());
|
| PasswordManager::CreateForWebContentsAndDelegate(
|
|
|