| OLD | NEW |
| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1015 | 1015 |
| 1016 SourceStreamTestData stream_data_0(0, stream_0_length, true); | 1016 SourceStreamTestData stream_data_0(0, stream_0_length, true); |
| 1017 SourceStreamTestData stream_data_1(stream_0_length - 1, 0, false); | 1017 SourceStreamTestData stream_data_1(stream_0_length - 1, 0, false); |
| 1018 VerifySourceStreamsStates(stream_data_0); | 1018 VerifySourceStreamsStates(stream_data_0); |
| 1019 VerifySourceStreamsStates(stream_data_1); | 1019 VerifySourceStreamsStates(stream_data_1); |
| 1020 EXPECT_EQ(stream_0_length, TotalBytesReceived()); | 1020 EXPECT_EQ(stream_0_length, TotalBytesReceived()); |
| 1021 | 1021 |
| 1022 DestroyDownloadFile(0); | 1022 DestroyDownloadFile(0); |
| 1023 } | 1023 } |
| 1024 | 1024 |
| 1025 // While one stream is writing, kick off another stream with an offset that has |
| 1026 // been written by the first one. |
| 1027 TEST_F(DownloadFileTest, SecondStreamStartingOffsetAlreadyWritten) { |
| 1028 int64_t stream_0_length = GetBuffersLength(kTestData6, 2); |
| 1029 |
| 1030 ASSERT_TRUE(CreateDownloadFile(0, stream_0_length, true, |
| 1031 DownloadItem::ReceivedSlices())); |
| 1032 |
| 1033 Sequence seq; |
| 1034 SetupDataAppend(kTestData6, 2, input_stream_, seq, 0); |
| 1035 |
| 1036 EXPECT_CALL(*input_stream_, Read(_, _)) |
| 1037 .InSequence(seq) |
| 1038 .WillOnce(Return(ByteStreamReader::STREAM_EMPTY)) |
| 1039 .RetiresOnSaturation(); |
| 1040 sink_callback_.Run(); |
| 1041 base::RunLoop().RunUntilIdle(); |
| 1042 |
| 1043 additional_streams_[0] = new StrictMock<MockByteStreamReader>(); |
| 1044 EXPECT_CALL(*additional_streams_[0], RegisterCallback(_)) |
| 1045 .WillRepeatedly(Invoke(this, &DownloadFileTest::RegisterCallback)) |
| 1046 .RetiresOnSaturation(); |
| 1047 EXPECT_CALL(*additional_streams_[0], Read(_, _)) |
| 1048 .WillOnce(Return(ByteStreamReader::STREAM_EMPTY)) |
| 1049 .RetiresOnSaturation(); |
| 1050 |
| 1051 download_file_->AddByteStream( |
| 1052 std::unique_ptr<MockByteStreamReader>(additional_streams_[0]), 0, |
| 1053 DownloadSaveInfo::kLengthFullContent); |
| 1054 |
| 1055 // The stream should get terminated and reset the callback. |
| 1056 EXPECT_TRUE(sink_callback_.is_null()); |
| 1057 download_file_->Cancel(); |
| 1058 DestroyDownloadFile(0, false); |
| 1059 } |
| 1060 |
| 1025 } // namespace content | 1061 } // namespace content |
| OLD | NEW |