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

Unified Diff: content/browser/byte_stream_unittest.cc

Issue 18098004: Add Flush() method to ByteStream. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 5 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 | « content/browser/byte_stream.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/byte_stream_unittest.cc
diff --git a/content/browser/byte_stream_unittest.cc b/content/browser/byte_stream_unittest.cc
index ed413da8f3cc0c884bfec31e34b5b0ac2a2209a1..a585fb7a6c2f3ddda09bbc4c973b2f890e6b2773 100644
--- a/content/browser/byte_stream_unittest.cc
+++ b/content/browser/byte_stream_unittest.cc
@@ -146,6 +146,45 @@ TEST_F(ByteStreamTest, ByteStream_PushBack) {
byte_stream_output->Read(&output_io_buffer, &output_length));
}
+// Confirm that Flush() method makes the writer to send written contents to
+// the reader.
+TEST_F(ByteStreamTest, ByteStream_Flush) {
+ scoped_ptr<ByteStreamWriter> byte_stream_input;
+ scoped_ptr<ByteStreamReader> byte_stream_output;
+ CreateByteStream(
+ message_loop_.message_loop_proxy(), message_loop_.message_loop_proxy(),
+ 1024, &byte_stream_input, &byte_stream_output);
+
+ EXPECT_TRUE(Write(byte_stream_input.get(), 1));
+ message_loop_.RunUntilIdle();
+
+ scoped_refptr<net::IOBuffer> output_io_buffer;
+ size_t output_length = 0;
+ // Check that data is not sent to the reader yet.
+ EXPECT_EQ(ByteStreamReader::STREAM_EMPTY,
+ byte_stream_output->Read(&output_io_buffer, &output_length));
+
+ byte_stream_input->Flush();
+ message_loop_.RunUntilIdle();
+
+ EXPECT_EQ(ByteStreamReader::STREAM_HAS_DATA,
+ byte_stream_output->Read(&output_io_buffer, &output_length));
+ EXPECT_TRUE(ValidateIOBuffer(output_io_buffer, output_length));
+
+ // Check that it's ok to Flush() an empty writer.
+ byte_stream_input->Flush();
+ message_loop_.RunUntilIdle();
+
+ EXPECT_EQ(ByteStreamReader::STREAM_EMPTY,
+ byte_stream_output->Read(&output_io_buffer, &output_length));
+
+ byte_stream_input->Close(DOWNLOAD_INTERRUPT_REASON_NONE);
+ message_loop_.RunUntilIdle();
+
+ EXPECT_EQ(ByteStreamReader::STREAM_COMPLETE,
+ byte_stream_output->Read(&output_io_buffer, &output_length));
+}
+
// Same as above, only use knowledge of the internals to confirm
// that we're getting pushback even when data's split across the two
// objects
« no previous file with comments | « content/browser/byte_stream.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698