| 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 #include "ppapi/tests/test_tcp_server_socket_private.h" | 5 #include "ppapi/tests/test_tcp_server_socket_private.h" |
| 6 | 6 |
| 7 #include <cstdio> | 7 #include <cstdio> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "ppapi/cpp/pass_ref.h" | 10 #include "ppapi/cpp/pass_ref.h" |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 current_thread_loop.AttachToCurrentThread(); | 163 current_thread_loop.AttachToCurrentThread(); |
| 164 } | 164 } |
| 165 | 165 |
| 166 PP_Resource resource; | 166 PP_Resource resource; |
| 167 int32_t accept_rv = server_socket.Accept(&resource, | 167 int32_t accept_rv = server_socket.Accept(&resource, |
| 168 accept_callback.GetCallback()); | 168 accept_callback.GetCallback()); |
| 169 | 169 |
| 170 TCPSocketPrivate client_socket(instance_); | 170 TCPSocketPrivate client_socket(instance_); |
| 171 ForceConnect(&client_socket, &address); | 171 ForceConnect(&client_socket, &address); |
| 172 | 172 |
| 173 PP_NetAddress_Private client_local_addr, client_remote_addr; |
| 174 ASSERT_TRUE(client_socket.GetLocalAddress(&client_local_addr)); |
| 175 ASSERT_TRUE(client_socket.GetRemoteAddress(&client_remote_addr)); |
| 176 |
| 173 accept_callback.WaitForResult(accept_rv); | 177 accept_callback.WaitForResult(accept_rv); |
| 174 CHECK_CALLBACK_BEHAVIOR(accept_callback); | 178 CHECK_CALLBACK_BEHAVIOR(accept_callback); |
| 175 ASSERT_EQ(PP_OK, accept_callback.result()); | 179 ASSERT_EQ(PP_OK, accept_callback.result()); |
| 176 | 180 |
| 177 ASSERT_TRUE(resource != 0); | 181 ASSERT_TRUE(resource != 0); |
| 178 TCPSocketPrivate accepted_socket(pp::PassRef(), resource); | 182 TCPSocketPrivate accepted_socket(pp::PassRef(), resource); |
| 183 PP_NetAddress_Private accepted_local_addr, accepted_remote_addr; |
| 184 ASSERT_TRUE(accepted_socket.GetLocalAddress(&accepted_local_addr)); |
| 185 ASSERT_TRUE(accepted_socket.GetRemoteAddress(&accepted_remote_addr)); |
| 186 ASSERT_TRUE(NetAddressPrivate::AreEqual(client_local_addr, |
| 187 accepted_remote_addr)); |
| 179 | 188 |
| 180 const char kSentByte = 'a'; | 189 const char kSentByte = 'a'; |
| 181 ASSERT_SUBTEST_SUCCESS(SyncWrite(&client_socket, | 190 ASSERT_SUBTEST_SUCCESS(SyncWrite(&client_socket, |
| 182 &kSentByte, | 191 &kSentByte, |
| 183 sizeof(kSentByte))); | 192 sizeof(kSentByte))); |
| 184 | 193 |
| 185 char received_byte; | 194 char received_byte; |
| 186 ASSERT_SUBTEST_SUCCESS(SyncRead(&accepted_socket, | 195 ASSERT_SUBTEST_SUCCESS(SyncRead(&accepted_socket, |
| 187 &received_byte, | 196 &received_byte, |
| 188 sizeof(received_byte))); | 197 sizeof(received_byte))); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 client_sockets[i]->Disconnect(); | 260 client_sockets[i]->Disconnect(); |
| 252 delete client_sockets[i]; | 261 delete client_sockets[i]; |
| 253 delete connect_callbacks[i]; | 262 delete connect_callbacks[i]; |
| 254 accepted_sockets[i]->Disconnect(); | 263 accepted_sockets[i]->Disconnect(); |
| 255 delete accepted_sockets[i]; | 264 delete accepted_sockets[i]; |
| 256 } | 265 } |
| 257 | 266 |
| 258 server_socket.StopListening(); | 267 server_socket.StopListening(); |
| 259 PASS(); | 268 PASS(); |
| 260 } | 269 } |
| OLD | NEW |