OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ppapi/tests/test_talk_private.h" | 5 #include "ppapi/tests/test_talk_private.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 #include <string.h> | 8 #include <string.h> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "ppapi/c/dev/ppb_testing_dev.h" | 11 #include "ppapi/c/dev/ppb_testing_dev.h" |
12 #include "ppapi/c/pp_errors.h" | 12 #include "ppapi/c/pp_errors.h" |
13 #include "ppapi/c/private/ppb_talk_private.h" | 13 #include "ppapi/c/private/ppb_talk_private.h" |
14 #include "ppapi/cpp/instance.h" | 14 #include "ppapi/cpp/instance.h" |
15 #include "ppapi/cpp/module.h" | 15 #include "ppapi/cpp/module.h" |
16 #include "ppapi/tests/test_utils.h" | 16 #include "ppapi/tests/test_utils.h" |
17 #include "ppapi/tests/testing_instance.h" | 17 #include "ppapi/tests/testing_instance.h" |
18 | 18 |
19 REGISTER_TEST_CASE(TalkPrivate); | 19 REGISTER_TEST_CASE(TalkPrivate); |
20 | 20 |
21 TestTalkPrivate::TestTalkPrivate(TestingInstance* instance) | 21 TestTalkPrivate::TestTalkPrivate(TestingInstance* instance) |
22 : TestCase(instance), | 22 : TestCase(instance), |
23 talk_private_interface_(NULL) { | 23 talk_private_interface_1(NULL) { |
24 } | 24 } |
25 | 25 |
26 bool TestTalkPrivate::Init() { | 26 bool TestTalkPrivate::Init() { |
27 if (!CheckTestingInterface()) { | 27 if (!CheckTestingInterface()) { |
28 instance_->AppendError("Testing interface not available"); | 28 instance_->AppendError("Testing interface not available"); |
29 return false; | 29 return false; |
30 } | 30 } |
31 | 31 |
32 talk_private_interface_ = static_cast<const PPB_Talk_Private*>( | 32 talk_private_interface_1 = static_cast<const PPB_Talk_Private_1_0*>( |
33 pp::Module::Get()->GetBrowserInterface(PPB_TALK_PRIVATE_INTERFACE)); | 33 pp::Module::Get()->GetBrowserInterface(PPB_TALK_PRIVATE_INTERFACE_1_0)); |
34 | 34 |
35 #if defined(__native_client__) | 35 #if defined(__native_client__) |
36 if (talk_private_interface_) | 36 if (talk_private_interface_1) |
37 instance_->AppendError("TalkPrivate interface is supported by NaCl"); | 37 instance_->AppendError("TalkPrivate interface is supported by NaCl"); |
38 #else | 38 #else |
39 if (!talk_private_interface_) | 39 if (!talk_private_interface_1) |
40 instance_->AppendError("TalkPrivate interface not available"); | 40 instance_->AppendError("TalkPrivate interface not available"); |
41 #endif | 41 #endif |
42 return true; | 42 return true; |
43 } | 43 } |
44 | 44 |
45 void TestTalkPrivate::RunTests(const std::string& filter) { | 45 void TestTalkPrivate::RunTests(const std::string& filter) { |
46 RUN_CALLBACK_TEST(TestTalkPrivate, GetPermission, filter); | 46 RUN_CALLBACK_TEST(TestTalkPrivate, GetPermission, filter); |
47 } | 47 } |
48 | 48 |
49 std::string TestTalkPrivate::TestGetPermission() { | 49 std::string TestTalkPrivate::TestGetPermission() { |
50 if (!talk_private_interface_) { | 50 if (!talk_private_interface_1) { |
51 PASS(); | 51 PASS(); |
52 } | 52 } |
53 | 53 |
54 if (!testing_interface_->IsOutOfProcess()) { | 54 if (!testing_interface_->IsOutOfProcess()) { |
55 // We only support out-of-process access to this API, so skip in-process | 55 // We only support out-of-process access to this API, so skip in-process |
56 PASS(); | 56 PASS(); |
57 } | 57 } |
58 | 58 |
59 #if defined(USE_ASH) | 59 #if defined(USE_ASH) |
60 // Under Ash, this will prompt the user so the test cannot run in an automated | 60 // Under Ash, this will prompt the user so the test cannot run in an automated |
61 // fashion. To manually test under Ash, comment this out. | 61 // fashion. To manually test under Ash, comment this out. |
62 PASS(); | 62 PASS(); |
63 #endif | 63 #endif |
64 | 64 |
65 PP_Resource talk_resource = talk_private_interface_->Create( | 65 PP_Resource talk_resource = talk_private_interface_1->Create( |
66 instance_->pp_instance()); | 66 instance_->pp_instance()); |
67 | 67 |
68 TestCompletionCallback callback(instance_->pp_instance(), callback_type()); | 68 TestCompletionCallback callback(instance_->pp_instance(), callback_type()); |
69 callback.WaitForResult(talk_private_interface_->GetPermission(talk_resource, | 69 callback.WaitForResult(talk_private_interface_1->GetPermission(talk_resource, |
70 callback.GetCallback().pp_completion_callback())); | 70 callback.GetCallback().pp_completion_callback())); |
71 CHECK_CALLBACK_BEHAVIOR(callback); | 71 CHECK_CALLBACK_BEHAVIOR(callback); |
72 | 72 |
73 #if defined(USE_ASH) | 73 #if defined(USE_ASH) |
74 // Under Ash, this test will actually prompt the user and return either true | 74 // Under Ash, this test will actually prompt the user and return either true |
75 // or false depending on their choice. | 75 // or false depending on their choice. |
76 if (callback.result() != 0 && callback.result() != 1) | 76 if (callback.result() != 0 && callback.result() != 1) |
77 return "Unexpected result"; | 77 return "Unexpected result"; |
78 #else | 78 #else |
79 // Currently not implemented without Ash, bur always returns false. | 79 // Currently not implemented without Ash, bur always returns false. |
80 if (callback.result() != 0) | 80 if (callback.result() != 0) |
81 return "Unexpected non-zero result"; | 81 return "Unexpected non-zero result"; |
82 #endif | 82 #endif |
83 | 83 |
84 PASS(); | 84 PASS(); |
85 } | 85 } |
OLD | NEW |