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 92cba32558746765f15ba8bcd4bd4673fc826dce..6d6093fc597242d317f599b59ba50e3b07164e3d 100644 |
| --- a/cc/trees/layer_tree_host_unittest.cc |
| +++ b/cc/trees/layer_tree_host_unittest.cc |
| @@ -636,6 +636,73 @@ class LayerTreeHostTestCompositeAndReadbackAfterForcedDraw |
| MULTI_THREAD_TEST_F(LayerTreeHostTestCompositeAndReadbackAfterForcedDraw); |
| +class LayerTreeHostTestSetNextCommitForcesRedraw : public LayerTreeHostTest { |
| + public: |
|
bajones
2013/09/27 20:50:11
@enne: Is this what you had in mind?
|
| + LayerTreeHostTestSetNextCommitForcesRedraw() |
| + : num_draws_(0), |
| + bounds_(50, 50), |
| + root_layer_(ContentLayer::Create(&client_)) { |
| + } |
| + |
| + virtual void BeginTest() OVERRIDE { |
| + root_layer_->SetIsDrawable(true); |
| + root_layer_->SetBounds(bounds_); |
| + layer_tree_host()->SetRootLayer(root_layer_); |
| + layer_tree_host()->SetViewportSize(bounds_); |
| + PostSetNeedsCommitToMainThread(); |
| + } |
| + |
| + virtual bool PrepareToDrawOnThread(LayerTreeHostImpl* host_impl, |
| + LayerTreeHostImpl::FrameData* frame_data, |
| + bool result) OVERRIDE { |
| + EXPECT_TRUE(result); |
| + |
| + gfx::RectF root_damage_rect; |
| + if (!frame_data->render_passes.empty()) |
| + root_damage_rect = frame_data->render_passes.back()->damage_rect; |
| + |
| + if (num_draws_ == 0 || num_draws_ == 3) |
| + // First and last draw should expect full frame damage |
| + EXPECT_RECT_EQ(gfx::Rect(bounds_), root_damage_rect); |
| + else |
| + EXPECT_RECT_EQ(gfx::Rect(0, 0, 0, 0), root_damage_rect); |
| + |
| + return result; |
| + } |
| + |
| + virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
| + switch (num_draws_) { |
| + case 0: |
| + case 1: |
| + // Cycle through a couple of empty commits to ensure we're observing the |
|
enne (OOO)
2013/10/01 19:15:30
Hrm. I was hoping you could add a commit -> draw
|
| + // right behavior |
| + PostSetNeedsCommitToMainThread(); |
| + break; |
| + case 2: |
| + // Should force full frame damage on the next commit |
| + PostSetNextCommitForcesRedrawToMainThread(); |
| + PostSetNeedsCommitToMainThread(); |
| + break; |
| + default: |
| + EndTest(); |
| + break; |
| + } |
| + num_draws_++; |
| + } |
| + |
| + virtual void AfterTest() OVERRIDE { |
| + EXPECT_EQ(4, num_draws_); |
| + } |
| + |
| + private: |
| + int num_draws_; |
| + const gfx::Size bounds_; |
| + FakeContentLayerClient client_; |
| + scoped_refptr<ContentLayer> root_layer_; |
| +}; |
| + |
| +SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestSetNextCommitForcesRedraw); |
| + |
| // If the layerTreeHost says it can't draw, Then we should not try to draw. |
| class LayerTreeHostTestCanDrawBlocksDrawing : public LayerTreeHostTest { |
| public: |