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

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

Issue 1603903002: Add an OriginFilterBuilder class for [white|black]listing origins. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase over 1246583002 Created 4 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 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 693 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 EXPECT_CALL(GetMockDownloadItem(2), Remove()) 704 EXPECT_CALL(GetMockDownloadItem(2), Remove())
705 .WillOnce(Return()); 705 .WillOnce(Return());
706 EXPECT_CALL(GetMockDownloadItem(3), Remove()) 706 EXPECT_CALL(GetMockDownloadItem(3), Remove())
707 .Times(0); 707 .Times(0);
708 708
709 download_manager_->RemoveAllDownloads(); 709 download_manager_->RemoveAllDownloads();
710 // Because we're mocking the download item, the Remove call doesn't 710 // Because we're mocking the download item, the Remove call doesn't
711 // result in them being removed from the DownloadManager list. 711 // result in them being removed from the DownloadManager list.
712 } 712 }
713 713
714 // Confirm that only downloads with same origin are removed. 714 namespace {
715 TEST_F(DownloadManagerTest, RemoveSameOriginDownloads) { 715
716 base::Callback<bool(const GURL&)> GetSingleURLFilter(const GURL& url) {
717 return base::Bind(&GURL::operator==, base::Owned(new GURL(url)));
718 }
719
720 } // namespace
721
722 // Confirm that only downloads with the specified URL are removed.
723 TEST_F(DownloadManagerTest, RemoveDownloadsByURL) {
716 base::Time now(base::Time::Now()); 724 base::Time now(base::Time::Now());
717 for (uint32_t i = 0; i < 2; ++i) { 725 for (uint32_t i = 0; i < 2; ++i) {
718 MockDownloadItemImpl& item(AddItemToManager()); 726 MockDownloadItemImpl& item(AddItemToManager());
719 EXPECT_CALL(item, GetStartTime()).WillRepeatedly(Return(now)); 727 EXPECT_CALL(item, GetStartTime()).WillRepeatedly(Return(now));
720 EXPECT_CALL(item, GetState()) 728 EXPECT_CALL(item, GetState())
721 .WillRepeatedly(Return(DownloadItem::COMPLETE)); 729 .WillRepeatedly(Return(DownloadItem::COMPLETE));
722 } 730 }
723 731
724 EXPECT_CALL(GetMockDownloadItem(0), Remove()); 732 EXPECT_CALL(GetMockDownloadItem(0), Remove());
725 EXPECT_CALL(GetMockDownloadItem(1), Remove()).Times(0); 733 EXPECT_CALL(GetMockDownloadItem(1), Remove()).Times(0);
726 734
727 url::Origin origin_to_clear(download_urls_[0]); 735 base::Callback<bool(const GURL&)> url_filter =
728 int remove_count = download_manager_->RemoveDownloadsByOriginAndTime( 736 GetSingleURLFilter(download_urls_[0]);
729 origin_to_clear, base::Time(), base::Time::Max()); 737 int remove_count = download_manager_->RemoveDownloadsByURLAndTime(
738 url_filter, base::Time(), base::Time::Max());
730 EXPECT_EQ(remove_count, 1); 739 EXPECT_EQ(remove_count, 1);
731 } 740 }
732 741
733 } // namespace content 742 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/download/download_manager_impl.cc ('k') | content/public/browser/download_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698