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

Unified Diff: chrome/browser/download/download_manager_unittest.cc

Issue 8404049: Added member data to classes to support download resumption. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Updated comment. Created 9 years 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
Index: chrome/browser/download/download_manager_unittest.cc
diff --git a/chrome/browser/download/download_manager_unittest.cc b/chrome/browser/download/download_manager_unittest.cc
index 61116f0af3b29f8b0e617c77053bf5d92f5a49dc..1fa71833dd03f98ca6d2dce8e6aaf440f9672d1d 100644
--- a/chrome/browser/download/download_manager_unittest.cc
+++ b/chrome/browser/download/download_manager_unittest.cc
@@ -65,13 +65,15 @@ class MockDownloadFileFactory
virtual DownloadFile* CreateFile(DownloadCreateInfo* info,
const DownloadRequestHandle& request_handle,
- DownloadManager* download_manager) OVERRIDE;
+ DownloadManager* download_manager,
+ bool calculate_hash) OVERRIDE;
};
DownloadFile* MockDownloadFileFactory::CreateFile(
DownloadCreateInfo* info,
const DownloadRequestHandle& request_handle,
- DownloadManager* download_manager) {
+ DownloadManager* download_manager,
+ bool calculate_hash) {
NOTREACHED();
return NULL;
}
@@ -222,8 +224,10 @@ class DownloadManagerTest : public testing::Test {
}
void OnDownloadInterrupted(int32 download_id, int64 size,
+ const std::string& hash_state,
InterruptReason reason) {
- download_manager_->OnDownloadInterrupted(download_id, size, reason);
+ download_manager_->OnDownloadInterrupted(download_id, size,
+ hash_state, reason);
}
// Get the download item with ID |id|.
@@ -262,11 +266,13 @@ const size_t DownloadManagerTest::kTestDataLen =
// A DownloadFile that we can inject errors into.
class DownloadFileWithErrors : public DownloadFileImpl {
public:
- DownloadFileWithErrors(DownloadCreateInfo* info, DownloadManager* manager);
+ DownloadFileWithErrors(DownloadCreateInfo* info,
+ DownloadManager* manager,
+ bool calculate_hash);
virtual ~DownloadFileWithErrors() {}
// BaseFile delegated functions.
- virtual net::Error Initialize(bool calculate_hash);
+ virtual net::Error Initialize();
virtual net::Error AppendDataToFile(const char* data, size_t data_len);
virtual net::Error Rename(const FilePath& full_path);
@@ -289,13 +295,17 @@ class DownloadFileWithErrors : public DownloadFileImpl {
};
DownloadFileWithErrors::DownloadFileWithErrors(DownloadCreateInfo* info,
- DownloadManager* manager)
- : DownloadFileImpl(info, new DownloadRequestHandle(), manager),
+ DownloadManager* manager,
+ bool calculate_hash)
+ : DownloadFileImpl(info,
+ new DownloadRequestHandle(),
+ manager,
+ calculate_hash),
forced_error_(net::OK) {
}
-net::Error DownloadFileWithErrors::Initialize(bool calculate_hash) {
- return ReturnError(DownloadFileImpl::Initialize(calculate_hash));
+net::Error DownloadFileWithErrors::Initialize() {
+ return ReturnError(DownloadFileImpl::Initialize());
}
net::Error DownloadFileWithErrors::AppendDataToFile(const char* data,
@@ -483,9 +493,9 @@ TEST_F(DownloadManagerTest, MAYBE_StartDownload) {
DownloadFile* download_file(
new DownloadFileImpl(info.get(), new DownloadRequestHandle(),
- download_manager_));
+ download_manager_, false));
AddDownloadToFileManager(info->download_id.local(), download_file);
- download_file->Initialize(false);
+ download_file->Initialize();
download_manager_->StartDownload(info->download_id.local());
message_loop_.RunAllPending();
@@ -921,7 +931,7 @@ TEST_F(DownloadManagerTest, DownloadInterruptTest) {
EXPECT_TRUE(GetActiveDownloadItem(0) != NULL);
int64 error_size = 3;
- OnDownloadInterrupted(0, error_size,
+ OnDownloadInterrupted(0, error_size, "",
DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED);
message_loop_.RunAllPending();
@@ -987,7 +997,8 @@ TEST_F(DownloadManagerTest, DownloadFileErrorTest) {
// Create a download file that we can insert errors into.
DownloadFileWithErrors* download_file(new DownloadFileWithErrors(
- info.get(), download_manager_));
+ info.get(), download_manager_, false));
+ download_file->Initialize();
AddDownloadToFileManager(local_id, download_file);
// |download_file| is owned by DownloadFileManager.
@@ -1161,10 +1172,10 @@ TEST_F(DownloadManagerTest, MAYBE_DownloadOverwriteTest) {
// properly.
DownloadFile* download_file(
new DownloadFileImpl(info.get(), new DownloadRequestHandle(),
- download_manager_));
+ download_manager_, false));
download_file->Rename(cr_path);
// This creates the .crdownload version of the file.
- download_file->Initialize(false);
+ download_file->Initialize();
// |download_file| is owned by DownloadFileManager.
AddDownloadToFileManager(info->download_id.local(), download_file);
@@ -1238,10 +1249,10 @@ TEST_F(DownloadManagerTest, MAYBE_DownloadRemoveTest) {
// properly.
DownloadFile* download_file(
new DownloadFileImpl(info.get(), new DownloadRequestHandle(),
- download_manager_));
+ download_manager_, false));
download_file->Rename(cr_path);
// This creates the .crdownload version of the file.
- download_file->Initialize(false);
+ download_file->Initialize();
// |download_file| is owned by DownloadFileManager.
AddDownloadToFileManager(info->download_id.local(), download_file);

Powered by Google App Engine
This is Rietveld 408576698