OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 bool OnMessageReceived(const IPC::Message& message) { | 46 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE { |
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 return true; |
51 } | 51 } |
52 | 52 |
53 virtual void OnChannelConnected(int32 peer_pid) { | 53 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE { |
54 status_ = CONNECTED; | 54 status_ = CONNECTED; |
55 if (!quit_only_on_message_) { | 55 if (!quit_only_on_message_) { |
56 QuitRunLoop(); | 56 QuitRunLoop(); |
57 } | 57 } |
58 } | 58 } |
59 | 59 |
60 virtual void OnChannelError() { | 60 virtual void OnChannelError() OVERRIDE { |
61 status_ = CHANNEL_ERROR; | 61 status_ = CHANNEL_ERROR; |
62 if (!quit_only_on_message_) { | 62 if (!quit_only_on_message_) { |
63 QuitRunLoop(); | 63 QuitRunLoop(); |
64 } | 64 } |
65 } | 65 } |
66 | 66 |
67 virtual void OnChannelDenied() { | 67 virtual void OnChannelDenied() OVERRIDE { |
68 status_ = DENIED; | 68 status_ = DENIED; |
69 if (!quit_only_on_message_) { | 69 if (!quit_only_on_message_) { |
70 QuitRunLoop(); | 70 QuitRunLoop(); |
71 } | 71 } |
72 } | 72 } |
73 | 73 |
74 virtual void OnChannelListenError() { | 74 virtual void OnChannelListenError() OVERRIDE { |
75 status_ = LISTEN_ERROR; | 75 status_ = LISTEN_ERROR; |
76 if (!quit_only_on_message_) { | 76 if (!quit_only_on_message_) { |
77 QuitRunLoop(); | 77 QuitRunLoop(); |
78 } | 78 } |
79 } | 79 } |
80 | 80 |
81 STATUS status() { return status_; } | 81 STATUS status() { return status_; } |
82 | 82 |
83 void QuitRunLoop() { | 83 void QuitRunLoop() { |
84 MessageLoopForIO::current()->QuitNow(); | 84 MessageLoopForIO::current()->QuitNow(); |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 bool connected = channel.Connect(); | 380 bool connected = channel.Connect(); |
381 if (connected) { | 381 if (connected) { |
382 IPCChannelPosixTest::SpinRunLoop(TestTimeouts::action_max_timeout_ms()); | 382 IPCChannelPosixTest::SpinRunLoop(TestTimeouts::action_max_timeout_ms()); |
383 EXPECT_EQ(IPCChannelPosixTestListener::CHANNEL_ERROR, listener.status()); | 383 EXPECT_EQ(IPCChannelPosixTestListener::CHANNEL_ERROR, listener.status()); |
384 } else { | 384 } else { |
385 EXPECT_EQ(IPCChannelPosixTestListener::DISCONNECTED, listener.status()); | 385 EXPECT_EQ(IPCChannelPosixTestListener::DISCONNECTED, listener.status()); |
386 } | 386 } |
387 return 0; | 387 return 0; |
388 } | 388 } |
389 | 389 |
OLD | NEW |