summaryrefslogtreecommitdiffstats
path: root/ppapi/proxy
diff options
context:
space:
mode:
authorbbudge@chromium.org <bbudge@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-20 21:18:07 +0000
committerbbudge@chromium.org <bbudge@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-20 21:18:07 +0000
commited33e2eb202e0efc5bba8f275fd126aebdc91ada (patch)
tree5560e2bd728baaca0c72f4b31f03dc9761090e64 /ppapi/proxy
parent52dc84021b685da622a96e0d0c35dbc3f1197ada (diff)
downloadchromium_src-ed33e2eb202e0efc5bba8f275fd126aebdc91ada.zip
chromium_src-ed33e2eb202e0efc5bba8f275fd126aebdc91ada.tar.gz
chromium_src-ed33e2eb202e0efc5bba8f275fd126aebdc91ada.tar.bz2
Add functions to generate input events to PPB_Testing_Dev. These make
it possible to test APIs that require user gestures and other input events. BUG=none TEST=none Review URL: http://codereview.chromium.org/8413021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110865 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/proxy')
-rw-r--r--ppapi/proxy/ppapi_messages.h3
-rw-r--r--ppapi/proxy/ppb_testing_proxy.cc35
-rw-r--r--ppapi/proxy/ppb_testing_proxy.h5
3 files changed, 42 insertions, 1 deletions
diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h
index d38a397..758e040 100644
--- a/ppapi/proxy/ppapi_messages.h
+++ b/ppapi/proxy/ppapi_messages.h
@@ -974,6 +974,9 @@ IPC_SYNC_MESSAGE_ROUTED3_1(
IPC_SYNC_MESSAGE_ROUTED1_1(PpapiHostMsg_PPBTesting_GetLiveObjectsForInstance,
PP_Instance /* instance */,
uint32 /* result */)
+IPC_MESSAGE_ROUTED2(PpapiHostMsg_PPBTesting_SimulateInputEvent,
+ PP_Instance /* instance */,
+ ppapi::InputEventData /* input_event */)
// PPB_TextInput.
IPC_MESSAGE_ROUTED2(PpapiHostMsg_PPBTextInput_SetTextInputType,
diff --git a/ppapi/proxy/ppb_testing_proxy.cc b/ppapi/proxy/ppb_testing_proxy.cc
index 73f9b5b..d9f90f2 100644
--- a/ppapi/proxy/ppb_testing_proxy.cc
+++ b/ppapi/proxy/ppb_testing_proxy.cc
@@ -6,11 +6,17 @@
#include "base/message_loop.h"
#include "ppapi/c/dev/ppb_testing_dev.h"
+#include "ppapi/proxy/enter_proxy.h"
#include "ppapi/proxy/plugin_dispatcher.h"
#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/shared_impl/ppapi_globals.h"
#include "ppapi/shared_impl/resource.h"
#include "ppapi/shared_impl/resource_tracker.h"
+#include "ppapi/thunk/enter.h"
+#include "ppapi/thunk/ppb_input_event_api.h"
+
+using ppapi::thunk::EnterResource;
+using ppapi::thunk::PPB_InputEvent_API;
namespace ppapi {
namespace proxy {
@@ -68,12 +74,26 @@ PP_Bool IsOutOfProcess() {
return PP_TRUE;
}
+void SimulateInputEvent(PP_Instance instance_id, PP_Resource input_event) {
+ PluginDispatcher* dispatcher = PluginDispatcher::GetForInstance(instance_id);
+ if (!dispatcher)
+ return;
+ EnterResource<PPB_InputEvent_API> enter(input_event, false);
+ if (enter.failed())
+ return;
+
+ const InputEventData& input_event_data = enter.object()->GetInputEventData();
+ dispatcher->Send(new PpapiHostMsg_PPBTesting_SimulateInputEvent(
+ API_ID_PPB_TESTING, instance_id, input_event_data));
+}
+
const PPB_Testing_Dev testing_interface = {
&ReadImageData,
&RunMessageLoop,
&QuitMessageLoop,
&GetLiveObjectsForInstance,
- &IsOutOfProcess
+ &IsOutOfProcess,
+ &SimulateInputEvent
};
InterfaceProxy* CreateTestingProxy(Dispatcher* dispatcher) {
@@ -113,6 +133,8 @@ bool PPB_Testing_Proxy::OnMessageReceived(const IPC::Message& msg) {
OnMsgReadImageData)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTesting_GetLiveObjectsForInstance,
OnMsgGetLiveObjectsForInstance)
+ IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBTesting_SimulateInputEvent,
+ OnMsgSimulateInputEvent)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
@@ -140,5 +162,16 @@ void PPB_Testing_Proxy::OnMsgGetLiveObjectsForInstance(PP_Instance instance,
*result = ppb_testing_impl_->GetLiveObjectsForInstance(instance);
}
+void PPB_Testing_Proxy::OnMsgSimulateInputEvent(
+ PP_Instance instance,
+ const InputEventData& input_event) {
+ scoped_refptr<InputEventImpl> input_event_impl(
+ new InputEventImpl(InputEventImpl::InitAsProxy(),
+ instance,
+ input_event));
+ ppb_testing_impl_->SimulateInputEvent(instance,
+ input_event_impl->pp_resource());
+}
+
} // namespace proxy
} // namespace ppapi
diff --git a/ppapi/proxy/ppb_testing_proxy.h b/ppapi/proxy/ppb_testing_proxy.h
index eaf5fb3..ffbd73f 100644
--- a/ppapi/proxy/ppb_testing_proxy.h
+++ b/ppapi/proxy/ppb_testing_proxy.h
@@ -15,6 +15,9 @@ struct PP_Point;
struct PPB_Testing_Dev;
namespace ppapi {
+
+struct InputEventData;
+
namespace proxy {
class PPB_Testing_Proxy : public InterfaceProxy {
@@ -36,6 +39,8 @@ class PPB_Testing_Proxy : public InterfaceProxy {
void OnMsgRunMessageLoop(PP_Instance instance);
void OnMsgQuitMessageLoop(PP_Instance instance);
void OnMsgGetLiveObjectsForInstance(PP_Instance instance, uint32_t* result);
+ void OnMsgSimulateInputEvent(PP_Instance instance,
+ const ppapi::InputEventData& input_event);
// When this proxy is in the host side, this value caches the interface
// pointer so we don't have to retrieve it from the dispatcher each time.