| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 MOJO_EDK_SYSTEM_TEST_UTILS_H_ | 5 #ifndef MOJO_EDK_SYSTEM_TEST_UTILS_H_ |
| 6 #define MOJO_EDK_SYSTEM_TEST_UTILS_H_ | 6 #define MOJO_EDK_SYSTEM_TEST_UTILS_H_ |
| 7 | 7 |
| 8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
| 9 #include "mojo/public/c/system/types.h" | 9 #include "mojo/public/c/system/types.h" |
| 10 #include "mojo/public/cpp/system/macros.h" | 10 #include "mojo/public/cpp/system/macros.h" |
| 11 | 11 |
| 12 namespace mojo { | 12 namespace mojo { |
| 13 namespace system { | 13 namespace system { |
| 14 namespace test { | 14 namespace test { |
| 15 | 15 |
| 16 MojoDeadline DeadlineFromMilliseconds(unsigned milliseconds); | 16 MojoDeadline DeadlineFromMilliseconds(unsigned milliseconds); |
| 17 | 17 |
| 18 // A timeout smaller than |TestTimeouts::tiny_timeout()|, as a |MojoDeadline|. | 18 // A timeout smaller than |TestTimeouts::tiny_timeout()|, as a |MojoDeadline|. |
| 19 // Warning: This may lead to flakiness, but this is unavoidable if, e.g., you're | 19 // Warning: This may lead to flakiness, but this is unavoidable if, e.g., you're |
| 20 // trying to ensure that functions with timeouts are reasonably accurate. We | 20 // trying to ensure that functions with timeouts are reasonably accurate. We |
| 21 // want this to be as small as possible without causing too much flakiness. | 21 // want this to be as small as possible without causing too much flakiness. |
| 22 MojoDeadline EpsilonDeadline(); | 22 MojoDeadline EpsilonDeadline(); |
| 23 | 23 |
| 24 // |TestTimeouts::tiny_timeout()|, as a |MojoDeadline|. (Expect this to be on | 24 // |TestTimeouts::tiny_timeout()|, as a |MojoDeadline|. (Expect this to be on |
| 25 // the order of 100 ms.) | 25 // the order of 100 ms.) |
| 26 MojoDeadline TinyDeadline(); | 26 MojoDeadline TinyDeadline(); |
| 27 | 27 |
| 28 // |TestTimeouts::action_timeout()|, as a |MojoDeadline|. (Expect this to be on | 28 // |TestTimeouts::action_timeout()|, as a |MojoDeadline|.(Expect this to be on |
| 29 // the order of 10 s.) | 29 // the order of 10 s.) |
| 30 MojoDeadline ActionDeadline(); | 30 MojoDeadline ActionDeadline(); |
| 31 | 31 |
| 32 // Sleeps for at least the specified duration. | 32 // Sleeps for at least the specified duration. |
| 33 void Sleep(MojoDeadline deadline); | 33 void Sleep(MojoDeadline deadline); |
| 34 | 34 |
| 35 // Stopwatch ------------------------------------------------------------------- | 35 // Stopwatch ------------------------------------------------------------------- |
| 36 | 36 |
| 37 // A simple "stopwatch" for measuring time elapsed from a given starting point. | 37 // A simple "stopwatch" for measuring time elapsed from a given starting point. |
| 38 class Stopwatch { | 38 class Stopwatch { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 49 base::TimeTicks start_time_; | 49 base::TimeTicks start_time_; |
| 50 | 50 |
| 51 MOJO_DISALLOW_COPY_AND_ASSIGN(Stopwatch); | 51 MOJO_DISALLOW_COPY_AND_ASSIGN(Stopwatch); |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 } // namespace test | 54 } // namespace test |
| 55 } // namespace system | 55 } // namespace system |
| 56 } // namespace mojo | 56 } // namespace mojo |
| 57 | 57 |
| 58 #endif // MOJO_EDK_SYSTEM_TEST_UTILS_H_ | 58 #endif // MOJO_EDK_SYSTEM_TEST_UTILS_H_ |
| OLD | NEW |