Connect PPAPI IPC channels for non-SFI mode.
[chromium-blink-merge.git] / net / tools / quic / quic_spdy_client_stream_test.cc
blobbad9080494defb2b81941775fa2dc1bd1da1185b
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.
5 #include "net/tools/quic/quic_spdy_client_stream.h"
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/tools/epoll_server/epoll_server.h"
11 #include "net/tools/quic/quic_client_session.h"
12 #include "net/tools/quic/quic_spdy_client_stream.h"
13 #include "net/tools/quic/spdy_utils.h"
14 #include "net/tools/quic/test_tools/quic_test_utils.h"
15 #include "testing/gmock/include/gmock/gmock.h"
16 #include "testing/gtest/include/gtest/gtest.h"
18 using net::test::DefaultQuicConfig;
19 using net::test::SupportedVersions;
20 using testing::TestWithParam;
21 using testing::StrictMock;
23 namespace net {
24 namespace tools {
25 namespace test {
26 namespace {
28 class QuicSpdyClientStreamTest : public TestWithParam<QuicVersion> {
29 public:
30 QuicSpdyClientStreamTest()
31 : connection_(new StrictMock<MockConnection>(
32 false, SupportedVersions(GetParam()))),
33 session_("example.com", DefaultQuicConfig(), connection_,
34 &crypto_config_),
35 body_("hello world") {
36 crypto_config_.SetDefaults();
38 headers_.SetResponseFirstlineFromStringPieces("HTTP/1.1", "200", "Ok");
39 headers_.ReplaceOrAppendHeader("content-length", "11");
41 headers_string_ = SpdyUtils::SerializeResponseHeaders(headers_);
42 stream_.reset(new QuicSpdyClientStream(3, &session_));
45 StrictMock<MockConnection>* connection_;
46 QuicClientSession session_;
47 scoped_ptr<QuicSpdyClientStream> stream_;
48 BalsaHeaders headers_;
49 string headers_string_;
50 string body_;
51 QuicCryptoClientConfig crypto_config_;
54 INSTANTIATE_TEST_CASE_P(Tests, QuicSpdyClientStreamTest,
55 ::testing::ValuesIn(QuicSupportedVersions()));
57 TEST_P(QuicSpdyClientStreamTest, TestFraming) {
58 EXPECT_EQ(headers_string_.size(), stream_->ProcessData(
59 headers_string_.c_str(), headers_string_.size()));
60 EXPECT_EQ(body_.size(),
61 stream_->ProcessData(body_.c_str(), body_.size()));
62 EXPECT_EQ(200u, stream_->headers().parsed_response_code());
63 EXPECT_EQ(body_, stream_->data());
66 TEST_P(QuicSpdyClientStreamTest, TestFramingOnePacket) {
67 string message = headers_string_ + body_;
69 EXPECT_EQ(message.size(), stream_->ProcessData(
70 message.c_str(), message.size()));
71 EXPECT_EQ(200u, stream_->headers().parsed_response_code());
72 EXPECT_EQ(body_, stream_->data());
75 TEST_P(QuicSpdyClientStreamTest, DISABLED_TestFramingExtraData) {
76 string large_body = "hello world!!!!!!";
78 EXPECT_EQ(headers_string_.size(), stream_->ProcessData(
79 headers_string_.c_str(), headers_string_.size()));
80 // The headers should parse successfully.
81 EXPECT_EQ(QUIC_STREAM_NO_ERROR, stream_->stream_error());
82 EXPECT_EQ(200u, stream_->headers().parsed_response_code());
84 EXPECT_CALL(*connection_,
85 SendRstStream(stream_->id(), QUIC_BAD_APPLICATION_PAYLOAD, 0));
86 stream_->ProcessData(large_body.c_str(), large_body.size());
88 EXPECT_NE(QUIC_STREAM_NO_ERROR, stream_->stream_error());
91 TEST_P(QuicSpdyClientStreamTest, TestNoBidirectionalStreaming) {
92 QuicStreamFrame frame(3, false, 3, MakeIOVector("asd"));
94 EXPECT_FALSE(stream_->write_side_closed());
95 EXPECT_TRUE(stream_->OnStreamFrame(frame));
96 EXPECT_TRUE(stream_->write_side_closed());
99 } // namespace
100 } // namespace test
101 } // namespace tools
102 } // namespace net