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

Unified Diff: chrome/browser/ntp_snippets/download_suggestions_provider_unittest.cc

Issue 2787303002: [NTP::Downloads] Use last access time to filter old asset downloads. (Closed)
Patch Set: clean rebase. 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ntp_snippets/download_suggestions_provider_unittest.cc
diff --git a/chrome/browser/ntp_snippets/download_suggestions_provider_unittest.cc b/chrome/browser/ntp_snippets/download_suggestions_provider_unittest.cc
index 1788f8c729450b94b1a0d368abf2f8f36819c030..5a08ebdf1eb1d0d9c436c32cf7336deeec242376 100644
--- a/chrome/browser/ntp_snippets/download_suggestions_provider_unittest.cc
+++ b/chrome/browser/ntp_snippets/download_suggestions_provider_unittest.cc
@@ -1110,3 +1110,40 @@ TEST_F(DownloadSuggestionsProviderTest,
CreateProvider(/*show_assets=*/false, /*show_offline_pages=*/true,
std::move(test_clock));
}
+
+TEST_F(DownloadSuggestionsProviderTest,
+ ShouldShowRecentlyVisitedAssetDownloads) {
+ IgnoreOnCategoryStatusChangedToAvailable();
+ IgnoreOnSuggestionInvalidated();
+
+ const base::Time not_outdated =
+ now - base::TimeDelta::FromHours(kDefaultMaxDownloadAgeHours) +
+ base::TimeDelta::FromSeconds(1);
+ const base::Time outdated =
+ now - base::TimeDelta::FromHours(kDefaultMaxDownloadAgeHours) -
+ base::TimeDelta::FromSeconds(1);
+
+ *(downloads_manager()->mutable_items()) = CreateDummyAssetDownloads({0, 1});
+
+ downloads_manager()->mutable_items()->at(0)->SetURL(
+ GURL("http://download.com/0"));
+ downloads_manager()->mutable_items()->at(0)->SetStartTime(outdated);
+ downloads_manager()->mutable_items()->at(0)->SetLastAccessTime(not_outdated);
+
+ downloads_manager()->mutable_items()->at(1)->SetURL(
+ GURL("http://download.com/1"));
+ downloads_manager()->mutable_items()->at(1)->SetStartTime(outdated);
+ downloads_manager()->mutable_items()->at(1)->SetLastAccessTime(
+ downloads_manager()->mutable_items()->at(1)->GetStartTime());
+
+ // Even though asset download 0 was downloaded long time ago, it should be
+ // reported because it has been visited recently.
+ EXPECT_CALL(
+ *observer(),
+ OnNewSuggestions(_, downloads_category(),
+ UnorderedElementsAre(HasUrl("http://download.com/0"))));
+ auto test_clock = base::MakeUnique<base::SimpleTestClock>();
+ test_clock->SetNow(now);
+ CreateLoadedProvider(/*show_assets=*/true, /*show_offline_pages=*/false,
+ std::move(test_clock));
+}
« no previous file with comments | « chrome/browser/ntp_snippets/download_suggestions_provider.cc ('k') | content/public/test/fake_download_item.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698