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

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

Issue 2703883003: Read and restore persisted slice info (Closed)
Patch Set: Created 3 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
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_manager_impl.h" 5 #include "content/browser/download/download_manager_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 base::Time(), 95 base::Time(),
96 std::string(), 96 std::string(),
97 std::string(), 97 std::string(),
98 0, 98 0,
99 0, 99 0,
100 std::string(), 100 std::string(),
101 DownloadItem::COMPLETE, 101 DownloadItem::COMPLETE,
102 DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, 102 DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
103 DOWNLOAD_INTERRUPT_REASON_NONE, 103 DOWNLOAD_INTERRUPT_REASON_NONE,
104 false, 104 false,
105 std::vector<DownloadItem::ReceivedSlice>(),
105 net::NetLogWithSource()) {} 106 net::NetLogWithSource()) {}
106 virtual ~MockDownloadItemImpl() {} 107 virtual ~MockDownloadItemImpl() {}
107 108
108 MOCK_METHOD4(OnDownloadTargetDetermined, 109 MOCK_METHOD4(OnDownloadTargetDetermined,
109 void(const base::FilePath&, TargetDisposition, 110 void(const base::FilePath&, TargetDisposition,
110 DownloadDangerType, const base::FilePath&)); 111 DownloadDangerType, const base::FilePath&));
111 MOCK_METHOD1(AddObserver, void(DownloadItem::Observer*)); 112 MOCK_METHOD1(AddObserver, void(DownloadItem::Observer*));
112 MOCK_METHOD1(RemoveObserver, void(DownloadItem::Observer*)); 113 MOCK_METHOD1(RemoveObserver, void(DownloadItem::Observer*));
113 MOCK_METHOD0(UpdateObservers, void()); 114 MOCK_METHOD0(UpdateObservers, void());
114 MOCK_METHOD0(CanShowInFolder, bool()); 115 MOCK_METHOD0(CanShowInFolder, bool());
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 const base::Time& end_time, 262 const base::Time& end_time,
262 const std::string& etag, 263 const std::string& etag,
263 const std::string& last_modofied, 264 const std::string& last_modofied,
264 int64_t received_bytes, 265 int64_t received_bytes,
265 int64_t total_bytes, 266 int64_t total_bytes,
266 const std::string& hash, 267 const std::string& hash,
267 DownloadItem::DownloadState state, 268 DownloadItem::DownloadState state,
268 DownloadDangerType danger_type, 269 DownloadDangerType danger_type,
269 DownloadInterruptReason interrupt_reason, 270 DownloadInterruptReason interrupt_reason,
270 bool opened, 271 bool opened,
272 const std::vector<DownloadItem::ReceivedSlice>& received_slices,
271 const net::NetLogWithSource& net_log) override; 273 const net::NetLogWithSource& net_log) override;
272 DownloadItemImpl* CreateActiveItem( 274 DownloadItemImpl* CreateActiveItem(
273 DownloadItemImplDelegate* delegate, 275 DownloadItemImplDelegate* delegate,
274 uint32_t download_id, 276 uint32_t download_id,
275 const DownloadCreateInfo& info, 277 const DownloadCreateInfo& info,
276 const net::NetLogWithSource& net_log) override; 278 const net::NetLogWithSource& net_log) override;
277 DownloadItemImpl* CreateSavePageItem( 279 DownloadItemImpl* CreateSavePageItem(
278 DownloadItemImplDelegate* delegate, 280 DownloadItemImplDelegate* delegate,
279 uint32_t download_id, 281 uint32_t download_id,
280 const base::FilePath& path, 282 const base::FilePath& path,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 const base::Time& end_time, 335 const base::Time& end_time,
334 const std::string& etag, 336 const std::string& etag,
335 const std::string& last_modified, 337 const std::string& last_modified,
336 int64_t received_bytes, 338 int64_t received_bytes,
337 int64_t total_bytes, 339 int64_t total_bytes,
338 const std::string& hash, 340 const std::string& hash,
339 DownloadItem::DownloadState state, 341 DownloadItem::DownloadState state,
340 DownloadDangerType danger_type, 342 DownloadDangerType danger_type,
341 DownloadInterruptReason interrupt_reason, 343 DownloadInterruptReason interrupt_reason,
342 bool opened, 344 bool opened,
345 const std::vector<DownloadItem::ReceivedSlice>& received_slices,
343 const net::NetLogWithSource& net_log) { 346 const net::NetLogWithSource& net_log) {
344 DCHECK(items_.find(download_id) == items_.end()); 347 DCHECK(items_.find(download_id) == items_.end());
345 MockDownloadItemImpl* result = 348 MockDownloadItemImpl* result =
346 new StrictMock<MockDownloadItemImpl>(&item_delegate_); 349 new StrictMock<MockDownloadItemImpl>(&item_delegate_);
347 EXPECT_CALL(*result, GetId()) 350 EXPECT_CALL(*result, GetId())
348 .WillRepeatedly(Return(download_id)); 351 .WillRepeatedly(Return(download_id));
349 EXPECT_CALL(*result, GetGuid()).WillRepeatedly(ReturnRefOfCopy(guid)); 352 EXPECT_CALL(*result, GetGuid()).WillRepeatedly(ReturnRefOfCopy(guid));
350 items_[download_id] = result; 353 items_[download_id] = result;
351 return result; 354 return result;
352 } 355 }
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 ASSERT_FALSE(download_manager_->GetDownloadByGuid("")); 719 ASSERT_FALSE(download_manager_->GetDownloadByGuid(""));
717 720
718 const char kGuid[] = "8DF158E8-C980-4618-BB03-EBA3242EB48B"; 721 const char kGuid[] = "8DF158E8-C980-4618-BB03-EBA3242EB48B";
719 DownloadItem* persisted_item = download_manager_->CreateDownloadItem( 722 DownloadItem* persisted_item = download_manager_->CreateDownloadItem(
720 kGuid, 10, base::FilePath(), base::FilePath(), std::vector<GURL>(), 723 kGuid, 10, base::FilePath(), base::FilePath(), std::vector<GURL>(),
721 GURL("http://example.com/a"), GURL("http://example.com/a"), 724 GURL("http://example.com/a"), GURL("http://example.com/a"),
722 GURL("http://example.com/a"), GURL("http://example.com/a"), 725 GURL("http://example.com/a"), GURL("http://example.com/a"),
723 "application/octet-stream", "application/octet-stream", base::Time::Now(), 726 "application/octet-stream", "application/octet-stream", base::Time::Now(),
724 base::Time::Now(), std::string(), std::string(), 10, 10, std::string(), 727 base::Time::Now(), std::string(), std::string(), 10, 10, std::string(),
725 DownloadItem::INTERRUPTED, DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, 728 DownloadItem::INTERRUPTED, DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
726 DOWNLOAD_INTERRUPT_REASON_SERVER_FAILED, false); 729 DOWNLOAD_INTERRUPT_REASON_SERVER_FAILED, false,
730 std::vector<DownloadItem::ReceivedSlice>());
727 ASSERT_TRUE(persisted_item); 731 ASSERT_TRUE(persisted_item);
728 732
729 ASSERT_EQ(persisted_item, download_manager_->GetDownloadByGuid(kGuid)); 733 ASSERT_EQ(persisted_item, download_manager_->GetDownloadByGuid(kGuid));
730 } 734 }
731 735
732 namespace { 736 namespace {
733 737
734 base::Callback<bool(const GURL&)> GetSingleURLFilter(const GURL& url) { 738 base::Callback<bool(const GURL&)> GetSingleURLFilter(const GURL& url) {
735 return base::Bind(static_cast<bool (*)(const GURL&, const GURL&)>(operator==), 739 return base::Bind(static_cast<bool (*)(const GURL&, const GURL&)>(operator==),
736 GURL(url)); 740 GURL(url));
(...skipping 15 matching lines...) Expand all
752 EXPECT_CALL(GetMockDownloadItem(1), Remove()).Times(0); 756 EXPECT_CALL(GetMockDownloadItem(1), Remove()).Times(0);
753 757
754 base::Callback<bool(const GURL&)> url_filter = 758 base::Callback<bool(const GURL&)> url_filter =
755 GetSingleURLFilter(download_urls_[0]); 759 GetSingleURLFilter(download_urls_[0]);
756 int remove_count = download_manager_->RemoveDownloadsByURLAndTime( 760 int remove_count = download_manager_->RemoveDownloadsByURLAndTime(
757 url_filter, base::Time(), base::Time::Max()); 761 url_filter, base::Time(), base::Time::Max());
758 EXPECT_EQ(remove_count, 1); 762 EXPECT_EQ(remove_count, 1);
759 } 763 }
760 764
761 } // namespace content 765 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/download/download_manager_impl.cc ('k') | content/public/browser/download_item.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698