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

Side by Side Diff: ipc/ipc_channel_posix_unittest.cc

Issue 57783006: Revert https://src.chromium.org/viewvc/chrome?view=rev&revision=231330 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile (cc perftest). Created 7 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 | Annotate | Revision Log
« no previous file with comments | « ipc/ipc_channel_posix.cc ('k') | ipc/ipc_channel_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 // These tests are POSIX only. 5 // These tests are POSIX only.
6 6
7 #include "ipc/ipc_channel_posix.h" 7 #include "ipc/ipc_channel_posix.h"
8 8
9 #include <fcntl.h> 9 #include <fcntl.h>
10 #include <sys/socket.h> 10 #include <sys/socket.h>
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 ASSERT_TRUE(channel.Connect()); 237 ASSERT_TRUE(channel.Connect());
238 ASSERT_TRUE(channel.AcceptsConnections()); 238 ASSERT_TRUE(channel.AcceptsConnections());
239 ASSERT_FALSE(channel.HasAcceptedConnection()); 239 ASSERT_FALSE(channel.HasAcceptedConnection());
240 240
241 base::ProcessHandle handle = SpawnChild("IPCChannelPosixTestConnectionProc", 241 base::ProcessHandle handle = SpawnChild("IPCChannelPosixTestConnectionProc",
242 false); 242 false);
243 ASSERT_TRUE(handle); 243 ASSERT_TRUE(handle);
244 SpinRunLoop(TestTimeouts::action_max_timeout()); 244 SpinRunLoop(TestTimeouts::action_max_timeout());
245 ASSERT_EQ(IPCChannelPosixTestListener::CONNECTED, listener.status()); 245 ASSERT_EQ(IPCChannelPosixTestListener::CONNECTED, listener.status());
246 ASSERT_TRUE(channel.HasAcceptedConnection()); 246 ASSERT_TRUE(channel.HasAcceptedConnection());
247 IPC::Message* message = new IPC::Message(0, /* routing_id */ 247 IPC::Message* message = new IPC::Message(0, // routing_id
248 kQuitMessage /* message type */); 248 kQuitMessage, // message type
249 IPC::Message::PRIORITY_NORMAL);
249 channel.Send(message); 250 channel.Send(message);
250 SpinRunLoop(TestTimeouts::action_timeout()); 251 SpinRunLoop(TestTimeouts::action_timeout());
251 int exit_code = 0; 252 int exit_code = 0;
252 EXPECT_TRUE(base::WaitForExitCode(handle, &exit_code)); 253 EXPECT_TRUE(base::WaitForExitCode(handle, &exit_code));
253 EXPECT_EQ(0, exit_code); 254 EXPECT_EQ(0, exit_code);
254 ASSERT_EQ(IPCChannelPosixTestListener::CHANNEL_ERROR, listener.status()); 255 ASSERT_EQ(IPCChannelPosixTestListener::CHANNEL_ERROR, listener.status());
255 ASSERT_FALSE(channel.HasAcceptedConnection()); 256 ASSERT_FALSE(channel.HasAcceptedConnection());
256 } 257 }
257 258
258 TEST_F(IPCChannelPosixTest, ResetState) { 259 TEST_F(IPCChannelPosixTest, ResetState) {
(...skipping 16 matching lines...) Expand all
275 ASSERT_TRUE(channel.HasAcceptedConnection()); 276 ASSERT_TRUE(channel.HasAcceptedConnection());
276 channel.ResetToAcceptingConnectionState(); 277 channel.ResetToAcceptingConnectionState();
277 ASSERT_FALSE(channel.HasAcceptedConnection()); 278 ASSERT_FALSE(channel.HasAcceptedConnection());
278 279
279 base::ProcessHandle handle2 = SpawnChild("IPCChannelPosixTestConnectionProc", 280 base::ProcessHandle handle2 = SpawnChild("IPCChannelPosixTestConnectionProc",
280 false); 281 false);
281 ASSERT_TRUE(handle2); 282 ASSERT_TRUE(handle2);
282 SpinRunLoop(TestTimeouts::action_max_timeout()); 283 SpinRunLoop(TestTimeouts::action_max_timeout());
283 ASSERT_EQ(IPCChannelPosixTestListener::CONNECTED, listener.status()); 284 ASSERT_EQ(IPCChannelPosixTestListener::CONNECTED, listener.status());
284 ASSERT_TRUE(channel.HasAcceptedConnection()); 285 ASSERT_TRUE(channel.HasAcceptedConnection());
285 IPC::Message* message = new IPC::Message(0, /* routing_id */ 286 IPC::Message* message = new IPC::Message(0, // routing_id
286 kQuitMessage /* message type */); 287 kQuitMessage, // message type
288 IPC::Message::PRIORITY_NORMAL);
287 channel.Send(message); 289 channel.Send(message);
288 SpinRunLoop(TestTimeouts::action_timeout()); 290 SpinRunLoop(TestTimeouts::action_timeout());
289 EXPECT_TRUE(base::KillProcess(handle, 0, false)); 291 EXPECT_TRUE(base::KillProcess(handle, 0, false));
290 int exit_code = 0; 292 int exit_code = 0;
291 EXPECT_TRUE(base::WaitForExitCode(handle2, &exit_code)); 293 EXPECT_TRUE(base::WaitForExitCode(handle2, &exit_code));
292 EXPECT_EQ(0, exit_code); 294 EXPECT_EQ(0, exit_code);
293 ASSERT_EQ(IPCChannelPosixTestListener::CHANNEL_ERROR, listener.status()); 295 ASSERT_EQ(IPCChannelPosixTestListener::CHANNEL_ERROR, listener.status());
294 ASSERT_FALSE(channel.HasAcceptedConnection()); 296 ASSERT_FALSE(channel.HasAcceptedConnection());
295 } 297 }
296 298
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 ASSERT_TRUE(channel.HasAcceptedConnection()); 335 ASSERT_TRUE(channel.HasAcceptedConnection());
334 base::ProcessHandle handle2 = SpawnChild("IPCChannelPosixFailConnectionProc", 336 base::ProcessHandle handle2 = SpawnChild("IPCChannelPosixFailConnectionProc",
335 false); 337 false);
336 ASSERT_TRUE(handle2); 338 ASSERT_TRUE(handle2);
337 SpinRunLoop(TestTimeouts::action_max_timeout()); 339 SpinRunLoop(TestTimeouts::action_max_timeout());
338 int exit_code = 0; 340 int exit_code = 0;
339 EXPECT_TRUE(base::WaitForExitCode(handle2, &exit_code)); 341 EXPECT_TRUE(base::WaitForExitCode(handle2, &exit_code));
340 EXPECT_EQ(exit_code, 0); 342 EXPECT_EQ(exit_code, 0);
341 ASSERT_EQ(IPCChannelPosixTestListener::DENIED, listener.status()); 343 ASSERT_EQ(IPCChannelPosixTestListener::DENIED, listener.status());
342 ASSERT_TRUE(channel.HasAcceptedConnection()); 344 ASSERT_TRUE(channel.HasAcceptedConnection());
343 IPC::Message* message = new IPC::Message(0, /* routing_id */ 345 IPC::Message* message = new IPC::Message(0, // routing_id
344 kQuitMessage /* message type */); 346 kQuitMessage, // message type
347 IPC::Message::PRIORITY_NORMAL);
345 channel.Send(message); 348 channel.Send(message);
346 SpinRunLoop(TestTimeouts::action_timeout()); 349 SpinRunLoop(TestTimeouts::action_timeout());
347 EXPECT_TRUE(base::WaitForExitCode(handle, &exit_code)); 350 EXPECT_TRUE(base::WaitForExitCode(handle, &exit_code));
348 EXPECT_EQ(exit_code, 0); 351 EXPECT_EQ(exit_code, 0);
349 ASSERT_EQ(IPCChannelPosixTestListener::CHANNEL_ERROR, listener.status()); 352 ASSERT_EQ(IPCChannelPosixTestListener::CHANNEL_ERROR, listener.status());
350 ASSERT_FALSE(channel.HasAcceptedConnection()); 353 ASSERT_FALSE(channel.HasAcceptedConnection());
351 } 354 }
352 355
353 TEST_F(IPCChannelPosixTest, DoubleServer) { 356 TEST_F(IPCChannelPosixTest, DoubleServer) {
354 // Test setting up two servers with the same name. 357 // Test setting up two servers with the same name.
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 if (connected) { 417 if (connected) {
415 IPCChannelPosixTest::SpinRunLoop(TestTimeouts::action_max_timeout()); 418 IPCChannelPosixTest::SpinRunLoop(TestTimeouts::action_max_timeout());
416 EXPECT_EQ(IPCChannelPosixTestListener::CHANNEL_ERROR, listener.status()); 419 EXPECT_EQ(IPCChannelPosixTestListener::CHANNEL_ERROR, listener.status());
417 } else { 420 } else {
418 EXPECT_EQ(IPCChannelPosixTestListener::DISCONNECTED, listener.status()); 421 EXPECT_EQ(IPCChannelPosixTestListener::DISCONNECTED, listener.status());
419 } 422 }
420 return 0; 423 return 0;
421 } 424 }
422 425
423 } // namespace 426 } // namespace
OLDNEW
« no previous file with comments | « ipc/ipc_channel_posix.cc ('k') | ipc/ipc_channel_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698