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

Side by Side Diff: components/ntp_snippets/remote/ntp_snippets_service_unittest.cc

Issue 2387293009: Removes a data-dependent DCHECK(). (Closed)
Patch Set: merged to head Created 4 years, 2 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 unified diff | Download patch
« no previous file with comments | « components/ntp_snippets/remote/ntp_snippets_service.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/ntp_snippets/remote/ntp_snippets_service.h" 5 #include "components/ntp_snippets/remote/ntp_snippets_service.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 1154 matching lines...) Expand 10 before | Expand all | Expand 10 after
1165 LoadFromJSONString(service.get(), 1165 LoadFromJSONString(service.get(),
1166 GetTestJson({GetSnippetWithUrl( 1166 GetTestJson({GetSnippetWithUrl(
1167 "http://something.com/pletely/unrelated")})); 1167 "http://something.com/pletely/unrelated")}));
1168 // The image should still be available until a restart happens. 1168 // The image should still be available until a restart happens.
1169 EXPECT_FALSE(FetchImage(service.get(), MakeArticleID(kSnippetUrl)).IsEmpty()); 1169 EXPECT_FALSE(FetchImage(service.get(), MakeArticleID(kSnippetUrl)).IsEmpty());
1170 ResetSnippetsService(&service); 1170 ResetSnippetsService(&service);
1171 // After the restart, the image should be garbage collected. 1171 // After the restart, the image should be garbage collected.
1172 EXPECT_TRUE(FetchImage(service.get(), MakeArticleID(kSnippetUrl)).IsEmpty()); 1172 EXPECT_TRUE(FetchImage(service.get(), MakeArticleID(kSnippetUrl)).IsEmpty());
1173 } 1173 }
1174 1174
1175 TEST_F(NTPSnippetsServiceTest, ShouldHandleMoreThanMaxSnippetsInResponse) {
1176 auto service = MakeSnippetsService();
1177
1178 std::vector<std::string> suggestions;
1179 for (int i = 0 ; i < service->GetMaxSnippetCountForTesting() + 1; ++i) {
1180 suggestions.push_back(GetSnippetWithUrl(
1181 base::StringPrintf("http://localhost/snippet-id-%d", i)));
1182 }
1183 LoadFromJSONString(service.get(), GetTestJson(suggestions));
1184 // TODO(tschumann): We should probably trim out any additional results and
1185 // only serve the MaxSnippetCount items.
1186 EXPECT_THAT(service->GetSnippetsForTesting(articles_category()),
1187 SizeIs(service->GetMaxSnippetCountForTesting() + 1));
1188 }
1189
1175 } // namespace ntp_snippets 1190 } // namespace ntp_snippets
OLDNEW
« no previous file with comments | « components/ntp_snippets/remote/ntp_snippets_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698