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

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

Issue 2395273003: [NTP Snippets] Persist remote categories in prefs (Closed)
Patch Set: tschumann review 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
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..c2785da1ebd203f951c91c4fb84aad903e61f055 100644
--- a/components/ntp_snippets/remote/ntp_snippets_service_unittest.cc
+++ b/components/ntp_snippets/remote/ntp_snippets_service_unittest.cc
@@ -738,6 +738,38 @@ TEST_F(NTPSnippetsServiceTest, MultipleCategories) {
}
}
+TEST_F(NTPSnippetsServiceTest, PersistCategoryInfos) {
+ auto service = MakeSnippetsService();
+
+ LoadFromJSONString(service.get(),
+ GetMultiCategoryJson({GetSnippetN(0)}, {GetSnippetN(1)}));
+
+ ASSERT_NE(observer().StatusForCategory(articles_category()),
+ CategoryStatus::NOT_PROVIDED);
+ ASSERT_NE(observer().StatusForCategory(other_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();

Powered by Google App Engine
This is Rietveld 408576698