Commit 9cabda14 authored by Chris Mumford's avatar Chris Mumford Committed by Commit Bot

Switch ThumbnailFetcherImplTest to use C++ lambda.

This change switches from using testing::CreateFunctor
when calling testing::Invoke() to a C++ lambda. This
improves test readibility and makes easier an upcoming
changes to gmock_mutant.h (switch away from base::Bind()).

Bug: 1007833, 806952
Change-Id: I267d0681e833a36c245a4529a2a7c0faef6f9693
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1874485
Commit-Queue: Chris Mumford <cmumford@google.com>
Reviewed-by: default avatarCarlos Knippschild <carlosk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#710067}
parent 91d0d0f8
......@@ -15,12 +15,13 @@
#include "components/offline_pages/core/client_id.h"
#include "components/offline_pages/core/client_namespace_constants.h"
#include "components/prefs/testing_pref_service.h"
#include "testing/gmock_mutant.h"
namespace offline_pages {
namespace {
using testing::_;
using testing::Invoke;
using testing::WithArg;
const char kClientID1[] = "client-id-1";
ntp_snippets::Category ArticlesCategory() {
......@@ -88,20 +89,17 @@ class ThumbnailFetcherImplTest : public testing::Test {
return suggestions_provider_;
}
void ExpectFetchThumbnail(const std::string& thumbnail_data) {
void ExpectFetchThumbnail(std::string thumbnail_data) {
scoped_refptr<base::TestMockTimeTaskRunner> task_runner = task_runner_;
EXPECT_CALL(*suggestions_provider(),
FetchSuggestionImageDataMock(SuggestionID1(), _))
.WillOnce(
testing::Invoke(testing::CallbackToFunctor(base::BindRepeating(
[](const std::string& thumbnail_data,
scoped_refptr<base::TestMockTimeTaskRunner> task_runner,
const ntp_snippets::ContentSuggestion::ID& id,
ntp_snippets::ImageDataFetchedCallback* callback) {
task_runner->PostTask(
FROM_HERE,
base::BindOnce(std::move(*callback), thumbnail_data));
},
thumbnail_data, task_runner_))));
.WillOnce(WithArg<1>(
Invoke([task_runner, thumbnail_data](
ntp_snippets::ImageDataFetchedCallback* callback) {
task_runner->PostTask(
FROM_HERE,
base::BindOnce(std::move(*callback), thumbnail_data));
})));
}
std::unique_ptr<TestContentSuggestionsService> content_suggestions_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment