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

Side by Side Diff: content/browser/download/download_manager_impl_unittest.cc

Issue 10831302: Download resumption - Preliminary (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixed signed/unsigned compare issue. Created 8 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 unified diff | Download patch
OLDNEW
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/file_util.h" 9 #include "base/file_util.h"
10 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 MOCK_METHOD0(OpenDownload, void()); 92 MOCK_METHOD0(OpenDownload, void());
93 MOCK_METHOD0(ShowDownloadInShell, void()); 93 MOCK_METHOD0(ShowDownloadInShell, void());
94 MOCK_METHOD0(DangerousDownloadValidated, void()); 94 MOCK_METHOD0(DangerousDownloadValidated, void());
95 MOCK_METHOD3(UpdateProgress, void(int64, int64, const std::string&)); 95 MOCK_METHOD3(UpdateProgress, void(int64, int64, const std::string&));
96 MOCK_METHOD1(Cancel, void(bool)); 96 MOCK_METHOD1(Cancel, void(bool));
97 MOCK_METHOD0(MarkAsComplete, void()); 97 MOCK_METHOD0(MarkAsComplete, void());
98 MOCK_METHOD1(OnAllDataSaved, void(const std::string&)); 98 MOCK_METHOD1(OnAllDataSaved, void(const std::string&));
99 MOCK_METHOD0(OnDownloadedFileRemoved, void()); 99 MOCK_METHOD0(OnDownloadedFileRemoved, void());
100 MOCK_METHOD0(MaybeCompleteDownload, void()); 100 MOCK_METHOD0(MaybeCompleteDownload, void());
101 virtual void Start( 101 virtual void Start(
102 scoped_ptr<DownloadFile> download_file) OVERRIDE { 102 scoped_ptr<DownloadFile> download_file,
103 MockStart(download_file.get()); 103 scoped_ptr<DownloadRequestHandleInterface> req_handle) OVERRIDE {
104 MockStart(download_file.get(), req_handle.get());
104 } 105 }
105 106
106 MOCK_METHOD1(MockStart, void(DownloadFile*)); 107 MOCK_METHOD2(MockStart, void(DownloadFile*, DownloadRequestHandleInterface*));
107 108
108 MOCK_METHOD1(Delete, void(DeleteReason)); 109 MOCK_METHOD1(Delete, void(DeleteReason));
109 MOCK_METHOD0(Remove, void()); 110 MOCK_METHOD0(Remove, void());
110 MOCK_CONST_METHOD1(TimeRemaining, bool(base::TimeDelta*)); 111 MOCK_CONST_METHOD1(TimeRemaining, bool(base::TimeDelta*));
111 MOCK_CONST_METHOD0(CurrentSpeed, int64()); 112 MOCK_CONST_METHOD0(CurrentSpeed, int64());
112 MOCK_CONST_METHOD0(PercentComplete, int()); 113 MOCK_CONST_METHOD0(PercentComplete, int());
113 MOCK_CONST_METHOD0(AllDataSaved, bool()); 114 MOCK_CONST_METHOD0(AllDataSaved, bool());
114 MOCK_METHOD0(TogglePause, void()); 115 MOCK_METHOD0(TogglePause, void());
115 MOCK_CONST_METHOD1(MatchesQuery, bool(const string16& query)); 116 MOCK_CONST_METHOD1(MatchesQuery, bool(const string16& query));
116 MOCK_CONST_METHOD0(IsPartialDownload, bool()); 117 MOCK_CONST_METHOD0(IsPartialDownload, bool());
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 const base::Time& start_time, 232 const base::Time& start_time,
232 const base::Time& end_time, 233 const base::Time& end_time,
233 int64 received_bytes, 234 int64 received_bytes,
234 int64 total_bytes, 235 int64 total_bytes,
235 DownloadItem::DownloadState state, 236 DownloadItem::DownloadState state,
236 bool opened, 237 bool opened,
237 const net::BoundNetLog& bound_net_log) OVERRIDE; 238 const net::BoundNetLog& bound_net_log) OVERRIDE;
238 virtual DownloadItemImpl* CreateActiveItem( 239 virtual DownloadItemImpl* CreateActiveItem(
239 DownloadItemImplDelegate* delegate, 240 DownloadItemImplDelegate* delegate,
240 const DownloadCreateInfo& info, 241 const DownloadCreateInfo& info,
241 scoped_ptr<DownloadRequestHandleInterface> request_handle,
242 const net::BoundNetLog& bound_net_log) OVERRIDE; 242 const net::BoundNetLog& bound_net_log) OVERRIDE;
243 virtual DownloadItemImpl* CreateSavePageItem( 243 virtual DownloadItemImpl* CreateSavePageItem(
244 DownloadItemImplDelegate* delegate, 244 DownloadItemImplDelegate* delegate,
245 const FilePath& path, 245 const FilePath& path,
246 const GURL& url, 246 const GURL& url,
247 DownloadId download_id, 247 DownloadId download_id,
248 const std::string& mime_type, 248 const std::string& mime_type,
249 const net::BoundNetLog& bound_net_log) OVERRIDE; 249 const net::BoundNetLog& bound_net_log) OVERRIDE;
250 250
251 private: 251 private:
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 EXPECT_CALL(*result, GetId()) 302 EXPECT_CALL(*result, GetId())
303 .WillRepeatedly(Return(local_id)); 303 .WillRepeatedly(Return(local_id));
304 items_[local_id] = result; 304 items_[local_id] = result;
305 305
306 return result; 306 return result;
307 } 307 }
308 308
309 DownloadItemImpl* MockDownloadItemFactory::CreateActiveItem( 309 DownloadItemImpl* MockDownloadItemFactory::CreateActiveItem(
310 DownloadItemImplDelegate* delegate, 310 DownloadItemImplDelegate* delegate,
311 const DownloadCreateInfo& info, 311 const DownloadCreateInfo& info,
312 scoped_ptr<DownloadRequestHandleInterface> request_handle,
313 const net::BoundNetLog& bound_net_log) { 312 const net::BoundNetLog& bound_net_log) {
314 int local_id = info.download_id.local(); 313 int local_id = info.download_id.local();
315 DCHECK(items_.find(local_id) == items_.end()); 314 DCHECK(items_.find(local_id) == items_.end());
316 315
317 MockDownloadItemImpl* result = 316 MockDownloadItemImpl* result =
318 new StrictMock<MockDownloadItemImpl>(&item_delegate_); 317 new StrictMock<MockDownloadItemImpl>(&item_delegate_);
319 EXPECT_CALL(*result, GetId()) 318 EXPECT_CALL(*result, GetId())
320 .WillRepeatedly(Return(local_id)); 319 .WillRepeatedly(Return(local_id));
321 EXPECT_CALL(*result, GetGlobalId()) 320 EXPECT_CALL(*result, GetGlobalId())
322 .WillRepeatedly(Return(DownloadId(delegate, local_id))); 321 .WillRepeatedly(Return(DownloadId(delegate, local_id)));
323 items_[local_id] = result; 322 items_[local_id] = result;
324 323
325 // Active items are created and then immediately are called to start 324 // Active items are created and then immediately are called to start
326 // the download. 325 // the download.
327 EXPECT_CALL(*result, MockStart(_)); 326 EXPECT_CALL(*result, MockStart(_, _));
328 327
329 return result; 328 return result;
330 } 329 }
331 330
332 DownloadItemImpl* MockDownloadItemFactory::CreateSavePageItem( 331 DownloadItemImpl* MockDownloadItemFactory::CreateSavePageItem(
333 DownloadItemImplDelegate* delegate, 332 DownloadItemImplDelegate* delegate,
334 const FilePath& path, 333 const FilePath& path,
335 const GURL& url, 334 const GURL& url,
336 DownloadId download_id, 335 DownloadId download_id,
337 const std::string& mime_type, 336 const std::string& mime_type,
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 DownloadCreateInfo info; 489 DownloadCreateInfo info;
491 490
492 static const char* kDownloadIdDomain = "Test download id domain"; 491 static const char* kDownloadIdDomain = "Test download id domain";
493 492
494 // Args are ignored except for download id, so everything else can be 493 // Args are ignored except for download id, so everything else can be
495 // null. 494 // null.
496 int id = next_download_id_; 495 int id = next_download_id_;
497 ++next_download_id_; 496 ++next_download_id_;
498 info.download_id = DownloadId(kDownloadIdDomain, id); 497 info.download_id = DownloadId(kDownloadIdDomain, id);
499 info.request_handle = DownloadRequestHandle(); 498 info.request_handle = DownloadRequestHandle();
500 download_manager_->CreateDownloadItem(&info, net::BoundNetLog()); 499 download_manager_->CreateDownloadItem(&info);
501 500
502 DCHECK(mock_download_item_factory_->GetItem(id)); 501 DCHECK(mock_download_item_factory_->GetItem(id));
503 MockDownloadItemImpl& item(*mock_download_item_factory_->GetItem(id)); 502 MockDownloadItemImpl& item(*mock_download_item_factory_->GetItem(id));
504 // Satisfy expectation. If the item is created in StartDownload(), 503 // Satisfy expectation. If the item is created in StartDownload(),
505 // we call Start on it immediately, so we need to set that expectation 504 // we call Start on it immediately, so we need to set that expectation
506 // in the factory. 505 // in the factory.
507 item.Start(scoped_ptr<DownloadFile>()); 506 scoped_ptr<DownloadRequestHandleInterface> req_handle;
507 item.Start(scoped_ptr<DownloadFile>(), req_handle.Pass());
508 508
509 return item; 509 return item;
510 } 510 }
511 511
512 MockDownloadItemImpl& GetMockDownloadItem(int id) { 512 MockDownloadItemImpl& GetMockDownloadItem(int id) {
513 MockDownloadItemImpl* itemp = mock_download_item_factory_->GetItem(id); 513 MockDownloadItemImpl* itemp = mock_download_item_factory_->GetItem(id);
514 514
515 DCHECK(itemp); 515 DCHECK(itemp);
516 return *itemp; 516 return *itemp;
517 } 517 }
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 // Put a mock we have a handle to on the download manager. 663 // Put a mock we have a handle to on the download manager.
664 MockDownloadItemImpl& item(AddItemToManager()); 664 MockDownloadItemImpl& item(AddItemToManager());
665 665
666 EXPECT_CALL(item, GetState()) 666 EXPECT_CALL(item, GetState())
667 .WillRepeatedly(Return(DownloadItem::CANCELLED)); 667 .WillRepeatedly(Return(DownloadItem::CANCELLED));
668 668
669 DownloadStopped(&item); 669 DownloadStopped(&item);
670 } 670 }
671 671
672 } // namespace content 672 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/download/download_manager_impl.cc ('k') | content/browser/download/download_net_log_parameters.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698