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

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

Issue 9296012: Hooked up NetLog to DownloadItem, DownloadFile, and FileStream. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Create DownloadItem's BoundNetLog closer to constructor Created 8 years, 10 months 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 | Annotate | Revision Log
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 "content/browser/download/download_file_manager.h" 5 #include "content/browser/download/download_file_manager.h"
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
(...skipping 26 matching lines...) Expand all
37 public DownloadFileManager::DownloadFileFactory { 37 public DownloadFileManager::DownloadFileFactory {
38 38
39 public: 39 public:
40 MockDownloadFileFactory() {} 40 MockDownloadFileFactory() {}
41 virtual ~MockDownloadFileFactory() {} 41 virtual ~MockDownloadFileFactory() {}
42 42
43 virtual content::DownloadFile* CreateFile( 43 virtual content::DownloadFile* CreateFile(
44 DownloadCreateInfo* info, 44 DownloadCreateInfo* info,
45 const DownloadRequestHandle& request_handle, 45 const DownloadRequestHandle& request_handle,
46 content::DownloadManager* download_manager, 46 content::DownloadManager* download_manager,
47 bool calculate_hash) OVERRIDE; 47 bool calculate_hash,
48 const net::BoundNetLog& bound_net_log) OVERRIDE;
48 49
49 MockDownloadFile* GetExistingFile(const DownloadId& id); 50 MockDownloadFile* GetExistingFile(const DownloadId& id);
50 51
51 private: 52 private:
52 std::map<DownloadId, MockDownloadFile*> files_; 53 std::map<DownloadId, MockDownloadFile*> files_;
53 }; 54 };
54 55
55 content::DownloadFile* MockDownloadFileFactory::CreateFile( 56 content::DownloadFile* MockDownloadFileFactory::CreateFile(
56 DownloadCreateInfo* info, 57 DownloadCreateInfo* info,
57 const DownloadRequestHandle& request_handle, 58 const DownloadRequestHandle& request_handle,
58 content::DownloadManager* download_manager, 59 content::DownloadManager* download_manager,
59 bool calculate_hash) { 60 bool calculate_hash,
61 const net::BoundNetLog& bound_net_log) {
60 DCHECK(files_.end() == files_.find(info->download_id)); 62 DCHECK(files_.end() == files_.find(info->download_id));
61 MockDownloadFile* created_file = new MockDownloadFile(); 63 MockDownloadFile* created_file = new MockDownloadFile();
62 files_[info->download_id] = created_file; 64 files_[info->download_id] = created_file;
63 65
64 ON_CALL(*created_file, GetDownloadManager()) 66 ON_CALL(*created_file, GetDownloadManager())
65 .WillByDefault(Return(download_manager)); 67 .WillByDefault(Return(download_manager));
66 68
67 return created_file; 69 return created_file;
68 } 70 }
69 71
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 // new MockDownloadFile, add to downloads_[id] 162 // new MockDownloadFile, add to downloads_[id]
161 // DownloadRequestHandle::ResumeRequest 163 // DownloadRequestHandle::ResumeRequest
162 // StartUpdateTimer 164 // StartUpdateTimer
163 // DownloadCreateInfo is destroyed 165 // DownloadCreateInfo is destroyed
164 // Process one message in the message loop 166 // Process one message in the message loop
165 // DownloadManager::StartDownload 167 // DownloadManager::StartDownload
166 info->download_id = id; 168 info->download_id = id;
167 169
168 // Set expectations and return values. 170 // Set expectations and return values.
169 EXPECT_CALL(*download_manager_, CreateDownloadItem(info, _)) 171 EXPECT_CALL(*download_manager_, CreateDownloadItem(info, _))
170 .Times(1); 172 .Times(1)
173 .WillOnce(Return(net::BoundNetLog()));
171 EXPECT_CALL(*download_manager_, GenerateFileHash()) 174 EXPECT_CALL(*download_manager_, GenerateFileHash())
172 .Times(AtLeast(1)) 175 .Times(AtLeast(1))
173 .WillRepeatedly(Return(false)); 176 .WillRepeatedly(Return(false));
174 EXPECT_CALL(*download_manager_, StartDownload(id.local())); 177 EXPECT_CALL(*download_manager_, StartDownload(id.local()));
175 178
176 download_file_manager_->StartDownload(info, *request_handle_); 179 download_file_manager_->StartDownload(info, *request_handle_);
177 ProcessAllPendingMessages(); 180 ProcessAllPendingMessages();
178 181
179 ClearExpectations(id); 182 ClearExpectations(id);
180 } 183 }
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 // DownloadFile::GetDownloadFile 664 // DownloadFile::GetDownloadFile
662 // Process one message in the message loop 665 // Process one message in the message loop
663 // DownloadManager::UpdateDownload 666 // DownloadManager::UpdateDownload
664 667
665 // TODO(ahendrickson) -- A test for download manager shutdown. 668 // TODO(ahendrickson) -- A test for download manager shutdown.
666 // Expected call sequence: 669 // Expected call sequence:
667 // OnDownloadManagerShutdown 670 // OnDownloadManagerShutdown
668 // DownloadFile::GetDownloadManager 671 // DownloadFile::GetDownloadManager
669 // DownloadFile::CancelDownloadRequest 672 // DownloadFile::CancelDownloadRequest
670 // DownloadFile::~DownloadFile 673 // DownloadFile::~DownloadFile
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698