Chromium Code Reviews| Index: cc/trees/layer_tree_host_unittest.cc |
| diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc |
| index ab0046c1715c5f7b2d52d257c21b63b1ebd71cb9..bc9dd15b660fdc3d7a4ce9ea73910b08b57c6627 100644 |
| --- a/cc/trees/layer_tree_host_unittest.cc |
| +++ b/cc/trees/layer_tree_host_unittest.cc |
| @@ -4181,5 +4181,70 @@ class LayerTreeHostTestUpdateLayerInEmptyViewport : public LayerTreeHostTest { |
| MULTI_THREAD_TEST_F(LayerTreeHostTestUpdateLayerInEmptyViewport); |
| +class LayerTreeHostTestAbortEvictedTextures : public LayerTreeHostTest { |
| + public: |
| + LayerTreeHostTestAbortEvictedTextures() |
| + : num_will_begin_frames_(0), num_impl_commits_(0) {} |
| + |
| + protected: |
| + virtual void SetupTree() OVERRIDE { |
| + scoped_refptr<SolidColorLayer> root_layer = SolidColorLayer::Create(); |
| + root_layer->SetScrollable(true); |
| + root_layer->SetBounds(gfx::Size(200, 200)); |
| + root_layer->SetMaxScrollOffset(gfx::Vector2d(100, 100)); |
| + root_layer->SetIsDrawable(true); |
| + |
| + layer_tree_host()->SetRootLayer(root_layer); |
| + LayerTreeHostTest::SetupTree(); |
| + } |
| + |
| + virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
| + |
| + virtual void WillBeginFrame() OVERRIDE { |
| + num_will_begin_frames_++; |
| + switch (num_will_begin_frames_) { |
| + case 2: |
| + // Send a redraw to the compositor thread. This will (wrongly) be |
| + // ignored unless aborting resets the texture state. |
| + PostSetNeedsRedrawToMainThread(); |
|
danakj
2013/08/06 19:36:53
nit: You're on the main thread, you can just LTH->
enne (OOO)
2013/08/06 21:41:21
Done.
|
| + break; |
| + } |
| + } |
| + |
| + virtual void BeginCommitOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
| + num_impl_commits_++; |
| + } |
| + |
| + virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
| + switch (impl->SourceAnimationFrameNumber()) { |
| + case 1: |
| + // Trigger an abortable commit. |
| + impl->active_tree()->root_layer()->ScrollBy(gfx::Vector2d(1, 1)); |
| + // Prevent draws until that commit. |
| + impl->active_tree()->SetContentsTexturesPurged(); |
| + EXPECT_FALSE(impl->CanDraw()); |
| + impl->SetNeedsCommit(); |
|
danakj
2013/08/06 19:36:53
why? didn't scrollby do this?
enne (OOO)
2013/08/06 21:41:21
Maybe it should, but it doesn't. This normally ge
|
| + break; |
| + case 2: |
| + EndTest(); |
| + break; |
| + } |
| + } |
| + |
| + virtual void AfterTest() OVERRIDE { |
| + // Ensure that the commit was truly aborted. |
| + EXPECT_EQ(2, num_will_begin_frames_); |
| + EXPECT_EQ(1, num_impl_commits_); |
| + } |
| + |
| + private: |
| + int num_will_begin_frames_; |
| + int num_impl_commits_; |
| +}; |
| + |
| +// Commits can only be aborted when using the thread proxy. |
| +MULTI_THREAD_TEST_F(LayerTreeHostTestAbortEvictedTextures); |
| + |
| } // namespace |
| + |
|
danakj
2013/08/06 19:36:53
?
enne (OOO)
2013/08/06 21:41:21
Presubmit style.
|
| } // namespace cc |