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/chromium/bidirectional_stream_quic_impl.h" | 5 #include "net/quic/chromium/bidirectional_stream_quic_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 1567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1578 scoped_refptr<IOBuffer> read_buffer(new IOBuffer(kReadBufferSize)); | 1578 scoped_refptr<IOBuffer> read_buffer(new IOBuffer(kReadBufferSize)); |
1579 std::unique_ptr<TestDelegateBase> delegate( | 1579 std::unique_ptr<TestDelegateBase> delegate( |
1580 new TestDelegateBase(read_buffer.get(), kReadBufferSize)); | 1580 new TestDelegateBase(read_buffer.get(), kReadBufferSize)); |
1581 delegate->Start(&request, net_log().bound(), session()->CreateHandle()); | 1581 delegate->Start(&request, net_log().bound(), session()->CreateHandle()); |
1582 delegate->WaitUntilNextCallback(kOnStreamReady); | 1582 delegate->WaitUntilNextCallback(kOnStreamReady); |
1583 ConfirmHandshake(); | 1583 ConfirmHandshake(); |
1584 | 1584 |
1585 // Server sends a Rst. | 1585 // Server sends a Rst. |
1586 ProcessPacket(ConstructServerRstStreamPacket(1)); | 1586 ProcessPacket(ConstructServerRstStreamPacket(1)); |
1587 | 1587 |
1588 EXPECT_TRUE(delegate->on_failed_called()); | |
1589 | |
1590 TestCompletionCallback cb; | 1588 TestCompletionCallback cb; |
1591 EXPECT_THAT(delegate->ReadData(cb.callback()), | 1589 EXPECT_THAT(delegate->ReadData(cb.callback()), |
1592 IsError(ERR_QUIC_PROTOCOL_ERROR)); | 1590 IsError(ERR_QUIC_PROTOCOL_ERROR)); |
1593 | 1591 |
1594 base::RunLoop().RunUntilIdle(); | 1592 base::RunLoop().RunUntilIdle(); |
1595 | 1593 |
1596 EXPECT_THAT(delegate->error(), IsError(ERR_QUIC_PROTOCOL_ERROR)); | 1594 EXPECT_THAT(delegate->error(), IsError(ERR_QUIC_PROTOCOL_ERROR)); |
1597 EXPECT_EQ(0, delegate->on_data_read_count()); | 1595 EXPECT_EQ(0, delegate->on_data_read_count()); |
1598 EXPECT_EQ(0, delegate->on_data_sent_count()); | 1596 EXPECT_EQ(0, delegate->on_data_sent_count()); |
1599 EXPECT_EQ(static_cast<int64_t>(spdy_request_headers_frame_length), | 1597 EXPECT_EQ(static_cast<int64_t>(spdy_request_headers_frame_length), |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1642 delegate->WaitUntilNextCallback(kOnHeadersReceived); | 1640 delegate->WaitUntilNextCallback(kOnHeadersReceived); |
1643 EXPECT_EQ("200", delegate->response_headers().find(":status")->second); | 1641 EXPECT_EQ("200", delegate->response_headers().find(":status")->second); |
1644 | 1642 |
1645 TestCompletionCallback cb; | 1643 TestCompletionCallback cb; |
1646 int rv = delegate->ReadData(cb.callback()); | 1644 int rv = delegate->ReadData(cb.callback()); |
1647 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 1645 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
1648 | 1646 |
1649 // Server sends a Rst. | 1647 // Server sends a Rst. |
1650 ProcessPacket(ConstructServerRstStreamPacket(3)); | 1648 ProcessPacket(ConstructServerRstStreamPacket(3)); |
1651 | 1649 |
1652 EXPECT_TRUE(delegate->on_failed_called()); | 1650 delegate->WaitUntilNextCallback(kOnFailed); |
1653 | 1651 |
1654 EXPECT_THAT(delegate->ReadData(cb.callback()), | 1652 EXPECT_THAT(delegate->ReadData(cb.callback()), |
1655 IsError(ERR_QUIC_PROTOCOL_ERROR)); | 1653 IsError(ERR_QUIC_PROTOCOL_ERROR)); |
1656 EXPECT_THAT(delegate->error(), IsError(ERR_QUIC_PROTOCOL_ERROR)); | 1654 EXPECT_THAT(delegate->error(), IsError(ERR_QUIC_PROTOCOL_ERROR)); |
1657 EXPECT_EQ(0, delegate->on_data_read_count()); | 1655 EXPECT_EQ(0, delegate->on_data_read_count()); |
1658 EXPECT_EQ(0, delegate->on_data_sent_count()); | 1656 EXPECT_EQ(0, delegate->on_data_sent_count()); |
1659 EXPECT_EQ(static_cast<int64_t>(spdy_request_headers_frame_length), | 1657 EXPECT_EQ(static_cast<int64_t>(spdy_request_headers_frame_length), |
1660 delegate->GetTotalSentBytes()); | 1658 delegate->GetTotalSentBytes()); |
1661 EXPECT_EQ(static_cast<int64_t>(spdy_response_headers_frame_length), | 1659 EXPECT_EQ(static_cast<int64_t>(spdy_response_headers_frame_length), |
1662 delegate->GetTotalReceivedBytes()); | 1660 delegate->GetTotalReceivedBytes()); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1696 ProcessPacket(ConstructResponseHeadersPacket( | 1694 ProcessPacket(ConstructResponseHeadersPacket( |
1697 2, !kFin, std::move(response_headers), | 1695 2, !kFin, std::move(response_headers), |
1698 &spdy_response_headers_frame_length, &offset)); | 1696 &spdy_response_headers_frame_length, &offset)); |
1699 | 1697 |
1700 delegate->WaitUntilNextCallback(kOnHeadersReceived); | 1698 delegate->WaitUntilNextCallback(kOnHeadersReceived); |
1701 TestCompletionCallback cb; | 1699 TestCompletionCallback cb; |
1702 int rv = delegate->ReadData(cb.callback()); | 1700 int rv = delegate->ReadData(cb.callback()); |
1703 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); | 1701 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); |
1704 session()->connection()->CloseConnection( | 1702 session()->connection()->CloseConnection( |
1705 QUIC_NO_ERROR, "test", ConnectionCloseBehavior::SILENT_CLOSE); | 1703 QUIC_NO_ERROR, "test", ConnectionCloseBehavior::SILENT_CLOSE); |
| 1704 delegate->WaitUntilNextCallback(kOnFailed); |
1706 EXPECT_TRUE(delegate->on_failed_called()); | 1705 EXPECT_TRUE(delegate->on_failed_called()); |
1707 | 1706 |
1708 // Try to send data after OnFailed(), should not get called back. | 1707 // Try to send data after OnFailed(), should not get called back. |
1709 scoped_refptr<StringIOBuffer> buf(new StringIOBuffer(kUploadData)); | 1708 scoped_refptr<StringIOBuffer> buf(new StringIOBuffer(kUploadData)); |
1710 delegate->SendData(buf, buf->size(), false); | 1709 delegate->SendData(buf, buf->size(), false); |
1711 base::RunLoop().RunUntilIdle(); | |
1712 | 1710 |
1713 EXPECT_THAT(delegate->ReadData(cb.callback()), IsError(ERR_UNEXPECTED)); | 1711 EXPECT_THAT(delegate->ReadData(cb.callback()), |
1714 EXPECT_THAT(delegate->error(), IsError(ERR_UNEXPECTED)); | 1712 IsError(ERR_QUIC_PROTOCOL_ERROR)); |
| 1713 EXPECT_THAT(delegate->error(), IsError(ERR_QUIC_PROTOCOL_ERROR)); |
1715 EXPECT_EQ(0, delegate->on_data_read_count()); | 1714 EXPECT_EQ(0, delegate->on_data_read_count()); |
1716 EXPECT_EQ(0, delegate->on_data_sent_count()); | 1715 EXPECT_EQ(0, delegate->on_data_sent_count()); |
1717 EXPECT_EQ(kProtoQUIC, delegate->GetProtocol()); | 1716 EXPECT_EQ(kProtoQUIC, delegate->GetProtocol()); |
1718 EXPECT_EQ(static_cast<int64_t>(spdy_request_headers_frame_length), | 1717 EXPECT_EQ(static_cast<int64_t>(spdy_request_headers_frame_length), |
1719 delegate->GetTotalSentBytes()); | 1718 delegate->GetTotalSentBytes()); |
1720 EXPECT_EQ(static_cast<int64_t>(spdy_response_headers_frame_length), | 1719 EXPECT_EQ(static_cast<int64_t>(spdy_response_headers_frame_length), |
1721 delegate->GetTotalReceivedBytes()); | 1720 delegate->GetTotalReceivedBytes()); |
1722 } | 1721 } |
1723 | 1722 |
1724 TEST_P(BidirectionalStreamQuicImplTest, SessionClosedBeforeStartConfirmed) { | 1723 TEST_P(BidirectionalStreamQuicImplTest, SessionClosedBeforeStartConfirmed) { |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2108 | 2107 |
2109 base::RunLoop().RunUntilIdle(); | 2108 base::RunLoop().RunUntilIdle(); |
2110 | 2109 |
2111 EXPECT_EQ(1, delegate->on_data_read_count()); | 2110 EXPECT_EQ(1, delegate->on_data_read_count()); |
2112 EXPECT_EQ(0, delegate->on_data_sent_count()); | 2111 EXPECT_EQ(0, delegate->on_data_sent_count()); |
2113 } | 2112 } |
2114 | 2113 |
2115 } // namespace test | 2114 } // namespace test |
2116 | 2115 |
2117 } // namespace net | 2116 } // namespace net |
OLD | NEW |