Commit c0ca109d authored by Chris Mumford's avatar Chris Mumford Committed by Commit Bot

Stopped using CreateFunctor in DownloadUIController_HistoryDownload.

Switching from testing::CreateFunctor to a C++ lambda is
slightly easier to understand, but allows the deletion of
an upcoming CL to delete gmock_mutant.h.

Bug: 1007833, 806952
Change-Id: Ib210a0c92090ca330f99b695a3256c981f7f14e5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1887661Reviewed-by: default avatarXing Liu <xingliu@chromium.org>
Commit-Queue: Chris Mumford <cmumford@google.com>
Cr-Commit-Position: refs/heads/master@{#710424}
parent 8b8ecebb
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include "content/public/test/mock_download_manager.h" #include "content/public/test/mock_download_manager.h"
#include "content/public/test/navigation_simulator.h" #include "content/public/test/navigation_simulator.h"
#include "testing/gmock/include/gmock/gmock.h" #include "testing/gmock/include/gmock/gmock.h"
#include "testing/gmock_mutant.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
using content::MockDownloadManager; using content::MockDownloadManager;
...@@ -36,7 +35,6 @@ using history::HistoryService; ...@@ -36,7 +35,6 @@ using history::HistoryService;
using testing::_; using testing::_;
using testing::AnyNumber; using testing::AnyNumber;
using testing::Assign; using testing::Assign;
using testing::CreateFunctor;
using testing::Return; using testing::Return;
using testing::ReturnRef; using testing::ReturnRef;
using testing::ReturnRefOfCopy; using testing::ReturnRefOfCopy;
...@@ -360,15 +358,17 @@ TEST_F(DownloadUIControllerTest, DownloadUIController_HistoryDownload) { ...@@ -360,15 +358,17 @@ TEST_F(DownloadUIControllerTest, DownloadUIController_HistoryDownload) {
// is called, we need to first invoke the OnDownloadCreated callback for // is called, we need to first invoke the OnDownloadCreated callback for
// DownloadHistory before returning the DownloadItem since that's the // DownloadHistory before returning the DownloadItem since that's the
// sequence of events expected by DownloadHistory. // sequence of events expected by DownloadHistory.
base::Closure history_on_created_callback = content::DownloadManager::Observer* observer =
base::Bind(&content::DownloadManager::Observer::OnDownloadCreated, download_history_manager_observer();
base::Unretained(download_history_manager_observer()), MockDownloadManager* download_manager = manager();
manager(), MockDownloadItem* download_item = item.get();
item.get());
EXPECT_CALL(*manager(), MockCreateDownloadItem(_)) EXPECT_CALL(*manager(), MockCreateDownloadItem(_))
.WillOnce(testing::DoAll(testing::InvokeWithoutArgs(CreateFunctor( .WillOnce(testing::DoAll(
history_on_created_callback)), testing::InvokeWithoutArgs(
Return(item.get()))); [observer, download_manager, download_item]() {
observer->OnDownloadCreated(download_manager, download_item);
}),
Return(item.get())));
EXPECT_CALL(mock_function, Call()); EXPECT_CALL(mock_function, Call());
std::move(*history_query_callback()).Run(std::move(history_downloads)); std::move(*history_query_callback()).Run(std::move(history_downloads));
......
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