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_split.h" | 11 #include "base/strings/string_split.h" |
12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
13 #include "base/test/test_simple_task_runner.h" | 13 #include "base/test/test_simple_task_runner.h" |
14 #include "remoting/base/auto_thread_task_runner.h" | 14 #include "remoting/base/auto_thread_task_runner.h" |
15 #include "remoting/base/constants.h" | 15 #include "remoting/base/constants.h" |
16 #include "remoting/host/audio_capturer.h" | 16 #include "remoting/host/audio_capturer.h" |
17 #include "remoting/host/client_session.h" | 17 #include "remoting/host/client_session.h" |
18 #include "remoting/host/desktop_environment.h" | 18 #include "remoting/host/desktop_environment.h" |
19 #include "remoting/host/fake_desktop_capturer.h" | |
20 #include "remoting/host/fake_host_extension.h" | 19 #include "remoting/host/fake_host_extension.h" |
21 #include "remoting/host/fake_mouse_cursor_monitor.h" | 20 #include "remoting/host/fake_mouse_cursor_monitor.h" |
22 #include "remoting/host/host_extension.h" | 21 #include "remoting/host/host_extension.h" |
23 #include "remoting/host/host_extension_session.h" | 22 #include "remoting/host/host_extension_session.h" |
24 #include "remoting/host/host_mock_objects.h" | 23 #include "remoting/host/host_mock_objects.h" |
| 24 #include "remoting/protocol/fake_desktop_capturer.h" |
25 #include "remoting/protocol/protocol_mock_objects.h" | 25 #include "remoting/protocol/protocol_mock_objects.h" |
26 #include "remoting/protocol/test_event_matchers.h" | 26 #include "remoting/protocol/test_event_matchers.h" |
27 #include "testing/gmock/include/gmock/gmock-matchers.h" | 27 #include "testing/gmock/include/gmock/gmock-matchers.h" |
28 #include "testing/gmock_mutant.h" | 28 #include "testing/gmock_mutant.h" |
29 #include "testing/gtest/include/gtest/gtest.h" | 29 #include "testing/gtest/include/gtest/gtest.h" |
30 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" | 30 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" |
31 #include "third_party/webrtc/modules/desktop_capture/desktop_region.h" | 31 #include "third_party/webrtc/modules/desktop_capture/desktop_region.h" |
32 #include "third_party/webrtc/modules/desktop_capture/screen_capturer_mock_object
s.h" | 32 #include "third_party/webrtc/modules/desktop_capture/screen_capturer_mock_object
s.h" |
33 | 33 |
34 namespace remoting { | 34 namespace remoting { |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 | 289 |
290 return desktop_environment; | 290 return desktop_environment; |
291 } | 291 } |
292 | 292 |
293 InputInjector* ClientSessionTest::CreateInputInjector() { | 293 InputInjector* ClientSessionTest::CreateInputInjector() { |
294 EXPECT_TRUE(input_injector_); | 294 EXPECT_TRUE(input_injector_); |
295 return input_injector_.release(); | 295 return input_injector_.release(); |
296 } | 296 } |
297 | 297 |
298 webrtc::DesktopCapturer* ClientSessionTest::CreateVideoCapturer() { | 298 webrtc::DesktopCapturer* ClientSessionTest::CreateVideoCapturer() { |
299 return new FakeDesktopCapturer(); | 299 return new protocol::FakeDesktopCapturer(); |
300 } | 300 } |
301 | 301 |
302 webrtc::MouseCursorMonitor* ClientSessionTest::CreateMouseCursorMonitor() { | 302 webrtc::MouseCursorMonitor* ClientSessionTest::CreateMouseCursorMonitor() { |
303 return new FakeMouseCursorMonitor(); | 303 return new FakeMouseCursorMonitor(); |
304 } | 304 } |
305 | 305 |
306 void ClientSessionTest::ConnectClientSession() { | 306 void ClientSessionTest::ConnectClientSession() { |
307 // Stubs should be set only after connection is authenticated. | 307 // Stubs should be set only after connection is authenticated. |
308 EXPECT_FALSE(connection_->clipboard_stub()); | 308 EXPECT_FALSE(connection_->clipboard_stub()); |
309 EXPECT_FALSE(connection_->input_stub()); | 309 EXPECT_FALSE(connection_->input_stub()); |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_)) | 550 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_)) |
551 .WillOnce(Return(true)); | 551 .WillOnce(Return(true)); |
552 EXPECT_CALL(*input_injector_, StartPtr(_)).After(authenticated); | 552 EXPECT_CALL(*input_injector_, StartPtr(_)).After(authenticated); |
553 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_)) | 553 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_)) |
554 .After(authenticated); | 554 .After(authenticated); |
555 EXPECT_CALL(session_event_handler_, OnSessionClosed(_)).After(authenticated); | 555 EXPECT_CALL(session_event_handler_, OnSessionClosed(_)).After(authenticated); |
556 | 556 |
557 Expectation connected = authenticated; | 557 Expectation connected = authenticated; |
558 | 558 |
559 int input_x[3] = { -999, 100, 999 }; | 559 int input_x[3] = { -999, 100, 999 }; |
560 int expected_x[3] = { 0, 100, FakeDesktopCapturer::kWidth - 1 }; | 560 int expected_x[3] = { 0, 100, protocol::FakeDesktopCapturer::kWidth - 1 }; |
561 int input_y[3] = { -999, 50, 999 }; | 561 int input_y[3] = { -999, 50, 999 }; |
562 int expected_y[3] = { 0, 50, FakeDesktopCapturer::kHeight - 1 }; | 562 int expected_y[3] = { 0, 50, protocol::FakeDesktopCapturer::kHeight - 1 }; |
563 | 563 |
564 protocol::MouseEvent expected_event; | 564 protocol::MouseEvent expected_event; |
565 for (int j = 0; j < 3; j++) { | 565 for (int j = 0; j < 3; j++) { |
566 for (int i = 0; i < 3; i++) { | 566 for (int i = 0; i < 3; i++) { |
567 protocol::MouseEvent injected_event; | 567 protocol::MouseEvent injected_event; |
568 injected_event.set_x(input_x[i]); | 568 injected_event.set_x(input_x[i]); |
569 injected_event.set_y(input_y[j]); | 569 injected_event.set_y(input_y[j]); |
570 | 570 |
571 if (i == 0 && j == 0) { | 571 if (i == 0 && j == 0) { |
572 // Inject the 1st event once a video packet has been received. | 572 // Inject the 1st event once a video packet has been received. |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
768 | 768 |
769 DisconnectClientSession(); | 769 DisconnectClientSession(); |
770 StopClientSession(); | 770 StopClientSession(); |
771 | 771 |
772 // ext1 was instantiated and wrapped the video capturer. | 772 // ext1 was instantiated and wrapped the video capturer. |
773 EXPECT_TRUE(extension.was_instantiated()); | 773 EXPECT_TRUE(extension.was_instantiated()); |
774 EXPECT_TRUE(extension.has_wrapped_video_capturer()); | 774 EXPECT_TRUE(extension.has_wrapped_video_capturer()); |
775 } | 775 } |
776 | 776 |
777 } // namespace remoting | 777 } // namespace remoting |
OLD | NEW |