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

Side by Side Diff: net/tools/quic/quic_spdy_server_stream_test.cc

Issue 1028923002: Make some changes to the QuicInMemory server to clarify the interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix tests Created 5 years, 9 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/tools/quic/quic_spdy_server_stream.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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/tools/quic/quic_spdy_server_stream.h" 5 #include "net/tools/quic/quic_spdy_server_stream.h"
6 6
7 #include "base/strings/string_number_conversions.h" 7 #include "base/strings/string_number_conversions.h"
8 #include "base/strings/string_piece.h" 8 #include "base/strings/string_piece.h"
9 #include "net/quic/quic_connection.h" 9 #include "net/quic/quic_connection.h"
10 #include "net/quic/quic_protocol.h" 10 #include "net/quic/quic_protocol.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 stream_.reset(new QuicSpdyServerStreamPeer(3, &session_)); 93 stream_.reset(new QuicSpdyServerStreamPeer(3, &session_));
94 } 94 }
95 95
96 static void SetUpTestCase() { 96 static void SetUpTestCase() {
97 QuicInMemoryCachePeer::ResetForTests(); 97 QuicInMemoryCachePeer::ResetForTests();
98 } 98 }
99 99
100 void SetUp() override { 100 void SetUp() override {
101 QuicInMemoryCache* cache = QuicInMemoryCache::GetInstance(); 101 QuicInMemoryCache* cache = QuicInMemoryCache::GetInstance();
102 102
103 BalsaHeaders request_headers, response_headers; 103 BalsaHeaders response_headers;
104 StringPiece body("Yum"); 104 StringPiece body("Yum");
105 request_headers.SetRequestFirstlineFromStringPieces(
106 "GET",
107 "https://www.google.com/foo",
108 "HTTP/1.1");
109 response_headers.SetRequestFirstlineFromStringPieces("HTTP/1.1", 105 response_headers.SetRequestFirstlineFromStringPieces("HTTP/1.1",
110 "200", 106 "200",
111 "OK"); 107 "OK");
112 response_headers.AppendHeader("content-length", 108 response_headers.AppendHeader("content-length",
113 base::IntToString(body.length())); 109 base::IntToString(body.length()));
114 110
111 string host = "";
112 string path = "/foo";
115 // Check if response already exists and matches. 113 // Check if response already exists and matches.
116 const QuicInMemoryCache::Response* cached_response = 114 const QuicInMemoryCache::Response* cached_response =
117 cache->GetResponse(request_headers); 115 cache->GetResponse(host, path);
118 if (cached_response != nullptr) { 116 if (cached_response != nullptr) {
119 string cached_response_headers_str, response_headers_str; 117 string cached_response_headers_str, response_headers_str;
120 cached_response->headers().DumpToString(&cached_response_headers_str); 118 cached_response->headers().DumpToString(&cached_response_headers_str);
121 response_headers.DumpToString(&response_headers_str); 119 response_headers.DumpToString(&response_headers_str);
122 CHECK_EQ(cached_response_headers_str, response_headers_str); 120 CHECK_EQ(cached_response_headers_str, response_headers_str);
123 CHECK_EQ(cached_response->body(), body); 121 CHECK_EQ(cached_response->body(), body);
124 return; 122 return;
125 } 123 }
126 124
127 cache->AddResponse(request_headers, response_headers, body); 125 cache->AddResponse(host, path, response_headers, body);
128 } 126 }
129 127
130 const string& StreamBody() { 128 const string& StreamBody() {
131 return QuicSpdyServerStreamPeer::body(stream_.get()); 129 return QuicSpdyServerStreamPeer::body(stream_.get());
132 } 130 }
133 131
134 const BalsaHeaders& StreamHeaders() { 132 const BalsaHeaders& StreamHeaders() {
135 return QuicSpdyServerStreamPeer::headers(stream_.get()); 133 return QuicSpdyServerStreamPeer::headers(stream_.get());
136 } 134 }
137 135
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 StringPiece data(arr, arraysize(arr)); 262 StringPiece data(arr, arraysize(arr));
265 QuicStreamFrame frame(stream_->id(), true, 0, MakeIOVector(data)); 263 QuicStreamFrame frame(stream_->id(), true, 0, MakeIOVector(data));
266 // Verify that we don't crash when we get a invalid headers in stream frame. 264 // Verify that we don't crash when we get a invalid headers in stream frame.
267 stream_->OnStreamFrame(frame); 265 stream_->OnStreamFrame(frame);
268 } 266 }
269 267
270 } // namespace 268 } // namespace
271 } // namespace test 269 } // namespace test
272 } // namespace tools 270 } // namespace tools
273 } // namespace net 271 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_spdy_server_stream.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698