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

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

Issue 4192012: Convert implicit scoped_refptr constructor calls to explicit ones, part 1 (Closed) Base URL: http://git.chromium.org/git/chromium.git
Patch Set: fix presubmit Created 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/time.h" 5 #include "base/time.h"
6 #include "base/waitable_event.h" 6 #include "base/waitable_event.h"
7 #include "base/test/test_timeouts.h" 7 #include "base/test/test_timeouts.h"
8 #include "net/base/completion_callback.h" 8 #include "net/base/completion_callback.h"
9 #include "net/base/io_buffer.h" 9 #include "net/base/io_buffer.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 session_manager_pair_ = new SessionManagerPair(&thread_); 111 session_manager_pair_ = new SessionManagerPair(&thread_);
112 session_manager_pair_->Init(); 112 session_manager_pair_->Init();
113 host_server_ = new JingleChromotocolServer(&thread_); 113 host_server_ = new JingleChromotocolServer(&thread_);
114 host_server_->set_allow_local_ips(true); 114 host_server_->set_allow_local_ips(true);
115 host_server_->Init(SessionManagerPair::kHostJid, 115 host_server_->Init(SessionManagerPair::kHostJid,
116 session_manager_pair_->host_session_manager(), 116 session_manager_pair_->host_session_manager(),
117 NewCallback(&host_server_callback_, 117 NewCallback(&host_server_callback_,
118 &MockServerCallback::OnIncomingConnection)); 118 &MockServerCallback::OnIncomingConnection));
119 client_server_ = new JingleChromotocolServer(&thread_); 119 client_server_ = new JingleChromotocolServer(&thread_);
120 client_server_->set_allow_local_ips(true); 120 client_server_->set_allow_local_ips(true);
121 client_server_->Init(SessionManagerPair::kClientJid, 121 client_server_->Init(
122 session_manager_pair_->client_session_manager(), 122 SessionManagerPair::kClientJid,
123 NewCallback(&client_server_callback_, 123 session_manager_pair_->client_session_manager(),
124 &MockServerCallback::OnIncomingConnection)) ; 124 NewCallback(&client_server_callback_,
125 &MockServerCallback::OnIncomingConnection));
125 } 126 }
126 127
127 bool InitiateConnection() { 128 bool InitiateConnection() {
128 EXPECT_CALL(host_server_callback_, OnIncomingConnection(_, _)) 129 EXPECT_CALL(host_server_callback_, OnIncomingConnection(_, _))
129 .WillOnce(DoAll( 130 .WillOnce(DoAll(
130 WithArg<0>(Invoke( 131 WithArg<0>(Invoke(
131 this, &JingleChromotocolConnectionTest::SetHostConnection)), 132 this, &JingleChromotocolConnectionTest::SetHostConnection)),
132 SetArgumentPointee<1>(ChromotocolServer::ACCEPT))); 133 SetArgumentPointee<1>(ChromotocolServer::ACCEPT)));
133 134
134 base::WaitableEvent host_connected_event(false, false); 135 base::WaitableEvent host_connected_event(false, false);
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 protected: 416 protected:
416 virtual void InitBuffers() { 417 virtual void InitBuffers() {
417 } 418 }
418 419
419 virtual void DoWrite() { 420 virtual void DoWrite() {
420 if (packets_sent_ >= kMessages) { 421 if (packets_sent_ >= kMessages) {
421 done_event_.Signal(); 422 done_event_.Signal();
422 return; 423 return;
423 } 424 }
424 425
425 scoped_refptr<net::IOBuffer> packet = new net::IOBuffer(kMessageSize); 426 scoped_refptr<net::IOBuffer> packet(new net::IOBuffer(kMessageSize));
426 memset(packet->data(), 123, kMessageSize); 427 memset(packet->data(), 123, kMessageSize);
427 sent_packets_[packets_sent_] = packet; 428 sent_packets_[packets_sent_] = packet;
428 // Put index of this packet in the beginning of the packet body. 429 // Put index of this packet in the beginning of the packet body.
429 memcpy(packet->data(), &packets_sent_, sizeof(packets_sent_)); 430 memcpy(packet->data(), &packets_sent_, sizeof(packets_sent_));
430 431
431 int result = socket_1_->Write(packet, kMessageSize, &write_cb_); 432 int result = socket_1_->Write(packet, kMessageSize, &write_cb_);
432 HandleWriteResult(result); 433 HandleWriteResult(result);
433 } 434 }
434 435
435 void OnWritten(int result) { 436 void OnWritten(int result) {
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 // Verify that we can connect two endpoints. 545 // Verify that we can connect two endpoints.
545 TEST_F(JingleChromotocolConnectionTest, Connect) { 546 TEST_F(JingleChromotocolConnectionTest, Connect) {
546 CreateServerPair(); 547 CreateServerPair();
547 ASSERT_TRUE(InitiateConnection()); 548 ASSERT_TRUE(InitiateConnection());
548 } 549 }
549 550
550 // Verify that data can be transmitted over the event channel. 551 // Verify that data can be transmitted over the event channel.
551 TEST_F(JingleChromotocolConnectionTest, TestControlChannel) { 552 TEST_F(JingleChromotocolConnectionTest, TestControlChannel) {
552 CreateServerPair(); 553 CreateServerPair();
553 ASSERT_TRUE(InitiateConnection()); 554 ASSERT_TRUE(InitiateConnection());
554 scoped_refptr<TCPChannelTester> tester = 555 scoped_refptr<TCPChannelTester> tester(
555 new TCPChannelTester(thread_.message_loop(), host_connection_, 556 new TCPChannelTester(thread_.message_loop(), host_connection_,
556 client_connection_); 557 client_connection_));
557 tester->Start(ChannelTesterBase::CONTROL); 558 tester->Start(ChannelTesterBase::CONTROL);
558 ASSERT_TRUE(tester->WaitFinished()); 559 ASSERT_TRUE(tester->WaitFinished());
559 tester->CheckResults(); 560 tester->CheckResults();
560 561
561 // Connections must be closed while |tester| still exists. 562 // Connections must be closed while |tester| still exists.
562 CloseConnections(); 563 CloseConnections();
563 } 564 }
564 565
565 566
566 // Verify that data can be transmitted over the video channel. 567 // Verify that data can be transmitted over the video channel.
567 TEST_F(JingleChromotocolConnectionTest, TestVideoChannel) { 568 TEST_F(JingleChromotocolConnectionTest, TestVideoChannel) {
568 CreateServerPair(); 569 CreateServerPair();
569 ASSERT_TRUE(InitiateConnection()); 570 ASSERT_TRUE(InitiateConnection());
570 scoped_refptr<TCPChannelTester> tester = 571 scoped_refptr<TCPChannelTester> tester(
571 new TCPChannelTester(thread_.message_loop(), host_connection_, 572 new TCPChannelTester(thread_.message_loop(), host_connection_,
572 client_connection_); 573 client_connection_));
573 tester->Start(ChannelTesterBase::VIDEO); 574 tester->Start(ChannelTesterBase::VIDEO);
574 ASSERT_TRUE(tester->WaitFinished()); 575 ASSERT_TRUE(tester->WaitFinished());
575 tester->CheckResults(); 576 tester->CheckResults();
576 577
577 // Connections must be closed while |tester| still exists. 578 // Connections must be closed while |tester| still exists.
578 CloseConnections(); 579 CloseConnections();
579 } 580 }
580 581
581 // Verify that data can be transmitted over the event channel. 582 // Verify that data can be transmitted over the event channel.
582 TEST_F(JingleChromotocolConnectionTest, TestEventChannel) { 583 TEST_F(JingleChromotocolConnectionTest, TestEventChannel) {
583 CreateServerPair(); 584 CreateServerPair();
584 ASSERT_TRUE(InitiateConnection()); 585 ASSERT_TRUE(InitiateConnection());
585 scoped_refptr<TCPChannelTester> tester = 586 scoped_refptr<TCPChannelTester> tester(
586 new TCPChannelTester(thread_.message_loop(), host_connection_, 587 new TCPChannelTester(thread_.message_loop(), host_connection_,
587 client_connection_); 588 client_connection_));
588 tester->Start(ChannelTesterBase::EVENT); 589 tester->Start(ChannelTesterBase::EVENT);
589 ASSERT_TRUE(tester->WaitFinished()); 590 ASSERT_TRUE(tester->WaitFinished());
590 tester->CheckResults(); 591 tester->CheckResults();
591 592
592 // Connections must be closed while |tester| still exists. 593 // Connections must be closed while |tester| still exists.
593 CloseConnections(); 594 CloseConnections();
594 } 595 }
595 596
596 // Verify that data can be transmitted over the video RTP channel. 597 // Verify that data can be transmitted over the video RTP channel.
597 TEST_F(JingleChromotocolConnectionTest, TestVideoRtpChannel) { 598 TEST_F(JingleChromotocolConnectionTest, TestVideoRtpChannel) {
598 CreateServerPair(); 599 CreateServerPair();
599 ASSERT_TRUE(InitiateConnection()); 600 ASSERT_TRUE(InitiateConnection());
600 scoped_refptr<UDPChannelTester> tester = 601 scoped_refptr<UDPChannelTester> tester(
601 new UDPChannelTester(thread_.message_loop(), host_connection_, 602 new UDPChannelTester(thread_.message_loop(), host_connection_,
602 client_connection_); 603 client_connection_));
603 tester->Start(ChannelTesterBase::VIDEO_RTP); 604 tester->Start(ChannelTesterBase::VIDEO_RTP);
604 ASSERT_TRUE(tester->WaitFinished()); 605 ASSERT_TRUE(tester->WaitFinished());
605 tester->CheckResults(); 606 tester->CheckResults();
606 607
607 // Connections must be closed while |tester| still exists. 608 // Connections must be closed while |tester| still exists.
608 CloseConnections(); 609 CloseConnections();
609 } 610 }
610 611
611 } // namespace remoting 612 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/host_message_dispatcher.cc ('k') | remoting/protocol/jingle_chromotocol_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698