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

Unified Diff: content/browser/download/download_file_unittest.cc

Issue 2861443005: Clear callback when a parallel request can no longer write any data (Closed)
Patch Set: Created 3 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 | « content/browser/download/download_file_impl.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/download/download_file_unittest.cc
diff --git a/content/browser/download/download_file_unittest.cc b/content/browser/download/download_file_unittest.cc
index 11b943e3da204da46037191f616c16699d579f45..a51777d66b5aee933426a0179a7332bc8a0df20d 100644
--- a/content/browser/download/download_file_unittest.cc
+++ b/content/browser/download/download_file_unittest.cc
@@ -989,7 +989,7 @@ TEST_F(DownloadFileTest, MutipleStreamsLimitedLength) {
DestroyDownloadFile(0, false);
}
-// Activate and deplete one stream, later add the second stream.
+// Activate and deplete one stream, later add the second stream.
TEST_F(DownloadFileTest, MutipleStreamsFirstStreamWriteAllData) {
int64_t stream_0_length = GetBuffersLength(kTestData8, 4);
@@ -1022,4 +1022,40 @@ TEST_F(DownloadFileTest, MutipleStreamsFirstStreamWriteAllData) {
DestroyDownloadFile(0);
}
+// While one stream is writing, kick off another stream with an offset that has
+// been written by the first one.
+TEST_F(DownloadFileTest, SecondStreamStartingOffsetAlreadyWritten) {
+ int64_t stream_0_length = GetBuffersLength(kTestData6, 2);
+
+ ASSERT_TRUE(CreateDownloadFile(0, stream_0_length, true,
+ DownloadItem::ReceivedSlices()));
+
+ Sequence seq;
+ SetupDataAppend(kTestData6, 2, input_stream_, seq, 0);
+
+ EXPECT_CALL(*input_stream_, Read(_, _))
+ .InSequence(seq)
+ .WillOnce(Return(ByteStreamReader::STREAM_EMPTY))
+ .RetiresOnSaturation();
+ sink_callback_.Run();
+ base::RunLoop().RunUntilIdle();
+
+ additional_streams_[0] = new StrictMock<MockByteStreamReader>();
+ EXPECT_CALL(*additional_streams_[0], RegisterCallback(_))
+ .WillRepeatedly(Invoke(this, &DownloadFileTest::RegisterCallback))
+ .RetiresOnSaturation();
+ EXPECT_CALL(*additional_streams_[0], Read(_, _))
+ .WillOnce(Return(ByteStreamReader::STREAM_EMPTY))
+ .RetiresOnSaturation();
+
+ download_file_->AddByteStream(
+ std::unique_ptr<MockByteStreamReader>(additional_streams_[0]), 0,
+ DownloadSaveInfo::kLengthFullContent);
+
+ // The stream should get terminated and reset the callback.
+ EXPECT_TRUE(sink_callback_.is_null());
+ download_file_->Cancel();
+ DestroyDownloadFile(0, false);
+}
+
} // namespace content
« no previous file with comments | « content/browser/download/download_file_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698