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/test/test_renderer_host.h" | 5 #include "content/test/test_renderer_host.h" |
6 | 6 |
7 #include "content/browser/renderer_host/render_view_host_factory.h" | 7 #include "content/browser/renderer_host/render_view_host_factory.h" |
8 #include "content/browser/renderer_host/test_render_view_host.h" | 8 #include "content/browser/renderer_host/test_render_view_host.h" |
9 #include "content/browser/site_instance_impl.h" | 9 #include "content/browser/site_instance_impl.h" |
10 #include "content/browser/tab_contents/navigation_entry_impl.h" | 10 #include "content/browser/tab_contents/navigation_entry_impl.h" |
11 #include "content/browser/tab_contents/test_tab_contents.h" | 11 #include "content/browser/tab_contents/test_tab_contents.h" |
12 #include "content/test/mock_render_process_host.h" | 12 #include "content/test/mock_render_process_host.h" |
13 #include "content/test/test_browser_context.h" | 13 #include "content/test/test_browser_context.h" |
14 | 14 |
15 #if defined(USE_AURA) | 15 #if defined(USE_AURA) |
| 16 #include "ui/aura/env.h" |
| 17 #include "ui/aura/monitor_manager.h" |
16 #include "ui/aura/root_window.h" | 18 #include "ui/aura/root_window.h" |
17 #include "ui/aura/test/test_screen.h" | 19 #include "ui/aura/test/test_screen.h" |
18 #include "ui/aura/test/test_stacking_client.h" | 20 #include "ui/aura/test/test_stacking_client.h" |
19 #endif | 21 #endif |
20 | 22 |
21 namespace content { | 23 namespace content { |
22 | 24 |
23 // Manages creation of the RenderViewHosts using our special subclass. This | 25 // Manages creation of the RenderViewHosts using our special subclass. This |
24 // automatically registers itself when it goes in scope, and unregisters itself | 26 // automatically registers itself when it goes in scope, and unregisters itself |
25 // when it goes out of scope. Since you can't have more than one factory | 27 // when it goes out of scope. Since you can't have more than one factory |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 void RenderViewHostTestHarness::Reload() { | 176 void RenderViewHostTestHarness::Reload() { |
175 NavigationEntry* entry = controller().GetLastCommittedEntry(); | 177 NavigationEntry* entry = controller().GetLastCommittedEntry(); |
176 DCHECK(entry); | 178 DCHECK(entry); |
177 controller().Reload(false); | 179 controller().Reload(false); |
178 static_cast<TestRenderViewHost*>( | 180 static_cast<TestRenderViewHost*>( |
179 rvh())->SendNavigate(entry->GetPageID(), entry->GetURL()); | 181 rvh())->SendNavigate(entry->GetPageID(), entry->GetURL()); |
180 } | 182 } |
181 | 183 |
182 void RenderViewHostTestHarness::SetUp() { | 184 void RenderViewHostTestHarness::SetUp() { |
183 #if defined(USE_AURA) | 185 #if defined(USE_AURA) |
184 root_window_.reset(new aura::RootWindow); | 186 root_window_.reset(Env::GetInstance()->monitor_manager()-> |
| 187 CreateRootWindowForPrimaryMonitor()); |
185 gfx::Screen::SetInstance(new aura::TestScreen(root_window_.get())); | 188 gfx::Screen::SetInstance(new aura::TestScreen(root_window_.get())); |
186 test_stacking_client_.reset( | 189 test_stacking_client_.reset( |
187 new aura::test::TestStackingClient(root_window_.get())); | 190 new aura::test::TestStackingClient(root_window_.get())); |
188 #endif | 191 #endif |
189 SetContents(CreateTestTabContents()); | 192 SetContents(CreateTestTabContents()); |
190 } | 193 } |
191 | 194 |
192 void RenderViewHostTestHarness::TearDown() { | 195 void RenderViewHostTestHarness::TearDown() { |
193 SetContents(NULL); | 196 SetContents(NULL); |
194 #if defined(USE_AURA) | 197 #if defined(USE_AURA) |
195 test_stacking_client_.reset(); | 198 test_stacking_client_.reset(); |
196 root_window_.reset(); | 199 root_window_.reset(); |
197 #endif | 200 #endif |
198 | 201 |
199 // Make sure that we flush any messages related to TabContents destruction | 202 // Make sure that we flush any messages related to TabContents destruction |
200 // before we destroy the browser context. | 203 // before we destroy the browser context. |
201 MessageLoop::current()->RunAllPending(); | 204 MessageLoop::current()->RunAllPending(); |
202 | 205 |
203 // Release the browser context on the UI thread. | 206 // Release the browser context on the UI thread. |
204 message_loop_.DeleteSoon(FROM_HERE, browser_context_.release()); | 207 message_loop_.DeleteSoon(FROM_HERE, browser_context_.release()); |
205 message_loop_.RunAllPending(); | 208 message_loop_.RunAllPending(); |
206 } | 209 } |
207 | 210 |
208 void RenderViewHostTestHarness::SetRenderProcessHostFactory( | 211 void RenderViewHostTestHarness::SetRenderProcessHostFactory( |
209 RenderProcessHostFactory* factory) { | 212 RenderProcessHostFactory* factory) { |
210 rvh_test_enabler_.rvh_factory_->set_render_process_host_factory(factory); | 213 rvh_test_enabler_.rvh_factory_->set_render_process_host_factory(factory); |
211 } | 214 } |
212 | 215 |
213 } // namespace content | 216 } // namespace content |
OLD | NEW |