Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Side by Side Diff: remoting/host/chromoting_host_unittest.cc

Issue 1458323002: Simplify It2Me host shutdown (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 275
276 void DisconnectAllClients() { 276 void DisconnectAllClients() {
277 host_->DisconnectAllClients(); 277 host_->DisconnectAllClients();
278 } 278 }
279 279
280 // Helper method to disconnect client 1 from the host. 280 // Helper method to disconnect client 1 from the host.
281 void DisconnectClient1() { 281 void DisconnectClient1() {
282 NotifyClientSessionClosed(0); 282 NotifyClientSessionClosed(0);
283 } 283 }
284 284
285 // Notify |host_| that the authenticating client has been rejected.
286 void RejectAuthenticatingClient() {
287 host_->RejectAuthenticatingClient();
288 }
289
290 // Notify |host_| that a client session has closed. 285 // Notify |host_| that a client session has closed.
291 void NotifyClientSessionClosed(int connection_index) { 286 void NotifyClientSessionClosed(int connection_index) {
292 get_client(connection_index)->OnConnectionClosed( 287 get_client(connection_index)->OnConnectionClosed(
293 get_connection(connection_index), protocol::OK); 288 get_connection(connection_index), protocol::OK);
294 } 289 }
295 290
296 void NotifyConnectionClosed1() { 291 void NotifyConnectionClosed1() {
297 if (session_unowned1_event_handler_) { 292 if (session_unowned1_event_handler_) {
298 session_unowned1_event_handler_->OnSessionStateChange(Session::CLOSED); 293 session_unowned1_event_handler_->OnSessionStateChange(Session::CLOSED);
299 } 294 }
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 0, InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost)); 468 0, InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost));
474 Expectation client_disconnected = ExpectClientDisconnected( 469 Expectation client_disconnected = ExpectClientDisconnected(
475 0, true, video_packet_sent, InvokeWithoutArgs(base::DoNothing)); 470 0, true, video_packet_sent, InvokeWithoutArgs(base::DoNothing));
476 EXPECT_CALL(host_status_observer_, OnShutdown()).After(client_disconnected); 471 EXPECT_CALL(host_status_observer_, OnShutdown()).After(client_disconnected);
477 472
478 host_->Start(xmpp_login_); 473 host_->Start(xmpp_login_);
479 SimulateClientConnection(0, true, false); 474 SimulateClientConnection(0, true, false);
480 message_loop_.Run(); 475 message_loop_.Run();
481 } 476 }
482 477
483 TEST_F(ChromotingHostTest, RejectAuthenticatingClient) {
484 Expectation start = ExpectHostAndSessionManagerStart();
485 EXPECT_CALL(host_status_observer_, OnClientAuthenticated(session_jid1_))
486 .WillOnce(InvokeWithoutArgs(
487 this, &ChromotingHostTest::RejectAuthenticatingClient));
488 ExpectClientDisconnected(
489 0, true, start,
490 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost));
491 EXPECT_CALL(host_status_observer_, OnShutdown());
492
493 host_->Start(xmpp_login_);
494 SimulateClientConnection(0, true, true);
495 message_loop_.Run();
496 }
497
498 TEST_F(ChromotingHostTest, AuthenticationFailed) { 478 TEST_F(ChromotingHostTest, AuthenticationFailed) {
499 ExpectHostAndSessionManagerStart(); 479 ExpectHostAndSessionManagerStart();
500 EXPECT_CALL(host_status_observer_, OnAccessDenied(session_jid1_)) 480 EXPECT_CALL(host_status_observer_, OnAccessDenied(session_jid1_))
501 .WillOnce(InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost)); 481 .WillOnce(InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost));
502 EXPECT_CALL(host_status_observer_, OnShutdown()); 482 EXPECT_CALL(host_status_observer_, OnShutdown());
503 483
504 host_->Start(xmpp_login_); 484 host_->Start(xmpp_login_);
505 SimulateClientConnection(0, false, false); 485 SimulateClientConnection(0, false, false);
506 message_loop_.Run(); 486 message_loop_.Run();
507 } 487 }
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 ExpectClientDisconnected(0, true, video_packet_sent, 650 ExpectClientDisconnected(0, true, video_packet_sent,
671 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost)); 651 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost));
672 EXPECT_CALL(host_status_observer_, OnShutdown()); 652 EXPECT_CALL(host_status_observer_, OnShutdown());
673 653
674 host_->Start(xmpp_login_); 654 host_->Start(xmpp_login_);
675 SimulateClientConnection(0, true, false); 655 SimulateClientConnection(0, true, false);
676 message_loop_.Run(); 656 message_loop_.Run();
677 } 657 }
678 658
679 } // namespace remoting 659 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698