OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/message_loop.h" | 5 #include "base/message_loop.h" |
6 #include "base/platform_thread.h" | 6 #include "base/platform_thread.h" |
7 #include "base/waitable_event.h" | 7 #include "base/waitable_event.h" |
8 #include "base/waitable_event_watcher.h" | 8 #include "base/waitable_event_watcher.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
11 using base::WaitableEvent; | 11 using base::WaitableEvent; |
(...skipping 19 matching lines...) Expand all Loading... |
31 int* counter_; | 31 int* counter_; |
32 }; | 32 }; |
33 | 33 |
34 void RunTest_BasicSignal(MessageLoop::Type message_loop_type) { | 34 void RunTest_BasicSignal(MessageLoop::Type message_loop_type) { |
35 MessageLoop message_loop(message_loop_type); | 35 MessageLoop message_loop(message_loop_type); |
36 | 36 |
37 // A manual-reset event that is not yet signaled. | 37 // A manual-reset event that is not yet signaled. |
38 WaitableEvent event(true, false); | 38 WaitableEvent event(true, false); |
39 | 39 |
40 WaitableEventWatcher watcher; | 40 WaitableEventWatcher watcher; |
41 EXPECT_TRUE(NULL == watcher.GetWatchedEvent()); | 41 EXPECT_EQ(NULL, watcher.GetWatchedEvent()); |
42 | 42 |
43 QuitDelegate delegate; | 43 QuitDelegate delegate; |
44 watcher.StartWatching(&event, &delegate); | 44 watcher.StartWatching(&event, &delegate); |
45 EXPECT_EQ(&event, watcher.GetWatchedEvent()); | 45 EXPECT_EQ(&event, watcher.GetWatchedEvent()); |
46 | 46 |
47 event.Signal(); | 47 event.Signal(); |
48 | 48 |
49 MessageLoop::current()->Run(); | 49 MessageLoop::current()->Run(); |
50 | 50 |
51 EXPECT_TRUE(NULL == watcher.GetWatchedEvent()); | 51 EXPECT_EQ(NULL, watcher.GetWatchedEvent()); |
52 } | 52 } |
53 | 53 |
54 void RunTest_BasicCancel(MessageLoop::Type message_loop_type) { | 54 void RunTest_BasicCancel(MessageLoop::Type message_loop_type) { |
55 MessageLoop message_loop(message_loop_type); | 55 MessageLoop message_loop(message_loop_type); |
56 | 56 |
57 // A manual-reset event that is not yet signaled. | 57 // A manual-reset event that is not yet signaled. |
58 WaitableEvent event(true, false); | 58 WaitableEvent event(true, false); |
59 | 59 |
60 WaitableEventWatcher watcher; | 60 WaitableEventWatcher watcher; |
61 | 61 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 RunTest_OutlivesMessageLoop(MessageLoop::TYPE_DEFAULT); | 149 RunTest_OutlivesMessageLoop(MessageLoop::TYPE_DEFAULT); |
150 RunTest_OutlivesMessageLoop(MessageLoop::TYPE_IO); | 150 RunTest_OutlivesMessageLoop(MessageLoop::TYPE_IO); |
151 RunTest_OutlivesMessageLoop(MessageLoop::TYPE_UI); | 151 RunTest_OutlivesMessageLoop(MessageLoop::TYPE_UI); |
152 } | 152 } |
153 | 153 |
154 TEST(WaitableEventWatcherTest, DeleteUnder) { | 154 TEST(WaitableEventWatcherTest, DeleteUnder) { |
155 RunTest_DeleteUnder(MessageLoop::TYPE_DEFAULT); | 155 RunTest_DeleteUnder(MessageLoop::TYPE_DEFAULT); |
156 RunTest_DeleteUnder(MessageLoop::TYPE_IO); | 156 RunTest_DeleteUnder(MessageLoop::TYPE_IO); |
157 RunTest_DeleteUnder(MessageLoop::TYPE_UI); | 157 RunTest_DeleteUnder(MessageLoop::TYPE_UI); |
158 } | 158 } |
OLD | NEW |