Extend the enterprise policy for SSL overrides to the "danger" command
[chromium-blink-merge.git] / ppapi / tests / test_tcp_server_socket_private_disallowed.cc
blobab375005f48201a90586603a02caf2cb4ee6d225
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_tcp_server_socket_private_disallowed.h"
7 #include <cstddef>
9 #include "ppapi/cpp/module.h"
10 #include "ppapi/cpp/private/net_address_private.h"
11 #include "ppapi/tests/test_utils.h"
12 #include "ppapi/tests/testing_instance.h"
14 REGISTER_TEST_CASE(TCPServerSocketPrivateDisallowed);
16 TestTCPServerSocketPrivateDisallowed::TestTCPServerSocketPrivateDisallowed(
17 TestingInstance* instance)
18 : TestCase(instance),
19 core_interface_(NULL),
20 tcp_server_socket_private_interface_(NULL) {
23 bool TestTCPServerSocketPrivateDisallowed::Init() {
24 core_interface_ = static_cast<const PPB_Core*>(
25 pp::Module::Get()->GetBrowserInterface(PPB_CORE_INTERFACE));
26 if (!core_interface_)
27 instance_->AppendError("PPB_Core interface not available");
29 tcp_server_socket_private_interface_ =
30 static_cast<const PPB_TCPServerSocket_Private*>(
31 pp::Module::Get()->GetBrowserInterface(
32 PPB_TCPSERVERSOCKET_PRIVATE_INTERFACE));
33 if (!tcp_server_socket_private_interface_) {
34 instance_->AppendError(
35 "PPB_TCPServerSocket_Private interface not available");
38 bool net_address_private_is_available = pp::NetAddressPrivate::IsAvailable();
39 if (!net_address_private_is_available)
40 instance_->AppendError("PPB_NetAddress_Private interface not available");
42 return core_interface_ &&
43 tcp_server_socket_private_interface_ &&
44 net_address_private_is_available &&
45 CheckTestingInterface();
48 void TestTCPServerSocketPrivateDisallowed::RunTests(const std::string& filter) {
49 RUN_CALLBACK_TEST(TestTCPServerSocketPrivateDisallowed, Listen, filter);
52 std::string TestTCPServerSocketPrivateDisallowed::TestListen() {
53 PP_Resource socket =
54 tcp_server_socket_private_interface_->Create(instance_->pp_instance());
55 ASSERT_TRUE(socket != 0);
56 ASSERT_TRUE(tcp_server_socket_private_interface_->IsTCPServerSocket(socket));
58 PP_NetAddress_Private base_address, address;
59 pp::NetAddressPrivate::GetAnyAddress(false, &base_address);
60 ASSERT_TRUE(pp::NetAddressPrivate::ReplacePort(
61 base_address, 0, &address));
62 TestCompletionCallback callback(instance_->pp_instance());
63 callback.WaitForResult(tcp_server_socket_private_interface_->Listen(
64 socket,
65 &address,
67 callback.GetCallback().pp_completion_callback()));
68 CHECK_CALLBACK_BEHAVIOR(callback);
69 ASSERT_NE(PP_OK, callback.result());
70 PASS();