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

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: fix tests Created 3 years, 8 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 const std::string& etag, 144 const std::string& etag,
145 const std::string& last_modofied, 145 const std::string& last_modofied,
146 int64_t received_bytes, 146 int64_t received_bytes,
147 int64_t total_bytes, 147 int64_t total_bytes,
148 const std::string& hash, 148 const std::string& hash,
149 DownloadItem::DownloadState state, 149 DownloadItem::DownloadState state,
150 DownloadDangerType danger_type, 150 DownloadDangerType danger_type,
151 DownloadInterruptReason interrupt_reason, 151 DownloadInterruptReason interrupt_reason,
152 bool opened, 152 bool opened,
153 base::Time last_access_time, 153 base::Time last_access_time,
154 bool transient,
154 const std::vector<DownloadItem::ReceivedSlice>& received_slices, 155 const std::vector<DownloadItem::ReceivedSlice>& received_slices,
155 const net::NetLogWithSource& net_log) override; 156 const net::NetLogWithSource& net_log) override;
156 DownloadItemImpl* CreateActiveItem( 157 DownloadItemImpl* CreateActiveItem(
157 DownloadItemImplDelegate* delegate, 158 DownloadItemImplDelegate* delegate,
158 uint32_t download_id, 159 uint32_t download_id,
159 const DownloadCreateInfo& info, 160 const DownloadCreateInfo& info,
160 const net::NetLogWithSource& net_log) override; 161 const net::NetLogWithSource& net_log) override;
161 DownloadItemImpl* CreateSavePageItem( 162 DownloadItemImpl* CreateSavePageItem(
162 DownloadItemImplDelegate* delegate, 163 DownloadItemImplDelegate* delegate,
163 uint32_t download_id, 164 uint32_t download_id,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 const std::string& etag, 219 const std::string& etag,
219 const std::string& last_modified, 220 const std::string& last_modified,
220 int64_t received_bytes, 221 int64_t received_bytes,
221 int64_t total_bytes, 222 int64_t total_bytes,
222 const std::string& hash, 223 const std::string& hash,
223 DownloadItem::DownloadState state, 224 DownloadItem::DownloadState state,
224 DownloadDangerType danger_type, 225 DownloadDangerType danger_type,
225 DownloadInterruptReason interrupt_reason, 226 DownloadInterruptReason interrupt_reason,
226 bool opened, 227 bool opened,
227 base::Time last_access_time, 228 base::Time last_access_time,
229 bool transient,
228 const std::vector<DownloadItem::ReceivedSlice>& received_slices, 230 const std::vector<DownloadItem::ReceivedSlice>& received_slices,
229 const net::NetLogWithSource& net_log) { 231 const net::NetLogWithSource& net_log) {
230 DCHECK(items_.find(download_id) == items_.end()); 232 DCHECK(items_.find(download_id) == items_.end());
231 MockDownloadItemImpl* result = 233 MockDownloadItemImpl* result =
232 new StrictMock<MockDownloadItemImpl>(&item_delegate_); 234 new StrictMock<MockDownloadItemImpl>(&item_delegate_);
233 EXPECT_CALL(*result, GetId()) 235 EXPECT_CALL(*result, GetId())
234 .WillRepeatedly(Return(download_id)); 236 .WillRepeatedly(Return(download_id));
235 EXPECT_CALL(*result, GetGuid()).WillRepeatedly(ReturnRefOfCopy(guid)); 237 EXPECT_CALL(*result, GetGuid()).WillRepeatedly(ReturnRefOfCopy(guid));
236 items_[download_id] = result; 238 items_[download_id] = result;
237 return result; 239 return result;
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 ASSERT_FALSE(download_manager_->GetDownloadByGuid("")); 606 ASSERT_FALSE(download_manager_->GetDownloadByGuid(""));
605 607
606 const char kGuid[] = "8DF158E8-C980-4618-BB03-EBA3242EB48B"; 608 const char kGuid[] = "8DF158E8-C980-4618-BB03-EBA3242EB48B";
607 DownloadItem* persisted_item = download_manager_->CreateDownloadItem( 609 DownloadItem* persisted_item = download_manager_->CreateDownloadItem(
608 kGuid, 10, base::FilePath(), base::FilePath(), std::vector<GURL>(), 610 kGuid, 10, base::FilePath(), base::FilePath(), std::vector<GURL>(),
609 GURL("http://example.com/a"), GURL("http://example.com/a"), 611 GURL("http://example.com/a"), GURL("http://example.com/a"),
610 GURL("http://example.com/a"), GURL("http://example.com/a"), 612 GURL("http://example.com/a"), GURL("http://example.com/a"),
611 "application/octet-stream", "application/octet-stream", base::Time::Now(), 613 "application/octet-stream", "application/octet-stream", base::Time::Now(),
612 base::Time::Now(), std::string(), std::string(), 10, 10, std::string(), 614 base::Time::Now(), std::string(), std::string(), 10, 10, std::string(),
613 DownloadItem::INTERRUPTED, DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, 615 DownloadItem::INTERRUPTED, DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
614 DOWNLOAD_INTERRUPT_REASON_SERVER_FAILED, false, base::Time::Now(), 616 DOWNLOAD_INTERRUPT_REASON_SERVER_FAILED, false, base::Time::Now(), true,
615 std::vector<DownloadItem::ReceivedSlice>()); 617 std::vector<DownloadItem::ReceivedSlice>());
616 ASSERT_TRUE(persisted_item); 618 ASSERT_TRUE(persisted_item);
617 619
618 ASSERT_EQ(persisted_item, download_manager_->GetDownloadByGuid(kGuid)); 620 ASSERT_EQ(persisted_item, download_manager_->GetDownloadByGuid(kGuid));
619 } 621 }
620 622
621 namespace { 623 namespace {
622 624
623 base::Callback<bool(const GURL&)> GetSingleURLFilter(const GURL& url) { 625 base::Callback<bool(const GURL&)> GetSingleURLFilter(const GURL& url) {
624 return base::Bind(static_cast<bool (*)(const GURL&, const GURL&)>(operator==), 626 return base::Bind(static_cast<bool (*)(const GURL&, const GURL&)>(operator==),
(...skipping 16 matching lines...) Expand all
641 EXPECT_CALL(GetMockDownloadItem(1), Remove()).Times(0); 643 EXPECT_CALL(GetMockDownloadItem(1), Remove()).Times(0);
642 644
643 base::Callback<bool(const GURL&)> url_filter = 645 base::Callback<bool(const GURL&)> url_filter =
644 GetSingleURLFilter(download_urls_[0]); 646 GetSingleURLFilter(download_urls_[0]);
645 int remove_count = download_manager_->RemoveDownloadsByURLAndTime( 647 int remove_count = download_manager_->RemoveDownloadsByURLAndTime(
646 url_filter, base::Time(), base::Time::Max()); 648 url_filter, base::Time(), base::Time::Max());
647 EXPECT_EQ(remove_count, 1); 649 EXPECT_EQ(remove_count, 1);
648 } 650 }
649 651
650 } // namespace content 652 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/download/download_manager_impl.cc ('k') | content/browser/download/mock_download_item_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698