[email protected] | e461da2f | 2012-02-16 19:06:40 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 24050234 | 2011-12-22 20:07:49 | [diff] [blame] | 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" | ||||
[email protected] | e461da2f | 2012-02-16 19:06:40 | [diff] [blame] | 8 | #include "ppapi/cpp/private/net_address_private.h" |
[email protected] | 24050234 | 2011-12-22 20:07:49 | [diff] [blame] | 9 | #include "ppapi/tests/testing_instance.h" |
[email protected] | e461da2f | 2012-02-16 19:06:40 | [diff] [blame] | 10 | #include "ppapi/tests/test_utils.h" |
[email protected] | 24050234 | 2011-12-22 20:07:49 | [diff] [blame] | 11 | |
12 | REGISTER_TEST_CASE(UDPSocketPrivateDisallowed); | ||||
13 | |||||
14 | TestUDPSocketPrivateDisallowed::TestUDPSocketPrivateDisallowed( | ||||
15 | TestingInstance* instance) | ||||
16 | : TestCase(instance), udp_socket_private_interface_(NULL) { | ||||
17 | } | ||||
18 | |||||
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 | |||||
27 | void TestUDPSocketPrivateDisallowed::RunTests(const std::string& filter) { | ||||
[email protected] | e461da2f | 2012-02-16 19:06:40 | [diff] [blame] | 28 | RUN_TEST(Bind, filter); |
[email protected] | 24050234 | 2011-12-22 20:07:49 | [diff] [blame] | 29 | } |
30 | |||||
[email protected] | e461da2f | 2012-02-16 19:06:40 | [diff] [blame] | 31 | std::string TestUDPSocketPrivateDisallowed::TestBind() { |
[email protected] | 24050234 | 2011-12-22 20:07:49 | [diff] [blame] | 32 | PP_Resource socket = |
33 | udp_socket_private_interface_->Create(instance_->pp_instance()); | ||||
34 | if (0 != socket) { | ||||
[email protected] | e461da2f | 2012-02-16 19:06:40 | [diff] [blame] | 35 | PP_NetAddress_Private addr; |
36 | pp::NetAddressPrivate::GetAnyAddress(false, &addr); | ||||
37 | |||||
38 | TestCompletionCallback callback(instance_->pp_instance()); | ||||
[email protected] | d1674cc4 | 2013-04-16 15:06:26 | [diff] [blame] | 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()); | ||||
[email protected] | 24050234 | 2011-12-22 20:07:49 | [diff] [blame] | 43 | } |
44 | PASS(); | ||||
45 | } |