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 <set> | 5 #include <set> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 MOCK_METHOD0(ShowDownloadInShell, void()); | 104 MOCK_METHOD0(ShowDownloadInShell, void()); |
105 MOCK_METHOD0(ValidateDangerousDownload, void()); | 105 MOCK_METHOD0(ValidateDangerousDownload, void()); |
106 MOCK_METHOD1(StealDangerousDownload, void(const AcquireFileCallback&)); | 106 MOCK_METHOD1(StealDangerousDownload, void(const AcquireFileCallback&)); |
107 MOCK_METHOD3(UpdateProgress, void(int64, int64, const std::string&)); | 107 MOCK_METHOD3(UpdateProgress, void(int64, int64, const std::string&)); |
108 MOCK_METHOD1(Cancel, void(bool)); | 108 MOCK_METHOD1(Cancel, void(bool)); |
109 MOCK_METHOD0(MarkAsComplete, void()); | 109 MOCK_METHOD0(MarkAsComplete, void()); |
110 MOCK_METHOD1(OnAllDataSaved, void(const std::string&)); | 110 MOCK_METHOD1(OnAllDataSaved, void(const std::string&)); |
111 MOCK_METHOD0(OnDownloadedFileRemoved, void()); | 111 MOCK_METHOD0(OnDownloadedFileRemoved, void()); |
112 virtual void Start( | 112 virtual void Start( |
113 scoped_ptr<DownloadFile> download_file, | 113 scoped_ptr<DownloadFile> download_file, |
114 scoped_ptr<DownloadRequestHandleInterface> req_handle) OVERRIDE { | 114 scoped_ptr<DownloadRequestHandleInterface> req_handle) override { |
115 MockStart(download_file.get(), req_handle.get()); | 115 MockStart(download_file.get(), req_handle.get()); |
116 } | 116 } |
117 | 117 |
118 MOCK_METHOD2(MockStart, void(DownloadFile*, DownloadRequestHandleInterface*)); | 118 MOCK_METHOD2(MockStart, void(DownloadFile*, DownloadRequestHandleInterface*)); |
119 | 119 |
120 MOCK_METHOD0(Remove, void()); | 120 MOCK_METHOD0(Remove, void()); |
121 MOCK_CONST_METHOD1(TimeRemaining, bool(base::TimeDelta*)); | 121 MOCK_CONST_METHOD1(TimeRemaining, bool(base::TimeDelta*)); |
122 MOCK_CONST_METHOD0(CurrentSpeed, int64()); | 122 MOCK_CONST_METHOD0(CurrentSpeed, int64()); |
123 MOCK_CONST_METHOD0(PercentComplete, int()); | 123 MOCK_CONST_METHOD0(PercentComplete, int()); |
124 MOCK_CONST_METHOD0(AllDataSaved, bool()); | 124 MOCK_CONST_METHOD0(AllDataSaved, bool()); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 MOCK_CONST_METHOD0(GetOpened, bool()); | 166 MOCK_CONST_METHOD0(GetOpened, bool()); |
167 MOCK_CONST_METHOD0(GetLastModifiedTime, const std::string&()); | 167 MOCK_CONST_METHOD0(GetLastModifiedTime, const std::string&()); |
168 MOCK_CONST_METHOD0(GetETag, const std::string&()); | 168 MOCK_CONST_METHOD0(GetETag, const std::string&()); |
169 MOCK_CONST_METHOD0(GetLastReason, DownloadInterruptReason()); | 169 MOCK_CONST_METHOD0(GetLastReason, DownloadInterruptReason()); |
170 MOCK_CONST_METHOD0(GetBrowserContext, BrowserContext*()); | 170 MOCK_CONST_METHOD0(GetBrowserContext, BrowserContext*()); |
171 MOCK_CONST_METHOD0(GetWebContents, WebContents*()); | 171 MOCK_CONST_METHOD0(GetWebContents, WebContents*()); |
172 MOCK_CONST_METHOD0(GetFileNameToReportUser, base::FilePath()); | 172 MOCK_CONST_METHOD0(GetFileNameToReportUser, base::FilePath()); |
173 MOCK_METHOD1(SetDisplayName, void(const base::FilePath&)); | 173 MOCK_METHOD1(SetDisplayName, void(const base::FilePath&)); |
174 MOCK_METHOD0(NotifyRemoved, void()); | 174 MOCK_METHOD0(NotifyRemoved, void()); |
175 // May be called when vlog is on. | 175 // May be called when vlog is on. |
176 virtual std::string DebugString(bool verbose) const OVERRIDE { | 176 virtual std::string DebugString(bool verbose) const override { |
177 return std::string(); | 177 return std::string(); |
178 } | 178 } |
179 }; | 179 }; |
180 | 180 |
181 class MockDownloadManagerDelegate : public DownloadManagerDelegate { | 181 class MockDownloadManagerDelegate : public DownloadManagerDelegate { |
182 public: | 182 public: |
183 MockDownloadManagerDelegate(); | 183 MockDownloadManagerDelegate(); |
184 virtual ~MockDownloadManagerDelegate(); | 184 virtual ~MockDownloadManagerDelegate(); |
185 | 185 |
186 MOCK_METHOD0(Shutdown, void()); | 186 MOCK_METHOD0(Shutdown, void()); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 const base::Time& start_time, | 241 const base::Time& start_time, |
242 const base::Time& end_time, | 242 const base::Time& end_time, |
243 const std::string& etag, | 243 const std::string& etag, |
244 const std::string& last_modofied, | 244 const std::string& last_modofied, |
245 int64 received_bytes, | 245 int64 received_bytes, |
246 int64 total_bytes, | 246 int64 total_bytes, |
247 DownloadItem::DownloadState state, | 247 DownloadItem::DownloadState state, |
248 DownloadDangerType danger_type, | 248 DownloadDangerType danger_type, |
249 DownloadInterruptReason interrupt_reason, | 249 DownloadInterruptReason interrupt_reason, |
250 bool opened, | 250 bool opened, |
251 const net::BoundNetLog& bound_net_log) OVERRIDE; | 251 const net::BoundNetLog& bound_net_log) override; |
252 virtual DownloadItemImpl* CreateActiveItem( | 252 virtual DownloadItemImpl* CreateActiveItem( |
253 DownloadItemImplDelegate* delegate, | 253 DownloadItemImplDelegate* delegate, |
254 uint32 download_id, | 254 uint32 download_id, |
255 const DownloadCreateInfo& info, | 255 const DownloadCreateInfo& info, |
256 const net::BoundNetLog& bound_net_log) OVERRIDE; | 256 const net::BoundNetLog& bound_net_log) override; |
257 virtual DownloadItemImpl* CreateSavePageItem( | 257 virtual DownloadItemImpl* CreateSavePageItem( |
258 DownloadItemImplDelegate* delegate, | 258 DownloadItemImplDelegate* delegate, |
259 uint32 download_id, | 259 uint32 download_id, |
260 const base::FilePath& path, | 260 const base::FilePath& path, |
261 const GURL& url, | 261 const GURL& url, |
262 const std::string& mime_type, | 262 const std::string& mime_type, |
263 scoped_ptr<DownloadRequestHandleInterface> request_handle, | 263 scoped_ptr<DownloadRequestHandleInterface> request_handle, |
264 const net::BoundNetLog& bound_net_log) OVERRIDE; | 264 const net::BoundNetLog& bound_net_log) override; |
265 | 265 |
266 private: | 266 private: |
267 std::map<uint32, MockDownloadItemImpl*> items_; | 267 std::map<uint32, MockDownloadItemImpl*> items_; |
268 DownloadItemImplDelegate item_delegate_; | 268 DownloadItemImplDelegate item_delegate_; |
269 | 269 |
270 DISALLOW_COPY_AND_ASSIGN(MockDownloadItemFactory); | 270 DISALLOW_COPY_AND_ASSIGN(MockDownloadItemFactory); |
271 }; | 271 }; |
272 | 272 |
273 MockDownloadItemFactory::MockDownloadItemFactory() {} | 273 MockDownloadItemFactory::MockDownloadItemFactory() {} |
274 | 274 |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
680 .WillOnce(Return()); | 680 .WillOnce(Return()); |
681 EXPECT_CALL(GetMockDownloadItem(3), Remove()) | 681 EXPECT_CALL(GetMockDownloadItem(3), Remove()) |
682 .Times(0); | 682 .Times(0); |
683 | 683 |
684 download_manager_->RemoveAllDownloads(); | 684 download_manager_->RemoveAllDownloads(); |
685 // Because we're mocking the download item, the Remove call doesn't | 685 // Because we're mocking the download item, the Remove call doesn't |
686 // result in them being removed from the DownloadManager list. | 686 // result in them being removed from the DownloadManager list. |
687 } | 687 } |
688 | 688 |
689 } // namespace content | 689 } // namespace content |
OLD | NEW |