| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2015 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/gunit.h" | 11 #include "webrtc/base/gunit.h" |
| 12 #include "webrtc/base/ratetracker.h" | 12 #include "webrtc/base/ratetracker.h" |
| 13 | 13 |
| 14 namespace rtc { | 14 namespace rtc { |
| 15 | 15 |
| 16 class RateTrackerForTest : public RateTracker { | 16 class RateTrackerForTest : public RateTracker { |
| 17 public: | 17 public: |
| 18 RateTrackerForTest() : RateTracker(100u, 10u), time_(0) {} | 18 RateTrackerForTest() : RateTracker(100u, 10u), time_(0) {} |
| 19 virtual uint32 Time() const { return time_; } | 19 virtual uint32_t Time() const { return time_; } |
| 20 void AdvanceTime(uint32 delta) { time_ += delta; } | 20 void AdvanceTime(uint32_t delta) { time_ += delta; } |
| 21 | 21 |
| 22 private: | 22 private: |
| 23 uint32 time_; | 23 uint32_t time_; |
| 24 }; | 24 }; |
| 25 | 25 |
| 26 TEST(RateTrackerTest, Test30FPS) { | 26 TEST(RateTrackerTest, Test30FPS) { |
| 27 RateTrackerForTest tracker; | 27 RateTrackerForTest tracker; |
| 28 | 28 |
| 29 for (int i = 0; i < 300; ++i) { | 29 for (int i = 0; i < 300; ++i) { |
| 30 tracker.AddSamples(1); | 30 tracker.AddSamples(1); |
| 31 tracker.AdvanceTime(33); | 31 tracker.AdvanceTime(33); |
| 32 if (i % 3 == 0) { | 32 if (i % 3 == 0) { |
| 33 tracker.AdvanceTime(1); | 33 tracker.AdvanceTime(1); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 } | 153 } |
| 154 | 154 |
| 155 TEST(RateTrackerTest, TestGetUnitSecondsAfterInitialValue) { | 155 TEST(RateTrackerTest, TestGetUnitSecondsAfterInitialValue) { |
| 156 RateTrackerForTest tracker; | 156 RateTrackerForTest tracker; |
| 157 tracker.AddSamples(1234); | 157 tracker.AddSamples(1234); |
| 158 tracker.AdvanceTime(1000); | 158 tracker.AdvanceTime(1000); |
| 159 EXPECT_DOUBLE_EQ(1234.0, tracker.ComputeRateForInterval(1000u)); | 159 EXPECT_DOUBLE_EQ(1234.0, tracker.ComputeRateForInterval(1000u)); |
| 160 } | 160 } |
| 161 | 161 |
| 162 } // namespace rtc | 162 } // namespace rtc |
| OLD | NEW |