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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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( | 64 file->reset( |
65 new DownloadFile(&info, DownloadRequestHandle(), download_manager_)); | 65 new DownloadFile(&info, new DownloadRequestHandle(), |
| 66 download_manager_)); |
66 } | 67 } |
67 | 68 |
68 virtual void DestroyDownloadFile(scoped_ptr<DownloadFile>* file, int offset) { | 69 virtual void DestroyDownloadFile(scoped_ptr<DownloadFile>* file, int offset) { |
69 EXPECT_EQ(kDummyDownloadId + offset, (*file)->id()); | 70 EXPECT_EQ(kDummyDownloadId + offset, (*file)->id()); |
70 EXPECT_EQ(download_manager_, (*file)->GetDownloadManager()); | 71 EXPECT_EQ(download_manager_, (*file)->GetDownloadManager()); |
71 EXPECT_FALSE((*file)->in_progress()); | 72 EXPECT_FALSE((*file)->in_progress()); |
72 EXPECT_EQ(static_cast<int64>(expected_data_.size()), | 73 EXPECT_EQ(static_cast<int64>(expected_data_.size()), |
73 (*file)->bytes_so_far()); | 74 (*file)->bytes_so_far()); |
74 | 75 |
75 // Make sure the data has been properly written to disk. | 76 // Make sure the data has been properly written to disk. |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 // Check the files. | 184 // Check the files. |
184 EXPECT_FALSE(file_util::PathExists(path_3)); | 185 EXPECT_FALSE(file_util::PathExists(path_3)); |
185 EXPECT_TRUE(file_util::PathExists(path_4)); | 186 EXPECT_TRUE(file_util::PathExists(path_4)); |
186 | 187 |
187 // Check the hash. | 188 // Check the hash. |
188 EXPECT_TRUE(download_file_->GetSha256Hash(&hash)); | 189 EXPECT_TRUE(download_file_->GetSha256Hash(&hash)); |
189 EXPECT_EQ(kDataHash, base::HexEncode(hash.data(), hash.size())); | 190 EXPECT_EQ(kDataHash, base::HexEncode(hash.data(), hash.size())); |
190 | 191 |
191 DestroyDownloadFile(&download_file_, 0); | 192 DestroyDownloadFile(&download_file_, 0); |
192 } | 193 } |
OLD | NEW |