| 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" |
| 6 #include "remoting/base/auto_thread_task_runner.h" | 8 #include "remoting/base/auto_thread_task_runner.h" |
| 7 #include "remoting/base/constants.h" | 9 #include "remoting/base/constants.h" |
| 8 #include "remoting/capturer/video_capturer_mock_objects.h" | |
| 9 #include "remoting/capturer/video_frame_capturer_fake.h" | |
| 10 #include "remoting/host/audio_capturer.h" | 10 #include "remoting/host/audio_capturer.h" |
| 11 #include "remoting/host/client_session.h" | 11 #include "remoting/host/client_session.h" |
| 12 #include "remoting/host/desktop_environment.h" | 12 #include "remoting/host/desktop_environment.h" |
| 13 #include "remoting/host/host_mock_objects.h" | 13 #include "remoting/host/host_mock_objects.h" |
| 14 #include "remoting/protocol/protocol_mock_objects.h" | 14 #include "remoting/protocol/protocol_mock_objects.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 16 |
| 17 namespace remoting { | 17 namespace remoting { |
| 18 | 18 |
| 19 using protocol::MockConnectionToClient; | 19 using protocol::MockConnectionToClient; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 virtual void SetUp() OVERRIDE; | 60 virtual void SetUp() OVERRIDE; |
| 61 virtual void TearDown() OVERRIDE; | 61 virtual void TearDown() OVERRIDE; |
| 62 | 62 |
| 63 // Disconnects the client session. | 63 // Disconnects the client session. |
| 64 void DisconnectClientSession(); | 64 void DisconnectClientSession(); |
| 65 | 65 |
| 66 // Stops and releases the ClientSession, allowing the MessageLoop to quit. | 66 // Stops and releases the ClientSession, allowing the MessageLoop to quit. |
| 67 void StopClientSession(); | 67 void StopClientSession(); |
| 68 | 68 |
| 69 protected: | 69 protected: |
| 70 // Creates a DesktopEnvironment with a fake VideoFrameCapturer, to mock | 70 // Creates a DesktopEnvironment with a fake media::ScreenCapturer, to mock |
| 71 // DesktopEnvironmentFactory::Create(). | 71 // DesktopEnvironmentFactory::Create(). |
| 72 DesktopEnvironment* CreateDesktopEnvironment(); | 72 DesktopEnvironment* CreateDesktopEnvironment(); |
| 73 | 73 |
| 74 // Returns |event_executor_| created and initialized by SetUp(), to mock | 74 // Returns |event_executor_| created and initialized by SetUp(), to mock |
| 75 // DesktopEnvironment::CreateEventExecutor(). | 75 // DesktopEnvironment::CreateEventExecutor(). |
| 76 EventExecutor* CreateEventExecutor( | 76 EventExecutor* CreateEventExecutor( |
| 77 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, | 77 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, |
| 78 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner); | 78 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner); |
| 79 | 79 |
| 80 // Creates a fake VideoFrameCapturer, to mock | 80 // Creates a fake media::ScreenCapturer, to mock |
| 81 // DesktopEnvironment::CreateVideoCapturer(). | 81 // DesktopEnvironment::CreateVideoCapturer(). |
| 82 VideoFrameCapturer* CreateVideoCapturer( | 82 media::ScreenCapturer* CreateVideoCapturer( |
| 83 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, | 83 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, |
| 84 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner); | 84 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner); |
| 85 | 85 |
| 86 // Notifies the client session that the client connection has been | 86 // Notifies the client session that the client connection has been |
| 87 // authenticated and channels have been connected. This effectively enables | 87 // authenticated and channels have been connected. This effectively enables |
| 88 // the input pipe line and starts video capturing. | 88 // the input pipe line and starts video capturing. |
| 89 void ConnectClientSession(); | 89 void ConnectClientSession(); |
| 90 | 90 |
| 91 // Invoked when the last reference to the AutoThreadTaskRunner has been | 91 // Invoked when the last reference to the AutoThreadTaskRunner has been |
| 92 // released and quits the message loop to finish the test. | 92 // released and quits the message loop to finish the test. |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 return desktop_environment; | 201 return desktop_environment; |
| 202 } | 202 } |
| 203 | 203 |
| 204 EventExecutor* ClientSessionTest::CreateEventExecutor( | 204 EventExecutor* ClientSessionTest::CreateEventExecutor( |
| 205 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, | 205 scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, |
| 206 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { | 206 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { |
| 207 EXPECT_TRUE(event_executor_); | 207 EXPECT_TRUE(event_executor_); |
| 208 return event_executor_.release(); | 208 return event_executor_.release(); |
| 209 } | 209 } |
| 210 | 210 |
| 211 VideoFrameCapturer* ClientSessionTest::CreateVideoCapturer( | 211 media::ScreenCapturer* ClientSessionTest::CreateVideoCapturer( |
| 212 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, | 212 scoped_refptr<base::SingleThreadTaskRunner> capture_task_runner, |
| 213 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner) { | 213 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner) { |
| 214 return new VideoFrameCapturerFake(); | 214 return new media::ScreenCapturerFake(); |
| 215 } | 215 } |
| 216 | 216 |
| 217 void ClientSessionTest::ConnectClientSession() { | 217 void ClientSessionTest::ConnectClientSession() { |
| 218 client_session_->OnConnectionAuthenticated(client_session_->connection()); | 218 client_session_->OnConnectionAuthenticated(client_session_->connection()); |
| 219 client_session_->OnConnectionChannelsConnected(client_session_->connection()); | 219 client_session_->OnConnectionChannelsConnected(client_session_->connection()); |
| 220 } | 220 } |
| 221 | 221 |
| 222 void ClientSessionTest::QuitMainMessageLoop() { | 222 void ClientSessionTest::QuitMainMessageLoop() { |
| 223 message_loop_.PostTask(FROM_HERE, MessageLoop::QuitClosure()); | 223 message_loop_.PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
| 224 } | 224 } |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 } | 430 } |
| 431 | 431 |
| 432 TEST_F(ClientSessionTest, ClampMouseEvents) { | 432 TEST_F(ClientSessionTest, ClampMouseEvents) { |
| 433 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_)); | 433 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_)); |
| 434 EXPECT_CALL(*event_executor_, StartPtr(_)); | 434 EXPECT_CALL(*event_executor_, StartPtr(_)); |
| 435 Expectation connected = | 435 Expectation connected = |
| 436 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_)); | 436 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_)); |
| 437 EXPECT_CALL(session_event_handler_, OnSessionClosed(_)); | 437 EXPECT_CALL(session_event_handler_, OnSessionClosed(_)); |
| 438 | 438 |
| 439 int input_x[3] = { -999, 100, 999 }; | 439 int input_x[3] = { -999, 100, 999 }; |
| 440 int expected_x[3] = { 0, 100, VideoFrameCapturerFake::kWidth - 1 }; | 440 int expected_x[3] = { 0, 100, media::ScreenCapturerFake::kWidth - 1 }; |
| 441 int input_y[3] = { -999, 50, 999 }; | 441 int input_y[3] = { -999, 50, 999 }; |
| 442 int expected_y[3] = { 0, 50, VideoFrameCapturerFake::kHeight - 1 }; | 442 int expected_y[3] = { 0, 50, media::ScreenCapturerFake::kHeight - 1 }; |
| 443 | 443 |
| 444 protocol::MouseEvent expected_event; | 444 protocol::MouseEvent expected_event; |
| 445 for (int j = 0; j < 3; j++) { | 445 for (int j = 0; j < 3; j++) { |
| 446 for (int i = 0; i < 3; i++) { | 446 for (int i = 0; i < 3; i++) { |
| 447 protocol::MouseEvent injected_event; | 447 protocol::MouseEvent injected_event; |
| 448 injected_event.set_x(input_x[i]); | 448 injected_event.set_x(input_x[i]); |
| 449 injected_event.set_y(input_y[j]); | 449 injected_event.set_y(input_y[j]); |
| 450 | 450 |
| 451 if (i == 0 && j == 0) { | 451 if (i == 0 && j == 0) { |
| 452 // Inject the 1st event once a video packet has been received. | 452 // Inject the 1st event once a video packet has been received. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 477 .After(connected) | 477 .After(connected) |
| 478 .WillOnce(DoAll( | 478 .WillOnce(DoAll( |
| 479 InvokeWithoutArgs(this, &ClientSessionTest::DisconnectClientSession), | 479 InvokeWithoutArgs(this, &ClientSessionTest::DisconnectClientSession), |
| 480 InvokeWithoutArgs(this, &ClientSessionTest::StopClientSession))); | 480 InvokeWithoutArgs(this, &ClientSessionTest::StopClientSession))); |
| 481 | 481 |
| 482 ConnectClientSession(); | 482 ConnectClientSession(); |
| 483 message_loop_.Run(); | 483 message_loop_.Run(); |
| 484 } | 484 } |
| 485 | 485 |
| 486 } // namespace remoting | 486 } // namespace remoting |
| OLD | NEW |