Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Side by Side Diff: base/synchronization/waitable_event_watcher_unittest.cc

Issue 9055001: Change code in base (primarily unit tests) to use Sleep(TimeDelta). (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Qualify windows Sleep calls to go through PlatformThread. Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « base/synchronization/waitable_event_unittest.cc ('k') | base/threading/platform_thread_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698