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

Side by Side Diff: mojo/system/test_utils.h

Issue 621153003: Move mojo edk into mojo/edk (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix checkdeps Created 6 years, 2 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 | « mojo/system/system_impl_export.h ('k') | mojo/system/test_utils.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 2013 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 MOJO_SYSTEM_TEST_UTILS_H_
6 #define MOJO_SYSTEM_TEST_UTILS_H_
7
8 #include <stdint.h>
9
10 #include "base/callback_forward.h"
11 #include "base/compiler_specific.h"
12 #include "base/macros.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/task_runner.h"
15 #include "base/threading/thread.h"
16 #include "base/time/time.h"
17
18 namespace tracked_objects {
19 class Location;
20 }
21
22 namespace mojo {
23 namespace system {
24 namespace test {
25
26 // Posts the given task (to the given task runner) and waits for it to complete.
27 // (Note: Doesn't spin the current thread's message loop, so if you're careless
28 // this could easily deadlock.)
29 void PostTaskAndWait(scoped_refptr<base::TaskRunner> task_runner,
30 const tracked_objects::Location& from_here,
31 const base::Closure& task);
32
33 // A timeout smaller than |TestTimeouts::tiny_timeout()|. Warning: This may lead
34 // to flakiness, but this is unavoidable if, e.g., you're trying to ensure that
35 // functions with timeouts are reasonably accurate. We want this to be as small
36 // as possible without causing too much flakiness.
37 base::TimeDelta EpsilonTimeout();
38
39 // Stopwatch -------------------------------------------------------------------
40
41 // A simple "stopwatch" for measuring time elapsed from a given starting point.
42 class Stopwatch {
43 public:
44 Stopwatch() {}
45 ~Stopwatch() {}
46
47 void Start() { start_time_ = base::TimeTicks::Now(); }
48
49 base::TimeDelta Elapsed() { return base::TimeTicks::Now() - start_time_; }
50
51 private:
52 base::TimeTicks start_time_;
53
54 DISALLOW_COPY_AND_ASSIGN(Stopwatch);
55 };
56
57 } // namespace test
58 } // namespace system
59 } // namespace mojo
60
61 #endif // MOJO_SYSTEM_TEST_UTILS_H_
OLDNEW
« no previous file with comments | « mojo/system/system_impl_export.h ('k') | mojo/system/test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698