Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 1159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1170 LoadFromJSONString(service.get(), | 1170 LoadFromJSONString(service.get(), |
| 1171 GetTestJson({GetSnippetWithUrl( | 1171 GetTestJson({GetSnippetWithUrl( |
| 1172 "http://something.com/pletely/unrelated")})); | 1172 "http://something.com/pletely/unrelated")})); |
| 1173 // The image should still be available until a restart happens. | 1173 // The image should still be available until a restart happens. |
| 1174 EXPECT_FALSE(FetchImage(service.get(), MakeArticleID(kSnippetUrl)).IsEmpty()); | 1174 EXPECT_FALSE(FetchImage(service.get(), MakeArticleID(kSnippetUrl)).IsEmpty()); |
| 1175 ResetSnippetsService(&service); | 1175 ResetSnippetsService(&service); |
| 1176 // After the restart, the image should be garbage collected. | 1176 // After the restart, the image should be garbage collected. |
| 1177 EXPECT_TRUE(FetchImage(service.get(), MakeArticleID(kSnippetUrl)).IsEmpty()); | 1177 EXPECT_TRUE(FetchImage(service.get(), MakeArticleID(kSnippetUrl)).IsEmpty()); |
| 1178 } | 1178 } |
| 1179 | 1179 |
| 1180 TEST_F(NTPSnippetsServiceTest, ShouldHandleMoreThanMaxSnippetsInResponse) { | |
| 1181 auto service = MakeSnippetsService(); | |
| 1182 | |
| 1183 std::vector<std::string> suggestions; | |
| 1184 for (int i = 0 ; i < service->GetMaxSnippetCountForTesting() + 1; ++i) { | |
| 1185 suggestions.push_back(GetSnippetWithUrl( | |
| 1186 base::StringPrintf("http://localhost/snippet-id-%d", i))); | |
| 1187 } | |
| 1188 LoadFromJSONString(service.get(), GetTestJson(suggestions)); | |
| 1189 EXPECT_THAT(service->GetSnippetsForTesting(articles_category()), | |
| 1190 SizeIs(service->GetMaxSnippetCountForTesting() + 1)); | |
|
Marc Treib
2016/10/06 15:36:13
Is this actually the behavior we want?
tschumann
2016/10/06 17:57:42
added a TODO().
| |
| 1191 } | |
| 1192 | |
| 1180 } // namespace ntp_snippets | 1193 } // namespace ntp_snippets |
| OLD | NEW |