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

Side by Side Diff: net/quic/chromium/quic_chromium_client_stream_test.cc

Issue 2393233002: Remove OnDataAvailable() notification when trailers are to be delivered (Closed)
Patch Set: Address Andrei's comments Created 4 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
OLDNEW
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/quic/chromium/quic_chromium_client_stream.h" 5 #include "net/quic/chromium/quic_chromium_client_stream.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 SpdyHeaderBlock trailers; 410 SpdyHeaderBlock trailers;
411 trailers["bar"] = "foo"; 411 trailers["bar"] = "foo";
412 trailers[kFinalOffsetHeaderKey] = base::IntToString(strlen(data)); 412 trailers[kFinalOffsetHeaderKey] = base::IntToString(strlen(data));
413 std::string uncompressed_trailers = 413 std::string uncompressed_trailers =
414 SpdyUtils::SerializeUncompressedHeaders(trailers); 414 SpdyUtils::SerializeUncompressedHeaders(trailers);
415 415
416 stream_->OnStreamHeaders(uncompressed_trailers); 416 stream_->OnStreamHeaders(uncompressed_trailers);
417 stream_->OnStreamHeadersComplete(true, uncompressed_trailers.length()); 417 stream_->OnStreamHeadersComplete(true, uncompressed_trailers.length());
418 EXPECT_FALSE(stream_->IsDoneReading()); 418 EXPECT_FALSE(stream_->IsDoneReading());
419 419
420 // Now the pending should complete. Make sure that IsDoneReading() is false
421 // even though ReadData returns 0 byte, because OnHeadersAvailable callback
422 // comes after this OnDataAvailable callback.
423 base::RunLoop run_loop2; 420 base::RunLoop run_loop2;
424 EXPECT_CALL(delegate_, OnDataAvailable())
425 .Times(1)
426 .WillOnce(testing::DoAll(
427 testing::Invoke(CreateFunctor(&QuicChromiumClientStreamTest::ReadData,
428 base::Unretained(this), StringPiece())),
429 testing::InvokeWithoutArgs([&run_loop2]() { run_loop2.Quit(); })));
430 run_loop2.Run();
431 // Make sure that the stream is not closed, even though ReadData returns 0.
432 EXPECT_FALSE(stream_->IsDoneReading());
433
434 // The OnHeadersAvailable call should follow.
435 base::RunLoop run_loop3;
436 EXPECT_CALL(delegate_, 421 EXPECT_CALL(delegate_,
437 OnHeadersAvailableMock(_, uncompressed_trailers.length())) 422 OnHeadersAvailableMock(_, uncompressed_trailers.length()))
438 .WillOnce( 423 .WillOnce(
439 testing::InvokeWithoutArgs([&run_loop3]() { run_loop3.Quit(); })); 424 testing::InvokeWithoutArgs([&run_loop2]() { run_loop2.Quit(); }));
440 425
441 run_loop3.Run(); 426 run_loop2.Run();
427
442 // Make sure the stream is properly closed since trailers and data are all 428 // Make sure the stream is properly closed since trailers and data are all
443 // consumed. 429 // consumed.
444 EXPECT_TRUE(stream_->IsDoneReading()); 430 EXPECT_TRUE(stream_->IsDoneReading());
445 // Make sure kFinalOffsetHeaderKey is gone from the delivered actual trailers. 431 // Make sure kFinalOffsetHeaderKey is gone from the delivered actual trailers.
446 trailers.erase(kFinalOffsetHeaderKey); 432 trailers.erase(kFinalOffsetHeaderKey);
447 EXPECT_EQ(trailers, delegate_.headers_); 433 EXPECT_EQ(trailers, delegate_.headers_);
448 434
449 base::RunLoop().RunUntilIdle(); 435 base::RunLoop().RunUntilIdle();
450 EXPECT_CALL(delegate_, OnClose()); 436 EXPECT_CALL(delegate_, OnClose());
451 } 437 }
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 base::RunLoop().RunUntilIdle(); 540 base::RunLoop().RunUntilIdle();
555 EXPECT_EQ(headers_, delegate_.headers_); 541 EXPECT_EQ(headers_, delegate_.headers_);
556 542
557 // Times(2) because OnClose will be called for stream and stream_. 543 // Times(2) because OnClose will be called for stream and stream_.
558 EXPECT_CALL(delegate_, OnClose()).Times(2); 544 EXPECT_CALL(delegate_, OnClose()).Times(2);
559 } 545 }
560 546
561 } // namespace 547 } // namespace
562 } // namespace test 548 } // namespace test
563 } // namespace net 549 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698