Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Side by Side Diff: net/tools/quic/quic_spdy_client_stream_test.cc

Issue 2422233003: Remove references to BalsaHeaders from a number of files and use SpdyHeaderBlock instead. (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/tools/quic/quic_client_bin.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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_spdy_client_stream.h" 5 #include "net/tools/quic/quic_spdy_client_stream.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
11 #include "net/quic/core/quic_utils.h" 11 #include "net/quic/core/quic_utils.h"
12 #include "net/quic/core/spdy_utils.h" 12 #include "net/quic/core/spdy_utils.h"
13 #include "net/quic/test_tools/crypto_test_utils.h" 13 #include "net/quic/test_tools/crypto_test_utils.h"
14 #include "net/quic/test_tools/quic_test_utils.h" 14 #include "net/quic/test_tools/quic_test_utils.h"
15 #include "net/tools/quic/quic_client_session.h" 15 #include "net/tools/quic/quic_client_session.h"
16 #include "net/tools/quic/spdy_balsa_utils.h"
17 #include "testing/gmock/include/gmock/gmock.h" 16 #include "testing/gmock/include/gmock/gmock.h"
18 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
19 18
20 using net::test::CryptoTestUtils; 19 using net::test::CryptoTestUtils;
21 using net::test::DefaultQuicConfig; 20 using net::test::DefaultQuicConfig;
22 using net::test::MockQuicConnection; 21 using net::test::MockQuicConnection;
23 using net::test::MockQuicConnectionHelper; 22 using net::test::MockQuicConnectionHelper;
24 using net::test::SupportedVersions; 23 using net::test::SupportedVersions;
25 using net::test::kClientDataStreamId1; 24 using net::test::kClientDataStreamId1;
26 using net::test::kServerDataStreamId1; 25 using net::test::kServerDataStreamId1;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 class StreamVisitor; 61 class StreamVisitor;
63 62
64 QuicSpdyClientStreamTest() 63 QuicSpdyClientStreamTest()
65 : connection_(new StrictMock<MockQuicConnection>(&helper_, 64 : connection_(new StrictMock<MockQuicConnection>(&helper_,
66 &alarm_factory_, 65 &alarm_factory_,
67 Perspective::IS_CLIENT)), 66 Perspective::IS_CLIENT)),
68 session_(connection_, &push_promise_index_), 67 session_(connection_, &push_promise_index_),
69 body_("hello world") { 68 body_("hello world") {
70 session_.Initialize(); 69 session_.Initialize();
71 70
72 headers_.SetResponseFirstlineFromStringPieces("HTTP/1.1", "200", "Ok"); 71 headers_[":status"] = "200";
73 headers_.ReplaceOrAppendHeader("content-length", "11"); 72 headers_["content-length"] = "11";
74 73 headers_string_ = SpdyUtils::SerializeUncompressedHeaders(headers_);
75 headers_string_ = net::SpdyBalsaUtils::SerializeResponseHeaders(headers_);
76 74
77 stream_.reset(new QuicSpdyClientStream(kClientDataStreamId1, &session_)); 75 stream_.reset(new QuicSpdyClientStream(kClientDataStreamId1, &session_));
78 stream_visitor_.reset(new StreamVisitor()); 76 stream_visitor_.reset(new StreamVisitor());
79 stream_->set_visitor(stream_visitor_.get()); 77 stream_->set_visitor(stream_visitor_.get());
80 } 78 }
81 79
82 class StreamVisitor : public QuicSpdyClientStream::Visitor { 80 class StreamVisitor : public QuicSpdyClientStream::Visitor {
83 void OnClose(QuicSpdyStream* stream) override { 81 void OnClose(QuicSpdyStream* stream) override {
84 DVLOG(1) << "stream " << stream->id(); 82 DVLOG(1) << "stream " << stream->id();
85 } 83 }
86 }; 84 };
87 85
88 MockQuicConnectionHelper helper_; 86 MockQuicConnectionHelper helper_;
89 MockAlarmFactory alarm_factory_; 87 MockAlarmFactory alarm_factory_;
90 StrictMock<MockQuicConnection>* connection_; 88 StrictMock<MockQuicConnection>* connection_;
91 QuicClientPushPromiseIndex push_promise_index_; 89 QuicClientPushPromiseIndex push_promise_index_;
92 90
93 MockQuicClientSession session_; 91 MockQuicClientSession session_;
94 std::unique_ptr<QuicSpdyClientStream> stream_; 92 std::unique_ptr<QuicSpdyClientStream> stream_;
95 std::unique_ptr<StreamVisitor> stream_visitor_; 93 std::unique_ptr<StreamVisitor> stream_visitor_;
96 BalsaHeaders headers_; 94 SpdyHeaderBlock headers_;
97 string headers_string_; 95 string headers_string_;
98 string body_; 96 string body_;
99 }; 97 };
100 98
101 TEST_F(QuicSpdyClientStreamTest, TestReceivingIllegalResponseStatusCode) { 99 TEST_F(QuicSpdyClientStreamTest, TestReceivingIllegalResponseStatusCode) {
102 headers_.ReplaceOrAppendHeader(":status", "200 ok"); 100 headers_[":status"] = "200 ok";
103 headers_string_ = SpdyBalsaUtils::SerializeResponseHeaders(headers_); 101 headers_string_ = SpdyUtils::SerializeUncompressedHeaders(headers_);
104 102
105 stream_->OnStreamHeaders(headers_string_); 103 stream_->OnStreamHeaders(headers_string_);
106 EXPECT_CALL(*connection_, 104 EXPECT_CALL(*connection_,
107 SendRstStream(stream_->id(), QUIC_BAD_APPLICATION_PAYLOAD, 0)); 105 SendRstStream(stream_->id(), QUIC_BAD_APPLICATION_PAYLOAD, 0));
108 stream_->OnStreamHeadersComplete(false, headers_string_.size()); 106 stream_->OnStreamHeadersComplete(false, headers_string_.size());
109 EXPECT_EQ(QUIC_BAD_APPLICATION_PAYLOAD, stream_->stream_error()); 107 EXPECT_EQ(QUIC_BAD_APPLICATION_PAYLOAD, stream_->stream_error());
110 } 108 }
111 109
112 TEST_F(QuicSpdyClientStreamTest, TestFraming) { 110 TEST_F(QuicSpdyClientStreamTest, TestFraming) {
113 stream_->OnStreamHeaders(headers_string_); 111 stream_->OnStreamHeaders(headers_string_);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 // Now send the body, which should close the stream as the FIN has been 173 // Now send the body, which should close the stream as the FIN has been
176 // received, as well as all data. 174 // received, as well as all data.
177 EXPECT_CALL(session_, CloseStream(stream_->id())); 175 EXPECT_CALL(session_, CloseStream(stream_->id()));
178 stream_->OnStreamFrame( 176 stream_->OnStreamFrame(
179 QuicStreamFrame(stream_->id(), /*fin=*/false, /*offset=*/0, body_)); 177 QuicStreamFrame(stream_->id(), /*fin=*/false, /*offset=*/0, body_));
180 } 178 }
181 179
182 } // namespace 180 } // namespace
183 } // namespace test 181 } // namespace test
184 } // namespace net 182 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_client_bin.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698