OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/message_loop/message_loop_proxy.h" | 8 #include "base/message_loop/message_loop_proxy.h" |
9 #include "remoting/base/auto_thread_task_runner.h" | 9 #include "remoting/base/auto_thread_task_runner.h" |
10 #include "remoting/host/audio_capturer.h" | 10 #include "remoting/host/audio_capturer.h" |
11 #include "remoting/host/chromoting_host.h" | 11 #include "remoting/host/chromoting_host.h" |
12 #include "remoting/host/chromoting_host_context.h" | 12 #include "remoting/host/chromoting_host_context.h" |
13 #include "remoting/host/desktop_environment.h" | 13 #include "remoting/host/desktop_environment.h" |
| 14 #include "remoting/host/fake_mouse_cursor_monitor.h" |
14 #include "remoting/host/fake_screen_capturer.h" | 15 #include "remoting/host/fake_screen_capturer.h" |
15 #include "remoting/host/host_mock_objects.h" | 16 #include "remoting/host/host_mock_objects.h" |
16 #include "remoting/proto/video.pb.h" | 17 #include "remoting/proto/video.pb.h" |
17 #include "remoting/protocol/errors.h" | 18 #include "remoting/protocol/errors.h" |
18 #include "remoting/protocol/protocol_mock_objects.h" | 19 #include "remoting/protocol/protocol_mock_objects.h" |
19 #include "remoting/protocol/session_config.h" | 20 #include "remoting/protocol/session_config.h" |
20 #include "remoting/signaling/mock_signal_strategy.h" | 21 #include "remoting/signaling/mock_signal_strategy.h" |
21 #include "testing/gmock/include/gmock/gmock.h" | 22 #include "testing/gmock/include/gmock/gmock.h" |
22 #include "testing/gmock_mutant.h" | 23 #include "testing/gmock_mutant.h" |
23 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 EXPECT_CALL(*desktop_environment, CreateAudioCapturerPtr()) | 243 EXPECT_CALL(*desktop_environment, CreateAudioCapturerPtr()) |
243 .Times(0); | 244 .Times(0); |
244 EXPECT_CALL(*desktop_environment, CreateInputInjectorPtr()) | 245 EXPECT_CALL(*desktop_environment, CreateInputInjectorPtr()) |
245 .Times(AtMost(1)) | 246 .Times(AtMost(1)) |
246 .WillOnce(Invoke(this, &ChromotingHostTest::CreateInputInjector)); | 247 .WillOnce(Invoke(this, &ChromotingHostTest::CreateInputInjector)); |
247 EXPECT_CALL(*desktop_environment, CreateScreenControlsPtr()) | 248 EXPECT_CALL(*desktop_environment, CreateScreenControlsPtr()) |
248 .Times(AtMost(1)); | 249 .Times(AtMost(1)); |
249 EXPECT_CALL(*desktop_environment, CreateVideoCapturerPtr()) | 250 EXPECT_CALL(*desktop_environment, CreateVideoCapturerPtr()) |
250 .Times(AtMost(1)) | 251 .Times(AtMost(1)) |
251 .WillOnce(Invoke(this, &ChromotingHostTest::CreateVideoCapturer)); | 252 .WillOnce(Invoke(this, &ChromotingHostTest::CreateVideoCapturer)); |
| 253 EXPECT_CALL(*desktop_environment, CreateMouseCursorMonitorPtr()) |
| 254 .Times(AtMost(1)) |
| 255 .WillOnce(Invoke(this, &ChromotingHostTest::CreateMouseCursorMonitor)); |
252 EXPECT_CALL(*desktop_environment, GetCapabilities()) | 256 EXPECT_CALL(*desktop_environment, GetCapabilities()) |
253 .Times(AtMost(1)); | 257 .Times(AtMost(1)); |
254 EXPECT_CALL(*desktop_environment, SetCapabilities(_)) | 258 EXPECT_CALL(*desktop_environment, SetCapabilities(_)) |
255 .Times(AtMost(1)); | 259 .Times(AtMost(1)); |
256 | 260 |
257 return desktop_environment; | 261 return desktop_environment; |
258 } | 262 } |
259 | 263 |
260 // Creates a dummy InputInjector, to mock | 264 // Creates a dummy InputInjector, to mock |
261 // DesktopEnvironment::CreateInputInjector(). | 265 // DesktopEnvironment::CreateInputInjector(). |
262 InputInjector* CreateInputInjector() { | 266 InputInjector* CreateInputInjector() { |
263 MockInputInjector* input_injector = new MockInputInjector(); | 267 MockInputInjector* input_injector = new MockInputInjector(); |
264 EXPECT_CALL(*input_injector, StartPtr(_)); | 268 EXPECT_CALL(*input_injector, StartPtr(_)); |
265 return input_injector; | 269 return input_injector; |
266 } | 270 } |
267 | 271 |
268 // Creates a fake webrtc::ScreenCapturer, to mock | 272 // Creates a fake webrtc::ScreenCapturer, to mock |
269 // DesktopEnvironment::CreateVideoCapturer(). | 273 // DesktopEnvironment::CreateVideoCapturer(). |
270 webrtc::ScreenCapturer* CreateVideoCapturer() { | 274 webrtc::ScreenCapturer* CreateVideoCapturer() { |
271 return new FakeScreenCapturer(); | 275 return new FakeScreenCapturer(); |
272 } | 276 } |
273 | 277 |
| 278 // Creates a MockMouseCursorMonitor, to mock |
| 279 // DesktopEnvironment::CreateMouseCursorMonitor(). |
| 280 webrtc::MouseCursorMonitor* CreateMouseCursorMonitor() { |
| 281 return new FakeMouseCursorMonitor(); |
| 282 } |
| 283 |
274 void DisconnectAllClients() { | 284 void DisconnectAllClients() { |
275 host_->DisconnectAllClients(); | 285 host_->DisconnectAllClients(); |
276 } | 286 } |
277 | 287 |
278 // Helper method to disconnect client 1 from the host. | 288 // Helper method to disconnect client 1 from the host. |
279 void DisconnectClient1() { | 289 void DisconnectClient1() { |
280 NotifyClientSessionClosed(0); | 290 NotifyClientSessionClosed(0); |
281 } | 291 } |
282 | 292 |
283 // Notify |host_| that the authenticating client has been rejected. | 293 // Notify |host_| that the authenticating client has been rejected. |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 ExpectClientDisconnected(0, true, video_packet_sent, | 711 ExpectClientDisconnected(0, true, video_packet_sent, |
702 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost)); | 712 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost)); |
703 EXPECT_CALL(host_status_observer_, OnShutdown()); | 713 EXPECT_CALL(host_status_observer_, OnShutdown()); |
704 | 714 |
705 host_->Start(xmpp_login_); | 715 host_->Start(xmpp_login_); |
706 SimulateClientConnection(0, true, false); | 716 SimulateClientConnection(0, true, false); |
707 message_loop_.Run(); | 717 message_loop_.Run(); |
708 } | 718 } |
709 | 719 |
710 } // namespace remoting | 720 } // namespace remoting |
OLD | NEW |