| 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 9eab18dc7810fcaef212cc47bf1700ef54942073..8f49824eda42a39a45f0a5bcf197fd7edbbbb327 100644
|
| --- a/components/ntp_snippets/ntp_snippets_service_unittest.cc
|
| +++ b/components/ntp_snippets/ntp_snippets_service_unittest.cc
|
| @@ -190,7 +190,7 @@ TEST_F(NTPSnippetsServiceDisabledTest, Unschedule) {
|
| TEST_F(NTPSnippetsServiceTest, Loop) {
|
| std::string json_str(
|
| "{ \"recos\": [ "
|
| - "{ \"contentInfo\": { \"url\" : \"http://localhost/foobar\" }}"
|
| + " { \"contentInfo\": { \"url\" : \"http://localhost/foobar\" }}"
|
| "]}");
|
| LoadFromJSONString(json_str);
|
|
|
| @@ -236,6 +236,26 @@ TEST_F(NTPSnippetsServiceTest, Clear) {
|
| EXPECT_EQ(service()->size(), 0u);
|
| }
|
|
|
| +TEST_F(NTPSnippetsServiceTest, InsertAtFront) {
|
| + std::string json_str(
|
| + "{ \"recos\": [ "
|
| + " { \"contentInfo\": { \"url\" : \"http://first\" }}"
|
| + "]}");
|
| + LoadFromJSONString(json_str);
|
| + ASSERT_EQ(service()->size(), 1u);
|
| +
|
| + std::string json_str2(
|
| + "{ \"recos\": [ "
|
| + " { \"contentInfo\": { \"url\" : \"http://second\" }}"
|
| + "]}");
|
| + LoadFromJSONString(json_str2);
|
| + ASSERT_EQ(service()->size(), 2u);
|
| +
|
| + // The snippet loaded last should be at the first position in the list now.
|
| + const NTPSnippet& first_snippet = *service()->begin();
|
| + EXPECT_EQ(first_snippet.url(), GURL("http://second"));
|
| +}
|
| +
|
| TEST_F(NTPSnippetsServiceTest, LoadInvalidJson) {
|
| SetExpectJsonParseSuccess(false);
|
| LoadFromJSONString(GetInvalidJson());
|
|
|