ProfilePolicyConnectorFactory: Refactoring from Profile to BrowserContext.
[chromium-blink-merge.git] / android_webview / browser / test / rendering_test.cc
blobfe69bcd6d3c54b018a600a8b13dbd23ab8e40390
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 "base/message_loop/message_loop.h"
9 #include "content/public/test/test_synchronous_compositor_android.h"
11 namespace android_webview {
13 RenderingTest::RenderingTest() : message_loop_(new base::MessageLoop) {
14 ui_proxy_ = base::MessageLoopProxy::current();
17 RenderingTest::~RenderingTest() {
18 if (window_.get())
19 window_->Detach();
22 void RenderingTest::SetUpTestHarness() {
23 DCHECK(!browser_view_renderer_.get());
24 browser_view_renderer_.reset(
25 new BrowserViewRenderer(this, base::MessageLoopProxy::current()));
26 InitializeCompositor();
27 Attach();
30 void RenderingTest::InitializeCompositor() {
31 DCHECK(!compositor_.get());
32 DCHECK(browser_view_renderer_.get());
33 compositor_.reset(new content::TestSynchronousCompositor);
34 compositor_->SetClient(browser_view_renderer_.get());
37 void RenderingTest::Attach() {
38 window_.reset(
39 new FakeWindow(browser_view_renderer_.get(), this, gfx::Rect(100, 100)));
42 void RenderingTest::RunTest() {
43 SetUpTestHarness();
45 ui_proxy_->PostTask(
46 FROM_HERE, base::Bind(&RenderingTest::StartTest, base::Unretained(this)));
47 message_loop_->Run();
50 void RenderingTest::StartTest() {
51 EndTest();
54 void RenderingTest::EndTest() {
55 ui_proxy_->PostTask(FROM_HERE, base::Bind(&RenderingTest::QuitMessageLoop,
56 base::Unretained(this)));
59 void RenderingTest::QuitMessageLoop() {
60 DCHECK_EQ(base::MessageLoop::current(), message_loop_.get());
61 message_loop_->QuitWhenIdle();
64 bool RenderingTest::RequestDrawGL(bool wait_for_completion) {
65 window_->RequestDrawGL(wait_for_completion);
66 return true;
69 void RenderingTest::OnNewPicture() {
72 void RenderingTest::PostInvalidate() {
73 window_->PostInvalidate();
76 void RenderingTest::DetachFunctorFromView() {
79 gfx::Point RenderingTest::GetLocationOnScreen() {
80 return gfx::Point();
83 bool RenderingTest::IsFlingActive() const {
84 return false;
87 } // namespace android_webview