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