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 REMOTING_HOST_HOST_MOCK_OBJECTS_H_
6 #define REMOTING_HOST_HOST_MOCK_OBJECTS_H_
10 #include "net/base/ip_endpoint.h"
11 #include "remoting/host/chromoting_host_context.h"
12 #include "remoting/host/client_session.h"
13 #include "remoting/host/client_session_control.h"
14 #include "remoting/host/desktop_environment.h"
15 #include "remoting/host/gnubby_auth_handler.h"
16 #include "remoting/host/host_status_observer.h"
17 #include "remoting/host/input_injector.h"
18 #include "remoting/host/screen_controls.h"
19 #include "remoting/host/screen_resolution.h"
20 #include "remoting/proto/control.pb.h"
21 #include "testing/gmock/include/gmock/gmock.h"
22 #include "third_party/webrtc/modules/desktop_capture/mouse_cursor_monitor.h"
25 class SingleThreadTaskRunner
;
30 class MockDesktopEnvironment
: public DesktopEnvironment
{
32 MockDesktopEnvironment();
33 ~MockDesktopEnvironment() override
;
35 MOCK_METHOD0(CreateAudioCapturerPtr
, AudioCapturer
*());
36 MOCK_METHOD0(CreateInputInjectorPtr
, InputInjector
*());
37 MOCK_METHOD0(CreateScreenControlsPtr
, ScreenControls
*());
38 MOCK_METHOD0(CreateVideoCapturerPtr
, webrtc::DesktopCapturer
*());
39 MOCK_METHOD0(CreateMouseCursorMonitorPtr
, webrtc::MouseCursorMonitor
*());
40 MOCK_CONST_METHOD0(GetCapabilities
, std::string());
41 MOCK_METHOD1(SetCapabilities
, void(const std::string
&));
42 MOCK_METHOD1(CreateGnubbyAuthHandlerPtr
, GnubbyAuthHandler
*(
43 protocol::ClientStub
* client_stub
));
45 // DesktopEnvironment implementation.
46 scoped_ptr
<AudioCapturer
> CreateAudioCapturer() override
;
47 scoped_ptr
<InputInjector
> CreateInputInjector() override
;
48 scoped_ptr
<ScreenControls
> CreateScreenControls() override
;
49 scoped_ptr
<webrtc::DesktopCapturer
> CreateVideoCapturer() override
;
50 scoped_ptr
<GnubbyAuthHandler
> CreateGnubbyAuthHandler(
51 protocol::ClientStub
* client_stub
) override
;
52 scoped_ptr
<webrtc::MouseCursorMonitor
> CreateMouseCursorMonitor()
56 class MockClientSessionControl
: public ClientSessionControl
{
58 MockClientSessionControl();
59 ~MockClientSessionControl() override
;
61 MOCK_CONST_METHOD0(client_jid
, const std::string
&());
62 MOCK_METHOD0(DisconnectSession
, void());
63 MOCK_METHOD1(OnLocalMouseMoved
, void(const webrtc::DesktopVector
&));
64 MOCK_METHOD1(SetDisableInputs
, void(bool));
65 MOCK_METHOD0(ResetVideoPipeline
, void());
68 DISALLOW_COPY_AND_ASSIGN(MockClientSessionControl
);
71 class MockClientSessionEventHandler
: public ClientSession::EventHandler
{
73 MockClientSessionEventHandler();
74 ~MockClientSessionEventHandler() override
;
76 MOCK_METHOD1(OnSessionAuthenticating
, void(ClientSession
* client
));
77 MOCK_METHOD1(OnSessionAuthenticated
, bool(ClientSession
* client
));
78 MOCK_METHOD1(OnSessionChannelsConnected
, void(ClientSession
* client
));
79 MOCK_METHOD1(OnSessionAuthenticationFailed
, void(ClientSession
* client
));
80 MOCK_METHOD1(OnSessionClosed
, void(ClientSession
* client
));
81 MOCK_METHOD3(OnSessionRouteChange
, void(
82 ClientSession
* client
,
83 const std::string
& channel_name
,
84 const protocol::TransportRoute
& route
));
87 DISALLOW_COPY_AND_ASSIGN(MockClientSessionEventHandler
);
90 class MockDesktopEnvironmentFactory
: public DesktopEnvironmentFactory
{
92 MockDesktopEnvironmentFactory();
93 ~MockDesktopEnvironmentFactory() override
;
95 MOCK_METHOD0(CreatePtr
, DesktopEnvironment
*());
96 MOCK_CONST_METHOD0(SupportsAudioCapture
, bool());
98 scoped_ptr
<DesktopEnvironment
> Create(
99 base::WeakPtr
<ClientSessionControl
> client_session_control
) override
;
102 DISALLOW_COPY_AND_ASSIGN(MockDesktopEnvironmentFactory
);
105 class MockInputInjector
: public InputInjector
{
108 ~MockInputInjector() override
;
110 MOCK_METHOD1(InjectClipboardEvent
,
111 void(const protocol::ClipboardEvent
& event
));
112 MOCK_METHOD1(InjectKeyEvent
, void(const protocol::KeyEvent
& event
));
113 MOCK_METHOD1(InjectTextEvent
, void(const protocol::TextEvent
& event
));
114 MOCK_METHOD1(InjectMouseEvent
, void(const protocol::MouseEvent
& event
));
115 MOCK_METHOD1(InjectTouchEvent
, void(const protocol::TouchEvent
& event
));
116 MOCK_METHOD1(StartPtr
,
117 void(protocol::ClipboardStub
* client_clipboard
));
119 void Start(scoped_ptr
<protocol::ClipboardStub
> client_clipboard
);
122 DISALLOW_COPY_AND_ASSIGN(MockInputInjector
);
125 class MockHostStatusObserver
: public HostStatusObserver
{
127 MockHostStatusObserver();
128 ~MockHostStatusObserver() override
;
130 MOCK_METHOD1(OnAccessDenied
, void(const std::string
& jid
));
131 MOCK_METHOD1(OnClientAuthenticated
, void(const std::string
& jid
));
132 MOCK_METHOD1(OnClientConnected
, void(const std::string
& jid
));
133 MOCK_METHOD1(OnClientDisconnected
, void(const std::string
& jid
));
134 MOCK_METHOD3(OnClientRouteChange
,
135 void(const std::string
& jid
,
136 const std::string
& channel_name
,
137 const protocol::TransportRoute
& route
));
138 MOCK_METHOD1(OnStart
, void(const std::string
& xmpp_login
));
139 MOCK_METHOD0(OnShutdown
, void());
142 class MockGnubbyAuthHandler
: public GnubbyAuthHandler
{
144 MockGnubbyAuthHandler();
145 ~MockGnubbyAuthHandler() override
;
147 MOCK_METHOD1(DeliverClientMessage
, void(const std::string
& message
));
148 MOCK_CONST_METHOD2(DeliverHostDataMessage
,
149 void(int connection_id
, const std::string
& data
));
152 DISALLOW_COPY_AND_ASSIGN(MockGnubbyAuthHandler
);
155 class MockMouseCursorMonitor
: public webrtc::MouseCursorMonitor
{
157 MockMouseCursorMonitor();
158 ~MockMouseCursorMonitor() override
;
160 MOCK_METHOD2(Init
, void(Callback
* callback
, Mode mode
));
161 MOCK_METHOD0(Capture
, void());
164 DISALLOW_COPY_AND_ASSIGN(MockMouseCursorMonitor
);
167 } // namespace remoting
169 #endif // REMOTING_HOST_HOST_MOCK_OBJECTS_H_