0

Backport some tests in /ipc to SingleThreadTaskEnvironment

These tests were previously migrated from single-threaded MessageLoop to
a multi-threaded TaskEnvironment (then named ScopedTaskEnvironment) as
part of crbug.com/891670.

//base OWNERS decided in retrospect that it was better to keep a
single-threaded option for TaskEnvironment and introduced
SingleThreadTaskEnvironment. This CL retrofits that decision for
/ipc.

This CL is a no-op if it passes CQ.

This CL was uploaded by git cl split.

R=rockot@google.com

Bug: 891670
Change-Id: I410de34fd2b80faf6403ee60d3a81e9a0ac40a6b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1787059
Auto-Submit: Gabriel Charette <gab@chromium.org>
Commit-Queue: John Abd-El-Malek <jam@chromium.org>
Reviewed-by: John Abd-El-Malek <jam@chromium.org>
Cr-Commit-Position: refs/heads/master@{#694970}
This commit is contained in:
Gabriel Charette
2019-09-09 23:03:32 +00:00
committed by Commit Bot
parent c56158c742
commit c523fa633a
6 changed files with 24 additions and 24 deletions

@ -949,7 +949,7 @@ class ChannelProxyClient {
IPC::ChannelProxy* proxy() { return runner_->proxy(); }
private:
base::test::TaskEnvironment task_environment_;
base::test::SingleThreadTaskEnvironment task_environment_;
std::unique_ptr<ChannelProxyRunner> runner_;
};

@ -394,7 +394,7 @@ class MojoSteadyPingPongTest : public mojo::core::test::MojoTestBase {
};
DEFINE_TEST_CLIENT_WITH_PIPE(PingPongClient, MojoSteadyPingPongTest, h) {
base::test::TaskEnvironment task_environment;
base::test::SingleThreadTaskEnvironment task_environment;
return RunPingPongClient(h);
}
@ -402,14 +402,14 @@ DEFINE_TEST_CLIENT_WITH_PIPE(PingPongClient, MojoSteadyPingPongTest, h) {
// instead of raw IPC::Messages.
TEST_F(MojoSteadyPingPongTest, AsyncPingPong) {
RunTestClient("PingPongClient", [&](MojoHandle h) {
base::test::TaskEnvironment task_environment;
base::test::SingleThreadTaskEnvironment task_environment;
RunPingPongServer(h, "Mojo_CPU_Async", false);
});
}
TEST_F(MojoSteadyPingPongTest, SyncPingPong) {
RunTestClient("PingPongClient", [&](MojoHandle h) {
base::test::TaskEnvironment task_environment;
base::test::SingleThreadTaskEnvironment task_environment;
RunPingPongServer(h, "Mojo_CPU_Sync", true);
});
}

@ -107,7 +107,7 @@ class IPCMojoBootstrapTest : public testing::Test {
};
TEST_F(IPCMojoBootstrapTest, Connect) {
base::test::TaskEnvironment task_environment;
base::test::SingleThreadTaskEnvironment task_environment;
Connection connection(
IPC::MojoBootstrap::Create(
helper_.StartChild("IPCMojoBootstrapTestClient"),
@ -132,7 +132,7 @@ TEST_F(IPCMojoBootstrapTest, Connect) {
MULTIPROCESS_TEST_MAIN_WITH_SETUP(
IPCMojoBootstrapTestClientTestChildMain,
::mojo::core::test::MultiprocessTestHelper::ChildSetup) {
base::test::TaskEnvironment task_environment;
base::test::SingleThreadTaskEnvironment task_environment;
Connection connection(
IPC::MojoBootstrap::Create(
std::move(mojo::core::test::MultiprocessTestHelper::primordial_pipe),
@ -153,7 +153,7 @@ MULTIPROCESS_TEST_MAIN_WITH_SETUP(
}
TEST_F(IPCMojoBootstrapTest, ReceiveEmptyMessage) {
base::test::TaskEnvironment task_environment;
base::test::SingleThreadTaskEnvironment task_environment;
Connection connection(
IPC::MojoBootstrap::Create(
helper_.StartChild("IPCMojoBootstrapTestEmptyMessage"),
@ -180,7 +180,7 @@ TEST_F(IPCMojoBootstrapTest, ReceiveEmptyMessage) {
MULTIPROCESS_TEST_MAIN_WITH_SETUP(
IPCMojoBootstrapTestEmptyMessageTestChildMain,
::mojo::core::test::MultiprocessTestHelper::ChildSetup) {
base::test::TaskEnvironment task_environment;
base::test::SingleThreadTaskEnvironment task_environment;
Connection connection(
IPC::MojoBootstrap::Create(
std::move(mojo::core::test::MultiprocessTestHelper::primordial_pipe),

@ -536,7 +536,7 @@ class MojoInterfacePassingPerfTest : public mojo::core::test::MojoTestBase {
DEFINE_TEST_CLIENT_WITH_PIPE(InterfacePassingClient,
MojoInterfacePassingPerfTest,
h) {
base::test::TaskEnvironment task_environment;
base::test::SingleThreadTaskEnvironment task_environment;
return RunInterfacePassingClient(h);
}
@ -571,7 +571,7 @@ using MojoInProcessInterfacePassingPerfTest =
InProcessPerfTest<MojoInterfacePassingPerfTest>;
DEFINE_TEST_CLIENT_WITH_PIPE(PingPongClient, MojoInterfacePerfTest, h) {
base::test::TaskEnvironment task_environment;
base::test::SingleThreadTaskEnvironment task_environment;
return RunPingPongClient(h);
}
@ -579,7 +579,7 @@ DEFINE_TEST_CLIENT_WITH_PIPE(PingPongClient, MojoInterfacePerfTest, h) {
// raw IPC::Messages.
TEST_F(MojoInterfacePerfTest, MultiprocessPingPong) {
RunTestClient("PingPongClient", [&](MojoHandle h) {
base::test::TaskEnvironment task_environment;
base::test::SingleThreadTaskEnvironment task_environment;
RunPingPongServer(h, "Multiprocess");
});
}
@ -587,21 +587,21 @@ TEST_F(MojoInterfacePerfTest, MultiprocessPingPong) {
TEST_F(MojoInterfacePerfTest, MultiprocessSyncPing) {
sync_ = true;
RunTestClient("PingPongClient", [&](MojoHandle h) {
base::test::TaskEnvironment task_environment;
base::test::SingleThreadTaskEnvironment task_environment;
RunPingPongServer(h, "MultiprocessSync");
});
}
TEST_F(MojoInterfacePassingPerfTest, MultiprocessInterfacePassing) {
RunTestClient("InterfacePassingClient", [&](MojoHandle h) {
base::test::TaskEnvironment task_environment;
base::test::SingleThreadTaskEnvironment task_environment;
RunInterfacePassingServer(h, "InterfacePassing", false /* associated */);
});
}
TEST_F(MojoInterfacePassingPerfTest, MultiprocessAssociatedInterfacePassing) {
RunTestClient("InterfacePassingClient", [&](MojoHandle h) {
base::test::TaskEnvironment task_environment;
base::test::SingleThreadTaskEnvironment task_environment;
RunInterfacePassingServer(h, "AssociatedInterfacePassing",
true /* associated*/);
});
@ -618,7 +618,7 @@ TEST_P(MojoInProcessInterfacePerfTest, MultiThreadPingPong) {
FROM_HERE,
base::BindOnce(base::IgnoreResult(&RunPingPongClient), client_handle));
base::test::TaskEnvironment task_environment;
base::test::SingleThreadTaskEnvironment task_environment;
RunPingPongServer(server_handle, "SingleProcess");
}
@ -626,7 +626,7 @@ TEST_P(MojoInProcessInterfacePerfTest, SingleThreadPingPong) {
MojoHandle server_handle, client_handle;
CreateMessagePipe(&server_handle, &client_handle);
base::test::TaskEnvironment task_environment;
base::test::SingleThreadTaskEnvironment task_environment;
mojo::MessagePipeHandle mp_handle(client_handle);
mojo::ScopedMessagePipeHandle scoped_mp(mp_handle);
LockThreadAffinity thread_locker(kSharedCore);
@ -650,7 +650,7 @@ TEST_P(MojoInProcessInterfacePassingPerfTest, MultiThreadInterfacePassing) {
FROM_HERE, base::BindOnce(base::IgnoreResult(&RunInterfacePassingClient),
client_handle));
base::test::TaskEnvironment task_environment;
base::test::SingleThreadTaskEnvironment task_environment;
RunInterfacePassingServer(server_handle, "SingleProcess",
false /* associated */);
}
@ -666,7 +666,7 @@ TEST_P(MojoInProcessInterfacePassingPerfTest,
FROM_HERE, base::BindOnce(base::IgnoreResult(&RunInterfacePassingClient),
client_handle));
base::test::TaskEnvironment task_environment;
base::test::SingleThreadTaskEnvironment task_environment;
RunInterfacePassingServer(server_handle, "SingleProcess",
true /* associated */);
}
@ -675,7 +675,7 @@ TEST_P(MojoInProcessInterfacePassingPerfTest, SingleThreadInterfacePassing) {
MojoHandle server_handle, client_handle;
CreateMessagePipe(&server_handle, &client_handle);
base::test::TaskEnvironment task_environment;
base::test::SingleThreadTaskEnvironment task_environment;
mojo::MessagePipeHandle mp_handle(client_handle);
mojo::ScopedMessagePipeHandle scoped_mp(mp_handle);
LockThreadAffinity thread_locker(kSharedCore);
@ -690,7 +690,7 @@ TEST_P(MojoInProcessInterfacePassingPerfTest,
MojoHandle server_handle, client_handle;
CreateMessagePipe(&server_handle, &client_handle);
base::test::TaskEnvironment task_environment;
base::test::SingleThreadTaskEnvironment task_environment;
mojo::MessagePipeHandle mp_handle(client_handle);
mojo::ScopedMessagePipeHandle scoped_mp(mp_handle);
LockThreadAffinity thread_locker(kSharedCore);
@ -836,7 +836,7 @@ class CallbackPerfTest : public testing::Test {
private:
base::Thread client_thread_;
base::test::TaskEnvironment task_environment_;
base::test::SingleThreadTaskEnvironment task_environment_;
int message_count_;
int count_down_;
std::string payload_;

@ -291,7 +291,7 @@ void RunTest(std::vector<Worker*> workers) {
class IPCSyncChannelTest : public testing::Test {
private:
base::test::TaskEnvironment task_environment_;
base::test::SingleThreadTaskEnvironment task_environment_;
};
//------------------------------------------------------------------------------

@ -75,8 +75,8 @@ class IpcChannelMojoTestClient {
IPC::Channel* channel() const { return channel_.get(); }
private:
base::test::TaskEnvironment task_environment_{
base::test::TaskEnvironment::MainThreadType::IO};
base::test::SingleThreadTaskEnvironment task_environment_{
base::test::SingleThreadTaskEnvironment::MainThreadType::IO};
mojo::ScopedMessagePipeHandle handle_;
std::unique_ptr<IPC::Channel> channel_;
};