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

Unified Diff: net/quic/quic_chromium_client_stream_test.cc

Issue 1856073002: Coalesce small buffers in net::BidirectionalStream (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix javadoc Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/quic_chromium_client_stream.cc ('k') | net/quic/test_tools/quic_test_packet_maker.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/quic_chromium_client_stream_test.cc
diff --git a/net/quic/quic_chromium_client_stream_test.cc b/net/quic/quic_chromium_client_stream_test.cc
index b7c888c1bba848cba5ead83a372bfc56fbb35076..8e107e63bdb60c6aaa976a7673b05a805e4a60b3 100644
--- a/net/quic/quic_chromium_client_stream_test.cc
+++ b/net/quic/quic_chromium_client_stream_test.cc
@@ -7,6 +7,7 @@
#include "base/macros.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
+#include "net/base/io_buffer.h"
#include "net/base/net_errors.h"
#include "net/base/test_completion_callback.h"
#include "net/quic/quic_chromium_client_session.h"
@@ -464,6 +465,52 @@ TEST_P(QuicChromiumClientStreamTest, WriteStreamDataAsync) {
EXPECT_EQ(OK, callback.WaitForResult());
}
+TEST_P(QuicChromiumClientStreamTest, WritevStreamData) {
+ EXPECT_CALL(delegate_, OnClose(QUIC_NO_ERROR));
+
+ scoped_refptr<StringIOBuffer> buf1(new StringIOBuffer("hello world!"));
+ scoped_refptr<StringIOBuffer> buf2(
+ new StringIOBuffer("Just a small payload"));
+
+ // All data written.
+ EXPECT_CALL(session_, WritevData(stream_->id(), _, _, _, _))
+ .WillOnce(Return(QuicConsumedData(buf1->size(), false)))
+ .WillOnce(Return(QuicConsumedData(buf2->size(), true)));
+ TestCompletionCallback callback;
+ EXPECT_EQ(OK, stream_->WritevStreamData({buf1.get(), buf2.get()},
+ {buf1->size(), buf2->size()}, true,
+ callback.callback()));
+}
+
+TEST_P(QuicChromiumClientStreamTest, WritevStreamDataAsync) {
+ EXPECT_CALL(delegate_, HasSendHeadersComplete()).Times(AnyNumber());
+ EXPECT_CALL(delegate_, OnClose(QUIC_NO_ERROR));
+
+ scoped_refptr<StringIOBuffer> buf1(new StringIOBuffer("hello world!"));
+ scoped_refptr<StringIOBuffer> buf2(
+ new StringIOBuffer("Just a small payload"));
+
+ // Only a part of the data is written.
+ EXPECT_CALL(session_, WritevData(stream_->id(), _, _, _, _))
+ // First piece of data is written.
+ .WillOnce(Return(QuicConsumedData(buf1->size(), false)))
+ // Second piece of data is queued.
+ .WillOnce(Return(QuicConsumedData(0, false)));
+ TestCompletionCallback callback;
+ EXPECT_EQ(ERR_IO_PENDING,
+ stream_->WritevStreamData({buf1.get(), buf2.get()},
+ {buf1->size(), buf2->size()}, true,
+ callback.callback()));
+ ASSERT_FALSE(callback.have_result());
+
+ // The second piece of data is written.
+ EXPECT_CALL(session_, WritevData(stream_->id(), _, _, _, _))
+ .WillOnce(Return(QuicConsumedData(buf2->size(), true)));
+ stream_->OnCanWrite();
+ ASSERT_TRUE(callback.have_result());
+ EXPECT_EQ(OK, callback.WaitForResult());
+}
+
TEST_P(QuicChromiumClientStreamTest, HeadersBeforeDelegate) {
// We don't use stream_ because we want an incoming server push
// stream.
« no previous file with comments | « net/quic/quic_chromium_client_stream.cc ('k') | net/quic/test_tools/quic_test_packet_maker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698