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

Side by Side Diff: ipc/ipc_tests.cc

Issue 10692155: Switch to TimeDelta interfaces for process waiting functions in net and ipc. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 5 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/ipc_send_fds_test.cc ('k') | ipc/sync_socket_unittest.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #elif defined(OS_POSIX) 9 #elif defined(OS_POSIX)
10 #include <sys/types.h> 10 #include <sys/types.h>
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 231
232 Send(&chan, "hello from parent"); 232 Send(&chan, "hello from parent");
233 233
234 // Run message loop. 234 // Run message loop.
235 MessageLoop::current()->Run(); 235 MessageLoop::current()->Run();
236 236
237 // Close Channel so client gets its OnChannelError() callback fired. 237 // Close Channel so client gets its OnChannelError() callback fired.
238 chan.Close(); 238 chan.Close();
239 239
240 // Cleanup child process. 240 // Cleanup child process.
241 EXPECT_TRUE(base::WaitForSingleProcess(process_handle, 5000)); 241 EXPECT_TRUE(base::WaitForSingleProcess(
242 process_handle, base::TimeDelta::FromSeconds(5)));
242 base::CloseProcessHandle(process_handle); 243 base::CloseProcessHandle(process_handle);
243 } 244 }
244 245
245 #if defined(OS_WIN) 246 #if defined(OS_WIN)
246 TEST_F(IPCChannelTest, ChannelTestExistingPipe) { 247 TEST_F(IPCChannelTest, ChannelTestExistingPipe) {
247 MyChannelListener channel_listener; 248 MyChannelListener channel_listener;
248 // Setup IPC channel with existing pipe. Specify name in Chrome format. 249 // Setup IPC channel with existing pipe. Specify name in Chrome format.
249 std::string name("\\\\.\\pipe\\chrome."); 250 std::string name("\\\\.\\pipe\\chrome.");
250 name.append(kTestClientChannel); 251 name.append(kTestClientChannel);
251 const DWORD open_mode = PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED | 252 const DWORD open_mode = PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED |
(...skipping 19 matching lines...) Expand all
271 272
272 Send(&chan, "hello from parent"); 273 Send(&chan, "hello from parent");
273 274
274 // Run message loop. 275 // Run message loop.
275 MessageLoop::current()->Run(); 276 MessageLoop::current()->Run();
276 277
277 // Close Channel so client gets its OnChannelError() callback fired. 278 // Close Channel so client gets its OnChannelError() callback fired.
278 chan.Close(); 279 chan.Close();
279 280
280 // Cleanup child process. 281 // Cleanup child process.
281 EXPECT_TRUE(base::WaitForSingleProcess(process_handle, 5000)); 282 EXPECT_TRUE(base::WaitForSingleProcess(
283 process_handle, base::TimeDelta::FromSeconds(5)));
282 base::CloseProcessHandle(process_handle); 284 base::CloseProcessHandle(process_handle);
283 } 285 }
284 #endif // defined (OS_WIN) 286 #endif // defined (OS_WIN)
285 287
286 TEST_F(IPCChannelTest, ChannelProxyTest) { 288 TEST_F(IPCChannelTest, ChannelProxyTest) {
287 MyChannelListener channel_listener; 289 MyChannelListener channel_listener;
288 290
289 // The thread needs to out-live the ChannelProxy. 291 // The thread needs to out-live the ChannelProxy.
290 base::Thread thread("ChannelProxyTestServer"); 292 base::Thread thread("ChannelProxyTestServer");
291 base::Thread::Options options; 293 base::Thread::Options options;
(...skipping 24 matching lines...) Expand all
316 #endif // defined(OS_POSIX) 318 #endif // defined(OS_POSIX)
317 319
318 ASSERT_TRUE(process_handle); 320 ASSERT_TRUE(process_handle);
319 321
320 Send(&chan, "hello from parent"); 322 Send(&chan, "hello from parent");
321 323
322 // run message loop 324 // run message loop
323 MessageLoop::current()->Run(); 325 MessageLoop::current()->Run();
324 326
325 // cleanup child process 327 // cleanup child process
326 EXPECT_TRUE(base::WaitForSingleProcess(process_handle, 5000)); 328 EXPECT_TRUE(base::WaitForSingleProcess(
329 process_handle, base::TimeDelta::FromSeconds(5)));
327 base::CloseProcessHandle(process_handle); 330 base::CloseProcessHandle(process_handle);
328 } 331 }
329 thread.Stop(); 332 thread.Stop();
330 } 333 }
331 334
332 class ChannelListenerWithOnConnectedSend : public IPC::Listener { 335 class ChannelListenerWithOnConnectedSend : public IPC::Listener {
333 public: 336 public:
334 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE { 337 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE {
335 SendNextMessage(); 338 SendNextMessage();
336 } 339 }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 395
393 Send(&channel, "hello from parent"); 396 Send(&channel, "hello from parent");
394 397
395 // Run message loop. 398 // Run message loop.
396 MessageLoop::current()->Run(); 399 MessageLoop::current()->Run();
397 400
398 // Close Channel so client gets its OnChannelError() callback fired. 401 // Close Channel so client gets its OnChannelError() callback fired.
399 channel.Close(); 402 channel.Close();
400 403
401 // Cleanup child process. 404 // Cleanup child process.
402 EXPECT_TRUE(base::WaitForSingleProcess(process_handle, 5000)); 405 EXPECT_TRUE(base::WaitForSingleProcess(
406 process_handle, base::TimeDelta::FromSeconds(5)));
403 base::CloseProcessHandle(process_handle); 407 base::CloseProcessHandle(process_handle);
404 } 408 }
405 409
406 MULTIPROCESS_IPC_TEST_MAIN(RunTestClient) { 410 MULTIPROCESS_IPC_TEST_MAIN(RunTestClient) {
407 MessageLoopForIO main_message_loop; 411 MessageLoopForIO main_message_loop;
408 MyChannelListener channel_listener; 412 MyChannelListener channel_listener;
409 413
410 // setup IPC channel 414 // setup IPC channel
411 IPC::Channel chan(kTestClientChannel, IPC::Channel::MODE_CLIENT, 415 IPC::Channel chan(kTestClientChannel, IPC::Channel::MODE_CLIENT,
412 &channel_listener); 416 &channel_listener);
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 #endif // PERFORMANCE_TEST 591 #endif // PERFORMANCE_TEST
588 592
589 int main(int argc, char** argv) { 593 int main(int argc, char** argv) {
590 #ifdef PERFORMANCE_TEST 594 #ifdef PERFORMANCE_TEST
591 int retval = base::PerfTestSuite(argc, argv).Run(); 595 int retval = base::PerfTestSuite(argc, argv).Run();
592 #else 596 #else
593 int retval = base::TestSuite(argc, argv).Run(); 597 int retval = base::TestSuite(argc, argv).Run();
594 #endif 598 #endif
595 return retval; 599 return retval;
596 } 600 }
OLDNEW
« no previous file with comments | « ipc/ipc_send_fds_test.cc ('k') | ipc/sync_socket_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698