 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 TestAnimateInAndOutOfScreen : public RenderingTest { | |
| 63 public: | |
| 64 TestAnimateInAndOutOfScreen() : step_(1u) {} | |
| 
boliu
2015/03/19 00:15:20
We are computer scientists!! We start counting fro
 
hush (inactive)
2015/03/19 01:02:51
Done. But I can't put it in StartTest because the
 | |
| 65 | |
| 66 void StartTest() override { | |
| 67 new_constraints_ = ParentCompositorDrawConstraints( | |
| 68 false, gfx::Transform(), gfx::Rect(window_->surface_size())); | |
| 69 new_constraints_.transform.Scale(2.0, 2.0); | |
| 70 browser_view_renderer_->SetContinuousInvalidate(true); | |
| 71 } | |
| 72 | |
| 73 void WillOnDraw() override { | |
| 74 if (step_ == 1u) { | |
| 75 // Step 1: A single onDraw on screen. The parent draw constraints | |
| 76 // of the BVR will updated to be the initial constraints. | |
| 77 browser_view_renderer_->SetContinuousInvalidate(false); | |
| 78 } | |
| 79 if (step_ == 2u) { | |
| 80 // Step 2: A single onDrraw off screen. The parent draw constraints of the | |
| 81 // BVR will be updated to the new constraints. | |
| 82 browser_view_renderer_->PrepareToDraw(gfx::Vector2d(), gfx::Rect()); | |
| 83 } | |
| 84 if (step_ == 3u) { | |
| 85 // Step 3: Continuously call onDraw onscreen. End the test when the parent | |
| 86 // draw constraints of BVR is updated to initial constraints. | |
| 87 browser_view_renderer_->SetContinuousInvalidate(true); | |
| 88 } | |
| 89 } | |
| 90 | |
| 91 void DidOnDraw(bool success) override { EXPECT_TRUE(success); } | |
| 92 | |
| 93 bool WillDrawOnRT(SharedRendererState* functor, | |
| 94 AwDrawGLInfo& draw_info) override { | |
| 95 if (browser_view_renderer_->global_visible_rect_for_testing().IsEmpty()) | |
| 96 return false; | |
| 97 | |
| 98 draw_info.width = window_->surface_size().width(); | |
| 99 draw_info.height = window_->surface_size().height(); | |
| 100 draw_info.is_layer = false; | |
| 101 | |
| 102 gfx::Transform transform; | |
| 103 if (step_ == 2u) | |
| 104 transform = new_constraints_.transform; | |
| 105 | |
| 106 transform.matrix().asColMajorf(draw_info.transform); | |
| 107 return true; | |
| 108 } | |
| 109 | |
| 110 void ParentDrawConstraintsUpdated() override { | |
| 111 ParentCompositorDrawConstraints constraints = | |
| 112 browser_view_renderer_->parent_draw_constraints_for_testing(); | |
| 
boliu
2015/03/19 00:15:20
We don't need both ConstraintsUpdated and GetConst
 
hush (inactive)
2015/03/19 01:02:51
Done.
 | |
| 113 if (step_ == 1u && constraints.Equals(initial_constraints_)) { | |
| 114 step_++; | |
| 
boliu
2015/03/19 00:15:20
Do we get more than one ParentDrawConstraintsUpdat
 
hush (inactive)
2015/03/19 01:02:51
By 'validating' I guess you mean EXPECT_TRUE?
I'm
 
boliu
2015/03/19 01:05:33
I don't understand why there will be multiple Pare
 | |
| 115 } | |
| 116 | |
| 117 if (step_ == 2u && constraints.Equals(new_constraints_)) { | |
| 118 step_++; | |
| 119 PostInvalidate(); | |
| 120 } | |
| 121 | |
| 122 if (step_ == 3u && constraints.Equals(initial_constraints_)) { | |
| 123 step_++; | |
| 124 browser_view_renderer_->SetContinuousInvalidate(false); | |
| 125 EndTest(); | |
| 126 } | |
| 127 } | |
| 128 | |
| 129 private: | |
| 130 size_t step_; | |
| 131 ParentCompositorDrawConstraints initial_constraints_; | |
| 132 ParentCompositorDrawConstraints new_constraints_; | |
| 133 }; | |
| 134 | |
| 135 RENDERING_TEST_F(TestAnimateInAndOutOfScreen); | |
| 136 | |
| 62 } // namespace android_webview | 137 } // namespace android_webview | 
| OLD | NEW |