| 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_tiles/most_visited_sites.h" | 5 #include "components/ntp_tiles/most_visited_sites.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <ostream> | 10 #include <ostream> |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 }; | 186 }; |
| 187 | 187 |
| 188 class MockMostVisitedSitesObserver : public MostVisitedSites::Observer { | 188 class MockMostVisitedSitesObserver : public MostVisitedSites::Observer { |
| 189 public: | 189 public: |
| 190 MOCK_METHOD1(OnMostVisitedURLsAvailable, void(const NTPTilesVector& tiles)); | 190 MOCK_METHOD1(OnMostVisitedURLsAvailable, void(const NTPTilesVector& tiles)); |
| 191 MOCK_METHOD1(OnIconMadeAvailable, void(const GURL& site_url)); | 191 MOCK_METHOD1(OnIconMadeAvailable, void(const GURL& site_url)); |
| 192 }; | 192 }; |
| 193 | 193 |
| 194 class MockIconCacher : public IconCacher { | 194 class MockIconCacher : public IconCacher { |
| 195 public: | 195 public: |
| 196 MOCK_METHOD2(StartFetch, | 196 MOCK_METHOD3(StartFetch, |
| 197 void(PopularSites::Site site, | 197 void(PopularSites::Site site, |
| 198 const base::Callback<void(bool)>& done)); | 198 const base::Closure& icon_available, |
| 199 const base::Closure& preliminary_icon_available)); |
| 199 }; | 200 }; |
| 200 | 201 |
| 201 class PopularSitesFactoryForTest { | 202 class PopularSitesFactoryForTest { |
| 202 public: | 203 public: |
| 203 PopularSitesFactoryForTest( | 204 PopularSitesFactoryForTest( |
| 204 bool enabled, | 205 bool enabled, |
| 205 sync_preferences::TestingPrefServiceSyncable* pref_service) | 206 sync_preferences::TestingPrefServiceSyncable* pref_service) |
| 206 : prefs_(pref_service), | 207 : prefs_(pref_service), |
| 207 url_fetcher_factory_(/*default_factory=*/nullptr), | 208 url_fetcher_factory_(/*default_factory=*/nullptr), |
| 208 url_request_context_(new net::TestURLRequestContextGetter( | 209 url_request_context_(new net::TestURLRequestContextGetter( |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 }, | 305 }, |
| 305 &save_success, &loop)); | 306 &save_success, &loop)); |
| 306 loop.Run(); | 307 loop.Run(); |
| 307 EXPECT_TRUE(save_success); | 308 EXPECT_TRUE(save_success); |
| 308 | 309 |
| 309 // With PopularSites enabled, blacklist is exercised. | 310 // With PopularSites enabled, blacklist is exercised. |
| 310 EXPECT_CALL(*mock_top_sites_, IsBlacklisted(_)) | 311 EXPECT_CALL(*mock_top_sites_, IsBlacklisted(_)) |
| 311 .WillRepeatedly(Return(false)); | 312 .WillRepeatedly(Return(false)); |
| 312 // Mock icon cacher never replies, and we also don't verify whether the | 313 // Mock icon cacher never replies, and we also don't verify whether the |
| 313 // code uses it correctly. | 314 // code uses it correctly. |
| 314 EXPECT_CALL(*icon_cacher, StartFetch(_, _)).Times(AtLeast(0)); | 315 EXPECT_CALL(*icon_cacher, StartFetch(_, _, _)).Times(AtLeast(0)); |
| 315 } | 316 } |
| 316 | 317 |
| 317 most_visited_sites_ = base::MakeUnique<MostVisitedSites>( | 318 most_visited_sites_ = base::MakeUnique<MostVisitedSites>( |
| 318 &pref_service_, mock_top_sites_, &mock_suggestions_service_, | 319 &pref_service_, mock_top_sites_, &mock_suggestions_service_, |
| 319 popular_sites_factory_.New(), std::move(icon_cacher), | 320 popular_sites_factory_.New(), std::move(icon_cacher), |
| 320 /*supervisor=*/nullptr); | 321 /*supervisor=*/nullptr); |
| 321 } | 322 } |
| 322 | 323 |
| 323 bool IsPopularSitesEnabledViaVariations() const { return GetParam(); } | 324 bool IsPopularSitesEnabledViaVariations() const { return GetParam(); } |
| 324 | 325 |
| (...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 875 MatchesTile("Site 4", "https://www.site4.com/", | 876 MatchesTile("Site 4", "https://www.site4.com/", |
| 876 NTPTileSource::TOP_SITES), | 877 NTPTileSource::TOP_SITES), |
| 877 MatchesTile("Site 1", "https://www.site1.com/", | 878 MatchesTile("Site 1", "https://www.site1.com/", |
| 878 NTPTileSource::POPULAR), | 879 NTPTileSource::POPULAR), |
| 879 MatchesTile("Site 2", "https://www.site2.com/", | 880 MatchesTile("Site 2", "https://www.site2.com/", |
| 880 NTPTileSource::POPULAR))); | 881 NTPTileSource::POPULAR))); |
| 881 } | 882 } |
| 882 | 883 |
| 883 } // namespace | 884 } // namespace |
| 884 } // namespace ntp_tiles | 885 } // namespace ntp_tiles |
| OLD | NEW |