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

Side by Side Diff: remoting/protocol/jingle_session_unittest.cc

Issue 1302233003: Replace gmock's deprecated SetArgumentPointee with SetArgPointee. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 2017 Created 3 years, 7 months 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 | « media/filters/ffmpeg_glue_unittest.cc ('k') | no next file » | 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 "remoting/protocol/jingle_session.h" 5 #include "remoting/protocol/jingle_session.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 26 matching lines...) Expand all
37 using testing::_; 37 using testing::_;
38 using testing::AtLeast; 38 using testing::AtLeast;
39 using testing::AtMost; 39 using testing::AtMost;
40 using testing::DeleteArg; 40 using testing::DeleteArg;
41 using testing::DoAll; 41 using testing::DoAll;
42 using testing::InSequence; 42 using testing::InSequence;
43 using testing::Invoke; 43 using testing::Invoke;
44 using testing::InvokeWithoutArgs; 44 using testing::InvokeWithoutArgs;
45 using testing::Return; 45 using testing::Return;
46 using testing::SaveArg; 46 using testing::SaveArg;
47 using testing::SetArgumentPointee; 47 using testing::SetArgPointee;
48 using testing::WithArg; 48 using testing::WithArg;
49 49
50 namespace remoting { 50 namespace remoting {
51 namespace protocol { 51 namespace protocol {
52 52
53 namespace { 53 namespace {
54 54
55 const char kHostJid[] = "Host@gmail.com/123"; 55 const char kHostJid[] = "Host@gmail.com/123";
56 const char kClientJid[] = "Client@gmail.com/321"; 56 const char kClientJid[] = "Client@gmail.com/321";
57 57
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 host_server_.reset(); 216 host_server_.reset();
217 client_server_.reset(); 217 client_server_.reset();
218 host_signal_strategy_.reset(); 218 host_signal_strategy_.reset();
219 client_signal_strategy_.reset(); 219 client_signal_strategy_.reset();
220 } 220 }
221 221
222 void SetHostExpectation(bool expect_fail) { 222 void SetHostExpectation(bool expect_fail) {
223 EXPECT_CALL(host_server_listener_, OnIncomingSession(_, _)) 223 EXPECT_CALL(host_server_listener_, OnIncomingSession(_, _))
224 .WillOnce( 224 .WillOnce(
225 DoAll(WithArg<0>(Invoke(this, &JingleSessionTest::SetHostSession)), 225 DoAll(WithArg<0>(Invoke(this, &JingleSessionTest::SetHostSession)),
226 SetArgumentPointee<1>(protocol::SessionManager::ACCEPT))); 226 SetArgPointee<1>(protocol::SessionManager::ACCEPT)));
227 227
228 { 228 {
229 InSequence dummy; 229 InSequence dummy;
230 230
231 EXPECT_CALL(host_session_event_handler_, 231 EXPECT_CALL(host_session_event_handler_,
232 OnSessionStateChange(Session::ACCEPTED)) 232 OnSessionStateChange(Session::ACCEPTED))
233 .Times(AtMost(1)); 233 .Times(AtMost(1));
234 EXPECT_CALL(host_session_event_handler_, 234 EXPECT_CALL(host_session_event_handler_,
235 OnSessionStateChange(Session::AUTHENTICATING)) 235 OnSessionStateChange(Session::AUTHENTICATING))
236 .Times(AtMost(1)); 236 .Times(AtMost(1));
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 CreateSessionManagers(FakeAuthenticator::Config(FakeAuthenticator::ACCEPT)); 350 CreateSessionManagers(FakeAuthenticator::Config(FakeAuthenticator::ACCEPT));
351 } 351 }
352 352
353 // Verify that an incoming session can be rejected, and that the 353 // Verify that an incoming session can be rejected, and that the
354 // status of the connection is set to FAILED in this case. 354 // status of the connection is set to FAILED in this case.
355 TEST_F(JingleSessionTest, RejectConnection) { 355 TEST_F(JingleSessionTest, RejectConnection) {
356 CreateSessionManagers(FakeAuthenticator::Config(FakeAuthenticator::ACCEPT)); 356 CreateSessionManagers(FakeAuthenticator::Config(FakeAuthenticator::ACCEPT));
357 357
358 // Reject incoming session. 358 // Reject incoming session.
359 EXPECT_CALL(host_server_listener_, OnIncomingSession(_, _)) 359 EXPECT_CALL(host_server_listener_, OnIncomingSession(_, _))
360 .WillOnce(SetArgumentPointee<1>(protocol::SessionManager::DECLINE)); 360 .WillOnce(SetArgPointee<1>(protocol::SessionManager::DECLINE));
361 361
362 { 362 {
363 InSequence dummy; 363 InSequence dummy;
364 EXPECT_CALL(client_session_event_handler_, 364 EXPECT_CALL(client_session_event_handler_,
365 OnSessionStateChange(Session::FAILED)) 365 OnSessionStateChange(Session::FAILED))
366 .Times(1); 366 .Times(1);
367 } 367 }
368 368
369 ConnectClient(FakeAuthenticator::Config(FakeAuthenticator::ACCEPT)); 369 ConnectClient(FakeAuthenticator::Config(FakeAuthenticator::ACCEPT));
370 client_session_->SetEventHandler(&client_session_event_handler_); 370 client_session_->SetEventHandler(&client_session_event_handler_);
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 EXPECT_FALSE(host_session_); 490 EXPECT_FALSE(host_session_);
491 } 491 }
492 492
493 TEST_F(JingleSessionTest, DeleteSessionOnIncomingConnection) { 493 TEST_F(JingleSessionTest, DeleteSessionOnIncomingConnection) {
494 const int kAuthRoundtrips = 3; 494 const int kAuthRoundtrips = 3;
495 FakeAuthenticator::Config auth_config(kAuthRoundtrips, 495 FakeAuthenticator::Config auth_config(kAuthRoundtrips,
496 FakeAuthenticator::ACCEPT, true); 496 FakeAuthenticator::ACCEPT, true);
497 CreateSessionManagers(auth_config); 497 CreateSessionManagers(auth_config);
498 498
499 EXPECT_CALL(host_server_listener_, OnIncomingSession(_, _)) 499 EXPECT_CALL(host_server_listener_, OnIncomingSession(_, _))
500 .WillOnce(DoAll( 500 .WillOnce(
501 WithArg<0>(Invoke(this, &JingleSessionTest::SetHostSession)), 501 DoAll(WithArg<0>(Invoke(this, &JingleSessionTest::SetHostSession)),
502 SetArgumentPointee<1>(protocol::SessionManager::ACCEPT))); 502 SetArgPointee<1>(protocol::SessionManager::ACCEPT)));
503 503
504 EXPECT_CALL(host_session_event_handler_, 504 EXPECT_CALL(host_session_event_handler_,
505 OnSessionStateChange(Session::ACCEPTED)) 505 OnSessionStateChange(Session::ACCEPTED))
506 .Times(AtMost(1)); 506 .Times(AtMost(1));
507 507
508 EXPECT_CALL(host_session_event_handler_, 508 EXPECT_CALL(host_session_event_handler_,
509 OnSessionStateChange(Session::AUTHENTICATING)) 509 OnSessionStateChange(Session::AUTHENTICATING))
510 .WillOnce(InvokeWithoutArgs(this, &JingleSessionTest::DeleteHostSession)); 510 .WillOnce(InvokeWithoutArgs(this, &JingleSessionTest::DeleteHostSession));
511 511
512 ConnectClient(auth_config); 512 ConnectClient(auth_config);
513 } 513 }
514 514
515 TEST_F(JingleSessionTest, DeleteSessionOnAuth) { 515 TEST_F(JingleSessionTest, DeleteSessionOnAuth) {
516 // Same as the previous test, but set messages_till_started to 2 in 516 // Same as the previous test, but set messages_till_started to 2 in
517 // CreateSessionManagers so that the session will goes into the 517 // CreateSessionManagers so that the session will goes into the
518 // AUTHENTICATING state after two message exchanges. 518 // AUTHENTICATING state after two message exchanges.
519 const int kMessagesTillStarted = 2; 519 const int kMessagesTillStarted = 2;
520 520
521 const int kAuthRoundtrips = 3; 521 const int kAuthRoundtrips = 3;
522 FakeAuthenticator::Config auth_config(kAuthRoundtrips, 522 FakeAuthenticator::Config auth_config(kAuthRoundtrips,
523 FakeAuthenticator::ACCEPT, true); 523 FakeAuthenticator::ACCEPT, true);
524 CreateSessionManagers(auth_config, kMessagesTillStarted); 524 CreateSessionManagers(auth_config, kMessagesTillStarted);
525 525
526 EXPECT_CALL(host_server_listener_, OnIncomingSession(_, _)) 526 EXPECT_CALL(host_server_listener_, OnIncomingSession(_, _))
527 .WillOnce( 527 .WillOnce(
528 DoAll(WithArg<0>(Invoke(this, &JingleSessionTest::SetHostSession)), 528 DoAll(WithArg<0>(Invoke(this, &JingleSessionTest::SetHostSession)),
529 SetArgumentPointee<1>(protocol::SessionManager::ACCEPT))); 529 SetArgPointee<1>(protocol::SessionManager::ACCEPT)));
530 530
531 EXPECT_CALL(host_session_event_handler_, 531 EXPECT_CALL(host_session_event_handler_,
532 OnSessionStateChange(Session::ACCEPTED)) 532 OnSessionStateChange(Session::ACCEPTED))
533 .Times(AtMost(1)); 533 .Times(AtMost(1));
534 534
535 EXPECT_CALL(host_session_event_handler_, 535 EXPECT_CALL(host_session_event_handler_,
536 OnSessionStateChange(Session::AUTHENTICATING)) 536 OnSessionStateChange(Session::AUTHENTICATING))
537 .WillOnce(InvokeWithoutArgs(this, &JingleSessionTest::DeleteHostSession)); 537 .WillOnce(InvokeWithoutArgs(this, &JingleSessionTest::DeleteHostSession));
538 538
539 ConnectClient(auth_config); 539 ConnectClient(auth_config);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 629
630 client_session_->Close(HOST_OVERLOAD); 630 client_session_->Close(HOST_OVERLOAD);
631 base::RunLoop().RunUntilIdle(); 631 base::RunLoop().RunUntilIdle();
632 // We should only send a SESSION_TERMINATE message if the session has been 632 // We should only send a SESSION_TERMINATE message if the session has been
633 // closed before SESSION_INITIATE message. 633 // closed before SESSION_INITIATE message.
634 ASSERT_EQ(1U, host_signal_strategy_->received_messages().size()); 634 ASSERT_EQ(1U, host_signal_strategy_->received_messages().size());
635 } 635 }
636 636
637 } // namespace protocol 637 } // namespace protocol
638 } // namespace remoting 638 } // namespace remoting
OLDNEW
« no previous file with comments | « media/filters/ffmpeg_glue_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698