| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2016 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 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 | 46 |
| 47 private: | 47 private: |
| 48 QuicTime now_; | 48 QuicTime now_; |
| 49 }; | 49 }; |
| 50 | 50 |
| 51 // Implements OnAlarm() event which alarm triggers. | 51 // Implements OnAlarm() event which alarm triggers. |
| 52 class MockAlarmDelegate : public QuicAlarm::Delegate { | 52 class MockAlarmDelegate : public QuicAlarm::Delegate { |
| 53 public: | 53 public: |
| 54 MockAlarmDelegate() : fired_(false) {} | 54 MockAlarmDelegate() : fired_(false) {} |
| 55 | 55 |
| 56 QuicTime OnAlarm() override { | 56 void OnAlarm() override { fired_ = true; } |
| 57 fired_ = true; | |
| 58 return QuicTime::Zero(); | |
| 59 } | |
| 60 | 57 |
| 61 bool fired() const { return fired_; } | 58 bool fired() const { return fired_; } |
| 62 void Clear() { fired_ = false; } | 59 void Clear() { fired_ = false; } |
| 63 | 60 |
| 64 private: | 61 private: |
| 65 bool fired_; | 62 bool fired_; |
| 66 }; | 63 }; |
| 67 | 64 |
| 68 class QuicAlarmTest : public ::testing::Test { | 65 class QuicAlarmTest : public ::testing::Test { |
| 69 public: | 66 public: |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 ASSERT_FALSE(delegate_->fired()); | 116 ASSERT_FALSE(delegate_->fired()); |
| 120 } | 117 } |
| 121 | 118 |
| 122 // Test that timing for posting task is accurate. | 119 // Test that timing for posting task is accurate. |
| 123 TEST_F(QuicAlarmTest, AlarmGetDelay) { | 120 TEST_F(QuicAlarmTest, AlarmGetDelay) { |
| 124 SetTime(1000000); | 121 SetTime(1000000); |
| 125 EXPECT_EQ(1000, alarm_->GetDelay()); | 122 EXPECT_EQ(1000, alarm_->GetDelay()); |
| 126 clock_.AdvanceTime(QuicTime::Delta::FromMicroseconds(300000)); | 123 clock_.AdvanceTime(QuicTime::Delta::FromMicroseconds(300000)); |
| 127 EXPECT_EQ(700, alarm_->GetDelay()); | 124 EXPECT_EQ(700, alarm_->GetDelay()); |
| 128 } | 125 } |
| OLD | NEW |