| 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/spdy/bidirectional_stream_spdy_impl.h" | 5 #include "net/spdy/bidirectional_stream_spdy_impl.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 bool on_failed_called_; | 200 bool on_failed_called_; |
| 201 | 201 |
| 202 DISALLOW_COPY_AND_ASSIGN(TestDelegateBase); | 202 DISALLOW_COPY_AND_ASSIGN(TestDelegateBase); |
| 203 }; | 203 }; |
| 204 | 204 |
| 205 } // namespace | 205 } // namespace |
| 206 | 206 |
| 207 class BidirectionalStreamSpdyImplTest : public testing::Test { | 207 class BidirectionalStreamSpdyImplTest : public testing::Test { |
| 208 public: | 208 public: |
| 209 BidirectionalStreamSpdyImplTest() | 209 BidirectionalStreamSpdyImplTest() |
| 210 : spdy_util_(kProtoHTTP2, true), | 210 : spdy_util_(true), |
| 211 session_deps_(kProtoHTTP2), | |
| 212 default_url_(kDefaultUrl), | 211 default_url_(kDefaultUrl), |
| 213 host_port_pair_(HostPortPair::FromURL(default_url_)), | 212 host_port_pair_(HostPortPair::FromURL(default_url_)), |
| 214 key_(host_port_pair_, ProxyServer::Direct(), PRIVACY_MODE_DISABLED), | 213 key_(host_port_pair_, ProxyServer::Direct(), PRIVACY_MODE_DISABLED), |
| 215 ssl_data_(SSLSocketDataProvider(ASYNC, OK)) { | 214 ssl_data_(SSLSocketDataProvider(ASYNC, OK)) { |
| 216 ssl_data_.SetNextProto(kProtoHTTP2); | 215 ssl_data_.SetNextProto(kProtoHTTP2); |
| 217 ssl_data_.cert = ImportCertFromFile(GetTestCertsDirectory(), "ok_cert.pem"); | 216 ssl_data_.cert = ImportCertFromFile(GetTestCertsDirectory(), "ok_cert.pem"); |
| 218 } | 217 } |
| 219 | 218 |
| 220 protected: | 219 protected: |
| 221 void TearDown() override { | 220 void TearDown() override { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 EXPECT_EQ(0, delegate->on_data_sent_count()); | 299 EXPECT_EQ(0, delegate->on_data_sent_count()); |
| 301 EXPECT_EQ(kProtoHTTP2, delegate->GetProtocol()); | 300 EXPECT_EQ(kProtoHTTP2, delegate->GetProtocol()); |
| 302 // BidirectionalStreamSpdyStreamJob does not count the bytes sent for |rst| | 301 // BidirectionalStreamSpdyStreamJob does not count the bytes sent for |rst| |
| 303 // because it is sent after SpdyStream::Delegate::OnClose is called. | 302 // because it is sent after SpdyStream::Delegate::OnClose is called. |
| 304 EXPECT_EQ(CountWriteBytes(writes, 1), delegate->GetTotalSentBytes()); | 303 EXPECT_EQ(CountWriteBytes(writes, 1), delegate->GetTotalSentBytes()); |
| 305 EXPECT_EQ(CountReadBytes(reads, arraysize(reads)), | 304 EXPECT_EQ(CountReadBytes(reads, arraysize(reads)), |
| 306 delegate->GetTotalReceivedBytes()); | 305 delegate->GetTotalReceivedBytes()); |
| 307 } | 306 } |
| 308 | 307 |
| 309 TEST_F(BidirectionalStreamSpdyImplTest, SendDataAfterCancelStream) { | 308 TEST_F(BidirectionalStreamSpdyImplTest, SendDataAfterCancelStream) { |
| 310 BufferedSpdyFramer framer(spdy_util_.spdy_version()); | 309 BufferedSpdyFramer framer(HTTP2); |
| 311 | 310 |
| 312 std::unique_ptr<SpdySerializedFrame> req(spdy_util_.ConstructSpdyPost( | 311 std::unique_ptr<SpdySerializedFrame> req(spdy_util_.ConstructSpdyPost( |
| 313 kDefaultUrl, 1, kBodyDataSize * 3, LOWEST, nullptr, 0)); | 312 kDefaultUrl, 1, kBodyDataSize * 3, LOWEST, nullptr, 0)); |
| 314 std::unique_ptr<SpdySerializedFrame> data_frame( | 313 std::unique_ptr<SpdySerializedFrame> data_frame( |
| 315 framer.CreateDataFrame(1, kBodyData, kBodyDataSize, DATA_FLAG_NONE)); | 314 framer.CreateDataFrame(1, kBodyData, kBodyDataSize, DATA_FLAG_NONE)); |
| 316 std::unique_ptr<SpdySerializedFrame> rst( | 315 std::unique_ptr<SpdySerializedFrame> rst( |
| 317 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_CANCEL)); | 316 spdy_util_.ConstructSpdyRstStream(1, RST_STREAM_CANCEL)); |
| 318 | 317 |
| 319 MockWrite writes[] = { | 318 MockWrite writes[] = { |
| 320 CreateMockWrite(*req, 0), CreateMockWrite(*data_frame, 3), | 319 CreateMockWrite(*req, 0), CreateMockWrite(*data_frame, 3), |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 EXPECT_FALSE(delegate->on_failed_called()); | 367 EXPECT_FALSE(delegate->on_failed_called()); |
| 369 | 368 |
| 370 EXPECT_EQ("200", delegate->response_headers().find(":status")->second); | 369 EXPECT_EQ("200", delegate->response_headers().find(":status")->second); |
| 371 EXPECT_EQ(0, delegate->on_data_read_count()); | 370 EXPECT_EQ(0, delegate->on_data_read_count()); |
| 372 EXPECT_EQ(kProtoHTTP2, delegate->GetProtocol()); | 371 EXPECT_EQ(kProtoHTTP2, delegate->GetProtocol()); |
| 373 EXPECT_EQ(0, delegate->GetTotalSentBytes()); | 372 EXPECT_EQ(0, delegate->GetTotalSentBytes()); |
| 374 EXPECT_EQ(0, delegate->GetTotalReceivedBytes()); | 373 EXPECT_EQ(0, delegate->GetTotalReceivedBytes()); |
| 375 } | 374 } |
| 376 | 375 |
| 377 } // namespace net | 376 } // namespace net |
| OLD | NEW |