Chromium Code Reviews| 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..4469921f2db53f7c6f4610348658f3aec9af72eb 100644 |
| --- a/components/ntp_snippets/ntp_snippets_service_unittest.cc |
| +++ b/components/ntp_snippets/ntp_snippets_service_unittest.cc |
| @@ -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\" }}" |
|
Bernhard Bauer
2016/04/21 16:21:28
Maybe indent the opening brace inside the string,
Marc Treib
2016/04/22 08:16:47
Done.
|
| + "]}"); |
| + 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()); |