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

Side by Side Diff: cc/scheduler/frame_rate_controller_unittest.cc

Issue 221833009: cc: Move scheduling logic out of OutputSurface (Closed) Base URL: http://git.chromium.org/chromium/src.git@swapAck2Sched11
Patch Set: rebase; add comment about race Created 6 years, 8 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 | « cc/scheduler/frame_rate_controller.cc ('k') | cc/scheduler/scheduler.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 2011 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 "cc/scheduler/frame_rate_controller.h"
6
7 #include "base/test/test_simple_task_runner.h"
8 #include "cc/test/scheduler_test_common.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 namespace cc {
12 namespace {
13
14 class FakeFrameRateControllerClient : public FrameRateControllerClient {
15 public:
16 FakeFrameRateControllerClient() { Reset(); }
17
18 void Reset() { frame_count_ = 0; }
19 bool BeganFrame() const { return frame_count_ > 0; }
20 int frame_count() const { return frame_count_; }
21
22 virtual void FrameRateControllerTick(const BeginFrameArgs& args) OVERRIDE {
23 frame_count_ += 1;
24 }
25
26 protected:
27 int frame_count_;
28 };
29
30 TEST(FrameRateControllerTest, TestFrameThrottling_ImmediateAck) {
31 scoped_refptr<base::TestSimpleTaskRunner> task_runner =
32 new base::TestSimpleTaskRunner;
33 FakeFrameRateControllerClient client;
34 base::TimeDelta interval = base::TimeDelta::FromMicroseconds(
35 base::Time::kMicrosecondsPerSecond / 60);
36 scoped_refptr<FakeDelayBasedTimeSource> time_source =
37 FakeDelayBasedTimeSource::Create(interval, task_runner.get());
38 FrameRateController controller(time_source);
39
40 controller.SetClient(&client);
41 controller.SetActive(true);
42
43 base::TimeTicks elapsed; // Muck around with time a bit
44
45 // Trigger one frame, make sure the BeginFrame callback is called
46 elapsed += task_runner->NextPendingTaskDelay();
47 time_source->SetNow(elapsed);
48 task_runner->RunPendingTasks();
49 EXPECT_TRUE(client.BeganFrame());
50 client.Reset();
51
52 // Trigger another frame, make sure BeginFrame runs again
53 elapsed += task_runner->NextPendingTaskDelay();
54 // Sanity check that previous code didn't move time backward.
55 EXPECT_GE(elapsed, time_source->Now());
56 time_source->SetNow(elapsed);
57 task_runner->RunPendingTasks();
58 EXPECT_TRUE(client.BeganFrame());
59 }
60
61 } // namespace
62 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scheduler/frame_rate_controller.cc ('k') | cc/scheduler/scheduler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698