OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_client_session.h" | 5 #include "net/tools/quic/quic_client_session.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 session_->ProcessUdpPacket(client_address, server_address, *received); | 318 session_->ProcessUdpPacket(client_address, server_address, *received); |
319 } | 319 } |
320 | 320 |
321 TEST_P(QuicClientSessionTest, PushPromiseOnPromiseHeaders) { | 321 TEST_P(QuicClientSessionTest, PushPromiseOnPromiseHeaders) { |
322 // Initialize crypto before the client session will create a stream. | 322 // Initialize crypto before the client session will create a stream. |
323 CompleteCryptoHandshake(); | 323 CompleteCryptoHandshake(); |
324 | 324 |
325 MockQuicSpdyClientStream* stream = static_cast<MockQuicSpdyClientStream*>( | 325 MockQuicSpdyClientStream* stream = static_cast<MockQuicSpdyClientStream*>( |
326 session_->CreateOutgoingDynamicStream(kDefaultPriority)); | 326 session_->CreateOutgoingDynamicStream(kDefaultPriority)); |
327 | 327 |
328 EXPECT_CALL(*stream, OnPromiseHeaders(_)); | 328 EXPECT_CALL(*stream, OnPromiseHeaderList(_, _, _)); |
329 StringPiece headers_data; | 329 session_->OnPromiseHeaderList(associated_stream_id_, promised_stream_id_, 0, |
330 session_->OnPromiseHeaders(associated_stream_id_, headers_data); | 330 QuicHeaderList()); |
331 } | 331 } |
332 | 332 |
333 TEST_P(QuicClientSessionTest, PushPromiseOnPromiseHeadersAlreadyClosed) { | 333 TEST_P(QuicClientSessionTest, PushPromiseOnPromiseHeadersAlreadyClosed) { |
334 // Initialize crypto before the client session will create a stream. | 334 // Initialize crypto before the client session will create a stream. |
335 CompleteCryptoHandshake(); | 335 CompleteCryptoHandshake(); |
336 | 336 |
337 session_->CreateOutgoingDynamicStream(kDefaultPriority); | 337 session_->CreateOutgoingDynamicStream(kDefaultPriority); |
338 | 338 |
339 EXPECT_CALL(*connection_, | 339 EXPECT_CALL(*connection_, |
340 SendRstStream(associated_stream_id_, QUIC_REFUSED_STREAM, 0)); | 340 SendRstStream(associated_stream_id_, QUIC_REFUSED_STREAM, 0)); |
341 session_->ResetPromised(associated_stream_id_, QUIC_REFUSED_STREAM); | 341 session_->ResetPromised(associated_stream_id_, QUIC_REFUSED_STREAM); |
342 | 342 |
343 StringPiece headers_data; | 343 session_->OnPromiseHeaderList(associated_stream_id_, promised_stream_id_, 0, |
344 session_->OnPromiseHeaders(associated_stream_id_, headers_data); | 344 QuicHeaderList()); |
345 } | |
346 | |
347 TEST_P(QuicClientSessionTest, PushPromiseOnHeadersCompleteAlreadyClosed) { | |
348 // Initialize crypto before the client session will create a stream. | |
349 CompleteCryptoHandshake(); | |
350 | |
351 session_->CreateOutgoingDynamicStream(kDefaultPriority); | |
352 EXPECT_CALL(*connection_, | |
353 SendRstStream(associated_stream_id_, QUIC_REFUSED_STREAM, 0)); | |
354 session_->ResetPromised(associated_stream_id_, QUIC_REFUSED_STREAM); | |
355 | |
356 session_->OnPromiseHeadersComplete(associated_stream_id_, promised_stream_id_, | |
357 0); | |
358 } | 345 } |
359 | 346 |
360 TEST_P(QuicClientSessionTest, PushPromiseOutOfOrder) { | 347 TEST_P(QuicClientSessionTest, PushPromiseOutOfOrder) { |
361 // Initialize crypto before the client session will create a stream. | 348 // Initialize crypto before the client session will create a stream. |
362 CompleteCryptoHandshake(); | 349 CompleteCryptoHandshake(); |
363 | 350 |
364 MockQuicSpdyClientStream* stream = static_cast<MockQuicSpdyClientStream*>( | 351 MockQuicSpdyClientStream* stream = static_cast<MockQuicSpdyClientStream*>( |
365 session_->CreateOutgoingDynamicStream(kDefaultPriority)); | 352 session_->CreateOutgoingDynamicStream(kDefaultPriority)); |
366 | 353 |
367 EXPECT_CALL(*stream, OnPromiseHeadersComplete(promised_stream_id_, _)); | 354 EXPECT_CALL(*stream, OnPromiseHeaderList(promised_stream_id_, _, _)); |
368 session_->OnPromiseHeadersComplete(associated_stream_id_, promised_stream_id_, | 355 session_->OnPromiseHeaderList(associated_stream_id_, promised_stream_id_, 0, |
369 0); | 356 QuicHeaderList()); |
370 associated_stream_id_ += 2; | 357 associated_stream_id_ += 2; |
371 EXPECT_CALL(*connection_, | 358 EXPECT_CALL(*connection_, |
372 CloseConnection(QUIC_INVALID_STREAM_ID, | 359 CloseConnection(QUIC_INVALID_STREAM_ID, |
373 "Received push stream id lesser or equal to the" | 360 "Received push stream id lesser or equal to the" |
374 " last accepted before", | 361 " last accepted before", |
375 _)); | 362 _)); |
376 session_->OnPromiseHeadersComplete(associated_stream_id_, promised_stream_id_, | 363 session_->OnPromiseHeaderList(associated_stream_id_, promised_stream_id_, 0, |
377 0); | 364 QuicHeaderList()); |
378 } | 365 } |
379 | 366 |
380 TEST_P(QuicClientSessionTest, PushPromiseHandlePromise) { | 367 TEST_P(QuicClientSessionTest, PushPromiseHandlePromise) { |
381 // Initialize crypto before the client session will create a stream. | 368 // Initialize crypto before the client session will create a stream. |
382 CompleteCryptoHandshake(); | 369 CompleteCryptoHandshake(); |
383 | 370 |
384 session_->CreateOutgoingDynamicStream(kDefaultPriority); | 371 session_->CreateOutgoingDynamicStream(kDefaultPriority); |
385 | 372 |
386 session_->HandlePromised(associated_stream_id_, promised_stream_id_, | 373 session_->HandlePromised(associated_stream_id_, promised_stream_id_, |
387 push_promise_); | 374 push_promise_); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 QuicClientPromisedInfo* promised = | 514 QuicClientPromisedInfo* promised = |
528 session_->GetPromisedById(promised_stream_id_); | 515 session_->GetPromisedById(promised_stream_id_); |
529 EXPECT_NE(promised, nullptr); | 516 EXPECT_NE(promised, nullptr); |
530 EXPECT_NE(session_->GetPromisedByUrl(promise_url_), nullptr); | 517 EXPECT_NE(session_->GetPromisedByUrl(promise_url_), nullptr); |
531 EXPECT_EQ(session_->GetPromisedStream(promised_stream_id_), nullptr); | 518 EXPECT_EQ(session_->GetPromisedStream(promised_stream_id_), nullptr); |
532 } | 519 } |
533 | 520 |
534 } // namespace | 521 } // namespace |
535 } // namespace test | 522 } // namespace test |
536 } // namespace net | 523 } // namespace net |
OLD | NEW |