| 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_chromium_client_stream.h" | 5 #include "net/quic/quic_chromium_client_stream.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "net/base/io_buffer.h" | 10 #include "net/base/io_buffer.h" |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 .WillByDefault(testing::Return(QuicConsumedData(0, false))); | 137 .WillByDefault(testing::Return(QuicConsumedData(0, false))); |
| 138 } | 138 } |
| 139 | 139 |
| 140 MockQuicClientSessionBase::~MockQuicClientSessionBase() {} | 140 MockQuicClientSessionBase::~MockQuicClientSessionBase() {} |
| 141 | 141 |
| 142 class QuicChromiumClientStreamTest | 142 class QuicChromiumClientStreamTest |
| 143 : public ::testing::TestWithParam<QuicVersion> { | 143 : public ::testing::TestWithParam<QuicVersion> { |
| 144 public: | 144 public: |
| 145 QuicChromiumClientStreamTest() | 145 QuicChromiumClientStreamTest() |
| 146 : crypto_config_(CryptoTestUtils::ProofVerifierForTesting()), | 146 : crypto_config_(CryptoTestUtils::ProofVerifierForTesting()), |
| 147 session_(new MockConnection(&helper_, | 147 session_(new MockQuicConnection(&helper_, |
| 148 &alarm_factory_, | 148 &alarm_factory_, |
| 149 Perspective::IS_CLIENT, | 149 Perspective::IS_CLIENT, |
| 150 SupportedVersions(GetParam())), | 150 SupportedVersions(GetParam())), |
| 151 &push_promise_index_) { | 151 &push_promise_index_) { |
| 152 stream_ = | 152 stream_ = |
| 153 new QuicChromiumClientStream(kTestStreamId, &session_, BoundNetLog()); | 153 new QuicChromiumClientStream(kTestStreamId, &session_, BoundNetLog()); |
| 154 session_.ActivateStream(stream_); | 154 session_.ActivateStream(stream_); |
| 155 stream_->SetDelegate(&delegate_); | 155 stream_->SetDelegate(&delegate_); |
| 156 } | 156 } |
| 157 | 157 |
| 158 void InitializeHeaders() { | 158 void InitializeHeaders() { |
| 159 headers_[":host"] = "www.google.com"; | 159 headers_[":host"] = "www.google.com"; |
| 160 headers_[":path"] = "/index.hml"; | 160 headers_[":path"] = "/index.hml"; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 188 void ReadData(StringPiece expected_data) { | 188 void ReadData(StringPiece expected_data) { |
| 189 scoped_refptr<IOBuffer> buffer(new IOBuffer(expected_data.length() + 1)); | 189 scoped_refptr<IOBuffer> buffer(new IOBuffer(expected_data.length() + 1)); |
| 190 EXPECT_EQ(static_cast<int>(expected_data.length()), | 190 EXPECT_EQ(static_cast<int>(expected_data.length()), |
| 191 stream_->Read(buffer.get(), expected_data.length() + 1)); | 191 stream_->Read(buffer.get(), expected_data.length() + 1)); |
| 192 EXPECT_EQ(expected_data, | 192 EXPECT_EQ(expected_data, |
| 193 StringPiece(buffer->data(), expected_data.length())); | 193 StringPiece(buffer->data(), expected_data.length())); |
| 194 } | 194 } |
| 195 | 195 |
| 196 QuicCryptoClientConfig crypto_config_; | 196 QuicCryptoClientConfig crypto_config_; |
| 197 testing::StrictMock<MockDelegate> delegate_; | 197 testing::StrictMock<MockDelegate> delegate_; |
| 198 MockConnectionHelper helper_; | 198 MockQuicConnectionHelper helper_; |
| 199 MockAlarmFactory alarm_factory_; | 199 MockAlarmFactory alarm_factory_; |
| 200 MockQuicClientSessionBase session_; | 200 MockQuicClientSessionBase session_; |
| 201 QuicChromiumClientStream* stream_; | 201 QuicChromiumClientStream* stream_; |
| 202 SpdyHeaderBlock headers_; | 202 SpdyHeaderBlock headers_; |
| 203 QuicClientPushPromiseIndex push_promise_index_; | 203 QuicClientPushPromiseIndex push_promise_index_; |
| 204 }; | 204 }; |
| 205 | 205 |
| 206 INSTANTIATE_TEST_CASE_P(Version, | 206 INSTANTIATE_TEST_CASE_P(Version, |
| 207 QuicChromiumClientStreamTest, | 207 QuicChromiumClientStreamTest, |
| 208 ::testing::ValuesIn(QuicSupportedVersions())); | 208 ::testing::ValuesIn(QuicSupportedVersions())); |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 stream->SetDelegate(&delegate_); | 530 stream->SetDelegate(&delegate_); |
| 531 base::MessageLoop::current()->RunUntilIdle(); | 531 base::MessageLoop::current()->RunUntilIdle(); |
| 532 | 532 |
| 533 // Times(2) because OnClose will be called for stream and stream_. | 533 // Times(2) because OnClose will be called for stream and stream_. |
| 534 EXPECT_CALL(delegate_, OnClose(QUIC_NO_ERROR)).Times(2); | 534 EXPECT_CALL(delegate_, OnClose(QUIC_NO_ERROR)).Times(2); |
| 535 } | 535 } |
| 536 | 536 |
| 537 } // namespace | 537 } // namespace |
| 538 } // namespace test | 538 } // namespace test |
| 539 } // namespace net | 539 } // namespace net |
| OLD | NEW |