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

Unified Diff: net/http/bidirectional_stream_unittest.cc

Issue 1932853002: Log urls and headers in BIDIRECTIONAL_STREAM events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: net/http/bidirectional_stream_unittest.cc
diff --git a/net/http/bidirectional_stream_unittest.cc b/net/http/bidirectional_stream_unittest.cc
index 8ecb3f2277df97fd3455245f3b22d8d5bdf82a98..8e72740acdc9c75746dd21828cc3f9a8fdd5de19 100644
--- a/net/http/bidirectional_stream_unittest.cc
+++ b/net/http/bidirectional_stream_unittest.cc
@@ -480,7 +480,8 @@ TEST_F(BidirectionalStreamTest, TestReadDataAfterClose) {
delegate->GetTotalReceivedBytes());
}
-TEST_F(BidirectionalStreamTest, TestContainFullBytes) {
+// Tests that the NetLog contains correct entries.
+TEST_F(BidirectionalStreamTest, TestNetLogContainEntries) {
BufferedSpdyFramer framer(spdy_util_.spdy_version());
std::unique_ptr<SpdySerializedFrame> req(spdy_util_.ConstructSpdyPost(
@@ -496,7 +497,12 @@ TEST_F(BidirectionalStreamTest, TestContainFullBytes) {
std::unique_ptr<SpdySerializedFrame> response_body_frame1(
spdy_util_.ConstructSpdyBodyFrame(1, false));
std::unique_ptr<SpdySerializedFrame> response_body_frame2(
- spdy_util_.ConstructSpdyBodyFrame(1, true));
+ spdy_util_.ConstructSpdyBodyFrame(1, false));
+
+ SpdyHeaderBlock late_headers;
mef 2016/04/28 20:43:18 maybe rename late_headers => trailers and trailers
xunjieli 2016/04/28 21:06:15 Done.
+ late_headers["foo"] = "bar";
+ std::unique_ptr<SpdySerializedFrame> trailers(
+ spdy_util_.ConstructSpdyResponseHeaders(1, late_headers, true));
MockRead reads[] = {
CreateMockRead(*resp, 1),
@@ -504,7 +510,8 @@ TEST_F(BidirectionalStreamTest, TestContainFullBytes) {
CreateMockRead(*response_body_frame1, 4),
MockRead(ASYNC, ERR_IO_PENDING, 5), // Force a pause.
CreateMockRead(*response_body_frame2, 6),
- MockRead(ASYNC, 0, 7),
+ CreateMockRead(*trailers, 7),
+ MockRead(ASYNC, 0, 8),
};
HostPortPair host_port_pair("www.example.org", 443);
@@ -558,16 +565,31 @@ TEST_F(BidirectionalStreamTest, TestContainFullBytes) {
EXPECT_EQ(1, delegate->on_data_read_count());
EXPECT_EQ(1, delegate->on_data_sent_count());
EXPECT_EQ(kProtoHTTP2, delegate->GetProtocol());
+ EXPECT_EQ("bar", delegate->trailers().find("foo")->second);
EXPECT_EQ(CountWriteBytes(writes, arraysize(writes)),
delegate->GetTotalSentBytes());
EXPECT_EQ(CountReadBytes(reads, arraysize(reads)),
delegate->GetTotalReceivedBytes());
+ // Destroy the delegate will destroy the stream, so we can get a
+ // the end event for BIDIRECTIONAL_STREAM_ALIVE.
+ delegate.reset();
TestNetLogEntry::List entries;
net_log_.GetEntries(&entries);
- // Sent bytes. Sending data is always asynchronous.
size_t index = ExpectLogContainsSomewhere(
- entries, 0, NetLog::TYPE_BIDIRECTIONAL_STREAM_BYTES_SENT,
+ entries, 0, NetLog::TYPE_BIDIRECTIONAL_STREAM_ALIVE, NetLog::PHASE_BEGIN);
+ // Headers received should happen after BIDIRECTIONAL_STREAM_ALIVE.
+ index = ExpectLogContainsSomewhere(
+ entries, index, NetLog::TYPE_BIDIRECTIONAL_STREAM_RECV_HEADERS,
+ NetLog::PHASE_NONE);
+ // Trailers received should happen after headers received. It might happen
+ // before the reads complete.
+ ExpectLogContainsSomewhere(entries, index,
+ NetLog::TYPE_BIDIRECTIONAL_STREAM_RECV_TRAILERS,
+ NetLog::PHASE_NONE);
+ // Sent bytes. Sending data is always asynchronous.
+ index = ExpectLogContainsSomewhere(
+ entries, index, NetLog::TYPE_BIDIRECTIONAL_STREAM_BYTES_SENT,
NetLog::PHASE_NONE);
TestNetLogEntry entry = entries[index];
EXPECT_EQ(NetLog::SOURCE_BIDIRECTIONAL_STREAM, entry.source.type);
@@ -583,6 +605,9 @@ TEST_F(BidirectionalStreamTest, TestContainFullBytes) {
NetLog::PHASE_NONE);
entry = entries[index];
EXPECT_EQ(NetLog::SOURCE_BIDIRECTIONAL_STREAM, entry.source.type);
+ index = ExpectLogContainsSomewhere(entries, index,
mef 2016/04/28 20:43:18 anything interesting to check at this index?
xunjieli 2016/04/28 21:06:15 Done. Nothing in particular, so i have got rid of
+ NetLog::TYPE_BIDIRECTIONAL_STREAM_ALIVE,
+ NetLog::PHASE_END);
}
TEST_F(BidirectionalStreamTest, TestInterleaveReadDataAndSendData) {

Powered by Google App Engine
This is Rietveld 408576698