Update V8 to version 4.7.47.
[chromium-blink-merge.git] / android_webview / browser / test / rendering_test.cc
blob26799b86f07db971ae55918b7f1c306654767a5c
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "android_webview/browser/test/rendering_test.h"
7 #include "android_webview/browser/browser_view_renderer.h"
8 #include "android_webview/browser/child_frame.h"
9 #include "base/location.h"
10 #include "base/thread_task_runner_handle.h"
11 #include "content/public/test/test_synchronous_compositor_android.h"
13 namespace android_webview {
15 RenderingTest::RenderingTest() : message_loop_(new base::MessageLoop) {
16 ui_task_runner_ = base::ThreadTaskRunnerHandle::Get();
19 RenderingTest::~RenderingTest() {
20 if (window_.get())
21 window_->Detach();
24 void RenderingTest::SetUpTestHarness() {
25 DCHECK(!browser_view_renderer_.get());
26 browser_view_renderer_.reset(
27 new BrowserViewRenderer(this, base::ThreadTaskRunnerHandle::Get()));
28 InitializeCompositor();
29 Attach();
32 void RenderingTest::InitializeCompositor() {
33 DCHECK(!compositor_.get());
34 DCHECK(browser_view_renderer_.get());
35 compositor_.reset(new content::TestSynchronousCompositor);
36 compositor_->SetClient(browser_view_renderer_.get());
39 void RenderingTest::Attach() {
40 window_.reset(
41 new FakeWindow(browser_view_renderer_.get(), this, gfx::Rect(100, 100)));
44 void RenderingTest::RunTest() {
45 SetUpTestHarness();
47 ui_task_runner_->PostTask(
48 FROM_HERE, base::Bind(&RenderingTest::StartTest, base::Unretained(this)));
49 message_loop_->Run();
52 void RenderingTest::StartTest() {
53 EndTest();
56 void RenderingTest::EndTest() {
57 ui_task_runner_->PostTask(
58 FROM_HERE,
59 base::Bind(&RenderingTest::QuitMessageLoop, base::Unretained(this)));
62 void RenderingTest::QuitMessageLoop() {
63 DCHECK_EQ(base::MessageLoop::current(), message_loop_.get());
64 message_loop_->QuitWhenIdle();
67 bool RenderingTest::RequestDrawGL(bool wait_for_completion) {
68 window_->RequestDrawGL(wait_for_completion);
69 return true;
72 bool RenderingTest::WillDrawOnRT(SharedRendererState* functor,
73 AwDrawGLInfo* draw_info) {
74 draw_info->width = window_->surface_size().width();
75 draw_info->height = window_->surface_size().height();
76 draw_info->is_layer = false;
77 gfx::Transform transform;
78 transform.matrix().asColMajorf(draw_info->transform);
79 return true;
82 void RenderingTest::OnNewPicture() {
85 void RenderingTest::PostInvalidate() {
86 window_->PostInvalidate();
89 void RenderingTest::DetachFunctorFromView() {
92 gfx::Point RenderingTest::GetLocationOnScreen() {
93 return gfx::Point();
96 } // namespace android_webview