Chromium Code Reviews| 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/string_number_conversions.h" | 7 #include "base/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/download/byte_stream.h" | 10 #include "content/browser/download/byte_stream.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 120 // to ensure that all resources are cleaned up before the test exits. | 120 // to ensure that all resources are cleaned up before the test exits. |
| 121 download_manager_ = NULL; | 121 download_manager_ = NULL; |
| 122 ui_thread_.message_loop()->RunAllPending(); | 122 ui_thread_.message_loop()->RunAllPending(); |
| 123 } | 123 } |
| 124 | 124 |
| 125 // Mock calls to this function are forwarded here. | 125 // Mock calls to this function are forwarded here. |
| 126 void RegisterCallback(base::Closure sink_callback) { | 126 void RegisterCallback(base::Closure sink_callback) { |
| 127 sink_callback_ = sink_callback; | 127 sink_callback_ = sink_callback; |
| 128 } | 128 } |
| 129 | 129 |
| 130 void SetInterruptReasonCallback(bool* was_called, | |
|
asanka
2012/09/20 18:42:15
Is this used?
Randy Smith (Not in Mondays)
2012/09/21 21:58:01
Apparently not. I think I was a bit too fast and
| |
| 131 content::DownloadInterruptReason* reason_p, | |
| 132 content::DownloadInterruptReason reason) { | |
| 133 *was_called = true; | |
| 134 *reason_p = reason; | |
| 135 } | |
| 136 | |
| 130 virtual bool CreateDownloadFile(int offset, bool calculate_hash) { | 137 virtual bool CreateDownloadFile(int offset, bool calculate_hash) { |
| 131 // There can be only one. | 138 // There can be only one. |
| 132 DCHECK(!download_file_.get()); | 139 DCHECK(!download_file_.get()); |
| 133 | 140 |
| 134 input_stream_ = new StrictMock<MockByteStreamReader>(); | 141 input_stream_ = new StrictMock<MockByteStreamReader>(); |
| 135 | 142 |
| 136 // TODO: Need to actually create a function that'll set the variables | 143 // TODO: Need to actually create a function that'll set the variables |
| 137 // based on the inputs from the callback. | 144 // based on the inputs from the callback. |
| 138 EXPECT_CALL(*input_stream_, RegisterCallback(_)) | 145 EXPECT_CALL(*input_stream_, RegisterCallback(_)) |
| 139 .WillOnce(Invoke(this, &DownloadFileTest::RegisterCallback)) | 146 .WillOnce(Invoke(this, &DownloadFileTest::RegisterCallback)) |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 602 base::TimeDelta::FromMilliseconds(750)); | 609 base::TimeDelta::FromMilliseconds(750)); |
| 603 loop_.Run(); | 610 loop_.Run(); |
| 604 | 611 |
| 605 EXPECT_EQ(static_cast<int64>(strlen(kTestData1) + strlen(kTestData2)), | 612 EXPECT_EQ(static_cast<int64>(strlen(kTestData1) + strlen(kTestData2)), |
| 606 bytes_); | 613 bytes_); |
| 607 EXPECT_EQ(download_file_->GetHashState(), hash_state_); | 614 EXPECT_EQ(download_file_->GetHashState(), hash_state_); |
| 608 | 615 |
| 609 FinishStream(content::DOWNLOAD_INTERRUPT_REASON_NONE, true); | 616 FinishStream(content::DOWNLOAD_INTERRUPT_REASON_NONE, true); |
| 610 DestroyDownloadFile(0); | 617 DestroyDownloadFile(0); |
| 611 } | 618 } |
| OLD | NEW |