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

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

Issue 14197014: Add TestBrowserThreadBundle into RenderViewHostTestHarness. Kill some unnecessary real threads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merged ToT Created 7 years, 6 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
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 24 matching lines...) Expand all
35 sent_states_.clear(); 35 sent_states_.clear();
36 } 36 }
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 public: 45 protected:
46 PasswordGenerationManagerTest()
47 : ChromeRenderViewHostTestHarness(),
48 ui_thread_(content::BrowserThread::UI, &message_loop_),
49 io_thread_(content::BrowserThread::IO) {}
50
51 virtual void SetUp() OVERRIDE { 46 virtual void SetUp() OVERRIDE {
52 TestingProfile* profile = CreateProfile(); 47 TestingProfile* profile = CreateProfile();
53 profile->CreateRequestContext(); 48 profile->CreateRequestContext();
54 browser_context_.reset(profile); 49 browser_context_.reset(profile);
55 50
51 SetThreadBundleOptions(content::TestBrowserThreadBundle::REAL_IO_THREAD);
56 ChromeRenderViewHostTestHarness::SetUp(); 52 ChromeRenderViewHostTestHarness::SetUp();
57 io_thread_.StartIOThread();
58 53
59 password_generation_manager_.reset( 54 password_generation_manager_.reset(
60 new TestPasswordGenerationManager(web_contents())); 55 new TestPasswordGenerationManager(web_contents()));
61 } 56 }
62 57
63 virtual void TearDown() OVERRIDE { 58 virtual void TearDown() OVERRIDE {
64 ChromeRenderViewHostTestHarness::TearDown(); 59 ChromeRenderViewHostTestHarness::TearDown();
65 } 60 }
66 61
67 virtual TestingProfile* CreateProfile() { 62 virtual TestingProfile* CreateProfile() {
68 return new TestingProfile(); 63 return new TestingProfile();
69 } 64 }
70 65
71 void UpdateState(bool new_renderer) { 66 void UpdateState(bool new_renderer) {
72 password_generation_manager_->UpdateState(NULL, new_renderer); 67 password_generation_manager_->UpdateState(NULL, new_renderer);
73 } 68 }
74 69
75 protected:
76 content::TestBrowserThread ui_thread_;
77 content::TestBrowserThread io_thread_;
78
79 scoped_ptr<TestPasswordGenerationManager> password_generation_manager_; 70 scoped_ptr<TestPasswordGenerationManager> password_generation_manager_;
80 }; 71 };
81 72
82 class IncognitoPasswordGenerationManagerTest : 73 class IncognitoPasswordGenerationManagerTest :
83 public PasswordGenerationManagerTest { 74 public PasswordGenerationManagerTest {
84 public: 75 public:
85 virtual TestingProfile* CreateProfile() OVERRIDE { 76 virtual TestingProfile* CreateProfile() OVERRIDE {
86 // Create an incognito profile. 77 // Create an incognito profile.
87 TestingProfile::Builder builder; 78 TestingProfile::Builder builder;
88 scoped_ptr<TestingProfile> profile = builder.Build(); 79 scoped_ptr<TestingProfile> profile = builder.Build();
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 prefs->SetBoolean(prefs::kSyncKeepEverythingSynced, false); 203 prefs->SetBoolean(prefs::kSyncKeepEverythingSynced, false);
213 // 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
214 // behavior of password sync. 205 // behavior of password sync.
215 prefs->SetBoolean(prefs::kPasswordGenerationEnabled, true); 206 prefs->SetBoolean(prefs::kPasswordGenerationEnabled, true);
216 207
217 browser_sync::SyncPrefs sync_prefs(profile()->GetPrefs()); 208 browser_sync::SyncPrefs sync_prefs(profile()->GetPrefs());
218 sync_prefs.SetSyncSetupCompleted(); 209 sync_prefs.SetSyncSetupCompleted();
219 UpdateState(false); 210 UpdateState(false);
220 EXPECT_EQ(0u, password_generation_manager_->GetSentStates().size()); 211 EXPECT_EQ(0u, password_generation_manager_->GetSentStates().size());
221 } 212 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698