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

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

Issue 2720613002: Downloads: Added transient flag to download item and download database (Closed)
Patch Set: Fixed migration unit test Created 3 years, 9 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 base::Time(), 105 base::Time(),
106 true,
106 std::vector<DownloadItem::ReceivedSlice>(), 107 std::vector<DownloadItem::ReceivedSlice>(),
107 net::NetLogWithSource()) {} 108 net::NetLogWithSource()) {}
108 virtual ~MockDownloadItemImpl() {} 109 virtual ~MockDownloadItemImpl() {}
109 110
110 MOCK_METHOD4(OnDownloadTargetDetermined, 111 MOCK_METHOD4(OnDownloadTargetDetermined,
111 void(const base::FilePath&, TargetDisposition, 112 void(const base::FilePath&, TargetDisposition,
112 DownloadDangerType, const base::FilePath&)); 113 DownloadDangerType, const base::FilePath&));
113 MOCK_METHOD1(AddObserver, void(DownloadItem::Observer*)); 114 MOCK_METHOD1(AddObserver, void(DownloadItem::Observer*));
114 MOCK_METHOD1(RemoveObserver, void(DownloadItem::Observer*)); 115 MOCK_METHOD1(RemoveObserver, void(DownloadItem::Observer*));
115 MOCK_METHOD0(UpdateObservers, void()); 116 MOCK_METHOD0(UpdateObservers, void());
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 const std::string& etag, 265 const std::string& etag,
265 const std::string& last_modofied, 266 const std::string& last_modofied,
266 int64_t received_bytes, 267 int64_t received_bytes,
267 int64_t total_bytes, 268 int64_t total_bytes,
268 const std::string& hash, 269 const std::string& hash,
269 DownloadItem::DownloadState state, 270 DownloadItem::DownloadState state,
270 DownloadDangerType danger_type, 271 DownloadDangerType danger_type,
271 DownloadInterruptReason interrupt_reason, 272 DownloadInterruptReason interrupt_reason,
272 bool opened, 273 bool opened,
273 const base::Time& last_access_time, 274 const base::Time& last_access_time,
275 bool visible,
274 const std::vector<DownloadItem::ReceivedSlice>& received_slices, 276 const std::vector<DownloadItem::ReceivedSlice>& received_slices,
275 const net::NetLogWithSource& net_log) override; 277 const net::NetLogWithSource& net_log) override;
276 DownloadItemImpl* CreateActiveItem( 278 DownloadItemImpl* CreateActiveItem(
277 DownloadItemImplDelegate* delegate, 279 DownloadItemImplDelegate* delegate,
278 uint32_t download_id, 280 uint32_t download_id,
279 const DownloadCreateInfo& info, 281 const DownloadCreateInfo& info,
280 const net::NetLogWithSource& net_log) override; 282 const net::NetLogWithSource& net_log) override;
281 DownloadItemImpl* CreateSavePageItem( 283 DownloadItemImpl* CreateSavePageItem(
282 DownloadItemImplDelegate* delegate, 284 DownloadItemImplDelegate* delegate,
283 uint32_t download_id, 285 uint32_t download_id,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 const std::string& etag, 340 const std::string& etag,
339 const std::string& last_modified, 341 const std::string& last_modified,
340 int64_t received_bytes, 342 int64_t received_bytes,
341 int64_t total_bytes, 343 int64_t total_bytes,
342 const std::string& hash, 344 const std::string& hash,
343 DownloadItem::DownloadState state, 345 DownloadItem::DownloadState state,
344 DownloadDangerType danger_type, 346 DownloadDangerType danger_type,
345 DownloadInterruptReason interrupt_reason, 347 DownloadInterruptReason interrupt_reason,
346 bool opened, 348 bool opened,
347 const base::Time& last_access_time, 349 const base::Time& last_access_time,
350 bool visible,
348 const std::vector<DownloadItem::ReceivedSlice>& received_slices, 351 const std::vector<DownloadItem::ReceivedSlice>& received_slices,
349 const net::NetLogWithSource& net_log) { 352 const net::NetLogWithSource& net_log) {
350 DCHECK(items_.find(download_id) == items_.end()); 353 DCHECK(items_.find(download_id) == items_.end());
351 MockDownloadItemImpl* result = 354 MockDownloadItemImpl* result =
352 new StrictMock<MockDownloadItemImpl>(&item_delegate_); 355 new StrictMock<MockDownloadItemImpl>(&item_delegate_);
353 EXPECT_CALL(*result, GetId()) 356 EXPECT_CALL(*result, GetId())
354 .WillRepeatedly(Return(download_id)); 357 .WillRepeatedly(Return(download_id));
355 EXPECT_CALL(*result, GetGuid()).WillRepeatedly(ReturnRefOfCopy(guid)); 358 EXPECT_CALL(*result, GetGuid()).WillRepeatedly(ReturnRefOfCopy(guid));
356 items_[download_id] = result; 359 items_[download_id] = result;
357 return result; 360 return result;
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 ASSERT_FALSE(download_manager_->GetDownloadByGuid("")); 725 ASSERT_FALSE(download_manager_->GetDownloadByGuid(""));
723 726
724 const char kGuid[] = "8DF158E8-C980-4618-BB03-EBA3242EB48B"; 727 const char kGuid[] = "8DF158E8-C980-4618-BB03-EBA3242EB48B";
725 DownloadItem* persisted_item = download_manager_->CreateDownloadItem( 728 DownloadItem* persisted_item = download_manager_->CreateDownloadItem(
726 kGuid, 10, base::FilePath(), base::FilePath(), std::vector<GURL>(), 729 kGuid, 10, base::FilePath(), base::FilePath(), std::vector<GURL>(),
727 GURL("http://example.com/a"), GURL("http://example.com/a"), 730 GURL("http://example.com/a"), GURL("http://example.com/a"),
728 GURL("http://example.com/a"), GURL("http://example.com/a"), 731 GURL("http://example.com/a"), GURL("http://example.com/a"),
729 "application/octet-stream", "application/octet-stream", base::Time::Now(), 732 "application/octet-stream", "application/octet-stream", base::Time::Now(),
730 base::Time::Now(), std::string(), std::string(), 10, 10, std::string(), 733 base::Time::Now(), std::string(), std::string(), 10, 10, std::string(),
731 DownloadItem::INTERRUPTED, DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, 734 DownloadItem::INTERRUPTED, DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
732 DOWNLOAD_INTERRUPT_REASON_SERVER_FAILED, false, base::Time::Now(), 735 DOWNLOAD_INTERRUPT_REASON_SERVER_FAILED, false, base::Time::Now(), true,
733 std::vector<DownloadItem::ReceivedSlice>()); 736 std::vector<DownloadItem::ReceivedSlice>());
734 ASSERT_TRUE(persisted_item); 737 ASSERT_TRUE(persisted_item);
735 738
736 ASSERT_EQ(persisted_item, download_manager_->GetDownloadByGuid(kGuid)); 739 ASSERT_EQ(persisted_item, download_manager_->GetDownloadByGuid(kGuid));
737 } 740 }
738 741
739 namespace { 742 namespace {
740 743
741 base::Callback<bool(const GURL&)> GetSingleURLFilter(const GURL& url) { 744 base::Callback<bool(const GURL&)> GetSingleURLFilter(const GURL& url) {
742 return base::Bind(static_cast<bool (*)(const GURL&, const GURL&)>(operator==), 745 return base::Bind(static_cast<bool (*)(const GURL&, const GURL&)>(operator==),
(...skipping 16 matching lines...) Expand all
759 EXPECT_CALL(GetMockDownloadItem(1), Remove()).Times(0); 762 EXPECT_CALL(GetMockDownloadItem(1), Remove()).Times(0);
760 763
761 base::Callback<bool(const GURL&)> url_filter = 764 base::Callback<bool(const GURL&)> url_filter =
762 GetSingleURLFilter(download_urls_[0]); 765 GetSingleURLFilter(download_urls_[0]);
763 int remove_count = download_manager_->RemoveDownloadsByURLAndTime( 766 int remove_count = download_manager_->RemoveDownloadsByURLAndTime(
764 url_filter, base::Time(), base::Time::Max()); 767 url_filter, base::Time(), base::Time::Max());
765 EXPECT_EQ(remove_count, 1); 768 EXPECT_EQ(remove_count, 1);
766 } 769 }
767 770
768 } // namespace content 771 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698