blob: 1d7f2036d33edb1ae9c2d88a471fad14e42f8268 [file] [log] [blame]
[email protected]465faa22011-02-08 16:31:461// 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
3// found in the LICENSE file.
4
[email protected]465faa22011-02-08 16:31:465#include "ipc/ipc_message_utils.h"
6#include "ppapi/c/ppb_audio.h"
7#include "ppapi/c/ppp_instance.h"
8#include "ppapi/proxy/ppapi_messages.h"
9#include "ppapi/proxy/ppapi_proxy_test.h"
10
[email protected]4d2efd22011-08-18 21:58:0211namespace ppapi {
[email protected]465faa22011-02-08 16:31:4612namespace proxy {
13
14namespace {
15
16bool received_create = false;
17
18// Implement PPB_Audio since it's a relatively simple PPB interface and
19// includes bidirectional communication.
20PP_Resource Create(PP_Instance instance, PP_Resource config,
21 PPB_Audio_Callback audio_callback, void* user_data) {
22 received_create = true;
23 return 0;
24}
25PP_Bool IsAudio(PP_Resource resource) {
26 return PP_FALSE;
27}
28PP_Resource GetCurrentConfig(PP_Resource audio) {
29 return 0;
30}
31PP_Bool StartPlayback(PP_Resource audio) {
32 return PP_FALSE;
33}
34PP_Bool StopPlayback(PP_Resource audio) {
35 return PP_FALSE;
36}
37
38PPB_Audio dummy_audio_interface = {
39 &Create,
40 &IsAudio,
41 &GetCurrentConfig,
42 &StartPlayback,
43 &StopPlayback
44};
45
[email protected]912f3d6c2011-06-29 18:26:3646PPP_Instance dummy_ppp_instance_interface = {};
47
[email protected]465faa22011-02-08 16:31:4648} // namespace
49
50class PluginDispatcherTest : public PluginProxyTest {
51 public:
52 PluginDispatcherTest() {}
53
[email protected]ac4b54d2011-10-20 23:09:2854 bool HasTargetProxy(ApiID id) {
[email protected]5c966022011-09-13 18:09:3755 return !!plugin_dispatcher()->proxies_[id].get();
[email protected]465faa22011-02-08 16:31:4656 }
57};
58
59TEST_F(PluginDispatcherTest, SupportsInterface) {
60 RegisterTestInterface(PPB_AUDIO_INTERFACE, &dummy_audio_interface);
[email protected]912f3d6c2011-06-29 18:26:3661 RegisterTestInterface(PPP_INSTANCE_INTERFACE, &dummy_ppp_instance_interface);
[email protected]465faa22011-02-08 16:31:4662
63 // Sending a request for a random interface should fail.
kareng1c62eeb2014-11-08 16:35:0364 EXPECT_FALSE(SupportsInterface("Random interface"));
[email protected]465faa22011-02-08 16:31:4665
[email protected]465faa22011-02-08 16:31:4666 // Sending a request for a supported PPP interface should succeed.
kareng1c62eeb2014-11-08 16:35:0367 EXPECT_TRUE(SupportsInterface(PPP_INSTANCE_INTERFACE));
[email protected]465faa22011-02-08 16:31:4668}
69
70TEST_F(PluginDispatcherTest, PPBCreation) {
71 // Sending a PPB message out of the blue should create a target proxy for
72 // that interface in the plugin.
[email protected]ac4b54d2011-10-20 23:09:2873 EXPECT_FALSE(HasTargetProxy(API_ID_PPB_AUDIO));
[email protected]465faa22011-02-08 16:31:4674 PpapiMsg_PPBAudio_NotifyAudioStreamCreated audio_msg(
[email protected]ac4b54d2011-10-20 23:09:2875 API_ID_PPB_AUDIO, HostResource(), 0,
Alexandr Ilin20f2841c2018-06-01 11:56:1876 ppapi::proxy::SerializedHandle(ppapi::proxy::SerializedHandle::SOCKET),
[email protected]246fc492012-08-27 20:28:1877 ppapi::proxy::SerializedHandle(
Alexandr Ilin20f2841c2018-06-01 11:56:1878 ppapi::proxy::SerializedHandle::SHARED_MEMORY_REGION));
[email protected]465faa22011-02-08 16:31:4679 plugin_dispatcher()->OnMessageReceived(audio_msg);
[email protected]ac4b54d2011-10-20 23:09:2880 EXPECT_TRUE(HasTargetProxy(API_ID_PPB_AUDIO));
[email protected]465faa22011-02-08 16:31:4681}
82
83} // namespace proxy
[email protected]4d2efd22011-08-18 21:58:0284} // namespace ppapi
[email protected]465faa22011-02-08 16:31:4685