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

Unified Diff: cc/trees/layer_tree_host_unittest.cc

Issue 2712983003: [cc] Set BeginFrame sequence numbers on CompositorFrames from Scheduler. (Closed)
Patch Set: fix comment + test. Created 3 years, 9 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 | « cc/trees/layer_tree_host_impl_unittest.cc ('k') | cc/trees/proxy_impl.cc » ('j') | 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 1f2059cb0c3ea1c3c1bd7d9bf17b64d037a71a42..d2421cf840b00b1bf28647a6a9450c0591c2a5d3 100644
--- a/cc/trees/layer_tree_host_unittest.cc
+++ b/cc/trees/layer_tree_host_unittest.cc
@@ -34,6 +34,7 @@
#include "cc/quads/render_pass_draw_quad.h"
#include "cc/quads/tile_draw_quad.h"
#include "cc/resources/ui_resource_manager.h"
+#include "cc/test/begin_frame_args_test.h"
#include "cc/test/fake_content_layer_client.h"
#include "cc/test/fake_layer_tree_host_client.h"
#include "cc/test/fake_output_surface.h"
@@ -7037,5 +7038,82 @@ class LayerTreeHostTestContentSourceId : public LayerTreeHostTest {
SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestContentSourceId);
+class LayerTreeHostTestBeginFrameSequenceNumbers : public LayerTreeHostTest {
+ protected:
+ void BeginTest() override { PostSetNeedsCommitToMainThread(); }
+
+ void WillBeginImplFrameOnThread(LayerTreeHostImpl* impl,
+ const BeginFrameArgs& args) override {
+ // First BeginFrame will block activation, second one unblocks.
+ impl->BlockNotifyReadyToActivateForTesting(false);
+
+ EXPECT_TRUE(args.IsValid());
+ current_begin_frame_args_ = args;
+ }
+
+ void BeginMainFrame(const BeginFrameArgs& args) override {
+ EXPECT_TRUE(args.IsValid());
+ if (!current_begin_main_frame_args_.IsValid())
+ current_begin_main_frame_args_ = args;
+ }
+
+ void BeginCommitOnThread(LayerTreeHostImpl* impl) override {
+ current_begin_main_frame_args_on_impl_ = current_begin_main_frame_args_;
+ // Request another subsequent commit. That way, the first commit's
+ // latest_confirmed_sequence_number should stay at the first BeginFrame's
+ // sequence number.
+ PostSetNeedsCommitToMainThread();
+ }
+
+ void WillCommitCompleteOnThread(LayerTreeHostImpl* impl) override {
+ // Defer current commit's activation until second BeginFrame.
+ impl->BlockNotifyReadyToActivateForTesting(true);
+ }
+
+ DrawResult PrepareToDrawOnThread(LayerTreeHostImpl* impl,
+ LayerTreeHostImpl::FrameData* frame_data,
+ DrawResult draw_result) override {
+ // We should only draw in second BeginFrame.
+ EXPECT_TRUE(current_begin_main_frame_args_on_impl_.IsValid());
+ EXPECT_LT(current_begin_main_frame_args_on_impl_.sequence_number,
+ current_begin_frame_args_.sequence_number);
+ frame_data_ = frame_data;
+ return draw_result;
+ }
+
+ void DrawLayersOnThread(LayerTreeHostImpl* impl) override {
+ EXPECT_TRUE(frame_data_);
+ EXPECT_EQ(
+ BeginFrameAck(current_begin_frame_args_.source_id,
+ current_begin_frame_args_.sequence_number,
+ current_begin_main_frame_args_on_impl_.sequence_number, 0,
+ true),
+ frame_data_->begin_frame_ack);
+ }
+
+ void DisplayReceivedCompositorFrameOnThread(
+ const CompositorFrame& frame) override {
+ compositor_frame_submitted_ = true;
+ EXPECT_EQ(
+ BeginFrameAck(current_begin_frame_args_.source_id,
+ current_begin_frame_args_.sequence_number,
+ current_begin_main_frame_args_on_impl_.sequence_number, 0,
+ true),
+ frame.metadata.begin_frame_ack);
+ EndTest();
+ }
+
+ void AfterTest() override { EXPECT_TRUE(compositor_frame_submitted_); }
+
+ private:
+ bool compositor_frame_submitted_;
+ BeginFrameArgs current_begin_frame_args_;
+ BeginFrameArgs current_begin_main_frame_args_;
+ BeginFrameArgs current_begin_main_frame_args_on_impl_;
+ LayerTreeHostImpl::FrameData* frame_data_;
+};
+
+MULTI_THREAD_BLOCKNOTIFY_TEST_F(LayerTreeHostTestBeginFrameSequenceNumbers);
+
} // namespace
} // namespace cc
« no previous file with comments | « cc/trees/layer_tree_host_impl_unittest.cc ('k') | cc/trees/proxy_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698