| 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::EpsilonDeadline()| may be increased to | 6 // heavily-loaded system). Sorry. |test::EpsilonDeadline()| 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" |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 | 78 |
| 79 const MojoDeadline deadline_; | 79 const MojoDeadline deadline_; |
| 80 Waiter waiter_; // Thread-safe. | 80 Waiter waiter_; // Thread-safe. |
| 81 | 81 |
| 82 base::Lock lock_; // Protects the following members. | 82 base::Lock lock_; // Protects the following members. |
| 83 bool done_; | 83 bool done_; |
| 84 MojoResult result_; | 84 MojoResult result_; |
| 85 uintptr_t context_; | 85 uintptr_t context_; |
| 86 MojoDeadline elapsed_; | 86 MojoDeadline elapsed_; |
| 87 | 87 |
| 88 MOJO_DISALLOW_COPY_AND_ASSIGN(WaitingThread); | 88 DISALLOW_COPY_AND_ASSIGN(WaitingThread); |
| 89 }; | 89 }; |
| 90 | 90 |
| 91 TEST(WaiterTest, Basic) { | 91 TEST(WaiterTest, Basic) { |
| 92 MojoResult result; | 92 MojoResult result; |
| 93 uintptr_t context; | 93 uintptr_t context; |
| 94 MojoDeadline elapsed; | 94 MojoDeadline elapsed; |
| 95 | 95 |
| 96 // Finite deadline. | 96 // Finite deadline. |
| 97 | 97 |
| 98 // Awake immediately after thread start. | 98 // Awake immediately after thread start. |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, result); | 289 EXPECT_EQ(MOJO_RESULT_FAILED_PRECONDITION, result); |
| 290 EXPECT_EQ(7u, context); | 290 EXPECT_EQ(7u, context); |
| 291 EXPECT_GT(elapsed, (1 - 1) * test::EpsilonDeadline()); | 291 EXPECT_GT(elapsed, (1 - 1) * test::EpsilonDeadline()); |
| 292 EXPECT_LT(elapsed, (1 + 1) * test::EpsilonDeadline()); | 292 EXPECT_LT(elapsed, (1 + 1) * test::EpsilonDeadline()); |
| 293 } | 293 } |
| 294 } | 294 } |
| 295 | 295 |
| 296 } // namespace | 296 } // namespace |
| 297 } // namespace edk | 297 } // namespace edk |
| 298 } // namespace mojo | 298 } // namespace mojo |
| OLD | NEW |