Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / android_webview / browser / test / rendering_test.cc
blobc4ddb3b65d6aa5eaf80fa81045d5e96ba8a4a935
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/message_loop/message_loop.h"
10 #include "content/public/test/test_synchronous_compositor_android.h"
12 namespace android_webview {
14 RenderingTest::RenderingTest() : message_loop_(new base::MessageLoop) {
15 ui_proxy_ = base::MessageLoopProxy::current();
18 RenderingTest::~RenderingTest() {
19 if (window_.get())
20 window_->Detach();
23 void RenderingTest::SetUpTestHarness() {
24 DCHECK(!browser_view_renderer_.get());
25 browser_view_renderer_.reset(
26 new BrowserViewRenderer(this, base::MessageLoopProxy::current()));
27 InitializeCompositor();
28 Attach();
31 void RenderingTest::InitializeCompositor() {
32 DCHECK(!compositor_.get());
33 DCHECK(browser_view_renderer_.get());
34 compositor_.reset(new content::TestSynchronousCompositor);
35 compositor_->SetClient(browser_view_renderer_.get());
38 void RenderingTest::Attach() {
39 window_.reset(
40 new FakeWindow(browser_view_renderer_.get(), this, gfx::Rect(100, 100)));
43 void RenderingTest::RunTest() {
44 SetUpTestHarness();
46 ui_proxy_->PostTask(
47 FROM_HERE, base::Bind(&RenderingTest::StartTest, base::Unretained(this)));
48 message_loop_->Run();
51 void RenderingTest::StartTest() {
52 EndTest();
55 void RenderingTest::EndTest() {
56 ui_proxy_->PostTask(FROM_HERE, base::Bind(&RenderingTest::QuitMessageLoop,
57 base::Unretained(this)));
60 void RenderingTest::QuitMessageLoop() {
61 DCHECK_EQ(base::MessageLoop::current(), message_loop_.get());
62 message_loop_->QuitWhenIdle();
65 bool RenderingTest::RequestDrawGL(bool wait_for_completion) {
66 window_->RequestDrawGL(wait_for_completion);
67 return true;
70 bool RenderingTest::WillDrawOnRT(SharedRendererState* functor,
71 AwDrawGLInfo* draw_info) {
72 draw_info->width = window_->surface_size().width();
73 draw_info->height = window_->surface_size().height();
74 draw_info->is_layer = false;
75 gfx::Transform transform;
76 transform.matrix().asColMajorf(draw_info->transform);
77 return true;
80 void RenderingTest::OnNewPicture() {
83 void RenderingTest::PostInvalidate() {
84 window_->PostInvalidate();
87 void RenderingTest::DetachFunctorFromView() {
90 gfx::Point RenderingTest::GetLocationOnScreen() {
91 return gfx::Point();
94 bool RenderingTest::IsFlingActive() const {
95 return false;
98 } // namespace android_webview