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 // NOTE(vtl): Some of these tests are inherently flaky (e.g., if run on a | 5 // NOTE(vtl): Some of these tests are inherently flaky (e.g., if run on a |
6 // heavily-loaded system). Sorry. |test::EpsilonTimeout()| may be increased to | 6 // heavily-loaded system). Sorry. |test::EpsilonTimeout()| may be increased to |
7 // increase tolerance and reduce observed flakiness (though doing so reduces the | 7 // increase tolerance and reduce observed flakiness (though doing so reduces the |
8 // meaningfulness of the test). | 8 // meaningfulness of the test). |
9 | 9 |
10 #include "mojo/edk/system/waiter.h" | 10 #include "mojo/edk/system/waiter.h" |
11 | 11 |
12 #include <stdint.h> | 12 #include <stdint.h> |
13 | 13 |
14 #include "mojo/edk/system/mutex.h" | |
15 #include "mojo/edk/system/test/simple_test_thread.h" | 14 #include "mojo/edk/system/test/simple_test_thread.h" |
16 #include "mojo/edk/system/test/sleep.h" | 15 #include "mojo/edk/system/test/sleep.h" |
17 #include "mojo/edk/system/test/stopwatch.h" | 16 #include "mojo/edk/system/test/stopwatch.h" |
18 #include "mojo/edk/system/test/timeouts.h" | 17 #include "mojo/edk/system/test/timeouts.h" |
| 18 #include "mojo/edk/util/mutex.h" |
19 #include "mojo/public/cpp/system/macros.h" | 19 #include "mojo/public/cpp/system/macros.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
21 | 21 |
| 22 using mojo::util::Mutex; |
| 23 using mojo::util::MutexLocker; |
| 24 |
22 namespace mojo { | 25 namespace mojo { |
23 namespace system { | 26 namespace system { |
24 namespace { | 27 namespace { |
25 | 28 |
26 const unsigned kPollTimeMs = 10; | 29 const unsigned kPollTimeMs = 10; |
27 | 30 |
28 class WaitingThread : public test::SimpleTestThread { | 31 class WaitingThread : public test::SimpleTestThread { |
29 public: | 32 public: |
30 explicit WaitingThread(MojoDeadline deadline) | 33 explicit WaitingThread(MojoDeadline deadline) |
31 : deadline_(deadline), | 34 : deadline_(deadline), |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, result); | 293 EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, result); |
291 EXPECT_EQ(7u, context); | 294 EXPECT_EQ(7u, context); |
292 EXPECT_GT(elapsed, (1 - 1) * test::EpsilonTimeout()); | 295 EXPECT_GT(elapsed, (1 - 1) * test::EpsilonTimeout()); |
293 EXPECT_LT(elapsed, (1 + 1) * test::EpsilonTimeout()); | 296 EXPECT_LT(elapsed, (1 + 1) * test::EpsilonTimeout()); |
294 } | 297 } |
295 } | 298 } |
296 | 299 |
297 } // namespace | 300 } // namespace |
298 } // namespace system | 301 } // namespace system |
299 } // namespace mojo | 302 } // namespace mojo |
OLD | NEW |