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

Side by Side Diff: blimp/engine/renderer/frame_scheduler_unittest.cc

Issue 2629743003: Remove all blimp engine code (Closed)
Patch Set: Use consistent comment style in //chrome Created 3 years, 11 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 | « blimp/engine/renderer/frame_scheduler.cc ('k') | blimp/engine/session/blimp_engine_session.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "blimp/engine/renderer/frame_scheduler.h"
6
7 #include "base/run_loop.h"
8 #include "base/threading/thread_task_runner_handle.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 namespace blimp {
12 namespace engine {
13 namespace {
14
15 class FrameSchedulerTest : public testing::Test, public FrameSchedulerClient {
16 public:
17 FrameSchedulerTest() : scheduler_(base::ThreadTaskRunnerHandle::Get(), this) {
18 scheduler_.set_frame_delay_for_testing(base::TimeDelta::FromSeconds(0));
19 }
20 ~FrameSchedulerTest() override {}
21
22 // FrameSchedulerClient implementation.
23 void StartFrameUpdate() override {
24 num_frames_++;
25 if (send_client_update_during_frame_) {
26 scheduler_.DidSendFrameUpdateToClient();
27 send_client_update_during_frame_ = false;
28 }
29 }
30
31 protected:
32 base::MessageLoop loop_;
33 FrameScheduler scheduler_;
34 int num_frames_ = 0;
35
36 bool send_client_update_during_frame_ = false;
37 };
38
39 TEST_F(FrameSchedulerTest, FirstMainFrameRequest) {
40 // The request for the first main frame should be responded to right away.
41 scheduler_.ScheduleFrameUpdate();
42 base::RunLoop().RunUntilIdle();
43 EXPECT_EQ(1, num_frames_);
44 }
45
46 TEST_F(FrameSchedulerTest, MultipleMainFrameRequestsResultInSingleFrame) {
47 // Multiple main frame requests result in a single callback to the client.
48 scheduler_.ScheduleFrameUpdate();
49 scheduler_.ScheduleFrameUpdate();
50 base::RunLoop().RunUntilIdle();
51 EXPECT_EQ(1, num_frames_);
52 }
53
54 TEST_F(FrameSchedulerTest, MainFrameBlockedOnAckFromClient) {
55 // Request a main frame, start it and send an update to the client. The second
56 // frame should remain blocked till an ack is received.
57 scheduler_.ScheduleFrameUpdate();
58 send_client_update_during_frame_ = true;
59 base::RunLoop().RunUntilIdle();
60 EXPECT_EQ(1, num_frames_);
61
62 // Request a frame and ensure that the client is not asked to start it.
63 scheduler_.ScheduleFrameUpdate();
64 base::RunLoop().RunUntilIdle();
65 EXPECT_EQ(1, num_frames_);
66
67 // Now we have an ack from the client. This should start another frame.
68 scheduler_.DidReceiveFrameUpdateAck();
69 base::RunLoop().RunUntilIdle();
70 EXPECT_EQ(2, num_frames_);
71 }
72
73 } // namespace
74 } // namespace engine
75 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/engine/renderer/frame_scheduler.cc ('k') | blimp/engine/session/blimp_engine_session.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698