| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/threading/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; |
| 12 using base::WaitableEventWatcher; | 12 using base::WaitableEventWatcher; |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 class QuitDelegate : public WaitableEventWatcher::Delegate { | 16 class QuitDelegate : public WaitableEventWatcher::Delegate { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 WaitableEventWatcher watcher; | 74 WaitableEventWatcher watcher; |
| 75 | 75 |
| 76 int counter = 1; | 76 int counter = 1; |
| 77 DecrementCountDelegate delegate(&counter); | 77 DecrementCountDelegate delegate(&counter); |
| 78 | 78 |
| 79 watcher.StartWatching(&event, &delegate); | 79 watcher.StartWatching(&event, &delegate); |
| 80 | 80 |
| 81 event.Signal(); | 81 event.Signal(); |
| 82 | 82 |
| 83 // Let the background thread do its business | 83 // Let the background thread do its business |
| 84 PlatformThread::Sleep(30); | 84 base::PlatformThread::Sleep(30); |
| 85 | 85 |
| 86 watcher.StopWatching(); | 86 watcher.StopWatching(); |
| 87 | 87 |
| 88 MessageLoop::current()->RunAllPending(); | 88 MessageLoop::current()->RunAllPending(); |
| 89 | 89 |
| 90 // Our delegate should not have fired. | 90 // Our delegate should not have fired. |
| 91 EXPECT_EQ(1, counter); | 91 EXPECT_EQ(1, counter); |
| 92 } | 92 } |
| 93 | 93 |
| 94 void RunTest_OutlivesMessageLoop(MessageLoop::Type message_loop_type) { | 94 void RunTest_OutlivesMessageLoop(MessageLoop::Type message_loop_type) { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 // Crashes sometimes on vista. http://crbug.com/62119 | 155 // Crashes sometimes on vista. http://crbug.com/62119 |
| 156 #define MAYBE_DeleteUnder DISABLED_DeleteUnder | 156 #define MAYBE_DeleteUnder DISABLED_DeleteUnder |
| 157 #else | 157 #else |
| 158 #define MAYBE_DeleteUnder DeleteUnder | 158 #define MAYBE_DeleteUnder DeleteUnder |
| 159 #endif | 159 #endif |
| 160 TEST(WaitableEventWatcherTest, MAYBE_DeleteUnder) { | 160 TEST(WaitableEventWatcherTest, MAYBE_DeleteUnder) { |
| 161 RunTest_DeleteUnder(MessageLoop::TYPE_DEFAULT); | 161 RunTest_DeleteUnder(MessageLoop::TYPE_DEFAULT); |
| 162 RunTest_DeleteUnder(MessageLoop::TYPE_IO); | 162 RunTest_DeleteUnder(MessageLoop::TYPE_IO); |
| 163 RunTest_DeleteUnder(MessageLoop::TYPE_UI); | 163 RunTest_DeleteUnder(MessageLoop::TYPE_UI); |
| 164 } | 164 } |
| OLD | NEW |