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

Side by Side Diff: net/http/bidirectional_stream_unittest.cc

Issue 2044583002: Improve NetLog logging in net::BidirectionalStream (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 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/http/bidirectional_stream.cc ('k') | net/log/net_log_event_type_list.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/http/bidirectional_stream.h" 5 #include "net/http/bidirectional_stream.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 EXPECT_EQ(CountWriteBytes(writes, arraysize(writes)), 590 EXPECT_EQ(CountWriteBytes(writes, arraysize(writes)),
591 delegate->GetTotalSentBytes()); 591 delegate->GetTotalSentBytes());
592 EXPECT_EQ(CountReadBytes(reads, arraysize(reads)), 592 EXPECT_EQ(CountReadBytes(reads, arraysize(reads)),
593 delegate->GetTotalReceivedBytes()); 593 delegate->GetTotalReceivedBytes());
594 594
595 // Destroy the delegate will destroy the stream, so we can get an end event 595 // Destroy the delegate will destroy the stream, so we can get an end event
596 // for BIDIRECTIONAL_STREAM_ALIVE. 596 // for BIDIRECTIONAL_STREAM_ALIVE.
597 delegate.reset(); 597 delegate.reset();
598 TestNetLogEntry::List entries; 598 TestNetLogEntry::List entries;
599 net_log_.GetEntries(&entries); 599 net_log_.GetEntries(&entries);
600
600 size_t index = ExpectLogContainsSomewhere( 601 size_t index = ExpectLogContainsSomewhere(
601 entries, 0, NetLog::TYPE_BIDIRECTIONAL_STREAM_ALIVE, NetLog::PHASE_BEGIN); 602 entries, 0, NetLog::TYPE_BIDIRECTIONAL_STREAM_ALIVE, NetLog::PHASE_BEGIN);
602 // HTTP_STREAM_REQUEST is nested inside in BIDIRECTIONAL_STREAM_ALIVE. 603 // HTTP_STREAM_REQUEST is nested inside in BIDIRECTIONAL_STREAM_ALIVE.
603 index = ExpectLogContainsSomewhere( 604 index = ExpectLogContainsSomewhere(
604 entries, index, NetLog::TYPE_HTTP_STREAM_REQUEST, NetLog::PHASE_BEGIN); 605 entries, index, NetLog::TYPE_HTTP_STREAM_REQUEST, NetLog::PHASE_BEGIN);
605 index = ExpectLogContainsSomewhere( 606 index = ExpectLogContainsSomewhere(
606 entries, index, NetLog::TYPE_HTTP_STREAM_REQUEST, NetLog::PHASE_END); 607 entries, index, NetLog::TYPE_HTTP_STREAM_REQUEST, NetLog::PHASE_END);
607 // Headers received should happen after HTTP_STREAM_REQUEST. 608 // Headers received should happen after HTTP_STREAM_REQUEST.
608 index = ExpectLogContainsSomewhere( 609 index = ExpectLogContainsSomewhere(
609 entries, index, NetLog::TYPE_BIDIRECTIONAL_STREAM_RECV_HEADERS, 610 entries, index, NetLog::TYPE_BIDIRECTIONAL_STREAM_RECV_HEADERS,
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 EXPECT_EQ(1, delegate->on_data_read_count()); 803 EXPECT_EQ(1, delegate->on_data_read_count());
803 804
804 EXPECT_EQ("200", delegate->response_headers().find(":status")->second); 805 EXPECT_EQ("200", delegate->response_headers().find(":status")->second);
805 EXPECT_EQ(1, delegate->on_data_read_count()); 806 EXPECT_EQ(1, delegate->on_data_read_count());
806 EXPECT_EQ(1, delegate->on_data_sent_count()); 807 EXPECT_EQ(1, delegate->on_data_sent_count());
807 EXPECT_EQ(kProtoHTTP2, delegate->GetProtocol()); 808 EXPECT_EQ(kProtoHTTP2, delegate->GetProtocol());
808 EXPECT_EQ(CountWriteBytes(writes, arraysize(writes)), 809 EXPECT_EQ(CountWriteBytes(writes, arraysize(writes)),
809 delegate->GetTotalSentBytes()); 810 delegate->GetTotalSentBytes());
810 EXPECT_EQ(CountReadBytes(reads, arraysize(reads)), 811 EXPECT_EQ(CountReadBytes(reads, arraysize(reads)),
811 delegate->GetTotalReceivedBytes()); 812 delegate->GetTotalReceivedBytes());
813
814 TestNetLogEntry::List entries;
815 net_log_.GetEntries(&entries);
816 size_t index = ExpectLogContainsSomewhere(
817 entries, 0, NetLog::TYPE_BIDIRECTIONAL_STREAM_BYTES_SENT_COALESCED,
818 NetLog::PHASE_BEGIN);
819 TestNetLogEntry entry = entries[index];
820 int num_buffers_coalesced = 0;
821 EXPECT_TRUE(entry.params->GetInteger("num_buffers_coalesced",
822 &num_buffers_coalesced));
823 EXPECT_EQ(2, num_buffers_coalesced);
824
825 index = ExpectLogContainsSomewhereAfter(
826 entries, index, NetLog::TYPE_BIDIRECTIONAL_STREAM_BYTES_SENT,
827 NetLog::PHASE_NONE);
828 entry = entries[index];
829 int byte_count = 0;
830 EXPECT_TRUE(entry.params->GetInteger("byte_count", &byte_count));
831 EXPECT_EQ(buf->size(), byte_count);
832
833 index = ExpectLogContainsSomewhereAfter(
834 entries, index + 1, NetLog::TYPE_BIDIRECTIONAL_STREAM_BYTES_SENT,
835 NetLog::PHASE_NONE);
836 entry = entries[index];
837 byte_count = 0;
838 EXPECT_TRUE(entry.params->GetInteger("byte_count", &byte_count));
839 EXPECT_EQ(buf2->size(), byte_count);
840
841 ExpectLogContainsSomewhere(
842 entries, index, NetLog::TYPE_BIDIRECTIONAL_STREAM_BYTES_SENT_COALESCED,
843 NetLog::PHASE_END);
812 } 844 }
813 845
814 // Tests that BidirectionalStreamSpdyImpl::OnClose will complete any remaining 846 // Tests that BidirectionalStreamSpdyImpl::OnClose will complete any remaining
815 // read even if the read queue is empty. 847 // read even if the read queue is empty.
816 TEST_F(BidirectionalStreamTest, TestCompleteAsyncRead) { 848 TEST_F(BidirectionalStreamTest, TestCompleteAsyncRead) {
817 std::unique_ptr<SpdySerializedFrame> req( 849 std::unique_ptr<SpdySerializedFrame> req(
818 spdy_util_.ConstructSpdyGet("https://www.example.org", 1, LOWEST)); 850 spdy_util_.ConstructSpdyGet("https://www.example.org", 1, LOWEST));
819 // Empty DATA frame with an END_STREAM flag. 851 // Empty DATA frame with an END_STREAM flag.
820 std::unique_ptr<SpdySerializedFrame> end_stream( 852 std::unique_ptr<SpdySerializedFrame> end_stream(
821 spdy_util_.ConstructSpdyBodyFrame(1, nullptr, 0, true)); 853 spdy_util_.ConstructSpdyBodyFrame(1, nullptr, 0, true));
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
1218 EXPECT_EQ(delegate->response_headers().end(), 1250 EXPECT_EQ(delegate->response_headers().end(),
1219 delegate->response_headers().find(":status")); 1251 delegate->response_headers().find(":status"));
1220 EXPECT_EQ(0, delegate->on_data_read_count()); 1252 EXPECT_EQ(0, delegate->on_data_read_count());
1221 EXPECT_EQ(0, delegate->on_data_sent_count()); 1253 EXPECT_EQ(0, delegate->on_data_sent_count());
1222 EXPECT_EQ(kProtoHTTP2, delegate->GetProtocol()); 1254 EXPECT_EQ(kProtoHTTP2, delegate->GetProtocol());
1223 // BidirectionalStreamSpdyStreamJob does not count the bytes sent for |rst| 1255 // BidirectionalStreamSpdyStreamJob does not count the bytes sent for |rst|
1224 // because it is sent after SpdyStream::Delegate::OnClose is called. 1256 // because it is sent after SpdyStream::Delegate::OnClose is called.
1225 EXPECT_EQ(CountWriteBytes(writes, 1), delegate->GetTotalSentBytes()); 1257 EXPECT_EQ(CountWriteBytes(writes, 1), delegate->GetTotalSentBytes());
1226 EXPECT_EQ(CountReadBytes(reads, arraysize(reads)), 1258 EXPECT_EQ(CountReadBytes(reads, arraysize(reads)),
1227 delegate->GetTotalReceivedBytes()); 1259 delegate->GetTotalReceivedBytes());
1260
1261 TestNetLogEntry::List entries;
1262 net_log_.GetEntries(&entries);
1263
1264 size_t index = ExpectLogContainsSomewhere(
1265 entries, 0, NetLog::TYPE_BIDIRECTIONAL_STREAM_READY, NetLog::PHASE_NONE);
1266 TestNetLogEntry entry = entries[index];
1267 bool request_headers_sent = false;
1268 EXPECT_TRUE(
1269 entry.params->GetBoolean("request_headers_sent", &request_headers_sent));
1270 EXPECT_TRUE(request_headers_sent);
1271
1272 index = ExpectLogContainsSomewhere(entries, index,
1273 NetLog::TYPE_BIDIRECTIONAL_STREAM_FAILED,
1274 NetLog::PHASE_NONE);
1275 entry = entries[index];
1276 int net_error = OK;
1277 EXPECT_TRUE(entry.params->GetInteger("net_error", &net_error));
1278 EXPECT_EQ(ERR_SPDY_PROTOCOL_ERROR, net_error);
1228 } 1279 }
1229 1280
1230 INSTANTIATE_TEST_CASE_P(CancelOrDeleteTests, 1281 INSTANTIATE_TEST_CASE_P(CancelOrDeleteTests,
1231 BidirectionalStreamTest, 1282 BidirectionalStreamTest,
1232 ::testing::Values(true, false)); 1283 ::testing::Values(true, false));
1233 1284
1234 TEST_P(BidirectionalStreamTest, CancelOrDeleteStreamDuringOnHeadersReceived) { 1285 TEST_P(BidirectionalStreamTest, CancelOrDeleteStreamDuringOnHeadersReceived) {
1235 std::unique_ptr<SpdySerializedFrame> req( 1286 std::unique_ptr<SpdySerializedFrame> req(
1236 spdy_util_.ConstructSpdyGet("https://www.example.org", 1, LOWEST)); 1287 spdy_util_.ConstructSpdyGet("https://www.example.org", 1, LOWEST));
1237 1288
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
1527 AlternativeServiceVector alternative_service_vector = 1578 AlternativeServiceVector alternative_service_vector =
1528 http_session_->http_server_properties()->GetAlternativeServices(server); 1579 http_session_->http_server_properties()->GetAlternativeServices(server);
1529 ASSERT_EQ(1u, alternative_service_vector.size()); 1580 ASSERT_EQ(1u, alternative_service_vector.size());
1530 EXPECT_EQ(AlternateProtocolFromNextProto(kProtoQUIC1SPDY3), 1581 EXPECT_EQ(AlternateProtocolFromNextProto(kProtoQUIC1SPDY3),
1531 alternative_service_vector[0].protocol); 1582 alternative_service_vector[0].protocol);
1532 EXPECT_EQ("www.example.org", alternative_service_vector[0].host); 1583 EXPECT_EQ("www.example.org", alternative_service_vector[0].host);
1533 EXPECT_EQ(443, alternative_service_vector[0].port); 1584 EXPECT_EQ(443, alternative_service_vector[0].port);
1534 } 1585 }
1535 1586
1536 } // namespace net 1587 } // namespace net
OLDNEW
« no previous file with comments | « net/http/bidirectional_stream.cc ('k') | net/log/net_log_event_type_list.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698