Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(200)

Side by Side Diff: android_webview/browser/browser_view_renderer_unittest.cc

Issue 1858853002: Rename SharedRendererState to RenderThreadManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include <map> 5 #include <map>
6 #include <queue> 6 #include <queue>
7 #include <utility> 7 #include <utility>
8 8
9 #include "android_webview/browser/browser_view_renderer.h" 9 #include "android_webview/browser/browser_view_renderer.h"
10 #include "android_webview/browser/child_frame.h" 10 #include "android_webview/browser/child_frame.h"
11 #include "android_webview/browser/test/rendering_test.h" 11 #include "android_webview/browser/test/rendering_test.h"
12 #include "base/location.h" 12 #include "base/location.h"
13 #include "base/single_thread_task_runner.h" 13 #include "base/single_thread_task_runner.h"
14 #include "cc/output/compositor_frame.h" 14 #include "cc/output/compositor_frame.h"
15 #include "content/public/test/test_synchronous_compositor_android.h" 15 #include "content/public/test/test_synchronous_compositor_android.h"
16 16
17 namespace android_webview { 17 namespace android_webview {
18 18
19 class SmokeTest : public RenderingTest { 19 class SmokeTest : public RenderingTest {
20 void StartTest() override { browser_view_renderer_->PostInvalidate(); } 20 void StartTest() override { browser_view_renderer_->PostInvalidate(); }
21 21
22 void DidDrawOnRT(SharedRendererState* functor) override { 22 void DidDrawOnRT(RenderThreadManager* functor) override {
23 EndTest(); 23 EndTest();
24 } 24 }
25 }; 25 };
26 26
27 RENDERING_TEST_F(SmokeTest); 27 RENDERING_TEST_F(SmokeTest);
28 28
29 class ClearViewTest : public RenderingTest { 29 class ClearViewTest : public RenderingTest {
30 public: 30 public:
31 ClearViewTest() : on_draw_count_(0) {} 31 ClearViewTest() : on_draw_count_(0) {}
32 32
33 void StartTest() override { 33 void StartTest() override {
34 browser_view_renderer_->PostInvalidate(); 34 browser_view_renderer_->PostInvalidate();
35 browser_view_renderer_->ClearView(); 35 browser_view_renderer_->ClearView();
36 } 36 }
37 37
38 void DidOnDraw(bool success) override { 38 void DidOnDraw(bool success) override {
39 on_draw_count_++; 39 on_draw_count_++;
40 if (on_draw_count_ == 1) { 40 if (on_draw_count_ == 1) {
41 // First OnDraw should be skipped due to ClearView. 41 // First OnDraw should be skipped due to ClearView.
42 EXPECT_FALSE(success); 42 EXPECT_FALSE(success);
43 browser_view_renderer_->DidUpdateContent(); // Unset ClearView. 43 browser_view_renderer_->DidUpdateContent(); // Unset ClearView.
44 browser_view_renderer_->PostInvalidate(); 44 browser_view_renderer_->PostInvalidate();
45 } else { 45 } else {
46 // Following OnDraws should succeed. 46 // Following OnDraws should succeed.
47 EXPECT_TRUE(success); 47 EXPECT_TRUE(success);
48 } 48 }
49 } 49 }
50 50
51 void DidDrawOnRT(SharedRendererState* functor) override { 51 void DidDrawOnRT(RenderThreadManager* functor) override {
52 EndTest(); 52 EndTest();
53 } 53 }
54 private: 54 private:
55 int on_draw_count_; 55 int on_draw_count_;
56 }; 56 };
57 57
58 RENDERING_TEST_F(ClearViewTest); 58 RENDERING_TEST_F(ClearViewTest);
59 59
60 class TestAnimateInAndOutOfScreen : public RenderingTest { 60 class TestAnimateInAndOutOfScreen : public RenderingTest {
61 public: 61 public:
(...skipping 17 matching lines...) Expand all
79 // draw constraints of BVR is updated to initial constraints. 79 // draw constraints of BVR is updated to initial constraints.
80 if (on_draw_count_ == 1 || on_draw_count_ == 2) 80 if (on_draw_count_ == 1 || on_draw_count_ == 2)
81 browser_view_renderer_->PrepareToDraw(gfx::Vector2d(), gfx::Rect()); 81 browser_view_renderer_->PrepareToDraw(gfx::Vector2d(), gfx::Rect());
82 } 82 }
83 83
84 void DidOnDraw(bool success) override { 84 void DidOnDraw(bool success) override {
85 EXPECT_TRUE(success); 85 EXPECT_TRUE(success);
86 on_draw_count_++; 86 on_draw_count_++;
87 } 87 }
88 88
89 bool WillDrawOnRT(SharedRendererState* functor, 89 bool WillDrawOnRT(RenderThreadManager* functor,
90 AwDrawGLInfo* draw_info) override { 90 AwDrawGLInfo* draw_info) override {
91 if (draw_gl_count_on_rt_ == 1) { 91 if (draw_gl_count_on_rt_ == 1) {
92 draw_gl_count_on_rt_++; 92 draw_gl_count_on_rt_++;
93 ui_task_runner_->PostTask( 93 ui_task_runner_->PostTask(
94 FROM_HERE, 94 FROM_HERE,
95 base::Bind(&RenderingTest::PostInvalidate, base::Unretained(this))); 95 base::Bind(&RenderingTest::PostInvalidate, base::Unretained(this)));
96 return false; 96 return false;
97 } 97 }
98 98
99 draw_info->width = window_->surface_size().width(); 99 draw_info->width = window_->surface_size().width();
100 draw_info->height = window_->surface_size().height(); 100 draw_info->height = window_->surface_size().height();
101 draw_info->is_layer = false; 101 draw_info->is_layer = false;
102 102
103 gfx::Transform transform; 103 gfx::Transform transform;
104 if (draw_gl_count_on_rt_ == 0) 104 if (draw_gl_count_on_rt_ == 0)
105 transform = new_constraints_.transform; 105 transform = new_constraints_.transform;
106 106
107 transform.matrix().asColMajorf(draw_info->transform); 107 transform.matrix().asColMajorf(draw_info->transform);
108 return true; 108 return true;
109 } 109 }
110 110
111 void DidDrawOnRT(SharedRendererState* functor) override { 111 void DidDrawOnRT(RenderThreadManager* functor) override {
112 draw_gl_count_on_rt_++; 112 draw_gl_count_on_rt_++;
113 } 113 }
114 114
115 bool DrawConstraintsEquals( 115 bool DrawConstraintsEquals(
116 const ParentCompositorDrawConstraints& constraints1, 116 const ParentCompositorDrawConstraints& constraints1,
117 const ParentCompositorDrawConstraints& constraints2) { 117 const ParentCompositorDrawConstraints& constraints2) {
118 if (constraints1.is_layer != constraints2.is_layer || 118 if (constraints1.is_layer != constraints2.is_layer ||
119 constraints1.transform != constraints2.transform) 119 constraints1.transform != constraints2.transform)
120 return false; 120 return false;
121 121
122 return !constraints1.is_layer || 122 return !constraints1.is_layer ||
123 constraints1.surface_rect_empty == constraints2.surface_rect_empty; 123 constraints1.surface_rect_empty == constraints2.surface_rect_empty;
124 } 124 }
125 125
126 void OnParentDrawConstraintsUpdated() override { 126 void OnParentDrawConstraintsUpdated() override {
127 RenderingTest::OnParentDrawConstraintsUpdated(); 127 RenderingTest::OnParentDrawConstraintsUpdated();
128 ParentCompositorDrawConstraints constraints = 128 ParentCompositorDrawConstraints constraints =
129 shared_renderer_state_->GetParentDrawConstraintsOnUI(); 129 render_thread_manager_->GetParentDrawConstraintsOnUI();
130 switch (on_draw_count_) { 130 switch (on_draw_count_) {
131 case 1u: 131 case 1u:
132 EXPECT_TRUE(DrawConstraintsEquals(constraints, new_constraints_)); 132 EXPECT_TRUE(DrawConstraintsEquals(constraints, new_constraints_));
133 break; 133 break;
134 case 3u: 134 case 3u:
135 EXPECT_TRUE(DrawConstraintsEquals(constraints, initial_constraints_)); 135 EXPECT_TRUE(DrawConstraintsEquals(constraints, initial_constraints_));
136 EndTest(); 136 EndTest();
137 break; 137 break;
138 // There will be a following 4th onDraw. But the hardware renderer won't 138 // There will be a following 4th onDraw. But the hardware renderer won't
139 // post back the draw constraints in DrawGL because the constraints 139 // post back the draw constraints in DrawGL because the constraints
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 279
280 private: 280 private:
281 std::queue<content::SynchronousCompositor::Frame> frames_; 281 std::queue<content::SynchronousCompositor::Frame> frames_;
282 uint32_t last_output_surface_id_; 282 uint32_t last_output_surface_id_;
283 std::map<cc::ResourceId, int> expected_return_count_; 283 std::map<cc::ResourceId, int> expected_return_count_;
284 }; 284 };
285 285
286 RENDERING_TEST_F(SwitchOutputSurfaceIdTest); 286 RENDERING_TEST_F(SwitchOutputSurfaceIdTest);
287 287
288 } // namespace android_webview 288 } // namespace android_webview
OLDNEW
« no previous file with comments | « android_webview/browser/browser_view_renderer.cc ('k') | android_webview/browser/deferred_gpu_command_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698