Chromium Code Reviews| 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(); |