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

Unified Diff: components/ntp_snippets/remote/remote_suggestions_provider_unittest.cc

Issue 2558393004: Refactoring: Moves image fetching and caching into CachedImageFetcher (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 side-by-side diff with in-line comments
Download patch
Index: components/ntp_snippets/remote/remote_suggestions_provider_unittest.cc
diff --git a/components/ntp_snippets/remote/remote_suggestions_provider_unittest.cc b/components/ntp_snippets/remote/remote_suggestions_provider_unittest.cc
index 27ac0a2efee7c070fe71981ad46f0b1da1bf3161..82cc68216595f8fe716ae861c8622ca9943c243b 100644
--- a/components/ntp_snippets/remote/remote_suggestions_provider_unittest.cc
+++ b/components/ntp_snippets/remote/remote_suggestions_provider_unittest.cc
@@ -930,7 +930,8 @@ TEST_F(RemoteSuggestionsProviderTest, LoadsAdditionalSnippets) {
expect_only_second_suggestion_received);
// Verify we can resolve the image of the new snippets.
- ServeImageCallback cb = base::Bind(&ServeOneByOneImage, service.get());
+ ServeImageCallback cb =
+ base::Bind(&ServeOneByOneImage, &service->GetImageFetcherForTesting());
EXPECT_CALL(*image_fetcher(), StartOrQueueNetworkRequest(_, _, _))
.Times(2)
.WillRepeatedly(WithArgs<0, 2>(Invoke(&cb, &ServeImageCallback::Run)));
@@ -1166,7 +1167,8 @@ TEST_F(RemoteSuggestionsProviderTest, Dismiss) {
ASSERT_THAT(service->GetSnippetsForTesting(articles_category()), SizeIs(1));
// Load the image to store it in the database.
- ServeImageCallback cb = base::Bind(&ServeOneByOneImage, service.get());
+ ServeImageCallback cb =
+ base::Bind(&ServeOneByOneImage, &service->GetImageFetcherForTesting());
EXPECT_CALL(*image_fetcher(), StartOrQueueNetworkRequest(_, _, _))
.WillOnce(WithArgs<0, 2>(Invoke(&cb, &ServeImageCallback::Run)));
image_decoder()->SetDecodedImage(gfx::test::CreateImage(1, 1));
@@ -1263,7 +1265,8 @@ TEST_F(RemoteSuggestionsProviderTest, RemoveExpiredDismissedContent) {
// Load the image to store it in the database.
// TODO(tschumann): Introduce some abstraction to nicely work with image
// fetching expectations.
- ServeImageCallback cb = base::Bind(&ServeOneByOneImage, service.get());
+ ServeImageCallback cb =
+ base::Bind(&ServeOneByOneImage, &service->GetImageFetcherForTesting());
EXPECT_CALL(*image_fetcher(), StartOrQueueNetworkRequest(_, _, _))
.WillOnce(WithArgs<0, 2>(Invoke(&cb, &ServeImageCallback::Run)));
image_decoder()->SetDecodedImage(gfx::test::CreateImage(1, 1));
@@ -1475,7 +1478,8 @@ TEST_F(RemoteSuggestionsProviderTest, ImageReturnedWithTheSameId) {
gfx::Image image;
MockFunction<void(const gfx::Image&)> image_fetched;
- ServeImageCallback cb = base::Bind(&ServeOneByOneImage, service.get());
+ ServeImageCallback cb =
+ base::Bind(&ServeOneByOneImage, &service->GetImageFetcherForTesting());
{
InSequence s;
EXPECT_CALL(*image_fetcher(), StartOrQueueNetworkRequest(_, _, _))
@@ -1557,7 +1561,8 @@ TEST_F(RemoteSuggestionsProviderTest, ShouldClearOrphanedImagesOnRestart) {
auto service = MakeSnippetsService();
LoadFromJSONString(service.get(), GetTestJson({GetSnippet()}));
- ServeImageCallback cb = base::Bind(&ServeOneByOneImage, service.get());
+ ServeImageCallback cb =
+ base::Bind(&ServeOneByOneImage, &service->GetImageFetcherForTesting());
EXPECT_CALL(*image_fetcher(), StartOrQueueNetworkRequest(_, _, _))
.WillOnce(WithArgs<0, 2>(Invoke(&cb, &ServeImageCallback::Run)));

Powered by Google App Engine
This is Rietveld 408576698