| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 25 matching lines...) Expand all Loading... |
| 36 CONNECTED, | 36 CONNECTED, |
| 37 DENIED, | 37 DENIED, |
| 38 LISTEN_ERROR | 38 LISTEN_ERROR |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 IPCChannelPosixTestListener(bool quit_only_on_message) | 41 IPCChannelPosixTestListener(bool quit_only_on_message) |
| 42 : status_(DISCONNECTED), quit_only_on_message_(quit_only_on_message) {} | 42 : status_(DISCONNECTED), quit_only_on_message_(quit_only_on_message) {} |
| 43 | 43 |
| 44 virtual ~IPCChannelPosixTestListener() {} | 44 virtual ~IPCChannelPosixTestListener() {} |
| 45 | 45 |
| 46 virtual void OnMessageReceived(const IPC::Message& message) { | 46 virtual bool OnMessageReceived(const IPC::Message& message) { |
| 47 EXPECT_EQ(message.type(), QUIT_MESSAGE); | 47 EXPECT_EQ(message.type(), QUIT_MESSAGE); |
| 48 status_ = MESSAGE_RECEIVED; | 48 status_ = MESSAGE_RECEIVED; |
| 49 QuitRunLoop(); | 49 QuitRunLoop(); |
| 50 return true; |
| 50 } | 51 } |
| 51 | 52 |
| 52 virtual void OnChannelConnected(int32 peer_pid) { | 53 virtual void OnChannelConnected(int32 peer_pid) { |
| 53 status_ = CONNECTED; | 54 status_ = CONNECTED; |
| 54 if (!quit_only_on_message_) { | 55 if (!quit_only_on_message_) { |
| 55 QuitRunLoop(); | 56 QuitRunLoop(); |
| 56 } | 57 } |
| 57 } | 58 } |
| 58 | 59 |
| 59 virtual void OnChannelError() { | 60 virtual void OnChannelError() { |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 bool connected = channel.Connect(); | 347 bool connected = channel.Connect(); |
| 347 if (connected) { | 348 if (connected) { |
| 348 IPCChannelPosixTest::SpinRunLoop(TestTimeouts::action_max_timeout_ms()); | 349 IPCChannelPosixTest::SpinRunLoop(TestTimeouts::action_max_timeout_ms()); |
| 349 EXPECT_EQ(IPCChannelPosixTestListener::CHANNEL_ERROR, listener.status()); | 350 EXPECT_EQ(IPCChannelPosixTestListener::CHANNEL_ERROR, listener.status()); |
| 350 } else { | 351 } else { |
| 351 EXPECT_EQ(IPCChannelPosixTestListener::DISCONNECTED, listener.status()); | 352 EXPECT_EQ(IPCChannelPosixTestListener::DISCONNECTED, listener.status()); |
| 352 } | 353 } |
| 353 return 0; | 354 return 0; |
| 354 } | 355 } |
| 355 | 356 |
| OLD | NEW |