| 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/core/quic_alarm.h" | 5 #include "net/quic/core/quic_alarm.h" |
| 6 | 6 |
| 7 #include "testing/gmock/include/gmock/gmock.h" | 7 #include "net/quic/platform/api/quic_test.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | |
| 9 | 8 |
| 10 using testing::Return; | 9 using testing::Return; |
| 11 using testing::Invoke; | 10 using testing::Invoke; |
| 12 | 11 |
| 13 namespace net { | 12 namespace net { |
| 14 namespace test { | 13 namespace test { |
| 15 namespace { | 14 namespace { |
| 16 | 15 |
| 17 class MockDelegate : public QuicAlarm::Delegate { | 16 class MockDelegate : public QuicAlarm::Delegate { |
| 18 public: | 17 public: |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 : QuicAlarm(QuicArenaScopedPtr<DestructiveDelegate>(delegate)) {} | 66 : QuicAlarm(QuicArenaScopedPtr<DestructiveDelegate>(delegate)) {} |
| 68 | 67 |
| 69 void FireAlarm() { Fire(); } | 68 void FireAlarm() { Fire(); } |
| 70 | 69 |
| 71 protected: | 70 protected: |
| 72 void SetImpl() override {} | 71 void SetImpl() override {} |
| 73 | 72 |
| 74 void CancelImpl() override {} | 73 void CancelImpl() override {} |
| 75 }; | 74 }; |
| 76 | 75 |
| 77 class QuicAlarmTest : public ::testing::Test { | 76 class QuicAlarmTest : public QuicTest { |
| 78 public: | 77 public: |
| 79 QuicAlarmTest() | 78 QuicAlarmTest() |
| 80 : delegate_(new MockDelegate()), | 79 : delegate_(new MockDelegate()), |
| 81 alarm_(delegate_), | 80 alarm_(delegate_), |
| 82 deadline_(QuicTime::Zero() + QuicTime::Delta::FromSeconds(7)), | 81 deadline_(QuicTime::Zero() + QuicTime::Delta::FromSeconds(7)), |
| 83 deadline2_(QuicTime::Zero() + QuicTime::Delta::FromSeconds(14)), | 82 deadline2_(QuicTime::Zero() + QuicTime::Delta::FromSeconds(14)), |
| 84 new_deadline_(QuicTime::Zero()) {} | 83 new_deadline_(QuicTime::Zero()) {} |
| 85 | 84 |
| 86 void ResetAlarm() { alarm_.Set(new_deadline_); } | 85 void ResetAlarm() { alarm_.Set(new_deadline_); } |
| 87 | 86 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 delegate->set_alarm(alarm); | 157 delegate->set_alarm(alarm); |
| 159 QuicTime deadline = QuicTime::Zero() + QuicTime::Delta::FromSeconds(7); | 158 QuicTime deadline = QuicTime::Zero() + QuicTime::Delta::FromSeconds(7); |
| 160 alarm->Set(deadline); | 159 alarm->Set(deadline); |
| 161 // This should not crash, even though it will destroy alarm. | 160 // This should not crash, even though it will destroy alarm. |
| 162 alarm->FireAlarm(); | 161 alarm->FireAlarm(); |
| 163 } | 162 } |
| 164 | 163 |
| 165 } // namespace | 164 } // namespace |
| 166 } // namespace test | 165 } // namespace test |
| 167 } // namespace net | 166 } // namespace net |
| OLD | NEW |