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 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 EXPECT_FALSE(suggestions_service_callbacks_.empty()); | 344 EXPECT_FALSE(suggestions_service_callbacks_.empty()); |
345 EXPECT_FALSE(top_sites_callbacks_.empty()); | 345 EXPECT_FALSE(top_sites_callbacks_.empty()); |
346 } | 346 } |
347 }; | 347 }; |
348 | 348 |
349 TEST_F(MostVisitedSitesWithEmptyCacheTest, | 349 TEST_F(MostVisitedSitesWithEmptyCacheTest, |
350 ShouldQueryTopSitesAndSuggestionsService) { | 350 ShouldQueryTopSitesAndSuggestionsService) { |
351 // Constructor sets basic expectations for a suggestions service cache miss. | 351 // Constructor sets basic expectations for a suggestions service cache miss. |
352 } | 352 } |
353 | 353 |
354 // TODO(mastiz): This describes the current behavior but it actually is a bug. | |
355 TEST_F(MostVisitedSitesWithEmptyCacheTest, | 354 TEST_F(MostVisitedSitesWithEmptyCacheTest, |
356 DoesNotIgnoreTopSitesIfSuggestionsServiceFaster) { | 355 ShouldIgnoreTopSitesIfSuggestionsServiceFaster) { |
357 // Reply from suggestions service triggers and update to our observer. | 356 // Reply from suggestions service triggers and update to our observer. |
358 EXPECT_CALL( | 357 EXPECT_CALL( |
359 mock_observer_, | 358 mock_observer_, |
360 OnMostVisitedURLsAvailable(ElementsAre(MatchesTile( | 359 OnMostVisitedURLsAvailable(ElementsAre(MatchesTile( |
361 "Site 1", "http://site1/", NTPTileSource::SUGGESTIONS_SERVICE)))); | 360 "Site 1", "http://site1/", NTPTileSource::SUGGESTIONS_SERVICE)))); |
362 suggestions_service_callbacks_.Notify( | 361 suggestions_service_callbacks_.Notify( |
363 MakeProfile({MakeSuggestion("Site 1", "http://site1/")})); | 362 MakeProfile({MakeSuggestion("Site 1", "http://site1/")})); |
364 VerifyAndClearExpectations(); | 363 VerifyAndClearExpectations(); |
365 | 364 |
366 // Reply from top sites is currently not ignored (i.e. is actually reported to | 365 // Reply from top sites is ignored (i.e. not reported to observer). |
367 // observer). | |
368 EXPECT_CALL(mock_observer_, | |
369 OnMostVisitedURLsAvailable(ElementsAre(MatchesTile( | |
370 "Site 2", "http://site2/", NTPTileSource::TOP_SITES)))); | |
371 top_sites_callbacks_.ClearAndNotify( | 366 top_sites_callbacks_.ClearAndNotify( |
372 {MakeMostVisitedURL("Site 2", "http://site2/")}); | 367 {MakeMostVisitedURL("Site 2", "http://site2/")}); |
373 base::RunLoop().RunUntilIdle(); | 368 base::RunLoop().RunUntilIdle(); |
374 } | 369 } |
375 | 370 |
376 TEST_F(MostVisitedSitesWithEmptyCacheTest, | 371 TEST_F(MostVisitedSitesWithEmptyCacheTest, |
377 ShouldExposeTopSitesIfSuggestionsServiceFasterButEmpty) { | 372 ShouldExposeTopSitesIfSuggestionsServiceFasterButEmpty) { |
378 // Empty reply from suggestions service causes no update to our observer. | 373 // Empty reply from suggestions service causes no update to our observer. |
379 // However, the current implementation issues a redundant query to TopSites. | 374 // However, the current implementation issues a redundant query to TopSites. |
380 // TODO(mastiz): Avoid this redundant call. | 375 // TODO(mastiz): Avoid this redundant call. |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 MatchesTile("Site 4", "https://www.site4.com/", | 525 MatchesTile("Site 4", "https://www.site4.com/", |
531 NTPTileSource::TOP_SITES), | 526 NTPTileSource::TOP_SITES), |
532 MatchesTile("Site 1", "https://www.site1.com/", | 527 MatchesTile("Site 1", "https://www.site1.com/", |
533 NTPTileSource::POPULAR), | 528 NTPTileSource::POPULAR), |
534 MatchesTile("Site 2", "https://www.site2.com/", | 529 MatchesTile("Site 2", "https://www.site2.com/", |
535 NTPTileSource::POPULAR))); | 530 NTPTileSource::POPULAR))); |
536 } | 531 } |
537 | 532 |
538 } // namespace | 533 } // namespace |
539 } // namespace ntp_tiles | 534 } // namespace ntp_tiles |
OLD | NEW |