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 "base/file_util.h" | 5 #include "base/file_util.h" |
6 #include "base/message_loop.h" | 6 #include "base/message_loop.h" |
7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
8 #include "base/test/test_file_util.h" | 8 #include "base/test/test_file_util.h" |
9 #include "content/browser/browser_thread_impl.h" | 9 #include "content/browser/browser_thread_impl.h" |
10 #include "content/browser/byte_stream.h" | 10 #include "content/browser/byte_stream.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 input_stream_ = new StrictMock<MockByteStreamReader>(); | 124 input_stream_ = new StrictMock<MockByteStreamReader>(); |
125 | 125 |
126 // TODO: Need to actually create a function that'll set the variables | 126 // TODO: Need to actually create a function that'll set the variables |
127 // based on the inputs from the callback. | 127 // based on the inputs from the callback. |
128 EXPECT_CALL(*input_stream_, RegisterCallback(_)) | 128 EXPECT_CALL(*input_stream_, RegisterCallback(_)) |
129 .WillOnce(Invoke(this, &DownloadFileTest::RegisterCallback)) | 129 .WillOnce(Invoke(this, &DownloadFileTest::RegisterCallback)) |
130 .RetiresOnSaturation(); | 130 .RetiresOnSaturation(); |
131 | 131 |
132 scoped_ptr<DownloadSaveInfo> save_info(new DownloadSaveInfo()); | 132 scoped_ptr<DownloadSaveInfo> save_info(new DownloadSaveInfo()); |
133 download_file_.reset( | 133 download_file_.reset( |
134 new DownloadFileImpl( | 134 new DownloadFileImpl(save_info.Pass(), |
135 save_info.Pass(), | 135 base::FilePath(), |
136 base::FilePath(), | 136 GURL(), // Source |
137 GURL(), // Source | 137 GURL(), // Referrer |
138 GURL(), // Referrer | 138 calculate_hash, |
139 calculate_hash, | 139 scoped_ptr<ByteStreamReader>(input_stream_), |
140 scoped_ptr<ByteStreamReader>(input_stream_), | 140 net::BoundNetLog(), |
141 net::BoundNetLog(), | 141 scoped_ptr<PowerSaveBlocker>().Pass(), |
142 scoped_ptr<PowerSaveBlocker>(NULL).Pass(), | 142 observer_factory_.GetWeakPtr())); |
143 observer_factory_.GetWeakPtr())); | |
144 | 143 |
145 EXPECT_CALL(*input_stream_, Read(_, _)) | 144 EXPECT_CALL(*input_stream_, Read(_, _)) |
146 .WillOnce(Return(ByteStreamReader::STREAM_EMPTY)) | 145 .WillOnce(Return(ByteStreamReader::STREAM_EMPTY)) |
147 .RetiresOnSaturation(); | 146 .RetiresOnSaturation(); |
148 | 147 |
149 base::WeakPtrFactory<DownloadFileTest> weak_ptr_factory(this); | 148 base::WeakPtrFactory<DownloadFileTest> weak_ptr_factory(this); |
150 bool called = false; | 149 bool called = false; |
151 DownloadInterruptReason result; | 150 DownloadInterruptReason result; |
152 download_file_->Initialize(base::Bind( | 151 download_file_->Initialize(base::Bind( |
153 &DownloadFileTest::SetInterruptReasonCallback, | 152 &DownloadFileTest::SetInterruptReasonCallback, |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 | 596 |
598 EXPECT_EQ(static_cast<int64>(strlen(kTestData1) + strlen(kTestData2)), | 597 EXPECT_EQ(static_cast<int64>(strlen(kTestData1) + strlen(kTestData2)), |
599 bytes_); | 598 bytes_); |
600 EXPECT_EQ(download_file_->GetHashState(), hash_state_); | 599 EXPECT_EQ(download_file_->GetHashState(), hash_state_); |
601 | 600 |
602 FinishStream(DOWNLOAD_INTERRUPT_REASON_NONE, true); | 601 FinishStream(DOWNLOAD_INTERRUPT_REASON_NONE, true); |
603 DestroyDownloadFile(0); | 602 DestroyDownloadFile(0); |
604 } | 603 } |
605 | 604 |
606 } // namespace content | 605 } // namespace content |
OLD | NEW |