Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(322)

Unified Diff: ipc/mojo/ipc_channel_mojo_unittest.cc

Issue 654113002: ChannelMojo: Fail when GetFileHandleForProcess() failed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ipc/mojo/ipc_mojo_bootstrap.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/mojo/ipc_channel_mojo_unittest.cc
diff --git a/ipc/mojo/ipc_channel_mojo_unittest.cc b/ipc/mojo/ipc_channel_mojo_unittest.cc
index c66fc913598f9ebc9fc27b8f628a1ff042c625a3..cefa29e08af85d1172b41e906529547e9be7c031 100644
--- a/ipc/mojo/ipc_channel_mojo_unittest.cc
+++ b/ipc/mojo/ipc_channel_mojo_unittest.cc
@@ -259,6 +259,64 @@ TEST_F(IPCChannelMojoErrorTest, SendFailWithPendingMessages) {
DestroyChannel();
}
+#if defined(OS_WIN)
+class IPCChannelMojoDeadHandleTest : public IPCTestBase {
+ protected:
+ virtual scoped_ptr<IPC::ChannelFactory> CreateChannelFactory(
+ const IPC::ChannelHandle& handle,
+ base::TaskRunner* runner) override {
+ host_.reset(new IPC::ChannelMojoHost(task_runner()));
+ return IPC::ChannelMojo::CreateServerFactory(host_->channel_delegate(),
+ handle);
+ }
+
+ virtual bool DidStartClient() override {
+ IPCTestBase::DidStartClient();
+ base::ProcessHandle client = client_process();
+ // Forces GetFileHandleForProcess() fail. It happens occasionally
+ // in production, so we should exercise it somehow.
+ ::CloseHandle(client);
+ host_->OnClientLaunched(client);
+ return true;
+ }
+
+ private:
+ scoped_ptr<IPC::ChannelMojoHost> host_;
+};
+
+TEST_F(IPCChannelMojoDeadHandleTest, InvalidClientHandle) {
+ // Any client type is fine as it is going to be killed anyway.
+ Init("IPCChannelMojoTestDoNothingClient");
+
+ // Set up IPC channel and start client.
+ ListenerExpectingErrors listener;
+ CreateChannel(&listener);
+ ASSERT_TRUE(ConnectChannel());
+
+ ASSERT_TRUE(StartClient());
+ base::MessageLoop::current()->Run();
+
+ this->channel()->Close();
+
+ // WaitForClientShutdown() fails as client_hanadle() is already
+ // closed.
+ EXPECT_FALSE(WaitForClientShutdown());
+ EXPECT_TRUE(listener.has_error());
+
+ DestroyChannel();
+}
+
+MULTIPROCESS_IPC_TEST_CLIENT_MAIN(IPCChannelMojoTestDoNothingClient) {
+ ListenerThatQuits listener;
+ ChannelClient client(&listener, "IPCChannelMojoTestDoNothingClient");
+ client.Connect();
+
+ // Quits without running the message loop as this client won't
+ // receive any messages from the server.
+
+ return 0;
+}
+#endif
#if defined(OS_POSIX)
class ListenerThatExpectsFile : public IPC::Listener {
« no previous file with comments | « no previous file | ipc/mojo/ipc_mojo_bootstrap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698