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

Unified Diff: ipc/ipc_tests.cc

Issue 9150030: Initialize IPC:ChannelHandle from existing HANDLE (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: use string16 Created 8 years, 11 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 | « ipc/ipc_message_utils.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/ipc_tests.cc
diff --git a/ipc/ipc_tests.cc b/ipc/ipc_tests.cc
index 27276814c07182bba0ca37cc7528e95f8091412e..f52ff950f12de355b5ad911bd6cab6a409f3998a 100644
--- a/ipc/ipc_tests.cc
+++ b/ipc/ipc_tests.cc
@@ -240,6 +240,47 @@ TEST_F(IPCChannelTest, ChannelTest) {
base::CloseProcessHandle(process_handle);
}
+#if defined(OS_WIN)
+TEST_F(IPCChannelTest, ChannelTestExistingPipe) {
+ MyChannelListener channel_listener;
+ // Setup IPC channel with existing pipe. Specify name in Chrome format.
+ std::string name("\\\\.\\pipe\\chrome.");
+ name.append(kTestClientChannel);
+ const DWORD open_mode = PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED |
+ FILE_FLAG_FIRST_PIPE_INSTANCE;
+ HANDLE pipe = CreateNamedPipeA(name.c_str(),
+ open_mode,
+ PIPE_TYPE_BYTE | PIPE_READMODE_BYTE,
+ 1,
+ 4096,
+ 4096,
+ 5000,
+ NULL);
+ IPC::Channel chan(IPC::ChannelHandle(pipe), IPC::Channel::MODE_SERVER,
+ &channel_listener);
+ // Channel will duplicate the handle.
+ CloseHandle(pipe);
+ ASSERT_TRUE(chan.Connect());
+
+ channel_listener.Init(&chan);
+
+ base::ProcessHandle process_handle = SpawnChild(TEST_CLIENT, &chan);
+ ASSERT_TRUE(process_handle);
+
+ Send(&chan, "hello from parent");
+
+ // Run message loop.
+ MessageLoop::current()->Run();
+
+ // Close Channel so client gets its OnChannelError() callback fired.
+ chan.Close();
+
+ // Cleanup child process.
+ EXPECT_TRUE(base::WaitForSingleProcess(process_handle, 5000));
+ base::CloseProcessHandle(process_handle);
+}
+#endif // defined (OS_WIN)
+
TEST_F(IPCChannelTest, ChannelProxyTest) {
MyChannelListener channel_listener;
« no previous file with comments | « ipc/ipc_message_utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698