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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 } | 170 } |
171 handle->socket.fd = socket_fd; | 171 handle->socket.fd = socket_fd; |
172 } | 172 } |
173 | 173 |
174 void IPCChannelPosixTest::SpinRunLoop(int milliseconds) { | 174 void IPCChannelPosixTest::SpinRunLoop(int milliseconds) { |
175 MessageLoopForIO *loop = MessageLoopForIO::current(); | 175 MessageLoopForIO *loop = MessageLoopForIO::current(); |
176 // Post a quit task so that this loop eventually ends and we don't hang | 176 // Post a quit task so that this loop eventually ends and we don't hang |
177 // in the case of a bad test. Usually, the run loop will quit sooner than | 177 // in the case of a bad test. Usually, the run loop will quit sooner than |
178 // that because all tests use a IPCChannelPosixTestListener which quits the | 178 // that because all tests use a IPCChannelPosixTestListener which quits the |
179 // current run loop on any channel activity. | 179 // current run loop on any channel activity. |
180 loop->PostDelayedTask(FROM_HERE, new MessageLoop::QuitTask(), milliseconds); | 180 loop->PostDelayedTask(FROM_HERE, MessageLoop::QuitClosure(), milliseconds); |
181 loop->Run(); | 181 loop->Run(); |
182 } | 182 } |
183 | 183 |
184 TEST_F(IPCChannelPosixTest, BasicListen) { | 184 TEST_F(IPCChannelPosixTest, BasicListen) { |
185 | 185 |
186 #if defined(OS_ANDROID) | 186 #if defined(OS_ANDROID) |
187 const char* kChannelName = "/data/local/IPCChannelPosixTest_BasicListen"; | 187 const char* kChannelName = "/data/local/IPCChannelPosixTest_BasicListen"; |
188 #else | 188 #else |
189 const char* kChannelName = "/var/tmp/IPCChannelPosixTest_BasicListen"; | 189 const char* kChannelName = "/var/tmp/IPCChannelPosixTest_BasicListen"; |
190 #endif | 190 #endif |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 // it. | 408 // it. |
409 bool connected = channel.Connect(); | 409 bool connected = channel.Connect(); |
410 if (connected) { | 410 if (connected) { |
411 IPCChannelPosixTest::SpinRunLoop(TestTimeouts::action_max_timeout_ms()); | 411 IPCChannelPosixTest::SpinRunLoop(TestTimeouts::action_max_timeout_ms()); |
412 EXPECT_EQ(IPCChannelPosixTestListener::CHANNEL_ERROR, listener.status()); | 412 EXPECT_EQ(IPCChannelPosixTestListener::CHANNEL_ERROR, listener.status()); |
413 } else { | 413 } else { |
414 EXPECT_EQ(IPCChannelPosixTestListener::DISCONNECTED, listener.status()); | 414 EXPECT_EQ(IPCChannelPosixTestListener::DISCONNECTED, listener.status()); |
415 } | 415 } |
416 return 0; | 416 return 0; |
417 } | 417 } |
OLD | NEW |