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, MessageLoop::QuitClosure(), milliseconds); | 180 loop->PostDelayedTask( |
| 181 FROM_HERE, |
| 182 MessageLoop::QuitClosure(), |
| 183 base::TimeDelta::FromMilliseconds(milliseconds)); |
181 loop->Run(); | 184 loop->Run(); |
182 } | 185 } |
183 | 186 |
184 TEST_F(IPCChannelPosixTest, BasicListen) { | 187 TEST_F(IPCChannelPosixTest, BasicListen) { |
185 | 188 |
186 #if defined(OS_ANDROID) | 189 #if defined(OS_ANDROID) |
187 const char* kChannelName = "/data/local/IPCChannelPosixTest_BasicListen"; | 190 const char* kChannelName = "/data/local/IPCChannelPosixTest_BasicListen"; |
188 #else | 191 #else |
189 const char* kChannelName = "/var/tmp/IPCChannelPosixTest_BasicListen"; | 192 const char* kChannelName = "/var/tmp/IPCChannelPosixTest_BasicListen"; |
190 #endif | 193 #endif |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 // it. | 411 // it. |
409 bool connected = channel.Connect(); | 412 bool connected = channel.Connect(); |
410 if (connected) { | 413 if (connected) { |
411 IPCChannelPosixTest::SpinRunLoop(TestTimeouts::action_max_timeout_ms()); | 414 IPCChannelPosixTest::SpinRunLoop(TestTimeouts::action_max_timeout_ms()); |
412 EXPECT_EQ(IPCChannelPosixTestListener::CHANNEL_ERROR, listener.status()); | 415 EXPECT_EQ(IPCChannelPosixTestListener::CHANNEL_ERROR, listener.status()); |
413 } else { | 416 } else { |
414 EXPECT_EQ(IPCChannelPosixTestListener::DISCONNECTED, listener.status()); | 417 EXPECT_EQ(IPCChannelPosixTestListener::DISCONNECTED, listener.status()); |
415 } | 418 } |
416 return 0; | 419 return 0; |
417 } | 420 } |
OLD | NEW |