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 bb315e79d02c152d57cb9ecb4dc8d343eee4acd1..0a7f5ac111d53ebfbfcc3c2d8f522c636c64b2b3 100644 |
| --- a/cc/trees/layer_tree_host_unittest.cc |
| +++ b/cc/trees/layer_tree_host_unittest.cc |
| @@ -6320,4 +6320,85 @@ class LayerTreeHostTestNoTasksBetweenWillAndDidCommit |
| SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestNoTasksBetweenWillAndDidCommit); |
| +// Verify that if a LayerImpl holds onto a copy request for multiple |
| +// frames that it will continue to have a render surface through |
| +// multiple commits, even though the Layer itself has no reason |
| +// to have a render surface. |
| +class LayerPreserveRenderSurfaceFromOutputRequests : public LayerTreeHostTest { |
| + protected: |
| + void SetupTree() override { |
| + scoped_refptr<Layer> root = Layer::Create(); |
| + root->CreateRenderSurface(); |
| + root->SetBounds(gfx::Size(10, 10)); |
| + child_ = Layer::Create(); |
| + child_->SetBounds(gfx::Size(20, 20)); |
| + root->AddChild(child_); |
| + |
| + layer_tree_host()->SetRootLayer(root); |
| + LayerTreeHostTest::SetupTree(); |
| + } |
| + |
| + static void CopyOutputCallback(scoped_ptr<CopyOutputResult> result) {} |
| + |
| + void BeginTest() override { |
| + child_->RequestCopyOfOutput( |
| + CopyOutputRequest::CreateBitmapRequest(base::Bind(CopyOutputCallback))); |
| + EXPECT_TRUE(child_->HasCopyRequest()); |
| + PostSetNeedsCommitToMainThread(); |
| + } |
| + |
| + void DidCommit() override { EXPECT_FALSE(child_->HasCopyRequest()); } |
| + |
| + void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override { |
| + LayerImpl* child_impl = host_impl->sync_tree()->LayerById(child_->id()); |
| + ASSERT_TRUE(child_impl); |
|
danakj
2015/02/19 18:08:39
ASSERT_ in layer tree tests is marginally bleh cuz
enne (OOO)
2015/02/19 18:10:31
But crashing in a unit test ends everything?
danakj
2015/02/19 18:36:44
Not sure what you mean, it ends the test immediate
enne (OOO)
2015/02/19 18:40:33
Ok. Removed asserts.
|
| + |
| + switch (host_impl->sync_tree()->source_frame_number()) { |
| + case 0: |
| + EXPECT_TRUE(child_impl->HasCopyRequest()); |
| + EXPECT_TRUE(child_impl->render_surface()); |
| + break; |
| + case 1: |
| + if (host_impl->proxy()->CommitToActiveTree()) { |
| + EXPECT_TRUE(child_impl->HasCopyRequest()); |
| + EXPECT_TRUE(child_impl->render_surface()); |
| + } else { |
| + EXPECT_FALSE(child_impl->HasCopyRequest()); |
| + EXPECT_FALSE(child_impl->render_surface()); |
| + } |
| + break; |
| + default: |
| + NOTREACHED(); |
| + break; |
| + } |
| + } |
| + |
| + void DidActivateTreeOnThread(LayerTreeHostImpl* host_impl) override { |
| + LayerImpl* child_impl = host_impl->active_tree()->LayerById(child_->id()); |
| + ASSERT_TRUE(child_impl); |
| + EXPECT_TRUE(child_impl->HasCopyRequest()); |
| + EXPECT_TRUE(child_impl->render_surface()); |
| + |
| + switch (host_impl->active_tree()->source_frame_number()) { |
| + case 0: |
| + // Lose output surface to prevent drawing and cause another commit. |
| + host_impl->DidLoseOutputSurface(); |
| + break; |
| + case 1: |
| + EndTest(); |
| + break; |
| + default: |
| + NOTREACHED(); |
| + break; |
| + } |
| + } |
| + |
| + void AfterTest() override {} |
| + |
| + private: |
| + scoped_refptr<Layer> child_; |
| +}; |
| + |
| +SINGLE_AND_MULTI_THREAD_TEST_F(LayerPreserveRenderSurfaceFromOutputRequests); |
| + |
| } // namespace cc |