OLD | NEW |
(Empty) | |
| 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_host_resolver_private_disallowed.h" |
| 6 |
| 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" |
| 11 |
| 12 REGISTER_TEST_CASE(HostResolverPrivateDisallowed); |
| 13 |
| 14 TestHostResolverPrivateDisallowed::TestHostResolverPrivateDisallowed( |
| 15 TestingInstance* instance) |
| 16 : TestCase(instance) { |
| 17 } |
| 18 |
| 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"); |
| 24 |
| 25 bool init_host_port = |
| 26 GetLocalHostPort(instance_->pp_instance(), &host_, &port_); |
| 27 if (!init_host_port) |
| 28 instance_->AppendError("Can't init host and port"); |
| 29 |
| 30 return host_resolver_private_is_available && |
| 31 init_host_port && |
| 32 EnsureRunningOverHTTP(); |
| 33 } |
| 34 |
| 35 void TestHostResolverPrivateDisallowed::RunTests(const std::string& filter) { |
| 36 RUN_TEST_FORCEASYNC_AND_NOT(Resolve, filter); |
| 37 } |
| 38 |
| 39 std::string TestHostResolverPrivateDisallowed::TestResolve() { |
| 40 pp::HostResolverPrivate host_resolver(instance_); |
| 41 PP_HostResolver_Private_Hint hint; |
| 42 hint.family = PP_NETADDRESSFAMILY_UNSPECIFIED; |
| 43 hint.flags = PP_HOST_RESOLVER_FLAGS_CANONNAME; |
| 44 TestCompletionCallback callback(instance_->pp_instance(), force_async_); |
| 45 int32_t rv = host_resolver.Resolve(host_, port_, hint, callback); |
| 46 if (force_async_ && rv != PP_OK_COMPLETIONPENDING) |
| 47 return ReportError("PPB_HostResolver_Private::Resolve force_async", rv); |
| 48 if (rv == PP_OK_COMPLETIONPENDING) |
| 49 rv = callback.WaitForResult(); |
| 50 if (rv != PP_ERROR_FAILED) |
| 51 return "PPB_HostResolver_Private can resolve without allowing switch"; |
| 52 PASS(); |
| 53 } |
OLD | NEW |