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 edf6722a07d8b7bddd8de1295148d541c0f956d2..da692e6961780360cdae99c72a137eae8c4ce694 100644 |
--- a/cc/trees/layer_tree_host_unittest.cc |
+++ b/cc/trees/layer_tree_host_unittest.cc |
@@ -276,6 +276,64 @@ class LayerTreeHostTestNoExtraCommitFromInvalidate : public LayerTreeHostTest { |
SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestNoExtraCommitFromInvalidate); |
+class LayerTreeHostTestNoExtraCommitFromScrollbarInvalidate |
+ : public LayerTreeHostTest { |
+ public: |
+ LayerTreeHostTestNoExtraCommitFromScrollbarInvalidate() |
+ : root_layer_(ContentLayer::Create(&client_)), |
+ num_draws_(0) {} |
+ |
+ virtual void SetupTree() OVERRIDE { |
+ root_layer_->SetBounds(gfx::Size(10, 20)); |
+ |
+ bool paint_scrollbar = true; |
+ bool has_thumb = false; |
+ scrollbar_ = FakeScrollbarLayer::Create(paint_scrollbar, |
+ has_thumb, |
+ root_layer_->id()); |
+ scrollbar_->SetPosition(gfx::Point(0, 10)); |
+ scrollbar_->SetBounds(gfx::Size(10, 10)); |
+ |
+ root_layer_->AddChild(scrollbar_); |
+ |
+ layer_tree_host()->SetRootLayer(root_layer_); |
+ LayerTreeHostTest::SetupTree(); |
+ } |
+ |
+ virtual void BeginTest() OVERRIDE { |
+ PostSetNeedsCommitToMainThread(); |
+ } |
+ |
+ virtual void DrawLayersOnThread(LayerTreeHostImpl* host_impl) OVERRIDE { |
+ num_draws_++; |
+ if (num_draws_ == 2) |
+ EndTest(); |
danakj
2013/04/18 18:53:32
Can you not tie this to the number of draws? You m
ajuma
2013/04/18 18:59:08
I tried this approach, but this wasn't enough to g
ajuma
2013/04/18 19:21:25
As discussed offline, changed this to use source_f
|
+ } |
+ |
+ virtual void DidCommit() OVERRIDE { |
+ switch (layer_tree_host()->commit_number()) { |
+ case 1: |
+ // This should cause a single commit. |
+ scrollbar_->SetRasterScale(4.0f); |
+ break; |
+ default: |
+ // No extra commits. |
+ EXPECT_EQ(2, layer_tree_host()->commit_number()); |
+ } |
+ } |
+ |
+ virtual void AfterTest() OVERRIDE {} |
+ |
+ private: |
+ FakeContentLayerClient client_; |
+ scoped_refptr<ContentLayer> root_layer_; |
danakj
2013/04/18 18:53:32
can you use FakeContentLayer instead? it does stuf
ajuma
2013/04/18 19:21:25
Done.
|
+ scoped_refptr<FakeScrollbarLayer> scrollbar_; |
+ int num_draws_; |
+}; |
+ |
+SINGLE_AND_MULTI_THREAD_TEST_F( |
+ LayerTreeHostTestNoExtraCommitFromScrollbarInvalidate); |
+ |
class LayerTreeHostTestCompositeAndReadback : public LayerTreeHostTest { |
public: |
LayerTreeHostTestCompositeAndReadback() : num_commits_(0) {} |