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

Side by Side Diff: src/base/platform/time-unittest.cc

Issue 520503004: Merge base unit tests into src to be in line with Chrome. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project 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 "src/base/platform/time.h" 5 #include "src/base/platform/time.h"
6 6
7 #if V8_OS_MACOSX 7 #if V8_OS_MACOSX
8 #include <mach/mach_time.h> 8 #include <mach/mach_time.h>
9 #endif 9 #endif
10 #if V8_OS_POSIX 10 #if V8_OS_POSIX
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 // change, we detect the minimum time between measurements. 132 // change, we detect the minimum time between measurements.
133 do { 133 do {
134 now = Now(); 134 now = Now();
135 delta = now - start; 135 delta = now - start;
136 } while (now <= start); 136 } while (now <= start);
137 EXPECT_NE(static_cast<int64_t>(0), delta.InMicroseconds()); 137 EXPECT_NE(static_cast<int64_t>(0), delta.InMicroseconds());
138 } while (delta > target_granularity && !timer.HasExpired(kExpirationTimeout)); 138 } while (delta > target_granularity && !timer.HasExpired(kExpirationTimeout));
139 EXPECT_LE(delta, target_granularity); 139 EXPECT_LE(delta, target_granularity);
140 } 140 }
141 141
142 } 142 } // namespace
143 143
144 144
145 TEST(Time, NowResolution) { 145 TEST(Time, NowResolution) {
146 // We assume that Time::Now() has at least 16ms resolution. 146 // We assume that Time::Now() has at least 16ms resolution.
147 static const TimeDelta kTargetGranularity = TimeDelta::FromMilliseconds(16); 147 static const TimeDelta kTargetGranularity = TimeDelta::FromMilliseconds(16);
148 ResolutionTest<Time>(&Time::Now, kTargetGranularity); 148 ResolutionTest<Time>(&Time::Now, kTargetGranularity);
149 } 149 }
150 150
151 151
152 TEST(TimeTicks, NowResolution) { 152 TEST(TimeTicks, NowResolution) {
(...skipping 24 matching lines...) Expand all
177 EXPECT_GE((normal_ticks - previous_normal_ticks).InMicroseconds(), 0); 177 EXPECT_GE((normal_ticks - previous_normal_ticks).InMicroseconds(), 0);
178 EXPECT_GE(highres_ticks, previous_highres_ticks); 178 EXPECT_GE(highres_ticks, previous_highres_ticks);
179 EXPECT_GE((highres_ticks - previous_highres_ticks).InMicroseconds(), 0); 179 EXPECT_GE((highres_ticks - previous_highres_ticks).InMicroseconds(), 0);
180 previous_normal_ticks = normal_ticks; 180 previous_normal_ticks = normal_ticks;
181 previous_highres_ticks = highres_ticks; 181 previous_highres_ticks = highres_ticks;
182 } 182 }
183 } 183 }
184 184
185 } // namespace base 185 } // namespace base
186 } // namespace v8 186 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698