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

Side by Side Diff: net/quic/chromium/bidirectional_stream_quic_impl_unittest.cc

Issue 2918663002: Clean up error handling in BidirectionalStreamQuicImpl::Start (Closed)
Patch Set: Fix test Created 3 years, 6 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/quic/chromium/bidirectional_stream_quic_impl.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 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 1611 matching lines...) Expand 10 before | Expand all | Expand 10 after
1622 EXPECT_THAT(delegate->error(), IsError(ERR_UNEXPECTED)); 1622 EXPECT_THAT(delegate->error(), IsError(ERR_UNEXPECTED));
1623 EXPECT_EQ(0, delegate->on_data_read_count()); 1623 EXPECT_EQ(0, delegate->on_data_read_count());
1624 EXPECT_EQ(0, delegate->on_data_sent_count()); 1624 EXPECT_EQ(0, delegate->on_data_sent_count());
1625 EXPECT_EQ(kProtoQUIC, delegate->GetProtocol()); 1625 EXPECT_EQ(kProtoQUIC, delegate->GetProtocol());
1626 EXPECT_EQ(static_cast<int64_t>(spdy_request_headers_frame_length), 1626 EXPECT_EQ(static_cast<int64_t>(spdy_request_headers_frame_length),
1627 delegate->GetTotalSentBytes()); 1627 delegate->GetTotalSentBytes());
1628 EXPECT_EQ(static_cast<int64_t>(spdy_response_headers_frame_length), 1628 EXPECT_EQ(static_cast<int64_t>(spdy_response_headers_frame_length),
1629 delegate->GetTotalReceivedBytes()); 1629 delegate->GetTotalReceivedBytes());
1630 } 1630 }
1631 1631
1632 TEST_P(BidirectionalStreamQuicImplTest, SessionClosedBeforeStartConfirmed) {
1633 SetRequest("POST", "/", DEFAULT_PRIORITY);
1634 Initialize();
1635
1636 BidirectionalStreamRequestInfo request;
1637 request.method = "POST";
1638 request.url = GURL("http://www.google.com/");
1639 request.end_stream_on_headers = false;
1640 request.priority = DEFAULT_PRIORITY;
1641
1642 ConfirmHandshake();
1643 session()->connection()->CloseConnection(
1644 QUIC_NO_ERROR, "test", ConnectionCloseBehavior::SILENT_CLOSE);
1645
1646 scoped_refptr<IOBuffer> read_buffer(new IOBuffer(kReadBufferSize));
1647 std::unique_ptr<TestDelegateBase> delegate(
1648 new TestDelegateBase(read_buffer.get(), kReadBufferSize));
1649 delegate->Start(&request, net_log().bound(), session()->CreateHandle());
1650 delegate->WaitUntilNextCallback(); // OnFailed
1651 EXPECT_TRUE(delegate->on_failed_called());
1652 EXPECT_THAT(delegate->error(), IsError(ERR_CONNECTION_CLOSED));
1653 }
1654
1655 TEST_P(BidirectionalStreamQuicImplTest, SessionClosedBeforeStartNotConfirmed) {
1656 SetRequest("POST", "/", DEFAULT_PRIORITY);
1657 Initialize();
1658
1659 session()->connection()->CloseConnection(
1660 QUIC_NO_ERROR, "test", ConnectionCloseBehavior::SILENT_CLOSE);
1661
1662 BidirectionalStreamRequestInfo request;
1663 request.method = "POST";
1664 request.url = GURL("http://www.google.com/");
1665 request.end_stream_on_headers = false;
1666 request.priority = DEFAULT_PRIORITY;
1667
1668 scoped_refptr<IOBuffer> read_buffer(new IOBuffer(kReadBufferSize));
1669 std::unique_ptr<TestDelegateBase> delegate(
1670 new TestDelegateBase(read_buffer.get(), kReadBufferSize));
1671 delegate->Start(&request, net_log().bound(), session()->CreateHandle());
1672 delegate->WaitUntilNextCallback(); // OnFailed
1673 EXPECT_TRUE(delegate->on_failed_called());
1674 EXPECT_THAT(delegate->error(), IsError(ERR_QUIC_HANDSHAKE_FAILED));
1675 }
1676
1632 TEST_P(BidirectionalStreamQuicImplTest, SessionCloseDuringOnStreamReady) { 1677 TEST_P(BidirectionalStreamQuicImplTest, SessionCloseDuringOnStreamReady) {
1633 SetRequest("POST", "/", DEFAULT_PRIORITY); 1678 SetRequest("POST", "/", DEFAULT_PRIORITY);
1634 QuicStreamOffset header_stream_offset = 0; 1679 QuicStreamOffset header_stream_offset = 0;
1635 AddWrite(ConstructInitialSettingsPacket(1, &header_stream_offset)); 1680 AddWrite(ConstructInitialSettingsPacket(1, &header_stream_offset));
1636 AddWriteError(SYNCHRONOUS, ERR_CONNECTION_REFUSED); 1681 AddWriteError(SYNCHRONOUS, ERR_CONNECTION_REFUSED);
1637 1682
1638 Initialize(); 1683 Initialize();
1639 1684
1640 BidirectionalStreamRequestInfo request; 1685 BidirectionalStreamRequestInfo request;
1641 request.method = "POST"; 1686 request.method = "POST";
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
1971 2016
1972 base::RunLoop().RunUntilIdle(); 2017 base::RunLoop().RunUntilIdle();
1973 2018
1974 EXPECT_EQ(1, delegate->on_data_read_count()); 2019 EXPECT_EQ(1, delegate->on_data_read_count());
1975 EXPECT_EQ(0, delegate->on_data_sent_count()); 2020 EXPECT_EQ(0, delegate->on_data_sent_count());
1976 } 2021 }
1977 2022
1978 } // namespace test 2023 } // namespace test
1979 2024
1980 } // namespace net 2025 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/chromium/bidirectional_stream_quic_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698