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_host_resolver_private_disallowed.h"
7 #include "ppapi/cpp/module.h"
8 #include "ppapi/cpp/private/net_address_private.h"
9 #include "ppapi/tests/test_utils.h"
10 #include "ppapi/tests/testing_instance.h"
12 REGISTER_TEST_CASE(HostResolverPrivateDisallowed
);
14 TestHostResolverPrivateDisallowed::TestHostResolverPrivateDisallowed(
15 TestingInstance
* instance
)
16 : TestCase(instance
) {
19 bool TestHostResolverPrivateDisallowed::Init() {
20 bool host_resolver_private_is_available
=
21 pp::HostResolverPrivate::IsAvailable();
22 if (!host_resolver_private_is_available
)
23 instance_
->AppendError("PPB_HostResolver_Private interface not available");
26 GetLocalHostPort(instance_
->pp_instance(), &host_
, &port_
);
28 instance_
->AppendError("Can't init host and port");
30 return host_resolver_private_is_available
&&
32 EnsureRunningOverHTTP();
35 void TestHostResolverPrivateDisallowed::RunTests(const std::string
& filter
) {
36 RUN_CALLBACK_TEST(TestHostResolverPrivateDisallowed
, Resolve
, filter
);
39 std::string
TestHostResolverPrivateDisallowed::TestResolve() {
40 pp::HostResolverPrivate
host_resolver(instance_
);
41 PP_HostResolver_Private_Hint hint
;
42 hint
.family
= PP_NETADDRESSFAMILY_PRIVATE_UNSPECIFIED
;
43 hint
.flags
= PP_HOST_RESOLVER_PRIVATE_FLAGS_CANONNAME
;
44 TestCompletionCallback
callback(instance_
->pp_instance(), callback_type());
45 callback
.WaitForResult(
46 host_resolver
.Resolve(host_
, port_
, hint
, callback
.GetCallback()));
47 CHECK_CALLBACK_BEHAVIOR(callback
);
48 ASSERT_EQ(PP_ERROR_FAILED
, callback
.result());