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

Unified Diff: components/ntp_snippets/remote/ntp_snippets_service_unittest.cc

Issue 2395273003: [NTP Snippets] Persist remote categories in prefs (Closed)
Patch Set: Created 4 years, 2 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/remote/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/remote/ntp_snippets_service_unittest.cc
diff --git a/components/ntp_snippets/remote/ntp_snippets_service_unittest.cc b/components/ntp_snippets/remote/ntp_snippets_service_unittest.cc
index 1018c686fd6f5723dcdb267dd6c5ff5ef0e0bca3..e3d7199bf7b9ff06314b5dd6485ff4f7a531eab0 100644
--- a/components/ntp_snippets/remote/ntp_snippets_service_unittest.cc
+++ b/components/ntp_snippets/remote/ntp_snippets_service_unittest.cc
@@ -738,6 +738,40 @@ TEST_F(NTPSnippetsServiceTest, MultipleCategories) {
}
}
+TEST_F(NTPSnippetsServiceTest, PersistCategoryInfos) {
+ std::string json_str(
+ GetMultiCategoryJson({GetSnippetN(0)}, {GetSnippetN(1)}));
tschumann 2016/10/07 14:45:55 inline json_str?
Marc Treib 2016/10/07 15:29:55 Done.
+
+ auto service = MakeSnippetsService();
+
+ LoadFromJSONString(service.get(), json_str);
+
+ ASSERT_NE(observer().StatusForCategory(articles_category()),
+ CategoryStatus::NOT_PROVIDED);
+ ASSERT_NE(observer().StatusForCategory(other_category()),
tschumann 2016/10/07 14:45:55 ideally, this method would be called unknown_categ
Marc Treib 2016/10/07 15:29:55 Hm. There's corresponding MakeArticleID/MakeOtherI
tschumann 2016/10/07 16:12:45 The problem I'm seeing is that in this case, we do
Marc Treib 2016/10/10 08:33:42 Alright, made an unknown_category.
+ CategoryStatus::NOT_PROVIDED);
+
+ CategoryInfo info_articles_before =
+ service->GetCategoryInfo(articles_category());
+ CategoryInfo info_other_before = service->GetCategoryInfo(other_category());
+
+ // Recreate the service to simulate a Chrome restart.
+ ResetSnippetsService(&service);
+
+ // The categories should have been restored.
+ ASSERT_NE(observer().StatusForCategory(articles_category()),
+ CategoryStatus::NOT_PROVIDED);
+ ASSERT_NE(observer().StatusForCategory(other_category()),
+ CategoryStatus::NOT_PROVIDED);
+
+ CategoryInfo info_articles_after =
+ service->GetCategoryInfo(articles_category());
+ CategoryInfo info_other_after = service->GetCategoryInfo(other_category());
+
+ EXPECT_EQ(info_articles_before.title(), info_articles_after.title());
+ EXPECT_EQ(info_other_before.title(), info_other_after.title());
+}
+
TEST_F(NTPSnippetsServiceTest, Clear) {
auto service = MakeSnippetsService();
« no previous file with comments | « components/ntp_snippets/remote/ntp_snippets_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698