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 <process.h> | 5 #include <process.h> |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/win/object_watcher.h" | 8 #include "base/win/object_watcher.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
11 namespace base { | 11 namespace base { |
12 namespace win { | 12 namespace win { |
13 | 13 |
14 namespace { | 14 namespace { |
15 | 15 |
16 class QuitDelegate : public ObjectWatcher::Delegate { | 16 class QuitDelegate : public ObjectWatcher::Delegate { |
17 public: | 17 public: |
18 virtual void OnObjectSignaled(HANDLE object) { | 18 virtual void OnObjectSignaled(HANDLE object) { |
19 MessageLoop::current()->Quit(); | 19 MessageLoop::current()->QuitWhenIdle(); |
20 } | 20 } |
21 }; | 21 }; |
22 | 22 |
23 class DecrementCountDelegate : public ObjectWatcher::Delegate { | 23 class DecrementCountDelegate : public ObjectWatcher::Delegate { |
24 public: | 24 public: |
25 explicit DecrementCountDelegate(int* counter) : counter_(counter) { | 25 explicit DecrementCountDelegate(int* counter) : counter_(counter) { |
26 } | 26 } |
27 virtual void OnObjectSignaled(HANDLE object) { | 27 virtual void OnObjectSignaled(HANDLE object) { |
28 --(*counter_); | 28 --(*counter_); |
29 } | 29 } |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 } | 163 } |
164 | 164 |
165 TEST(ObjectWatcherTest, OutlivesMessageLoop) { | 165 TEST(ObjectWatcherTest, OutlivesMessageLoop) { |
166 RunTest_OutlivesMessageLoop(MessageLoop::TYPE_DEFAULT); | 166 RunTest_OutlivesMessageLoop(MessageLoop::TYPE_DEFAULT); |
167 RunTest_OutlivesMessageLoop(MessageLoop::TYPE_IO); | 167 RunTest_OutlivesMessageLoop(MessageLoop::TYPE_IO); |
168 RunTest_OutlivesMessageLoop(MessageLoop::TYPE_UI); | 168 RunTest_OutlivesMessageLoop(MessageLoop::TYPE_UI); |
169 } | 169 } |
170 | 170 |
171 } // namespace win | 171 } // namespace win |
172 } // namespace base | 172 } // namespace base |
OLD | NEW |