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 <string> 9 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" 23 24 namespace base { 25 class SingleThreadTaskRunner; 26 } // namespace base 27 28 namespace remoting { 29 30 class MockDesktopEnvironment : public DesktopEnvironment { 31 public: 32 MockDesktopEnvironment(); 33 virtual ~MockDesktopEnvironment(); 34 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)); 44 45 // DesktopEnvironment implementation. 46 virtual scoped_ptr<AudioCapturer> CreateAudioCapturer() OVERRIDE; 47 virtual scoped_ptr<InputInjector> CreateInputInjector() OVERRIDE; 48 virtual scoped_ptr<ScreenControls> CreateScreenControls() OVERRIDE; 49 virtual scoped_ptr<webrtc::DesktopCapturer> CreateVideoCapturer() OVERRIDE; 50 virtual scoped_ptr<GnubbyAuthHandler> CreateGnubbyAuthHandler( 51 protocol::ClientStub* client_stub) OVERRIDE; 52 virtual scoped_ptr<webrtc::MouseCursorMonitor> CreateMouseCursorMonitor() 53 OVERRIDE; 54 }; 55 56 class MockClientSessionControl : public ClientSessionControl { 57 public: 58 MockClientSessionControl(); 59 virtual ~MockClientSessionControl(); 60 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()); 66 67 private: 68 DISALLOW_COPY_AND_ASSIGN(MockClientSessionControl); 69 }; 70 71 class MockClientSessionEventHandler : public ClientSession::EventHandler { 72 public: 73 MockClientSessionEventHandler(); 74 virtual ~MockClientSessionEventHandler(); 75 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)); 85 86 private: 87 DISALLOW_COPY_AND_ASSIGN(MockClientSessionEventHandler); 88 }; 89 90 class MockDesktopEnvironmentFactory : public DesktopEnvironmentFactory { 91 public: 92 MockDesktopEnvironmentFactory(); 93 virtual ~MockDesktopEnvironmentFactory(); 94 95 MOCK_METHOD0(CreatePtr, DesktopEnvironment*()); 96 MOCK_CONST_METHOD0(SupportsAudioCapture, bool()); 97 98 virtual scoped_ptr<DesktopEnvironment> Create( 99 base::WeakPtr<ClientSessionControl> client_session_control) OVERRIDE; 100 101 private: 102 DISALLOW_COPY_AND_ASSIGN(MockDesktopEnvironmentFactory); 103 }; 104 105 class MockInputInjector : public InputInjector { 106 public: 107 MockInputInjector(); 108 virtual ~MockInputInjector(); 109 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(StartPtr, 116 void(protocol::ClipboardStub* client_clipboard)); 117 118 void Start(scoped_ptr<protocol::ClipboardStub> client_clipboard); 119 120 private: 121 DISALLOW_COPY_AND_ASSIGN(MockInputInjector); 122 }; 123 124 class MockHostStatusObserver : public HostStatusObserver { 125 public: 126 MockHostStatusObserver(); 127 virtual ~MockHostStatusObserver(); 128 129 MOCK_METHOD1(OnAccessDenied, void(const std::string& jid)); 130 MOCK_METHOD1(OnClientAuthenticated, void(const std::string& jid)); 131 MOCK_METHOD1(OnClientConnected, void(const std::string& jid)); 132 MOCK_METHOD1(OnClientDisconnected, void(const std::string& jid)); 133 MOCK_METHOD3(OnClientRouteChange, 134 void(const std::string& jid, 135 const std::string& channel_name, 136 const protocol::TransportRoute& route)); 137 MOCK_METHOD1(OnStart, void(const std::string& xmpp_login)); 138 MOCK_METHOD0(OnShutdown, void()); 139 }; 140 141 class MockGnubbyAuthHandler : public GnubbyAuthHandler { 142 public: 143 MockGnubbyAuthHandler(); 144 virtual ~MockGnubbyAuthHandler(); 145 146 MOCK_METHOD1(DeliverClientMessage, void(const std::string& message)); 147 MOCK_CONST_METHOD2(DeliverHostDataMessage, 148 void(int connection_id, const std::string& data)); 149 150 private: 151 DISALLOW_COPY_AND_ASSIGN(MockGnubbyAuthHandler); 152 }; 153 154 class MockMouseCursorMonitor : public webrtc::MouseCursorMonitor { 155 public: 156 MockMouseCursorMonitor(); 157 virtual ~MockMouseCursorMonitor(); 158 159 MOCK_METHOD2(Init, void(Callback* callback, Mode mode)); 160 MOCK_METHOD0(Capture, void()); 161 162 private: 163 DISALLOW_COPY_AND_ASSIGN(MockMouseCursorMonitor); 164 }; 165 166 } // namespace remoting 167 168 #endif // REMOTING_HOST_HOST_MOCK_OBJECTS_H_ 169