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

Side by Side 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, 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "chrome/browser/ntp_snippets/download_suggestions_provider.h" 5 #include "chrome/browser/ntp_snippets/download_suggestions_provider.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 1092 matching lines...) Expand 10 before | Expand all | Expand 10 after
1103 // it has been visited recently. 1103 // it has been visited recently.
1104 EXPECT_CALL( 1104 EXPECT_CALL(
1105 *observer(), 1105 *observer(),
1106 OnNewSuggestions(_, downloads_category(), 1106 OnNewSuggestions(_, downloads_category(),
1107 UnorderedElementsAre(HasUrl("http://dummy.com/0")))); 1107 UnorderedElementsAre(HasUrl("http://dummy.com/0"))));
1108 auto test_clock = base::MakeUnique<base::SimpleTestClock>(); 1108 auto test_clock = base::MakeUnique<base::SimpleTestClock>();
1109 test_clock->SetNow(now); 1109 test_clock->SetNow(now);
1110 CreateProvider(/*show_assets=*/false, /*show_offline_pages=*/true, 1110 CreateProvider(/*show_assets=*/false, /*show_offline_pages=*/true,
1111 std::move(test_clock)); 1111 std::move(test_clock));
1112 } 1112 }
1113
1114 TEST_F(DownloadSuggestionsProviderTest,
1115 ShouldShowRecentlyVisitedAssetDownloads) {
1116 IgnoreOnCategoryStatusChangedToAvailable();
1117 IgnoreOnSuggestionInvalidated();
1118
1119 const base::Time not_outdated =
1120 now - base::TimeDelta::FromHours(kDefaultMaxDownloadAgeHours) +
1121 base::TimeDelta::FromSeconds(1);
1122 const base::Time outdated =
1123 now - base::TimeDelta::FromHours(kDefaultMaxDownloadAgeHours) -
1124 base::TimeDelta::FromSeconds(1);
1125
1126 *(downloads_manager()->mutable_items()) = CreateDummyAssetDownloads({0, 1});
1127
1128 downloads_manager()->mutable_items()->at(0)->SetURL(
1129 GURL("http://download.com/0"));
1130 downloads_manager()->mutable_items()->at(0)->SetStartTime(outdated);
1131 downloads_manager()->mutable_items()->at(0)->SetLastAccessTime(not_outdated);
1132
1133 downloads_manager()->mutable_items()->at(1)->SetURL(
1134 GURL("http://download.com/1"));
1135 downloads_manager()->mutable_items()->at(1)->SetStartTime(outdated);
1136 downloads_manager()->mutable_items()->at(1)->SetLastAccessTime(
1137 downloads_manager()->mutable_items()->at(1)->GetStartTime());
1138
1139 // Even though asset download 0 was downloaded long time ago, it should be
1140 // reported because it has been visited recently.
1141 EXPECT_CALL(
1142 *observer(),
1143 OnNewSuggestions(_, downloads_category(),
1144 UnorderedElementsAre(HasUrl("http://download.com/0"))));
1145 auto test_clock = base::MakeUnique<base::SimpleTestClock>();
1146 test_clock->SetNow(now);
1147 CreateLoadedProvider(/*show_assets=*/true, /*show_offline_pages=*/false,
1148 std::move(test_clock));
1149 }
OLDNEW
« 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