Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(243)

Side by Side Diff: ipc/sync_socket_unittest.cc

Issue 11819041: Make ipc_tests file structure a little saner and add an ipc_perftests target. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ugh Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ipc/ipc_tests.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "base/sync_socket.h" 5 #include "base/sync_socket.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 #include <string> 8 #include <string>
9 #include <sstream> 9 #include <sstream>
10 10
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/message_loop.h" 12 #include "base/message_loop.h"
13 #include "base/process_util.h" 13 #include "base/process_util.h"
14 #include "base/threading/thread.h" 14 #include "base/threading/thread.h"
15 #include "ipc/ipc_channel_proxy.h" 15 #include "ipc/ipc_channel_proxy.h"
16 #include "ipc/ipc_multiprocess_test.h" 16 #include "ipc/ipc_multiprocess_test.h"
17 #include "ipc/ipc_tests.h" 17 #include "ipc/ipc_test_base.h"
18 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
19 #include "testing/multiprocess_func_list.h" 19 #include "testing/multiprocess_func_list.h"
20 20
21 #if defined(OS_POSIX) 21 #if defined(OS_POSIX)
22 #include "base/file_descriptor_posix.h" 22 #include "base/file_descriptor_posix.h"
23 #endif 23 #endif
24 24
25 // IPC messages for testing --------------------------------------------------- 25 // IPC messages for testing ---------------------------------------------------
26 26
27 #define IPC_MESSAGE_IMPL 27 #define IPC_MESSAGE_IMPL
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 EXPECT_TRUE(chan_->Send(msg)); 157 EXPECT_TRUE(chan_->Send(msg));
158 MessageLoop::current()->Quit(); 158 MessageLoop::current()->Quit();
159 } 159 }
160 160
161 base::SyncSocket* socket_; 161 base::SyncSocket* socket_;
162 IPC::Channel* chan_; 162 IPC::Channel* chan_;
163 163
164 DISALLOW_COPY_AND_ASSIGN(SyncSocketClientListener); 164 DISALLOW_COPY_AND_ASSIGN(SyncSocketClientListener);
165 }; 165 };
166 166
167 class SyncSocketTest : public IPCChannelTest { 167 class SyncSocketTest : public IPCTestBase {
168 }; 168 };
169 169
170 TEST_F(SyncSocketTest, SanityTest) { 170 TEST_F(SyncSocketTest, SanityTest) {
171 SyncSocketClientListener listener; 171 SyncSocketClientListener listener;
172 IPC::Channel chan(kSyncSocketChannel, IPC::Channel::MODE_SERVER, 172 IPC::Channel chan(kSyncSocketChannel, IPC::Channel::MODE_SERVER,
173 &listener); 173 &listener);
174 base::ProcessHandle server_process = SpawnChild(SYNC_SOCKET_SERVER, &chan); 174 base::ProcessHandle server_process = SpawnChild(SYNC_SOCKET_SERVER, &chan);
175 ASSERT_TRUE(server_process); 175 ASSERT_TRUE(server_process);
176 // Create a pair of SyncSockets. 176 // Create a pair of SyncSockets.
177 base::SyncSocket pair[2]; 177 base::SyncSocket pair[2];
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 EXPECT_EQ(0U, pair[0].Send(kHelloString, kHelloStringLength)); 301 EXPECT_EQ(0U, pair[0].Send(kHelloString, kHelloStringLength));
302 EXPECT_EQ(bytes_in_buffer, pair[1].Peek()); 302 EXPECT_EQ(bytes_in_buffer, pair[1].Peek());
303 303
304 // Read from another socket to free some space for a new write. 304 // Read from another socket to free some space for a new write.
305 char hello[kHelloStringLength] = {0}; 305 char hello[kHelloStringLength] = {0};
306 pair[1].Receive(&hello[0], sizeof(hello)); 306 pair[1].Receive(&hello[0], sizeof(hello));
307 307
308 // Should be able to write more data to the buffer now. 308 // Should be able to write more data to the buffer now.
309 EXPECT_EQ(kHelloStringLength, pair[0].Send(kHelloString, kHelloStringLength)); 309 EXPECT_EQ(kHelloStringLength, pair[0].Send(kHelloString, kHelloStringLength));
310 } 310 }
OLDNEW
« no previous file with comments | « ipc/ipc_tests.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698