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

Unified Diff: components/exo/surface_unittest.cc

Issue 2724953007: [exo] Clean up BeginFrame distribution & add acks in Surface. (Closed)
Patch Set: rename instance var. 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 | « components/exo/surface.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/exo/surface_unittest.cc
diff --git a/components/exo/surface_unittest.cc b/components/exo/surface_unittest.cc
index 3b8f4c470fdfa9e1a65b800ac2e91007369216f2..eb06aa29fe8a1760ef9c227107f63d820ae0462c 100644
--- a/components/exo/surface_unittest.cc
+++ b/components/exo/surface_unittest.cc
@@ -2,11 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "cc/surfaces/surface.h"
#include "base/bind.h"
#include "cc/output/compositor_frame.h"
#include "cc/quads/texture_draw_quad.h"
-#include "cc/surfaces/surface.h"
#include "cc/surfaces/surface_manager.h"
+#include "cc/test/begin_frame_args_test.h"
+#include "cc/test/fake_external_begin_frame_source.h"
#include "components/exo/buffer.h"
#include "components/exo/surface.h"
#include "components/exo/test/exo_test_base.h"
@@ -311,5 +313,41 @@ TEST_F(SurfaceTest, Commit) {
surface->Commit();
}
+TEST_F(SurfaceTest, SendsBeginFrameAcks) {
+ cc::FakeExternalBeginFrameSource source(0.f, false);
+ gfx::Size buffer_size(1, 1);
+ std::unique_ptr<Buffer> buffer(
+ new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)));
+ std::unique_ptr<Surface> surface(new Surface);
+ surface->SetBeginFrameSource(&source);
+ surface->Attach(buffer.get());
+
+ // Request a frame callback so that Surface now needs BeginFrames.
+ base::TimeTicks frame_time;
+ surface->RequestFrameCallback(
+ base::Bind(&SetFrameTime, base::Unretained(&frame_time)));
+ surface->Commit(); // Move callback from pending callbacks to current ones.
+ RunAllPendingInMessageLoop();
+
+ // Surface should add itself as observer during WillDraw().
+ surface->WillDraw();
+ EXPECT_EQ(1u, source.num_observers());
+
+ cc::BeginFrameArgs args(source.CreateBeginFrameArgs(BEGINFRAME_FROM_HERE));
+ args.frame_time = base::TimeTicks::FromInternalValue(100);
+ source.TestOnBeginFrame(args); // Runs the frame callback.
+ EXPECT_EQ(args.frame_time, frame_time);
+
+ surface->Commit(); // Acknowledges the BeginFrame.
+ RunAllPendingInMessageLoop();
+
+ cc::BeginFrameAck expected_ack(args.source_id, args.sequence_number,
+ args.sequence_number, 0, true);
+ EXPECT_EQ(expected_ack, source.LastAckForObserver(surface.get()));
+
+ const cc::CompositorFrame& frame = GetFrameFromSurface(surface.get());
+ EXPECT_EQ(expected_ack, frame.metadata.begin_frame_ack);
+}
+
} // namespace
} // namespace exo
« no previous file with comments | « components/exo/surface.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698