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