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

Side by Side Diff: chrome/browser/password_manager/password_generation_manager_unittest.cc

Issue 18068017: Change RenderViewHostTestHarness to create BrowserContext after thread startup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/password_manager/password_manager_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <vector> 5 #include <vector>
6 6
7 #include "base/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "chrome/browser/password_manager/password_generation_manager.h" 8 #include "chrome/browser/password_manager/password_generation_manager.h"
9 #include "chrome/browser/password_manager/password_manager.h" 9 #include "chrome/browser/password_manager/password_manager.h"
10 #include "chrome/browser/password_manager/password_manager_delegate_impl.h" 10 #include "chrome/browser/password_manager/password_manager_delegate_impl.h"
(...skipping 26 matching lines...) Expand all
37 37
38 private: 38 private:
39 std::vector<bool> sent_states_; 39 std::vector<bool> sent_states_;
40 40
41 DISALLOW_COPY_AND_ASSIGN(TestPasswordGenerationManager); 41 DISALLOW_COPY_AND_ASSIGN(TestPasswordGenerationManager);
42 }; 42 };
43 43
44 class PasswordGenerationManagerTest : public ChromeRenderViewHostTestHarness { 44 class PasswordGenerationManagerTest : public ChromeRenderViewHostTestHarness {
45 protected: 45 protected:
46 virtual void SetUp() OVERRIDE { 46 virtual void SetUp() OVERRIDE {
47 TestingProfile* profile = CreateProfile();
48 profile->CreateRequestContext();
49 browser_context_.reset(profile);
50 47
51 SetThreadBundleOptions(content::TestBrowserThreadBundle::REAL_IO_THREAD); 48 SetThreadBundleOptions(content::TestBrowserThreadBundle::REAL_IO_THREAD);
52 ChromeRenderViewHostTestHarness::SetUp(); 49 ChromeRenderViewHostTestHarness::SetUp();
53 50
54 password_generation_manager_.reset( 51 password_generation_manager_.reset(
55 new TestPasswordGenerationManager(web_contents())); 52 new TestPasswordGenerationManager(web_contents()));
56 } 53 }
57 54
58 virtual void TearDown() OVERRIDE { 55 virtual void TearDown() OVERRIDE {
59 ChromeRenderViewHostTestHarness::TearDown(); 56 ChromeRenderViewHostTestHarness::TearDown();
60 } 57 }
61 58
62 virtual TestingProfile* CreateProfile() { 59 virtual content::BrowserContext* CreateBrowserContext() OVERRIDE {
63 return new TestingProfile(); 60 TestingProfile* profile = new TestingProfile();
61 profile->CreateRequestContext();
62 return profile;
64 } 63 }
65 64
66 void UpdateState(bool new_renderer) { 65 void UpdateState(bool new_renderer) {
67 password_generation_manager_->UpdateState(NULL, new_renderer); 66 password_generation_manager_->UpdateState(NULL, new_renderer);
68 } 67 }
69 68
70 scoped_ptr<TestPasswordGenerationManager> password_generation_manager_; 69 scoped_ptr<TestPasswordGenerationManager> password_generation_manager_;
71 }; 70 };
72 71
73 class IncognitoPasswordGenerationManagerTest : 72 class IncognitoPasswordGenerationManagerTest :
74 public PasswordGenerationManagerTest { 73 public PasswordGenerationManagerTest {
75 public: 74 public:
76 virtual TestingProfile* CreateProfile() OVERRIDE { 75 virtual content::BrowserContext* CreateBrowserContext() OVERRIDE {
77 // Create an incognito profile. 76 // Create an incognito profile.
78 TestingProfile::Builder builder; 77 TestingProfile::Builder builder;
79 scoped_ptr<TestingProfile> profile = builder.Build(); 78 scoped_ptr<TestingProfile> profile = builder.Build();
80 profile->set_incognito(true); 79 profile->set_incognito(true);
80 profile->CreateRequestContext();
81 return profile.release(); 81 return profile.release();
82 } 82 }
83 }; 83 };
84 84
85 TEST_F(PasswordGenerationManagerTest, UpdateState) { 85 TEST_F(PasswordGenerationManagerTest, UpdateState) {
86 PasswordManagerDelegateImpl::CreateForWebContents(web_contents()); 86 PasswordManagerDelegateImpl::CreateForWebContents(web_contents());
87 PasswordManager::CreateForWebContentsAndDelegate( 87 PasswordManager::CreateForWebContentsAndDelegate(
88 web_contents(), 88 web_contents(),
89 PasswordManagerDelegateImpl::FromWebContents(web_contents())); 89 PasswordManagerDelegateImpl::FromWebContents(web_contents()));
90 90
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 prefs->SetBoolean(prefs::kSyncKeepEverythingSynced, false); 203 prefs->SetBoolean(prefs::kSyncKeepEverythingSynced, false);
204 // Always set password generation enabled check box so we can test the 204 // Always set password generation enabled check box so we can test the
205 // behavior of password sync. 205 // behavior of password sync.
206 prefs->SetBoolean(prefs::kPasswordGenerationEnabled, true); 206 prefs->SetBoolean(prefs::kPasswordGenerationEnabled, true);
207 207
208 browser_sync::SyncPrefs sync_prefs(profile()->GetPrefs()); 208 browser_sync::SyncPrefs sync_prefs(profile()->GetPrefs());
209 sync_prefs.SetSyncSetupCompleted(); 209 sync_prefs.SetSyncSetupCompleted();
210 UpdateState(false); 210 UpdateState(false);
211 EXPECT_EQ(0u, password_generation_manager_->GetSentStates().size()); 211 EXPECT_EQ(0u, password_generation_manager_->GetSentStates().size());
212 } 212 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/password_manager/password_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698