Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(189)

Side by Side Diff: cc/trees/layer_tree_host_unittest.cc

Issue 1162763002: Revert of cc: Test BeginMainFrame values come from BeginImplFrame. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 5671 matching lines...) Expand 10 before | Expand all | Expand 10 after
5682 5682
5683 class LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame 5683 class LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame
5684 : public LayerTreeHostTest { 5684 : public LayerTreeHostTest {
5685 public: 5685 public:
5686 enum { kExpectedNumImplFrames = 10 }; 5686 enum { kExpectedNumImplFrames = 10 };
5687 5687
5688 LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame() 5688 LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame()
5689 : will_begin_impl_frame_count_(0), did_finish_impl_frame_count_(0) {} 5689 : will_begin_impl_frame_count_(0), did_finish_impl_frame_count_(0) {}
5690 5690
5691 void BeginTest() override { 5691 void BeginTest() override {
5692 // Kick off the test with a commit.
5692 PostSetNeedsCommitToMainThread(); 5693 PostSetNeedsCommitToMainThread();
5693 } 5694 }
5694 5695
5695 void WillBeginImplFrameOnThread(LayerTreeHostImpl* host_impl, 5696 void WillBeginImplFrameOnThread(LayerTreeHostImpl* host_impl,
5696 const BeginFrameArgs& args) override { 5697 const BeginFrameArgs& args) override {
5697 EXPECT_EQ(will_begin_impl_frame_count_, did_finish_impl_frame_count_); 5698 EXPECT_EQ(will_begin_impl_frame_count_, did_finish_impl_frame_count_);
5698 EXPECT_FALSE(TestEnded()); 5699 EXPECT_FALSE(TestEnded());
5699 will_begin_impl_frame_count_++; 5700 will_begin_impl_frame_count_++;
5700 } 5701 }
5701 5702
(...skipping 25 matching lines...) Expand all
5727 } 5728 }
5728 5729
5729 private: 5730 private:
5730 int will_begin_impl_frame_count_; 5731 int will_begin_impl_frame_count_;
5731 int did_finish_impl_frame_count_; 5732 int did_finish_impl_frame_count_;
5732 }; 5733 };
5733 5734
5734 SINGLE_AND_MULTI_THREAD_TEST_F( 5735 SINGLE_AND_MULTI_THREAD_TEST_F(
5735 LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame); 5736 LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame);
5736 5737
5737 ::testing::AssertionResult AssertFrameTimeContained(
5738 const char* haystack_expr,
5739 const char* needle_expr,
5740 const std::vector<BeginFrameArgs>& haystack,
5741 const BeginFrameArgs& needle) {
5742 auto failure = ::testing::AssertionFailure()
5743 << needle.frame_time << " (" << needle_expr
5744 << ") not found in " << haystack_expr;
5745
5746 if (haystack.size() == 0) {
5747 failure << " which is empty.";
5748 } else {
5749 failure << " which contains:\n";
5750 for (size_t i = 0; i < haystack.size(); i++) {
5751 if (haystack[i].frame_time == needle.frame_time)
5752 return ::testing::AssertionSuccess();
5753 failure << " [" << i << "]: " << haystack[i].frame_time << "\n";
5754 }
5755 }
5756
5757 return failure;
5758 }
5759
5760 class LayerTreeHostTestBeginMainFrameTimeIsAlsoImplTime
5761 : public LayerTreeHostTest {
5762 public:
5763 LayerTreeHostTestBeginMainFrameTimeIsAlsoImplTime()
5764 : impl_frame_args_(), will_begin_impl_frame_count_(0) {}
5765
5766 void BeginTest() override {
5767 // Kick off the test with a commit.
5768 PostSetNeedsCommitToMainThread();
5769 }
5770
5771 void WillBeginImplFrameOnThread(LayerTreeHostImpl* impl,
5772 const BeginFrameArgs& args) override {
5773 impl_frame_args_.push_back(args);
5774
5775 will_begin_impl_frame_count_++;
5776 if (will_begin_impl_frame_count_ < 10)
5777 PostSetNeedsCommitToMainThread();
5778 }
5779
5780 void BeginMainFrame(const BeginFrameArgs& args) override {
5781 ASSERT_GT(impl_frame_args_.size(), 0U)
5782 << "BeginMainFrame called before BeginImplFrame called!";
5783 EXPECT_PRED_FORMAT2(AssertFrameTimeContained, impl_frame_args_, args);
5784 }
5785
5786 void SendBeginMainFrameNotExpectedSoon() override { EndTest(); }
5787
5788 void AfterTest() override {
5789 EXPECT_GT(impl_frame_args_.size(), 0U);
5790 EXPECT_GE(will_begin_impl_frame_count_, 10);
5791 }
5792
5793 private:
5794 std::vector<BeginFrameArgs> impl_frame_args_;
5795 int will_begin_impl_frame_count_;
5796 };
5797
5798 SINGLE_AND_MULTI_THREAD_IMPL_TEST_F(
5799 LayerTreeHostTestBeginMainFrameTimeIsAlsoImplTime);
5800
5801 class LayerTreeHostTestSendBeginFramesToChildren : public LayerTreeHostTest { 5738 class LayerTreeHostTestSendBeginFramesToChildren : public LayerTreeHostTest {
5802 public: 5739 public:
5803 LayerTreeHostTestSendBeginFramesToChildren() 5740 LayerTreeHostTestSendBeginFramesToChildren()
5804 : begin_frame_sent_to_children_(false) { 5741 : begin_frame_sent_to_children_(false) {
5805 } 5742 }
5806 5743
5807 void BeginTest() override { 5744 void BeginTest() override {
5808 // Kick off the test with a commit. 5745 // Kick off the test with a commit.
5809 PostSetNeedsCommitToMainThread(); 5746 PostSetNeedsCommitToMainThread();
5810 } 5747 }
(...skipping 1532 matching lines...) Expand 10 before | Expand all | Expand 10 after
7343 void AfterTest() override {} 7280 void AfterTest() override {}
7344 7281
7345 scoped_refptr<FakePictureLayer> content_child_layer_; 7282 scoped_refptr<FakePictureLayer> content_child_layer_;
7346 FakeContentLayerClient client_; 7283 FakeContentLayerClient client_;
7347 }; 7284 };
7348 7285
7349 SINGLE_AND_MULTI_THREAD_TEST_F( 7286 SINGLE_AND_MULTI_THREAD_TEST_F(
7350 LayerTreeTestReflectionMaskLayerForSurfaceWithUnclippedChild); 7287 LayerTreeTestReflectionMaskLayerForSurfaceWithUnclippedChild);
7351 7288
7352 } // namespace cc 7289 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698