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

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

Issue 11363222: Persist download interrupt reason, both target and current paths, and url_chain. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged to r180302 Created 7 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 <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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 } 62 }
63 63
64 class MockDownloadItemImpl : public DownloadItemImpl { 64 class MockDownloadItemImpl : public DownloadItemImpl {
65 public: 65 public:
66 // Use history constructor for minimal base object. 66 // Use history constructor for minimal base object.
67 MockDownloadItemImpl(DownloadItemImplDelegate* delegate) 67 MockDownloadItemImpl(DownloadItemImplDelegate* delegate)
68 : DownloadItemImpl( 68 : DownloadItemImpl(
69 delegate, 69 delegate,
70 content::DownloadId(), 70 content::DownloadId(),
71 FilePath(), 71 FilePath(),
72 GURL(), 72 FilePath(),
73 std::vector<GURL>(),
73 GURL(), 74 GURL(),
74 base::Time(), 75 base::Time(),
75 base::Time(), 76 base::Time(),
76 0, 77 0,
77 0, 78 0,
78 DownloadItem::IN_PROGRESS, 79 DownloadItem::IN_PROGRESS,
80 DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
81 DOWNLOAD_INTERRUPT_REASON_NONE,
79 false, 82 false,
80 net::BoundNetLog()) {} 83 net::BoundNetLog()) {}
81 virtual ~MockDownloadItemImpl() {} 84 virtual ~MockDownloadItemImpl() {}
82 85
83 MOCK_METHOD4(OnDownloadTargetDetermined, 86 MOCK_METHOD4(OnDownloadTargetDetermined,
84 void(const FilePath&, TargetDisposition, 87 void(const FilePath&, TargetDisposition,
85 DownloadDangerType, const FilePath&)); 88 DownloadDangerType, const FilePath&));
86 MOCK_METHOD1(AddObserver, void(DownloadItem::Observer*)); 89 MOCK_METHOD1(AddObserver, void(DownloadItem::Observer*));
87 MOCK_METHOD1(RemoveObserver, void(DownloadItem::Observer*)); 90 MOCK_METHOD1(RemoveObserver, void(DownloadItem::Observer*));
88 MOCK_METHOD0(UpdateObservers, void()); 91 MOCK_METHOD0(UpdateObservers, void());
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 MockDownloadItemImpl* PopItem(); 218 MockDownloadItemImpl* PopItem();
216 219
217 // Should be called when the item of this id is removed so that 220 // Should be called when the item of this id is removed so that
218 // we don't keep dangling pointers. 221 // we don't keep dangling pointers.
219 void RemoveItem(int id); 222 void RemoveItem(int id);
220 223
221 // Overridden methods from DownloadItemFactory. 224 // Overridden methods from DownloadItemFactory.
222 virtual DownloadItemImpl* CreatePersistedItem( 225 virtual DownloadItemImpl* CreatePersistedItem(
223 DownloadItemImplDelegate* delegate, 226 DownloadItemImplDelegate* delegate,
224 DownloadId download_id, 227 DownloadId download_id,
225 const FilePath& path, 228 const FilePath& current_path,
226 const GURL& url, 229 const FilePath& target_path,
230 const std::vector<GURL>& url_chain,
227 const GURL& referrer_url, 231 const GURL& referrer_url,
228 const base::Time& start_time, 232 const base::Time& start_time,
229 const base::Time& end_time, 233 const base::Time& end_time,
230 int64 received_bytes, 234 int64 received_bytes,
231 int64 total_bytes, 235 int64 total_bytes,
232 DownloadItem::DownloadState state, 236 DownloadItem::DownloadState state,
237 DownloadDangerType danger_type,
238 DownloadInterruptReason interrupt_reason,
233 bool opened, 239 bool opened,
234 const net::BoundNetLog& bound_net_log) OVERRIDE; 240 const net::BoundNetLog& bound_net_log) OVERRIDE;
235 virtual DownloadItemImpl* CreateActiveItem( 241 virtual DownloadItemImpl* CreateActiveItem(
236 DownloadItemImplDelegate* delegate, 242 DownloadItemImplDelegate* delegate,
237 const DownloadCreateInfo& info, 243 const DownloadCreateInfo& info,
238 const net::BoundNetLog& bound_net_log) OVERRIDE; 244 const net::BoundNetLog& bound_net_log) OVERRIDE;
239 virtual DownloadItemImpl* CreateSavePageItem( 245 virtual DownloadItemImpl* CreateSavePageItem(
240 DownloadItemImplDelegate* delegate, 246 DownloadItemImplDelegate* delegate,
241 const FilePath& path, 247 const FilePath& path,
242 const GURL& url, 248 const GURL& url,
(...skipping 30 matching lines...) Expand all
273 } 279 }
274 280
275 void MockDownloadItemFactory::RemoveItem(int id) { 281 void MockDownloadItemFactory::RemoveItem(int id) {
276 DCHECK(items_.find(id) != items_.end()); 282 DCHECK(items_.find(id) != items_.end());
277 items_.erase(id); 283 items_.erase(id);
278 } 284 }
279 285
280 DownloadItemImpl* MockDownloadItemFactory::CreatePersistedItem( 286 DownloadItemImpl* MockDownloadItemFactory::CreatePersistedItem(
281 DownloadItemImplDelegate* delegate, 287 DownloadItemImplDelegate* delegate,
282 DownloadId download_id, 288 DownloadId download_id,
283 const FilePath& path, 289 const FilePath& current_path,
284 const GURL& url, 290 const FilePath& target_path,
291 const std::vector<GURL>& url_chain,
285 const GURL& referrer_url, 292 const GURL& referrer_url,
286 const base::Time& start_time, 293 const base::Time& start_time,
287 const base::Time& end_time, 294 const base::Time& end_time,
288 int64 received_bytes, 295 int64 received_bytes,
289 int64 total_bytes, 296 int64 total_bytes,
290 DownloadItem::DownloadState state, 297 DownloadItem::DownloadState state,
298 DownloadDangerType danger_type,
299 DownloadInterruptReason interrupt_reason,
291 bool opened, 300 bool opened,
292 const net::BoundNetLog& bound_net_log) { 301 const net::BoundNetLog& bound_net_log) {
293 int local_id = download_id.local(); 302 int local_id = download_id.local();
294 DCHECK(items_.find(local_id) == items_.end()); 303 DCHECK(items_.find(local_id) == items_.end());
295 304
296 MockDownloadItemImpl* result = 305 MockDownloadItemImpl* result =
297 new StrictMock<MockDownloadItemImpl>(&item_delegate_); 306 new StrictMock<MockDownloadItemImpl>(&item_delegate_);
298 EXPECT_CALL(*result, GetId()) 307 EXPECT_CALL(*result, GetId())
299 .WillRepeatedly(Return(local_id)); 308 .WillRepeatedly(Return(local_id));
300 items_[local_id] = result; 309 items_[local_id] = result;
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 callback_called_ = false; 650 callback_called_ = false;
642 DetermineDownloadTarget(&item); 651 DetermineDownloadTarget(&item);
643 EXPECT_TRUE(callback_called_); 652 EXPECT_TRUE(callback_called_);
644 EXPECT_EQ(path, target_path_); 653 EXPECT_EQ(path, target_path_);
645 EXPECT_EQ(DownloadItem::TARGET_DISPOSITION_OVERWRITE, target_disposition_); 654 EXPECT_EQ(DownloadItem::TARGET_DISPOSITION_OVERWRITE, target_disposition_);
646 EXPECT_EQ(DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, danger_type_); 655 EXPECT_EQ(DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, danger_type_);
647 EXPECT_EQ(path, intermediate_path_); 656 EXPECT_EQ(path, intermediate_path_);
648 } 657 }
649 658
650 } // namespace content 659 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/download/download_manager_impl.cc ('k') | content/public/browser/download_interrupt_reason_values.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698