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

Unified Diff: base/time_unittest.cc

Issue 10257020: Add interface to system trace clock. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: consolidate high res clock unit test code Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/time_posix.cc ('k') | base/time_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/time_unittest.cc
diff --git a/base/time_unittest.cc b/base/time_unittest.cc
index 9823147a33dac223d224726b3c988676cf8e7be6..b4b166be75ee1c9deaeab9bcb07b09f4ab7e1eaa 100644
--- a/base/time_unittest.cc
+++ b/base/time_unittest.cc
@@ -464,7 +464,7 @@ TEST(TimeTicks, Deltas) {
}
}
-TEST(TimeTicks, HighResNow) {
+static void HighResClockTest(TimeTicks (*GetTicks)()) {
#if defined(OS_WIN)
// HighResNow doesn't work on some systems. Since the product still works
// even if it doesn't work, it makes this entire test questionable.
@@ -486,12 +486,12 @@ TEST(TimeTicks, HighResNow) {
int retries = 100; // Arbitrary.
TimeDelta delta;
while (!success && retries--) {
- TimeTicks ticks_start = TimeTicks::HighResNow();
+ TimeTicks ticks_start = GetTicks();
// Loop until we can detect that the clock has changed. Non-HighRes timers
// will increment in chunks, e.g. 15ms. By spinning until we see a clock
// change, we detect the minimum time between measurements.
do {
- delta = TimeTicks::HighResNow() - ticks_start;
+ delta = GetTicks() - ticks_start;
} while (delta.InMilliseconds() == 0);
if (delta.InMicroseconds() <= kTargetGranularityUs)
@@ -503,6 +503,15 @@ TEST(TimeTicks, HighResNow) {
EXPECT_TRUE(success);
}
+TEST(TimeTicks, HighResNow) {
+ HighResClockTest(&TimeTicks::HighResNow);
+}
+
+TEST(TimeTicks, NowFromSystemTraceTime) {
+ // Re-use HighResNow test for now since clock properties are identical.
+ HighResClockTest(&TimeTicks::NowFromSystemTraceTime);
+}
+
TEST(TimeDelta, FromAndIn) {
EXPECT_TRUE(TimeDelta::FromDays(2) == TimeDelta::FromHours(48));
EXPECT_TRUE(TimeDelta::FromHours(3) == TimeDelta::FromMinutes(180));
« no previous file with comments | « base/time_posix.cc ('k') | base/time_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698