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

Side by Side Diff: cc/test/ordered_simple_task_runner.h

Issue 387493002: Fixing and enhancing OrderedSimpleTaskRunner to allow 100% deterministic tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sprintf is hard. Created 6 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef CC_TEST_ORDERED_SIMPLE_TASK_RUNNER_H_ 5 #ifndef CC_TEST_ORDERED_SIMPLE_TASK_RUNNER_H_
6 #define CC_TEST_ORDERED_SIMPLE_TASK_RUNNER_H_ 6 #define CC_TEST_ORDERED_SIMPLE_TASK_RUNNER_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/logging.h"
10 #include "base/test/test_simple_task_runner.h" 11 #include "base/test/test_simple_task_runner.h"
11 12
12 namespace cc { 13 namespace cc {
13 14
14 // This runs pending tasks based on task's post_time + delay. 15 // This runs pending tasks based on task's post_time + delay.
15 // We should not execute a delayed task sooner than some of the queued tasks 16 // We should not execute a delayed task sooner than some of the queued tasks
16 // which don't have a delay even though it is queued early. 17 // which don't have a delay even though it is queued early.
17 class OrderedSimpleTaskRunner : public base::TestSimpleTaskRunner { 18 class OrderedSimpleTaskRunner : public base::TestSimpleTaskRunner {
18 public: 19 public:
19 OrderedSimpleTaskRunner(); 20 OrderedSimpleTaskRunner() : advance_now_(true), now_() {}
20 21
21 virtual void RunPendingTasks() OVERRIDE; 22 virtual void RunPendingTasks() OVERRIDE;
22 23
24 void SetAdvanceNow(bool advance_now) { advance_now_ = advance_now; }
Sami 2014/07/11 17:22:46 Looks like these should go into the .cc file.
brianderson 2014/07/14 23:42:31 Can you make the method name more descriptive? It
mithro-old 2014/07/16 14:18:12 I changed it to SetAutoAdvanceNowToPendingTasks bu
mithro-old 2014/07/16 14:18:12 Done.
25 void SetNow(base::TimeTicks time) {
26 DCHECK(time > now_);
27 now_ = time;
28 }
29 base::TimeTicks Now() { return now_; }
30
23 protected: 31 protected:
24 virtual ~OrderedSimpleTaskRunner(); 32 virtual ~OrderedSimpleTaskRunner();
25 33
26 private: 34 private:
35 bool advance_now_;
36 base::TimeTicks now_;
37
27 DISALLOW_COPY_AND_ASSIGN(OrderedSimpleTaskRunner); 38 DISALLOW_COPY_AND_ASSIGN(OrderedSimpleTaskRunner);
28 }; 39 };
29 40
30 } // namespace cc 41 } // namespace cc
31 42
32 #endif // CC_TEST_ORDERED_SIMPLE_TASK_RUNNER_H_ 43 #endif // CC_TEST_ORDERED_SIMPLE_TASK_RUNNER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698