summaryrefslogtreecommitdiffstats
path: root/ipc/mojo/ipc_channel_mojo_unittest.cc
diff options
context:
space:
mode:
authormorrita <morrita@chromium.org>2014-09-09 12:35:24 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-09 19:41:40 +0000
commit373af03b7c0e1932c7ea3b832918b7767d47ff89 (patch)
tree5be2bbc870238a11e54e650434ddcf09472a9600 /ipc/mojo/ipc_channel_mojo_unittest.cc
parent182520b878bee21aad3500391cd51d486e37bf1e (diff)
downloadchromium_src-373af03b7c0e1932c7ea3b832918b7767d47ff89.zip
chromium_src-373af03b7c0e1932c7ea3b832918b7767d47ff89.tar.gz
chromium_src-373af03b7c0e1932c7ea3b832918b7767d47ff89.tar.bz2
Add ipc_mojo_perftests
This change adds ipc_mojo_perftests that runs the same benchmark as of ipc_perftests. Now head-to-head comparison becomes possible. For this change, whole ipc_perftests logic is extracted to ipc_perftest_support.cc to make it reusable by ipc_mojo_perftests. TEST=none BUG=none R=jam@chromium.org, darin@chromium.org, yuzhu@chromium.org Review URL: https://codereview.chromium.org/536213002 Cr-Commit-Position: refs/heads/master@{#293988}
Diffstat (limited to 'ipc/mojo/ipc_channel_mojo_unittest.cc')
-rw-r--r--ipc/mojo/ipc_channel_mojo_unittest.cc49
1 files changed, 8 insertions, 41 deletions
diff --git a/ipc/mojo/ipc_channel_mojo_unittest.cc b/ipc/mojo/ipc_channel_mojo_unittest.cc
index 60069b7..8ea828f 100644
--- a/ipc/mojo/ipc_channel_mojo_unittest.cc
+++ b/ipc/mojo/ipc_channel_mojo_unittest.cc
@@ -55,33 +55,11 @@ class ListenerThatExpectsOK : public IPC::Listener {
bool received_ok_;
};
-class ListenerThatShouldBeNeverCalled : public IPC::Listener {
- virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE {
- NOTREACHED();
- return true;
- }
-
- virtual void OnChannelError() OVERRIDE {
- NOTREACHED();
- }
-
- virtual void OnChannelConnected(int32 peer_pid) OVERRIDE {
- NOTREACHED();
- }
-
- virtual void OnBadMessageReceived(const IPC::Message& message) OVERRIDE {
- NOTREACHED();
- }
-};
-
class ChannelClient {
public:
explicit ChannelClient(IPC::Listener* listener, const char* name) {
- scoped_ptr<IPC::Channel> bootstrap(IPC::Channel::CreateClient(
- IPCTestBase::GetChannelName(name),
- &never_called_));
channel_ = IPC::ChannelMojo::Create(
- bootstrap.Pass(), IPC::Channel::MODE_CLIENT, listener,
+ IPCTestBase::GetChannelName(name), IPC::Channel::MODE_CLIENT, listener,
main_message_loop_.message_loop_proxy());
}
@@ -93,31 +71,20 @@ class ChannelClient {
private:
scoped_ptr<IPC::ChannelMojo> channel_;
- ListenerThatShouldBeNeverCalled never_called_;
base::MessageLoopForIO main_message_loop_;
};
class IPCChannelMojoTest : public IPCTestBase {
- public:
- void CreateMojoChannel(IPC::Listener* listener);
-
protected:
- virtual void SetUp() OVERRIDE {
- IPCTestBase::SetUp();
+ virtual scoped_ptr<IPC::ChannelFactory> CreateChannelFactory(
+ const IPC::ChannelHandle& handle,
+ base::TaskRunner* runner) OVERRIDE {
+ return IPC::ChannelMojo::CreateFactory(
+ handle, IPC::Channel::MODE_SERVER, runner);
}
-
- ListenerThatShouldBeNeverCalled never_called_;
};
-void IPCChannelMojoTest::CreateMojoChannel(IPC::Listener* listener) {
- CreateChannel(&never_called_);
- scoped_ptr<IPC::Channel> mojo_channel = IPC::ChannelMojo::Create(
- ReleaseChannel(), IPC::Channel::MODE_SERVER, listener,
- task_runner()).PassAs<IPC::Channel>();
- SetChannel(mojo_channel.PassAs<IPC::Channel>());
-}
-
class TestChannelListenerWithExtraExpectations
: public IPC::TestChannelListener {
public:
@@ -142,7 +109,7 @@ TEST_F(IPCChannelMojoTest, ConnectedFromClient) {
// Set up IPC channel and start client.
TestChannelListenerWithExtraExpectations listener;
- CreateMojoChannel(&listener);
+ CreateChannel(&listener);
listener.Init(sender());
ASSERT_TRUE(ConnectChannel());
ASSERT_TRUE(StartClient());
@@ -236,7 +203,7 @@ TEST_F(IPCChannelMojoTest, SendPlatformHandle) {
Init("IPCChannelMojoTestSendPlatformHandleClient");
ListenerThatExpectsOK listener;
- CreateMojoChannel(&listener);
+ CreateChannel(&listener);
ASSERT_TRUE(ConnectChannel());
ASSERT_TRUE(StartClient());