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

Unified Diff: mojo/system/test_utils.h

Issue 281893002: Mojo: Base our epsilon timeouts off of TestTimeouts::tiny_timeout(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/system/simple_dispatcher_unittest.cc ('k') | mojo/system/test_utils.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/system/test_utils.h
diff --git a/mojo/system/test_utils.h b/mojo/system/test_utils.h
index 469edaf25833d65af85f1450893d33e58656b15f..c1a1a1e0b47d31d073d92a7d859845f1ba809197 100644
--- a/mojo/system/test_utils.h
+++ b/mojo/system/test_utils.h
@@ -23,6 +23,22 @@ namespace mojo {
namespace system {
namespace test {
+// Posts the given task (to the given task runner) and waits for it to complete.
+// (Note: Doesn't spin the current thread's message loop, so if you're careless
+// this could easily deadlock.)
+void PostTaskAndWait(scoped_refptr<base::TaskRunner> task_runner,
+ const tracked_objects::Location& from_here,
+ const base::Closure& task);
+
+// A timeout smaller than |TestTimeouts::tiny_timeout()|. Warning: This may lead
+// to flakiness, but this is unavoidable if, e.g., you're trying to ensure that
+// functions with timeouts are reasonably accurate. We want this to be as small
+// as possible without causing too much flakiness.
+base::TimeDelta EpsilonTimeout();
+
+// Stopwatch -------------------------------------------------------------------
+
+// A simple "stopwatch" for measuring time elapsed from a given starting point.
class Stopwatch {
public:
Stopwatch() {}
@@ -32,8 +48,8 @@ class Stopwatch {
start_time_ = base::TimeTicks::HighResNow();
}
- int64_t Elapsed() {
- return (base::TimeTicks::HighResNow() - start_time_).InMicroseconds();
+ base::TimeDelta Elapsed() {
+ return base::TimeTicks::HighResNow() - start_time_;
}
private:
@@ -42,13 +58,6 @@ class Stopwatch {
DISALLOW_COPY_AND_ASSIGN(Stopwatch);
};
-// Posts the given task (to the given task runner) and waits for it to complete.
-// (Note: Doesn't spin the current thread's message loop, so if you're careless
-// this could easily deadlock.)
-void PostTaskAndWait(scoped_refptr<base::TaskRunner> task_runner,
- const tracked_objects::Location& from_here,
- const base::Closure& task);
-
// TestIOThread ----------------------------------------------------------------
class TestIOThread {
« no previous file with comments | « mojo/system/simple_dispatcher_unittest.cc ('k') | mojo/system/test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698