| 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() |
| 72 : on_draw_count_(0u), draw_constraints_updated_count_(0u) { |
| 73 new_transform_.Scale(2.0, 2.0); |
| 74 } |
| 75 |
| 76 void StartTest() override { |
| 77 browser_view_renderer_->SetContinuousInvalidate(true); |
| 78 } |
| 79 |
| 80 void WillOnDraw() override { |
| 81 on_draw_count_++; |
| 82 if (on_draw_count_ == 2u) { |
| 83 browser_view_renderer_->PrepareToDraw(gfx::Vector2d(), gfx::Rect()); |
| 84 browser_view_renderer_->SetContinuousInvalidate(false); |
| 85 } |
| 86 } |
| 87 |
| 88 void DidOnDraw(bool success) override { EXPECT_TRUE(success); } |
| 89 |
| 90 bool WillDrawOnRT(SharedRendererState* functor, |
| 91 AwDrawGLInfo& draw_info) override { |
| 92 if (browser_view_renderer_->global_visible_rect_for_testing().IsEmpty()) |
| 93 return false; |
| 94 |
| 95 draw_info.width = window_->surface_size().width(); |
| 96 draw_info.height = window_->surface_size().height(); |
| 97 draw_info.is_layer = false; |
| 98 |
| 99 gfx::Transform transform; |
| 100 if (draw_constraints_updated_count_ == 1u) |
| 101 transform = new_transform_; |
| 102 |
| 103 transform.matrix().asColMajorf(draw_info.transform); |
| 104 return true; |
| 105 } |
| 106 |
| 107 void ParentDrawConstraintsUpdated() override { |
| 108 draw_constraints_updated_count_++; |
| 109 ParentCompositorDrawConstraints initial_constraints; |
| 110 ParentCompositorDrawConstraints new_constraints( |
| 111 false, new_transform_, gfx::Rect(window_->surface_size())); |
| 112 if (draw_constraints_updated_count_ == 1u) { |
| 113 EXPECT_TRUE(initial_constraints.Equals( |
| 114 browser_view_renderer_->parent_draw_constraints_for_testing())); |
| 115 } |
| 116 |
| 117 if (draw_constraints_updated_count_ == 2u) { |
| 118 EXPECT_TRUE(new_constraints.Equals( |
| 119 browser_view_renderer_->parent_draw_constraints_for_testing())); |
| 120 } |
| 121 if (draw_constraints_updated_count_ == 3u) { |
| 122 EXPECT_TRUE(new_constraints.Equals( |
| 123 browser_view_renderer_->parent_draw_constraints_for_testing())); |
| 124 EndTest(); |
| 125 } |
| 126 // Add test to assert the next time parent draw constraints will be the |
| 127 // initial constraints. |
| 128 } |
| 129 |
| 130 private: |
| 131 size_t on_draw_count_; |
| 132 size_t draw_constraints_updated_count_; |
| 133 gfx::Transform new_transform_; |
| 134 }; |
| 135 |
| 136 RENDERING_TEST_F(TestAnimateInAndOutOfScreen); |
| 137 |
| 62 } // namespace android_webview | 138 } // namespace android_webview |
| OLD | NEW |