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

Side by Side Diff: mojo/edk/system/connection_manager_unittest.cc

Issue 1665573002: Rename some variables platform_channel_pair -> platform_pipe. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 10 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 | « no previous file | mojo/edk/system/master_connection_manager.cc » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 // This is really a unit test for |MasterConnectionManager| and 5 // This is really a unit test for |MasterConnectionManager| and
6 // |SlaveConnectionManager| (since they need to be tested together). 6 // |SlaveConnectionManager| (since they need to be tested together).
7 7
8 #include "mojo/edk/system/connection_manager.h" 8 #include "mojo/edk/system/connection_manager.h"
9 9
10 #include <stdint.h> 10 #include <stdint.h>
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 } 191 }
192 192
193 // Connects the given |slave| (with the given |slave_process_delegate|) to the 193 // Connects the given |slave| (with the given |slave_process_delegate|) to the
194 // given master, creating and using a |TestSlaveInfo| with the given 194 // given master, creating and using a |TestSlaveInfo| with the given
195 // |slave_name|, and returns the process identifier for the slave. 195 // |slave_name|, and returns the process identifier for the slave.
196 ProcessIdentifier ConnectSlave( 196 ProcessIdentifier ConnectSlave(
197 MasterConnectionManager* master, 197 MasterConnectionManager* master,
198 embedder::SlaveProcessDelegate* slave_process_delegate, 198 embedder::SlaveProcessDelegate* slave_process_delegate,
199 SlaveConnectionManager* slave, 199 SlaveConnectionManager* slave,
200 const std::string& slave_name) { 200 const std::string& slave_name) {
201 PlatformPipe platform_channel_pair; 201 PlatformPipe platform_pipe;
202 ProcessIdentifier slave_process_identifier = master->AddSlave( 202 ProcessIdentifier slave_process_identifier = master->AddSlave(
203 new TestSlaveInfo(slave_name), platform_channel_pair.handle0.Pass()); 203 new TestSlaveInfo(slave_name), platform_pipe.handle0.Pass());
204 slave->Init(task_runner().Clone(), slave_process_delegate, 204 slave->Init(task_runner().Clone(), slave_process_delegate,
205 platform_channel_pair.handle1.Pass()); 205 platform_pipe.handle1.Pass());
206 return slave_process_identifier; 206 return slave_process_identifier;
207 } 207 }
208 208
209 private: 209 private:
210 embedder::SimplePlatformSupport platform_support_; 210 embedder::SimplePlatformSupport platform_support_;
211 std::unique_ptr<MessageLoop> message_loop_; 211 std::unique_ptr<MessageLoop> message_loop_;
212 MockMasterProcessDelegate master_process_delegate_; 212 MockMasterProcessDelegate master_process_delegate_;
213 213
214 MOJO_DISALLOW_COPY_AND_ASSIGN(ConnectionManagerTest); 214 MOJO_DISALLOW_COPY_AND_ASSIGN(ConnectionManagerTest);
215 }; 215 };
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 slave.Shutdown(); 643 slave.Shutdown();
644 master.Shutdown(); 644 master.Shutdown();
645 } 645 }
646 646
647 TEST_F(ConnectionManagerTest, AddSlaveThenImmediateShutdown) { 647 TEST_F(ConnectionManagerTest, AddSlaveThenImmediateShutdown) {
648 MasterConnectionManager master(platform_support()); 648 MasterConnectionManager master(platform_support());
649 master.Init(task_runner().Clone(), &master_process_delegate()); 649 master.Init(task_runner().Clone(), &master_process_delegate());
650 650
651 MockSlaveProcessDelegate slave_process_delegate; 651 MockSlaveProcessDelegate slave_process_delegate;
652 SlaveConnectionManager slave(platform_support()); 652 SlaveConnectionManager slave(platform_support());
653 PlatformPipe platform_channel_pair; 653 PlatformPipe platform_pipe;
654 ProcessIdentifier slave_id = master.AddSlave( 654 ProcessIdentifier slave_id =
655 new TestSlaveInfo("slave"), platform_channel_pair.handle0.Pass()); 655 master.AddSlave(new TestSlaveInfo("slave"), platform_pipe.handle0.Pass());
656 master.Shutdown(); 656 master.Shutdown();
657 EXPECT_TRUE(IsValidSlaveProcessIdentifier(slave_id)); 657 EXPECT_TRUE(IsValidSlaveProcessIdentifier(slave_id));
658 // Since we never initialized |slave|, we don't have to shut it down. 658 // Since we never initialized |slave|, we don't have to shut it down.
659 } 659 }
660 660
661 TEST_F(ConnectionManagerTest, AddSlaveAndBootstrap) { 661 TEST_F(ConnectionManagerTest, AddSlaveAndBootstrap) {
662 MasterConnectionManager master(platform_support()); 662 MasterConnectionManager master(platform_support());
663 master.Init(task_runner().Clone(), &master_process_delegate()); 663 master.Init(task_runner().Clone(), &master_process_delegate());
664 664
665 PlatformPipe platform_channel_pair; 665 PlatformPipe platform_pipe;
666 ConnectionIdentifier connection_id = master.GenerateConnectionIdentifier(); 666 ConnectionIdentifier connection_id = master.GenerateConnectionIdentifier();
667 ProcessIdentifier slave_id = master.AddSlaveAndBootstrap( 667 ProcessIdentifier slave_id = master.AddSlaveAndBootstrap(
668 new TestSlaveInfo("slave"), platform_channel_pair.handle0.Pass(), 668 new TestSlaveInfo("slave"), platform_pipe.handle0.Pass(), connection_id);
669 connection_id);
670 EXPECT_TRUE(IsValidSlaveProcessIdentifier(slave_id)); 669 EXPECT_TRUE(IsValidSlaveProcessIdentifier(slave_id));
671 670
672 ScopedPlatformHandle h1; 671 ScopedPlatformHandle h1;
673 ProcessIdentifier master_peer = kInvalidProcessIdentifier; 672 ProcessIdentifier master_peer = kInvalidProcessIdentifier;
674 bool is_first = false; 673 bool is_first = false;
675 EXPECT_EQ(ConnectionManager::Result::SUCCESS_CONNECT_NEW_CONNECTION, 674 EXPECT_EQ(ConnectionManager::Result::SUCCESS_CONNECT_NEW_CONNECTION,
676 master.Connect(connection_id, &master_peer, &is_first, &h1)); 675 master.Connect(connection_id, &master_peer, &is_first, &h1));
677 EXPECT_EQ(slave_id, master_peer); 676 EXPECT_EQ(slave_id, master_peer);
678 EXPECT_TRUE(is_first); 677 EXPECT_TRUE(is_first);
679 EXPECT_TRUE(h1.is_valid()); 678 EXPECT_TRUE(h1.is_valid());
680 679
681 // We can delay creating/initializing |slave| for quite a while. 680 // We can delay creating/initializing |slave| for quite a while.
682 MockSlaveProcessDelegate slave_process_delegate; 681 MockSlaveProcessDelegate slave_process_delegate;
683 SlaveConnectionManager slave(platform_support()); 682 SlaveConnectionManager slave(platform_support());
684 slave.Init(task_runner().Clone(), &slave_process_delegate, 683 slave.Init(task_runner().Clone(), &slave_process_delegate,
685 platform_channel_pair.handle1.Pass()); 684 platform_pipe.handle1.Pass());
686 685
687 ProcessIdentifier slave_peer = kInvalidProcessIdentifier; 686 ProcessIdentifier slave_peer = kInvalidProcessIdentifier;
688 ScopedPlatformHandle h2; 687 ScopedPlatformHandle h2;
689 EXPECT_EQ(ConnectionManager::Result::SUCCESS_CONNECT_NEW_CONNECTION, 688 EXPECT_EQ(ConnectionManager::Result::SUCCESS_CONNECT_NEW_CONNECTION,
690 slave.Connect(connection_id, &slave_peer, &is_first, &h2)); 689 slave.Connect(connection_id, &slave_peer, &is_first, &h2));
691 EXPECT_EQ(kMasterProcessIdentifier, slave_peer); 690 EXPECT_EQ(kMasterProcessIdentifier, slave_peer);
692 EXPECT_FALSE(is_first); 691 EXPECT_FALSE(is_first);
693 692
694 EXPECT_TRUE(ArePlatformHandlesConnected(h1.get(), h2.get())); 693 EXPECT_TRUE(ArePlatformHandlesConnected(h1.get(), h2.get()));
695 694
696 slave.Shutdown(); 695 slave.Shutdown();
697 master.Shutdown(); 696 master.Shutdown();
698 } 697 }
699 698
700 // TODO(vtl): More shutdown cases for |AddSlaveAndBootstrap()|? 699 // TODO(vtl): More shutdown cases for |AddSlaveAndBootstrap()|?
701 700
702 } // namespace 701 } // namespace
703 } // namespace system 702 } // namespace system
704 } // namespace mojo 703 } // namespace mojo
OLDNEW
« no previous file with comments | « no previous file | mojo/edk/system/master_connection_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698