Commit 1b92767a authored by Chris Mumford's avatar Chris Mumford Committed by Commit Bot

Switch pipeline/launcher tests to use C++ lambda.

This change switches from using testing::CreateFunctor
when calling testing::Invoke() to a C++ lambda. This
improves test readibility and allows for gmock_mutant.h
to be removed in an upcoming CL.

TBR=pinkerton@chromium.org

Bug: 1007833, 806952
Change-Id: Id60006d1fb841ca89f47c20170ee2df4c16e8c2f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1887842Reviewed-by: default avatarChris Mumford <cmumford@google.com>
Commit-Queue: Chris Mumford <cmumford@google.com>
Cr-Commit-Position: refs/heads/master@{#714030}
parent 2d91d0cc
......@@ -28,7 +28,6 @@
#include "media/base/text_renderer.h"
#include "media/base/text_track_config.h"
#include "media/base/time_delta_interpolator.h"
#include "testing/gmock_mutant.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/geometry/size.h"
......@@ -37,7 +36,6 @@ using ::base::test::RunOnceCallback;
using ::base::test::RunOnceClosure;
using ::testing::_;
using ::testing::AnyNumber;
using ::testing::CreateFunctor;
using ::testing::DeleteArg;
using ::testing::DoAll;
using ::testing::Invoke;
......@@ -729,9 +727,10 @@ TEST_F(PipelineImplTest, NoMessageDuringTearDownFromError) {
StartPipelineAndExpect(PIPELINE_OK);
// Trigger additional requests on the pipeline during tear down from error.
base::Callback<void(PipelineStatus)> cb =
base::Bind(&TestNoCallsAfterError, pipeline_.get(), &task_environment_);
ON_CALL(callbacks_, OnError(_)).WillByDefault(Invoke(CreateFunctor(cb)));
ON_CALL(callbacks_, OnError(_))
.WillByDefault(Invoke([=](PipelineStatus status) {
TestNoCallsAfterError(pipeline_.get(), &task_environment_, status);
}));
base::TimeDelta seek_time = base::TimeDelta::FromSeconds(5);
......
......@@ -27,18 +27,14 @@
#include "remoting/host/win/launch_process_with_token.h"
#include "remoting/host/worker_process_ipc_delegate.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gmock_mutant.h"
#include "testing/gtest/include/gtest/gtest.h"
using base::win::ScopedHandle;
using testing::_;
using testing::AnyNumber;
using testing::CreateFunctor;
using testing::DoAll;
using testing::Expectation;
using testing::Invoke;
using testing::InvokeWithoutArgs;
using testing::Return;
namespace remoting {
......@@ -434,12 +430,10 @@ TEST_F(WorkerProcessLauncherTest, Restart) {
Expectation first_connect =
EXPECT_CALL(server_listener_, OnChannelConnected(_))
.Times(2)
.WillOnce(InvokeWithoutArgs(CreateFunctor(
&WorkerProcessLauncherTest::TerminateWorker,
base::Unretained(this),
CONTROL_C_EXIT)))
.WillOnce(InvokeWithoutArgs(this,
&WorkerProcessLauncherTest::StopWorker));
.WillOnce(
InvokeWithoutArgs([=]() { TerminateWorker(CONTROL_C_EXIT); }))
.WillOnce(
InvokeWithoutArgs(this, &WorkerProcessLauncherTest::StopWorker));
EXPECT_CALL(server_listener_, OnPermanentError(_))
.Times(0);
......@@ -485,10 +479,8 @@ TEST_F(WorkerProcessLauncherTest, PermanentError) {
EXPECT_CALL(server_listener_, OnChannelConnected(_))
.Times(1)
.WillOnce(InvokeWithoutArgs(CreateFunctor(
&WorkerProcessLauncherTest::TerminateWorker,
base::Unretained(this),
kMinPermanentErrorExitCode)));
.WillOnce(InvokeWithoutArgs(
[=] { TerminateWorker(kMinPermanentErrorExitCode); }));
EXPECT_CALL(server_listener_, OnPermanentError(_))
.Times(1)
.WillOnce(InvokeWithoutArgs(this,
......@@ -516,10 +508,8 @@ TEST_F(WorkerProcessLauncherTest, Crash) {
EXPECT_CALL(client_listener_, OnCrash(_, _, _))
.Times(1)
.WillOnce(InvokeWithoutArgs(CreateFunctor(
&WorkerProcessLauncherTest::TerminateWorker,
base::Unretained(this),
EXCEPTION_BREAKPOINT)));
.WillOnce(
InvokeWithoutArgs([=]() { TerminateWorker(EXCEPTION_BREAKPOINT); }));
EXPECT_CALL(server_listener_, OnWorkerProcessStopped())
.Times(1);
......
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