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.
4
5#ifndef REMOTING_HOST_HOST_MOCK_OBJECTS_H_
6#define REMOTING_HOST_HOST_MOCK_OBJECTS_H_
7
8#include "net/base/ip_endpoint.h"
9#include "remoting/host/chromoting_host_context.h"
10#include "remoting/host/client_session.h"
11#include "remoting/host/client_session_control.h"
12#include "remoting/host/desktop_environment.h"
13#include "remoting/host/host_status_observer.h"
14#include "remoting/host/input_injector.h"
15#include "remoting/host/screen_controls.h"
16#include "remoting/host/screen_resolution.h"
17#include "remoting/proto/control.pb.h"
18#include "testing/gmock/include/gmock/gmock.h"
19
20namespace base {
21class SingleThreadTaskRunner;
22}  // namespace base
23
24namespace remoting {
25
26class MockDesktopEnvironment : public DesktopEnvironment {
27 public:
28  MockDesktopEnvironment();
29  virtual ~MockDesktopEnvironment();
30
31  MOCK_METHOD0(CreateAudioCapturerPtr, AudioCapturer*());
32  MOCK_METHOD0(CreateInputInjectorPtr, InputInjector*());
33  MOCK_METHOD0(CreateScreenControlsPtr, ScreenControls*());
34  MOCK_METHOD0(CreateVideoCapturerPtr, webrtc::ScreenCapturer*());
35  MOCK_CONST_METHOD0(GetCapabilities, std::string());
36  MOCK_METHOD1(SetCapabilities, void(const std::string&));
37
38  // DesktopEnvironment implementation.
39  virtual scoped_ptr<AudioCapturer> CreateAudioCapturer() OVERRIDE;
40  virtual scoped_ptr<InputInjector> CreateInputInjector() OVERRIDE;
41  virtual scoped_ptr<ScreenControls> CreateScreenControls() OVERRIDE;
42  virtual scoped_ptr<webrtc::ScreenCapturer> CreateVideoCapturer() OVERRIDE;
43};
44
45class MockClientSessionControl : public ClientSessionControl {
46 public:
47  MockClientSessionControl();
48  virtual ~MockClientSessionControl();
49
50  MOCK_CONST_METHOD0(client_jid, const std::string&());
51  MOCK_METHOD0(DisconnectSession, void());
52  MOCK_METHOD1(OnLocalMouseMoved, void(const webrtc::DesktopVector&));
53  MOCK_METHOD1(SetDisableInputs, void(bool));
54
55 private:
56  DISALLOW_COPY_AND_ASSIGN(MockClientSessionControl);
57};
58
59class MockClientSessionEventHandler : public ClientSession::EventHandler {
60 public:
61  MockClientSessionEventHandler();
62  virtual ~MockClientSessionEventHandler();
63
64  MOCK_METHOD1(OnSessionAuthenticated, bool(ClientSession* client));
65  MOCK_METHOD1(OnSessionChannelsConnected, void(ClientSession* client));
66  MOCK_METHOD1(OnSessionAuthenticationFailed, void(ClientSession* client));
67  MOCK_METHOD1(OnSessionClosed, void(ClientSession* client));
68  MOCK_METHOD2(OnSessionSequenceNumber, void(ClientSession* client,
69                                             int64 sequence_number));
70  MOCK_METHOD3(OnSessionRouteChange, void(
71      ClientSession* client,
72      const std::string& channel_name,
73      const protocol::TransportRoute& route));
74
75 private:
76  DISALLOW_COPY_AND_ASSIGN(MockClientSessionEventHandler);
77};
78
79class MockDesktopEnvironmentFactory : public DesktopEnvironmentFactory {
80 public:
81  MockDesktopEnvironmentFactory();
82  virtual ~MockDesktopEnvironmentFactory();
83
84  MOCK_METHOD0(CreatePtr, DesktopEnvironment*());
85  MOCK_CONST_METHOD0(SupportsAudioCapture, bool());
86
87  virtual scoped_ptr<DesktopEnvironment> Create(
88      base::WeakPtr<ClientSessionControl> client_session_control) OVERRIDE;
89
90 private:
91  DISALLOW_COPY_AND_ASSIGN(MockDesktopEnvironmentFactory);
92};
93
94class MockInputInjector : public InputInjector {
95 public:
96  MockInputInjector();
97  virtual ~MockInputInjector();
98
99  MOCK_METHOD1(InjectClipboardEvent,
100               void(const protocol::ClipboardEvent& event));
101  MOCK_METHOD1(InjectKeyEvent, void(const protocol::KeyEvent& event));
102  MOCK_METHOD1(InjectMouseEvent, void(const protocol::MouseEvent& event));
103  MOCK_METHOD1(StartPtr,
104               void(protocol::ClipboardStub* client_clipboard));
105
106  void Start(scoped_ptr<protocol::ClipboardStub> client_clipboard);
107
108 private:
109  DISALLOW_COPY_AND_ASSIGN(MockInputInjector);
110};
111
112class MockHostStatusObserver : public HostStatusObserver {
113 public:
114  MockHostStatusObserver();
115  virtual ~MockHostStatusObserver();
116
117  MOCK_METHOD1(OnAccessDenied, void(const std::string& jid));
118  MOCK_METHOD1(OnClientAuthenticated, void(const std::string& jid));
119  MOCK_METHOD1(OnClientConnected, void(const std::string& jid));
120  MOCK_METHOD1(OnClientDisconnected, void(const std::string& jid));
121  MOCK_METHOD3(OnClientRouteChange,
122               void(const std::string& jid,
123                    const std::string& channel_name,
124                    const protocol::TransportRoute& route));
125  MOCK_METHOD1(OnStart, void(const std::string& xmpp_login));
126  MOCK_METHOD0(OnShutdown, void());
127};
128
129}  // namespace remoting
130
131#endif  // REMOTING_HOST_HOST_MOCK_OBJECTS_H_
132