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

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

Issue 1104193003: cc: Test BeginMainFrame values come from BeginImplFrame. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't use references. Created 5 years, 3 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 4603 matching lines...) Expand 10 before | Expand all | Expand 10 after
4614 4614
4615 class LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame 4615 class LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame
4616 : public LayerTreeHostTest { 4616 : public LayerTreeHostTest {
4617 public: 4617 public:
4618 enum { kExpectedNumImplFrames = 10 }; 4618 enum { kExpectedNumImplFrames = 10 };
4619 4619
4620 LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame() 4620 LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame()
4621 : will_begin_impl_frame_count_(0), did_finish_impl_frame_count_(0) {} 4621 : will_begin_impl_frame_count_(0), did_finish_impl_frame_count_(0) {}
4622 4622
4623 void BeginTest() override { 4623 void BeginTest() override {
4624 // Kick off the test with a commit.
4625 PostSetNeedsCommitToMainThread(); 4624 PostSetNeedsCommitToMainThread();
4626 } 4625 }
4627 4626
4628 void WillBeginImplFrameOnThread(LayerTreeHostImpl* host_impl, 4627 void WillBeginImplFrameOnThread(LayerTreeHostImpl* host_impl,
4629 const BeginFrameArgs& args) override { 4628 const BeginFrameArgs& args) override {
4630 EXPECT_EQ(will_begin_impl_frame_count_, did_finish_impl_frame_count_); 4629 EXPECT_EQ(will_begin_impl_frame_count_, did_finish_impl_frame_count_);
4631 EXPECT_FALSE(TestEnded()); 4630 EXPECT_FALSE(TestEnded());
4632 will_begin_impl_frame_count_++; 4631 will_begin_impl_frame_count_++;
4633 } 4632 }
4634 4633
(...skipping 25 matching lines...) Expand all
4660 } 4659 }
4661 4660
4662 private: 4661 private:
4663 int will_begin_impl_frame_count_; 4662 int will_begin_impl_frame_count_;
4664 int did_finish_impl_frame_count_; 4663 int did_finish_impl_frame_count_;
4665 }; 4664 };
4666 4665
4667 SINGLE_AND_MULTI_THREAD_TEST_F( 4666 SINGLE_AND_MULTI_THREAD_TEST_F(
4668 LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame); 4667 LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame);
4669 4668
4669 ::testing::AssertionResult AssertFrameTimeContained(
4670 const char* haystack_expr,
4671 const char* needle_expr,
4672 const std::vector<BeginFrameArgs> haystack,
4673 const BeginFrameArgs needle) {
4674 auto failure = ::testing::AssertionFailure()
4675 << needle.frame_time << " (" << needle_expr
4676 << ") not found in " << haystack_expr;
4677
4678 if (haystack.size() == 0) {
4679 failure << " which is empty.";
4680 } else {
4681 failure << " which contains:\n";
4682 for (size_t i = 0; i < haystack.size(); i++) {
4683 if (haystack[i].frame_time == needle.frame_time)
4684 return ::testing::AssertionSuccess();
4685 failure << " [" << i << "]: " << haystack[i].frame_time << "\n";
4686 }
4687 }
4688
4689 return failure;
4690 }
4691
4692 class LayerTreeHostTestBeginMainFrameTimeIsAlsoImplTime
4693 : public LayerTreeHostTest {
4694 public:
4695 LayerTreeHostTestBeginMainFrameTimeIsAlsoImplTime()
4696 : impl_frame_args_(), will_begin_impl_frame_count_(0) {}
4697
4698 void BeginTest() override {
4699 // Kick off the test with a commit.
4700 PostSetNeedsCommitToMainThread();
4701 }
4702
4703 void WillBeginImplFrameOnThread(LayerTreeHostImpl* impl,
4704 const BeginFrameArgs& args) override {
4705 impl_frame_args_.push_back(args);
4706
4707 will_begin_impl_frame_count_++;
4708 if (will_begin_impl_frame_count_ < 10)
4709 PostSetNeedsCommitToMainThread();
4710 }
4711
4712 void BeginMainFrame(const BeginFrameArgs& args) override {
4713 ASSERT_GT(impl_frame_args_.size(), 0U)
4714 << "BeginMainFrame called before BeginImplFrame called!";
4715 EXPECT_PRED_FORMAT2(AssertFrameTimeContained, impl_frame_args_, args);
4716 }
4717
4718 void SendBeginMainFrameNotExpectedSoon() override { EndTest(); }
4719
4720 void AfterTest() override {
4721 EXPECT_GT(impl_frame_args_.size(), 0U);
4722 EXPECT_GE(will_begin_impl_frame_count_, 10);
4723 }
4724
4725 private:
4726 std::vector<BeginFrameArgs> impl_frame_args_;
4727 int will_begin_impl_frame_count_;
4728 };
4729
4730 SINGLE_AND_MULTI_THREAD_TEST_F(
4731 LayerTreeHostTestBeginMainFrameTimeIsAlsoImplTime);
4732
4670 class LayerTreeHostTestSendBeginFramesToChildren : public LayerTreeHostTest { 4733 class LayerTreeHostTestSendBeginFramesToChildren : public LayerTreeHostTest {
4671 public: 4734 public:
4672 LayerTreeHostTestSendBeginFramesToChildren() 4735 LayerTreeHostTestSendBeginFramesToChildren()
4673 : begin_frame_sent_to_children_(false) { 4736 : begin_frame_sent_to_children_(false) {
4674 } 4737 }
4675 4738
4676 void BeginTest() override { 4739 void BeginTest() override {
4677 // Kick off the test with a commit. 4740 // Kick off the test with a commit.
4678 PostSetNeedsCommitToMainThread(); 4741 PostSetNeedsCommitToMainThread();
4679 } 4742 }
(...skipping 1588 matching lines...) Expand 10 before | Expand all | Expand 10 after
6268 EndTest(); 6331 EndTest();
6269 } 6332 }
6270 6333
6271 void AfterTest() override {} 6334 void AfterTest() override {}
6272 }; 6335 };
6273 6336
6274 MULTI_THREAD_TEST_F(LayerTreeHostTestDestroyWhileInitializingOutputSurface); 6337 MULTI_THREAD_TEST_F(LayerTreeHostTestDestroyWhileInitializingOutputSurface);
6275 6338
6276 } // namespace 6339 } // namespace
6277 } // namespace cc 6340 } // 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