| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 | 53 |
| 54 ::testing::Matcher<const base::string16&> Str16Eq(const std::string& s) { | 54 ::testing::Matcher<const base::string16&> Str16Eq(const std::string& s) { |
| 55 return ::testing::Eq(base::UTF8ToUTF16(s)); | 55 return ::testing::Eq(base::UTF8ToUTF16(s)); |
| 56 } | 56 } |
| 57 | 57 |
| 58 ::testing::Matcher<const GURL&> URLEq(const std::string& s) { | 58 ::testing::Matcher<const GURL&> URLEq(const std::string& s) { |
| 59 return ::testing::Eq(GURL(s)); | 59 return ::testing::Eq(GURL(s)); |
| 60 } | 60 } |
| 61 | 61 |
| 62 size_t GetNumberOfDefaultPopularSitesForPlatform() { | 62 size_t GetNumberOfDefaultPopularSitesForPlatform() { |
| 63 #if defined(OS_ANDROID) | 63 #if defined(OS_ANDROID) || defined(OS_IOS) |
| 64 return 8ul; | 64 return 8ul; |
| 65 #else | 65 #else |
| 66 return 0ul; | 66 return 0ul; |
| 67 #endif | 67 #endif |
| 68 } | 68 } |
| 69 | 69 |
| 70 class PopularSitesTest : public ::testing::Test { | 70 class PopularSitesTest : public ::testing::Test { |
| 71 protected: | 71 protected: |
| 72 PopularSitesTest() | 72 PopularSitesTest() |
| 73 : kWikipedia{ | 73 : kWikipedia{ |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 EXPECT_THAT(sites.size(), Eq(GetNumberOfDefaultPopularSitesForPlatform())); | 258 EXPECT_THAT(sites.size(), Eq(GetNumberOfDefaultPopularSitesForPlatform())); |
| 259 } | 259 } |
| 260 | 260 |
| 261 TEST_F(PopularSitesTest, AddsIconResourcesToDefaultPages) { | 261 TEST_F(PopularSitesTest, AddsIconResourcesToDefaultPages) { |
| 262 scoped_refptr<net::TestURLRequestContextGetter> url_request_context( | 262 scoped_refptr<net::TestURLRequestContextGetter> url_request_context( |
| 263 new net::TestURLRequestContextGetter( | 263 new net::TestURLRequestContextGetter( |
| 264 base::ThreadTaskRunnerHandle::Get())); | 264 base::ThreadTaskRunnerHandle::Get())); |
| 265 std::unique_ptr<PopularSites> popular_sites = | 265 std::unique_ptr<PopularSites> popular_sites = |
| 266 CreatePopularSites(url_request_context.get()); | 266 CreatePopularSites(url_request_context.get()); |
| 267 | 267 |
| 268 #if defined(GOOGLE_CHROME_BUILD) && defined(OS_ANDROID) | 268 #if defined(GOOGLE_CHROME_BUILD) && (defined(OS_ANDROID) || defined(OS_IOS)) |
| 269 ASSERT_FALSE(popular_sites->sites().empty()); | 269 ASSERT_FALSE(popular_sites->sites().empty()); |
| 270 for (const auto& site : popular_sites->sites()) { | 270 for (const auto& site : popular_sites->sites()) { |
| 271 EXPECT_THAT(site.default_icon_resource, Gt(0)); | 271 EXPECT_THAT(site.default_icon_resource, Gt(0)); |
| 272 } | 272 } |
| 273 #endif | 273 #endif |
| 274 } | 274 } |
| 275 | 275 |
| 276 TEST_F(PopularSitesTest, ProvidesDefaultSitesUntilCallbackReturns) { | 276 TEST_F(PopularSitesTest, ProvidesDefaultSitesUntilCallbackReturns) { |
| 277 SetCountryAndVersion("ZZ", "9"); | 277 SetCountryAndVersion("ZZ", "9"); |
| 278 RespondWithJSON( | 278 RespondWithJSON( |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 | 467 |
| 468 PopularSites::SitesVector sites; | 468 PopularSites::SitesVector sites; |
| 469 EXPECT_THAT(FetchPopularSites(/*force_download=*/false, &sites), | 469 EXPECT_THAT(FetchPopularSites(/*force_download=*/false, &sites), |
| 470 Eq(base::Optional<bool>(true))); | 470 Eq(base::Optional<bool>(true))); |
| 471 | 471 |
| 472 EXPECT_THAT(sites.size(), Eq(1u)); | 472 EXPECT_THAT(sites.size(), Eq(1u)); |
| 473 } | 473 } |
| 474 | 474 |
| 475 } // namespace | 475 } // namespace |
| 476 } // namespace ntp_tiles | 476 } // namespace ntp_tiles |
| OLD | NEW |