 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| 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 #include "android_webview/browser/browser_view_renderer.h" | 5 #include "android_webview/browser/browser_view_renderer.h" | 
| 6 #include "android_webview/browser/test/rendering_test.h" | 6 #include "android_webview/browser/test/rendering_test.h" | 
| 7 | 7 | 
| 8 namespace android_webview { | 8 namespace android_webview { | 
| 9 | 9 | 
| 10 class SmokeTest : public RenderingTest { | 10 class SmokeTest : public RenderingTest { | 
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 52 | 52 | 
| 53 void DidDrawOnRT(SharedRendererState* functor) override { | 53 void DidDrawOnRT(SharedRendererState* functor) override { | 
| 54 EndTest(); | 54 EndTest(); | 
| 55 } | 55 } | 
| 56 private: | 56 private: | 
| 57 size_t on_draw_count_; | 57 size_t on_draw_count_; | 
| 58 }; | 58 }; | 
| 59 | 59 | 
| 60 RENDERING_TEST_F(ClearViewTest); | 60 RENDERING_TEST_F(ClearViewTest); | 
| 61 | 61 | 
| 62 // - The first ondraw is onscreen. It reads the default draw constraints. The | |
| 63 // first DrawGL will post the new constraints to UI thread. | |
| 64 // - The second onDraw is offscreen with an empty global visible rect. It reads | |
| 65 // the new draw constraints. The second DrawGL will be skipped because the | |
| 66 // WebView is offscreen. | |
| 67 // - The third onDraw is the result of force invalidate from the second onDraw. | |
| 68 // It reads the same draw constraints as the second onDraw does. | |
| 69 class TestAnimateInAndOutOfScreen : public RenderingTest { | |
| 70 public: | |
| 71 TestAnimateInAndOutOfScreen() : on_draw_count_(0u) { | |
| 72 new_transform_.Scale(2.0, 2.0); | |
| 73 } | |
| 74 | |
| 75 void StartTest() override { | |
| 76 browser_view_renderer_->SetContinuousInvalidate(true); | |
| 77 } | |
| 78 | |
| 79 void WillOnDraw() override { | |
| 80 on_draw_count_++; | |
| 81 if (on_draw_count_ == 2u) { | |
| 82 browser_view_renderer_->PrepareToDraw(gfx::Vector2d(), gfx::Rect()); | |
| 83 browser_view_renderer_->SetContinuousInvalidate(false); | |
| 
boliu
2015/03/13 23:51:55
Hmm, doesn't posting of the next OnDrawHardware st
 
hush (inactive)
2015/03/16 18:19:21
It does not race I think. Both are post tasks to U
 
boliu
2015/03/16 20:25:08
PostInvalidate happen at end of BVR::OnDrawHardwar
 
hush (inactive)
2015/03/17 18:26:45
Okay. I added a callback in browser view renderer
 | |
| 84 } | |
| 85 } | |
| 86 | |
| 87 void DidOnDraw(bool success) override { | |
| 88 ParentCompositorDrawConstraints initial_constraints; | |
| 89 ParentCompositorDrawConstraints new_constraints( | |
| 90 false, new_transform_, gfx::Rect(window_->surface_size())); | |
| 91 EXPECT_TRUE(success); | |
| 92 if (on_draw_count_ == 1u) { | |
| 93 EXPECT_TRUE(initial_constraints.Equals( | |
| 94 browser_view_renderer_->parent_draw_constraints_for_testing())); | |
| 95 } | |
| 96 | |
| 97 if (on_draw_count_ == 2u) { | |
| 98 EXPECT_TRUE(new_constraints.Equals( | |
| 99 browser_view_renderer_->parent_draw_constraints_for_testing())); | |
| 100 } | |
| 101 | |
| 102 if (on_draw_count_ == 3u) { | |
| 103 EXPECT_TRUE(new_constraints.Equals( | |
| 104 browser_view_renderer_->parent_draw_constraints_for_testing())); | |
| 
boliu
2015/03/13 23:51:55
DrawGL for on_draw_count_ == 3 uses the identity m
 
hush (inactive)
2015/03/16 18:19:21
Well.. the 4th onDraw will early out in "Previous
 
boliu
2015/03/16 20:25:08
Hmm. Let's not change production code just to make
 
hush (inactive)
2015/03/17 18:26:45
Done.
 | |
| 105 EndTest(); | |
| 106 } | |
| 107 } | |
| 108 | |
| 109 void SetParentDrawConstraints(AwDrawGLInfo& draw_info) override { | |
| 110 draw_info.width = window_->surface_size().width(); | |
| 111 draw_info.height = window_->surface_size().height(); | |
| 112 draw_info.is_layer = false; | |
| 113 | |
| 114 gfx::Transform transform; | |
| 115 if (on_draw_count_ == 1u) | |
| 116 transform = new_transform_; | |
| 117 | |
| 118 transform.matrix().asColMajorf(draw_info.transform); | |
| 119 } | |
| 120 | |
| 121 bool WillDrawOnRT(SharedRendererState* functor) override { | |
| 122 // The 2nd onDraw gets skipped because the WebView is offscreen. | |
| 123 if (on_draw_count_ == 2u) | |
| 124 return false; | |
| 125 | |
| 126 return true; | |
| 127 } | |
| 128 | |
| 129 bool WillWaitForModeDrawToFinish() override { return true; } | |
| 130 | |
| 131 private: | |
| 132 size_t on_draw_count_; | |
| 133 gfx::Transform new_transform_; | |
| 134 }; | |
| 135 | |
| 136 RENDERING_TEST_F(TestAnimateInAndOutOfScreen); | |
| 137 | |
| 62 } // namespace android_webview | 138 } // namespace android_webview | 
| OLD | NEW |