| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/quic/quic_alarm.h" | 5 #include "net/quic/quic_alarm.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "testing/gmock/include/gmock/gmock.h" | 8 #include "testing/gmock/include/gmock/gmock.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 | 81 |
| 82 TEST_F(QuicAlarmTest, Cancel) { | 82 TEST_F(QuicAlarmTest, Cancel) { |
| 83 QuicTime deadline = QuicTime::Zero().Add(QuicTime::Delta::FromSeconds(7)); | 83 QuicTime deadline = QuicTime::Zero().Add(QuicTime::Delta::FromSeconds(7)); |
| 84 alarm_.Set(deadline); | 84 alarm_.Set(deadline); |
| 85 alarm_.Cancel(); | 85 alarm_.Cancel(); |
| 86 EXPECT_FALSE(alarm_.IsSet()); | 86 EXPECT_FALSE(alarm_.IsSet()); |
| 87 EXPECT_FALSE(alarm_.scheduled()); | 87 EXPECT_FALSE(alarm_.scheduled()); |
| 88 EXPECT_EQ(QuicTime::Zero(), alarm_.deadline()); | 88 EXPECT_EQ(QuicTime::Zero(), alarm_.deadline()); |
| 89 } | 89 } |
| 90 | 90 |
| 91 TEST_F(QuicAlarmTest, Update) { |
| 92 QuicTime deadline = QuicTime::Zero().Add(QuicTime::Delta::FromSeconds(7)); |
| 93 alarm_.Set(deadline); |
| 94 QuicTime new_deadline = QuicTime::Zero().Add(QuicTime::Delta::FromSeconds(8)); |
| 95 alarm_.Update(new_deadline, QuicTime::Delta::Zero()); |
| 96 EXPECT_TRUE(alarm_.IsSet()); |
| 97 EXPECT_TRUE(alarm_.scheduled()); |
| 98 EXPECT_EQ(new_deadline, alarm_.deadline()); |
| 99 } |
| 100 |
| 101 TEST_F(QuicAlarmTest, UpdateWithZero) { |
| 102 QuicTime deadline = QuicTime::Zero().Add(QuicTime::Delta::FromSeconds(7)); |
| 103 alarm_.Set(deadline); |
| 104 alarm_.Update(QuicTime::Zero(), QuicTime::Delta::Zero()); |
| 105 EXPECT_FALSE(alarm_.IsSet()); |
| 106 EXPECT_FALSE(alarm_.scheduled()); |
| 107 EXPECT_EQ(QuicTime::Zero(), alarm_.deadline()); |
| 108 } |
| 109 |
| 91 TEST_F(QuicAlarmTest, Fire) { | 110 TEST_F(QuicAlarmTest, Fire) { |
| 92 QuicTime deadline = QuicTime::Zero().Add(QuicTime::Delta::FromSeconds(7)); | 111 QuicTime deadline = QuicTime::Zero().Add(QuicTime::Delta::FromSeconds(7)); |
| 93 alarm_.Set(deadline); | 112 alarm_.Set(deadline); |
| 94 EXPECT_CALL(*delegate_, OnAlarm()).WillOnce(Return(QuicTime::Zero())); | 113 EXPECT_CALL(*delegate_, OnAlarm()).WillOnce(Return(QuicTime::Zero())); |
| 95 alarm_.FireAlarm(); | 114 alarm_.FireAlarm(); |
| 96 EXPECT_FALSE(alarm_.IsSet()); | 115 EXPECT_FALSE(alarm_.IsSet()); |
| 97 EXPECT_FALSE(alarm_.scheduled()); | 116 EXPECT_FALSE(alarm_.scheduled()); |
| 98 EXPECT_EQ(QuicTime::Zero(), alarm_.deadline()); | 117 EXPECT_EQ(QuicTime::Zero(), alarm_.deadline()); |
| 99 } | 118 } |
| 100 | 119 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 115 Return(QuicTime::Zero()))); | 134 Return(QuicTime::Zero()))); |
| 116 alarm_.FireAlarm(); | 135 alarm_.FireAlarm(); |
| 117 EXPECT_TRUE(alarm_.IsSet()); | 136 EXPECT_TRUE(alarm_.IsSet()); |
| 118 EXPECT_TRUE(alarm_.scheduled()); | 137 EXPECT_TRUE(alarm_.scheduled()); |
| 119 EXPECT_EQ(deadline2_, alarm_.deadline()); | 138 EXPECT_EQ(deadline2_, alarm_.deadline()); |
| 120 } | 139 } |
| 121 | 140 |
| 122 } // namespace | 141 } // namespace |
| 123 } // namespace test | 142 } // namespace test |
| 124 } // namespace net | 143 } // namespace net |
| OLD | NEW |