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

Unified Diff: components/ntp_snippets/ntp_snippets_service_unittest.cc

Issue 1883523002: chrome://snippets-internals page for debugging NTP snippets. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Implementing last suggestions from Bernhard Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/ntp_snippets/ntp_snippets_service.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 b4700c5d11bf84309e49c370d8c5fc251a969826..b42a45050cd3a03d2c2f73990e08a1d94d0c9427 100644
--- a/components/ntp_snippets/ntp_snippets_service_unittest.cc
+++ b/components/ntp_snippets/ntp_snippets_service_unittest.cc
@@ -184,6 +184,16 @@ TEST_F(NTPSnippetsServiceTest, Full) {
}
}
+TEST_F(NTPSnippetsServiceTest, Clear) {
+ std::string json_str(GetTestJson());
+
+ LoadFromJSONString(json_str);
+ EXPECT_EQ(service()->size(), 1u);
+
+ service()->ClearSnippets();
+ EXPECT_EQ(service()->size(), 0u);
+}
+
TEST_F(NTPSnippetsServiceTest, LoadInvalidJson) {
SetExpectJsonParseSuccess(false);
LoadFromJSONString(GetInvalidJson());
@@ -237,6 +247,31 @@ TEST_F(NTPSnippetsServiceTest, Discard) {
CreateSnippetsService();
LoadFromJSONString(json_str);
EXPECT_EQ(0u, service()->size());
+
+ // The snippet can be added again after clearing discarded snippets.
+ service()->ClearDiscardedSnippets();
+ EXPECT_EQ(0u, service()->size());
+ LoadFromJSONString(json_str);
+ EXPECT_EQ(1u, service()->size());
+}
+
+TEST_F(NTPSnippetsServiceTest, GetDiscarded) {
+ std::string json_str(
+ "{ \"recos\": [ { \"contentInfo\": { \"url\" : \"http://site.com\" }}]}");
+ LoadFromJSONString(json_str);
+
+ // For the test, we need the snippet to get discarded.
+ ASSERT_TRUE(service()->DiscardSnippet(GURL("http://site.com")));
+ const NTPSnippetsService::NTPSnippetStorage& snippets =
+ service()->discarded_snippets();
+ EXPECT_EQ(1u, snippets.size());
+ for (auto& snippet : snippets) {
+ EXPECT_EQ(GURL("http://site.com"), snippet->url());
+ }
+
+ // There should be no discarded snippet after clearing the list.
+ service()->ClearDiscardedSnippets();
+ EXPECT_EQ(0u, service()->discarded_snippets().size());
}
TEST_F(NTPSnippetsServiceTest, CreationTimestampParseFail) {
« no previous file with comments | « components/ntp_snippets/ntp_snippets_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698