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/core/quic_session.h" | 5 #include "net/quic/core/quic_session.h" |
6 | 6 |
7 #include <cstdint> | 7 #include <cstdint> |
8 #include <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/rand_util.h" | 11 #include "base/rand_util.h" |
12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
13 #include "net/quic/core/crypto/crypto_protocol.h" | 13 #include "net/quic/core/crypto/crypto_protocol.h" |
14 #include "net/quic/core/crypto/null_encrypter.h" | 14 #include "net/quic/core/crypto/null_encrypter.h" |
15 #include "net/quic/core/quic_crypto_stream.h" | 15 #include "net/quic/core/quic_crypto_stream.h" |
16 #include "net/quic/core/quic_packets.h" | 16 #include "net/quic/core/quic_packets.h" |
17 #include "net/quic/core/quic_stream.h" | 17 #include "net/quic/core/quic_stream.h" |
18 #include "net/quic/core/quic_utils.h" | 18 #include "net/quic/core/quic_utils.h" |
19 #include "net/quic/platform/api/quic_flags.h" | 19 #include "net/quic/platform/api/quic_flags.h" |
20 #include "net/quic/platform/api/quic_map_util.h" | 20 #include "net/quic/platform/api/quic_map_util.h" |
21 #include "net/quic/platform/api/quic_ptr_util.h" | 21 #include "net/quic/platform/api/quic_ptr_util.h" |
22 #include "net/quic/platform/api/quic_str_cat.h" | 22 #include "net/quic/platform/api/quic_str_cat.h" |
23 #include "net/quic/platform/api/quic_string_piece.h" | 23 #include "net/quic/platform/api/quic_string_piece.h" |
| 24 #include "net/quic/platform/api/quic_test.h" |
24 #include "net/quic/test_tools/quic_config_peer.h" | 25 #include "net/quic/test_tools/quic_config_peer.h" |
25 #include "net/quic/test_tools/quic_connection_peer.h" | 26 #include "net/quic/test_tools/quic_connection_peer.h" |
26 #include "net/quic/test_tools/quic_flow_controller_peer.h" | 27 #include "net/quic/test_tools/quic_flow_controller_peer.h" |
27 #include "net/quic/test_tools/quic_session_peer.h" | 28 #include "net/quic/test_tools/quic_session_peer.h" |
28 #include "net/quic/test_tools/quic_spdy_session_peer.h" | 29 #include "net/quic/test_tools/quic_spdy_session_peer.h" |
29 #include "net/quic/test_tools/quic_spdy_stream_peer.h" | 30 #include "net/quic/test_tools/quic_spdy_stream_peer.h" |
30 #include "net/quic/test_tools/quic_stream_peer.h" | 31 #include "net/quic/test_tools/quic_stream_peer.h" |
31 #include "net/quic/test_tools/quic_test_utils.h" | 32 #include "net/quic/test_tools/quic_test_utils.h" |
32 #include "net/spdy/core/spdy_framer.h" | 33 #include "net/spdy/core/spdy_framer.h" |
33 #include "net/test/gtest_util.h" | 34 #include "net/test/gtest_util.h" |
34 #include "testing/gmock/include/gmock/gmock.h" | |
35 #include "testing/gmock_mutant.h" | 35 #include "testing/gmock_mutant.h" |
36 #include "testing/gtest/include/gtest/gtest.h" | |
37 | 36 |
38 using std::string; | 37 using std::string; |
39 using testing::CreateFunctor; | 38 using testing::CreateFunctor; |
40 using testing::AtLeast; | 39 using testing::AtLeast; |
41 using testing::InSequence; | 40 using testing::InSequence; |
42 using testing::Invoke; | 41 using testing::Invoke; |
43 using testing::Return; | 42 using testing::Return; |
44 using testing::StrictMock; | 43 using testing::StrictMock; |
45 using testing::_; | 44 using testing::_; |
46 | 45 |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 } | 215 } |
217 | 216 |
218 using QuicSession::PostProcessAfterData; | 217 using QuicSession::PostProcessAfterData; |
219 | 218 |
220 private: | 219 private: |
221 StrictMock<TestCryptoStream> crypto_stream_; | 220 StrictMock<TestCryptoStream> crypto_stream_; |
222 | 221 |
223 bool writev_consumes_all_data_; | 222 bool writev_consumes_all_data_; |
224 }; | 223 }; |
225 | 224 |
226 class QuicSessionTestBase : public ::testing::TestWithParam<QuicVersion> { | 225 class QuicSessionTestBase : public QuicTestWithParam<QuicVersion> { |
227 protected: | 226 protected: |
228 explicit QuicSessionTestBase(Perspective perspective) | 227 explicit QuicSessionTestBase(Perspective perspective) |
229 : connection_( | 228 : connection_( |
230 new StrictMock<MockQuicConnection>(&helper_, | 229 new StrictMock<MockQuicConnection>(&helper_, |
231 &alarm_factory_, | 230 &alarm_factory_, |
232 perspective, | 231 perspective, |
233 SupportedVersions(GetParam()))), | 232 SupportedVersions(GetParam()))), |
234 session_(connection_) { | 233 session_(connection_) { |
235 session_.config()->SetInitialStreamFlowControlWindowToSend( | 234 session_.config()->SetInitialStreamFlowControlWindowToSend( |
236 kInitialStreamFlowControlWindowForTest); | 235 kInitialStreamFlowControlWindowForTest); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 } | 276 } |
278 | 277 |
279 void CloseStream(QuicStreamId id) { | 278 void CloseStream(QuicStreamId id) { |
280 EXPECT_CALL(*connection_, SendRstStream(id, _, _)); | 279 EXPECT_CALL(*connection_, SendRstStream(id, _, _)); |
281 session_.CloseStream(id); | 280 session_.CloseStream(id); |
282 closed_streams_.insert(id); | 281 closed_streams_.insert(id); |
283 } | 282 } |
284 | 283 |
285 QuicVersion version() const { return connection_->version(); } | 284 QuicVersion version() const { return connection_->version(); } |
286 | 285 |
287 QuicFlagSaver flags_; // Save/restore all QUIC flag values. | |
288 MockQuicConnectionHelper helper_; | 286 MockQuicConnectionHelper helper_; |
289 MockAlarmFactory alarm_factory_; | 287 MockAlarmFactory alarm_factory_; |
290 StrictMock<MockQuicConnection>* connection_; | 288 StrictMock<MockQuicConnection>* connection_; |
291 TestSession session_; | 289 TestSession session_; |
292 std::set<QuicStreamId> closed_streams_; | 290 std::set<QuicStreamId> closed_streams_; |
293 SpdyHeaderBlock headers_; | 291 SpdyHeaderBlock headers_; |
294 }; | 292 }; |
295 | 293 |
296 class QuicSessionTestServer : public QuicSessionTestBase { | 294 class QuicSessionTestServer : public QuicSessionTestBase { |
297 protected: | 295 protected: |
(...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1314 if (version() != QUIC_VERSION_36) { | 1312 if (version() != QUIC_VERSION_36) { |
1315 EXPECT_FALSE(session_.force_hol_blocking()); | 1313 EXPECT_FALSE(session_.force_hol_blocking()); |
1316 } else { | 1314 } else { |
1317 EXPECT_TRUE(session_.force_hol_blocking()); | 1315 EXPECT_TRUE(session_.force_hol_blocking()); |
1318 } | 1316 } |
1319 } | 1317 } |
1320 | 1318 |
1321 } // namespace | 1319 } // namespace |
1322 } // namespace test | 1320 } // namespace test |
1323 } // namespace net | 1321 } // namespace net |
OLD | NEW |