OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "base/synchronization/waitable_event_watcher.h" | 5 #include "base/synchronization/waitable_event_watcher.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 }; | 45 }; |
46 | 46 |
47 void RunTest_BasicSignal(MessageLoop::Type message_loop_type) { | 47 void RunTest_BasicSignal(MessageLoop::Type message_loop_type) { |
48 MessageLoop message_loop(message_loop_type); | 48 MessageLoop message_loop(message_loop_type); |
49 | 49 |
50 // A manual-reset event that is not yet signaled. | 50 // A manual-reset event that is not yet signaled. |
51 WaitableEvent event(WaitableEvent::ResetPolicy::MANUAL, | 51 WaitableEvent event(WaitableEvent::ResetPolicy::MANUAL, |
52 WaitableEvent::InitialState::NOT_SIGNALED); | 52 WaitableEvent::InitialState::NOT_SIGNALED); |
53 | 53 |
54 WaitableEventWatcher watcher; | 54 WaitableEventWatcher watcher; |
55 EXPECT_TRUE(watcher.GetWatchedEvent() == NULL); | |
56 | |
57 watcher.StartWatching(&event, Bind(&QuitWhenSignaled)); | 55 watcher.StartWatching(&event, Bind(&QuitWhenSignaled)); |
58 EXPECT_EQ(&event, watcher.GetWatchedEvent()); | |
59 | 56 |
60 event.Signal(); | 57 event.Signal(); |
61 | 58 |
62 RunLoop().Run(); | 59 RunLoop().Run(); |
63 | |
64 EXPECT_TRUE(watcher.GetWatchedEvent() == NULL); | |
65 } | 60 } |
66 | 61 |
67 void RunTest_BasicCancel(MessageLoop::Type message_loop_type) { | 62 void RunTest_BasicCancel(MessageLoop::Type message_loop_type) { |
68 MessageLoop message_loop(message_loop_type); | 63 MessageLoop message_loop(message_loop_type); |
69 | 64 |
70 // A manual-reset event that is not yet signaled. | 65 // A manual-reset event that is not yet signaled. |
71 WaitableEvent event(WaitableEvent::ResetPolicy::MANUAL, | 66 WaitableEvent event(WaitableEvent::ResetPolicy::MANUAL, |
72 WaitableEvent::InitialState::NOT_SIGNALED); | 67 WaitableEvent::InitialState::NOT_SIGNALED); |
73 | 68 |
74 WaitableEventWatcher watcher; | 69 WaitableEventWatcher watcher; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 } | 164 } |
170 } | 165 } |
171 | 166 |
172 TEST(WaitableEventWatcherTest, DeleteUnder) { | 167 TEST(WaitableEventWatcherTest, DeleteUnder) { |
173 for (int i = 0; i < kNumTestingMessageLoops; i++) { | 168 for (int i = 0; i < kNumTestingMessageLoops; i++) { |
174 RunTest_DeleteUnder(testing_message_loops[i]); | 169 RunTest_DeleteUnder(testing_message_loops[i]); |
175 } | 170 } |
176 } | 171 } |
177 | 172 |
178 } // namespace base | 173 } // namespace base |
OLD | NEW |