Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(161)

Side by Side Diff: components/ntp_tiles/most_visited_sites_unittest.cc

Issue 2577253003: ntp_tiles: Avoid redundant calls to TopSites (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 364
365 // Reply from top sites is ignored (i.e. not reported to observer). 365 // Reply from top sites is ignored (i.e. not reported to observer).
366 top_sites_callbacks_.ClearAndNotify( 366 top_sites_callbacks_.ClearAndNotify(
367 {MakeMostVisitedURL("Site 2", "http://site2/")}); 367 {MakeMostVisitedURL("Site 2", "http://site2/")});
368 base::RunLoop().RunUntilIdle(); 368 base::RunLoop().RunUntilIdle();
369 } 369 }
370 370
371 TEST_F(MostVisitedSitesWithEmptyCacheTest, 371 TEST_F(MostVisitedSitesWithEmptyCacheTest,
372 ShouldExposeTopSitesIfSuggestionsServiceFasterButEmpty) { 372 ShouldExposeTopSitesIfSuggestionsServiceFasterButEmpty) {
373 // Empty reply from suggestions service causes no update to our observer. 373 // Empty reply from suggestions service causes no update to our observer.
374 // However, the current implementation issues a redundant query to TopSites.
375 // TODO(mastiz): Avoid this redundant call.
376 EXPECT_CALL(*mock_top_sites_, GetMostVisitedURLs(_, false))
377 .WillOnce(Invoke(&top_sites_callbacks_, &TopSitesCallbackList::Add));
378 suggestions_service_callbacks_.Notify(SuggestionsProfile()); 374 suggestions_service_callbacks_.Notify(SuggestionsProfile());
379 VerifyAndClearExpectations(); 375 VerifyAndClearExpectations();
380 376
381 // Reply from top sites is propagated to observer. 377 // Reply from top sites is propagated to observer.
382 // TODO(mastiz): Avoid a second redundant call to the observer. 378 // TODO(mastiz): Avoid a second redundant call to the observer.
383 EXPECT_CALL(mock_observer_, 379 EXPECT_CALL(mock_observer_,
384 OnMostVisitedURLsAvailable(ElementsAre(MatchesTile( 380 OnMostVisitedURLsAvailable(ElementsAre(MatchesTile(
385 "Site 1", "http://site1/", NTPTileSource::TOP_SITES)))) 381 "Site 1", "http://site1/", NTPTileSource::TOP_SITES))));
386 .Times(2);
387 top_sites_callbacks_.ClearAndNotify( 382 top_sites_callbacks_.ClearAndNotify(
388 {MakeMostVisitedURL("Site 1", "http://site1/")}); 383 {MakeMostVisitedURL("Site 1", "http://site1/")});
389 base::RunLoop().RunUntilIdle(); 384 base::RunLoop().RunUntilIdle();
390 } 385 }
391 386
392 TEST_F(MostVisitedSitesWithEmptyCacheTest, 387 TEST_F(MostVisitedSitesWithEmptyCacheTest,
393 ShouldFavorSuggestionsServiceAlthoughSlower) { 388 ShouldFavorSuggestionsServiceAlthoughSlower) {
394 // Reply from top sites is propagated to observer. 389 // Reply from top sites is propagated to observer.
395 EXPECT_CALL(mock_observer_, 390 EXPECT_CALL(mock_observer_,
396 OnMostVisitedURLsAvailable(ElementsAre(MatchesTile( 391 OnMostVisitedURLsAvailable(ElementsAre(MatchesTile(
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 MatchesTile("Site 4", "https://www.site4.com/", 520 MatchesTile("Site 4", "https://www.site4.com/",
526 NTPTileSource::TOP_SITES), 521 NTPTileSource::TOP_SITES),
527 MatchesTile("Site 1", "https://www.site1.com/", 522 MatchesTile("Site 1", "https://www.site1.com/",
528 NTPTileSource::POPULAR), 523 NTPTileSource::POPULAR),
529 MatchesTile("Site 2", "https://www.site2.com/", 524 MatchesTile("Site 2", "https://www.site2.com/",
530 NTPTileSource::POPULAR))); 525 NTPTileSource::POPULAR)));
531 } 526 }
532 527
533 } // namespace 528 } // namespace
534 } // namespace ntp_tiles 529 } // namespace ntp_tiles
OLDNEW
« components/ntp_tiles/most_visited_sites.cc ('K') | « components/ntp_tiles/most_visited_sites.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698