diff options
author | mithro <mithro@mithis.com> | 2015-05-07 21:57:25 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-05-08 04:57:53 +0000 |
commit | a003f9bc651a572fea3881cfb72a7d8842c62192 (patch) | |
tree | ac1235ca3868f9cdc767abcb8ef71a8f613aea1a | |
parent | 193da56aa306b667b81597b6fb35b36172d133da (diff) | |
download | chromium_src-a003f9bc651a572fea3881cfb72a7d8842c62192.zip chromium_src-a003f9bc651a572fea3881cfb72a7d8842c62192.tar.gz chromium_src-a003f9bc651a572fea3881cfb72a7d8842c62192.tar.bz2 |
cc: Test BeginMainFrame values come from BeginImplFrame.
The frame time in the BeginFrameArgs sent to BeginMainFrame should match a
value from a BeginImplFrame. However there is not a 1:1 relantionship, when the
main thread is slow, there many be multiple impl frames.
DEPS=http://crrev.com/787763006
BUG=346230
R=brianderson,enne
Review URL: https://codereview.chromium.org/1104193003
Cr-Commit-Position: refs/heads/master@{#328929}
-rw-r--r-- | cc/trees/layer_tree_host_unittest.cc | 65 |
1 files changed, 64 insertions, 1 deletions
diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc index df01000..64eebdc 100644 --- a/cc/trees/layer_tree_host_unittest.cc +++ b/cc/trees/layer_tree_host_unittest.cc @@ -5591,7 +5591,6 @@ class LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame : will_begin_impl_frame_count_(0), did_finish_impl_frame_count_(0) {} void BeginTest() override { - // Kick off the test with a commit. PostSetNeedsCommitToMainThread(); } @@ -5637,6 +5636,70 @@ class LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame SINGLE_AND_MULTI_THREAD_TEST_F( LayerTreeHostTestWillBeginImplFrameHasDidFinishImplFrame); +::testing::AssertionResult AssertFrameTimeContained( + const char* haystack_expr, + const char* needle_expr, + const std::vector<BeginFrameArgs>& haystack, + const BeginFrameArgs& needle) { + auto failure = ::testing::AssertionFailure() + << needle.frame_time << " (" << needle_expr + << ") not found in " << haystack_expr; + + if (haystack.size() == 0) { + failure << " which is empty."; + } else { + failure << " which contains:\n"; + for (size_t i = 0; i < haystack.size(); i++) { + if (haystack[i].frame_time == needle.frame_time) + return ::testing::AssertionSuccess(); + failure << " [" << i << "]: " << haystack[i].frame_time << "\n"; + } + } + + return failure; +} + +class LayerTreeHostTestBeginMainFrameTimeIsAlsoImplTime + : public LayerTreeHostTest { + public: + LayerTreeHostTestBeginMainFrameTimeIsAlsoImplTime() + : impl_frame_args_(), will_begin_impl_frame_count_(0) {} + + void BeginTest() override { + // Kick off the test with a commit. + PostSetNeedsCommitToMainThread(); + } + + void WillBeginImplFrameOnThread(LayerTreeHostImpl* impl, + const BeginFrameArgs& args) override { + impl_frame_args_.push_back(args); + + will_begin_impl_frame_count_++; + if (will_begin_impl_frame_count_ < 10) + PostSetNeedsCommitToMainThread(); + } + + void BeginMainFrame(const BeginFrameArgs& args) override { + ASSERT_GT(impl_frame_args_.size(), 0U) + << "BeginMainFrame called before BeginImplFrame called!"; + EXPECT_PRED_FORMAT2(AssertFrameTimeContained, impl_frame_args_, args); + } + + void SendBeginMainFrameNotExpectedSoon() override { EndTest(); } + + void AfterTest() override { + EXPECT_GT(impl_frame_args_.size(), 0U); + EXPECT_GE(will_begin_impl_frame_count_, 10); + } + + private: + std::vector<BeginFrameArgs> impl_frame_args_; + int will_begin_impl_frame_count_; +}; + +SINGLE_AND_MULTI_THREAD_IMPL_TEST_F( + LayerTreeHostTestBeginMainFrameTimeIsAlsoImplTime); + class LayerTreeHostTestSendBeginFramesToChildren : public LayerTreeHostTest { public: LayerTreeHostTestSendBeginFramesToChildren() |