| 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/chromium/quic_chromium_client_stream.h" | 5 #include "net/quic/chromium/quic_chromium_client_stream.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| 11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "net/base/io_buffer.h" | 12 #include "net/base/io_buffer.h" |
| 13 #include "net/base/net_errors.h" | 13 #include "net/base/net_errors.h" |
| 14 #include "net/base/test_completion_callback.h" | 14 #include "net/base/test_completion_callback.h" |
| 15 #include "net/quic/chromium/quic_chromium_client_session.h" | 15 #include "net/quic/chromium/quic_chromium_client_session.h" |
| 16 #include "net/quic/core/quic_client_session_base.h" | 16 #include "net/quic/core/quic_client_session_base.h" |
| 17 #include "net/quic/core/quic_utils.h" | 17 #include "net/quic/core/quic_utils.h" |
| 18 #include "net/quic/core/spdy_utils.h" | 18 #include "net/quic/core/spdy_utils.h" |
| 19 #include "net/quic/test_tools/crypto_test_utils.h" | 19 #include "net/quic/test_tools/crypto_test_utils.h" |
| 20 #include "net/quic/test_tools/quic_spdy_session_peer.h" |
| 20 #include "net/quic/test_tools/quic_test_utils.h" | 21 #include "net/quic/test_tools/quic_test_utils.h" |
| 21 #include "net/test/gtest_util.h" | 22 #include "net/test/gtest_util.h" |
| 22 #include "testing/gmock/include/gmock/gmock.h" | 23 #include "testing/gmock/include/gmock/gmock.h" |
| 23 #include "testing/gmock_mutant.h" | 24 #include "testing/gmock_mutant.h" |
| 24 | 25 |
| 25 using testing::AnyNumber; | 26 using testing::AnyNumber; |
| 26 using testing::CreateFunctor; | 27 using testing::CreateFunctor; |
| 27 using testing::Invoke; | 28 using testing::Invoke; |
| 28 using testing::Return; | 29 using testing::Return; |
| 29 using testing::StrEq; | 30 using testing::StrEq; |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 QuicHeaderList ProcessHeadersFull(const SpdyHeaderBlock& headers) { | 240 QuicHeaderList ProcessHeadersFull(const SpdyHeaderBlock& headers) { |
| 240 QuicHeaderList h = ProcessHeaders(headers); | 241 QuicHeaderList h = ProcessHeaders(headers); |
| 241 EXPECT_CALL(delegate_, | 242 EXPECT_CALL(delegate_, |
| 242 OnHeadersAvailableMock(_, h.uncompressed_header_bytes())); | 243 OnHeadersAvailableMock(_, h.uncompressed_header_bytes())); |
| 243 base::RunLoop().RunUntilIdle(); | 244 base::RunLoop().RunUntilIdle(); |
| 244 EXPECT_EQ(headers, delegate_.headers_); | 245 EXPECT_EQ(headers, delegate_.headers_); |
| 245 EXPECT_TRUE(stream_->header_list().empty()); | 246 EXPECT_TRUE(stream_->header_list().empty()); |
| 246 return h; | 247 return h; |
| 247 } | 248 } |
| 248 | 249 |
| 250 QuicStreamId GetNthClientInitiatedStreamId(int n) { |
| 251 return QuicSpdySessionPeer::GetNthClientInitiatedStreamId(session_, n); |
| 252 } |
| 253 |
| 254 QuicStreamId GetNthServerInitiatedStreamId(int n) { |
| 255 return QuicSpdySessionPeer::GetNthServerInitiatedStreamId(session_, n); |
| 256 } |
| 257 |
| 249 QuicCryptoClientConfig crypto_config_; | 258 QuicCryptoClientConfig crypto_config_; |
| 250 testing::StrictMock<MockDelegate> delegate_; | 259 testing::StrictMock<MockDelegate> delegate_; |
| 251 MockQuicConnectionHelper helper_; | 260 MockQuicConnectionHelper helper_; |
| 252 MockAlarmFactory alarm_factory_; | 261 MockAlarmFactory alarm_factory_; |
| 253 MockQuicClientSessionBase session_; | 262 MockQuicClientSessionBase session_; |
| 254 QuicChromiumClientStream* stream_; | 263 QuicChromiumClientStream* stream_; |
| 255 SpdyHeaderBlock headers_; | 264 SpdyHeaderBlock headers_; |
| 256 QuicClientPushPromiseIndex push_promise_index_; | 265 QuicClientPushPromiseIndex push_promise_index_; |
| 257 }; | 266 }; |
| 258 | 267 |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 .WillOnce(Return(QuicConsumedData(buf2->size(), true))); | 595 .WillOnce(Return(QuicConsumedData(buf2->size(), true))); |
| 587 stream_->OnCanWrite(); | 596 stream_->OnCanWrite(); |
| 588 ASSERT_TRUE(callback.have_result()); | 597 ASSERT_TRUE(callback.have_result()); |
| 589 EXPECT_THAT(callback.WaitForResult(), IsOk()); | 598 EXPECT_THAT(callback.WaitForResult(), IsOk()); |
| 590 } | 599 } |
| 591 | 600 |
| 592 TEST_P(QuicChromiumClientStreamTest, HeadersBeforeDelegate) { | 601 TEST_P(QuicChromiumClientStreamTest, HeadersBeforeDelegate) { |
| 593 // We don't use stream_ because we want an incoming server push | 602 // We don't use stream_ because we want an incoming server push |
| 594 // stream. | 603 // stream. |
| 595 QuicChromiumClientStream* stream = new QuicChromiumClientStream( | 604 QuicChromiumClientStream* stream = new QuicChromiumClientStream( |
| 596 kServerDataStreamId1, &session_, NetLogWithSource()); | 605 GetNthServerInitiatedStreamId(0), &session_, NetLogWithSource()); |
| 597 session_.ActivateStream(base::WrapUnique(stream)); | 606 session_.ActivateStream(base::WrapUnique(stream)); |
| 598 | 607 |
| 599 InitializeHeaders(); | 608 InitializeHeaders(); |
| 600 stream->SetDelegate(&delegate_); | 609 stream->SetDelegate(&delegate_); |
| 601 ProcessHeadersFull(headers_); | 610 ProcessHeadersFull(headers_); |
| 602 | 611 |
| 603 // Times(2) because OnClose will be called for stream and stream_. | 612 // Times(2) because OnClose will be called for stream and stream_. |
| 604 EXPECT_CALL(delegate_, OnClose()).Times(2); | 613 EXPECT_CALL(delegate_, OnClose()).Times(2); |
| 605 } | 614 } |
| 606 | 615 |
| 607 } // namespace | 616 } // namespace |
| 608 } // namespace test | 617 } // namespace test |
| 609 } // namespace net | 618 } // namespace net |
| OLD | NEW |