| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/tools/quic/quic_simple_server_stream.h" | 5 #include "net/tools/quic/quic_simple_server_stream.h" |
| 6 | 6 |
| 7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 8 #include "base/strings/string_piece.h" | 8 #include "base/strings/string_piece.h" |
| 9 #include "net/quic/quic_connection.h" | 9 #include "net/quic/quic_connection.h" |
| 10 #include "net/quic/quic_flags.h" | 10 #include "net/quic/quic_flags.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 | 77 |
| 78 static SpdyHeaderBlock& headers(QuicSimpleServerStream* stream) { | 78 static SpdyHeaderBlock& headers(QuicSimpleServerStream* stream) { |
| 79 return stream->request_headers_; | 79 return stream->request_headers_; |
| 80 } | 80 } |
| 81 }; | 81 }; |
| 82 | 82 |
| 83 class MockQuicSimpleServerSession : public QuicSimpleServerSession { | 83 class MockQuicSimpleServerSession : public QuicSimpleServerSession { |
| 84 public: | 84 public: |
| 85 const size_t kMaxStreamsForTest = 100; | 85 const size_t kMaxStreamsForTest = 100; |
| 86 | 86 |
| 87 explicit MockQuicSimpleServerSession(QuicConnection* connection, | 87 explicit MockQuicSimpleServerSession( |
| 88 MockQuicServerSessionVisitor* owner, | 88 QuicConnection* connection, |
| 89 QuicCryptoServerConfig* crypto_config) | 89 MockQuicServerSessionVisitor* owner, |
| 90 : QuicSimpleServerSession(::net::test::DefaultQuicConfig(), | 90 QuicCryptoServerConfig* crypto_config, |
| 91 QuicCompressedCertsCache* compressed_certs_cache) |
| 92 : QuicSimpleServerSession(DefaultQuicConfig(), |
| 91 connection, | 93 connection, |
| 92 owner, | 94 owner, |
| 93 crypto_config) { | 95 crypto_config, |
| 96 compressed_certs_cache) { |
| 94 set_max_open_incoming_streams(kMaxStreamsForTest); | 97 set_max_open_incoming_streams(kMaxStreamsForTest); |
| 95 set_max_open_outgoing_streams(kMaxStreamsForTest); | 98 set_max_open_outgoing_streams(kMaxStreamsForTest); |
| 96 ON_CALL(*this, WritevData(_, _, _, _, _)) | 99 ON_CALL(*this, WritevData(_, _, _, _, _)) |
| 97 .WillByDefault(testing::Return(QuicConsumedData(0, false))); | 100 .WillByDefault(testing::Return(QuicConsumedData(0, false))); |
| 98 } | 101 } |
| 99 | 102 |
| 100 ~MockQuicSimpleServerSession() override {} | 103 ~MockQuicSimpleServerSession() override {} |
| 101 | 104 |
| 102 MOCK_METHOD2(OnConnectionClosed, | 105 MOCK_METHOD2(OnConnectionClosed, |
| 103 void(QuicErrorCode error, ConnectionCloseSource source)); | 106 void(QuicErrorCode error, ConnectionCloseSource source)); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 QuicSimpleServerStreamTest() | 148 QuicSimpleServerStreamTest() |
| 146 : connection_( | 149 : connection_( |
| 147 new StrictMock<MockConnection>(&helper_, | 150 new StrictMock<MockConnection>(&helper_, |
| 148 Perspective::IS_SERVER, | 151 Perspective::IS_SERVER, |
| 149 SupportedVersions(GetParam()))), | 152 SupportedVersions(GetParam()))), |
| 150 session_owner_(new StrictMock<MockQuicServerSessionVisitor>()), | 153 session_owner_(new StrictMock<MockQuicServerSessionVisitor>()), |
| 151 crypto_config_(new QuicCryptoServerConfig( | 154 crypto_config_(new QuicCryptoServerConfig( |
| 152 QuicCryptoServerConfig::TESTING, | 155 QuicCryptoServerConfig::TESTING, |
| 153 QuicRandom::GetInstance(), | 156 QuicRandom::GetInstance(), |
| 154 ::net::test::CryptoTestUtils::ProofSourceForTesting())), | 157 ::net::test::CryptoTestUtils::ProofSourceForTesting())), |
| 155 session_(connection_, session_owner_, crypto_config_.get()), | 158 compressed_certs_cache_( |
| 159 QuicCompressedCertsCache::kQuicCompressedCertsCacheSize), |
| 160 session_(connection_, |
| 161 session_owner_, |
| 162 crypto_config_.get(), |
| 163 &compressed_certs_cache_), |
| 156 body_("hello world") { | 164 body_("hello world") { |
| 157 FLAGS_quic_always_log_bugs_for_tests = true; | 165 FLAGS_quic_always_log_bugs_for_tests = true; |
| 158 SpdyHeaderBlock request_headers; | 166 SpdyHeaderBlock request_headers; |
| 159 request_headers[":host"] = ""; | 167 request_headers[":host"] = ""; |
| 160 request_headers[":authority"] = "www.google.com"; | 168 request_headers[":authority"] = "www.google.com"; |
| 161 request_headers[":path"] = "/"; | 169 request_headers[":path"] = "/"; |
| 162 request_headers[":method"] = "POST"; | 170 request_headers[":method"] = "POST"; |
| 163 request_headers[":version"] = "HTTP/1.1"; | 171 request_headers[":version"] = "HTTP/1.1"; |
| 164 request_headers["content-length"] = "11"; | 172 request_headers["content-length"] = "11"; |
| 165 | 173 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 190 | 198 |
| 191 StringPiece StreamHeadersValue(const string& key) { | 199 StringPiece StreamHeadersValue(const string& key) { |
| 192 return (*stream_->mutable_headers())[key]; | 200 return (*stream_->mutable_headers())[key]; |
| 193 } | 201 } |
| 194 | 202 |
| 195 SpdyHeaderBlock response_headers_; | 203 SpdyHeaderBlock response_headers_; |
| 196 MockConnectionHelper helper_; | 204 MockConnectionHelper helper_; |
| 197 StrictMock<MockConnection>* connection_; | 205 StrictMock<MockConnection>* connection_; |
| 198 StrictMock<MockQuicServerSessionVisitor>* session_owner_; | 206 StrictMock<MockQuicServerSessionVisitor>* session_owner_; |
| 199 std::unique_ptr<QuicCryptoServerConfig> crypto_config_; | 207 std::unique_ptr<QuicCryptoServerConfig> crypto_config_; |
| 208 QuicCompressedCertsCache compressed_certs_cache_; |
| 200 StrictMock<MockQuicSimpleServerSession> session_; | 209 StrictMock<MockQuicSimpleServerSession> session_; |
| 201 QuicSimpleServerStreamPeer* stream_; // Owned by session_. | 210 QuicSimpleServerStreamPeer* stream_; // Owned by session_. |
| 202 string headers_string_; | 211 string headers_string_; |
| 203 string body_; | 212 string body_; |
| 204 }; | 213 }; |
| 205 | 214 |
| 206 INSTANTIATE_TEST_CASE_P(Tests, | 215 INSTANTIATE_TEST_CASE_P(Tests, |
| 207 QuicSimpleServerStreamTest, | 216 QuicSimpleServerStreamTest, |
| 208 ::testing::ValuesIn(QuicSupportedVersions())); | 217 ::testing::ValuesIn(QuicSupportedVersions())); |
| 209 | 218 |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 }; | 603 }; |
| 595 StringPiece data(arr, arraysize(arr)); | 604 StringPiece data(arr, arraysize(arr)); |
| 596 QuicStreamFrame frame(stream_->id(), true, 0, data); | 605 QuicStreamFrame frame(stream_->id(), true, 0, data); |
| 597 // Verify that we don't crash when we get a invalid headers in stream frame. | 606 // Verify that we don't crash when we get a invalid headers in stream frame. |
| 598 stream_->OnStreamFrame(frame); | 607 stream_->OnStreamFrame(frame); |
| 599 } | 608 } |
| 600 | 609 |
| 601 } // namespace | 610 } // namespace |
| 602 } // namespace test | 611 } // namespace test |
| 603 } // namespace net | 612 } // namespace net |
| OLD | NEW |