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

Unified Diff: components/ntp_snippets/ntp_snippets_service_unittest.cc

Issue 2303713002: Implement ClearHistory for all ntp_snippets providers (Closed)
Patch Set: Marc's nits. Created 4 years, 3 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: components/ntp_snippets/ntp_snippets_service_unittest.cc
diff --git a/components/ntp_snippets/ntp_snippets_service_unittest.cc b/components/ntp_snippets/ntp_snippets_service_unittest.cc
index 974f2e8f4550dfe78d0cacc9c6c5cc4552fd64ab..2bb208c8ad91d2f38560203e84af4777f19873bb 100644
--- a/components/ntp_snippets/ntp_snippets_service_unittest.cc
+++ b/components/ntp_snippets/ntp_snippets_service_unittest.cc
@@ -864,4 +864,26 @@ TEST_F(NTPSnippetsServiceTest, EmptyImageReturnedForNonExistentId) {
EXPECT_TRUE(image.IsEmpty());
}
+TEST_F(NTPSnippetsServiceTest, ClearHistoryRemovesAllSuggestions) {
+ auto service = MakeSnippetsService();
+
+ std::string first_snippet = GetSnippetWithUrl("http://url1.com");
+ std::string second_snippet = GetSnippetWithUrl("http://url2.com");
+ std::string json_str = GetTestJson({first_snippet, second_snippet});
+ LoadFromJSONString(service.get(), json_str);
+ ASSERT_THAT(service->GetSnippetsForTesting(), SizeIs(2));
+
+ service->DismissSuggestion(MakeUniqueID(*service, "http://url1.com"));
+ ASSERT_THAT(service->GetSnippetsForTesting(), SizeIs(1));
+ ASSERT_THAT(service->GetDismissedSnippetsForTesting(), SizeIs(1));
+
+ base::Time begin = base::Time::FromTimeT(123),
+ end = base::Time::FromTimeT(456);
+ base::Callback<bool(const GURL& url)> filter;
+ service->ClearHistory(begin, end, filter);
+
+ EXPECT_THAT(service->GetSnippetsForTesting(), IsEmpty());
+ EXPECT_THAT(service->GetDismissedSnippetsForTesting(), IsEmpty());
+}
+
} // namespace ntp_snippets

Powered by Google App Engine
This is Rietveld 408576698