OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_connection_helper.h" | 5 #include "net/quic/quic_connection_helper.h" |
6 | 6 |
7 #include <vector> | |
8 | |
9 #include "net/quic/test_tools/mock_clock.h" | 7 #include "net/quic/test_tools/mock_clock.h" |
10 #include "net/quic/test_tools/mock_random.h" | 8 #include "net/quic/test_tools/mock_random.h" |
11 #include "net/quic/test_tools/test_task_runner.h" | 9 #include "net/quic/test_tools/test_task_runner.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
13 | 11 |
14 namespace net { | 12 namespace net { |
15 namespace test { | 13 namespace test { |
| 14 namespace { |
16 | 15 |
17 class TestDelegate : public QuicAlarm::Delegate { | 16 class TestDelegate : public QuicAlarm::Delegate { |
18 public: | 17 public: |
19 TestDelegate() : fired_(false) {} | 18 TestDelegate() : fired_(false) {} |
20 | 19 |
21 virtual QuicTime OnAlarm() OVERRIDE { | 20 virtual QuicTime OnAlarm() OVERRIDE { |
22 fired_ = true; | 21 fired_ = true; |
23 return QuicTime::Zero(); | 22 return QuicTime::Zero(); |
24 } | 23 } |
25 | 24 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 // The latter task is still posted. | 134 // The latter task is still posted. |
136 ASSERT_EQ(1u, runner_->GetPostedTasks().size()); | 135 ASSERT_EQ(1u, runner_->GetPostedTasks().size()); |
137 | 136 |
138 // When the latter task is executed, the weak ptr will be invalid and | 137 // When the latter task is executed, the weak ptr will be invalid and |
139 // the alarm will not fire. | 138 // the alarm will not fire. |
140 runner_->RunNextTask(); | 139 runner_->RunNextTask(); |
141 EXPECT_EQ(QuicTime::Zero().Add(delta), clock_.Now()); | 140 EXPECT_EQ(QuicTime::Zero().Add(delta), clock_.Now()); |
142 EXPECT_FALSE(delegate->fired()); | 141 EXPECT_FALSE(delegate->fired()); |
143 } | 142 } |
144 | 143 |
| 144 } // namespace |
145 } // namespace test | 145 } // namespace test |
146 } // namespace net | 146 } // namespace net |
OLD | NEW |