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/bind.h" | 5 #include "base/bind.h" |
6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "remoting/base/auto_thread_task_runner.h" | 8 #include "remoting/base/auto_thread_task_runner.h" |
9 #include "remoting/host/audio_capturer.h" | 9 #include "remoting/host/audio_capturer.h" |
10 #include "remoting/host/chromoting_host.h" | 10 #include "remoting/host/chromoting_host.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 .WillRepeatedly(SaveArg<0>(&session_unowned2_event_handler_)); | 101 .WillRepeatedly(SaveArg<0>(&session_unowned2_event_handler_)); |
102 EXPECT_CALL(*session1_, config()) | 102 EXPECT_CALL(*session1_, config()) |
103 .WillRepeatedly(ReturnRef(*session_config1_)); | 103 .WillRepeatedly(ReturnRef(*session_config1_)); |
104 EXPECT_CALL(*session2_, config()) | 104 EXPECT_CALL(*session2_, config()) |
105 .WillRepeatedly(ReturnRef(*session_config2_)); | 105 .WillRepeatedly(ReturnRef(*session_config2_)); |
106 | 106 |
107 owned_connection1_.reset( | 107 owned_connection1_.reset( |
108 new protocol::FakeConnectionToClient(make_scoped_ptr(session1_))); | 108 new protocol::FakeConnectionToClient(make_scoped_ptr(session1_))); |
109 owned_connection1_->set_host_stub(&host_stub1_); | 109 owned_connection1_->set_host_stub(&host_stub1_); |
110 connection1_ = owned_connection1_.get(); | 110 connection1_ = owned_connection1_.get(); |
111 connection1_->set_video_stub(&video_stub1_); | |
112 connection1_->set_client_stub(&client_stub1_); | 111 connection1_->set_client_stub(&client_stub1_); |
113 | 112 |
114 owned_connection2_.reset( | 113 owned_connection2_.reset( |
115 new protocol::FakeConnectionToClient(make_scoped_ptr(session2_))); | 114 new protocol::FakeConnectionToClient(make_scoped_ptr(session2_))); |
116 owned_connection2_->set_host_stub(&host_stub2_); | 115 owned_connection2_->set_host_stub(&host_stub2_); |
117 connection2_ = owned_connection2_.get(); | 116 connection2_ = owned_connection2_.get(); |
118 connection2_->set_video_stub(&video_stub2_); | |
119 connection2_->set_client_stub(&client_stub2_); | 117 connection2_->set_client_stub(&client_stub2_); |
120 | |
121 ON_CALL(video_stub1_, ProcessVideoPacketPtr(_, _)) | |
122 .WillByDefault(DeleteArg<0>()); | |
123 ON_CALL(video_stub2_, ProcessVideoPacketPtr(_, _)) | |
124 .WillByDefault(DeleteArg<0>()); | |
125 } | 118 } |
126 | 119 |
127 // Helper method to pretend a client is connected to ChromotingHost. | 120 // Helper method to pretend a client is connected to ChromotingHost. |
128 void SimulateClientConnection(int connection_index, bool authenticate, | 121 void SimulateClientConnection(int connection_index, bool authenticate, |
129 bool reject) { | 122 bool reject) { |
130 scoped_ptr<protocol::ConnectionToClient> connection = | 123 scoped_ptr<protocol::ConnectionToClient> connection = |
131 ((connection_index == 0) ? owned_connection1_ : owned_connection2_) | 124 ((connection_index == 0) ? owned_connection1_ : owned_connection2_) |
132 .Pass(); | 125 .Pass(); |
133 protocol::ConnectionToClient* connection_ptr = connection.get(); | 126 protocol::ConnectionToClient* connection_ptr = connection.get(); |
134 scoped_ptr<ClientSession> client(new ClientSession( | 127 scoped_ptr<ClientSession> client(new ClientSession( |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 MockHostStatusObserver host_status_observer_; | 220 MockHostStatusObserver host_status_observer_; |
228 scoped_ptr<ChromotingHost> host_; | 221 scoped_ptr<ChromotingHost> host_; |
229 protocol::MockSessionManager* session_manager_; | 222 protocol::MockSessionManager* session_manager_; |
230 std::string xmpp_login_; | 223 std::string xmpp_login_; |
231 protocol::FakeConnectionToClient* connection1_; | 224 protocol::FakeConnectionToClient* connection1_; |
232 scoped_ptr<protocol::FakeConnectionToClient> owned_connection1_; | 225 scoped_ptr<protocol::FakeConnectionToClient> owned_connection1_; |
233 ClientSession* client1_; | 226 ClientSession* client1_; |
234 std::string session_jid1_; | 227 std::string session_jid1_; |
235 MockSession* session1_; // Owned by |connection_|. | 228 MockSession* session1_; // Owned by |connection_|. |
236 scoped_ptr<SessionConfig> session_config1_; | 229 scoped_ptr<SessionConfig> session_config1_; |
237 MockVideoStub video_stub1_; | |
238 MockClientStub client_stub1_; | 230 MockClientStub client_stub1_; |
239 MockHostStub host_stub1_; | 231 MockHostStub host_stub1_; |
240 protocol::FakeConnectionToClient* connection2_; | 232 protocol::FakeConnectionToClient* connection2_; |
241 scoped_ptr<protocol::FakeConnectionToClient> owned_connection2_; | 233 scoped_ptr<protocol::FakeConnectionToClient> owned_connection2_; |
242 ClientSession* client2_; | 234 ClientSession* client2_; |
243 std::string session_jid2_; | 235 std::string session_jid2_; |
244 MockSession* session2_; // Owned by |connection2_|. | 236 MockSession* session2_; // Owned by |connection2_|. |
245 scoped_ptr<SessionConfig> session_config2_; | 237 scoped_ptr<SessionConfig> session_config2_; |
246 MockVideoStub video_stub2_; | |
247 MockClientStub client_stub2_; | 238 MockClientStub client_stub2_; |
248 MockHostStub host_stub2_; | 239 MockHostStub host_stub2_; |
249 scoped_ptr<MockSession> session_unowned1_; // Not owned by a connection. | 240 scoped_ptr<MockSession> session_unowned1_; // Not owned by a connection. |
250 std::string session_unowned_jid1_; | 241 std::string session_unowned_jid1_; |
251 scoped_ptr<MockSession> session_unowned2_; // Not owned by a connection. | 242 scoped_ptr<MockSession> session_unowned2_; // Not owned by a connection. |
252 std::string session_unowned_jid2_; | 243 std::string session_unowned_jid2_; |
253 protocol::Session::EventHandler* session_unowned1_event_handler_; | 244 protocol::Session::EventHandler* session_unowned1_event_handler_; |
254 protocol::Session::EventHandler* session_unowned2_event_handler_; | 245 protocol::Session::EventHandler* session_unowned2_event_handler_; |
255 | 246 |
256 protocol::FakeConnectionToClient*& get_connection(int connection_index) { | 247 protocol::FakeConnectionToClient*& get_connection(int connection_index) { |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 | 410 |
420 ExpectClientConnected(0); | 411 ExpectClientConnected(0); |
421 SimulateClientConnection(0, true, false); | 412 SimulateClientConnection(0, true, false); |
422 | 413 |
423 ExpectClientDisconnected(0); | 414 ExpectClientDisconnected(0); |
424 DisconnectAllClients(); | 415 DisconnectAllClients(); |
425 testing::Mock::VerifyAndClearExpectations(&host_status_observer_); | 416 testing::Mock::VerifyAndClearExpectations(&host_status_observer_); |
426 } | 417 } |
427 | 418 |
428 } // namespace remoting | 419 } // namespace remoting |
OLD | NEW |