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.h" | 5 #include "base/message_loop.h" |
6 #include "media/video/capture/screen/screen_capturer_fake.h" | |
7 #include "media/video/capture/screen/screen_capturer_mock_objects.h" | |
8 #include "remoting/base/auto_thread_task_runner.h" | 6 #include "remoting/base/auto_thread_task_runner.h" |
9 #include "remoting/base/constants.h" | 7 #include "remoting/base/constants.h" |
10 #include "remoting/host/audio_capturer.h" | 8 #include "remoting/host/audio_capturer.h" |
11 #include "remoting/host/client_session.h" | 9 #include "remoting/host/client_session.h" |
12 #include "remoting/host/desktop_environment.h" | 10 #include "remoting/host/desktop_environment.h" |
13 #include "remoting/host/host_mock_objects.h" | 11 #include "remoting/host/host_mock_objects.h" |
| 12 #include "remoting/host/screen_capturer_fake.h" |
14 #include "remoting/protocol/protocol_mock_objects.h" | 13 #include "remoting/protocol/protocol_mock_objects.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
16 #include "third_party/webrtc/modules/desktop_capture/desktop_region.h" | 15 #include "third_party/webrtc/modules/desktop_capture/desktop_region.h" |
| 16 #include "third_party/webrtc/modules/desktop_capture/screen_capturer_mock_object
s.h" |
17 | 17 |
18 namespace remoting { | 18 namespace remoting { |
19 | 19 |
20 using protocol::MockConnectionToClient; | 20 using protocol::MockConnectionToClient; |
21 using protocol::MockClientStub; | 21 using protocol::MockClientStub; |
22 using protocol::MockHostStub; | 22 using protocol::MockHostStub; |
23 using protocol::MockInputStub; | 23 using protocol::MockInputStub; |
24 using protocol::MockSession; | 24 using protocol::MockSession; |
25 using protocol::MockVideoStub; | 25 using protocol::MockVideoStub; |
26 using protocol::SessionConfig; | 26 using protocol::SessionConfig; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 virtual void SetUp() OVERRIDE; | 62 virtual void SetUp() OVERRIDE; |
63 virtual void TearDown() OVERRIDE; | 63 virtual void TearDown() OVERRIDE; |
64 | 64 |
65 // Disconnects the client session. | 65 // Disconnects the client session. |
66 void DisconnectClientSession(); | 66 void DisconnectClientSession(); |
67 | 67 |
68 // Stops and releases the ClientSession, allowing the MessageLoop to quit. | 68 // Stops and releases the ClientSession, allowing the MessageLoop to quit. |
69 void StopClientSession(); | 69 void StopClientSession(); |
70 | 70 |
71 protected: | 71 protected: |
72 // Creates a DesktopEnvironment with a fake media::ScreenCapturer, to mock | 72 // Creates a DesktopEnvironment with a fake webrtc::ScreenCapturer, to mock |
73 // DesktopEnvironmentFactory::Create(). | 73 // DesktopEnvironmentFactory::Create(). |
74 DesktopEnvironment* CreateDesktopEnvironment(); | 74 DesktopEnvironment* CreateDesktopEnvironment(); |
75 | 75 |
76 // Returns |input_injector_| created and initialized by SetUp(), to mock | 76 // Returns |input_injector_| created and initialized by SetUp(), to mock |
77 // DesktopEnvironment::CreateInputInjector(). | 77 // DesktopEnvironment::CreateInputInjector(). |
78 InputInjector* CreateInputInjector(); | 78 InputInjector* CreateInputInjector(); |
79 | 79 |
80 // Creates a fake media::ScreenCapturer, to mock | 80 // Creates a fake webrtc::ScreenCapturer, to mock |
81 // DesktopEnvironment::CreateVideoCapturer(). | 81 // DesktopEnvironment::CreateVideoCapturer(). |
82 media::ScreenCapturer* CreateVideoCapturer(); | 82 webrtc::ScreenCapturer* CreateVideoCapturer(); |
83 | 83 |
84 // Notifies the client session that the client connection has been | 84 // Notifies the client session that the client connection has been |
85 // authenticated and channels have been connected. This effectively enables | 85 // authenticated and channels have been connected. This effectively enables |
86 // the input pipe line and starts video capturing. | 86 // the input pipe line and starts video capturing. |
87 void ConnectClientSession(); | 87 void ConnectClientSession(); |
88 | 88 |
89 // Invoked when the last reference to the AutoThreadTaskRunner has been | 89 // Invoked when the last reference to the AutoThreadTaskRunner has been |
90 // released and quits the message loop to finish the test. | 90 // released and quits the message loop to finish the test. |
91 void QuitMainMessageLoop(); | 91 void QuitMainMessageLoop(); |
92 | 92 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 .Times(AtMost(1)); | 202 .Times(AtMost(1)); |
203 | 203 |
204 return desktop_environment; | 204 return desktop_environment; |
205 } | 205 } |
206 | 206 |
207 InputInjector* ClientSessionTest::CreateInputInjector() { | 207 InputInjector* ClientSessionTest::CreateInputInjector() { |
208 EXPECT_TRUE(input_injector_); | 208 EXPECT_TRUE(input_injector_); |
209 return input_injector_.release(); | 209 return input_injector_.release(); |
210 } | 210 } |
211 | 211 |
212 media::ScreenCapturer* ClientSessionTest::CreateVideoCapturer() { | 212 webrtc::ScreenCapturer* ClientSessionTest::CreateVideoCapturer() { |
213 return new media::ScreenCapturerFake(); | 213 return new ScreenCapturerFake(); |
214 } | 214 } |
215 | 215 |
216 void ClientSessionTest::ConnectClientSession() { | 216 void ClientSessionTest::ConnectClientSession() { |
217 client_session_->OnConnectionAuthenticated(client_session_->connection()); | 217 client_session_->OnConnectionAuthenticated(client_session_->connection()); |
218 client_session_->OnConnectionChannelsConnected(client_session_->connection()); | 218 client_session_->OnConnectionChannelsConnected(client_session_->connection()); |
219 } | 219 } |
220 | 220 |
221 void ClientSessionTest::QuitMainMessageLoop() { | 221 void ClientSessionTest::QuitMainMessageLoop() { |
222 message_loop_.PostTask(FROM_HERE, base::MessageLoop::QuitClosure()); | 222 message_loop_.PostTask(FROM_HERE, base::MessageLoop::QuitClosure()); |
223 } | 223 } |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 EXPECT_CALL(*input_injector_, StartPtr(_)) | 480 EXPECT_CALL(*input_injector_, StartPtr(_)) |
481 .After(authenticated); | 481 .After(authenticated); |
482 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_)) | 482 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_)) |
483 .After(authenticated); | 483 .After(authenticated); |
484 EXPECT_CALL(session_event_handler_, OnSessionClosed(_)) | 484 EXPECT_CALL(session_event_handler_, OnSessionClosed(_)) |
485 .After(authenticated); | 485 .After(authenticated); |
486 | 486 |
487 Expectation connected = authenticated; | 487 Expectation connected = authenticated; |
488 | 488 |
489 int input_x[3] = { -999, 100, 999 }; | 489 int input_x[3] = { -999, 100, 999 }; |
490 int expected_x[3] = { 0, 100, media::ScreenCapturerFake::kWidth - 1 }; | 490 int expected_x[3] = { 0, 100, ScreenCapturerFake::kWidth - 1 }; |
491 int input_y[3] = { -999, 50, 999 }; | 491 int input_y[3] = { -999, 50, 999 }; |
492 int expected_y[3] = { 0, 50, media::ScreenCapturerFake::kHeight - 1 }; | 492 int expected_y[3] = { 0, 50, ScreenCapturerFake::kHeight - 1 }; |
493 | 493 |
494 protocol::MouseEvent expected_event; | 494 protocol::MouseEvent expected_event; |
495 for (int j = 0; j < 3; j++) { | 495 for (int j = 0; j < 3; j++) { |
496 for (int i = 0; i < 3; i++) { | 496 for (int i = 0; i < 3; i++) { |
497 protocol::MouseEvent injected_event; | 497 protocol::MouseEvent injected_event; |
498 injected_event.set_x(input_x[i]); | 498 injected_event.set_x(input_x[i]); |
499 injected_event.set_y(input_y[j]); | 499 injected_event.set_y(input_y[j]); |
500 | 500 |
501 if (i == 0 && j == 0) { | 501 if (i == 0 && j == 0) { |
502 // Inject the 1st event once a video packet has been received. | 502 // Inject the 1st event once a video packet has been received. |
(...skipping 24 matching lines...) Expand all Loading... |
527 .After(connected) | 527 .After(connected) |
528 .WillOnce(DoAll( | 528 .WillOnce(DoAll( |
529 InvokeWithoutArgs(this, &ClientSessionTest::DisconnectClientSession), | 529 InvokeWithoutArgs(this, &ClientSessionTest::DisconnectClientSession), |
530 InvokeWithoutArgs(this, &ClientSessionTest::StopClientSession))); | 530 InvokeWithoutArgs(this, &ClientSessionTest::StopClientSession))); |
531 | 531 |
532 ConnectClientSession(); | 532 ConnectClientSession(); |
533 message_loop_.Run(); | 533 message_loop_.Run(); |
534 } | 534 } |
535 | 535 |
536 } // namespace remoting | 536 } // namespace remoting |
OLD | NEW |