| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/core/quic_client_promised_info.h" | 5 #include "net/quic/core/quic_client_promised_info.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "net/quic/core/spdy_utils.h" | 10 #include "net/quic/core/spdy_utils.h" |
| 11 #include "net/quic/platform/api/quic_logging.h" | 11 #include "net/quic/platform/api/quic_logging.h" |
| 12 #include "net/quic/platform/api/quic_socket_address.h" | 12 #include "net/quic/platform/api/quic_socket_address.h" |
| 13 #include "net/quic/platform/api/quic_test.h" | 13 #include "net/quic/platform/api/quic_test.h" |
| 14 #include "net/quic/test_tools/crypto_test_utils.h" | 14 #include "net/quic/test_tools/crypto_test_utils.h" |
| 15 #include "net/quic/test_tools/quic_client_promised_info_peer.h" | 15 #include "net/quic/test_tools/quic_client_promised_info_peer.h" |
| 16 #include "net/quic/test_tools/quic_spdy_session_peer.h" | |
| 17 #include "net/test/gtest_util.h" | 16 #include "net/test/gtest_util.h" |
| 18 #include "net/tools/quic/quic_client_session.h" | 17 #include "net/tools/quic/quic_client_session.h" |
| 19 | 18 |
| 20 using std::string; | 19 using std::string; |
| 21 using testing::StrictMock; | 20 using testing::StrictMock; |
| 22 | 21 |
| 23 namespace net { | 22 namespace net { |
| 24 namespace test { | 23 namespace test { |
| 25 namespace { | 24 namespace { |
| 26 | 25 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 55 class QuicClientPromisedInfoTest : public QuicTest { | 54 class QuicClientPromisedInfoTest : public QuicTest { |
| 56 public: | 55 public: |
| 57 class StreamVisitor; | 56 class StreamVisitor; |
| 58 | 57 |
| 59 QuicClientPromisedInfoTest() | 58 QuicClientPromisedInfoTest() |
| 60 : connection_(new StrictMock<MockQuicConnection>(&helper_, | 59 : connection_(new StrictMock<MockQuicConnection>(&helper_, |
| 61 &alarm_factory_, | 60 &alarm_factory_, |
| 62 Perspective::IS_CLIENT)), | 61 Perspective::IS_CLIENT)), |
| 63 session_(connection_, &push_promise_index_), | 62 session_(connection_, &push_promise_index_), |
| 64 body_("hello world"), | 63 body_("hello world"), |
| 65 promise_id_(kInvalidStreamId) { | 64 promise_id_(kServerDataStreamId1) { |
| 66 session_.Initialize(); | 65 session_.Initialize(); |
| 67 | 66 |
| 68 headers_[":status"] = "200"; | 67 headers_[":status"] = "200"; |
| 69 headers_["content-length"] = "11"; | 68 headers_["content-length"] = "11"; |
| 70 | 69 |
| 71 stream_.reset(new QuicSpdyClientStream( | 70 stream_.reset(new QuicSpdyClientStream(kClientDataStreamId1, &session_)); |
| 72 QuicSpdySessionPeer::GetNthClientInitiatedStreamId(session_, 0), | |
| 73 &session_)); | |
| 74 stream_visitor_.reset(new StreamVisitor()); | 71 stream_visitor_.reset(new StreamVisitor()); |
| 75 stream_->set_visitor(stream_visitor_.get()); | 72 stream_->set_visitor(stream_visitor_.get()); |
| 76 | 73 |
| 77 push_promise_[":path"] = "/bar"; | 74 push_promise_[":path"] = "/bar"; |
| 78 push_promise_[":authority"] = "www.google.com"; | 75 push_promise_[":authority"] = "www.google.com"; |
| 79 push_promise_[":version"] = "HTTP/1.1"; | 76 push_promise_[":version"] = "HTTP/1.1"; |
| 80 push_promise_[":method"] = "GET"; | 77 push_promise_[":method"] = "GET"; |
| 81 push_promise_[":scheme"] = "https"; | 78 push_promise_[":scheme"] = "https"; |
| 82 | 79 |
| 83 promise_url_ = SpdyUtils::GetUrlFromHeaderBlock(push_promise_); | 80 promise_url_ = SpdyUtils::GetUrlFromHeaderBlock(push_promise_); |
| 84 | 81 |
| 85 client_request_ = push_promise_.Clone(); | 82 client_request_ = push_promise_.Clone(); |
| 86 promise_id_ = | |
| 87 QuicSpdySessionPeer::GetNthServerInitiatedStreamId(session_, 0); | |
| 88 } | 83 } |
| 89 | 84 |
| 90 class StreamVisitor : public QuicSpdyClientStream::Visitor { | 85 class StreamVisitor : public QuicSpdyClientStream::Visitor { |
| 91 void OnClose(QuicSpdyStream* stream) override { | 86 void OnClose(QuicSpdyStream* stream) override { |
| 92 QUIC_DVLOG(1) << "stream " << stream->id(); | 87 QUIC_DVLOG(1) << "stream " << stream->id(); |
| 93 } | 88 } |
| 94 }; | 89 }; |
| 95 | 90 |
| 96 void ReceivePromise(QuicStreamId id) { | 91 void ReceivePromise(QuicStreamId id) { |
| 97 auto headers = AsHeaderList(push_promise_); | 92 auto headers = AsHeaderList(push_promise_); |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 EXPECT_FALSE(delegate.rendezvous_fired()); | 305 EXPECT_FALSE(delegate.rendezvous_fired()); |
| 311 EXPECT_EQ(delegate.rendezvous_stream(), nullptr); | 306 EXPECT_EQ(delegate.rendezvous_stream(), nullptr); |
| 312 | 307 |
| 313 // Promise is gone | 308 // Promise is gone |
| 314 EXPECT_EQ(session_.GetPromisedById(promise_id_), nullptr); | 309 EXPECT_EQ(session_.GetPromisedById(promise_id_), nullptr); |
| 315 } | 310 } |
| 316 | 311 |
| 317 } // namespace | 312 } // namespace |
| 318 } // namespace test | 313 } // namespace test |
| 319 } // namespace net | 314 } // namespace net |
| OLD | NEW |