| 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/rtc_base/timeutils.h" | 11 #include "webrtc/base/event.h" |
| 12 #include "webrtc/rtc_base/event.h" | 12 #include "webrtc/base/fakeclock.h" |
| 13 #include "webrtc/rtc_base/fakeclock.h" | 13 #include "webrtc/base/gunit.h" |
| 14 #include "webrtc/rtc_base/gunit.h" | 14 #include "webrtc/base/helpers.h" |
| 15 #include "webrtc/rtc_base/helpers.h" | 15 #include "webrtc/base/thread.h" |
| 16 #include "webrtc/rtc_base/thread.h" | 16 #include "webrtc/base/timeutils.h" |
| 17 | 17 |
| 18 namespace rtc { | 18 namespace rtc { |
| 19 | 19 |
| 20 TEST(TimeTest, TimeInMs) { | 20 TEST(TimeTest, TimeInMs) { |
| 21 int64_t ts_earlier = TimeMillis(); | 21 int64_t ts_earlier = TimeMillis(); |
| 22 Thread::SleepMs(100); | 22 Thread::SleepMs(100); |
| 23 int64_t ts_now = TimeMillis(); | 23 int64_t ts_now = TimeMillis(); |
| 24 // Allow for the thread to wakeup ~20ms early. | 24 // Allow for the thread to wakeup ~20ms early. |
| 25 EXPECT_GE(ts_now, ts_earlier + 80); | 25 EXPECT_GE(ts_now, ts_earlier + 80); |
| 26 // Make sure the Time is not returning in smaller unit like microseconds. | 26 // Make sure the Time is not returning in smaller unit like microseconds. |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 | 373 |
| 374 SetClockForTesting(nullptr); | 374 SetClockForTesting(nullptr); |
| 375 | 375 |
| 376 // The message should have been dispatched long before the 60 seconds fully | 376 // The message should have been dispatched long before the 60 seconds fully |
| 377 // elapsed (just a sanity check). | 377 // elapsed (just a sanity check). |
| 378 int64_t real_end_time_ms = TimeMillis(); | 378 int64_t real_end_time_ms = TimeMillis(); |
| 379 EXPECT_LT(real_end_time_ms - real_start_time_ms, 10000); | 379 EXPECT_LT(real_end_time_ms - real_start_time_ms, 10000); |
| 380 } | 380 } |
| 381 | 381 |
| 382 } // namespace rtc | 382 } // namespace rtc |
| OLD | NEW |