blob: ab375005f48201a90586603a02caf2cb4ee6d225 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ppapi/tests/test_tcp_server_socket_private_disallowed.h"
#include <cstddef>
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/private/net_address_private.h"
#include "ppapi/tests/test_utils.h"
#include "ppapi/tests/testing_instance.h"
REGISTER_TEST_CASE(TCPServerSocketPrivateDisallowed);
TestTCPServerSocketPrivateDisallowed::TestTCPServerSocketPrivateDisallowed(
TestingInstance* instance)
: TestCase(instance),
core_interface_(NULL),
tcp_server_socket_private_interface_(NULL) {
}
bool TestTCPServerSocketPrivateDisallowed::Init() {
core_interface_ = static_cast<const PPB_Core*>(
pp::Module::Get()->GetBrowserInterface(PPB_CORE_INTERFACE));
if (!core_interface_)
instance_->AppendError("PPB_Core interface not available");
tcp_server_socket_private_interface_ =
static_cast<const PPB_TCPServerSocket_Private*>(
pp::Module::Get()->GetBrowserInterface(
PPB_TCPSERVERSOCKET_PRIVATE_INTERFACE));
if (!tcp_server_socket_private_interface_) {
instance_->AppendError(
"PPB_TCPServerSocket_Private interface not available");
}
bool net_address_private_is_available = pp::NetAddressPrivate::IsAvailable();
if (!net_address_private_is_available)
instance_->AppendError("PPB_NetAddress_Private interface not available");
return core_interface_ &&
tcp_server_socket_private_interface_ &&
net_address_private_is_available &&
CheckTestingInterface();
}
void TestTCPServerSocketPrivateDisallowed::RunTests(const std::string& filter) {
RUN_CALLBACK_TEST(TestTCPServerSocketPrivateDisallowed, Listen, filter);
}
std::string TestTCPServerSocketPrivateDisallowed::TestListen() {
PP_Resource socket =
tcp_server_socket_private_interface_->Create(instance_->pp_instance());
ASSERT_TRUE(socket != 0);
ASSERT_TRUE(tcp_server_socket_private_interface_->IsTCPServerSocket(socket));
PP_NetAddress_Private base_address, address;
pp::NetAddressPrivate::GetAnyAddress(false, &base_address);
ASSERT_TRUE(pp::NetAddressPrivate::ReplacePort(
base_address, 0, &address));
TestCompletionCallback callback(instance_->pp_instance());
callback.WaitForResult(tcp_server_socket_private_interface_->Listen(
socket,
&address,
1,
callback.GetCallback().pp_completion_callback()));
CHECK_CALLBACK_BEHAVIOR(callback);
ASSERT_NE(PP_OK, callback.result());
PASS();
}
|