| 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/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| 11 #include "base/test/test_simple_task_runner.h" | 11 #include "base/test/test_simple_task_runner.h" |
| 12 #include "remoting/base/auto_thread_task_runner.h" | 12 #include "remoting/base/auto_thread_task_runner.h" |
| 13 #include "remoting/base/constants.h" | 13 #include "remoting/base/constants.h" |
| 14 #include "remoting/host/audio_capturer.h" | 14 #include "remoting/host/audio_capturer.h" |
| 15 #include "remoting/host/client_session.h" | 15 #include "remoting/host/client_session.h" |
| 16 #include "remoting/host/desktop_environment.h" | 16 #include "remoting/host/desktop_environment.h" |
| 17 #include "remoting/host/fake_screen_capturer.h" |
| 17 #include "remoting/host/host_extension.h" | 18 #include "remoting/host/host_extension.h" |
| 18 #include "remoting/host/host_mock_objects.h" | 19 #include "remoting/host/host_mock_objects.h" |
| 19 #include "remoting/host/screen_capturer_fake.h" | |
| 20 #include "remoting/protocol/protocol_mock_objects.h" | 20 #include "remoting/protocol/protocol_mock_objects.h" |
| 21 #include "testing/gmock/include/gmock/gmock-matchers.h" | 21 #include "testing/gmock/include/gmock/gmock-matchers.h" |
| 22 #include "testing/gmock_mutant.h" | 22 #include "testing/gmock_mutant.h" |
| 23 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
| 24 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" | 24 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" |
| 25 #include "third_party/webrtc/modules/desktop_capture/desktop_region.h" | 25 #include "third_party/webrtc/modules/desktop_capture/desktop_region.h" |
| 26 #include "third_party/webrtc/modules/desktop_capture/screen_capturer_mock_object
s.h" | 26 #include "third_party/webrtc/modules/desktop_capture/screen_capturer_mock_object
s.h" |
| 27 | 27 |
| 28 namespace remoting { | 28 namespace remoting { |
| 29 | 29 |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 | 340 |
| 341 return desktop_environment; | 341 return desktop_environment; |
| 342 } | 342 } |
| 343 | 343 |
| 344 InputInjector* ClientSessionTest::CreateInputInjector() { | 344 InputInjector* ClientSessionTest::CreateInputInjector() { |
| 345 EXPECT_TRUE(input_injector_); | 345 EXPECT_TRUE(input_injector_); |
| 346 return input_injector_.release(); | 346 return input_injector_.release(); |
| 347 } | 347 } |
| 348 | 348 |
| 349 webrtc::ScreenCapturer* ClientSessionTest::CreateVideoCapturer() { | 349 webrtc::ScreenCapturer* ClientSessionTest::CreateVideoCapturer() { |
| 350 return new ScreenCapturerFake(); | 350 return new FakeScreenCapturer(); |
| 351 } | 351 } |
| 352 | 352 |
| 353 void ClientSessionTest::ConnectClientSession() { | 353 void ClientSessionTest::ConnectClientSession() { |
| 354 client_session_->OnConnectionAuthenticated(client_session_->connection()); | 354 client_session_->OnConnectionAuthenticated(client_session_->connection()); |
| 355 client_session_->OnConnectionChannelsConnected(client_session_->connection()); | 355 client_session_->OnConnectionChannelsConnected(client_session_->connection()); |
| 356 } | 356 } |
| 357 | 357 |
| 358 void ClientSessionTest::SetSendMessageAndDisconnectExpectation( | 358 void ClientSessionTest::SetSendMessageAndDisconnectExpectation( |
| 359 const std::string& message_type) { | 359 const std::string& message_type) { |
| 360 protocol::ExtensionMessage message; | 360 protocol::ExtensionMessage message; |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 EXPECT_CALL(*input_injector_, StartPtr(_)) | 638 EXPECT_CALL(*input_injector_, StartPtr(_)) |
| 639 .After(authenticated); | 639 .After(authenticated); |
| 640 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_)) | 640 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_)) |
| 641 .After(authenticated); | 641 .After(authenticated); |
| 642 EXPECT_CALL(session_event_handler_, OnSessionClosed(_)) | 642 EXPECT_CALL(session_event_handler_, OnSessionClosed(_)) |
| 643 .After(authenticated); | 643 .After(authenticated); |
| 644 | 644 |
| 645 Expectation connected = authenticated; | 645 Expectation connected = authenticated; |
| 646 | 646 |
| 647 int input_x[3] = { -999, 100, 999 }; | 647 int input_x[3] = { -999, 100, 999 }; |
| 648 int expected_x[3] = { 0, 100, ScreenCapturerFake::kWidth - 1 }; | 648 int expected_x[3] = { 0, 100, FakeScreenCapturer::kWidth - 1 }; |
| 649 int input_y[3] = { -999, 50, 999 }; | 649 int input_y[3] = { -999, 50, 999 }; |
| 650 int expected_y[3] = { 0, 50, ScreenCapturerFake::kHeight - 1 }; | 650 int expected_y[3] = { 0, 50, FakeScreenCapturer::kHeight - 1 }; |
| 651 | 651 |
| 652 protocol::MouseEvent expected_event; | 652 protocol::MouseEvent expected_event; |
| 653 for (int j = 0; j < 3; j++) { | 653 for (int j = 0; j < 3; j++) { |
| 654 for (int i = 0; i < 3; i++) { | 654 for (int i = 0; i < 3; i++) { |
| 655 protocol::MouseEvent injected_event; | 655 protocol::MouseEvent injected_event; |
| 656 injected_event.set_x(input_x[i]); | 656 injected_event.set_x(input_x[i]); |
| 657 injected_event.set_y(input_y[j]); | 657 injected_event.set_y(input_y[j]); |
| 658 | 658 |
| 659 if (i == 0 && j == 0) { | 659 if (i == 0 && j == 0) { |
| 660 // Inject the 1st event once a video packet has been received. | 660 // Inject the 1st event once a video packet has been received. |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 792 .After(authenticated) | 792 .After(authenticated) |
| 793 .WillOnce(DoAll( | 793 .WillOnce(DoAll( |
| 794 InvokeWithoutArgs(this, &ClientSessionTest::DisconnectClientSession), | 794 InvokeWithoutArgs(this, &ClientSessionTest::DisconnectClientSession), |
| 795 InvokeWithoutArgs(this, &ClientSessionTest::StopClientSession))); | 795 InvokeWithoutArgs(this, &ClientSessionTest::StopClientSession))); |
| 796 | 796 |
| 797 ConnectClientSession(); | 797 ConnectClientSession(); |
| 798 message_loop_.Run(); | 798 message_loop_.Run(); |
| 799 } | 799 } |
| 800 | 800 |
| 801 } // namespace remoting | 801 } // namespace remoting |
| OLD | NEW |