OLD | NEW |
---|---|
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 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
700 EXPECT_CALL(GetMockDownloadItem(2), Remove()) | 700 EXPECT_CALL(GetMockDownloadItem(2), Remove()) |
701 .WillOnce(Return()); | 701 .WillOnce(Return()); |
702 EXPECT_CALL(GetMockDownloadItem(3), Remove()) | 702 EXPECT_CALL(GetMockDownloadItem(3), Remove()) |
703 .Times(0); | 703 .Times(0); |
704 | 704 |
705 download_manager_->RemoveAllDownloads(); | 705 download_manager_->RemoveAllDownloads(); |
706 // Because we're mocking the download item, the Remove call doesn't | 706 // Because we're mocking the download item, the Remove call doesn't |
707 // result in them being removed from the DownloadManager list. | 707 // result in them being removed from the DownloadManager list. |
708 } | 708 } |
709 | 709 |
710 namespace { | |
711 base::Callback<bool(const GURL&)> GetSingleFileFilter(const GURL* url) { | |
712 return base::Bind(&GURL::operator==, base::Unretained(url)); | |
713 } | |
714 } | |
brettw
2016/02/05 21:26:04
Blank line before here (and after the namespace op
msramek
2016/02/10 14:30:37
Done. Also, renamed this and the test to mention U
| |
715 | |
710 // Confirm that only downloads with same origin are removed. | 716 // Confirm that only downloads with same origin are removed. |
711 TEST_F(DownloadManagerTest, RemoveSameOriginDownloads) { | 717 TEST_F(DownloadManagerTest, RemoveSameOriginDownloads) { |
712 base::Time now(base::Time::Now()); | 718 base::Time now(base::Time::Now()); |
713 for (uint32_t i = 0; i < 2; ++i) { | 719 for (uint32_t i = 0; i < 2; ++i) { |
714 MockDownloadItemImpl& item(AddItemToManager()); | 720 MockDownloadItemImpl& item(AddItemToManager()); |
715 EXPECT_CALL(item, GetStartTime()).WillRepeatedly(Return(now)); | 721 EXPECT_CALL(item, GetStartTime()).WillRepeatedly(Return(now)); |
716 EXPECT_CALL(item, GetState()) | 722 EXPECT_CALL(item, GetState()) |
717 .WillRepeatedly(Return(DownloadItem::COMPLETE)); | 723 .WillRepeatedly(Return(DownloadItem::COMPLETE)); |
718 } | 724 } |
719 | 725 |
720 EXPECT_CALL(GetMockDownloadItem(0), Remove()); | 726 EXPECT_CALL(GetMockDownloadItem(0), Remove()); |
721 EXPECT_CALL(GetMockDownloadItem(1), Remove()).Times(0); | 727 EXPECT_CALL(GetMockDownloadItem(1), Remove()).Times(0); |
722 | 728 |
723 url::Origin origin_to_clear(download_urls_[0]); | 729 base::Callback<bool(const GURL&)> url_filter = |
730 GetSingleFileFilter(&download_urls_[0]); | |
724 int remove_count = download_manager_->RemoveDownloadsByOriginAndTime( | 731 int remove_count = download_manager_->RemoveDownloadsByOriginAndTime( |
725 origin_to_clear, base::Time(), base::Time::Max()); | 732 url_filter, base::Time(), base::Time::Max()); |
726 EXPECT_EQ(remove_count, 1); | 733 EXPECT_EQ(remove_count, 1); |
727 } | 734 } |
728 | 735 |
729 } // namespace content | 736 } // namespace content |
OLD | NEW |