| 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/message_loop/message_loop.h" | 5 #include "base/message_loop/message_loop.h" |
| 6 #include "remoting/base/auto_thread_task_runner.h" | 6 #include "remoting/base/auto_thread_task_runner.h" |
| 7 #include "remoting/base/constants.h" | 7 #include "remoting/base/constants.h" |
| 8 #include "remoting/host/audio_capturer.h" | 8 #include "remoting/host/audio_capturer.h" |
| 9 #include "remoting/host/client_session.h" | 9 #include "remoting/host/client_session.h" |
| 10 #include "remoting/host/desktop_environment.h" | 10 #include "remoting/host/desktop_environment.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 DesktopEnvironment* CreateDesktopEnvironment(); | 76 DesktopEnvironment* CreateDesktopEnvironment(); |
| 77 | 77 |
| 78 // Returns |input_injector_| created and initialized by SetUp(), to mock | 78 // Returns |input_injector_| created and initialized by SetUp(), to mock |
| 79 // DesktopEnvironment::CreateInputInjector(). | 79 // DesktopEnvironment::CreateInputInjector(). |
| 80 InputInjector* CreateInputInjector(); | 80 InputInjector* CreateInputInjector(); |
| 81 | 81 |
| 82 // Creates a fake webrtc::ScreenCapturer, to mock | 82 // Creates a fake webrtc::ScreenCapturer, to mock |
| 83 // DesktopEnvironment::CreateVideoCapturer(). | 83 // DesktopEnvironment::CreateVideoCapturer(). |
| 84 webrtc::ScreenCapturer* CreateVideoCapturer(); | 84 webrtc::ScreenCapturer* CreateVideoCapturer(); |
| 85 | 85 |
| 86 // Creates a MockMouseCursorMonitor, to mock | |
| 87 // DesktopEnvironment::CreateMouseCursorMonitor | |
| 88 webrtc::MouseCursorMonitor* CreateMouseCursorMonitor(); | |
| 89 | |
| 90 // Notifies the client session that the client connection has been | 86 // Notifies the client session that the client connection has been |
| 91 // authenticated and channels have been connected. This effectively enables | 87 // authenticated and channels have been connected. This effectively enables |
| 92 // the input pipe line and starts video capturing. | 88 // the input pipe line and starts video capturing. |
| 93 void ConnectClientSession(); | 89 void ConnectClientSession(); |
| 94 | 90 |
| 95 // Invoked when the last reference to the AutoThreadTaskRunner has been | 91 // Invoked when the last reference to the AutoThreadTaskRunner has been |
| 96 // released and quits the message loop to finish the test. | 92 // released and quits the message loop to finish the test. |
| 97 void QuitMainMessageLoop(); | 93 void QuitMainMessageLoop(); |
| 98 | 94 |
| 99 // Message loop passed to |client_session_| to perform all functions on. | 95 // Message loop passed to |client_session_| to perform all functions on. |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 DesktopEnvironment* ClientSessionTest::CreateDesktopEnvironment() { | 191 DesktopEnvironment* ClientSessionTest::CreateDesktopEnvironment() { |
| 196 MockDesktopEnvironment* desktop_environment = new MockDesktopEnvironment(); | 192 MockDesktopEnvironment* desktop_environment = new MockDesktopEnvironment(); |
| 197 EXPECT_CALL(*desktop_environment, CreateAudioCapturerPtr()) | 193 EXPECT_CALL(*desktop_environment, CreateAudioCapturerPtr()) |
| 198 .Times(0); | 194 .Times(0); |
| 199 EXPECT_CALL(*desktop_environment, CreateInputInjectorPtr()) | 195 EXPECT_CALL(*desktop_environment, CreateInputInjectorPtr()) |
| 200 .WillOnce(Invoke(this, &ClientSessionTest::CreateInputInjector)); | 196 .WillOnce(Invoke(this, &ClientSessionTest::CreateInputInjector)); |
| 201 EXPECT_CALL(*desktop_environment, CreateScreenControlsPtr()) | 197 EXPECT_CALL(*desktop_environment, CreateScreenControlsPtr()) |
| 202 .Times(AtMost(1)); | 198 .Times(AtMost(1)); |
| 203 EXPECT_CALL(*desktop_environment, CreateVideoCapturerPtr()) | 199 EXPECT_CALL(*desktop_environment, CreateVideoCapturerPtr()) |
| 204 .WillOnce(Invoke(this, &ClientSessionTest::CreateVideoCapturer)); | 200 .WillOnce(Invoke(this, &ClientSessionTest::CreateVideoCapturer)); |
| 205 EXPECT_CALL(*desktop_environment, CreateMouseCursorMonitorPtr()) | |
| 206 .WillOnce(Invoke(this, &ClientSessionTest::CreateMouseCursorMonitor)); | |
| 207 EXPECT_CALL(*desktop_environment, GetCapabilities()) | 201 EXPECT_CALL(*desktop_environment, GetCapabilities()) |
| 208 .Times(AtMost(1)); | 202 .Times(AtMost(1)); |
| 209 EXPECT_CALL(*desktop_environment, SetCapabilities(_)) | 203 EXPECT_CALL(*desktop_environment, SetCapabilities(_)) |
| 210 .Times(AtMost(1)); | 204 .Times(AtMost(1)); |
| 211 | 205 |
| 212 return desktop_environment; | 206 return desktop_environment; |
| 213 } | 207 } |
| 214 | 208 |
| 215 InputInjector* ClientSessionTest::CreateInputInjector() { | 209 InputInjector* ClientSessionTest::CreateInputInjector() { |
| 216 EXPECT_TRUE(input_injector_); | 210 EXPECT_TRUE(input_injector_); |
| 217 return input_injector_.release(); | 211 return input_injector_.release(); |
| 218 } | 212 } |
| 219 | 213 |
| 220 webrtc::ScreenCapturer* ClientSessionTest::CreateVideoCapturer() { | 214 webrtc::ScreenCapturer* ClientSessionTest::CreateVideoCapturer() { |
| 221 return new ScreenCapturerFake(); | 215 return new ScreenCapturerFake(); |
| 222 } | 216 } |
| 223 | 217 |
| 224 webrtc::MouseCursorMonitor* ClientSessionTest::CreateMouseCursorMonitor() { | |
| 225 return new MockMouseCursorMonitor(); | |
| 226 } | |
| 227 | |
| 228 void ClientSessionTest::ConnectClientSession() { | 218 void ClientSessionTest::ConnectClientSession() { |
| 229 client_session_->OnConnectionAuthenticated(client_session_->connection()); | 219 client_session_->OnConnectionAuthenticated(client_session_->connection()); |
| 230 client_session_->OnConnectionChannelsConnected(client_session_->connection()); | 220 client_session_->OnConnectionChannelsConnected(client_session_->connection()); |
| 231 } | 221 } |
| 232 | 222 |
| 233 void ClientSessionTest::QuitMainMessageLoop() { | 223 void ClientSessionTest::QuitMainMessageLoop() { |
| 234 message_loop_.PostTask(FROM_HERE, base::MessageLoop::QuitClosure()); | 224 message_loop_.PostTask(FROM_HERE, base::MessageLoop::QuitClosure()); |
| 235 } | 225 } |
| 236 | 226 |
| 237 MATCHER_P2(EqualsClipboardEvent, m, d, "") { | 227 MATCHER_P2(EqualsClipboardEvent, m, d, "") { |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 .After(connected) | 533 .After(connected) |
| 544 .WillOnce(DoAll( | 534 .WillOnce(DoAll( |
| 545 InvokeWithoutArgs(this, &ClientSessionTest::DisconnectClientSession), | 535 InvokeWithoutArgs(this, &ClientSessionTest::DisconnectClientSession), |
| 546 InvokeWithoutArgs(this, &ClientSessionTest::StopClientSession))); | 536 InvokeWithoutArgs(this, &ClientSessionTest::StopClientSession))); |
| 547 | 537 |
| 548 ConnectClientSession(); | 538 ConnectClientSession(); |
| 549 message_loop_.Run(); | 539 message_loop_.Run(); |
| 550 } | 540 } |
| 551 | 541 |
| 552 } // namespace remoting | 542 } // namespace remoting |
| OLD | NEW |