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() {
24 void RenderingTest::SetUpTestHarness() {
25 DCHECK(!browser_view_renderer_
.get());
26 browser_view_renderer_
.reset(
27 new BrowserViewRenderer(this, base::ThreadTaskRunnerHandle::Get()));
28 InitializeCompositor();
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() {
41 new FakeWindow(browser_view_renderer_
.get(), this, gfx::Rect(100, 100)));
44 void RenderingTest::RunTest() {
47 ui_task_runner_
->PostTask(
48 FROM_HERE
, base::Bind(&RenderingTest::StartTest
, base::Unretained(this)));
52 void RenderingTest::StartTest() {
56 void RenderingTest::EndTest() {
57 ui_task_runner_
->PostTask(
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
);
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
);
82 void RenderingTest::OnNewPicture() {
85 void RenderingTest::PostInvalidate() {
86 window_
->PostInvalidate();
89 void RenderingTest::DetachFunctorFromView() {
92 gfx::Point
RenderingTest::GetLocationOnScreen() {
96 } // namespace android_webview