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/render_view_test.h" | 5 #include "content/public/test/render_view_test.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <cctype> | 9 #include <cctype> |
10 | 10 |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 } | 149 } |
150 | 150 |
151 RenderViewTest::RenderViewTest() | 151 RenderViewTest::RenderViewTest() |
152 : view_(NULL) { | 152 : view_(NULL) { |
153 RenderFrameImpl::InstallCreateHook(&TestRenderFrame::CreateTestRenderFrame); | 153 RenderFrameImpl::InstallCreateHook(&TestRenderFrame::CreateTestRenderFrame); |
154 } | 154 } |
155 | 155 |
156 RenderViewTest::~RenderViewTest() { | 156 RenderViewTest::~RenderViewTest() { |
157 } | 157 } |
158 | 158 |
159 void RenderViewTest::ProcessPendingMessages() { | |
160 msg_loop_.task_runner()->PostTask(FROM_HERE, | |
161 base::MessageLoop::QuitWhenIdleClosure()); | |
162 base::RunLoop().Run(); | |
163 } | |
164 | |
165 WebLocalFrame* RenderViewTest::GetMainFrame() { | 159 WebLocalFrame* RenderViewTest::GetMainFrame() { |
166 return view_->GetWebView()->MainFrame()->ToWebLocalFrame(); | 160 return view_->GetWebView()->MainFrame()->ToWebLocalFrame(); |
167 } | 161 } |
168 | 162 |
169 void RenderViewTest::ExecuteJavaScriptForTests(const char* js) { | 163 void RenderViewTest::ExecuteJavaScriptForTests(const char* js) { |
170 GetMainFrame()->ExecuteScript(WebScriptSource(WebString::FromUTF8(js))); | 164 GetMainFrame()->ExecuteScript(WebScriptSource(WebString::FromUTF8(js))); |
171 } | 165 } |
172 | 166 |
173 bool RenderViewTest::ExecuteJavaScriptAndReturnIntValue( | 167 bool RenderViewTest::ExecuteJavaScriptAndReturnIntValue( |
174 const base::string16& script, | 168 const base::string16& script, |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 view_params.max_size = gfx::Size(); | 309 view_params.max_size = gfx::Size(); |
316 | 310 |
317 // This needs to pass the mock render thread to the view. | 311 // This needs to pass the mock render thread to the view. |
318 RenderViewImpl* view = RenderViewImpl::Create( | 312 RenderViewImpl* view = RenderViewImpl::Create( |
319 compositor_deps_.get(), view_params, RenderWidget::ShowCallback()); | 313 compositor_deps_.get(), view_params, RenderWidget::ShowCallback()); |
320 view_ = view; | 314 view_ = view; |
321 } | 315 } |
322 | 316 |
323 void RenderViewTest::TearDown() { | 317 void RenderViewTest::TearDown() { |
324 // Run the loop so the release task from the renderwidget executes. | 318 // Run the loop so the release task from the renderwidget executes. |
325 ProcessPendingMessages(); | 319 base::RunLoop().RunUntilIdle(); |
326 | 320 |
327 render_thread_->SendCloseMessage(); | 321 render_thread_->SendCloseMessage(); |
328 | 322 |
329 std::unique_ptr<blink::WebLeakDetector> leak_detector = | 323 std::unique_ptr<blink::WebLeakDetector> leak_detector = |
330 base::WrapUnique(blink::WebLeakDetector::Create(this)); | 324 base::WrapUnique(blink::WebLeakDetector::Create(this)); |
331 | 325 |
332 leak_detector->PrepareForLeakDetection(view_->GetWebView()->MainFrame()); | 326 leak_detector->PrepareForLeakDetection(view_->GetWebView()->MainFrame()); |
333 | 327 |
334 view_ = NULL; | 328 view_ = NULL; |
335 mock_process_.reset(); | 329 mock_process_.reset(); |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 static_cast<TestRenderFrame*>(impl->GetMainRenderFrame()); | 662 static_cast<TestRenderFrame*>(impl->GetMainRenderFrame()); |
669 frame->Navigate(common_params, StartNavigationParams(), request_params); | 663 frame->Navigate(common_params, StartNavigationParams(), request_params); |
670 | 664 |
671 // The load actually happens asynchronously, so we pump messages to process | 665 // The load actually happens asynchronously, so we pump messages to process |
672 // the pending continuation. | 666 // the pending continuation. |
673 FrameLoadWaiter(frame).Wait(); | 667 FrameLoadWaiter(frame).Wait(); |
674 view_->GetWebView()->UpdateAllLifecyclePhases(); | 668 view_->GetWebView()->UpdateAllLifecyclePhases(); |
675 } | 669 } |
676 | 670 |
677 } // namespace content | 671 } // namespace content |
OLD | NEW |