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/tools/quic/quic_client_session.h" | 5 #include "net/tools/quic/quic_client_session.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "net/quic/core/crypto/aes_128_gcm_12_encrypter.h" | 9 #include "net/quic/core/crypto/aes_128_gcm_12_encrypter.h" |
10 #include "net/quic/core/spdy_utils.h" | 10 #include "net/quic/core/spdy_utils.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 MockQuicSpdyClientStream* stream = new MockQuicSpdyClientStream(id, this); | 59 MockQuicSpdyClientStream* stream = new MockQuicSpdyClientStream(id, this); |
60 ActivateStream(QuicWrapUnique(stream)); | 60 ActivateStream(QuicWrapUnique(stream)); |
61 return stream; | 61 return stream; |
62 } | 62 } |
63 }; | 63 }; |
64 | 64 |
65 class QuicClientSessionTest : public QuicTestWithParam<QuicVersion> { | 65 class QuicClientSessionTest : public QuicTestWithParam<QuicVersion> { |
66 protected: | 66 protected: |
67 QuicClientSessionTest() | 67 QuicClientSessionTest() |
68 : crypto_config_(crypto_test_utils::ProofVerifierForTesting()), | 68 : crypto_config_(crypto_test_utils::ProofVerifierForTesting()), |
69 promised_stream_id_(kServerDataStreamId1), | 69 promised_stream_id_(kInvalidStreamId), |
70 associated_stream_id_(kClientDataStreamId1) { | 70 associated_stream_id_(kInvalidStreamId) { |
71 Initialize(); | 71 Initialize(); |
72 // Advance the time, because timers do not like uninitialized times. | 72 // Advance the time, because timers do not like uninitialized times. |
73 connection_->AdvanceTime(QuicTime::Delta::FromSeconds(1)); | 73 connection_->AdvanceTime(QuicTime::Delta::FromSeconds(1)); |
74 } | 74 } |
75 | 75 |
76 ~QuicClientSessionTest() override { | 76 ~QuicClientSessionTest() override { |
77 // Session must be destroyed before promised_by_url_ | 77 // Session must be destroyed before promised_by_url_ |
78 session_.reset(nullptr); | 78 session_.reset(nullptr); |
79 } | 79 } |
80 | 80 |
81 void Initialize() { | 81 void Initialize() { |
82 session_.reset(); | 82 session_.reset(); |
83 connection_ = new PacketSavingConnection(&helper_, &alarm_factory_, | 83 connection_ = new PacketSavingConnection(&helper_, &alarm_factory_, |
84 Perspective::IS_CLIENT, | 84 Perspective::IS_CLIENT, |
85 SupportedVersions(GetParam())); | 85 SupportedVersions(GetParam())); |
86 session_.reset(new TestQuicClientSession( | 86 session_.reset(new TestQuicClientSession( |
87 DefaultQuicConfig(), connection_, | 87 DefaultQuicConfig(), connection_, |
88 QuicServerId(kServerHostname, kPort, PRIVACY_MODE_DISABLED), | 88 QuicServerId(kServerHostname, kPort, PRIVACY_MODE_DISABLED), |
89 &crypto_config_, &push_promise_index_)); | 89 &crypto_config_, &push_promise_index_)); |
90 session_->Initialize(); | 90 session_->Initialize(); |
91 push_promise_[":path"] = "/bar"; | 91 push_promise_[":path"] = "/bar"; |
92 push_promise_[":authority"] = "www.google.com"; | 92 push_promise_[":authority"] = "www.google.com"; |
93 push_promise_[":version"] = "HTTP/1.1"; | 93 push_promise_[":version"] = "HTTP/1.1"; |
94 push_promise_[":method"] = "GET"; | 94 push_promise_[":method"] = "GET"; |
95 push_promise_[":scheme"] = "https"; | 95 push_promise_[":scheme"] = "https"; |
96 promise_url_ = SpdyUtils::GetUrlFromHeaderBlock(push_promise_); | 96 promise_url_ = SpdyUtils::GetUrlFromHeaderBlock(push_promise_); |
| 97 promised_stream_id_ = |
| 98 QuicSpdySessionPeer::GetNthServerInitiatedStreamId(*session_, 0); |
| 99 associated_stream_id_ = |
| 100 QuicSpdySessionPeer::GetNthClientInitiatedStreamId(*session_, 0); |
97 } | 101 } |
98 | 102 |
99 void CompleteCryptoHandshake() { | 103 void CompleteCryptoHandshake() { |
100 CompleteCryptoHandshake(kDefaultMaxStreamsPerConnection); | 104 CompleteCryptoHandshake(kDefaultMaxStreamsPerConnection); |
101 } | 105 } |
102 | 106 |
103 void CompleteCryptoHandshake(uint32_t server_max_incoming_streams) { | 107 void CompleteCryptoHandshake(uint32_t server_max_incoming_streams) { |
104 session_->CryptoConnect(); | 108 session_->CryptoConnect(); |
105 QuicCryptoClientStream* stream = static_cast<QuicCryptoClientStream*>( | 109 QuicCryptoClientStream* stream = static_cast<QuicCryptoClientStream*>( |
106 session_->GetMutableCryptoStream()); | 110 session_->GetMutableCryptoStream()); |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 QuicClientPromisedInfo* promised = | 562 QuicClientPromisedInfo* promised = |
559 session_->GetPromisedById(promised_stream_id_); | 563 session_->GetPromisedById(promised_stream_id_); |
560 EXPECT_NE(promised, nullptr); | 564 EXPECT_NE(promised, nullptr); |
561 EXPECT_NE(session_->GetPromisedByUrl(promise_url_), nullptr); | 565 EXPECT_NE(session_->GetPromisedByUrl(promise_url_), nullptr); |
562 EXPECT_EQ(session_->GetPromisedStream(promised_stream_id_), nullptr); | 566 EXPECT_EQ(session_->GetPromisedStream(promised_stream_id_), nullptr); |
563 } | 567 } |
564 | 568 |
565 } // namespace | 569 } // namespace |
566 } // namespace test | 570 } // namespace test |
567 } // namespace net | 571 } // namespace net |
OLD | NEW |