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_desktop_capturer.h" |
18 #include "remoting/host/fake_host_extension.h" | 19 #include "remoting/host/fake_host_extension.h" |
19 #include "remoting/host/fake_mouse_cursor_monitor.h" | 20 #include "remoting/host/fake_mouse_cursor_monitor.h" |
20 #include "remoting/host/fake_screen_capturer.h" | |
21 #include "remoting/host/host_extension.h" | 21 #include "remoting/host/host_extension.h" |
22 #include "remoting/host/host_extension_session.h" | 22 #include "remoting/host/host_extension_session.h" |
23 #include "remoting/host/host_mock_objects.h" | 23 #include "remoting/host/host_mock_objects.h" |
24 #include "remoting/protocol/protocol_mock_objects.h" | 24 #include "remoting/protocol/protocol_mock_objects.h" |
25 #include "testing/gmock/include/gmock/gmock-matchers.h" | 25 #include "testing/gmock/include/gmock/gmock-matchers.h" |
26 #include "testing/gmock_mutant.h" | 26 #include "testing/gmock_mutant.h" |
27 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
28 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" | 28 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" |
29 #include "third_party/webrtc/modules/desktop_capture/desktop_region.h" | 29 #include "third_party/webrtc/modules/desktop_capture/desktop_region.h" |
30 #include "third_party/webrtc/modules/desktop_capture/screen_capturer_mock_object
s.h" | 30 #include "third_party/webrtc/modules/desktop_capture/screen_capturer_mock_object
s.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 // Creates the client session. | 128 // Creates the client session. |
129 void CreateClientSession(); | 129 void CreateClientSession(); |
130 | 130 |
131 // Disconnects the client session. | 131 // Disconnects the client session. |
132 void DisconnectClientSession(); | 132 void DisconnectClientSession(); |
133 | 133 |
134 // Stops and releases the ClientSession, allowing the MessageLoop to quit. | 134 // Stops and releases the ClientSession, allowing the MessageLoop to quit. |
135 void StopClientSession(); | 135 void StopClientSession(); |
136 | 136 |
137 protected: | 137 protected: |
138 // Creates a DesktopEnvironment with a fake webrtc::ScreenCapturer, to mock | 138 // Creates a DesktopEnvironment with a fake webrtc::DesktopCapturer, to mock |
139 // DesktopEnvironmentFactory::Create(). | 139 // DesktopEnvironmentFactory::Create(). |
140 DesktopEnvironment* CreateDesktopEnvironment(); | 140 DesktopEnvironment* CreateDesktopEnvironment(); |
141 | 141 |
142 // Returns |input_injector_| created and initialized by SetUp(), to mock | 142 // Returns |input_injector_| created and initialized by SetUp(), to mock |
143 // DesktopEnvironment::CreateInputInjector(). | 143 // DesktopEnvironment::CreateInputInjector(). |
144 InputInjector* CreateInputInjector(); | 144 InputInjector* CreateInputInjector(); |
145 | 145 |
146 // Creates a fake webrtc::ScreenCapturer, to mock | 146 // Creates a fake webrtc::DesktopCapturer, to mock |
147 // DesktopEnvironment::CreateVideoCapturer(). | 147 // DesktopEnvironment::CreateVideoCapturer(). |
148 webrtc::ScreenCapturer* CreateVideoCapturer(); | 148 webrtc::DesktopCapturer* CreateVideoCapturer(); |
149 | 149 |
150 // Creates a MockMouseCursorMonitor, to mock | 150 // Creates a MockMouseCursorMonitor, to mock |
151 // DesktopEnvironment::CreateMouseCursorMonitor | 151 // DesktopEnvironment::CreateMouseCursorMonitor |
152 webrtc::MouseCursorMonitor* CreateMouseCursorMonitor(); | 152 webrtc::MouseCursorMonitor* CreateMouseCursorMonitor(); |
153 | 153 |
154 // Notifies the client session that the client connection has been | 154 // Notifies the client session that the client connection has been |
155 // authenticated and channels have been connected. This effectively enables | 155 // authenticated and channels have been connected. This effectively enables |
156 // the input pipe line and starts video capturing. | 156 // the input pipe line and starts video capturing. |
157 void ConnectClientSession(); | 157 void ConnectClientSession(); |
158 | 158 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 .Times(AtMost(1)); | 294 .Times(AtMost(1)); |
295 | 295 |
296 return desktop_environment; | 296 return desktop_environment; |
297 } | 297 } |
298 | 298 |
299 InputInjector* ClientSessionTest::CreateInputInjector() { | 299 InputInjector* ClientSessionTest::CreateInputInjector() { |
300 EXPECT_TRUE(input_injector_); | 300 EXPECT_TRUE(input_injector_); |
301 return input_injector_.release(); | 301 return input_injector_.release(); |
302 } | 302 } |
303 | 303 |
304 webrtc::ScreenCapturer* ClientSessionTest::CreateVideoCapturer() { | 304 webrtc::DesktopCapturer* ClientSessionTest::CreateVideoCapturer() { |
305 return new FakeScreenCapturer(); | 305 return new FakeDesktopCapturer(); |
306 } | 306 } |
307 | 307 |
308 webrtc::MouseCursorMonitor* ClientSessionTest::CreateMouseCursorMonitor() { | 308 webrtc::MouseCursorMonitor* ClientSessionTest::CreateMouseCursorMonitor() { |
309 return new FakeMouseCursorMonitor(); | 309 return new FakeMouseCursorMonitor(); |
310 } | 310 } |
311 | 311 |
312 void ClientSessionTest::ConnectClientSession() { | 312 void ClientSessionTest::ConnectClientSession() { |
313 client_session_->OnConnectionAuthenticated(client_session_->connection()); | 313 client_session_->OnConnectionAuthenticated(client_session_->connection()); |
314 client_session_->OnConnectionChannelsConnected(client_session_->connection()); | 314 client_session_->OnConnectionChannelsConnected(client_session_->connection()); |
315 } | 315 } |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 EXPECT_CALL(*input_injector_, StartPtr(_)) | 589 EXPECT_CALL(*input_injector_, StartPtr(_)) |
590 .After(authenticated); | 590 .After(authenticated); |
591 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_)) | 591 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_)) |
592 .After(authenticated); | 592 .After(authenticated); |
593 EXPECT_CALL(session_event_handler_, OnSessionClosed(_)) | 593 EXPECT_CALL(session_event_handler_, OnSessionClosed(_)) |
594 .After(authenticated); | 594 .After(authenticated); |
595 | 595 |
596 Expectation connected = authenticated; | 596 Expectation connected = authenticated; |
597 | 597 |
598 int input_x[3] = { -999, 100, 999 }; | 598 int input_x[3] = { -999, 100, 999 }; |
599 int expected_x[3] = { 0, 100, FakeScreenCapturer::kWidth - 1 }; | 599 int expected_x[3] = { 0, 100, FakeDesktopCapturer::kWidth - 1 }; |
600 int input_y[3] = { -999, 50, 999 }; | 600 int input_y[3] = { -999, 50, 999 }; |
601 int expected_y[3] = { 0, 50, FakeScreenCapturer::kHeight - 1 }; | 601 int expected_y[3] = { 0, 50, FakeDesktopCapturer::kHeight - 1 }; |
602 | 602 |
603 protocol::MouseEvent expected_event; | 603 protocol::MouseEvent expected_event; |
604 for (int j = 0; j < 3; j++) { | 604 for (int j = 0; j < 3; j++) { |
605 for (int i = 0; i < 3; i++) { | 605 for (int i = 0; i < 3; i++) { |
606 protocol::MouseEvent injected_event; | 606 protocol::MouseEvent injected_event; |
607 injected_event.set_x(input_x[i]); | 607 injected_event.set_x(input_x[i]); |
608 injected_event.set_y(input_y[j]); | 608 injected_event.set_y(input_y[j]); |
609 | 609 |
610 if (i == 0 && j == 0) { | 610 if (i == 0 && j == 0) { |
611 // Inject the 1st event once a video packet has been received. | 611 // Inject the 1st event once a video packet has been received. |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
808 | 808 |
809 DisconnectClientSession(); | 809 DisconnectClientSession(); |
810 StopClientSession(); | 810 StopClientSession(); |
811 | 811 |
812 // ext1 was instantiated and wrapped the video capturer. | 812 // ext1 was instantiated and wrapped the video capturer. |
813 EXPECT_TRUE(extension.was_instantiated()); | 813 EXPECT_TRUE(extension.was_instantiated()); |
814 EXPECT_TRUE(extension.has_wrapped_video_capturer()); | 814 EXPECT_TRUE(extension.has_wrapped_video_capturer()); |
815 } | 815 } |
816 | 816 |
817 } // namespace remoting | 817 } // namespace remoting |
OLD | NEW |