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

Side by Side Diff: content/public/test/test_renderer_host.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 | « content/public/test/test_renderer_host.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/public/test/test_renderer_host.h" 5 #include "content/public/test/test_renderer_host.h"
6 6
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "content/browser/renderer_host/render_view_host_factory.h" 8 #include "content/browser/renderer_host/render_view_host_factory.h"
9 #include "content/browser/renderer_host/render_widget_host_impl.h" 9 #include "content/browser/renderer_host/render_widget_host_impl.h"
10 #include "content/browser/renderer_host/test_render_view_host.h" 10 #include "content/browser/renderer_host/test_render_view_host.h"
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 118
119 WebContents* RenderViewHostTestHarness::CreateTestWebContents() { 119 WebContents* RenderViewHostTestHarness::CreateTestWebContents() {
120 // Make sure we ran SetUp() already. 120 // Make sure we ran SetUp() already.
121 #if defined(OS_WIN) 121 #if defined(OS_WIN)
122 DCHECK(ole_initializer_ != NULL); 122 DCHECK(ole_initializer_ != NULL);
123 #endif 123 #endif
124 #if defined(USE_AURA) 124 #if defined(USE_AURA)
125 DCHECK(aura_test_helper_ != NULL); 125 DCHECK(aura_test_helper_ != NULL);
126 #endif 126 #endif
127 127
128 // See comment above browser_context_ decl for why we check for NULL here.
129 if (!browser_context_)
130 browser_context_.reset(new TestBrowserContext());
131
132 // This will be deleted when the WebContentsImpl goes away. 128 // This will be deleted when the WebContentsImpl goes away.
133 SiteInstance* instance = SiteInstance::Create(browser_context_.get()); 129 SiteInstance* instance = SiteInstance::Create(browser_context_.get());
134 130
135 return TestWebContents::Create(browser_context_.get(), instance); 131 return TestWebContents::Create(browser_context_.get(), instance);
136 } 132 }
137 133
138 void RenderViewHostTestHarness::NavigateAndCommit(const GURL& url) { 134 void RenderViewHostTestHarness::NavigateAndCommit(const GURL& url) {
139 static_cast<TestWebContents*>(web_contents())->NavigateAndCommit(url); 135 static_cast<TestWebContents*>(web_contents())->NavigateAndCommit(url);
140 } 136 }
141 137
(...skipping 17 matching lines...) Expand all
159 thread_bundle_.reset(new TestBrowserThreadBundle(thread_bundle_options_)); 155 thread_bundle_.reset(new TestBrowserThreadBundle(thread_bundle_options_));
160 156
161 #if defined(OS_WIN) 157 #if defined(OS_WIN)
162 ole_initializer_.reset(new ui::ScopedOleInitializer()); 158 ole_initializer_.reset(new ui::ScopedOleInitializer());
163 #endif 159 #endif
164 #if defined(USE_AURA) 160 #if defined(USE_AURA)
165 aura_test_helper_.reset( 161 aura_test_helper_.reset(
166 new aura::test::AuraTestHelper(base::MessageLoopForUI::current())); 162 new aura::test::AuraTestHelper(base::MessageLoopForUI::current()));
167 aura_test_helper_->SetUp(); 163 aura_test_helper_->SetUp();
168 #endif 164 #endif
165
166 DCHECK(!browser_context_);
167 browser_context_.reset(CreateBrowserContext());
168
169 SetContents(CreateTestWebContents()); 169 SetContents(CreateTestWebContents());
170 } 170 }
171 171
172 void RenderViewHostTestHarness::TearDown() { 172 void RenderViewHostTestHarness::TearDown() {
173 SetContents(NULL); 173 SetContents(NULL);
174 #if defined(USE_AURA) 174 #if defined(USE_AURA)
175 aura_test_helper_->TearDown(); 175 aura_test_helper_->TearDown();
176 #endif 176 #endif
177 // Make sure that we flush any messages related to WebContentsImpl destruction 177 // Make sure that we flush any messages related to WebContentsImpl destruction
178 // before we destroy the browser context. 178 // before we destroy the browser context.
(...skipping 10 matching lines...) Expand all
189 // Release the browser context by posting itself on the end of the task 189 // Release the browser context by posting itself on the end of the task
190 // queue. This is preferable to immediate deletion because it will behave 190 // queue. This is preferable to immediate deletion because it will behave
191 // properly if the |rph_factory_| reset above enqueued any tasks which 191 // properly if the |rph_factory_| reset above enqueued any tasks which
192 // depend on |browser_context_|. 192 // depend on |browser_context_|.
193 BrowserThread::DeleteSoon(content::BrowserThread::UI, 193 BrowserThread::DeleteSoon(content::BrowserThread::UI,
194 FROM_HERE, 194 FROM_HERE,
195 browser_context_.release()); 195 browser_context_.release());
196 thread_bundle_.reset(); 196 thread_bundle_.reset();
197 } 197 }
198 198
199 BrowserContext* RenderViewHostTestHarness::CreateBrowserContext() {
200 return new TestBrowserContext();
201 }
202
199 void RenderViewHostTestHarness::SetRenderProcessHostFactory( 203 void RenderViewHostTestHarness::SetRenderProcessHostFactory(
200 RenderProcessHostFactory* factory) { 204 RenderProcessHostFactory* factory) {
201 rvh_test_enabler_.rvh_factory_->set_render_process_host_factory(factory); 205 rvh_test_enabler_.rvh_factory_->set_render_process_host_factory(factory);
202 } 206 }
203 207
204 } // namespace content 208 } // namespace content
OLDNEW
« no previous file with comments | « content/public/test/test_renderer_host.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698