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

Unified Diff: components/ntp_snippets/ntp_snippets_service_unittest.cc

Issue 1908973002: [NTP Snippets] Add newly-fetched snippets at the front instead of at the end (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: spaces! Created 4 years, 8 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
« no previous file with comments | « components/ntp_snippets/ntp_snippets_service.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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());
« no previous file with comments | « components/ntp_snippets/ntp_snippets_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698