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_net_address_private_untrusted.h" | 5 #include "ppapi/tests/test_net_address_private_untrusted.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <sstream> | 8 #include <sstream> |
9 | 9 |
10 #include "ppapi/c/pp_errors.h" | 10 #include "ppapi/c/pp_errors.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 RUN_TEST(GetFamily, filter); | 50 RUN_TEST(GetFamily, filter); |
51 RUN_TEST(GetPort, filter); | 51 RUN_TEST(GetPort, filter); |
52 RUN_TEST(GetAddress, filter); | 52 RUN_TEST(GetAddress, filter); |
53 } | 53 } |
54 | 54 |
55 int32_t TestNetAddressPrivateUntrusted::Connect(TCPSocketPrivate* socket, | 55 int32_t TestNetAddressPrivateUntrusted::Connect(TCPSocketPrivate* socket, |
56 const std::string& host, | 56 const std::string& host, |
57 uint16_t port) { | 57 uint16_t port) { |
58 TestCompletionCallback callback(instance_->pp_instance(), false); | 58 TestCompletionCallback callback(instance_->pp_instance(), false); |
59 | 59 |
60 int32_t rv = socket->Connect(host.c_str(), port, callback.GetCallback()); | 60 callback.WaitForResult( |
61 if (rv == PP_OK_COMPLETIONPENDING) | 61 socket->Connect(host.c_str(), port, callback.GetCallback())); |
62 rv = callback.WaitForResult(); | 62 return callback.result(); |
63 return rv; | |
64 } | 63 } |
65 | 64 |
66 std::string TestNetAddressPrivateUntrusted::TestAreEqual() { | 65 std::string TestNetAddressPrivateUntrusted::TestAreEqual() { |
67 pp::TCPSocketPrivate socket(instance_); | 66 pp::TCPSocketPrivate socket(instance_); |
68 int32_t rv = Connect(&socket, host_, port_); | 67 int32_t rv = Connect(&socket, host_, port_); |
69 if (rv != PP_OK) | 68 if (rv != PP_OK) |
70 return ReportError("pp::TCPSocketPrivate::Connect", rv); | 69 return ReportError("pp::TCPSocketPrivate::Connect", rv); |
71 | 70 |
72 PP_NetAddress_Private local_address, remote_address; | 71 PP_NetAddress_Private local_address, remote_address; |
73 ASSERT_TRUE(socket.GetLocalAddress(&local_address)); | 72 ASSERT_TRUE(socket.GetLocalAddress(&local_address)); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 ASSERT_TRUE(socket.GetRemoteAddress(&remote_address)); | 195 ASSERT_TRUE(socket.GetRemoteAddress(&remote_address)); |
197 | 196 |
198 static const uint16_t buffer_size = sizeof(remote_address.data); | 197 static const uint16_t buffer_size = sizeof(remote_address.data); |
199 char buffer[buffer_size]; | 198 char buffer[buffer_size]; |
200 ASSERT_TRUE(NetAddressPrivate::GetAddress(remote_address, buffer, | 199 ASSERT_TRUE(NetAddressPrivate::GetAddress(remote_address, buffer, |
201 buffer_size)); | 200 buffer_size)); |
202 | 201 |
203 socket.Disconnect(); | 202 socket.Disconnect(); |
204 PASS(); | 203 PASS(); |
205 } | 204 } |
OLD | NEW |