| OLD | NEW |
| 1 // Copyright (c) 2006-2008 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 <process.h> | 5 #include <process.h> |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/object_watcher.h" | 8 #include "base/object_watcher.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| 11 namespace { | 11 namespace { |
| 12 | 12 |
| 13 class QuitDelegate : public base::ObjectWatcher::Delegate { | 13 class QuitDelegate : public base::ObjectWatcher::Delegate { |
| 14 public: | 14 public: |
| 15 virtual void OnObjectSignaled(HANDLE object) { | 15 virtual void OnObjectSignaled(HANDLE object) { |
| 16 MessageLoop::current()->Quit(); | 16 MessageLoop::current()->Quit(); |
| 17 } | 17 } |
| 18 }; | 18 }; |
| 19 | 19 |
| 20 class DecrementCountDelegate : public base::ObjectWatcher::Delegate { | 20 class DecrementCountDelegate : public base::ObjectWatcher::Delegate { |
| 21 public: | 21 public: |
| 22 DecrementCountDelegate(int* counter) : counter_(counter) { | 22 explicit DecrementCountDelegate(int* counter) : counter_(counter) { |
| 23 } | 23 } |
| 24 virtual void OnObjectSignaled(HANDLE object) { | 24 virtual void OnObjectSignaled(HANDLE object) { |
| 25 --(*counter_); | 25 --(*counter_); |
| 26 } | 26 } |
| 27 private: | 27 private: |
| 28 int* counter_; | 28 int* counter_; |
| 29 }; | 29 }; |
| 30 | 30 |
| 31 } // namespace | 31 } // namespace |
| 32 | 32 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 RunTest_CancelAfterSet(MessageLoop::TYPE_DEFAULT); | 134 RunTest_CancelAfterSet(MessageLoop::TYPE_DEFAULT); |
| 135 RunTest_CancelAfterSet(MessageLoop::TYPE_IO); | 135 RunTest_CancelAfterSet(MessageLoop::TYPE_IO); |
| 136 RunTest_CancelAfterSet(MessageLoop::TYPE_UI); | 136 RunTest_CancelAfterSet(MessageLoop::TYPE_UI); |
| 137 } | 137 } |
| 138 | 138 |
| 139 TEST(ObjectWatcherTest, OutlivesMessageLoop) { | 139 TEST(ObjectWatcherTest, OutlivesMessageLoop) { |
| 140 RunTest_OutlivesMessageLoop(MessageLoop::TYPE_DEFAULT); | 140 RunTest_OutlivesMessageLoop(MessageLoop::TYPE_DEFAULT); |
| 141 RunTest_OutlivesMessageLoop(MessageLoop::TYPE_IO); | 141 RunTest_OutlivesMessageLoop(MessageLoop::TYPE_IO); |
| 142 RunTest_OutlivesMessageLoop(MessageLoop::TYPE_UI); | 142 RunTest_OutlivesMessageLoop(MessageLoop::TYPE_UI); |
| 143 } | 143 } |
| OLD | NEW |