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

Side by Side Diff: base/time_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
« no previous file with comments | « base/threading/watchdog_unittest.cc ('k') | base/time_win_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <time.h> 5 #include <time.h>
6 6
7 #include "base/threading/platform_thread.h" 7 #include "base/threading/platform_thread.h"
8 #include "base/time.h" 8 #include "base/time.h"
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 } 304 }
305 305
306 TEST_F(TimeTest, ParseTimeTestInvalidString) { 306 TEST_F(TimeTest, ParseTimeTestInvalidString) {
307 Time parsed_time; 307 Time parsed_time;
308 EXPECT_FALSE(Time::FromString("Monday morning 2000", &parsed_time)); 308 EXPECT_FALSE(Time::FromString("Monday morning 2000", &parsed_time));
309 } 309 }
310 310
311 TEST(TimeTicks, Deltas) { 311 TEST(TimeTicks, Deltas) {
312 for (int index = 0; index < 50; index++) { 312 for (int index = 0; index < 50; index++) {
313 TimeTicks ticks_start = TimeTicks::Now(); 313 TimeTicks ticks_start = TimeTicks::Now();
314 base::PlatformThread::Sleep(10); 314 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(10));
315 TimeTicks ticks_stop = TimeTicks::Now(); 315 TimeTicks ticks_stop = TimeTicks::Now();
316 TimeDelta delta = ticks_stop - ticks_start; 316 TimeDelta delta = ticks_stop - ticks_start;
317 // Note: Although we asked for a 10ms sleep, if the 317 // Note: Although we asked for a 10ms sleep, if the
318 // time clock has a finer granularity than the Sleep() 318 // time clock has a finer granularity than the Sleep()
319 // clock, it is quite possible to wakeup early. Here 319 // clock, it is quite possible to wakeup early. Here
320 // is how that works: 320 // is how that works:
321 // Time(ms timer) Time(us timer) 321 // Time(ms timer) Time(us timer)
322 // 5 5010 322 // 5 5010
323 // 6 6010 323 // 6 6010
324 // 7 7010 324 // 7 7010
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 exploded.minute = 0; 425 exploded.minute = 0;
426 exploded.second = 0; 426 exploded.second = 0;
427 exploded.millisecond = 0; 427 exploded.millisecond = 0;
428 Time t = Time::FromUTCExploded(exploded); 428 Time t = Time::FromUTCExploded(exploded);
429 // Unix 1970 epoch. 429 // Unix 1970 epoch.
430 EXPECT_EQ(GG_INT64_C(11644473600000000), t.ToInternalValue()); 430 EXPECT_EQ(GG_INT64_C(11644473600000000), t.ToInternalValue());
431 431
432 // We can't test 1601 epoch, since the system time functions on Linux 432 // We can't test 1601 epoch, since the system time functions on Linux
433 // only compute years starting from 1900. 433 // only compute years starting from 1900.
434 } 434 }
OLDNEW
« no previous file with comments | « base/threading/watchdog_unittest.cc ('k') | base/time_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698