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
3 // found in the LICENSE file.
5 #include "ppapi/tests/test_udp_socket_private_disallowed.h"
7 #include "ppapi/cpp/module.h"
8 #include "ppapi/cpp/private/net_address_private.h"
9 #include "ppapi/tests/testing_instance.h"
10 #include "ppapi/tests/test_utils.h"
12 REGISTER_TEST_CASE(UDPSocketPrivateDisallowed
);
14 TestUDPSocketPrivateDisallowed::TestUDPSocketPrivateDisallowed(
15 TestingInstance
* instance
)
16 : TestCase(instance
), udp_socket_private_interface_(NULL
) {
19 bool TestUDPSocketPrivateDisallowed::Init() {
20 udp_socket_private_interface_
= static_cast<const PPB_UDPSocket_Private
*>(
21 pp::Module::Get()->GetBrowserInterface(PPB_UDPSOCKET_PRIVATE_INTERFACE
));
22 if (!udp_socket_private_interface_
)
23 instance_
->AppendError("UDPSocketPrivate interface not available");
24 return udp_socket_private_interface_
&& CheckTestingInterface();
27 void TestUDPSocketPrivateDisallowed::RunTests(const std::string
& filter
) {
28 RUN_TEST(Bind
, filter
);
31 std::string
TestUDPSocketPrivateDisallowed::TestBind() {
33 udp_socket_private_interface_
->Create(instance_
->pp_instance());
35 PP_NetAddress_Private addr
;
36 pp::NetAddressPrivate::GetAnyAddress(false, &addr
);
38 TestCompletionCallback
callback(instance_
->pp_instance());
39 callback
.WaitForResult(udp_socket_private_interface_
->Bind(socket
, &addr
,
40 callback
.GetCallback().pp_completion_callback()));
41 CHECK_CALLBACK_BEHAVIOR(callback
);
42 ASSERT_EQ(PP_ERROR_FAILED
, callback
.result());