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

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
« no previous file with comments | « remoting/host/chromoting_host.cc ('k') | remoting/host/client_session.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 263
264 void DisconnectAllClients() { 264 void DisconnectAllClients() {
265 host_->DisconnectAllClients(); 265 host_->DisconnectAllClients();
266 } 266 }
267 267
268 // Helper method to disconnect client 1 from the host. 268 // Helper method to disconnect client 1 from the host.
269 void DisconnectClient1() { 269 void DisconnectClient1() {
270 NotifyClientSessionClosed(0); 270 NotifyClientSessionClosed(0);
271 } 271 }
272 272
273 // Notify |host_| that the authenticating client has been rejected.
274 void RejectAuthenticatingClient() {
275 host_->RejectAuthenticatingClient();
276 }
277
278 // Notify |host_| that a client session has closed. 273 // Notify |host_| that a client session has closed.
279 void NotifyClientSessionClosed(int connection_index) { 274 void NotifyClientSessionClosed(int connection_index) {
280 get_client(connection_index)->OnConnectionClosed( 275 get_client(connection_index)->OnConnectionClosed(
281 get_connection(connection_index), protocol::OK); 276 get_connection(connection_index), protocol::OK);
282 } 277 }
283 278
284 void NotifyConnectionClosed1() { 279 void NotifyConnectionClosed1() {
285 if (session_unowned1_event_handler_) { 280 if (session_unowned1_event_handler_) {
286 session_unowned1_event_handler_->OnSessionStateChange(Session::CLOSED); 281 session_unowned1_event_handler_->OnSessionStateChange(Session::CLOSED);
287 } 282 }
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 0, InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost)); 456 0, InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost));
462 Expectation client_disconnected = ExpectClientDisconnected( 457 Expectation client_disconnected = ExpectClientDisconnected(
463 0, true, video_packet_sent, InvokeWithoutArgs(base::DoNothing)); 458 0, true, video_packet_sent, InvokeWithoutArgs(base::DoNothing));
464 EXPECT_CALL(host_status_observer_, OnShutdown()).After(client_disconnected); 459 EXPECT_CALL(host_status_observer_, OnShutdown()).After(client_disconnected);
465 460
466 host_->Start(xmpp_login_); 461 host_->Start(xmpp_login_);
467 SimulateClientConnection(0, true, false); 462 SimulateClientConnection(0, true, false);
468 message_loop_.Run(); 463 message_loop_.Run();
469 } 464 }
470 465
471 TEST_F(ChromotingHostTest, RejectAuthenticatingClient) {
472 Expectation start = ExpectHostAndSessionManagerStart();
473 EXPECT_CALL(host_status_observer_, OnClientAuthenticated(session_jid1_))
474 .WillOnce(InvokeWithoutArgs(
475 this, &ChromotingHostTest::RejectAuthenticatingClient));
476 ExpectClientDisconnected(
477 0, true, start,
478 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost));
479 EXPECT_CALL(host_status_observer_, OnShutdown());
480
481 host_->Start(xmpp_login_);
482 SimulateClientConnection(0, true, true);
483 message_loop_.Run();
484 }
485
486 TEST_F(ChromotingHostTest, AuthenticationFailed) { 466 TEST_F(ChromotingHostTest, AuthenticationFailed) {
487 ExpectHostAndSessionManagerStart(); 467 ExpectHostAndSessionManagerStart();
488 EXPECT_CALL(host_status_observer_, OnAccessDenied(session_jid1_)) 468 EXPECT_CALL(host_status_observer_, OnAccessDenied(session_jid1_))
489 .WillOnce(InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost)); 469 .WillOnce(InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost));
490 EXPECT_CALL(host_status_observer_, OnShutdown()); 470 EXPECT_CALL(host_status_observer_, OnShutdown());
491 471
492 host_->Start(xmpp_login_); 472 host_->Start(xmpp_login_);
493 SimulateClientConnection(0, false, false); 473 SimulateClientConnection(0, false, false);
494 message_loop_.Run(); 474 message_loop_.Run();
495 } 475 }
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
658 ExpectClientDisconnected(0, true, video_packet_sent, 638 ExpectClientDisconnected(0, true, video_packet_sent,
659 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost)); 639 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost));
660 EXPECT_CALL(host_status_observer_, OnShutdown()); 640 EXPECT_CALL(host_status_observer_, OnShutdown());
661 641
662 host_->Start(xmpp_login_); 642 host_->Start(xmpp_login_);
663 SimulateClientConnection(0, true, false); 643 SimulateClientConnection(0, true, false);
664 message_loop_.Run(); 644 message_loop_.Run();
665 } 645 }
666 646
667 } // namespace remoting 647 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/chromoting_host.cc ('k') | remoting/host/client_session.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698