Chromium Code Reviews| Index: android_webview/browser/browser_view_renderer_unittest.cc |
| diff --git a/android_webview/browser/browser_view_renderer_unittest.cc b/android_webview/browser/browser_view_renderer_unittest.cc |
| index b4a9d42227241cef82d61d71a47608eb57d52001..a65aedb910a076312cfbe62b12012106d6385f99 100644 |
| --- a/android_webview/browser/browser_view_renderer_unittest.cc |
| +++ b/android_webview/browser/browser_view_renderer_unittest.cc |
| @@ -59,4 +59,80 @@ class ClearViewTest : public RenderingTest { |
| RENDERING_TEST_F(ClearViewTest); |
| +// - The first ondraw is onscreen. It reads the default draw constraints. The |
| +// first DrawGL will post the new constraints to UI thread. |
| +// - The second onDraw is offscreen with an empty global visible rect. It reads |
| +// the new draw constraints. The second DrawGL will be skipped because the |
| +// WebView is offscreen. |
| +// - The third onDraw is the result of force invalidate from the second onDraw. |
| +// It reads the same draw constraints as the second onDraw does. |
| +class TestAnimateInAndOutOfScreen : public RenderingTest { |
| + public: |
| + TestAnimateInAndOutOfScreen() : on_draw_count_(0u) { |
| + new_transform_.Scale(2.0, 2.0); |
| + } |
| + |
| + void StartTest() override { |
| + browser_view_renderer_->SetContinuousInvalidate(true); |
| + } |
| + |
| + void WillOnDraw() override { |
| + on_draw_count_++; |
| + if (on_draw_count_ == 2u) { |
| + browser_view_renderer_->PrepareToDraw(gfx::Vector2d(), gfx::Rect()); |
| + 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
|
| + } |
| + } |
| + |
| + void DidOnDraw(bool success) override { |
| + ParentCompositorDrawConstraints initial_constraints; |
| + ParentCompositorDrawConstraints new_constraints( |
| + false, new_transform_, gfx::Rect(window_->surface_size())); |
| + EXPECT_TRUE(success); |
| + if (on_draw_count_ == 1u) { |
| + EXPECT_TRUE(initial_constraints.Equals( |
| + browser_view_renderer_->parent_draw_constraints_for_testing())); |
| + } |
| + |
| + if (on_draw_count_ == 2u) { |
| + EXPECT_TRUE(new_constraints.Equals( |
| + browser_view_renderer_->parent_draw_constraints_for_testing())); |
| + } |
| + |
| + if (on_draw_count_ == 3u) { |
| + EXPECT_TRUE(new_constraints.Equals( |
| + 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.
|
| + EndTest(); |
| + } |
| + } |
| + |
| + void SetParentDrawConstraints(AwDrawGLInfo& draw_info) override { |
| + draw_info.width = window_->surface_size().width(); |
| + draw_info.height = window_->surface_size().height(); |
| + draw_info.is_layer = false; |
| + |
| + gfx::Transform transform; |
| + if (on_draw_count_ == 1u) |
| + transform = new_transform_; |
| + |
| + transform.matrix().asColMajorf(draw_info.transform); |
| + } |
| + |
| + bool WillDrawOnRT(SharedRendererState* functor) override { |
| + // The 2nd onDraw gets skipped because the WebView is offscreen. |
| + if (on_draw_count_ == 2u) |
| + return false; |
| + |
| + return true; |
| + } |
| + |
| + bool WillWaitForModeDrawToFinish() override { return true; } |
| + |
| + private: |
| + size_t on_draw_count_; |
| + gfx::Transform new_transform_; |
| +}; |
| + |
| +RENDERING_TEST_F(TestAnimateInAndOutOfScreen); |
| + |
| } // namespace android_webview |