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

Side by Side Diff: webrtc/modules/utility/source/process_thread_impl_unittest.cc

Issue 1415923010: Several Tick counter improvements. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixup unittests that always assumed ::Now returned nonzero result. Created 5 years, 1 month 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
« no previous file with comments | « no previous file | webrtc/system_wrappers/include/tick_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 // Tests that we can wake up the worker thread to give us a callback right 244 // Tests that we can wake up the worker thread to give us a callback right
245 // away when we know the thread is sleeping. 245 // away when we know the thread is sleeping.
246 TEST(ProcessThreadImpl, WakeUp) { 246 TEST(ProcessThreadImpl, WakeUp) {
247 ProcessThreadImpl thread("ProcessThread"); 247 ProcessThreadImpl thread("ProcessThread");
248 thread.Start(); 248 thread.Start();
249 249
250 rtc::scoped_ptr<EventWrapper> started(EventWrapper::Create()); 250 rtc::scoped_ptr<EventWrapper> started(EventWrapper::Create());
251 rtc::scoped_ptr<EventWrapper> called(EventWrapper::Create()); 251 rtc::scoped_ptr<EventWrapper> called(EventWrapper::Create());
252 252
253 MockModule module; 253 MockModule module;
254 int64_t start_time = 0; 254 int64_t start_time = 0;
pbos-webrtc 2015/11/12 11:55:41 Shouldn't you initialize these to -1 and update th
noahric 2015/11/12 18:10:15 I think we should actually just the startTime != s
255 int64_t called_time = 0; 255 int64_t called_time = 0;
256
257 // On Mac, timestamps start at 0 the first time TickTime::Foo is called.
258 // Let this increment a very small amount before comparing our elapsed times.
259 (void)TickTime::MillisecondTimestamp();
260 started->Wait(10);
261
256 // Ask for a callback after 1000ms. 262 // Ask for a callback after 1000ms.
257 // TimeUntilNextProcess will be called twice. 263 // TimeUntilNextProcess will be called twice.
258 // The first time we use it to get the thread into a waiting state. 264 // The first time we use it to get the thread into a waiting state.
259 // Then we wake the thread and there should not be another call made to 265 // Then we wake the thread and there should not be another call made to
260 // TimeUntilNextProcess before Process() is called. 266 // TimeUntilNextProcess before Process() is called.
261 // The second time TimeUntilNextProcess is then called, is after Process 267 // The second time TimeUntilNextProcess is then called, is after Process
262 // has been called and we don't expect any more calls. 268 // has been called and we don't expect any more calls.
263 EXPECT_CALL(module, TimeUntilNextProcess()) 269 EXPECT_CALL(module, TimeUntilNextProcess())
264 .WillOnce(DoAll(SetTimestamp(&start_time), 270 .WillOnce(DoAll(SetTimestamp(&start_time),
265 SetEvent(started.get()), 271 SetEvent(started.get()),
(...skipping 29 matching lines...) Expand all
295 ProcessThreadImpl thread("ProcessThread"); 301 ProcessThreadImpl thread("ProcessThread");
296 rtc::scoped_ptr<EventWrapper> task_ran(EventWrapper::Create()); 302 rtc::scoped_ptr<EventWrapper> task_ran(EventWrapper::Create());
297 rtc::scoped_ptr<RaiseEventTask> task(new RaiseEventTask(task_ran.get())); 303 rtc::scoped_ptr<RaiseEventTask> task(new RaiseEventTask(task_ran.get()));
298 thread.Start(); 304 thread.Start();
299 thread.PostTask(task.Pass()); 305 thread.PostTask(task.Pass());
300 EXPECT_EQ(kEventSignaled, task_ran->Wait(100)); 306 EXPECT_EQ(kEventSignaled, task_ran->Wait(100));
301 thread.Stop(); 307 thread.Stop();
302 } 308 }
303 309
304 } // namespace webrtc 310 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/system_wrappers/include/tick_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698