OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_tiles/popular_sites_impl.h" | 5 #include "components/ntp_tiles/popular_sites_impl.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 "https://www.gstatic.com/chrome/ntp/suggested_sites_ZZ_9.json"); | 227 "https://www.gstatic.com/chrome/ntp/suggested_sites_ZZ_9.json"); |
228 RespondWith404( | 228 RespondWith404( |
229 "https://www.gstatic.com/chrome/ntp/suggested_sites_DEFAULT_5.json"); | 229 "https://www.gstatic.com/chrome/ntp/suggested_sites_DEFAULT_5.json"); |
230 | 230 |
231 PopularSites::SitesVector sites; | 231 PopularSites::SitesVector sites; |
232 EXPECT_THAT(FetchPopularSites(/*force_download=*/false, &sites), | 232 EXPECT_THAT(FetchPopularSites(/*force_download=*/false, &sites), |
233 Eq(base::Optional<bool>(false))); | 233 Eq(base::Optional<bool>(false))); |
234 EXPECT_THAT(sites.size(), Eq(GetNumberOfDefaultPopularSitesForPlatform())); | 234 EXPECT_THAT(sites.size(), Eq(GetNumberOfDefaultPopularSitesForPlatform())); |
235 } | 235 } |
236 | 236 |
| 237 TEST_F(PopularSitesTest, AddsIconResourcesToDefaultPages) { |
| 238 scoped_refptr<net::TestURLRequestContextGetter> url_request_context( |
| 239 new net::TestURLRequestContextGetter( |
| 240 base::ThreadTaskRunnerHandle::Get())); |
| 241 std::unique_ptr<PopularSites> popular_sites = |
| 242 CreatePopularSites(url_request_context.get()); |
| 243 |
| 244 for (const auto& site : popular_sites->sites()) { |
| 245 EXPECT_TRUE(site.default_resource_id > 0); |
| 246 } |
| 247 } |
| 248 |
237 TEST_F(PopularSitesTest, ProvidesDefaultSitesUntilCallbackReturns) { | 249 TEST_F(PopularSitesTest, ProvidesDefaultSitesUntilCallbackReturns) { |
238 SetCountryAndVersion("ZZ", "9"); | 250 SetCountryAndVersion("ZZ", "9"); |
239 RespondWithJSON( | 251 RespondWithJSON( |
240 "https://www.gstatic.com/chrome/ntp/suggested_sites_ZZ_9.json", | 252 "https://www.gstatic.com/chrome/ntp/suggested_sites_ZZ_9.json", |
241 {kWikipedia}); | 253 {kWikipedia}); |
242 scoped_refptr<net::TestURLRequestContextGetter> url_request_context( | 254 scoped_refptr<net::TestURLRequestContextGetter> url_request_context( |
243 new net::TestURLRequestContextGetter( | 255 new net::TestURLRequestContextGetter( |
244 base::ThreadTaskRunnerHandle::Get())); | 256 base::ThreadTaskRunnerHandle::Get())); |
245 std::unique_ptr<PopularSites> popular_sites = | 257 std::unique_ptr<PopularSites> popular_sites = |
246 CreatePopularSites(url_request_context.get()); | 258 CreatePopularSites(url_request_context.get()); |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 "https://www.gstatic.com/chrome/ntp/suggested_sites_ZZ_9.json", | 427 "https://www.gstatic.com/chrome/ntp/suggested_sites_ZZ_9.json", |
416 {kChromium}); | 428 {kChromium}); |
417 EXPECT_THAT(FetchPopularSites(/*force_download=*/false, &sites), | 429 EXPECT_THAT(FetchPopularSites(/*force_download=*/false, &sites), |
418 Eq(base::Optional<bool>(true))); | 430 Eq(base::Optional<bool>(true))); |
419 ASSERT_THAT(sites.size(), Eq(1u)); | 431 ASSERT_THAT(sites.size(), Eq(1u)); |
420 EXPECT_THAT(sites[0].url, URLEq("https://www.chromium.org/")); | 432 EXPECT_THAT(sites[0].url, URLEq("https://www.chromium.org/")); |
421 } | 433 } |
422 | 434 |
423 } // namespace | 435 } // namespace |
424 } // namespace ntp_tiles | 436 } // namespace ntp_tiles |
OLD | NEW |