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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « components/exo/surface.cc ('k') | 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/surfaces/surface.h"
5 #include "base/bind.h" 6 #include "base/bind.h"
6 #include "cc/output/compositor_frame.h" 7 #include "cc/output/compositor_frame.h"
7 #include "cc/quads/texture_draw_quad.h" 8 #include "cc/quads/texture_draw_quad.h"
8 #include "cc/surfaces/surface.h"
9 #include "cc/surfaces/surface_manager.h" 9 #include "cc/surfaces/surface_manager.h"
10 #include "cc/test/begin_frame_args_test.h"
11 #include "cc/test/fake_external_begin_frame_source.h"
10 #include "components/exo/buffer.h" 12 #include "components/exo/buffer.h"
11 #include "components/exo/surface.h" 13 #include "components/exo/surface.h"
12 #include "components/exo/test/exo_test_base.h" 14 #include "components/exo/test/exo_test_base.h"
13 #include "components/exo/test/exo_test_helper.h" 15 #include "components/exo/test/exo_test_helper.h"
14 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
15 #include "ui/aura/env.h" 17 #include "ui/aura/env.h"
16 #include "ui/compositor/layer_tree_owner.h" 18 #include "ui/compositor/layer_tree_owner.h"
17 #include "ui/gfx/gpu_memory_buffer.h" 19 #include "ui/gfx/gpu_memory_buffer.h"
18 #include "ui/wm/core/window_util.h" 20 #include "ui/wm/core/window_util.h"
19 21
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 surface->Commit(); 306 surface->Commit();
305 } 307 }
306 308
307 TEST_F(SurfaceTest, Commit) { 309 TEST_F(SurfaceTest, Commit) {
308 std::unique_ptr<Surface> surface(new Surface); 310 std::unique_ptr<Surface> surface(new Surface);
309 311
310 // Calling commit without a buffer should succeed. 312 // Calling commit without a buffer should succeed.
311 surface->Commit(); 313 surface->Commit();
312 } 314 }
313 315
316 TEST_F(SurfaceTest, SendsBeginFrameAcks) {
317 cc::FakeExternalBeginFrameSource source(0.f, false);
318 gfx::Size buffer_size(1, 1);
319 std::unique_ptr<Buffer> buffer(
320 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)));
321 std::unique_ptr<Surface> surface(new Surface);
322 surface->SetBeginFrameSource(&source);
323 surface->Attach(buffer.get());
324
325 // Request a frame callback so that Surface now needs BeginFrames.
326 base::TimeTicks frame_time;
327 surface->RequestFrameCallback(
328 base::Bind(&SetFrameTime, base::Unretained(&frame_time)));
329 surface->Commit(); // Move callback from pending callbacks to current ones.
330 RunAllPendingInMessageLoop();
331
332 // Surface should add itself as observer during WillDraw().
333 surface->WillDraw();
334 EXPECT_EQ(1u, source.num_observers());
335
336 cc::BeginFrameArgs args(source.CreateBeginFrameArgs(BEGINFRAME_FROM_HERE));
337 args.frame_time = base::TimeTicks::FromInternalValue(100);
338 source.TestOnBeginFrame(args); // Runs the frame callback.
339 EXPECT_EQ(args.frame_time, frame_time);
340
341 surface->Commit(); // Acknowledges the BeginFrame.
342 RunAllPendingInMessageLoop();
343
344 cc::BeginFrameAck expected_ack(args.source_id, args.sequence_number,
345 args.sequence_number, 0, true);
346 EXPECT_EQ(expected_ack, source.LastAckForObserver(surface.get()));
347
348 const cc::CompositorFrame& frame = GetFrameFromSurface(surface.get());
349 EXPECT_EQ(expected_ack, frame.metadata.begin_frame_ack);
350 }
351
314 } // namespace 352 } // namespace
315 } // namespace exo 353 } // namespace exo
OLDNEW
« 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