Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(408)

Side by Side Diff: mojo/edk/system/simple_dispatcher_unittest.cc

Issue 1352913002: Remove Windows support from the EDK. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « mojo/edk/system/remote_message_pipe_unittest.cc ('k') | mojo/edk/system/test_utils.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/simple_dispatcher.h" 10 #include "mojo/edk/system/simple_dispatcher.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 HandleSignalsState GetHandleSignalsStateImplNoLock() const override { 75 HandleSignalsState GetHandleSignalsStateImplNoLock() const override {
76 mutex().AssertHeld(); 76 mutex().AssertHeld();
77 return state_; 77 return state_;
78 } 78 }
79 79
80 HandleSignalsState state_ MOJO_GUARDED_BY(mutex()); 80 HandleSignalsState state_ MOJO_GUARDED_BY(mutex());
81 81
82 MOJO_DISALLOW_COPY_AND_ASSIGN(MockSimpleDispatcher); 82 MOJO_DISALLOW_COPY_AND_ASSIGN(MockSimpleDispatcher);
83 }; 83 };
84 84
85 #if defined(OS_WIN) 85 TEST(SimpleDispatcherTest, Basic) {
86 // http://crbug.com/396404
87 #define MAYBE_Basic DISABLED_Basic
88 #else
89 #define MAYBE_Basic Basic
90 #endif
91 TEST(SimpleDispatcherTest, MAYBE_Basic) {
92 test::Stopwatch stopwatch; 86 test::Stopwatch stopwatch;
93 87
94 scoped_refptr<MockSimpleDispatcher> d(new MockSimpleDispatcher()); 88 scoped_refptr<MockSimpleDispatcher> d(new MockSimpleDispatcher());
95 Waiter w; 89 Waiter w;
96 uint32_t context = 0; 90 uint32_t context = 0;
97 HandleSignalsState hss; 91 HandleSignalsState hss;
98 92
99 // Try adding a readable waiter when already readable. 93 // Try adding a readable waiter when already readable.
100 w.Init(); 94 w.Init();
101 d->SetSatisfiedSignals(MOJO_HANDLE_SIGNAL_READABLE); 95 d->SetSatisfiedSignals(MOJO_HANDLE_SIGNAL_READABLE);
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 d->AddAwakable(&w, MOJO_HANDLE_SIGNAL_WRITABLE, 4, nullptr)); 308 d->AddAwakable(&w, MOJO_HANDLE_SIGNAL_WRITABLE, 4, nullptr));
315 EXPECT_EQ(MOJO_RESULT_OK, d->Close()); 309 EXPECT_EQ(MOJO_RESULT_OK, d->Close());
316 stopwatch.Start(); 310 stopwatch.Start();
317 EXPECT_EQ(MOJO_RESULT_CANCELLED, 311 EXPECT_EQ(MOJO_RESULT_CANCELLED,
318 w.Wait(2 * test::EpsilonDeadline(), &context)); 312 w.Wait(2 * test::EpsilonDeadline(), &context));
319 EXPECT_LT(stopwatch.Elapsed(), test::EpsilonDeadline()); 313 EXPECT_LT(stopwatch.Elapsed(), test::EpsilonDeadline());
320 EXPECT_EQ(4u, context); 314 EXPECT_EQ(4u, context);
321 // Don't need to remove waiters from closed dispatchers. 315 // Don't need to remove waiters from closed dispatchers.
322 } 316 }
323 317
324 #if defined(OS_WIN) 318 TEST(SimpleDispatcherTest, BasicThreaded) {
325 // http://crbug.com/396393
326 #define MAYBE_BasicThreaded DISABLED_BasicThreaded
327 #else
328 #define MAYBE_BasicThreaded BasicThreaded
329 #endif
330 TEST(SimpleDispatcherTest, MAYBE_BasicThreaded) {
331 test::Stopwatch stopwatch; 319 test::Stopwatch stopwatch;
332 bool did_wait; 320 bool did_wait;
333 MojoResult result; 321 MojoResult result;
334 uint32_t context; 322 uint32_t context;
335 HandleSignalsState hss; 323 HandleSignalsState hss;
336 324
337 // Wait for readable (already readable). 325 // Wait for readable (already readable).
338 { 326 {
339 scoped_refptr<MockSimpleDispatcher> d(new MockSimpleDispatcher()); 327 scoped_refptr<MockSimpleDispatcher> d(new MockSimpleDispatcher());
340 { 328 {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 elapsed = stopwatch.Elapsed(); 429 elapsed = stopwatch.Elapsed();
442 EXPECT_GT(elapsed, (2 - 1) * test::EpsilonDeadline()); 430 EXPECT_GT(elapsed, (2 - 1) * test::EpsilonDeadline());
443 EXPECT_LT(elapsed, (2 + 1) * test::EpsilonDeadline()); 431 EXPECT_LT(elapsed, (2 + 1) * test::EpsilonDeadline());
444 EXPECT_TRUE(did_wait); 432 EXPECT_TRUE(did_wait);
445 EXPECT_EQ(MOJO_RESULT_DEADLINE_EXCEEDED, result); 433 EXPECT_EQ(MOJO_RESULT_DEADLINE_EXCEEDED, result);
446 EXPECT_EQ(MOJO_HANDLE_SIGNAL_WRITABLE, hss.satisfied_signals); 434 EXPECT_EQ(MOJO_HANDLE_SIGNAL_WRITABLE, hss.satisfied_signals);
447 EXPECT_EQ(MOJO_HANDLE_SIGNAL_READABLE | MOJO_HANDLE_SIGNAL_WRITABLE, 435 EXPECT_EQ(MOJO_HANDLE_SIGNAL_READABLE | MOJO_HANDLE_SIGNAL_WRITABLE,
448 hss.satisfiable_signals); 436 hss.satisfiable_signals);
449 } 437 }
450 438
451 #if defined(OS_WIN) 439 TEST(SimpleDispatcherTest, MultipleWaiters) {
452 // http://crbug.com/387124
453 #define MAYBE_MultipleWaiters DISABLED_MultipleWaiters
454 #else
455 #define MAYBE_MultipleWaiters MultipleWaiters
456 #endif
457 TEST(SimpleDispatcherTest, MAYBE_MultipleWaiters) {
458 static const uint32_t kNumWaiters = 20; 440 static const uint32_t kNumWaiters = 20;
459 441
460 bool did_wait[kNumWaiters]; 442 bool did_wait[kNumWaiters];
461 MojoResult result[kNumWaiters]; 443 MojoResult result[kNumWaiters];
462 uint32_t context[kNumWaiters]; 444 uint32_t context[kNumWaiters];
463 HandleSignalsState hss[kNumWaiters]; 445 HandleSignalsState hss[kNumWaiters];
464 446
465 // All wait for readable and becomes readable after some time. 447 // All wait for readable and becomes readable after some time.
466 { 448 {
467 scoped_refptr<MockSimpleDispatcher> d(new MockSimpleDispatcher()); 449 scoped_refptr<MockSimpleDispatcher> d(new MockSimpleDispatcher());
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 // Since we closed before joining, we can't say much about what each thread 576 // Since we closed before joining, we can't say much about what each thread
595 // saw as the state. 577 // saw as the state.
596 } 578 }
597 } 579 }
598 580
599 // TODO(vtl): Stress test? 581 // TODO(vtl): Stress test?
600 582
601 } // namespace 583 } // namespace
602 } // namespace system 584 } // namespace system
603 } // namespace mojo 585 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/remote_message_pipe_unittest.cc ('k') | mojo/edk/system/test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698