| OLD | NEW |
| 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 Loading... |
| 118 WebContents* RenderViewHostTestHarness::CreateTestWebContents() { | 118 WebContents* RenderViewHostTestHarness::CreateTestWebContents() { |
| 119 // Make sure we ran SetUp() already. | 119 // Make sure we ran SetUp() already. |
| 120 #if defined(OS_WIN) | 120 #if defined(OS_WIN) |
| 121 DCHECK(ole_initializer_ != NULL); | 121 DCHECK(ole_initializer_ != NULL); |
| 122 #endif | 122 #endif |
| 123 #if defined(USE_AURA) | 123 #if defined(USE_AURA) |
| 124 DCHECK(aura_test_helper_ != NULL); | 124 DCHECK(aura_test_helper_ != NULL); |
| 125 #endif | 125 #endif |
| 126 | 126 |
| 127 // See comment above browser_context_ decl for why we check for NULL here. | 127 // See comment above browser_context_ decl for why we check for NULL here. |
| 128 if (!browser_context_.get()) | 128 if (!browser_context_) |
| 129 browser_context_.reset(new TestBrowserContext()); | 129 browser_context_.reset(new TestBrowserContext()); |
| 130 | 130 |
| 131 // This will be deleted when the WebContentsImpl goes away. | 131 // This will be deleted when the WebContentsImpl goes away. |
| 132 SiteInstance* instance = SiteInstance::Create(browser_context_.get()); | 132 SiteInstance* instance = SiteInstance::Create(browser_context_.get()); |
| 133 | 133 |
| 134 return TestWebContents::Create(browser_context_.get(), instance); | 134 return TestWebContents::Create(browser_context_.get(), instance); |
| 135 } | 135 } |
| 136 | 136 |
| 137 void RenderViewHostTestHarness::NavigateAndCommit(const GURL& url) { | 137 void RenderViewHostTestHarness::NavigateAndCommit(const GURL& url) { |
| 138 static_cast<TestWebContents*>(web_contents())->NavigateAndCommit(url); | 138 static_cast<TestWebContents*>(web_contents())->NavigateAndCommit(url); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 168 void RenderViewHostTestHarness::TearDown() { | 168 void RenderViewHostTestHarness::TearDown() { |
| 169 SetContents(NULL); | 169 SetContents(NULL); |
| 170 #if defined(USE_AURA) | 170 #if defined(USE_AURA) |
| 171 aura_test_helper_->TearDown(); | 171 aura_test_helper_->TearDown(); |
| 172 #endif | 172 #endif |
| 173 // Make sure that we flush any messages related to WebContentsImpl destruction | 173 // Make sure that we flush any messages related to WebContentsImpl destruction |
| 174 // before we destroy the browser context. | 174 // before we destroy the browser context. |
| 175 base::RunLoop().RunUntilIdle(); | 175 base::RunLoop().RunUntilIdle(); |
| 176 | 176 |
| 177 // Delete any RenderProcessHosts before the BrowserContext goes away. | 177 // Delete any RenderProcessHosts before the BrowserContext goes away. |
| 178 if (rvh_test_enabler_.rph_factory_.get()) | 178 if (rvh_test_enabler_.rph_factory_) |
| 179 rvh_test_enabler_.rph_factory_.reset(); | 179 rvh_test_enabler_.rph_factory_.reset(); |
| 180 | 180 |
| 181 // Release the browser context on the UI thread. | 181 // Release the browser context on the UI thread. |
| 182 message_loop_.DeleteSoon(FROM_HERE, browser_context_.release()); | 182 message_loop_.DeleteSoon(FROM_HERE, browser_context_.release()); |
| 183 base::RunLoop().RunUntilIdle(); | 183 base::RunLoop().RunUntilIdle(); |
| 184 | 184 |
| 185 #if defined(OS_WIN) | 185 #if defined(OS_WIN) |
| 186 ole_initializer_.reset(); | 186 ole_initializer_.reset(); |
| 187 #endif | 187 #endif |
| 188 } | 188 } |
| 189 | 189 |
| 190 void RenderViewHostTestHarness::SetRenderProcessHostFactory( | 190 void RenderViewHostTestHarness::SetRenderProcessHostFactory( |
| 191 RenderProcessHostFactory* factory) { | 191 RenderProcessHostFactory* factory) { |
| 192 rvh_test_enabler_.rvh_factory_->set_render_process_host_factory(factory); | 192 rvh_test_enabler_.rvh_factory_->set_render_process_host_factory(factory); |
| 193 } | 193 } |
| 194 | 194 |
| 195 } // namespace content | 195 } // namespace content |
| OLD | NEW |