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

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

Issue 387493002: Fixing and enhancing OrderedSimpleTaskRunner to allow 100% deterministic tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixes for Brian's comments. Created 6 years, 3 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
« no previous file with comments | « cc/test/scheduler_test_common.cc ('k') | cc/test/test_now_source.cc » ('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 2014 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 #ifndef CC_TEST_TEST_NOW_SOURCE_H_
6 #define CC_TEST_TEST_NOW_SOURCE_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11 #include "base/debug/trace_event.h"
12 #include "base/debug/trace_event_argument.h"
13 #include "base/logging.h"
14
15 namespace cc {
16
17 class TestNowSource : public base::RefCounted<TestNowSource> {
18 public:
19 static scoped_refptr<TestNowSource> Create();
20 static scoped_refptr<TestNowSource> Create(int64_t initial);
21 static scoped_refptr<TestNowSource> Create(base::TimeTicks initial);
22
23 virtual void Reset();
24 virtual base::TimeTicks Now() const;
25 virtual void SetNow(base::TimeTicks time);
26 virtual void AdvanceNow(base::TimeDelta period);
27
28 // Convenience functions to make it the now source easier to use in unit
29 // tests.
30 void AdvanceNowMicroseconds(int64_t period_in_microseconds);
31 void SetNowMicroseconds(int64_t time_in_microseconds);
32
33 static const base::TimeTicks kAbsoluteMaxNow;
34
35 // Tracing functions
36 scoped_refptr<base::debug::ConvertableToTraceFormat> AsValue() const;
37 void AsValueInto(base::debug::TracedValue* state) const;
38 std::string ToString() const;
39
40 protected:
41 TestNowSource();
42 explicit TestNowSource(int64_t initial);
43 explicit TestNowSource(base::TimeTicks initial);
44
45 base::TimeTicks initial_;
46 base::TimeTicks now_;
47
48 private:
49 friend class base::RefCounted<TestNowSource>;
50 virtual ~TestNowSource();
51 };
52
53 // gtest pretty printing functions
54 void PrintTo(const scoped_refptr<TestNowSource>& src, ::std::ostream* os);
55 ::std::ostream& operator<<(::std::ostream& os,
56 const scoped_refptr<TestNowSource>& src);
57
58 } // namespace cc
59
60 #endif // CC_TEST_TEST_NOW_SOURCE_H_
OLDNEW
« no previous file with comments | « cc/test/scheduler_test_common.cc ('k') | cc/test/test_now_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698