OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef ANDROID_WEBVIEW_BROWSER_TEST_RENDERING_TEST_H_ | 5 #ifndef ANDROID_WEBVIEW_BROWSER_TEST_RENDERING_TEST_H_ |
6 #define ANDROID_WEBVIEW_BROWSER_TEST_RENDERING_TEST_H_ | 6 #define ANDROID_WEBVIEW_BROWSER_TEST_RENDERING_TEST_H_ |
7 | 7 |
8 #include "android_webview/browser/browser_view_renderer_client.h" | 8 #include "android_webview/browser/browser_view_renderer_client.h" |
9 #include "android_webview/browser/shared_renderer_state_client.h" | |
9 #include "android_webview/browser/test/fake_window.h" | 10 #include "android_webview/browser/test/fake_window.h" |
10 #include "base/macros.h" | 11 #include "base/macros.h" |
11 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
12 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
14 | 15 |
15 namespace base { | 16 namespace base { |
16 class MessageLoop; | 17 class MessageLoop; |
17 } | 18 } |
18 | 19 |
19 namespace cc { | 20 namespace cc { |
20 class CompositorFrame; | 21 class CompositorFrame; |
21 } | 22 } |
22 | 23 |
23 namespace content { | 24 namespace content { |
24 class TestSynchronousCompositor; | 25 class TestSynchronousCompositor; |
25 } | 26 } |
26 | 27 |
27 namespace android_webview { | 28 namespace android_webview { |
28 | 29 |
29 class BrowserViewRenderer; | 30 class BrowserViewRenderer; |
30 class FakeWindow; | 31 class FakeWindow; |
31 struct ParentCompositorDrawConstraints; | 32 struct ParentCompositorDrawConstraints; |
32 | 33 |
33 class RenderingTest : public testing::Test, | 34 class RenderingTest : public testing::Test, |
34 public BrowserViewRendererClient, | 35 public BrowserViewRendererClient, |
36 public SharedRendererStateClient, | |
35 public WindowHooks { | 37 public WindowHooks { |
36 public: | 38 public: |
37 // BrowserViewRendererClient overrides. | 39 // BrowserViewRendererClient overrides. |
38 bool RequestDrawGL(bool wait_for_completion) override; | |
39 void OnNewPicture() override; | 40 void OnNewPicture() override; |
40 void PostInvalidate() override; | 41 void PostInvalidate() override; |
41 void DetachFunctorFromView() override; | |
42 gfx::Point GetLocationOnScreen() override; | 42 gfx::Point GetLocationOnScreen() override; |
43 void ScrollContainerViewTo(const gfx::Vector2d& new_value) override {} | 43 void ScrollContainerViewTo(const gfx::Vector2d& new_value) override {} |
44 void UpdateScrollState(const gfx::Vector2d& max_scroll_offset, | 44 void UpdateScrollState(const gfx::Vector2d& max_scroll_offset, |
45 const gfx::SizeF& contents_size_dip, | 45 const gfx::SizeF& contents_size_dip, |
46 float page_scale_factor, | 46 float page_scale_factor, |
47 float min_page_scale_factor, | 47 float min_page_scale_factor, |
48 float max_page_scale_factor) override {} | 48 float max_page_scale_factor) override {} |
49 void DidOverscroll(const gfx::Vector2d& overscroll_delta, | 49 void DidOverscroll(const gfx::Vector2d& overscroll_delta, |
50 const gfx::Vector2dF& overscroll_velocity) override {} | 50 const gfx::Vector2dF& overscroll_velocity) override {} |
51 void ParentDrawConstraintsUpdated( | 51 void ParentDrawConstraintsUpdated( |
52 const ParentCompositorDrawConstraints& draw_constraints) override {} | 52 const ParentCompositorDrawConstraints& draw_constraints) override {} |
53 | |
54 // SharedRendererStateClient overrides. | |
55 void UpdateParentDrawConstraints() override; | |
56 bool RequestDrawGL(bool wait_for_completion) override; | |
57 void DetachFunctorFromView() override; | |
58 | |
53 // WindowHooks overrides. | 59 // WindowHooks overrides. |
54 void WillOnDraw() override; | 60 void WillOnDraw() override; |
55 void DidOnDraw(bool success) override {} | 61 void DidOnDraw(bool success) override {} |
56 void WillSyncOnRT(SharedRendererState* functor) override {} | 62 void WillSyncOnRT(SharedRendererState* functor) override {} |
57 void DidSyncOnRT(SharedRendererState* functor) override {} | 63 void DidSyncOnRT(SharedRendererState* functor) override {} |
58 void WillProcessOnRT(SharedRendererState* functor) override {} | 64 void WillProcessOnRT(SharedRendererState* functor) override {} |
59 void DidProcessOnRT(SharedRendererState* functor) override {} | 65 void DidProcessOnRT(SharedRendererState* functor) override {} |
60 bool WillDrawOnRT(SharedRendererState* functor, | 66 bool WillDrawOnRT(SharedRendererState* functor, |
61 AwDrawGLInfo* draw_info) override; | 67 AwDrawGLInfo* draw_info) override; |
62 void DidDrawOnRT(SharedRendererState* functor) override {} | 68 void DidDrawOnRT(SharedRendererState* functor) override {} |
63 | 69 |
64 protected: | 70 protected: |
65 | 71 |
66 RenderingTest(); | 72 RenderingTest(); |
67 ~RenderingTest() override; | 73 ~RenderingTest() override; |
68 | 74 |
69 virtual void SetUpTestHarness(); | 75 virtual void SetUpTestHarness(); |
70 virtual void StartTest(); | 76 virtual void StartTest(); |
71 | 77 |
72 void RunTest(); | 78 void RunTest(); |
73 void InitializeCompositor(); | 79 void InitializeCompositor(); |
74 void Attach(); | 80 void Attach(); |
75 void EndTest(); | 81 void EndTest(); |
76 scoped_ptr<cc::CompositorFrame> ConstructEmptyFrame(); | 82 scoped_ptr<cc::CompositorFrame> ConstructEmptyFrame(); |
77 | 83 |
78 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; | 84 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; |
79 scoped_ptr<BrowserViewRenderer> browser_view_renderer_; | 85 scoped_ptr<BrowserViewRenderer> browser_view_renderer_; |
86 scoped_ptr<SharedRendererState> shared_renderer_state_; | |
boliu
2016/03/30 16:12:13
need to be above BVR like in aw_contents
Tobias Sargeant
2016/03/30 17:17:17
Done.
| |
80 scoped_ptr<content::TestSynchronousCompositor> compositor_; | 87 scoped_ptr<content::TestSynchronousCompositor> compositor_; |
81 scoped_ptr<FakeWindow> window_; | 88 scoped_ptr<FakeWindow> window_; |
82 | 89 |
83 private: | 90 private: |
84 void QuitMessageLoop(); | 91 void QuitMessageLoop(); |
85 | 92 |
86 const scoped_ptr<base::MessageLoop> message_loop_; | 93 const scoped_ptr<base::MessageLoop> message_loop_; |
87 | 94 |
88 DISALLOW_COPY_AND_ASSIGN(RenderingTest); | 95 DISALLOW_COPY_AND_ASSIGN(RenderingTest); |
89 }; | 96 }; |
90 | 97 |
91 #define RENDERING_TEST_F(TEST_FIXTURE_NAME) \ | 98 #define RENDERING_TEST_F(TEST_FIXTURE_NAME) \ |
92 TEST_F(TEST_FIXTURE_NAME, RunTest) { RunTest(); } \ | 99 TEST_F(TEST_FIXTURE_NAME, RunTest) { RunTest(); } \ |
93 class NeedsSemicolon##TEST_FIXTURE_NAME {} | 100 class NeedsSemicolon##TEST_FIXTURE_NAME {} |
94 | 101 |
95 } // namespace android_webview | 102 } // namespace android_webview |
96 | 103 |
97 #endif // ANDROID_WEBVIEW_BROWSER_TEST_RENDERING_TEST_H_ | 104 #endif // ANDROID_WEBVIEW_BROWSER_TEST_RENDERING_TEST_H_ |
OLD | NEW |