OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/callback.h" | 7 #include "base/callback.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 #include "remoting/host/host_mock_objects.h" | 29 #include "remoting/host/host_mock_objects.h" |
30 #include "remoting/host/ipc_desktop_environment.h" | 30 #include "remoting/host/ipc_desktop_environment.h" |
31 #include "remoting/protocol/protocol_mock_objects.h" | 31 #include "remoting/protocol/protocol_mock_objects.h" |
32 #include "testing/gmock/include/gmock/gmock.h" | 32 #include "testing/gmock/include/gmock/gmock.h" |
33 #include "testing/gtest/include/gtest/gtest.h" | 33 #include "testing/gtest/include/gtest/gtest.h" |
34 #include "third_party/skia/include/core/SkRegion.h" | 34 #include "third_party/skia/include/core/SkRegion.h" |
35 | 35 |
36 using testing::_; | 36 using testing::_; |
37 using testing::AnyNumber; | 37 using testing::AnyNumber; |
38 using testing::AtLeast; | 38 using testing::AtLeast; |
| 39 using testing::AtMost; |
39 using testing::Return; | 40 using testing::Return; |
40 using testing::ReturnRef; | 41 using testing::ReturnRef; |
41 | 42 |
42 namespace remoting { | 43 namespace remoting { |
43 | 44 |
44 namespace { | 45 namespace { |
45 | 46 |
46 // Receives messages sent from the network process to the daemon. | 47 // Receives messages sent from the network process to the daemon. |
47 class FakeDaemonSender : public IPC::Sender { | 48 class FakeDaemonSender : public IPC::Sender { |
48 public: | 49 public: |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 &daemon_channel_)); | 271 &daemon_channel_)); |
271 desktop_environment_ = desktop_environment_factory_->Create( | 272 desktop_environment_ = desktop_environment_factory_->Create( |
272 client_session_control_factory_.GetWeakPtr()); | 273 client_session_control_factory_.GetWeakPtr()); |
273 | 274 |
274 // Create the input injector. | 275 // Create the input injector. |
275 input_injector_ = desktop_environment_->CreateInputInjector(); | 276 input_injector_ = desktop_environment_->CreateInputInjector(); |
276 | 277 |
277 // Create the screen capturer. | 278 // Create the screen capturer. |
278 video_capturer_ = | 279 video_capturer_ = |
279 desktop_environment_->CreateVideoCapturer(); | 280 desktop_environment_->CreateVideoCapturer(); |
| 281 |
| 282 desktop_environment_->SetCapabilities(std::string()); |
280 } | 283 } |
281 | 284 |
282 void IpcDesktopEnvironmentTest::ConnectTerminal( | 285 void IpcDesktopEnvironmentTest::ConnectTerminal( |
283 int terminal_id, | 286 int terminal_id, |
284 const ScreenResolution& resolution, | 287 const ScreenResolution& resolution, |
285 bool virtual_terminal) { | 288 bool virtual_terminal) { |
286 EXPECT_NE(terminal_id_, terminal_id); | 289 EXPECT_NE(terminal_id_, terminal_id); |
287 | 290 |
288 terminal_id_ = terminal_id; | 291 terminal_id_ = terminal_id; |
289 CreateDesktopProcess(); | 292 CreateDesktopProcess(); |
290 } | 293 } |
291 | 294 |
292 void IpcDesktopEnvironmentTest::DisconnectTerminal(int terminal_id) { | 295 void IpcDesktopEnvironmentTest::DisconnectTerminal(int terminal_id) { |
293 EXPECT_EQ(terminal_id_, terminal_id); | 296 EXPECT_EQ(terminal_id_, terminal_id); |
294 | 297 |
295 // The IPC desktop environment is fully destroyed now. Release the remaining | 298 // The IPC desktop environment is fully destroyed now. Release the remaining |
296 // task runners. | 299 // task runners. |
297 desktop_environment_factory_.reset(); | 300 desktop_environment_factory_.reset(); |
298 } | 301 } |
299 | 302 |
300 DesktopEnvironment* IpcDesktopEnvironmentTest::CreateDesktopEnvironment() { | 303 DesktopEnvironment* IpcDesktopEnvironmentTest::CreateDesktopEnvironment() { |
301 MockDesktopEnvironment* desktop_environment = new MockDesktopEnvironment(); | 304 MockDesktopEnvironment* desktop_environment = new MockDesktopEnvironment(); |
302 EXPECT_CALL(*desktop_environment, CreateAudioCapturerPtr()) | 305 EXPECT_CALL(*desktop_environment, CreateAudioCapturerPtr()) |
303 .Times(0); | 306 .Times(0); |
304 EXPECT_CALL(*desktop_environment, CreateInputInjectorPtr()) | 307 EXPECT_CALL(*desktop_environment, CreateInputInjectorPtr()) |
305 .Times(AnyNumber()) | 308 .Times(AtMost(1)) |
306 .WillRepeatedly(Invoke( | 309 .WillOnce(Invoke( |
307 this, &IpcDesktopEnvironmentTest::CreateInputInjector)); | 310 this, &IpcDesktopEnvironmentTest::CreateInputInjector)); |
308 EXPECT_CALL(*desktop_environment, CreateScreenControlsPtr()) | 311 EXPECT_CALL(*desktop_environment, CreateScreenControlsPtr()) |
309 .Times(AnyNumber()); | 312 .Times(AtMost(1)); |
310 EXPECT_CALL(*desktop_environment, CreateVideoCapturerPtr()) | 313 EXPECT_CALL(*desktop_environment, CreateVideoCapturerPtr()) |
311 .Times(AnyNumber()) | 314 .Times(AtMost(1)) |
312 .WillRepeatedly(Invoke( | 315 .WillOnce(Invoke( |
313 this, &IpcDesktopEnvironmentTest::CreateVideoCapturer)); | 316 this, &IpcDesktopEnvironmentTest::CreateVideoCapturer)); |
| 317 EXPECT_CALL(*desktop_environment, GetCapabilities()) |
| 318 .Times(AtMost(1)); |
| 319 EXPECT_CALL(*desktop_environment, SetCapabilities(_)) |
| 320 .Times(AtMost(1)); |
314 | 321 |
315 // Let tests know that the remote desktop environment is created. | 322 // Let tests know that the remote desktop environment is created. |
316 message_loop_.PostTask(FROM_HERE, setup_run_loop_->QuitClosure()); | 323 message_loop_.PostTask(FROM_HERE, setup_run_loop_->QuitClosure()); |
317 | 324 |
318 return desktop_environment; | 325 return desktop_environment; |
319 } | 326 } |
320 | 327 |
321 InputInjector* IpcDesktopEnvironmentTest::CreateInputInjector() { | 328 InputInjector* IpcDesktopEnvironmentTest::CreateInputInjector() { |
322 EXPECT_TRUE(remote_input_injector_ == NULL); | 329 EXPECT_TRUE(remote_input_injector_ == NULL); |
323 remote_input_injector_ = new MockInputInjector(); | 330 remote_input_injector_ = new MockInputInjector(); |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 event.set_x(0); | 658 event.set_x(0); |
652 event.set_y(0); | 659 event.set_y(0); |
653 input_injector_->InjectMouseEvent(event); | 660 input_injector_->InjectMouseEvent(event); |
654 | 661 |
655 task_runner_ = NULL; | 662 task_runner_ = NULL; |
656 io_task_runner_ = NULL; | 663 io_task_runner_ = NULL; |
657 main_run_loop_.Run(); | 664 main_run_loop_.Run(); |
658 } | 665 } |
659 | 666 |
660 } // namespace remoting | 667 } // namespace remoting |
OLD | NEW |