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"
24 class SingleThreadTaskRunner
;
29 class MockDesktopEnvironment
: public DesktopEnvironment
{
31 MockDesktopEnvironment();
32 virtual ~MockDesktopEnvironment();
34 MOCK_METHOD0(CreateAudioCapturerPtr
, AudioCapturer
*());
35 MOCK_METHOD0(CreateInputInjectorPtr
, InputInjector
*());
36 MOCK_METHOD0(CreateScreenControlsPtr
, ScreenControls
*());
37 MOCK_METHOD0(CreateVideoCapturerPtr
, webrtc::ScreenCapturer
*());
38 MOCK_CONST_METHOD0(GetCapabilities
, std::string());
39 MOCK_METHOD1(SetCapabilities
, void(const std::string
&));
40 MOCK_METHOD1(CreateGnubbyAuthHandlerPtr
, GnubbyAuthHandler
*(
41 protocol::ClientStub
* client_stub
));
43 // DesktopEnvironment implementation.
44 virtual scoped_ptr
<AudioCapturer
> CreateAudioCapturer() OVERRIDE
;
45 virtual scoped_ptr
<InputInjector
> CreateInputInjector() OVERRIDE
;
46 virtual scoped_ptr
<ScreenControls
> CreateScreenControls() OVERRIDE
;
47 virtual scoped_ptr
<webrtc::ScreenCapturer
> CreateVideoCapturer() OVERRIDE
;
48 virtual scoped_ptr
<GnubbyAuthHandler
> CreateGnubbyAuthHandler(
49 protocol::ClientStub
* client_stub
) OVERRIDE
;
52 class MockClientSessionControl
: public ClientSessionControl
{
54 MockClientSessionControl();
55 virtual ~MockClientSessionControl();
57 MOCK_CONST_METHOD0(client_jid
, const std::string
&());
58 MOCK_METHOD0(DisconnectSession
, void());
59 MOCK_METHOD1(OnLocalMouseMoved
, void(const webrtc::DesktopVector
&));
60 MOCK_METHOD1(SetDisableInputs
, void(bool));
63 DISALLOW_COPY_AND_ASSIGN(MockClientSessionControl
);
66 class MockClientSessionEventHandler
: public ClientSession::EventHandler
{
68 MockClientSessionEventHandler();
69 virtual ~MockClientSessionEventHandler();
71 MOCK_METHOD1(OnSessionAuthenticating
, void(ClientSession
* client
));
72 MOCK_METHOD1(OnSessionAuthenticated
, bool(ClientSession
* client
));
73 MOCK_METHOD1(OnSessionChannelsConnected
, void(ClientSession
* client
));
74 MOCK_METHOD1(OnSessionClientCapabilities
, void(ClientSession
* client
));
75 MOCK_METHOD1(OnSessionAuthenticationFailed
, void(ClientSession
* client
));
76 MOCK_METHOD1(OnSessionClosed
, void(ClientSession
* client
));
77 MOCK_METHOD3(OnSessionRouteChange
, void(
78 ClientSession
* client
,
79 const std::string
& channel_name
,
80 const protocol::TransportRoute
& route
));
83 DISALLOW_COPY_AND_ASSIGN(MockClientSessionEventHandler
);
86 class MockDesktopEnvironmentFactory
: public DesktopEnvironmentFactory
{
88 MockDesktopEnvironmentFactory();
89 virtual ~MockDesktopEnvironmentFactory();
91 MOCK_METHOD0(CreatePtr
, DesktopEnvironment
*());
92 MOCK_CONST_METHOD0(SupportsAudioCapture
, bool());
94 virtual scoped_ptr
<DesktopEnvironment
> Create(
95 base::WeakPtr
<ClientSessionControl
> client_session_control
) OVERRIDE
;
98 DISALLOW_COPY_AND_ASSIGN(MockDesktopEnvironmentFactory
);
101 class MockInputInjector
: public InputInjector
{
104 virtual ~MockInputInjector();
106 MOCK_METHOD1(InjectClipboardEvent
,
107 void(const protocol::ClipboardEvent
& event
));
108 MOCK_METHOD1(InjectKeyEvent
, void(const protocol::KeyEvent
& event
));
109 MOCK_METHOD1(InjectTextEvent
, void(const protocol::TextEvent
& event
));
110 MOCK_METHOD1(InjectMouseEvent
, void(const protocol::MouseEvent
& event
));
111 MOCK_METHOD1(StartPtr
,
112 void(protocol::ClipboardStub
* client_clipboard
));
114 void Start(scoped_ptr
<protocol::ClipboardStub
> client_clipboard
);
117 DISALLOW_COPY_AND_ASSIGN(MockInputInjector
);
120 class MockHostStatusObserver
: public HostStatusObserver
{
122 MockHostStatusObserver();
123 virtual ~MockHostStatusObserver();
125 MOCK_METHOD1(OnAccessDenied
, void(const std::string
& jid
));
126 MOCK_METHOD1(OnClientAuthenticated
, void(const std::string
& jid
));
127 MOCK_METHOD1(OnClientConnected
, void(const std::string
& jid
));
128 MOCK_METHOD1(OnClientDisconnected
, void(const std::string
& jid
));
129 MOCK_METHOD3(OnClientRouteChange
,
130 void(const std::string
& jid
,
131 const std::string
& channel_name
,
132 const protocol::TransportRoute
& route
));
133 MOCK_METHOD1(OnStart
, void(const std::string
& xmpp_login
));
134 MOCK_METHOD0(OnShutdown
, void());
137 class MockGnubbyAuthHandler
: public GnubbyAuthHandler
{
139 MockGnubbyAuthHandler();
140 virtual ~MockGnubbyAuthHandler();
142 MOCK_METHOD1(DeliverClientMessage
, void(const std::string
& message
));
143 MOCK_CONST_METHOD2(DeliverHostDataMessage
,
144 void(int connection_id
, const std::string
& data
));
147 DISALLOW_COPY_AND_ASSIGN(MockGnubbyAuthHandler
);
150 } // namespace remoting
152 #endif // REMOTING_HOST_HOST_MOCK_OBJECTS_H_