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

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

Issue 1035533006: Unify the QUIC client classes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ssize_t Created 5 years, 9 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_simple_client_stream.cc ('k') | net/tools/quic/quic_spdy_client_stream.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "net/tools/quic/quic_simple_client_stream.h"
6
7 #include "base/strings/string_number_conversions.h"
8 #include "net/quic/quic_utils.h"
9 #include "net/quic/test_tools/quic_test_utils.h"
10 #include "net/spdy/spdy_http_utils.h"
11 #include "net/tools/quic/quic_simple_client_session.h"
12 #include "net/tools/quic/spdy_utils.h"
13 #include "net/tools/quic/test_tools/quic_test_utils.h"
14 #include "testing/gmock/include/gmock/gmock.h"
15 #include "testing/gtest/include/gtest/gtest.h"
16
17 using net::test::DefaultQuicConfig;
18 using net::test::MockConnection;
19 using net::test::SupportedVersions;
20 using std::string;
21 using testing::StrictMock;
22 using testing::TestWithParam;
23
24 namespace net {
25 namespace tools {
26 namespace test {
27 namespace {
28
29 class QuicSimpleClientStreamTest : public TestWithParam<QuicVersion> {
30 public:
31 QuicSimpleClientStreamTest()
32 : connection_(
33 new StrictMock<MockConnection>(Perspective::IS_CLIENT,
34 SupportedVersions(GetParam()))),
35 session_(DefaultQuicConfig(), connection_),
36 headers_(new HttpResponseHeaders("")),
37 body_("hello world") {
38 session_.InitializeSession(
39 QuicServerId("example.com", 80, false, PRIVACY_MODE_DISABLED),
40 &crypto_config_);
41
42 headers_->ReplaceStatusLine("HTTP/1.1 200 Ok");
43 headers_->AddHeader("content-length: 11");
44
45 SpdyHeaderBlock header_block;
46 CreateSpdyHeadersFromHttpResponse(*headers_, SPDY3, &header_block);
47 headers_string_ = SpdyUtils::SerializeUncompressedHeaders(header_block);
48
49 // New streams rely on having the peer's flow control receive window
50 // negotiated in the config.
51 session_.config()->SetInitialStreamFlowControlWindowToSend(
52 kInitialStreamFlowControlWindowForTest);
53 session_.config()->SetInitialSessionFlowControlWindowToSend(
54 kInitialSessionFlowControlWindowForTest);
55 stream_.reset(new QuicSimpleClientStream(3, &session_));
56 }
57
58 StrictMock<MockConnection>* connection_;
59 QuicSimpleClientSession session_;
60 scoped_ptr<QuicSimpleClientStream> stream_;
61 scoped_refptr<HttpResponseHeaders> headers_;
62 string headers_string_;
63 string body_;
64 QuicCryptoClientConfig crypto_config_;
65 };
66
67 INSTANTIATE_TEST_CASE_P(Tests, QuicSimpleClientStreamTest,
68 ::testing::ValuesIn(QuicSupportedVersions()));
69
70 TEST_P(QuicSimpleClientStreamTest, TestFraming) {
71 EXPECT_EQ(headers_string_.size(), stream_->ProcessData(
72 headers_string_.c_str(), headers_string_.size()));
73 EXPECT_EQ(body_.size(),
74 stream_->ProcessData(body_.c_str(), body_.size()));
75 EXPECT_EQ(200, stream_->headers()->response_code());
76 EXPECT_EQ(body_, stream_->data());
77 }
78
79 TEST_P(QuicSimpleClientStreamTest, TestFramingOnePacket) {
80 string message = headers_string_ + body_;
81
82 EXPECT_EQ(message.size(), stream_->ProcessData(
83 message.c_str(), message.size()));
84 EXPECT_EQ(200, stream_->headers()->response_code());
85 EXPECT_EQ(body_, stream_->data());
86 }
87
88 TEST_P(QuicSimpleClientStreamTest, DISABLED_TestFramingExtraData) {
89 string large_body = "hello world!!!!!!";
90
91 EXPECT_EQ(headers_string_.size(), stream_->ProcessData(
92 headers_string_.c_str(), headers_string_.size()));
93 // The headers should parse successfully.
94 EXPECT_EQ(QUIC_STREAM_NO_ERROR, stream_->stream_error());
95 EXPECT_EQ(200, stream_->headers()->response_code());
96
97 EXPECT_CALL(*connection_,
98 SendRstStream(stream_->id(), QUIC_BAD_APPLICATION_PAYLOAD, 0));
99 stream_->ProcessData(large_body.c_str(), large_body.size());
100
101 EXPECT_NE(QUIC_STREAM_NO_ERROR, stream_->stream_error());
102 }
103
104 TEST_P(QuicSimpleClientStreamTest, TestNoBidirectionalStreaming) {
105 QuicStreamFrame frame(3, false, 3, MakeIOVector("asd"));
106
107 EXPECT_FALSE(stream_->write_side_closed());
108 stream_->OnStreamFrame(frame);
109 EXPECT_TRUE(stream_->write_side_closed());
110 }
111
112 } // namespace
113 } // namespace test
114 } // namespace tools
115 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_simple_client_stream.cc ('k') | net/tools/quic/quic_spdy_client_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698