OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 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 |
11 #include "webrtc/base/common.h" | 11 #include "webrtc/base/common.h" |
12 #include "webrtc/base/gunit.h" | 12 #include "webrtc/base/gunit.h" |
13 #include "webrtc/base/thread.h" | 13 #include "webrtc/base/thread.h" |
14 #include "webrtc/base/timeutils.h" | 14 #include "webrtc/base/timeutils.h" |
15 | 15 |
16 namespace rtc { | 16 namespace rtc { |
17 | 17 |
18 TEST(TimeTest, TimeInMs) { | 18 TEST(TimeTest, TimeInMs) { |
19 uint32 ts_earlier = Time(); | 19 uint32_t ts_earlier = Time(); |
20 Thread::SleepMs(100); | 20 Thread::SleepMs(100); |
21 uint32 ts_now = Time(); | 21 uint32_t ts_now = Time(); |
22 // Allow for the thread to wakeup ~20ms early. | 22 // Allow for the thread to wakeup ~20ms early. |
23 EXPECT_GE(ts_now, ts_earlier + 80); | 23 EXPECT_GE(ts_now, ts_earlier + 80); |
24 // Make sure the Time is not returning in smaller unit like microseconds. | 24 // Make sure the Time is not returning in smaller unit like microseconds. |
25 EXPECT_LT(ts_now, ts_earlier + 1000); | 25 EXPECT_LT(ts_now, ts_earlier + 1000); |
26 } | 26 } |
27 | 27 |
28 TEST(TimeTest, Comparison) { | 28 TEST(TimeTest, Comparison) { |
29 // Obtain two different times, in known order | 29 // Obtain two different times, in known order |
30 TimeStamp ts_earlier = Time(); | 30 TimeStamp ts_earlier = Time(); |
31 Thread::SleepMs(100); | 31 Thread::SleepMs(100); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 | 145 |
146 class TimestampWrapAroundHandlerTest : public testing::Test { | 146 class TimestampWrapAroundHandlerTest : public testing::Test { |
147 public: | 147 public: |
148 TimestampWrapAroundHandlerTest() {} | 148 TimestampWrapAroundHandlerTest() {} |
149 | 149 |
150 protected: | 150 protected: |
151 TimestampWrapAroundHandler wraparound_handler_; | 151 TimestampWrapAroundHandler wraparound_handler_; |
152 }; | 152 }; |
153 | 153 |
154 TEST_F(TimestampWrapAroundHandlerTest, Unwrap) { | 154 TEST_F(TimestampWrapAroundHandlerTest, Unwrap) { |
155 uint32 ts = 0xfffffff2; | 155 uint32_t ts = 0xfffffff2; |
156 int64 unwrapped_ts = ts; | 156 int64_t unwrapped_ts = ts; |
157 EXPECT_EQ(ts, wraparound_handler_.Unwrap(ts)); | 157 EXPECT_EQ(ts, wraparound_handler_.Unwrap(ts)); |
158 ts = 2; | 158 ts = 2; |
159 unwrapped_ts += 0x10; | 159 unwrapped_ts += 0x10; |
160 EXPECT_EQ(unwrapped_ts, wraparound_handler_.Unwrap(ts)); | 160 EXPECT_EQ(unwrapped_ts, wraparound_handler_.Unwrap(ts)); |
161 ts = 0xfffffff2; | 161 ts = 0xfffffff2; |
162 unwrapped_ts += 0xfffffff0; | 162 unwrapped_ts += 0xfffffff0; |
163 EXPECT_EQ(unwrapped_ts, wraparound_handler_.Unwrap(ts)); | 163 EXPECT_EQ(unwrapped_ts, wraparound_handler_.Unwrap(ts)); |
164 ts = 0; | 164 ts = 0; |
165 unwrapped_ts += 0xe; | 165 unwrapped_ts += 0xe; |
166 EXPECT_EQ(unwrapped_ts, wraparound_handler_.Unwrap(ts)); | 166 EXPECT_EQ(unwrapped_ts, wraparound_handler_.Unwrap(ts)); |
167 } | 167 } |
168 | 168 |
169 } // namespace rtc | 169 } // namespace rtc |
OLD | NEW |