| 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); |
| 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())); |
| 105 } |
| 106 if (on_draw_count_ == 4u) { |
| 107 EXPECT_TRUE(initial_constraints.Equals( |
| 108 browser_view_renderer_->parent_draw_constraints_for_testing())); |
| 109 EndTest(); |
| 110 } |
| 111 } |
| 112 |
| 113 void SetParentDrawConstraints(AwDrawGLInfo& draw_info) override { |
| 114 draw_info.width = window_->surface_size().width(); |
| 115 draw_info.height = window_->surface_size().height(); |
| 116 draw_info.is_layer = false; |
| 117 |
| 118 gfx::Transform transform; |
| 119 if (on_draw_count_ == 1u) |
| 120 transform = new_transform_; |
| 121 |
| 122 transform.matrix().asColMajorf(draw_info.transform); |
| 123 } |
| 124 |
| 125 bool WillDrawOnRT(SharedRendererState* functor) override { |
| 126 // The 2nd onDraw gets skipped because the WebView is offscreen. |
| 127 if (on_draw_count_ == 2u) |
| 128 return false; |
| 129 |
| 130 return true; |
| 131 } |
| 132 |
| 133 void Attach() override { |
| 134 window_.reset(new FakeWindow(browser_view_renderer_.get(), this, |
| 135 gfx::Rect(100, 100), true)); |
| 136 } |
| 137 |
| 138 private: |
| 139 size_t on_draw_count_; |
| 140 gfx::Transform new_transform_; |
| 141 }; |
| 142 |
| 143 RENDERING_TEST_F(TestAnimateInAndOutOfScreen); |
| 144 |
| 62 } // namespace android_webview | 145 } // namespace android_webview |
| OLD | NEW |