| 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/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "base/message_loop_proxy.h" | 7 #include "base/message_loop_proxy.h" |
| 8 #include "remoting/jingle_glue/mock_objects.h" | 8 #include "remoting/jingle_glue/mock_objects.h" |
| 9 #include "remoting/host/capturer_fake.h" | 9 #include "remoting/host/capturer_fake.h" |
| 10 #include "remoting/host/chromoting_host.h" | 10 #include "remoting/host/chromoting_host.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 | 97 |
| 98 host_ = new ChromotingHost( | 98 host_ = new ChromotingHost( |
| 99 &context_, &signal_strategy_, desktop_environment_.get(), | 99 &context_, &signal_strategy_, desktop_environment_.get(), |
| 100 protocol::NetworkSettings()); | 100 protocol::NetworkSettings()); |
| 101 | 101 |
| 102 disconnect_window_ = new MockDisconnectWindow(); | 102 disconnect_window_ = new MockDisconnectWindow(); |
| 103 continue_window_ = new MockContinueWindow(); | 103 continue_window_ = new MockContinueWindow(); |
| 104 local_input_monitor_ = new MockLocalInputMonitor(); | 104 local_input_monitor_ = new MockLocalInputMonitor(); |
| 105 it2me_host_user_interface_.reset(new It2MeHostUserInterface(host_, | 105 it2me_host_user_interface_.reset(new It2MeHostUserInterface(host_, |
| 106 &context_)); | 106 &context_)); |
| 107 it2me_host_user_interface_->InitFrom(disconnect_window_, continue_window_, | 107 it2me_host_user_interface_->InitFrom( |
| 108 local_input_monitor_); | 108 scoped_ptr<DisconnectWindow>(disconnect_window_), |
| 109 scoped_ptr<ContinueWindow>(continue_window_), |
| 110 scoped_ptr<LocalInputMonitor>(local_input_monitor_)); |
| 109 | 111 |
| 110 session_ = new MockSession(); | 112 session_ = new MockSession(); |
| 111 session2_ = new MockSession(); | 113 session2_ = new MockSession(); |
| 112 session_config_ = SessionConfig::GetDefault(); | 114 session_config_ = SessionConfig::GetDefault(); |
| 113 session_jid_ = "user@domain/rest-of-jid"; | 115 session_jid_ = "user@domain/rest-of-jid"; |
| 114 session_config2_ = SessionConfig::GetDefault(); | 116 session_config2_ = SessionConfig::GetDefault(); |
| 115 session2_jid_ = "user2@domain/rest-of-jid"; | 117 session2_jid_ = "user2@domain/rest-of-jid"; |
| 116 EXPECT_CALL(*session_, jid()) | 118 EXPECT_CALL(*session_, jid()) |
| 117 .WillRepeatedly(ReturnRef(session_jid_)); | 119 .WillRepeatedly(ReturnRef(session_jid_)); |
| 118 EXPECT_CALL(*session2_, jid()) | 120 EXPECT_CALL(*session2_, jid()) |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 owned_connection_.reset(); | 173 owned_connection_.reset(); |
| 172 owned_connection2_.reset(); | 174 owned_connection2_.reset(); |
| 173 host_ = NULL; | 175 host_ = NULL; |
| 174 // Run message loop before destroying because protocol::Session is | 176 // Run message loop before destroying because protocol::Session is |
| 175 // destroyed asynchronously. | 177 // destroyed asynchronously. |
| 176 message_loop_.RunAllPending(); | 178 message_loop_.RunAllPending(); |
| 177 } | 179 } |
| 178 | 180 |
| 179 // Helper method to pretend a client is connected to ChromotingHost. | 181 // Helper method to pretend a client is connected to ChromotingHost. |
| 180 void SimulateClientConnection(int connection_index, bool authenticate) { | 182 void SimulateClientConnection(int connection_index, bool authenticate) { |
| 181 protocol::ConnectionToClient* connection = (connection_index == 0) ? | 183 scoped_ptr<protocol::ConnectionToClient> connection = |
| 182 owned_connection_.release() : owned_connection2_.release(); | 184 ((connection_index == 0) ? owned_connection_ : owned_connection2_). |
| 185 PassAs<protocol::ConnectionToClient>(); |
| 186 protocol::ConnectionToClient* connection_ptr = connection.get(); |
| 183 ClientSession* client = new ClientSession( | 187 ClientSession* client = new ClientSession( |
| 184 host_.get(), connection, event_executor_, | 188 host_.get(), connection.Pass(), event_executor_, |
| 185 desktop_environment_->capturer()); | 189 desktop_environment_->capturer()); |
| 186 connection->set_host_stub(client); | 190 connection->set_host_stub(client); |
| 187 | 191 |
| 188 context_.network_message_loop()->PostTask( | 192 context_.network_message_loop()->PostTask( |
| 189 FROM_HERE, base::Bind(&ChromotingHostTest::AddClientToHost, | 193 FROM_HERE, base::Bind(&ChromotingHostTest::AddClientToHost, |
| 190 host_, client)); | 194 host_, client)); |
| 191 if (authenticate) { | 195 if (authenticate) { |
| 192 context_.network_message_loop()->PostTask( | 196 context_.network_message_loop()->PostTask( |
| 193 FROM_HERE, base::Bind(&ClientSession::OnConnectionOpened, | 197 FROM_HERE, base::Bind(&ClientSession::OnConnectionOpened, |
| 194 base::Unretained(client), connection)); | 198 base::Unretained(client), connection_ptr)); |
| 195 } | 199 } |
| 196 | 200 |
| 197 if (connection_index == 0) { | 201 if (connection_index == 0) { |
| 198 client_ = client; | 202 client_ = client; |
| 199 } else { | 203 } else { |
| 200 client2_ = client; | 204 client2_ = client; |
| 201 } | 205 } |
| 202 } | 206 } |
| 203 | 207 |
| 204 // Helper method to remove a client connection from ChromotingHost. | 208 // Helper method to remove a client connection from ChromotingHost. |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 EXPECT_CALL(*connection_, Disconnect()) | 373 EXPECT_CALL(*connection_, Disconnect()) |
| 370 .RetiresOnSaturation(); | 374 .RetiresOnSaturation(); |
| 371 EXPECT_CALL(*connection2_, Disconnect()) | 375 EXPECT_CALL(*connection2_, Disconnect()) |
| 372 .RetiresOnSaturation(); | 376 .RetiresOnSaturation(); |
| 373 | 377 |
| 374 SimulateClientConnection(0, true); | 378 SimulateClientConnection(0, true); |
| 375 message_loop_.Run(); | 379 message_loop_.Run(); |
| 376 } | 380 } |
| 377 | 381 |
| 378 } // namespace remoting | 382 } // namespace remoting |
| OLD | NEW |