diff options
author | morrita <morrita@chromium.org> | 2014-09-24 16:38:44 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-09-24 23:46:22 +0000 |
commit | be6c4ccb1377a0ffd5b31ef9b56b70474a126833 (patch) | |
tree | 0a2d2af3d2e83f8020d61d99fc9860073f17ec41 /ipc/mojo | |
parent | 3bbeaa6aa2cc762ceac9c886660af7b0db59c346 (diff) | |
download | chromium_src-be6c4ccb1377a0ffd5b31ef9b56b70474a126833.zip chromium_src-be6c4ccb1377a0ffd5b31ef9b56b70474a126833.tar.gz chromium_src-be6c4ccb1377a0ffd5b31ef9b56b70474a126833.tar.bz2 |
Fix IPCChannelMojoErrorTest.SendFailWithPendingMessages
The test has been broken since MojoBootstrap was introduced.
The change makes it impossible to inject failure from the ChannelMojo
subclass.
This change uses large data as pending message to trigger failure,
instead of overloading IPC::ChannelMojo functions.
R=viettrungluu@chromium.org
BUG=417439
Review URL: https://codereview.chromium.org/598093006
Cr-Commit-Position: refs/heads/master@{#296565}
Diffstat (limited to 'ipc/mojo')
-rw-r--r-- | ipc/mojo/ipc_channel_mojo_unittest.cc | 57 |
1 files changed, 11 insertions, 46 deletions
diff --git a/ipc/mojo/ipc_channel_mojo_unittest.cc b/ipc/mojo/ipc_channel_mojo_unittest.cc index 6626747..e1adecd 100644 --- a/ipc/mojo/ipc_channel_mojo_unittest.cc +++ b/ipc/mojo/ipc_channel_mojo_unittest.cc @@ -158,52 +158,16 @@ MULTIPROCESS_IPC_TEST_CLIENT_MAIN(IPCChannelMojoTestClient) { return 0; } -// Close given handle before use to simulate an error. -class ErraticChannelMojo : public IPC::ChannelMojo { - public: - ErraticChannelMojo(IPC::ChannelMojoHost* host, - const IPC::ChannelHandle& channel_handle, - IPC::Channel::Mode mode, - IPC::Listener* listener, - scoped_refptr<base::TaskRunner> runner) - : ChannelMojo(host, channel_handle, mode, listener) {} - - virtual void OnConnected(mojo::ScopedMessagePipeHandle pipe) { - MojoClose(pipe.get().value()); - OnConnected(pipe.Pass()); - } -}; - -// Exists to create ErraticChannelMojo. -class ErraticChannelFactory : public IPC::ChannelFactory { - public: - explicit ErraticChannelFactory(IPC::ChannelMojoHost* host, - const IPC::ChannelHandle& handle, - base::TaskRunner* runner) - : host_(host), handle_(handle), runner_(runner) {} - - virtual std::string GetName() const OVERRIDE { - return ""; - } - - virtual scoped_ptr<IPC::Channel> BuildChannel( - IPC::Listener* listener) OVERRIDE { - return scoped_ptr<IPC::Channel>(new ErraticChannelMojo( - host_, handle_, IPC::Channel::MODE_SERVER, listener, runner_)); - } - - private: - IPC::ChannelMojoHost* host_; - IPC::ChannelHandle handle_; - scoped_refptr<base::TaskRunner> runner_; -}; - class ListenerExpectingErrors : public IPC::Listener { public: ListenerExpectingErrors() : has_error_(false) { } + virtual void OnChannelConnected(int32 peer_pid) OVERRIDE { + base::MessageLoop::current()->Quit(); + } + virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE { return true; } @@ -226,8 +190,7 @@ class IPCChannelMojoErrorTest : public IPCTestBase { const IPC::ChannelHandle& handle, base::TaskRunner* runner) OVERRIDE { host_.reset(new IPC::ChannelMojoHost(task_runner())); - return scoped_ptr<IPC::ChannelFactory>( - new ErraticChannelFactory(host_.get(), handle, runner)); + return IPC::ChannelMojo::CreateServerFactory(host_.get(), handle); } virtual bool DidStartClient() OVERRIDE { @@ -266,8 +229,7 @@ MULTIPROCESS_IPC_TEST_CLIENT_MAIN(IPCChannelMojoErraticTestClient) { return 0; } -// https://crbug.com/417439 -TEST_F(IPCChannelMojoErrorTest, DISABLED_SendFailWithPendingMessages) { +TEST_F(IPCChannelMojoErrorTest, SendFailWithPendingMessages) { Init("IPCChannelMojoErraticTestClient"); // Set up IPC channel and start client. @@ -275,10 +237,13 @@ TEST_F(IPCChannelMojoErrorTest, DISABLED_SendFailWithPendingMessages) { CreateChannel(&listener); ASSERT_TRUE(ConnectChannel()); + // This matches a value in mojo/system/constants.h + const int kMaxMessageNumBytes = 4 * 1024 * 1024; + std::string overly_large_data(kMaxMessageNumBytes, '*'); // This messages are queued as pending. - for (size_t i = 0; i < 2; ++i) { + for (size_t i = 0; i < 10; ++i) { IPC::TestChannelListener::SendOneMessage( - sender(), "hello from parent"); + sender(), overly_large_data.c_str()); } ASSERT_TRUE(StartClient()); |