OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/synchronization/waitable_event.h" | 6 #include "base/synchronization/waitable_event.h" |
7 #include "base/synchronization/waitable_event_watcher.h" | 7 #include "base/synchronization/waitable_event_watcher.h" |
8 #include "base/threading/platform_thread.h" | 8 #include "base/threading/platform_thread.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 WaitableEventWatcher watcher; | 73 WaitableEventWatcher watcher; |
74 | 74 |
75 int counter = 1; | 75 int counter = 1; |
76 DecrementCountDelegate delegate(&counter); | 76 DecrementCountDelegate delegate(&counter); |
77 | 77 |
78 watcher.StartWatching(&event, &delegate); | 78 watcher.StartWatching(&event, &delegate); |
79 | 79 |
80 event.Signal(); | 80 event.Signal(); |
81 | 81 |
82 // Let the background thread do its business | 82 // Let the background thread do its business |
83 base::PlatformThread::Sleep(30); | 83 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(30)); |
84 | 84 |
85 watcher.StopWatching(); | 85 watcher.StopWatching(); |
86 | 86 |
87 MessageLoop::current()->RunAllPending(); | 87 MessageLoop::current()->RunAllPending(); |
88 | 88 |
89 // Our delegate should not have fired. | 89 // Our delegate should not have fired. |
90 EXPECT_EQ(1, counter); | 90 EXPECT_EQ(1, counter); |
91 } | 91 } |
92 | 92 |
93 void RunTest_OutlivesMessageLoop(MessageLoop::Type message_loop_type) { | 93 void RunTest_OutlivesMessageLoop(MessageLoop::Type message_loop_type) { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 #else | 156 #else |
157 #define MAYBE_DeleteUnder DeleteUnder | 157 #define MAYBE_DeleteUnder DeleteUnder |
158 #endif | 158 #endif |
159 TEST(WaitableEventWatcherTest, MAYBE_DeleteUnder) { | 159 TEST(WaitableEventWatcherTest, MAYBE_DeleteUnder) { |
160 RunTest_DeleteUnder(MessageLoop::TYPE_DEFAULT); | 160 RunTest_DeleteUnder(MessageLoop::TYPE_DEFAULT); |
161 RunTest_DeleteUnder(MessageLoop::TYPE_IO); | 161 RunTest_DeleteUnder(MessageLoop::TYPE_IO); |
162 RunTest_DeleteUnder(MessageLoop::TYPE_UI); | 162 RunTest_DeleteUnder(MessageLoop::TYPE_UI); |
163 } | 163 } |
164 | 164 |
165 } // namespace base | 165 } // namespace base |
OLD | NEW |