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 <algorithm> | 5 #include <algorithm> |
6 #include <string> | 6 #include <string> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "base/test/test_simple_task_runner.h" | 12 #include "base/test/test_simple_task_runner.h" |
13 #include "remoting/base/auto_thread_task_runner.h" | 13 #include "remoting/base/auto_thread_task_runner.h" |
14 #include "remoting/base/constants.h" | 14 #include "remoting/base/constants.h" |
15 #include "remoting/host/audio_capturer.h" | 15 #include "remoting/host/audio_capturer.h" |
16 #include "remoting/host/client_session.h" | 16 #include "remoting/host/client_session.h" |
17 #include "remoting/host/desktop_environment.h" | 17 #include "remoting/host/desktop_environment.h" |
18 #include "remoting/host/fake_host_extension.h" | 18 #include "remoting/host/fake_host_extension.h" |
| 19 #include "remoting/host/fake_mouse_cursor_monitor.h" |
19 #include "remoting/host/fake_screen_capturer.h" | 20 #include "remoting/host/fake_screen_capturer.h" |
20 #include "remoting/host/host_extension.h" | 21 #include "remoting/host/host_extension.h" |
21 #include "remoting/host/host_extension_session.h" | 22 #include "remoting/host/host_extension_session.h" |
22 #include "remoting/host/host_mock_objects.h" | 23 #include "remoting/host/host_mock_objects.h" |
23 #include "remoting/protocol/protocol_mock_objects.h" | 24 #include "remoting/protocol/protocol_mock_objects.h" |
24 #include "testing/gmock/include/gmock/gmock-matchers.h" | 25 #include "testing/gmock/include/gmock/gmock-matchers.h" |
25 #include "testing/gmock_mutant.h" | 26 #include "testing/gmock_mutant.h" |
26 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
27 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" | 28 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" |
28 #include "third_party/webrtc/modules/desktop_capture/desktop_region.h" | 29 #include "third_party/webrtc/modules/desktop_capture/desktop_region.h" |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 DesktopEnvironment* CreateDesktopEnvironment(); | 140 DesktopEnvironment* CreateDesktopEnvironment(); |
140 | 141 |
141 // Returns |input_injector_| created and initialized by SetUp(), to mock | 142 // Returns |input_injector_| created and initialized by SetUp(), to mock |
142 // DesktopEnvironment::CreateInputInjector(). | 143 // DesktopEnvironment::CreateInputInjector(). |
143 InputInjector* CreateInputInjector(); | 144 InputInjector* CreateInputInjector(); |
144 | 145 |
145 // Creates a fake webrtc::ScreenCapturer, to mock | 146 // Creates a fake webrtc::ScreenCapturer, to mock |
146 // DesktopEnvironment::CreateVideoCapturer(). | 147 // DesktopEnvironment::CreateVideoCapturer(). |
147 webrtc::ScreenCapturer* CreateVideoCapturer(); | 148 webrtc::ScreenCapturer* CreateVideoCapturer(); |
148 | 149 |
| 150 // Creates a MockMouseCursorMonitor, to mock |
| 151 // DesktopEnvironment::CreateMouseCursorMonitor |
| 152 webrtc::MouseCursorMonitor* CreateMouseCursorMonitor(); |
| 153 |
149 // Notifies the client session that the client connection has been | 154 // Notifies the client session that the client connection has been |
150 // authenticated and channels have been connected. This effectively enables | 155 // authenticated and channels have been connected. This effectively enables |
151 // the input pipe line and starts video capturing. | 156 // the input pipe line and starts video capturing. |
152 void ConnectClientSession(); | 157 void ConnectClientSession(); |
153 | 158 |
154 // Creates expectation that simulates client supporting same capabilities as | 159 // Creates expectation that simulates client supporting same capabilities as |
155 // host. | 160 // host. |
156 void SetMatchCapabilitiesExpectation(); | 161 void SetMatchCapabilitiesExpectation(); |
157 | 162 |
158 // Creates expectations to send an extension message and to disconnect | 163 // Creates expectations to send an extension message and to disconnect |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 DesktopEnvironment* ClientSessionTest::CreateDesktopEnvironment() { | 277 DesktopEnvironment* ClientSessionTest::CreateDesktopEnvironment() { |
273 MockDesktopEnvironment* desktop_environment = new MockDesktopEnvironment(); | 278 MockDesktopEnvironment* desktop_environment = new MockDesktopEnvironment(); |
274 EXPECT_CALL(*desktop_environment, CreateAudioCapturerPtr()) | 279 EXPECT_CALL(*desktop_environment, CreateAudioCapturerPtr()) |
275 .Times(0); | 280 .Times(0); |
276 EXPECT_CALL(*desktop_environment, CreateInputInjectorPtr()) | 281 EXPECT_CALL(*desktop_environment, CreateInputInjectorPtr()) |
277 .WillOnce(Invoke(this, &ClientSessionTest::CreateInputInjector)); | 282 .WillOnce(Invoke(this, &ClientSessionTest::CreateInputInjector)); |
278 EXPECT_CALL(*desktop_environment, CreateScreenControlsPtr()) | 283 EXPECT_CALL(*desktop_environment, CreateScreenControlsPtr()) |
279 .Times(AtMost(1)); | 284 .Times(AtMost(1)); |
280 EXPECT_CALL(*desktop_environment, CreateVideoCapturerPtr()) | 285 EXPECT_CALL(*desktop_environment, CreateVideoCapturerPtr()) |
281 .WillRepeatedly(Invoke(this, &ClientSessionTest::CreateVideoCapturer)); | 286 .WillRepeatedly(Invoke(this, &ClientSessionTest::CreateVideoCapturer)); |
| 287 EXPECT_CALL(*desktop_environment, CreateMouseCursorMonitorPtr()) |
| 288 .WillRepeatedly( |
| 289 Invoke(this, &ClientSessionTest::CreateMouseCursorMonitor)); |
282 EXPECT_CALL(*desktop_environment, GetCapabilities()) | 290 EXPECT_CALL(*desktop_environment, GetCapabilities()) |
283 .Times(AtMost(1)) | 291 .Times(AtMost(1)) |
284 .WillOnce(Return(kDefaultTestCapability)); | 292 .WillOnce(Return(kDefaultTestCapability)); |
285 EXPECT_CALL(*desktop_environment, SetCapabilities(_)) | 293 EXPECT_CALL(*desktop_environment, SetCapabilities(_)) |
286 .Times(AtMost(1)); | 294 .Times(AtMost(1)); |
287 | 295 |
288 return desktop_environment; | 296 return desktop_environment; |
289 } | 297 } |
290 | 298 |
291 InputInjector* ClientSessionTest::CreateInputInjector() { | 299 InputInjector* ClientSessionTest::CreateInputInjector() { |
292 EXPECT_TRUE(input_injector_); | 300 EXPECT_TRUE(input_injector_); |
293 return input_injector_.release(); | 301 return input_injector_.release(); |
294 } | 302 } |
295 | 303 |
296 webrtc::ScreenCapturer* ClientSessionTest::CreateVideoCapturer() { | 304 webrtc::ScreenCapturer* ClientSessionTest::CreateVideoCapturer() { |
297 return new FakeScreenCapturer(); | 305 return new FakeScreenCapturer(); |
298 } | 306 } |
299 | 307 |
| 308 webrtc::MouseCursorMonitor* ClientSessionTest::CreateMouseCursorMonitor() { |
| 309 return new FakeMouseCursorMonitor(); |
| 310 } |
| 311 |
300 void ClientSessionTest::ConnectClientSession() { | 312 void ClientSessionTest::ConnectClientSession() { |
301 client_session_->OnConnectionAuthenticated(client_session_->connection()); | 313 client_session_->OnConnectionAuthenticated(client_session_->connection()); |
302 client_session_->OnConnectionChannelsConnected(client_session_->connection()); | 314 client_session_->OnConnectionChannelsConnected(client_session_->connection()); |
303 } | 315 } |
304 | 316 |
305 void ClientSessionTest::SetMatchCapabilitiesExpectation() { | 317 void ClientSessionTest::SetMatchCapabilitiesExpectation() { |
306 // Set the client to report the same capabilities as the host. | 318 // Set the client to report the same capabilities as the host. |
307 EXPECT_CALL(client_stub_, SetCapabilities(_)) | 319 EXPECT_CALL(client_stub_, SetCapabilities(_)) |
308 .Times(AtMost(1)) | 320 .Times(AtMost(1)) |
309 .WillOnce(Invoke(client_session_.get(), &ClientSession::SetCapabilities)); | 321 .WillOnce(Invoke(client_session_.get(), &ClientSession::SetCapabilities)); |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
796 | 808 |
797 DisconnectClientSession(); | 809 DisconnectClientSession(); |
798 StopClientSession(); | 810 StopClientSession(); |
799 | 811 |
800 // ext1 was instantiated and wrapped the video capturer. | 812 // ext1 was instantiated and wrapped the video capturer. |
801 EXPECT_TRUE(extension.was_instantiated()); | 813 EXPECT_TRUE(extension.was_instantiated()); |
802 EXPECT_TRUE(extension.has_wrapped_video_capturer()); | 814 EXPECT_TRUE(extension.has_wrapped_video_capturer()); |
803 } | 815 } |
804 | 816 |
805 } // namespace remoting | 817 } // namespace remoting |
OLD | NEW |