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

Side by Side Diff: ppapi/tests/test_net_address_private_untrusted.cc

Issue 9307115: PPB_NetAddress_Private: add getter methods for sockaddr. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 8 years, 10 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 | « ppapi/tests/test_net_address_private_untrusted.h ('k') | ppapi/thunk/interfaces_ppb_private.h » ('j') | 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 "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 29 matching lines...) Expand all
40 init_host_port && 40 init_host_port &&
41 CheckTestingInterface(); 41 CheckTestingInterface();
42 } 42 }
43 43
44 void TestNetAddressPrivateUntrusted::RunTests(const std::string& filter) { 44 void TestNetAddressPrivateUntrusted::RunTests(const std::string& filter) {
45 RUN_TEST(AreEqual, filter); 45 RUN_TEST(AreEqual, filter);
46 RUN_TEST(AreHostsEqual, filter); 46 RUN_TEST(AreHostsEqual, filter);
47 RUN_TEST(Describe, filter); 47 RUN_TEST(Describe, filter);
48 RUN_TEST(ReplacePort, filter); 48 RUN_TEST(ReplacePort, filter);
49 RUN_TEST(GetAnyAddress, filter); 49 RUN_TEST(GetAnyAddress, filter);
50 RUN_TEST(GetFamily, filter);
51 RUN_TEST(GetPort, filter);
52 RUN_TEST(GetAddress, filter);
50 } 53 }
51 54
52 int32_t TestNetAddressPrivateUntrusted::Connect(TCPSocketPrivate* socket, 55 int32_t TestNetAddressPrivateUntrusted::Connect(TCPSocketPrivate* socket,
53 const std::string& host, 56 const std::string& host,
54 uint16_t port) { 57 uint16_t port) {
55 TestCompletionCallback callback(instance_->pp_instance(), false); 58 TestCompletionCallback callback(instance_->pp_instance(), false);
56 59
57 int32_t rv = socket->Connect(host.c_str(), port, callback); 60 int32_t rv = socket->Connect(host.c_str(), port, callback);
58 if (rv == PP_OK_COMPLETIONPENDING) 61 if (rv == PP_OK_COMPLETIONPENDING)
59 rv = callback.WaitForResult(); 62 rv = callback.WaitForResult();
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 PP_NetAddress_Private address; 147 PP_NetAddress_Private address;
145 148
146 NetAddressPrivate::GetAnyAddress(false, &address); 149 NetAddressPrivate::GetAnyAddress(false, &address);
147 ASSERT_TRUE(NetAddressPrivate::AreEqual(address, address)); 150 ASSERT_TRUE(NetAddressPrivate::AreEqual(address, address));
148 151
149 NetAddressPrivate::GetAnyAddress(true, &address); 152 NetAddressPrivate::GetAnyAddress(true, &address);
150 ASSERT_TRUE(NetAddressPrivate::AreEqual(address, address)); 153 ASSERT_TRUE(NetAddressPrivate::AreEqual(address, address));
151 154
152 PASS(); 155 PASS();
153 } 156 }
157
158 std::string TestNetAddressPrivateUntrusted::TestGetFamily() {
159 pp::TCPSocketPrivate socket(instance_);
160 int32_t rv = Connect(&socket, host_, port_);
161 if (rv != PP_OK)
162 return ReportError("pp::TCPSocketPrivate::Connect", rv);
163
164 PP_NetAddress_Private remote_address;
165 ASSERT_TRUE(socket.GetRemoteAddress(&remote_address));
166
167 ASSERT_EQ(NetAddressPrivate::GetFamily(remote_address),
168 NetAddressPrivate::GetFamily(remote_address));
169
170 socket.Disconnect();
171 PASS();
172 }
173
174 std::string TestNetAddressPrivateUntrusted::TestGetPort() {
175 pp::TCPSocketPrivate socket(instance_);
176 int32_t rv = Connect(&socket, host_, port_);
177 if (rv != PP_OK)
178 return ReportError("pp::TCPSocketPrivate::Connect", rv);
179
180 PP_NetAddress_Private remote_address;
181 ASSERT_TRUE(socket.GetRemoteAddress(&remote_address));
182
183 ASSERT_EQ(NetAddressPrivate::GetPort(remote_address), port_);
184
185 socket.Disconnect();
186 PASS();
187 }
188
189 std::string TestNetAddressPrivateUntrusted::TestGetAddress() {
190 pp::TCPSocketPrivate socket(instance_);
191 int32_t rv = Connect(&socket, host_, port_);
192 if (rv != PP_OK)
193 return ReportError("pp::TCPSocketPrivate::Connect", rv);
194
195 PP_NetAddress_Private remote_address;
196 ASSERT_TRUE(socket.GetRemoteAddress(&remote_address));
197
198 static const uint16_t buffer_size = sizeof(remote_address.data);
199 char buffer[buffer_size];
200 ASSERT_TRUE(NetAddressPrivate::GetAddress(remote_address, buffer,
201 buffer_size));
202
203 socket.Disconnect();
204 PASS();
205 }
OLDNEW
« no previous file with comments | « ppapi/tests/test_net_address_private_untrusted.h ('k') | ppapi/thunk/interfaces_ppb_private.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698