| OLD | NEW |
| 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 29 matching lines...) Expand all Loading... |
| 40 LISTEN_ERROR | 40 LISTEN_ERROR |
| 41 }; | 41 }; |
| 42 | 42 |
| 43 IPCChannelPosixTestListener(bool quit_only_on_message) | 43 IPCChannelPosixTestListener(bool quit_only_on_message) |
| 44 : status_(DISCONNECTED), | 44 : status_(DISCONNECTED), |
| 45 quit_only_on_message_(quit_only_on_message) { | 45 quit_only_on_message_(quit_only_on_message) { |
| 46 } | 46 } |
| 47 | 47 |
| 48 virtual ~IPCChannelPosixTestListener() {} | 48 virtual ~IPCChannelPosixTestListener() {} |
| 49 | 49 |
| 50 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE { | 50 virtual bool OnMessageReceived(const IPC::Message& message) override { |
| 51 EXPECT_EQ(message.type(), kQuitMessage); | 51 EXPECT_EQ(message.type(), kQuitMessage); |
| 52 status_ = MESSAGE_RECEIVED; | 52 status_ = MESSAGE_RECEIVED; |
| 53 QuitRunLoop(); | 53 QuitRunLoop(); |
| 54 return true; | 54 return true; |
| 55 } | 55 } |
| 56 | 56 |
| 57 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE { | 57 virtual void OnChannelConnected(int32 peer_pid) override { |
| 58 status_ = CONNECTED; | 58 status_ = CONNECTED; |
| 59 if (!quit_only_on_message_) { | 59 if (!quit_only_on_message_) { |
| 60 QuitRunLoop(); | 60 QuitRunLoop(); |
| 61 } | 61 } |
| 62 } | 62 } |
| 63 | 63 |
| 64 virtual void OnChannelError() OVERRIDE { | 64 virtual void OnChannelError() override { |
| 65 status_ = CHANNEL_ERROR; | 65 status_ = CHANNEL_ERROR; |
| 66 QuitRunLoop(); | 66 QuitRunLoop(); |
| 67 } | 67 } |
| 68 | 68 |
| 69 virtual void OnChannelDenied() OVERRIDE { | 69 virtual void OnChannelDenied() override { |
| 70 status_ = DENIED; | 70 status_ = DENIED; |
| 71 if (!quit_only_on_message_) { | 71 if (!quit_only_on_message_) { |
| 72 QuitRunLoop(); | 72 QuitRunLoop(); |
| 73 } | 73 } |
| 74 } | 74 } |
| 75 | 75 |
| 76 virtual void OnChannelListenError() OVERRIDE { | 76 virtual void OnChannelListenError() override { |
| 77 status_ = LISTEN_ERROR; | 77 status_ = LISTEN_ERROR; |
| 78 if (!quit_only_on_message_) { | 78 if (!quit_only_on_message_) { |
| 79 QuitRunLoop(); | 79 QuitRunLoop(); |
| 80 } | 80 } |
| 81 } | 81 } |
| 82 | 82 |
| 83 STATUS status() { return status_; } | 83 STATUS status() { return status_; } |
| 84 | 84 |
| 85 void QuitRunLoop() { | 85 void QuitRunLoop() { |
| 86 base::MessageLoopForIO* loop = base::MessageLoopForIO::current(); | 86 base::MessageLoopForIO* loop = base::MessageLoopForIO::current(); |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 if (connected) { | 479 if (connected) { |
| 480 IPCChannelPosixTest::SpinRunLoop(TestTimeouts::action_max_timeout()); | 480 IPCChannelPosixTest::SpinRunLoop(TestTimeouts::action_max_timeout()); |
| 481 EXPECT_EQ(IPCChannelPosixTestListener::CHANNEL_ERROR, listener.status()); | 481 EXPECT_EQ(IPCChannelPosixTestListener::CHANNEL_ERROR, listener.status()); |
| 482 } else { | 482 } else { |
| 483 EXPECT_EQ(IPCChannelPosixTestListener::DISCONNECTED, listener.status()); | 483 EXPECT_EQ(IPCChannelPosixTestListener::DISCONNECTED, listener.status()); |
| 484 } | 484 } |
| 485 return 0; | 485 return 0; |
| 486 } | 486 } |
| 487 | 487 |
| 488 } // namespace | 488 } // namespace |
| OLD | NEW |