| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 "cc/trees/layer_tree_host.h" | 5 #include "cc/trees/layer_tree_host.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 5573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5584 | 5584 |
| 5585 class LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame | 5585 class LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame |
| 5586 : public LayerTreeHostTest { | 5586 : public LayerTreeHostTest { |
| 5587 public: | 5587 public: |
| 5588 enum { kExpectedNumImplFrames = 10 }; | 5588 enum { kExpectedNumImplFrames = 10 }; |
| 5589 | 5589 |
| 5590 LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame() | 5590 LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame() |
| 5591 : will_begin_impl_frame_count_(0), did_finish_impl_frame_count_(0) {} | 5591 : will_begin_impl_frame_count_(0), did_finish_impl_frame_count_(0) {} |
| 5592 | 5592 |
| 5593 void BeginTest() override { | 5593 void BeginTest() override { |
| 5594 // Kick off the test with a commit. |
| 5594 PostSetNeedsCommitToMainThread(); | 5595 PostSetNeedsCommitToMainThread(); |
| 5595 } | 5596 } |
| 5596 | 5597 |
| 5597 void WillBeginImplFrameOnThread(LayerTreeHostImpl* host_impl, | 5598 void WillBeginImplFrameOnThread(LayerTreeHostImpl* host_impl, |
| 5598 const BeginFrameArgs& args) override { | 5599 const BeginFrameArgs& args) override { |
| 5599 EXPECT_EQ(will_begin_impl_frame_count_, did_finish_impl_frame_count_); | 5600 EXPECT_EQ(will_begin_impl_frame_count_, did_finish_impl_frame_count_); |
| 5600 EXPECT_FALSE(TestEnded()); | 5601 EXPECT_FALSE(TestEnded()); |
| 5601 will_begin_impl_frame_count_++; | 5602 will_begin_impl_frame_count_++; |
| 5602 } | 5603 } |
| 5603 | 5604 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 5629 } | 5630 } |
| 5630 | 5631 |
| 5631 private: | 5632 private: |
| 5632 int will_begin_impl_frame_count_; | 5633 int will_begin_impl_frame_count_; |
| 5633 int did_finish_impl_frame_count_; | 5634 int did_finish_impl_frame_count_; |
| 5634 }; | 5635 }; |
| 5635 | 5636 |
| 5636 SINGLE_AND_MULTI_THREAD_TEST_F( | 5637 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 5637 LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame); | 5638 LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame); |
| 5638 | 5639 |
| 5639 ::testing::AssertionResult AssertFrameTimeContained( | |
| 5640 const char* haystack_expr, | |
| 5641 const char* needle_expr, | |
| 5642 const std::vector<BeginFrameArgs>& haystack, | |
| 5643 const BeginFrameArgs& needle) { | |
| 5644 auto failure = ::testing::AssertionFailure() | |
| 5645 << needle.frame_time << " (" << needle_expr | |
| 5646 << ") not found in " << haystack_expr; | |
| 5647 | |
| 5648 if (haystack.size() == 0) { | |
| 5649 failure << " which is empty."; | |
| 5650 } else { | |
| 5651 failure << " which contains:\n"; | |
| 5652 for (size_t i = 0; i < haystack.size(); i++) { | |
| 5653 if (haystack[i].frame_time == needle.frame_time) | |
| 5654 return ::testing::AssertionSuccess(); | |
| 5655 failure << " [" << i << "]: " << haystack[i].frame_time << "\n"; | |
| 5656 } | |
| 5657 } | |
| 5658 | |
| 5659 return failure; | |
| 5660 } | |
| 5661 | |
| 5662 class LayerTreeHostTestBeginMainFrameTimeIsAlsoImplTime | |
| 5663 : public LayerTreeHostTest { | |
| 5664 public: | |
| 5665 LayerTreeHostTestBeginMainFrameTimeIsAlsoImplTime() | |
| 5666 : impl_frame_args_(), will_begin_impl_frame_count_(0) {} | |
| 5667 | |
| 5668 void BeginTest() override { | |
| 5669 // Kick off the test with a commit. | |
| 5670 PostSetNeedsCommitToMainThread(); | |
| 5671 } | |
| 5672 | |
| 5673 void WillBeginImplFrameOnThread(LayerTreeHostImpl* impl, | |
| 5674 const BeginFrameArgs& args) override { | |
| 5675 impl_frame_args_.push_back(args); | |
| 5676 | |
| 5677 will_begin_impl_frame_count_++; | |
| 5678 if (will_begin_impl_frame_count_ < 10) | |
| 5679 PostSetNeedsCommitToMainThread(); | |
| 5680 } | |
| 5681 | |
| 5682 void BeginMainFrame(const BeginFrameArgs& args) override { | |
| 5683 ASSERT_GT(impl_frame_args_.size(), 0U) | |
| 5684 << "BeginMainFrame called before BeginImplFrame called!"; | |
| 5685 EXPECT_PRED_FORMAT2(AssertFrameTimeContained, impl_frame_args_, args); | |
| 5686 } | |
| 5687 | |
| 5688 void SendBeginMainFrameNotExpectedSoon() override { EndTest(); } | |
| 5689 | |
| 5690 void AfterTest() override { | |
| 5691 EXPECT_GT(impl_frame_args_.size(), 0U); | |
| 5692 EXPECT_GE(will_begin_impl_frame_count_, 10); | |
| 5693 } | |
| 5694 | |
| 5695 private: | |
| 5696 std::vector<BeginFrameArgs> impl_frame_args_; | |
| 5697 int will_begin_impl_frame_count_; | |
| 5698 }; | |
| 5699 | |
| 5700 SINGLE_AND_MULTI_THREAD_IMPL_TEST_F( | |
| 5701 LayerTreeHostTestBeginMainFrameTimeIsAlsoImplTime); | |
| 5702 | |
| 5703 class LayerTreeHostTestSendBeginFramesToChildren : public LayerTreeHostTest { | 5640 class LayerTreeHostTestSendBeginFramesToChildren : public LayerTreeHostTest { |
| 5704 public: | 5641 public: |
| 5705 LayerTreeHostTestSendBeginFramesToChildren() | 5642 LayerTreeHostTestSendBeginFramesToChildren() |
| 5706 : begin_frame_sent_to_children_(false) { | 5643 : begin_frame_sent_to_children_(false) { |
| 5707 } | 5644 } |
| 5708 | 5645 |
| 5709 void BeginTest() override { | 5646 void BeginTest() override { |
| 5710 // Kick off the test with a commit. | 5647 // Kick off the test with a commit. |
| 5711 PostSetNeedsCommitToMainThread(); | 5648 PostSetNeedsCommitToMainThread(); |
| 5712 } | 5649 } |
| (...skipping 1525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7238 void AfterTest() override {} | 7175 void AfterTest() override {} |
| 7239 | 7176 |
| 7240 scoped_refptr<FakePictureLayer> content_child_layer_; | 7177 scoped_refptr<FakePictureLayer> content_child_layer_; |
| 7241 FakeContentLayerClient client_; | 7178 FakeContentLayerClient client_; |
| 7242 }; | 7179 }; |
| 7243 | 7180 |
| 7244 SINGLE_AND_MULTI_THREAD_TEST_F( | 7181 SINGLE_AND_MULTI_THREAD_TEST_F( |
| 7245 LayerTreeTestReflectionMaskLayerForSurfaceWithUnclippedChild); | 7182 LayerTreeTestReflectionMaskLayerForSurfaceWithUnclippedChild); |
| 7246 | 7183 |
| 7247 } // namespace cc | 7184 } // namespace cc |
| OLD | NEW |