| 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_impl.h" | 8 #include "content/browser/browser_thread_impl.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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 download_manager_ = NULL; | 64 download_manager_ = NULL; |
| 65 ui_thread_.message_loop()->RunAllPending(); | 65 ui_thread_.message_loop()->RunAllPending(); |
| 66 } | 66 } |
| 67 | 67 |
| 68 virtual void CreateDownloadFile(scoped_ptr<DownloadFile>* file, int offset) { | 68 virtual void CreateDownloadFile(scoped_ptr<DownloadFile>* file, int offset) { |
| 69 DownloadCreateInfo info; | 69 DownloadCreateInfo info; |
| 70 info.download_id = DownloadId(kValidIdDomain, kDummyDownloadId + offset); | 70 info.download_id = DownloadId(kValidIdDomain, kDummyDownloadId + offset); |
| 71 // info.request_handle default constructed to null. | 71 // info.request_handle default constructed to null. |
| 72 info.save_info.file_stream = file_stream_; | 72 info.save_info.file_stream = file_stream_; |
| 73 file->reset( | 73 file->reset( |
| 74 new DownloadFile(&info, DownloadRequestHandle(), download_manager_)); | 74 new DownloadFile(&info, new DownloadRequestHandle(), |
| 75 download_manager_)); |
| 75 } | 76 } |
| 76 | 77 |
| 77 virtual void DestroyDownloadFile(scoped_ptr<DownloadFile>* file, int offset) { | 78 virtual void DestroyDownloadFile(scoped_ptr<DownloadFile>* file, int offset) { |
| 78 EXPECT_EQ(kDummyDownloadId + offset, (*file)->id()); | 79 EXPECT_EQ(kDummyDownloadId + offset, (*file)->id()); |
| 79 EXPECT_EQ(download_manager_, (*file)->GetDownloadManager()); | 80 EXPECT_EQ(download_manager_, (*file)->GetDownloadManager()); |
| 80 EXPECT_FALSE((*file)->in_progress()); | 81 EXPECT_FALSE((*file)->in_progress()); |
| 81 EXPECT_EQ(static_cast<int64>(expected_data_.size()), | 82 EXPECT_EQ(static_cast<int64>(expected_data_.size()), |
| 82 (*file)->bytes_so_far()); | 83 (*file)->bytes_so_far()); |
| 83 | 84 |
| 84 // Make sure the data has been properly written to disk. | 85 // Make sure the data has been properly written to disk. |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 // Check the files. | 194 // Check the files. |
| 194 EXPECT_FALSE(file_util::PathExists(path_3)); | 195 EXPECT_FALSE(file_util::PathExists(path_3)); |
| 195 EXPECT_TRUE(file_util::PathExists(path_4)); | 196 EXPECT_TRUE(file_util::PathExists(path_4)); |
| 196 | 197 |
| 197 // Check the hash. | 198 // Check the hash. |
| 198 EXPECT_TRUE(download_file_->GetSha256Hash(&hash)); | 199 EXPECT_TRUE(download_file_->GetSha256Hash(&hash)); |
| 199 EXPECT_EQ(kDataHash, base::HexEncode(hash.data(), hash.size())); | 200 EXPECT_EQ(kDataHash, base::HexEncode(hash.data(), hash.size())); |
| 200 | 201 |
| 201 DestroyDownloadFile(&download_file_, 0); | 202 DestroyDownloadFile(&download_file_, 0); |
| 202 } | 203 } |
| OLD | NEW |