 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 class TestForceInvalidateWithEmptyGlobalVisibleRect : public RenderingTest { | |
| 63 public: | |
| 64 TestForceInvalidateWithEmptyGlobalVisibleRect() : on_draw_count_(0u) {} | |
| 65 | |
| 66 void StartTest() override { | |
| 67 browser_view_renderer_->SetContinuousInvalidate(true); | |
| 68 } | |
| 69 | |
| 70 void WillOnDraw() override { | |
| 71 browser_view_renderer_->PrepareToDraw(gfx::Vector2d(), gfx::Rect()); | |
| 72 browser_view_renderer_->SetContinuousInvalidate(false); | |
| 73 } | |
| 74 | |
| 75 void DidOnDraw(bool success) override { | |
| 76 on_draw_count_++; | |
| 77 | |
| 78 ParentCompositorDrawConstraints initialConstraint; | |
| 79 ParentCompositorDrawConstraints newConstraint = | |
| 80 ParentCompositorDrawConstraints(false, gfx::Transform(), | |
| 81 gfx::Rect(window_->surface_size())); | |
| 82 EXPECT_TRUE(success); | |
| 83 // The second onDraw will be the result of a forced invalidation because | |
| 84 // an empty global visible rect was used in the first onDraw. | |
| 85 if (on_draw_count_ == 1u) { | |
| 86 EXPECT_TRUE( | |
| 87 browser_view_renderer_->parent_draw_constraints_for_testing().Equals( | |
| 88 initialConstraint)); | |
| 89 } | |
| 90 | |
| 91 if (on_draw_count_ == 2u) { | |
| 92 EXPECT_TRUE( | |
| 93 browser_view_renderer_->parent_draw_constraints_for_testing().Equals( | |
| 94 newConstraint)); | |
| 95 EndTest(); | |
| 96 } | |
| 97 } | |
| 98 | |
| 99 private: | |
| 100 size_t on_draw_count_; | |
| 101 }; | |
| 102 | |
| 103 RENDERING_TEST_F(TestForceInvalidateWithEmptyGlobalVisibleRect); | |
| 104 | |
| 105 class TestAnimateInAndOutOfScreen : public RenderingTest { | |
| 
boliu
2015/03/13 19:14:22
I think this should replace the test above..
 
hush (inactive)
2015/03/13 23:24:04
Yes. Indeed.
 | |
| 106 public: | |
| 107 TestAnimateInAndOutOfScreen() : on_draw_count_(0u) {} | |
| 108 | |
| 109 void StartTest() override { | |
| 110 browser_view_renderer_->SetContinuousInvalidate(true); | |
| 111 } | |
| 112 | |
| 113 void WillOnDraw() override { | |
| 114 on_draw_count_++; | |
| 115 // First and third onDraws are onscreen. | |
| 116 // Second onDraw is offscreen. | |
| 117 if (on_draw_count_ == 2u) { | |
| 118 browser_view_renderer_->PrepareToDraw(gfx::Vector2d(), gfx::Rect()); | |
| 119 browser_view_renderer_->SetContinuousInvalidate(false); | |
| 
boliu
2015/03/13 19:14:22
Let's see
First draw is normal, and ParentConstra
 
hush (inactive)
2015/03/13 23:24:04
Please the see the new patch. I added some new syn
 | |
| 120 } | |
| 121 } | |
| 122 | |
| 123 void DidOnDraw(bool success) override { | |
| 124 ParentCompositorDrawConstraints initialConstraint; | |
| 125 ParentCompositorDrawConstraints newConstraint = | |
| 126 ParentCompositorDrawConstraints(false, gfx::Transform(), | |
| 127 gfx::Rect(window_->surface_size())); | |
| 128 EXPECT_TRUE(success); | |
| 129 if (on_draw_count_ == 1u) { | |
| 130 EXPECT_TRUE( | |
| 131 browser_view_renderer_->parent_draw_constraints_for_testing().Equals( | |
| 132 initialConstraint)); | |
| 133 } | |
| 134 | |
| 135 if (on_draw_count_ == 2u) { | |
| 136 EXPECT_TRUE( | |
| 137 browser_view_renderer_->parent_draw_constraints_for_testing().Equals( | |
| 138 newConstraint)); | |
| 139 } | |
| 140 | |
| 141 if (on_draw_count_ == 3u) { | |
| 142 EXPECT_TRUE( | |
| 143 browser_view_renderer_->parent_draw_constraints_for_testing().Equals( | |
| 144 newConstraint)); | |
| 145 EndTest(); | |
| 146 } | |
| 147 } | |
| 148 | |
| 149 bool WillDrawOnRT(SharedRendererState* functor) override { | |
| 150 if (on_draw_count_ == 2u) | |
| 151 return false; | |
| 152 | |
| 153 return true; | |
| 154 } | |
| 155 | |
| 156 private: | |
| 157 size_t on_draw_count_; | |
| 158 }; | |
| 159 | |
| 160 RENDERING_TEST_F(TestAnimateInAndOutOfScreen); | |
| 161 | |
| 62 } // namespace android_webview | 162 } // namespace android_webview | 
| OLD | NEW |