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/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 class QuicChromiumClientStreamTest | 165 class QuicChromiumClientStreamTest |
166 : public ::testing::TestWithParam<QuicVersion> { | 166 : public ::testing::TestWithParam<QuicVersion> { |
167 public: | 167 public: |
168 QuicChromiumClientStreamTest() | 168 QuicChromiumClientStreamTest() |
169 : crypto_config_(CryptoTestUtils::ProofVerifierForTesting()), | 169 : crypto_config_(CryptoTestUtils::ProofVerifierForTesting()), |
170 session_(new MockQuicConnection(&helper_, | 170 session_(new MockQuicConnection(&helper_, |
171 &alarm_factory_, | 171 &alarm_factory_, |
172 Perspective::IS_CLIENT, | 172 Perspective::IS_CLIENT, |
173 SupportedVersions(GetParam())), | 173 SupportedVersions(GetParam())), |
174 &push_promise_index_) { | 174 &push_promise_index_) { |
175 stream_ = | 175 stream_ = new QuicChromiumClientStream(kTestStreamId, &session_, |
176 new QuicChromiumClientStream(kTestStreamId, &session_, BoundNetLog()); | 176 NetLogWithSource()); |
177 session_.ActivateStream(stream_); | 177 session_.ActivateStream(stream_); |
178 stream_->SetDelegate(&delegate_); | 178 stream_->SetDelegate(&delegate_); |
179 } | 179 } |
180 | 180 |
181 void InitializeHeaders() { | 181 void InitializeHeaders() { |
182 headers_[":host"] = "www.google.com"; | 182 headers_[":host"] = "www.google.com"; |
183 headers_[":path"] = "/index.hml"; | 183 headers_[":path"] = "/index.hml"; |
184 headers_[":scheme"] = "https"; | 184 headers_[":scheme"] = "https"; |
185 headers_["cookie"] = | 185 headers_["cookie"] = |
186 "__utma=208381060.1228362404.1372200928.1372200928.1372200928.1; " | 186 "__utma=208381060.1228362404.1372200928.1372200928.1372200928.1; " |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 .WillOnce(Return(QuicConsumedData(buf2->size(), true))); | 531 .WillOnce(Return(QuicConsumedData(buf2->size(), true))); |
532 stream_->OnCanWrite(); | 532 stream_->OnCanWrite(); |
533 ASSERT_TRUE(callback.have_result()); | 533 ASSERT_TRUE(callback.have_result()); |
534 EXPECT_THAT(callback.WaitForResult(), IsOk()); | 534 EXPECT_THAT(callback.WaitForResult(), IsOk()); |
535 } | 535 } |
536 | 536 |
537 TEST_P(QuicChromiumClientStreamTest, HeadersBeforeDelegate) { | 537 TEST_P(QuicChromiumClientStreamTest, HeadersBeforeDelegate) { |
538 // We don't use stream_ because we want an incoming server push | 538 // We don't use stream_ because we want an incoming server push |
539 // stream. | 539 // stream. |
540 QuicChromiumClientStream* stream = new QuicChromiumClientStream( | 540 QuicChromiumClientStream* stream = new QuicChromiumClientStream( |
541 kServerDataStreamId1, &session_, BoundNetLog()); | 541 kServerDataStreamId1, &session_, NetLogWithSource()); |
542 session_.ActivateStream(stream); | 542 session_.ActivateStream(stream); |
543 | 543 |
544 InitializeHeaders(); | 544 InitializeHeaders(); |
545 std::string uncompressed_headers = | 545 std::string uncompressed_headers = |
546 SpdyUtils::SerializeUncompressedHeaders(headers_); | 546 SpdyUtils::SerializeUncompressedHeaders(headers_); |
547 stream->OnStreamHeaders(uncompressed_headers); | 547 stream->OnStreamHeaders(uncompressed_headers); |
548 stream->OnStreamHeadersComplete(false, uncompressed_headers.length()); | 548 stream->OnStreamHeadersComplete(false, uncompressed_headers.length()); |
549 EXPECT_TRUE(stream->decompressed_headers().empty()); | 549 EXPECT_TRUE(stream->decompressed_headers().empty()); |
550 | 550 |
551 EXPECT_CALL(delegate_, | 551 EXPECT_CALL(delegate_, |
552 OnHeadersAvailableMock(_, uncompressed_headers.length())); | 552 OnHeadersAvailableMock(_, uncompressed_headers.length())); |
553 stream->SetDelegate(&delegate_); | 553 stream->SetDelegate(&delegate_); |
554 base::RunLoop().RunUntilIdle(); | 554 base::RunLoop().RunUntilIdle(); |
555 EXPECT_EQ(headers_, delegate_.headers_); | 555 EXPECT_EQ(headers_, delegate_.headers_); |
556 | 556 |
557 // Times(2) because OnClose will be called for stream and stream_. | 557 // Times(2) because OnClose will be called for stream and stream_. |
558 EXPECT_CALL(delegate_, OnClose()).Times(2); | 558 EXPECT_CALL(delegate_, OnClose()).Times(2); |
559 } | 559 } |
560 | 560 |
561 } // namespace | 561 } // namespace |
562 } // namespace test | 562 } // namespace test |
563 } // namespace net | 563 } // namespace net |
OLD | NEW |