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

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

Issue 612323013: QUIC - (no behavior change) s/NULL/nullptr/g in .../quic/... (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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') | net/tools/quic/quic_time_wait_list_manager.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 (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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 "HTTP/1.1"); 108 "HTTP/1.1");
109 response_headers.SetRequestFirstlineFromStringPieces("HTTP/1.1", 109 response_headers.SetRequestFirstlineFromStringPieces("HTTP/1.1",
110 "200", 110 "200",
111 "OK"); 111 "OK");
112 response_headers.AppendHeader("content-length", 112 response_headers.AppendHeader("content-length",
113 base::IntToString(body.length())); 113 base::IntToString(body.length()));
114 114
115 // Check if response already exists and matches. 115 // Check if response already exists and matches.
116 const QuicInMemoryCache::Response* cached_response = 116 const QuicInMemoryCache::Response* cached_response =
117 cache->GetResponse(request_headers); 117 cache->GetResponse(request_headers);
118 if (cached_response != NULL) { 118 if (cached_response != nullptr) {
119 string cached_response_headers_str, response_headers_str; 119 string cached_response_headers_str, response_headers_str;
120 cached_response->headers().DumpToString(&cached_response_headers_str); 120 cached_response->headers().DumpToString(&cached_response_headers_str);
121 response_headers.DumpToString(&response_headers_str); 121 response_headers.DumpToString(&response_headers_str);
122 CHECK_EQ(cached_response_headers_str, response_headers_str); 122 CHECK_EQ(cached_response_headers_str, response_headers_str);
123 CHECK_EQ(cached_response->body(), body); 123 CHECK_EQ(cached_response->body(), body);
124 return; 124 return;
125 } 125 }
126 126
127 cache->AddResponse(request_headers, response_headers, body); 127 cache->AddResponse(request_headers, response_headers, body);
128 } 128 }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 request_headers->SetRequestFirstlineFromStringPieces( 206 request_headers->SetRequestFirstlineFromStringPieces(
207 "GET", 207 "GET",
208 "https://www.google.com/foo", 208 "https://www.google.com/foo",
209 "HTTP/1.1"); 209 "HTTP/1.1");
210 210
211 response_headers_.SetResponseFirstlineFromStringPieces( 211 response_headers_.SetResponseFirstlineFromStringPieces(
212 "HTTP/1.1", "200", "OK"); 212 "HTTP/1.1", "200", "OK");
213 response_headers_.ReplaceOrAppendHeader("content-length", "3"); 213 response_headers_.ReplaceOrAppendHeader("content-length", "3");
214 214
215 InSequence s; 215 InSequence s;
216 EXPECT_CALL(session_, 216 EXPECT_CALL(session_, WritevData(kHeadersStreamId, _, 0, false, _, nullptr));
217 WritevData(kHeadersStreamId, _, 0, false, _, NULL));
218 EXPECT_CALL(session_, WritevData(_, _, _, _, _, _)).Times(1). 217 EXPECT_CALL(session_, WritevData(_, _, _, _, _, _)).Times(1).
219 WillOnce(Return(QuicConsumedData(3, true))); 218 WillOnce(Return(QuicConsumedData(3, true)));
220 219
221 QuicSpdyServerStreamPeer::SendResponse(stream_.get()); 220 QuicSpdyServerStreamPeer::SendResponse(stream_.get());
222 EXPECT_TRUE(stream_->read_side_closed()); 221 EXPECT_TRUE(stream_->read_side_closed());
223 EXPECT_TRUE(stream_->write_side_closed()); 222 EXPECT_TRUE(stream_->write_side_closed());
224 } 223 }
225 224
226 TEST_P(QuicSpdyServerStreamTest, TestSendErrorResponse) { 225 TEST_P(QuicSpdyServerStreamTest, TestSendErrorResponse) {
227 response_headers_.SetResponseFirstlineFromStringPieces( 226 response_headers_.SetResponseFirstlineFromStringPieces(
228 "HTTP/1.1", "500", "Server Error"); 227 "HTTP/1.1", "500", "Server Error");
229 response_headers_.ReplaceOrAppendHeader("content-length", "3"); 228 response_headers_.ReplaceOrAppendHeader("content-length", "3");
230 229
231 InSequence s; 230 InSequence s;
232 EXPECT_CALL(session_, 231 EXPECT_CALL(session_, WritevData(kHeadersStreamId, _, 0, false, _, nullptr));
233 WritevData(kHeadersStreamId, _, 0, false, _, NULL));
234 EXPECT_CALL(session_, WritevData(_, _, _, _, _, _)).Times(1). 232 EXPECT_CALL(session_, WritevData(_, _, _, _, _, _)).Times(1).
235 WillOnce(Return(QuicConsumedData(3, true))); 233 WillOnce(Return(QuicConsumedData(3, true)));
236 234
237 QuicSpdyServerStreamPeer::SendErrorResponse(stream_.get()); 235 QuicSpdyServerStreamPeer::SendErrorResponse(stream_.get());
238 EXPECT_TRUE(stream_->read_side_closed()); 236 EXPECT_TRUE(stream_->read_side_closed());
239 EXPECT_TRUE(stream_->write_side_closed()); 237 EXPECT_TRUE(stream_->write_side_closed());
240 } 238 }
241 239
242 TEST_P(QuicSpdyServerStreamTest, InvalidHeadersWithFin) { 240 TEST_P(QuicSpdyServerStreamTest, InvalidHeadersWithFin) {
243 char arr[] = { 241 char arr[] = {
(...skipping 22 matching lines...) Expand all
266 StringPiece data(arr, arraysize(arr)); 264 StringPiece data(arr, arraysize(arr));
267 QuicStreamFrame frame(stream_->id(), true, 0, MakeIOVector(data)); 265 QuicStreamFrame frame(stream_->id(), true, 0, MakeIOVector(data));
268 // Verify that we don't crash when we get a invalid headers in stream frame. 266 // Verify that we don't crash when we get a invalid headers in stream frame.
269 stream_->OnStreamFrame(frame); 267 stream_->OnStreamFrame(frame);
270 } 268 }
271 269
272 } // namespace 270 } // namespace
273 } // namespace test 271 } // namespace test
274 } // namespace tools 272 } // namespace tools
275 } // namespace net 273 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_spdy_server_stream.cc ('k') | net/tools/quic/quic_time_wait_list_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698