| 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 "remoting/host/client_session.h" |
| 6 |
| 5 #include <stdint.h> | 7 #include <stdint.h> |
| 6 | 8 |
| 7 #include <algorithm> | 9 #include <algorithm> |
| 8 #include <string> | 10 #include <string> |
| 11 #include <utility> |
| 9 #include <vector> | 12 #include <vector> |
| 10 | 13 |
| 11 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
| 12 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
| 13 #include "base/strings/string_split.h" | 16 #include "base/strings/string_split.h" |
| 14 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
| 15 #include "build/build_config.h" | 18 #include "build/build_config.h" |
| 16 #include "remoting/base/auto_thread_task_runner.h" | 19 #include "remoting/base/auto_thread_task_runner.h" |
| 17 #include "remoting/base/constants.h" | 20 #include "remoting/base/constants.h" |
| 18 #include "remoting/codec/video_encoder_verbatim.h" | 21 #include "remoting/codec/video_encoder_verbatim.h" |
| 19 #include "remoting/host/client_session.h" | |
| 20 #include "remoting/host/desktop_environment.h" | 22 #include "remoting/host/desktop_environment.h" |
| 21 #include "remoting/host/fake_desktop_environment.h" | 23 #include "remoting/host/fake_desktop_environment.h" |
| 22 #include "remoting/host/fake_host_extension.h" | 24 #include "remoting/host/fake_host_extension.h" |
| 23 #include "remoting/host/fake_mouse_cursor_monitor.h" | 25 #include "remoting/host/fake_mouse_cursor_monitor.h" |
| 24 #include "remoting/host/host_extension.h" | 26 #include "remoting/host/host_extension.h" |
| 25 #include "remoting/host/host_extension_session.h" | 27 #include "remoting/host/host_extension_session.h" |
| 26 #include "remoting/host/host_mock_objects.h" | 28 #include "remoting/host/host_mock_objects.h" |
| 27 #include "remoting/protocol/fake_connection_to_client.h" | 29 #include "remoting/protocol/fake_connection_to_client.h" |
| 28 #include "remoting/protocol/fake_desktop_capturer.h" | 30 #include "remoting/protocol/fake_desktop_capturer.h" |
| 29 #include "remoting/protocol/protocol_mock_objects.h" | 31 #include "remoting/protocol/protocol_mock_objects.h" |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 | 174 |
| 173 void ClientSessionTest::CreateClientSession() { | 175 void ClientSessionTest::CreateClientSession() { |
| 174 // Mock protocol::Session APIs called directly by ClientSession. | 176 // Mock protocol::Session APIs called directly by ClientSession. |
| 175 scoped_ptr<protocol::MockSession> session(new MockSession()); | 177 scoped_ptr<protocol::MockSession> session(new MockSession()); |
| 176 EXPECT_CALL(*session, config()).WillRepeatedly(ReturnRef(*session_config_)); | 178 EXPECT_CALL(*session, config()).WillRepeatedly(ReturnRef(*session_config_)); |
| 177 EXPECT_CALL(*session, jid()).WillRepeatedly(ReturnRef(client_jid_)); | 179 EXPECT_CALL(*session, jid()).WillRepeatedly(ReturnRef(client_jid_)); |
| 178 | 180 |
| 179 // Mock protocol::ConnectionToClient APIs called directly by ClientSession. | 181 // Mock protocol::ConnectionToClient APIs called directly by ClientSession. |
| 180 // HostStub is not touched by ClientSession, so we can safely pass nullptr. | 182 // HostStub is not touched by ClientSession, so we can safely pass nullptr. |
| 181 scoped_ptr<protocol::FakeConnectionToClient> connection( | 183 scoped_ptr<protocol::FakeConnectionToClient> connection( |
| 182 new protocol::FakeConnectionToClient(session.Pass())); | 184 new protocol::FakeConnectionToClient(std::move(session))); |
| 183 connection->set_client_stub(&client_stub_); | 185 connection->set_client_stub(&client_stub_); |
| 184 connection_ = connection.get(); | 186 connection_ = connection.get(); |
| 185 | 187 |
| 186 client_session_.reset(new ClientSession( | 188 client_session_.reset(new ClientSession( |
| 187 &session_event_handler_, | 189 &session_event_handler_, |
| 188 task_runner_, // Audio thread. | 190 task_runner_, // Audio thread. |
| 189 task_runner_, // Input thread. | 191 task_runner_, // Input thread. |
| 190 task_runner_, // Capture thread. | 192 task_runner_, // Capture thread. |
| 191 task_runner_, // Encode thread. | 193 task_runner_, // Encode thread. |
| 192 task_runner_, // Network thread. | 194 task_runner_, // Network thread. |
| 193 task_runner_, // UI thread. | 195 task_runner_, // UI thread. |
| 194 connection.Pass(), | 196 std::move(connection), desktop_environment_factory_.get(), |
| 195 desktop_environment_factory_.get(), | 197 base::TimeDelta(), nullptr, extensions_)); |
| 196 base::TimeDelta(), | |
| 197 nullptr, | |
| 198 extensions_)); | |
| 199 } | 198 } |
| 200 | 199 |
| 201 void ClientSessionTest::ConnectClientSession() { | 200 void ClientSessionTest::ConnectClientSession() { |
| 202 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_)); | 201 EXPECT_CALL(session_event_handler_, OnSessionAuthenticated(_)); |
| 203 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_)); | 202 EXPECT_CALL(session_event_handler_, OnSessionChannelsConnected(_)); |
| 204 | 203 |
| 205 // Stubs should be set only after connection is authenticated. | 204 // Stubs should be set only after connection is authenticated. |
| 206 EXPECT_FALSE(connection_->clipboard_stub()); | 205 EXPECT_FALSE(connection_->clipboard_stub()); |
| 207 EXPECT_FALSE(connection_->input_stub()); | 206 EXPECT_FALSE(connection_->input_stub()); |
| 208 | 207 |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 | 517 |
| 519 client_session_->DisconnectSession(protocol::OK); | 518 client_session_->DisconnectSession(protocol::OK); |
| 520 client_session_.reset(); | 519 client_session_.reset(); |
| 521 | 520 |
| 522 // ext1 was instantiated and wrapped the video capturer. | 521 // ext1 was instantiated and wrapped the video capturer. |
| 523 EXPECT_TRUE(extension.was_instantiated()); | 522 EXPECT_TRUE(extension.was_instantiated()); |
| 524 EXPECT_TRUE(extension.has_wrapped_video_capturer()); | 523 EXPECT_TRUE(extension.has_wrapped_video_capturer()); |
| 525 } | 524 } |
| 526 | 525 |
| 527 } // namespace remoting | 526 } // namespace remoting |
| OLD | NEW |