| 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 e79d79ca5cb4aa48b17018157061004d7ca987ea..5f3fec3b133dccaac5d3490114f6a45395699694 100644
|
| --- a/components/ntp_snippets/remote/ntp_snippets_service_unittest.cc
|
| +++ b/components/ntp_snippets/remote/ntp_snippets_service_unittest.cc
|
| @@ -503,6 +503,13 @@ class NTPSnippetsServiceTest : public ::testing::Test {
|
| base::RunLoop().RunUntilIdle();
|
| }
|
|
|
| + void LoadMoreFromJSONString(NTPSnippetsService* service,
|
| + const std::string& json) {
|
| + SetUpFetchResponse(json);
|
| + service->FetchMore();
|
| + base::RunLoop().RunUntilIdle();
|
| + }
|
| +
|
| private:
|
| variations::testing::VariationParamsManager params_manager_;
|
| test::NTPSnippetsTestUtils utils_;
|
| @@ -832,6 +839,22 @@ TEST_F(NTPSnippetsServiceTest, ReplaceSnippets) {
|
| ElementsAre(IdEq(second)));
|
| }
|
|
|
| +TEST_F(NTPSnippetsServiceTest, LoadsAdditionalSnippets) {
|
| + auto service = MakeSnippetsService();
|
| +
|
| + std::string first("http://first");
|
| + LoadFromJSONString(service.get(), GetTestJson({GetSnippetWithUrl(first)}));
|
| + EXPECT_THAT(service->GetSnippetsForTesting(articles_category()),
|
| + ElementsAre(IdEq(first)));
|
| +
|
| + std::string second("http://second");
|
| + LoadMoreFromJSONString(service.get(),
|
| + GetTestJson({GetSnippetWithUrl(second)}));
|
| + // The snippets loaded last are added to the previously loaded.
|
| + EXPECT_THAT(service->GetSnippetsForTesting(articles_category()),
|
| + ElementsAre(IdEq(first), IdEq(second)));
|
| +}
|
| +
|
| TEST_F(NTPSnippetsServiceTest, LoadInvalidJson) {
|
| auto service = MakeSnippetsService();
|
|
|
|
|