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

Side by Side Diff: android_webview/browser/test/fake_window.cc

Issue 1002013003: Unit Test for WebView animating in and out of screen (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments Created 5 years, 9 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 "android_webview/browser/test/fake_window.h" 5 #include "android_webview/browser/test/fake_window.h"
6 6
7 #include "android_webview/browser/browser_view_renderer.h" 7 #include "android_webview/browser/browser_view_renderer.h"
8 #include "android_webview/public/browser/draw_gl.h"
9 #include "base/message_loop/message_loop_proxy.h" 8 #include "base/message_loop/message_loop_proxy.h"
10 #include "base/synchronization/waitable_event.h" 9 #include "base/synchronization/waitable_event.h"
11 #include "base/threading/thread.h" 10 #include "base/threading/thread.h"
12 #include "ui/gl/gl_bindings.h" 11 #include "ui/gl/gl_bindings.h"
13 12
14 namespace android_webview { 13 namespace android_webview {
15 14
16 class FakeWindow::ScopedMakeCurrent { 15 class FakeWindow::ScopedMakeCurrent {
17 public: 16 public:
18 ScopedMakeCurrent(FakeWindow* view_root) : view_root_(view_root) { 17 ScopedMakeCurrent(FakeWindow* view_root) : view_root_(view_root) {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 functor_->DrawGL(&process_info); 98 functor_->DrawGL(&process_info);
100 } 99 }
101 hooks_->DidProcessOnRT(functor_); 100 hooks_->DidProcessOnRT(functor_);
102 101
103 if (sync) 102 if (sync)
104 sync->Signal(); 103 sync->Signal();
105 } 104 }
106 105
107 void FakeWindow::PostInvalidate() { 106 void FakeWindow::PostInvalidate() {
108 CheckCurrentlyOnUIThread(); 107 CheckCurrentlyOnUIThread();
109 if (on_draw_hardware_pending_) 108 if (on_draw_hardware_pending_) {
109 base::MessageLoopProxy::current()->PostTask(
hush (inactive) 2015/03/17 18:38:18 I need this postTask so that the onDraws won't be
110 FROM_HERE, base::Bind(&FakeWindow::PostInvalidate,
111 weak_ptr_factory_.GetWeakPtr()));
110 return; 112 return;
113 }
111 on_draw_hardware_pending_ = true; 114 on_draw_hardware_pending_ = true;
112 base::MessageLoopProxy::current()->PostTask( 115 base::MessageLoopProxy::current()->PostTask(
113 FROM_HERE, 116 FROM_HERE,
114 base::Bind(&FakeWindow::OnDrawHardware, weak_ptr_factory_.GetWeakPtr())); 117 base::Bind(&FakeWindow::OnDrawHardware, weak_ptr_factory_.GetWeakPtr()));
115 } 118 }
116 119
117 void FakeWindow::OnDrawHardware() { 120 void FakeWindow::OnDrawHardware() {
118 CheckCurrentlyOnUIThread(); 121 CheckCurrentlyOnUIThread();
119 DCHECK(on_draw_hardware_pending_); 122 DCHECK(on_draw_hardware_pending_);
120 on_draw_hardware_pending_ = false; 123 on_draw_hardware_pending_ = false;
121 124
125 view_->PrepareToDraw(gfx::Vector2d(), location_);
122 hooks_->WillOnDraw(); 126 hooks_->WillOnDraw();
123 view_->PrepareToDraw(gfx::Vector2d(), location_);
124 bool success = view_->OnDrawHardware(); 127 bool success = view_->OnDrawHardware();
125 hooks_->DidOnDraw(success); 128 hooks_->DidOnDraw(success);
126 if (success) { 129 if (success) {
127 CreateRenderThreadIfNeeded(); 130 CreateRenderThreadIfNeeded();
128 131
129 base::WaitableEvent completion(true, false); 132 base::WaitableEvent completion(true, false);
130 render_thread_loop_->PostTask( 133 render_thread_loop_->PostTask(
131 FROM_HERE, base::Bind(&FakeWindow::DrawFunctorOnRT, 134 FROM_HERE, base::Bind(&FakeWindow::DrawFunctorOnRT,
132 base::Unretained(this), &completion)); 135 base::Unretained(this), &completion));
133 completion.Wait(); 136 completion.Wait();
(...skipping 15 matching lines...) Expand all
149 } 152 }
150 sync->Signal(); 153 sync->Signal();
151 154
152 AwDrawGLInfo draw_info; 155 AwDrawGLInfo draw_info;
153 draw_info.version = kAwDrawGLInfoVersion; 156 draw_info.version = kAwDrawGLInfoVersion;
154 draw_info.mode = AwDrawGLInfo::kModeDraw; 157 draw_info.mode = AwDrawGLInfo::kModeDraw;
155 draw_info.clip_left = location.x(); 158 draw_info.clip_left = location.x();
156 draw_info.clip_top = location.y(); 159 draw_info.clip_top = location.y();
157 draw_info.clip_right = location.x() + location.width(); 160 draw_info.clip_right = location.x() + location.width();
158 draw_info.clip_bottom = location.y() + location.height(); 161 draw_info.clip_bottom = location.y() + location.height();
159 draw_info.width = surface_size_.width();
160 draw_info.height = surface_size_.height();
161 draw_info.is_layer = false;
162 162
163 draw_info.transform[0] = 1.0; 163 if (!hooks_->WillDrawOnRT(functor_, draw_info))
164 draw_info.transform[1] = 0.0; 164 return;
165 draw_info.transform[2] = 0.0;
166 draw_info.transform[3] = 0.0;
167 165
168 draw_info.transform[4] = 0.0;
169 draw_info.transform[5] = 1.0;
170 draw_info.transform[6] = 0.0;
171 draw_info.transform[7] = 0.0;
172
173 draw_info.transform[8] = 0.0;
174 draw_info.transform[9] = 0.0;
175 draw_info.transform[10] = 1.0;
176 draw_info.transform[11] = 0.0;
177
178 draw_info.transform[12] = 0.0;
179 draw_info.transform[13] = 0.0;
180 draw_info.transform[14] = 0.0;
181 draw_info.transform[15] = 1.0;
182
183 hooks_->WillDrawOnRT(functor_);
184 { 166 {
185 ScopedMakeCurrent make_current(this); 167 ScopedMakeCurrent make_current(this);
186 functor_->DrawGL(&draw_info); 168 functor_->DrawGL(&draw_info);
187 } 169 }
188 hooks_->DidDrawOnRT(functor_); 170 hooks_->DidDrawOnRT(functor_);
189 } 171 }
190 172
191 void FakeWindow::CheckCurrentlyOnUIThread() { 173 void FakeWindow::CheckCurrentlyOnUIThread() {
192 DCHECK(ui_checker_.CalledOnValidSequencedThread()); 174 DCHECK(ui_checker_.CalledOnValidSequencedThread());
193 } 175 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 surface_ = nullptr; 213 surface_ = nullptr;
232 } 214 }
233 sync->Signal(); 215 sync->Signal();
234 } 216 }
235 217
236 void FakeWindow::CheckCurrentlyOnRT() { 218 void FakeWindow::CheckCurrentlyOnRT() {
237 DCHECK(rt_checker_.CalledOnValidSequencedThread()); 219 DCHECK(rt_checker_.CalledOnValidSequencedThread());
238 } 220 }
239 221
240 } // namespace android_webview 222 } // namespace android_webview
OLDNEW
« no previous file with comments | « android_webview/browser/test/fake_window.h ('k') | android_webview/browser/test/rendering_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698