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.
5 #ifndef CONTENT_RENDERER_PEPPER_MOCK_RENDERER_PPAPI_HOST_H_
6 #define CONTENT_RENDERER_PEPPER_MOCK_RENDERER_PPAPI_HOST_H_
8 #include "base/basictypes.h"
9 #include "content/public/renderer/renderer_ppapi_host.h"
10 #include "content/renderer/pepper/content_renderer_pepper_host_factory.h"
11 #include "ppapi/host/ppapi_host.h"
12 #include "ppapi/proxy/resource_message_test_sink.h"
23 // A mock RendererPpapiHost for testing resource hosts. Messages sent by
24 // resources through this will get added to the test sink.
25 class MockRendererPpapiHost
: public RendererPpapiHost
{
27 // This function takes the RenderView and instance that the mock resource
28 // host will be associated with.
29 MockRendererPpapiHost(RenderView
* render_view
,
30 PP_Instance instance
);
31 virtual ~MockRendererPpapiHost();
33 ppapi::proxy::ResourceMessageTestSink
& sink() { return sink_
; }
34 PP_Instance
pp_instance() const { return pp_instance_
; }
36 // Sets whether there is currently a user gesture. Defaults to false.
37 void set_has_user_gesture(bool gesture
) { has_user_gesture_
= gesture
; }
40 virtual ppapi::host::PpapiHost
* GetPpapiHost() OVERRIDE
;
41 virtual bool IsValidInstance(PP_Instance instance
) const OVERRIDE
;
42 virtual webkit::ppapi::PluginInstance
* GetPluginInstance(
43 PP_Instance instance
) const OVERRIDE
;
44 virtual RenderView
* GetRenderViewForInstance(
45 PP_Instance instance
) const OVERRIDE
;
46 virtual WebKit::WebPluginContainer
* GetContainerForInstance(
47 PP_Instance instance
) const OVERRIDE
;
48 virtual webkit::ppapi::PluginDelegate::PlatformGraphics2D
*
49 GetPlatformGraphics2D(PP_Resource resource
) OVERRIDE
;
50 virtual bool HasUserGesture(PP_Instance instance
) const OVERRIDE
;
51 virtual int GetRoutingIDForWidget(PP_Instance instance
) const OVERRIDE
;
52 virtual gfx::Point
PluginPointToRenderView(
54 const gfx::Point
& pt
) const OVERRIDE
;
55 virtual IPC::PlatformFileForTransit
ShareHandleWithRemote(
56 base::PlatformFile handle
,
57 bool should_close_source
) OVERRIDE
;
58 virtual bool IsRunningInProcess() const OVERRIDE
;
61 ppapi::proxy::ResourceMessageTestSink sink_
;
62 ppapi::host::PpapiHost ppapi_host_
;
64 RenderView
* render_view_
;
65 PP_Instance pp_instance_
;
67 bool has_user_gesture_
;
69 DISALLOW_COPY_AND_ASSIGN(MockRendererPpapiHost
);
72 } // namespace content
74 #endif // CONTENT_RENDERER_PEPPER_MOCK_RENDERER_PPAPI_HOST_H_