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

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

Issue 2445093002: cc/blimp: Add synchronization for scroll/scale state. (Closed)
Patch Set: test compile Created 4 years, 1 month 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') | cc/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 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 <blimp/engine/renderer/frame_scheduler.h> 5 #include "blimp/engine/renderer/frame_scheduler.h"
6
6 #include "base/run_loop.h" 7 #include "base/run_loop.h"
7 #include "base/threading/thread_task_runner_handle.h" 8 #include "base/threading/thread_task_runner_handle.h"
8 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
9 10
10 namespace blimp { 11 namespace blimp {
11 namespace engine { 12 namespace engine {
12 namespace { 13 namespace {
13 14
14 class FrameSchedulerForTesting : public FrameScheduler {
15 public:
16 explicit FrameSchedulerForTesting(FrameSchedulerClient* client)
17 // Use a zero time delta to let tests run main frames back-to-back.
18 : FrameScheduler(base::TimeDelta::FromSeconds(0),
19 base::ThreadTaskRunnerHandle::Get(),
20 client) {}
21 ~FrameSchedulerForTesting() override = default;
22 };
23
24 class FrameSchedulerTest : public testing::Test, public FrameSchedulerClient { 15 class FrameSchedulerTest : public testing::Test, public FrameSchedulerClient {
25 public: 16 public:
26 FrameSchedulerTest() : scheduler_(this) {} 17 FrameSchedulerTest() : scheduler_(base::ThreadTaskRunnerHandle::Get(), this) {
18 scheduler_.set_frame_delay_for_testing(base::TimeDelta::FromSeconds(0));
19 }
27 ~FrameSchedulerTest() override {} 20 ~FrameSchedulerTest() override {}
28 21
29 // FrameSchedulerClient implementation. 22 // FrameSchedulerClient implementation.
30 void StartFrameUpdate() override { 23 void StartFrameUpdate() override {
31 num_frames_++; 24 num_frames_++;
32 if (send_client_update_during_frame_) { 25 if (send_client_update_during_frame_) {
33 scheduler_.DidSendFrameUpdateToClient(); 26 scheduler_.DidSendFrameUpdateToClient();
34 send_client_update_during_frame_ = false; 27 send_client_update_during_frame_ = false;
35 } 28 }
36 } 29 }
37 30
38 protected: 31 protected:
39 base::MessageLoop loop_; 32 base::MessageLoop loop_;
40 FrameSchedulerForTesting scheduler_; 33 FrameScheduler scheduler_;
41 int num_frames_ = 0; 34 int num_frames_ = 0;
42 35
43 bool send_client_update_during_frame_ = false; 36 bool send_client_update_during_frame_ = false;
44 }; 37 };
45 38
46 TEST_F(FrameSchedulerTest, FirstMainFrameRequest) { 39 TEST_F(FrameSchedulerTest, FirstMainFrameRequest) {
47 // The request for the first main frame should be responded to right away. 40 // The request for the first main frame should be responded to right away.
48 scheduler_.ScheduleFrameUpdate(); 41 scheduler_.ScheduleFrameUpdate();
49 base::RunLoop().RunUntilIdle(); 42 base::RunLoop().RunUntilIdle();
50 EXPECT_EQ(1, num_frames_); 43 EXPECT_EQ(1, num_frames_);
(...skipping 22 matching lines...) Expand all
73 66
74 // Now we have an ack from the client. This should start another frame. 67 // Now we have an ack from the client. This should start another frame.
75 scheduler_.DidReceiveFrameUpdateAck(); 68 scheduler_.DidReceiveFrameUpdateAck();
76 base::RunLoop().RunUntilIdle(); 69 base::RunLoop().RunUntilIdle();
77 EXPECT_EQ(2, num_frames_); 70 EXPECT_EQ(2, num_frames_);
78 } 71 }
79 72
80 } // namespace 73 } // namespace
81 } // namespace engine 74 } // namespace engine
82 } // namespace blimp 75 } // namespace blimp
OLDNEW
« no previous file with comments | « blimp/engine/renderer/frame_scheduler.cc ('k') | cc/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698