 Chromium Code Reviews
 Chromium Code Reviews Issue 1002013003:
  Unit Test for WebView animating in and out of screen  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 1002013003:
  Unit Test for WebView animating in and out of screen  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| Index: android_webview/browser/test/fake_window.cc | 
| diff --git a/android_webview/browser/test/fake_window.cc b/android_webview/browser/test/fake_window.cc | 
| index 0a0956bab3a5316b7ea9e169edfae55ee7bdfad1..21f032e203c375968e9864507e451f28f42f4223 100644 | 
| --- a/android_webview/browser/test/fake_window.cc | 
| +++ b/android_webview/browser/test/fake_window.cc | 
| @@ -5,7 +5,6 @@ | 
| #include "android_webview/browser/test/fake_window.h" | 
| #include "android_webview/browser/browser_view_renderer.h" | 
| -#include "android_webview/public/browser/draw_gl.h" | 
| #include "base/message_loop/message_loop_proxy.h" | 
| #include "base/synchronization/waitable_event.h" | 
| #include "base/threading/thread.h" | 
| @@ -40,10 +39,12 @@ class FakeWindow::ScopedMakeCurrent { | 
| FakeWindow::FakeWindow(BrowserViewRenderer* view, | 
| WindowHooks* hooks, | 
| - gfx::Rect location) | 
| + gfx::Rect location, | 
| + bool will_wait_for_mode_draw_to_finish) | 
| : view_(view), | 
| hooks_(hooks), | 
| surface_size_(100, 100), | 
| + will_wait_for_mode_draw_to_finish_(will_wait_for_mode_draw_to_finish), | 
| location_(location), | 
| on_draw_hardware_pending_(false), | 
| functor_(nullptr), | 
| @@ -106,8 +107,14 @@ void FakeWindow::ProcessFunctorOnRT(base::WaitableEvent* sync) { | 
| void FakeWindow::PostInvalidate() { | 
| CheckCurrentlyOnUIThread(); | 
| - if (on_draw_hardware_pending_) | 
| + if (on_draw_hardware_pending_) { | 
| + if (will_wait_for_mode_draw_to_finish_) { | 
| 
boliu
2015/03/16 20:25:08
Oh this is what you meant... please no :(
We need
 | 
| + base::MessageLoopProxy::current()->PostTask( | 
| + FROM_HERE, base::Bind(&FakeWindow::PostInvalidate, | 
| + weak_ptr_factory_.GetWeakPtr())); | 
| + } | 
| return; | 
| + } | 
| on_draw_hardware_pending_ = true; | 
| base::MessageLoopProxy::current()->PostTask( | 
| FROM_HERE, | 
| @@ -117,10 +124,11 @@ void FakeWindow::PostInvalidate() { | 
| void FakeWindow::OnDrawHardware() { | 
| CheckCurrentlyOnUIThread(); | 
| DCHECK(on_draw_hardware_pending_); | 
| - on_draw_hardware_pending_ = false; | 
| + if (!will_wait_for_mode_draw_to_finish_) | 
| + on_draw_hardware_pending_ = false; | 
| - hooks_->WillOnDraw(); | 
| view_->PrepareToDraw(gfx::Vector2d(), location_); | 
| + hooks_->WillOnDraw(); | 
| bool success = view_->OnDrawHardware(); | 
| hooks_->DidOnDraw(success); | 
| if (success) { | 
| @@ -132,6 +140,9 @@ void FakeWindow::OnDrawHardware() { | 
| base::Unretained(this), &completion)); | 
| completion.Wait(); | 
| } | 
| + | 
| + if (will_wait_for_mode_draw_to_finish_) | 
| + on_draw_hardware_pending_ = false; | 
| } | 
| void FakeWindow::DrawFunctorOnRT(base::WaitableEvent* sync) { | 
| @@ -147,7 +158,10 @@ void FakeWindow::DrawFunctorOnRT(base::WaitableEvent* sync) { | 
| functor_->DrawGL(&process_info); | 
| hooks_->DidSyncOnRT(functor_); | 
| } | 
| - sync->Signal(); | 
| + | 
| + if (!will_wait_for_mode_draw_to_finish_) { | 
| + sync->Signal(); | 
| + } | 
| AwDrawGLInfo draw_info; | 
| draw_info.version = kAwDrawGLInfoVersion; | 
| @@ -156,36 +170,24 @@ void FakeWindow::DrawFunctorOnRT(base::WaitableEvent* sync) { | 
| draw_info.clip_top = location.y(); | 
| draw_info.clip_right = location.x() + location.width(); | 
| draw_info.clip_bottom = location.y() + location.height(); | 
| - draw_info.width = surface_size_.width(); | 
| - draw_info.height = surface_size_.height(); | 
| - draw_info.is_layer = false; | 
| - | 
| - draw_info.transform[0] = 1.0; | 
| - draw_info.transform[1] = 0.0; | 
| - draw_info.transform[2] = 0.0; | 
| - draw_info.transform[3] = 0.0; | 
| - | 
| - draw_info.transform[4] = 0.0; | 
| - draw_info.transform[5] = 1.0; | 
| - draw_info.transform[6] = 0.0; | 
| - draw_info.transform[7] = 0.0; | 
| - | 
| - draw_info.transform[8] = 0.0; | 
| - draw_info.transform[9] = 0.0; | 
| - draw_info.transform[10] = 1.0; | 
| - draw_info.transform[11] = 0.0; | 
| - | 
| - draw_info.transform[12] = 0.0; | 
| - draw_info.transform[13] = 0.0; | 
| - draw_info.transform[14] = 0.0; | 
| - draw_info.transform[15] = 1.0; | 
| - | 
| - hooks_->WillDrawOnRT(functor_); | 
| + | 
| + hooks_->SetParentDrawConstraints(draw_info); | 
| + | 
| + if (!hooks_->WillDrawOnRT(functor_)) { | 
| + if (will_wait_for_mode_draw_to_finish_) { | 
| + sync->Signal(); | 
| + } | 
| + return; | 
| + } | 
| + | 
| { | 
| ScopedMakeCurrent make_current(this); | 
| functor_->DrawGL(&draw_info); | 
| } | 
| hooks_->DidDrawOnRT(functor_); | 
| + if (will_wait_for_mode_draw_to_finish_) { | 
| + sync->Signal(); | 
| + } | 
| } | 
| void FakeWindow::CheckCurrentlyOnUIThread() { |