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/chromoting_host.h" | 5 #include "remoting/host/chromoting_host.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 task_runner_ = new AutoThreadTaskRunner(message_loop_.task_runner(), | 60 task_runner_ = new AutoThreadTaskRunner(message_loop_.task_runner(), |
61 base::Bind(&base::DoNothing)); | 61 base::Bind(&base::DoNothing)); |
62 | 62 |
63 desktop_environment_factory_.reset(new FakeDesktopEnvironmentFactory()); | 63 desktop_environment_factory_.reset(new FakeDesktopEnvironmentFactory()); |
64 session_manager_ = new protocol::MockSessionManager(); | 64 session_manager_ = new protocol::MockSessionManager(); |
65 | 65 |
66 host_.reset(new ChromotingHost( | 66 host_.reset(new ChromotingHost( |
67 desktop_environment_factory_.get(), make_scoped_ptr(session_manager_), | 67 desktop_environment_factory_.get(), make_scoped_ptr(session_manager_), |
68 protocol::TransportContext::ForTests(protocol::TransportRole::SERVER), | 68 protocol::TransportContext::ForTests(protocol::TransportRole::SERVER), |
69 task_runner_, // Audio | 69 task_runner_, // Audio |
70 task_runner_, // Input | 70 task_runner_)); // Video encode |
71 task_runner_, // Video capture | |
72 task_runner_, // Video encode | |
73 task_runner_, // Network | |
74 task_runner_)); // UI | |
75 host_->AddStatusObserver(&host_status_observer_); | 71 host_->AddStatusObserver(&host_status_observer_); |
76 | 72 |
77 xmpp_login_ = "host@domain"; | 73 xmpp_login_ = "host@domain"; |
78 session1_ = new MockSession(); | 74 session1_ = new MockSession(); |
79 session2_ = new MockSession(); | 75 session2_ = new MockSession(); |
80 session_unowned1_.reset(new MockSession()); | 76 session_unowned1_.reset(new MockSession()); |
81 session_unowned2_.reset(new MockSession()); | 77 session_unowned2_.reset(new MockSession()); |
82 session_config1_ = SessionConfig::ForTest(); | 78 session_config1_ = SessionConfig::ForTest(); |
83 session_jid1_ = "user@domain/rest-of-jid"; | 79 session_jid1_ = "user@domain/rest-of-jid"; |
84 session_config2_ = SessionConfig::ForTest(); | 80 session_config2_ = SessionConfig::ForTest(); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 connection2_->set_client_stub(&client_stub2_); | 118 connection2_->set_client_stub(&client_stub2_); |
123 } | 119 } |
124 | 120 |
125 // Helper method to pretend a client is connected to ChromotingHost. | 121 // Helper method to pretend a client is connected to ChromotingHost. |
126 void SimulateClientConnection(int connection_index, bool authenticate, | 122 void SimulateClientConnection(int connection_index, bool authenticate, |
127 bool reject) { | 123 bool reject) { |
128 scoped_ptr<protocol::ConnectionToClient> connection = std::move( | 124 scoped_ptr<protocol::ConnectionToClient> connection = std::move( |
129 (connection_index == 0) ? owned_connection1_ : owned_connection2_); | 125 (connection_index == 0) ? owned_connection1_ : owned_connection2_); |
130 protocol::ConnectionToClient* connection_ptr = connection.get(); | 126 protocol::ConnectionToClient* connection_ptr = connection.get(); |
131 scoped_ptr<ClientSession> client(new ClientSession( | 127 scoped_ptr<ClientSession> client(new ClientSession( |
132 host_.get(), | 128 host_.get(), task_runner_ /* audio_task_runner */, |
133 task_runner_, // Audio | |
134 task_runner_, // Input | |
135 task_runner_, // Video capture | |
136 task_runner_, // Video encode | |
137 task_runner_, // Network | |
138 task_runner_, // UI | |
139 std::move(connection), desktop_environment_factory_.get(), | 129 std::move(connection), desktop_environment_factory_.get(), |
140 base::TimeDelta(), nullptr, std::vector<HostExtension*>())); | 130 base::TimeDelta(), nullptr, std::vector<HostExtension*>())); |
141 ClientSession* client_ptr = client.get(); | 131 ClientSession* client_ptr = client.get(); |
142 | 132 |
143 connection_ptr->set_host_stub(client.get()); | 133 connection_ptr->set_host_stub(client.get()); |
144 get_client(connection_index) = client_ptr; | 134 get_client(connection_index) = client_ptr; |
145 | 135 |
146 // |host| is responsible for deleting |client| from now on. | 136 // |host| is responsible for deleting |client| from now on. |
147 host_->clients_.push_back(client.release()); | 137 host_->clients_.push_back(client.release()); |
148 | 138 |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 | 389 |
400 ExpectClientConnected(0); | 390 ExpectClientConnected(0); |
401 SimulateClientConnection(0, true, false); | 391 SimulateClientConnection(0, true, false); |
402 | 392 |
403 ExpectClientDisconnected(0); | 393 ExpectClientDisconnected(0); |
404 DisconnectAllClients(); | 394 DisconnectAllClients(); |
405 testing::Mock::VerifyAndClearExpectations(&host_status_observer_); | 395 testing::Mock::VerifyAndClearExpectations(&host_status_observer_); |
406 } | 396 } |
407 | 397 |
408 } // namespace remoting | 398 } // namespace remoting |
OLD | NEW |