| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/browser/browser_thread.h" | 8 #include "content/browser/browser_thread.h" |
| 9 #include "content/browser/download/download_create_info.h" | 9 #include "content/browser/download/download_create_info.h" |
| 10 #include "content/browser/download/download_file.h" | 10 #include "content/browser/download/download_file.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 // to ensure that all resources are cleaned up before the test exits. | 54 // to ensure that all resources are cleaned up before the test exits. |
| 55 download_manager_ = NULL; | 55 download_manager_ = NULL; |
| 56 ui_thread_.message_loop()->RunAllPending(); | 56 ui_thread_.message_loop()->RunAllPending(); |
| 57 } | 57 } |
| 58 | 58 |
| 59 virtual void CreateDownloadFile(scoped_ptr<DownloadFile>* file, int offset) { | 59 virtual void CreateDownloadFile(scoped_ptr<DownloadFile>* file, int offset) { |
| 60 DownloadCreateInfo info; | 60 DownloadCreateInfo info; |
| 61 info.download_id = kDummyDownloadId + offset; | 61 info.download_id = kDummyDownloadId + offset; |
| 62 // info.request_handle default constructed to null. | 62 // info.request_handle default constructed to null. |
| 63 info.save_info.file_stream = file_stream_; | 63 info.save_info.file_stream = file_stream_; |
| 64 file->reset(new DownloadFile(&info, download_manager_)); | 64 file->reset( |
| 65 new DownloadFile(&info, DownloadRequestHandle(), download_manager_)); |
| 65 } | 66 } |
| 66 | 67 |
| 67 virtual void DestroyDownloadFile(scoped_ptr<DownloadFile>* file, int offset) { | 68 virtual void DestroyDownloadFile(scoped_ptr<DownloadFile>* file, int offset) { |
| 68 EXPECT_EQ(kDummyDownloadId + offset, (*file)->id()); | 69 EXPECT_EQ(kDummyDownloadId + offset, (*file)->id()); |
| 69 EXPECT_EQ(download_manager_, (*file)->GetDownloadManager()); | 70 EXPECT_EQ(download_manager_, (*file)->GetDownloadManager()); |
| 70 EXPECT_FALSE((*file)->in_progress()); | 71 EXPECT_FALSE((*file)->in_progress()); |
| 71 EXPECT_EQ(static_cast<int64>(expected_data_.size()), | 72 EXPECT_EQ(static_cast<int64>(expected_data_.size()), |
| 72 (*file)->bytes_so_far()); | 73 (*file)->bytes_so_far()); |
| 73 | 74 |
| 74 // Make sure the data has been properly written to disk. | 75 // Make sure the data has been properly written to disk. |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 // Check the files. | 183 // Check the files. |
| 183 EXPECT_FALSE(file_util::PathExists(path_3)); | 184 EXPECT_FALSE(file_util::PathExists(path_3)); |
| 184 EXPECT_TRUE(file_util::PathExists(path_4)); | 185 EXPECT_TRUE(file_util::PathExists(path_4)); |
| 185 | 186 |
| 186 // Check the hash. | 187 // Check the hash. |
| 187 EXPECT_TRUE(download_file_->GetSha256Hash(&hash)); | 188 EXPECT_TRUE(download_file_->GetSha256Hash(&hash)); |
| 188 EXPECT_EQ(kDataHash, base::HexEncode(hash.data(), hash.size())); | 189 EXPECT_EQ(kDataHash, base::HexEncode(hash.data(), hash.size())); |
| 189 | 190 |
| 190 DestroyDownloadFile(&download_file_, 0); | 191 DestroyDownloadFile(&download_file_, 0); |
| 191 } | 192 } |
| OLD | NEW |