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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 bc77d651c5d7f74fb75d348618cc2605fe459547..d7c5632ca1ebfa334235be2d5efa5e45561c6aed 100644
--- a/cc/trees/layer_tree_host_unittest.cc
+++ b/cc/trees/layer_tree_host_unittest.cc
@@ -4621,7 +4621,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();
}
@@ -4667,6 +4666,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_TEST_F(
+ LayerTreeHostTestBeginMainFrameTimeIsAlsoImplTime);
+
class LayerTreeHostTestSendBeginFramesToChildren : public LayerTreeHostTest {
public:
LayerTreeHostTestSendBeginFramesToChildren()
« 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