 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(100, 100)); | |
| 
boliu
2015/03/13 17:53:34
Can we get these from FakeWindow instead of hard c
 
hush (inactive)
2015/03/13 18:33:30
Yes. Sure.
 
boliu
2015/03/13 18:50:37
Ehh, get the other two as well? You can get FakeWi
 | |
| 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)); | |
| 
boliu
2015/03/13 17:53:34
Shouldn't this be newConstraint? Then drop initial
 
hush (inactive)
2015/03/13 18:33:30
No. After the first onDraw, the new constraint fro
 
boliu
2015/03/13 18:50:37
Then test setup is still wrong, no? Test is suppos
 
hush (inactive)
2015/03/13 23:24:04
The test setup has some synchronization problems I
 | |
| 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 | |
| 62 } // namespace android_webview | 105 } // namespace android_webview | 
| OLD | NEW |