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

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

Issue 1774703003: QuicChromiumClientStream should only do OnStream after notifying delegate about trailers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
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/quic_chromium_client_stream.h" 5 #include "net/quic/quic_chromium_client_stream.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "net/base/net_errors.h" 8 #include "net/base/net_errors.h"
9 #include "net/base/test_completion_callback.h" 9 #include "net/base/test_completion_callback.h"
10 #include "net/quic/quic_chromium_client_session.h" 10 #include "net/quic/quic_chromium_client_session.h"
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 EXPECT_CALL(delegate_, 302 EXPECT_CALL(delegate_,
303 OnHeadersAvailable(headers_, uncompressed_headers.length())); 303 OnHeadersAvailable(headers_, uncompressed_headers.length()));
304 base::MessageLoop::current()->RunUntilIdle(); 304 base::MessageLoop::current()->RunUntilIdle();
305 EXPECT_TRUE(stream_->decompressed_headers().empty()); 305 EXPECT_TRUE(stream_->decompressed_headers().empty());
306 306
307 const char data[] = "hello world!"; 307 const char data[] = "hello world!";
308 stream_->OnStreamFrame(QuicStreamFrame(kTestStreamId, /*fin=*/false, 308 stream_->OnStreamFrame(QuicStreamFrame(kTestStreamId, /*fin=*/false,
309 /*offset=*/0, data)); 309 /*offset=*/0, data));
310 310
311 EXPECT_CALL(delegate_, OnDataAvailable()) 311 EXPECT_CALL(delegate_, OnDataAvailable())
312 .Times(1)
312 .WillOnce(testing::Invoke(CreateFunctor( 313 .WillOnce(testing::Invoke(CreateFunctor(
313 &QuicChromiumClientStreamTest::ReadData, base::Unretained(this), 314 &QuicChromiumClientStreamTest::ReadData, base::Unretained(this),
314 StringPiece(data, arraysize(data) - 1)))); 315 StringPiece(data, arraysize(data) - 1))));
315 316
317 // Wait until delegate_->OnDataAvailable is called.
318 base::MessageLoop::current()->RunUntilIdle();
319
316 SpdyHeaderBlock trailers; 320 SpdyHeaderBlock trailers;
317 trailers["bar"] = "foo"; 321 trailers["bar"] = "foo";
318 std::string uncompressed_trailers = 322 std::string uncompressed_trailers =
319 SpdyUtils::SerializeUncompressedHeaders(trailers); 323 SpdyUtils::SerializeUncompressedHeaders(trailers);
320 324
321 stream_->OnStreamHeaders(uncompressed_trailers); 325 stream_->OnStreamHeaders(uncompressed_trailers);
322 stream_->OnStreamHeadersComplete(true, uncompressed_trailers.length()); 326 stream_->OnStreamHeadersComplete(true, uncompressed_trailers.length());
323 327
324 EXPECT_CALL(delegate_, 328 EXPECT_CALL(delegate_,
325 OnHeadersAvailable(trailers, uncompressed_trailers.length())); 329 OnHeadersAvailable(trailers, uncompressed_trailers.length()));
326 330
331 // Make sure that OnDataAvailable is invoked to force us to read FIN.
332 EXPECT_CALL(delegate_, OnDataAvailable())
333 .Times(1)
334 .WillOnce(testing::Invoke(
335 CreateFunctor(&QuicChromiumClientStreamTest::ReadData,
336 base::Unretained(this), StringPiece(""))));
337
327 base::MessageLoop::current()->RunUntilIdle(); 338 base::MessageLoop::current()->RunUntilIdle();
328 EXPECT_CALL(delegate_, OnClose(QUIC_NO_ERROR)); 339 EXPECT_CALL(delegate_, OnClose(QUIC_NO_ERROR));
329 } 340 }
330 341
331 TEST_P(QuicChromiumClientStreamTest, WriteStreamData) { 342 TEST_P(QuicChromiumClientStreamTest, WriteStreamData) {
332 EXPECT_CALL(delegate_, OnClose(QUIC_NO_ERROR)); 343 EXPECT_CALL(delegate_, OnClose(QUIC_NO_ERROR));
333 344
334 const char kData1[] = "hello world"; 345 const char kData1[] = "hello world";
335 const size_t kDataLen = arraysize(kData1); 346 const size_t kDataLen = arraysize(kData1);
336 347
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 stream->SetDelegate(&delegate_); 396 stream->SetDelegate(&delegate_);
386 base::MessageLoop::current()->RunUntilIdle(); 397 base::MessageLoop::current()->RunUntilIdle();
387 398
388 // Times(2) because OnClose will be called for stream and stream_. 399 // Times(2) because OnClose will be called for stream and stream_.
389 EXPECT_CALL(delegate_, OnClose(QUIC_NO_ERROR)).Times(2); 400 EXPECT_CALL(delegate_, OnClose(QUIC_NO_ERROR)).Times(2);
390 } 401 }
391 402
392 } // namespace 403 } // namespace
393 } // namespace test 404 } // namespace test
394 } // namespace net 405 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698