OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/task.h" | 8 #include "base/task.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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 (connection_index == 0) ? connection_ : connection2_; | 164 (connection_index == 0) ? connection_ : connection2_; |
165 | 165 |
166 scoped_refptr<ClientSession> client = new ClientSession( | 166 scoped_refptr<ClientSession> client = new ClientSession( |
167 host_.get(), | 167 host_.get(), |
168 connection, | 168 connection, |
169 event_executor_, | 169 event_executor_, |
170 desktop_environment_->capturer()); | 170 desktop_environment_->capturer()); |
171 connection->set_host_stub(client.get()); | 171 connection->set_host_stub(client.get()); |
172 | 172 |
173 context_.network_message_loop()->PostTask( | 173 context_.network_message_loop()->PostTask( |
174 FROM_HERE, | 174 FROM_HERE, base::Bind(&ChromotingHostTest::AddClientToHost, |
175 NewRunnableFunction(&ChromotingHostTest::AddClientToHost, | 175 host_, client)); |
176 host_, client)); | |
177 if (authenticate) { | 176 if (authenticate) { |
178 context_.network_message_loop()->PostTask( | 177 context_.network_message_loop()->PostTask( |
179 FROM_HERE, | 178 FROM_HERE, base::Bind(&ClientSession::OnAuthenticationComplete, |
180 NewRunnableMethod(client.get(), | 179 client.get())); |
181 &ClientSession::OnAuthenticationComplete)); | |
182 } | 180 } |
183 } | 181 } |
184 | 182 |
185 // Helper method to remove a client connection from ChromotingHost. | 183 // Helper method to remove a client connection from ChromotingHost. |
186 void RemoveClientConnection() { | 184 void RemoveClientConnection() { |
187 context_.network_message_loop()->PostTask( | 185 context_.network_message_loop()->PostTask( |
188 FROM_HERE, | 186 FROM_HERE, base::Bind(&ChromotingHost::OnClientDisconnected, |
189 NewRunnableMethod(host_.get(), | 187 host_.get(), connection_)); |
190 &ChromotingHost::OnClientDisconnected, | |
191 connection_)); | |
192 } | 188 } |
193 | 189 |
194 static void AddClientToHost(scoped_refptr<ChromotingHost> host, | 190 static void AddClientToHost(scoped_refptr<ChromotingHost> host, |
195 scoped_refptr<ClientSession> session) { | 191 scoped_refptr<ClientSession> session) { |
196 host->clients_.push_back(session); | 192 host->clients_.push_back(session); |
197 } | 193 } |
198 | 194 |
199 void ShutdownHost() { | 195 void ShutdownHost() { |
200 host_->Shutdown( | 196 host_->Shutdown(base::Bind(&PostQuitTask, &message_loop_)); |
201 NewRunnableFunction(&PostQuitTask, &message_loop_)); | |
202 } | 197 } |
203 | 198 |
204 protected: | 199 protected: |
205 MessageLoop message_loop_; | 200 MessageLoop message_loop_; |
206 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; | 201 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; |
207 MockConnectionToClientEventHandler handler_; | 202 MockConnectionToClientEventHandler handler_; |
208 scoped_ptr<DesktopEnvironment> desktop_environment_; | 203 scoped_ptr<DesktopEnvironment> desktop_environment_; |
209 scoped_refptr<ChromotingHost> host_; | 204 scoped_refptr<ChromotingHost> host_; |
210 scoped_refptr<InMemoryHostConfig> config_; | 205 scoped_refptr<InMemoryHostConfig> config_; |
211 MockChromotingHostContext context_; | 206 MockChromotingHostContext context_; |
(...skipping 18 matching lines...) Expand all Loading... |
230 MockCurtain* curtain_; | 225 MockCurtain* curtain_; |
231 MockDisconnectWindow* disconnect_window_; | 226 MockDisconnectWindow* disconnect_window_; |
232 MockContinueWindow* continue_window_; | 227 MockContinueWindow* continue_window_; |
233 MockLocalInputMonitor* local_input_monitor_; | 228 MockLocalInputMonitor* local_input_monitor_; |
234 }; | 229 }; |
235 | 230 |
236 TEST_F(ChromotingHostTest, DISABLED_StartAndShutdown) { | 231 TEST_F(ChromotingHostTest, DISABLED_StartAndShutdown) { |
237 host_->Start(); | 232 host_->Start(); |
238 | 233 |
239 message_loop_.PostTask( | 234 message_loop_.PostTask( |
240 FROM_HERE,NewRunnableMethod( | 235 FROM_HERE, base::Bind( |
241 host_.get(), &ChromotingHost::Shutdown, | 236 &ChromotingHost::Shutdown, host_.get(), |
242 NewRunnableFunction(&PostQuitTask, &message_loop_))); | 237 base::Bind(&PostQuitTask, &message_loop_))); |
243 message_loop_.Run(); | 238 message_loop_.Run(); |
244 } | 239 } |
245 | 240 |
246 TEST_F(ChromotingHostTest, DISABLED_Connect) { | 241 TEST_F(ChromotingHostTest, DISABLED_Connect) { |
247 host_->Start(); | 242 host_->Start(); |
248 | 243 |
249 // When the video packet is received we first shutdown ChromotingHost | 244 // When the video packet is received we first shutdown ChromotingHost |
250 // then execute the done task. | 245 // then execute the done task. |
251 { | 246 { |
252 InSequence s; | 247 InSequence s; |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 .Times(1) | 459 .Times(1) |
465 .InSequence(s2); | 460 .InSequence(s2); |
466 } | 461 } |
467 SimulateClientConnection(0, true); | 462 SimulateClientConnection(0, true); |
468 message_loop_.Run(); | 463 message_loop_.Run(); |
469 host_->set_it2me(false); | 464 host_->set_it2me(false); |
470 EXPECT_THAT(curtain_activated, false); | 465 EXPECT_THAT(curtain_activated, false); |
471 } | 466 } |
472 | 467 |
473 } // namespace remoting | 468 } // namespace remoting |
OLD | NEW |