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

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, 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 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 visible,
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 visible,
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 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 ASSERT_FALSE(download_manager_->GetDownloadByGuid("")); 604 ASSERT_FALSE(download_manager_->GetDownloadByGuid(""));
603 605
604 const char kGuid[] = "8DF158E8-C980-4618-BB03-EBA3242EB48B"; 606 const char kGuid[] = "8DF158E8-C980-4618-BB03-EBA3242EB48B";
605 DownloadItem* persisted_item = download_manager_->CreateDownloadItem( 607 DownloadItem* persisted_item = download_manager_->CreateDownloadItem(
606 kGuid, 10, base::FilePath(), base::FilePath(), std::vector<GURL>(), 608 kGuid, 10, base::FilePath(), base::FilePath(), std::vector<GURL>(),
607 GURL("http://example.com/a"), GURL("http://example.com/a"), 609 GURL("http://example.com/a"), GURL("http://example.com/a"),
608 GURL("http://example.com/a"), GURL("http://example.com/a"), 610 GURL("http://example.com/a"), GURL("http://example.com/a"),
609 "application/octet-stream", "application/octet-stream", base::Time::Now(), 611 "application/octet-stream", "application/octet-stream", base::Time::Now(),
610 base::Time::Now(), std::string(), std::string(), 10, 10, std::string(), 612 base::Time::Now(), std::string(), std::string(), 10, 10, std::string(),
611 DownloadItem::INTERRUPTED, DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, 613 DownloadItem::INTERRUPTED, DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
612 DOWNLOAD_INTERRUPT_REASON_SERVER_FAILED, false, base::Time::Now(), 614 DOWNLOAD_INTERRUPT_REASON_SERVER_FAILED, false, base::Time::Now(), true,
613 std::vector<DownloadItem::ReceivedSlice>()); 615 std::vector<DownloadItem::ReceivedSlice>());
614 ASSERT_TRUE(persisted_item); 616 ASSERT_TRUE(persisted_item);
615 617
616 ASSERT_EQ(persisted_item, download_manager_->GetDownloadByGuid(kGuid)); 618 ASSERT_EQ(persisted_item, download_manager_->GetDownloadByGuid(kGuid));
617 } 619 }
618 620
619 namespace { 621 namespace {
620 622
621 base::Callback<bool(const GURL&)> GetSingleURLFilter(const GURL& url) { 623 base::Callback<bool(const GURL&)> GetSingleURLFilter(const GURL& url) {
622 return base::Bind(static_cast<bool (*)(const GURL&, const GURL&)>(operator==), 624 return base::Bind(static_cast<bool (*)(const GURL&, const GURL&)>(operator==),
(...skipping 16 matching lines...) Expand all
639 EXPECT_CALL(GetMockDownloadItem(1), Remove()).Times(0); 641 EXPECT_CALL(GetMockDownloadItem(1), Remove()).Times(0);
640 642
641 base::Callback<bool(const GURL&)> url_filter = 643 base::Callback<bool(const GURL&)> url_filter =
642 GetSingleURLFilter(download_urls_[0]); 644 GetSingleURLFilter(download_urls_[0]);
643 int remove_count = download_manager_->RemoveDownloadsByURLAndTime( 645 int remove_count = download_manager_->RemoveDownloadsByURLAndTime(
644 url_filter, base::Time(), base::Time::Max()); 646 url_filter, base::Time(), base::Time::Max());
645 EXPECT_EQ(remove_count, 1); 647 EXPECT_EQ(remove_count, 1);
646 } 648 }
647 649
648 } // namespace content 650 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698