| 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 |
| 11 using testing::Return; | 11 using testing::Return; |
| 12 using testing::Invoke; | 12 using testing::Invoke; |
| 13 | 13 |
| 14 namespace net { | 14 namespace net { |
| 15 namespace test { | 15 namespace test { |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 class MockDelegate : public QuicAlarm::Delegate { | 18 class MockDelegate : public QuicAlarm::Delegate { |
| 19 public: | 19 public: |
| 20 MOCK_METHOD0(OnAlarm, QuicTime()); | 20 MOCK_METHOD0(OnAlarm, QuicTime()); |
| 21 }; | 21 }; |
| 22 | 22 |
| 23 class TestAlarm : public QuicAlarm { | 23 class TestAlarm : public QuicAlarm { |
| 24 public: | 24 public: |
| 25 explicit TestAlarm(QuicAlarm::Delegate* delegate) : QuicAlarm(delegate) {} | 25 explicit TestAlarm(QuicAlarm::Delegate* delegate) |
| 26 : QuicAlarm(QuicArenaScopedPtr<QuicAlarm::Delegate>(delegate)) {} |
| 26 | 27 |
| 27 bool scheduled() const { return scheduled_; } | 28 bool scheduled() const { return scheduled_; } |
| 28 | 29 |
| 29 void FireAlarm() { | 30 void FireAlarm() { |
| 30 scheduled_ = false; | 31 scheduled_ = false; |
| 31 Fire(); | 32 Fire(); |
| 32 } | 33 } |
| 33 | 34 |
| 34 protected: | 35 protected: |
| 35 void SetImpl() override { | 36 void SetImpl() override { |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 Return(QuicTime::Zero()))); | 132 Return(QuicTime::Zero()))); |
| 132 alarm_.FireAlarm(); | 133 alarm_.FireAlarm(); |
| 133 EXPECT_TRUE(alarm_.IsSet()); | 134 EXPECT_TRUE(alarm_.IsSet()); |
| 134 EXPECT_TRUE(alarm_.scheduled()); | 135 EXPECT_TRUE(alarm_.scheduled()); |
| 135 EXPECT_EQ(deadline2_, alarm_.deadline()); | 136 EXPECT_EQ(deadline2_, alarm_.deadline()); |
| 136 } | 137 } |
| 137 | 138 |
| 138 } // namespace | 139 } // namespace |
| 139 } // namespace test | 140 } // namespace test |
| 140 } // namespace net | 141 } // namespace net |
| OLD | NEW |