OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
6 #include "ipc/ipc_message_utils.h" | 6 #include "ipc/ipc_message_utils.h" |
7 #include "ppapi/c/ppb_audio.h" | 7 #include "ppapi/c/ppb_audio.h" |
8 #include "ppapi/c/ppp_instance.h" | 8 #include "ppapi/c/ppp_instance.h" |
9 #include "ppapi/proxy/ppapi_messages.h" | 9 #include "ppapi/proxy/ppapi_messages.h" |
10 #include "ppapi/proxy/ppapi_proxy_test.h" | 10 #include "ppapi/proxy/ppapi_proxy_test.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 } | 37 } |
38 | 38 |
39 PPB_Audio dummy_audio_interface = { | 39 PPB_Audio dummy_audio_interface = { |
40 &Create, | 40 &Create, |
41 &IsAudio, | 41 &IsAudio, |
42 &GetCurrentConfig, | 42 &GetCurrentConfig, |
43 &StartPlayback, | 43 &StartPlayback, |
44 &StopPlayback | 44 &StopPlayback |
45 }; | 45 }; |
46 | 46 |
| 47 PPP_Instance dummy_ppp_instance_interface = {}; |
| 48 |
47 } // namespace | 49 } // namespace |
48 | 50 |
49 class PluginDispatcherTest : public PluginProxyTest { | 51 class PluginDispatcherTest : public PluginProxyTest { |
50 public: | 52 public: |
51 PluginDispatcherTest() {} | 53 PluginDispatcherTest() {} |
52 | 54 |
53 bool HasTargetProxy(InterfaceID id) { | 55 bool HasTargetProxy(InterfaceID id) { |
54 return !!plugin_dispatcher()->target_proxies_[id].get(); | 56 return !!plugin_dispatcher()->target_proxies_[id].get(); |
55 } | 57 } |
56 }; | 58 }; |
57 | 59 |
58 TEST_F(PluginDispatcherTest, SupportsInterface) { | 60 TEST_F(PluginDispatcherTest, SupportsInterface) { |
59 RegisterTestInterface(PPB_AUDIO_INTERFACE, &dummy_audio_interface); | 61 RegisterTestInterface(PPB_AUDIO_INTERFACE, &dummy_audio_interface); |
60 RegisterTestInterface(PPP_INSTANCE_INTERFACE, | 62 RegisterTestInterface(PPP_INSTANCE_INTERFACE, &dummy_ppp_instance_interface); |
61 reinterpret_cast<void*>(0xdeadbeef)); | |
62 | 63 |
63 // Sending a request for a random interface should fail. | 64 // Sending a request for a random interface should fail. |
64 EXPECT_FALSE(SupportsInterface("Random interface")); | 65 EXPECT_FALSE(SupportsInterface("Random interface")); |
65 | 66 |
66 // Sending a request for a PPB interface should fail even though we've | 67 // Sending a request for a PPB interface should fail even though we've |
67 // registered it as existing in the GetInterface function (the plugin proxy | 68 // registered it as existing in the GetInterface function (the plugin proxy |
68 // should only respond to PPP interfaces when asked if it supports them). | 69 // should only respond to PPP interfaces when asked if it supports them). |
69 EXPECT_FALSE(SupportsInterface(PPB_AUDIO_INTERFACE)); | 70 EXPECT_FALSE(SupportsInterface(PPB_AUDIO_INTERFACE)); |
70 | 71 |
71 // Sending a request for a supported PPP interface should succeed. | 72 // Sending a request for a supported PPP interface should succeed. |
72 EXPECT_TRUE(SupportsInterface(PPP_INSTANCE_INTERFACE)); | 73 EXPECT_TRUE(SupportsInterface(PPP_INSTANCE_INTERFACE)); |
73 } | 74 } |
74 | 75 |
75 TEST_F(PluginDispatcherTest, PPBCreation) { | 76 TEST_F(PluginDispatcherTest, PPBCreation) { |
76 // Sending a PPB message out of the blue should create a target proxy for | 77 // Sending a PPB message out of the blue should create a target proxy for |
77 // that interface in the plugin. | 78 // that interface in the plugin. |
78 EXPECT_FALSE(HasTargetProxy(INTERFACE_ID_PPB_AUDIO)); | 79 EXPECT_FALSE(HasTargetProxy(INTERFACE_ID_PPB_AUDIO)); |
79 PpapiMsg_PPBAudio_NotifyAudioStreamCreated audio_msg( | 80 PpapiMsg_PPBAudio_NotifyAudioStreamCreated audio_msg( |
80 INTERFACE_ID_PPB_AUDIO, HostResource(), 0, | 81 INTERFACE_ID_PPB_AUDIO, HostResource(), 0, |
81 IPC::PlatformFileForTransit(), base::SharedMemoryHandle(), 0); | 82 IPC::PlatformFileForTransit(), base::SharedMemoryHandle(), 0); |
82 plugin_dispatcher()->OnMessageReceived(audio_msg); | 83 plugin_dispatcher()->OnMessageReceived(audio_msg); |
83 EXPECT_TRUE(HasTargetProxy(INTERFACE_ID_PPB_AUDIO)); | 84 EXPECT_TRUE(HasTargetProxy(INTERFACE_ID_PPB_AUDIO)); |
84 } | 85 } |
85 | 86 |
86 } // namespace proxy | 87 } // namespace proxy |
87 } // namespace pp | 88 } // namespace pp |
88 | 89 |
OLD | NEW |