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 CheckTestingInterface() && | |
yzshen1
2013/01/24 18:45:03
It seems we don't need the testing interface?
ygorshenin1
2013/02/05 12:45:31
Done.
| |
33 EnsureRunningOverHTTP(); | |
34 } | |
35 | |
36 void TestHostResolverPrivateDisallowed::RunTests(const std::string& filter) { | |
37 RUN_TEST_FORCEASYNC_AND_NOT(Resolve, filter); | |
38 } | |
39 | |
40 std::string TestHostResolverPrivateDisallowed::TestResolve() { | |
41 pp::HostResolverPrivate host_resolver(instance_); | |
42 PP_HostResolver_Private_Hint hint; | |
43 hint.family = PP_NETADDRESSFAMILY_UNSPECIFIED; | |
44 hint.flags = PP_HOST_RESOLVER_FLAGS_CANONNAME; | |
45 TestCompletionCallback callback(instance_->pp_instance(), force_async_); | |
46 int32_t rv = host_resolver.Resolve(host_, port_, hint, callback); | |
47 if (force_async_ && rv != PP_OK_COMPLETIONPENDING) | |
48 return ReportError("PPB_HostResolver_Private::Resolve force_async", rv); | |
49 if (rv == PP_OK_COMPLETIONPENDING) | |
50 rv = callback.WaitForResult(); | |
51 if (rv != PP_ERROR_FAILED) | |
52 return "PPB_HostResolver_Private can resolve without allowing switch"; | |
53 PASS(); | |
54 } | |
OLD | NEW |