| 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 THIRD_PARTY_MOJO_SRC_MOJO_EDK_SYSTEM_TEST_UTILS_H_ | 5 #ifndef MOJO_EDK_SYSTEM_TEST_UTILS_H_ |
| 6 #define THIRD_PARTY_MOJO_SRC_MOJO_EDK_SYSTEM_TEST_UTILS_H_ | 6 #define MOJO_EDK_SYSTEM_TEST_UTILS_H_ |
| 7 | 7 |
| 8 #include "base/test/test_io_thread.h" |
| 8 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "mojo/edk/test/scoped_ipc_support.h" |
| 9 #include "mojo/public/c/system/types.h" | 11 #include "mojo/public/c/system/types.h" |
| 10 #include "mojo/public/cpp/system/macros.h" | 12 #include "mojo/public/cpp/system/macros.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 14 |
| 12 namespace mojo { | 15 namespace mojo { |
| 13 namespace system { | 16 namespace edk { |
| 14 namespace test { | 17 namespace test { |
| 15 | 18 |
| 16 MojoDeadline DeadlineFromMilliseconds(unsigned milliseconds); | 19 MojoDeadline DeadlineFromMilliseconds(unsigned milliseconds); |
| 17 | 20 |
| 18 // A timeout smaller than |TestTimeouts::tiny_timeout()|, as a |MojoDeadline|. | 21 // 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 | 22 // 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 | 23 // 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. | 24 // want this to be as small as possible without causing too much flakiness. |
| 22 MojoDeadline EpsilonDeadline(); | 25 MojoDeadline EpsilonDeadline(); |
| 23 | 26 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 44 // Returns the amount of time elapsed since the last call to |Start()| (in | 47 // Returns the amount of time elapsed since the last call to |Start()| (in |
| 45 // microseconds). | 48 // microseconds). |
| 46 MojoDeadline Elapsed(); | 49 MojoDeadline Elapsed(); |
| 47 | 50 |
| 48 private: | 51 private: |
| 49 base::TimeTicks start_time_; | 52 base::TimeTicks start_time_; |
| 50 | 53 |
| 51 MOJO_DISALLOW_COPY_AND_ASSIGN(Stopwatch); | 54 MOJO_DISALLOW_COPY_AND_ASSIGN(Stopwatch); |
| 52 }; | 55 }; |
| 53 | 56 |
| 57 // A base class which initializes and shuts down the necessary objects so that |
| 58 // Mojo system calls can be made. |
| 59 class MojoSystemTest : public testing::Test { |
| 60 public: |
| 61 MojoSystemTest(); |
| 62 ~MojoSystemTest() override; |
| 63 |
| 64 base::TestIOThread* test_io_thread() { return &test_io_thread_; } |
| 65 |
| 66 private: |
| 67 base::MessageLoop message_loop_; |
| 68 base::TestIOThread test_io_thread_; |
| 69 test::ScopedIPCSupport ipc_support_; |
| 70 |
| 71 MOJO_DISALLOW_COPY_AND_ASSIGN(MojoSystemTest); |
| 72 }; |
| 73 |
| 54 } // namespace test | 74 } // namespace test |
| 55 } // namespace system | 75 } // namespace edk |
| 56 } // namespace mojo | 76 } // namespace mojo |
| 57 | 77 |
| 58 #endif // THIRD_PARTY_MOJO_SRC_MOJO_EDK_SYSTEM_TEST_UTILS_H_ | 78 #endif // MOJO_EDK_SYSTEM_TEST_UTILS_H_ |
| OLD | NEW |