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

Side by Side Diff: ipc/mojo/ipc_channel_mojo_unittest.cc

Issue 942933005: ChannelMojo should use PID from the bootstrap Channel. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Landing Created 5 years, 9 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 unified diff | Download patch
« no previous file with comments | « ipc/mojo/ipc_channel_mojo.cc ('k') | ipc/mojo/ipc_mojo_bootstrap.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ipc/mojo/ipc_channel_mojo.h" 5 #include "ipc/mojo/ipc_channel_mojo.h"
6 6
7 #include "base/base_paths.h" 7 #include "base/base_paths.h"
8 #include "base/files/file.h" 8 #include "base/files/file.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
11 #include "base/pickle.h" 11 #include "base/pickle.h"
12 #include "base/test/test_timeouts.h"
12 #include "base/threading/thread.h" 13 #include "base/threading/thread.h"
13 #include "ipc/ipc_message.h" 14 #include "ipc/ipc_message.h"
14 #include "ipc/ipc_test_base.h" 15 #include "ipc/ipc_test_base.h"
15 #include "ipc/ipc_test_channel_listener.h" 16 #include "ipc/ipc_test_channel_listener.h"
16 #include "ipc/mojo/ipc_channel_mojo_host.h" 17 #include "ipc/mojo/ipc_channel_mojo_host.h"
17 #include "ipc/mojo/ipc_mojo_handle_attachment.h" 18 #include "ipc/mojo/ipc_mojo_handle_attachment.h"
18 #include "ipc/mojo/ipc_mojo_message_helper.h" 19 #include "ipc/mojo/ipc_mojo_message_helper.h"
19 20
20 #if defined(OS_POSIX) 21 #if defined(OS_POSIX)
21 #include "base/file_descriptor_posix.h" 22 #include "base/file_descriptor_posix.h"
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 client.Connect(); 572 client.Connect();
572 listener.set_sender(client.channel()); 573 listener.set_sender(client.channel());
573 574
574 base::MessageLoop::current()->Run(); 575 base::MessageLoop::current()->Run();
575 576
576 return 0; 577 return 0;
577 } 578 }
578 579
579 #endif 580 #endif
580 581
582 #if defined(OS_LINUX)
583
584 const base::ProcessId kMagicChildId = 54321;
585
586 class ListenerThatVerifiesPeerPid : public IPC::Listener {
587 public:
588 void OnChannelConnected(int32 peer_pid) override {
589 EXPECT_EQ(peer_pid, kMagicChildId);
590 base::MessageLoop::current()->Quit();
591 }
592
593 bool OnMessageReceived(const IPC::Message& message) override {
594 NOTREACHED();
595 return true;
596 }
597 };
598
599 TEST_F(IPCChannelMojoTest, VerifyGlobalPid) {
600 Init("IPCChannelMojoTestVerifyGlobalPidClient");
601
602 ListenerThatVerifiesPeerPid listener;
603 CreateChannel(&listener);
604 ASSERT_TRUE(ConnectChannel());
605 ASSERT_TRUE(StartClient());
606
607 base::MessageLoop::current()->Run();
608 this->channel()->Close();
609
610 EXPECT_TRUE(WaitForClientShutdown());
611 DestroyChannel();
612 }
613
614 MULTIPROCESS_IPC_TEST_CLIENT_MAIN(IPCChannelMojoTestVerifyGlobalPidClient) {
615 IPC::Channel::SetGlobalPid(kMagicChildId);
616 ListenerThatQuits listener;
617 ChannelClient client(&listener,
618 "IPCChannelMojoTestVerifyGlobalPidClient");
619 client.Connect();
620
621 base::MessageLoop::current()->Run();
622
623 return 0;
624 }
625
626 #endif // OS_LINUX
627
581 } // namespace 628 } // namespace
OLDNEW
« no previous file with comments | « ipc/mojo/ipc_channel_mojo.cc ('k') | ipc/mojo/ipc_mojo_bootstrap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698