| 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. |kEpsilonMicros| may be increased to increase | 6 // heavily-loaded system). Sorry. |kEpsilonMicros| may be increased to increase |
| 7 // tolerance and reduce observed flakiness. | 7 // tolerance and reduce observed flakiness. |
| 8 | 8 |
| 9 #include "mojo/system/simple_dispatcher.h" | 9 #include "mojo/system/simple_dispatcher.h" |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
| 15 #include "base/synchronization/lock.h" | 15 #include "base/synchronization/lock.h" |
| 16 #include "base/threading/platform_thread.h" // For |Sleep()|. | 16 #include "base/threading/platform_thread.h" // For |Sleep()|. |
| 17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
| 18 #include "mojo/system/test_utils.h" | 18 #include "mojo/system/test_utils.h" |
| 19 #include "mojo/system/waiter.h" | 19 #include "mojo/system/waiter.h" |
| 20 #include "mojo/system/waiter_test_utils.h" | 20 #include "mojo/system/waiter_test_utils.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
| 22 | 22 |
| 23 namespace mojo { | 23 namespace mojo { |
| 24 namespace system { | 24 namespace system { |
| 25 namespace { | 25 namespace { |
| 26 | 26 |
| 27 const int64_t kMicrosPerMs = 1000; | 27 const int64_t kMicrosPerMs = 1000; |
| 28 const int64_t kEpsilonMicros = 15 * kMicrosPerMs; // 15 ms. | 28 const int64_t kEpsilonMicros = 30 * kMicrosPerMs; // 30 ms. |
| 29 | 29 |
| 30 class MockSimpleDispatcher : public SimpleDispatcher { | 30 class MockSimpleDispatcher : public SimpleDispatcher { |
| 31 public: | 31 public: |
| 32 MockSimpleDispatcher() | 32 MockSimpleDispatcher() |
| 33 : satisfied_flags_(MOJO_WAIT_FLAG_NONE), | 33 : satisfied_flags_(MOJO_WAIT_FLAG_NONE), |
| 34 satisfiable_flags_(MOJO_WAIT_FLAG_READABLE | MOJO_WAIT_FLAG_WRITABLE) {} | 34 satisfiable_flags_(MOJO_WAIT_FLAG_READABLE | MOJO_WAIT_FLAG_WRITABLE) {} |
| 35 | 35 |
| 36 void SetSatisfiedFlags(MojoWaitFlags new_satisfied_flags) { | 36 void SetSatisfiedFlags(MojoWaitFlags new_satisfied_flags) { |
| 37 base::AutoLock locker(lock()); | 37 base::AutoLock locker(lock()); |
| 38 | 38 |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 EXPECT_TRUE(did_wait[i]); | 517 EXPECT_TRUE(did_wait[i]); |
| 518 EXPECT_EQ(MOJO_RESULT_DEADLINE_EXCEEDED, result[i]); | 518 EXPECT_EQ(MOJO_RESULT_DEADLINE_EXCEEDED, result[i]); |
| 519 } | 519 } |
| 520 } | 520 } |
| 521 | 521 |
| 522 // TODO(vtl): Stress test? | 522 // TODO(vtl): Stress test? |
| 523 | 523 |
| 524 } // namespace | 524 } // namespace |
| 525 } // namespace system | 525 } // namespace system |
| 526 } // namespace mojo | 526 } // namespace mojo |
| OLD | NEW |