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

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

Issue 1430593005: EDK: Remove (direct) dependencies of //mojo/edk/system on //base/test. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 1 month 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 | « mojo/edk/system/endpoint_relayer_unittest.cc ('k') | mojo/edk/system/message_pipe_perftest.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 #include "mojo/edk/system/ipc_support.h" 5 #include "mojo/edk/system/ipc_support.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/synchronization/waitable_event.h" 14 #include "base/synchronization/waitable_event.h"
15 #include "base/test/test_timeouts.h" 15 #include "base/time/time.h"
16 #include "mojo/edk/embedder/master_process_delegate.h" 16 #include "mojo/edk/embedder/master_process_delegate.h"
17 #include "mojo/edk/embedder/platform_channel_pair.h" 17 #include "mojo/edk/embedder/platform_channel_pair.h"
18 #include "mojo/edk/embedder/simple_platform_support.h" 18 #include "mojo/edk/embedder/simple_platform_support.h"
19 #include "mojo/edk/embedder/slave_process_delegate.h" 19 #include "mojo/edk/embedder/slave_process_delegate.h"
20 #include "mojo/edk/system/channel_manager.h" 20 #include "mojo/edk/system/channel_manager.h"
21 #include "mojo/edk/system/connection_identifier.h" 21 #include "mojo/edk/system/connection_identifier.h"
22 #include "mojo/edk/system/dispatcher.h" 22 #include "mojo/edk/system/dispatcher.h"
23 #include "mojo/edk/system/message_pipe.h" 23 #include "mojo/edk/system/message_pipe.h"
24 #include "mojo/edk/system/message_pipe_dispatcher.h" 24 #include "mojo/edk/system/message_pipe_dispatcher.h"
25 #include "mojo/edk/system/process_identifier.h" 25 #include "mojo/edk/system/process_identifier.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 118
119 class TestMasterProcessDelegate : public embedder::MasterProcessDelegate { 119 class TestMasterProcessDelegate : public embedder::MasterProcessDelegate {
120 public: 120 public:
121 TestMasterProcessDelegate() 121 TestMasterProcessDelegate()
122 : on_slave_disconnect_event_(false, false) {} // Auto reset. 122 : on_slave_disconnect_event_(false, false) {} // Auto reset.
123 ~TestMasterProcessDelegate() override {} 123 ~TestMasterProcessDelegate() override {}
124 124
125 // Warning: There's only one slave disconnect event (which resets 125 // Warning: There's only one slave disconnect event (which resets
126 // automatically). 126 // automatically).
127 bool TryWaitForOnSlaveDisconnect() { 127 bool TryWaitForOnSlaveDisconnect() {
128 return on_slave_disconnect_event_.TimedWait(TestTimeouts::action_timeout()); 128 return on_slave_disconnect_event_.TimedWait(
129 base::TimeDelta::FromMicroseconds(
130 static_cast<int64_t>(test::ActionTimeout())));
129 } 131 }
130 132
131 private: 133 private:
132 // |embedder::MasterProcessDelegate| methods: 134 // |embedder::MasterProcessDelegate| methods:
133 void OnShutdownComplete() override { NOTREACHED(); } 135 void OnShutdownComplete() override { NOTREACHED(); }
134 136
135 void OnSlaveDisconnect(embedder::SlaveInfo /*slave_info*/) override { 137 void OnSlaveDisconnect(embedder::SlaveInfo /*slave_info*/) override {
136 on_slave_disconnect_event_.Signal(); 138 on_slave_disconnect_event_.Signal();
137 } 139 }
138 140
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&event_)), 179 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&event_)),
178 nullptr, &slave_id_); 180 nullptr, &slave_id_);
179 EXPECT_TRUE(mp); 181 EXPECT_TRUE(mp);
180 EXPECT_NE(slave_id_, kInvalidProcessIdentifier); 182 EXPECT_NE(slave_id_, kInvalidProcessIdentifier);
181 EXPECT_NE(slave_id_, kMasterProcessIdentifier); 183 EXPECT_NE(slave_id_, kMasterProcessIdentifier);
182 slave_platform_handle_ = channel_pair.PassClientHandle(); 184 slave_platform_handle_ = channel_pair.PassClientHandle();
183 return mp; 185 return mp;
184 } 186 }
185 187
186 void WaitForChannelToSlave() { 188 void WaitForChannelToSlave() {
187 EXPECT_TRUE(event_.TimedWait(TestTimeouts::action_timeout())); 189 EXPECT_TRUE(event_.TimedWait(base::TimeDelta::FromMicroseconds(
190 static_cast<int64_t>(test::ActionTimeout()))));
188 } 191 }
189 192
190 void ShutdownChannelToSlave() { 193 void ShutdownChannelToSlave() {
191 // Since |event_| is manual-reset, calling this multiple times is OK. 194 // Since |event_| is manual-reset, calling this multiple times is OK.
192 WaitForChannelToSlave(); 195 WaitForChannelToSlave();
193 196
194 test_io_thread_->PostTaskAndWait( 197 test_io_thread_->PostTaskAndWait(
195 base::Bind(&ChannelManager::ShutdownChannelOnIOThread, 198 base::Bind(&ChannelManager::ShutdownChannelOnIOThread,
196 base::Unretained(master_ipc_support_->channel_manager()), 199 base::Unretained(master_ipc_support_->channel_manager()),
197 slave_id_)); 200 slave_id_));
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 RefPtr<MessagePipeDispatcher> mp = slave_ipc_support_.ConnectToMaster( 245 RefPtr<MessagePipeDispatcher> mp = slave_ipc_support_.ConnectToMaster(
243 connection_id, 246 connection_id,
244 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&event_)), 247 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&event_)),
245 nullptr, &master_id); 248 nullptr, &master_id);
246 EXPECT_TRUE(mp); 249 EXPECT_TRUE(mp);
247 EXPECT_EQ(kMasterProcessIdentifier, master_id); 250 EXPECT_EQ(kMasterProcessIdentifier, master_id);
248 return mp; 251 return mp;
249 } 252 }
250 253
251 void WaitForChannelToMaster() { 254 void WaitForChannelToMaster() {
252 EXPECT_TRUE(event_.TimedWait(TestTimeouts::action_timeout())); 255 EXPECT_TRUE(event_.TimedWait(base::TimeDelta::FromMicroseconds(
256 static_cast<int64_t>(test::ActionTimeout()))));
253 } 257 }
254 258
255 void ShutdownChannelToMaster() { 259 void ShutdownChannelToMaster() {
256 // Since |event_| is manual-reset, calling this multiple times is OK. 260 // Since |event_| is manual-reset, calling this multiple times is OK.
257 WaitForChannelToMaster(); 261 WaitForChannelToMaster();
258 262
259 test_io_thread_->PostTaskAndWait( 263 test_io_thread_->PostTaskAndWait(
260 base::Bind(&ChannelManager::ShutdownChannelOnIOThread, 264 base::Bind(&ChannelManager::ShutdownChannelOnIOThread,
261 base::Unretained(slave_ipc_support_.channel_manager()), 265 base::Unretained(slave_ipc_support_.channel_manager()),
262 kMasterProcessIdentifier)); 266 kMasterProcessIdentifier));
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 711
708 test_io_thread.PostTaskAndWait(base::Bind(&IPCSupport::ShutdownOnIOThread, 712 test_io_thread.PostTaskAndWait(base::Bind(&IPCSupport::ShutdownOnIOThread,
709 base::Unretained(&ipc_support))); 713 base::Unretained(&ipc_support)));
710 } 714 }
711 715
712 // TODO(vtl): Also test the case of the master "dying" before the slave. (The 716 // TODO(vtl): Also test the case of the master "dying" before the slave. (The
713 // slave should get OnMasterDisconnect(), which we currently don't test.) 717 // slave should get OnMasterDisconnect(), which we currently don't test.)
714 718
715 } // namespace system 719 } // namespace system
716 } // namespace mojo 720 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/edk/system/endpoint_relayer_unittest.cc ('k') | mojo/edk/system/message_pipe_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698