• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #include "ppapi/tests/test_udp_socket_private_disallowed.h"
6 
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"
11 
12 REGISTER_TEST_CASE(UDPSocketPrivateDisallowed);
13 
TestUDPSocketPrivateDisallowed(TestingInstance * instance)14 TestUDPSocketPrivateDisallowed::TestUDPSocketPrivateDisallowed(
15     TestingInstance* instance)
16     : TestCase(instance), udp_socket_private_interface_(NULL) {
17 }
18 
Init()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();
25 }
26 
RunTests(const std::string & filter)27 void TestUDPSocketPrivateDisallowed::RunTests(const std::string& filter) {
28   RUN_TEST(Bind, filter);
29 }
30 
TestBind()31 std::string TestUDPSocketPrivateDisallowed::TestBind() {
32   PP_Resource socket =
33       udp_socket_private_interface_->Create(instance_->pp_instance());
34   if (0 != socket) {
35     PP_NetAddress_Private addr;
36     pp::NetAddressPrivate::GetAnyAddress(false, &addr);
37 
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());
43   }
44   PASS();
45 }
46