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/system/simple_dispatcher.h" | 10 #include "mojo/system/simple_dispatcher.h" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 lock().AssertAcquired(); | 80 lock().AssertAcquired(); |
81 return state_; | 81 return state_; |
82 } | 82 } |
83 | 83 |
84 // Protected by |lock()|: | 84 // Protected by |lock()|: |
85 HandleSignalsState state_; | 85 HandleSignalsState state_; |
86 | 86 |
87 DISALLOW_COPY_AND_ASSIGN(MockSimpleDispatcher); | 87 DISALLOW_COPY_AND_ASSIGN(MockSimpleDispatcher); |
88 }; | 88 }; |
89 | 89 |
90 TEST(SimpleDispatcherTest, Basic) { | 90 #if defined(OS_WIN) |
| 91 // http://crbug.com/396404 |
| 92 #define MAYBE_Basic DISABLED_Basic |
| 93 #else |
| 94 #define MAYBE_Basic Basic |
| 95 #endif |
| 96 TEST(SimpleDispatcherTest, MAYBE_Basic) { |
91 test::Stopwatch stopwatch; | 97 test::Stopwatch stopwatch; |
92 | 98 |
93 scoped_refptr<MockSimpleDispatcher> d(new MockSimpleDispatcher()); | 99 scoped_refptr<MockSimpleDispatcher> d(new MockSimpleDispatcher()); |
94 Waiter w; | 100 Waiter w; |
95 uint32_t context = 0; | 101 uint32_t context = 0; |
96 | 102 |
97 // Try adding a readable waiter when already readable. | 103 // Try adding a readable waiter when already readable. |
98 w.Init(); | 104 w.Init(); |
99 d->SetSatisfiedSignals(MOJO_HANDLE_SIGNAL_READABLE); | 105 d->SetSatisfiedSignals(MOJO_HANDLE_SIGNAL_READABLE); |
100 EXPECT_EQ(MOJO_RESULT_ALREADY_EXISTS, | 106 EXPECT_EQ(MOJO_RESULT_ALREADY_EXISTS, |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 ASSERT_EQ(MOJO_RESULT_OK, d->AddWaiter(&w, MOJO_HANDLE_SIGNAL_WRITABLE, 4)); | 267 ASSERT_EQ(MOJO_RESULT_OK, d->AddWaiter(&w, MOJO_HANDLE_SIGNAL_WRITABLE, 4)); |
262 EXPECT_EQ(MOJO_RESULT_OK, d->Close()); | 268 EXPECT_EQ(MOJO_RESULT_OK, d->Close()); |
263 stopwatch.Start(); | 269 stopwatch.Start(); |
264 EXPECT_EQ(MOJO_RESULT_CANCELLED, | 270 EXPECT_EQ(MOJO_RESULT_CANCELLED, |
265 w.Wait(2 * test::EpsilonTimeout().InMicroseconds(), &context)); | 271 w.Wait(2 * test::EpsilonTimeout().InMicroseconds(), &context)); |
266 EXPECT_LT(stopwatch.Elapsed(), test::EpsilonTimeout()); | 272 EXPECT_LT(stopwatch.Elapsed(), test::EpsilonTimeout()); |
267 EXPECT_EQ(4u, context); | 273 EXPECT_EQ(4u, context); |
268 // Don't need to remove waiters from closed dispatchers. | 274 // Don't need to remove waiters from closed dispatchers. |
269 } | 275 } |
270 | 276 |
271 TEST(SimpleDispatcherTest, BasicThreaded) { | 277 #if defined(OS_WIN) |
| 278 // http://crbug.com/396393 |
| 279 #define MAYBE_BasicThreaded DISABLED_BasicThreaded |
| 280 #else |
| 281 #define MAYBE_BasicThreaded BasicThreaded |
| 282 #endif |
| 283 TEST(SimpleDispatcherTest, MAYBE_BasicThreaded) { |
272 test::Stopwatch stopwatch; | 284 test::Stopwatch stopwatch; |
273 bool did_wait; | 285 bool did_wait; |
274 MojoResult result; | 286 MojoResult result; |
275 uint32_t context; | 287 uint32_t context; |
276 | 288 |
277 // Wait for readable (already readable). | 289 // Wait for readable (already readable). |
278 { | 290 { |
279 scoped_refptr<MockSimpleDispatcher> d(new MockSimpleDispatcher()); | 291 scoped_refptr<MockSimpleDispatcher> d(new MockSimpleDispatcher()); |
280 { | 292 { |
281 d->SetSatisfiedSignals(MOJO_HANDLE_SIGNAL_READABLE); | 293 d->SetSatisfiedSignals(MOJO_HANDLE_SIGNAL_READABLE); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 // If we closed earlier, then probably we'd get a |MOJO_RESULT_CANCELLED|. | 386 // If we closed earlier, then probably we'd get a |MOJO_RESULT_CANCELLED|. |
375 EXPECT_EQ(MOJO_RESULT_OK, d->Close()); | 387 EXPECT_EQ(MOJO_RESULT_OK, d->Close()); |
376 } | 388 } |
377 elapsed = stopwatch.Elapsed(); | 389 elapsed = stopwatch.Elapsed(); |
378 EXPECT_GT(elapsed, (2-1) * test::EpsilonTimeout()); | 390 EXPECT_GT(elapsed, (2-1) * test::EpsilonTimeout()); |
379 EXPECT_LT(elapsed, (2+1) * test::EpsilonTimeout()); | 391 EXPECT_LT(elapsed, (2+1) * test::EpsilonTimeout()); |
380 EXPECT_TRUE(did_wait); | 392 EXPECT_TRUE(did_wait); |
381 EXPECT_EQ(MOJO_RESULT_DEADLINE_EXCEEDED, result); | 393 EXPECT_EQ(MOJO_RESULT_DEADLINE_EXCEEDED, result); |
382 } | 394 } |
383 | 395 |
384 TEST(SimpleDispatcherTest, MultipleWaiters) { | 396 #if defined(OS_WIN) |
| 397 // http://crbug.com/387124 |
| 398 #define MAYBE_MultipleWaiters DISABLED_MultipleWaiters |
| 399 #else |
| 400 #define MAYBE_MultipleWaiters MultipleWaiters |
| 401 #endif |
| 402 TEST(SimpleDispatcherTest, MAYBE_MultipleWaiters) { |
385 static const uint32_t kNumWaiters = 20; | 403 static const uint32_t kNumWaiters = 20; |
386 | 404 |
387 bool did_wait[kNumWaiters]; | 405 bool did_wait[kNumWaiters]; |
388 MojoResult result[kNumWaiters]; | 406 MojoResult result[kNumWaiters]; |
389 uint32_t context[kNumWaiters]; | 407 uint32_t context[kNumWaiters]; |
390 | 408 |
391 // All wait for readable and becomes readable after some time. | 409 // All wait for readable and becomes readable after some time. |
392 { | 410 { |
393 scoped_refptr<MockSimpleDispatcher> d(new MockSimpleDispatcher()); | 411 scoped_refptr<MockSimpleDispatcher> d(new MockSimpleDispatcher()); |
394 ScopedVector<test::WaiterThread> threads; | 412 ScopedVector<test::WaiterThread> threads; |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 EXPECT_TRUE(did_wait[i]); | 550 EXPECT_TRUE(did_wait[i]); |
533 EXPECT_EQ(MOJO_RESULT_DEADLINE_EXCEEDED, result[i]); | 551 EXPECT_EQ(MOJO_RESULT_DEADLINE_EXCEEDED, result[i]); |
534 } | 552 } |
535 } | 553 } |
536 | 554 |
537 // TODO(vtl): Stress test? | 555 // TODO(vtl): Stress test? |
538 | 556 |
539 } // namespace | 557 } // namespace |
540 } // namespace system | 558 } // namespace system |
541 } // namespace mojo | 559 } // namespace mojo |
OLD | NEW |