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

Side by Side Diff: webrtc/p2p/base/p2ptransportchannel_unittest.cc

Issue 1246913005: TransportController refactoring (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Set media engine on voice channel Created 5 years, 4 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
OLDNEW
1 /* 1 /*
2 * Copyright 2009 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2009 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 } 296 }
297 cricket::P2PTransportChannel* CreateChannel( 297 cricket::P2PTransportChannel* CreateChannel(
298 int endpoint, 298 int endpoint,
299 int component, 299 int component,
300 const std::string& local_ice_ufrag, 300 const std::string& local_ice_ufrag,
301 const std::string& local_ice_pwd, 301 const std::string& local_ice_pwd,
302 const std::string& remote_ice_ufrag, 302 const std::string& remote_ice_ufrag,
303 const std::string& remote_ice_pwd) { 303 const std::string& remote_ice_pwd) {
304 cricket::P2PTransportChannel* channel = new cricket::P2PTransportChannel( 304 cricket::P2PTransportChannel* channel = new cricket::P2PTransportChannel(
305 "test content name", component, NULL, GetAllocator(endpoint)); 305 "test content name", component, NULL, GetAllocator(endpoint));
306 channel->SignalRequestSignaling.connect( 306 channel->SignalCandidateGathered.connect(
307 this, &P2PTransportChannelTestBase::OnChannelRequestSignaling); 307 this, &P2PTransportChannelTestBase::OnCandidate);
308 channel->SignalCandidateReady.connect(this,
309 &P2PTransportChannelTestBase::OnCandidate);
310 channel->SignalReadPacket.connect( 308 channel->SignalReadPacket.connect(
311 this, &P2PTransportChannelTestBase::OnReadPacket); 309 this, &P2PTransportChannelTestBase::OnReadPacket);
312 channel->SignalRoleConflict.connect( 310 channel->SignalRoleConflict.connect(
313 this, &P2PTransportChannelTestBase::OnRoleConflict); 311 this, &P2PTransportChannelTestBase::OnRoleConflict);
314 channel->SetIceProtocolType(GetEndpoint(endpoint)->protocol_type()); 312 channel->SetIceProtocolType(GetEndpoint(endpoint)->protocol_type());
315 channel->SetIceCredentials(local_ice_ufrag, local_ice_pwd); 313 channel->SetIceCredentials(local_ice_ufrag, local_ice_pwd);
316 if (clear_remote_candidates_ufrag_pwd_) { 314 if (clear_remote_candidates_ufrag_pwd_) {
317 // This only needs to be set if we're clearing them from the 315 // This only needs to be set if we're clearing them from the
318 // candidates. Some unit tests rely on this not being set. 316 // candidates. Some unit tests rely on this not being set.
319 channel->SetRemoteIceCredentials(remote_ice_ufrag, remote_ice_pwd); 317 channel->SetRemoteIceCredentials(remote_ice_ufrag, remote_ice_pwd);
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 1000); 607 1000);
610 EXPECT_TRUE( 608 EXPECT_TRUE(
611 ep1_ch1()->best_connection() && ep2_ch1()->best_connection() && 609 ep1_ch1()->best_connection() && ep2_ch1()->best_connection() &&
612 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) && 610 LocalCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[0]) &&
613 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1])); 611 RemoteCandidate(ep1_ch1())->address().EqualIPs(kPublicAddrs[1]));
614 612
615 TestSendRecv(1); 613 TestSendRecv(1);
616 DestroyChannels(); 614 DestroyChannels();
617 } 615 }
618 616
619 void OnChannelRequestSignaling(cricket::TransportChannelImpl* channel) {
620 channel->OnSignalingReady();
621 }
622 // We pass the candidates directly to the other side. 617 // We pass the candidates directly to the other side.
623 void OnCandidate(cricket::TransportChannelImpl* ch, 618 void OnCandidate(cricket::TransportChannelImpl* ch,
624 const cricket::Candidate& c) { 619 const cricket::Candidate& c) {
625 if (force_relay_ && c.type() != cricket::RELAY_PORT_TYPE) 620 if (force_relay_ && c.type() != cricket::RELAY_PORT_TYPE)
626 return; 621 return;
627 622
628 if (GetEndpoint(ch)->save_candidates_) { 623 if (GetEndpoint(ch)->save_candidates_) {
629 GetEndpoint(ch)->saved_candidates_.push_back(new CandidateData(ch, c)); 624 GetEndpoint(ch)->saved_candidates_.push_back(new CandidateData(ch, c));
630 } else { 625 } else {
631 main_->Post(this, MSG_CANDIDATE, new CandidateData(ch, c)); 626 main_->Post(this, MSG_CANDIDATE, new CandidateData(ch, c));
(...skipping 1073 matching lines...) Expand 10 before | Expand all | Expand 10 after
1705 class P2PTransportChannelPingTest : public testing::Test, 1700 class P2PTransportChannelPingTest : public testing::Test,
1706 public sigslot::has_slots<> { 1701 public sigslot::has_slots<> {
1707 public: 1702 public:
1708 P2PTransportChannelPingTest() 1703 P2PTransportChannelPingTest()
1709 : pss_(new rtc::PhysicalSocketServer), 1704 : pss_(new rtc::PhysicalSocketServer),
1710 vss_(new rtc::VirtualSocketServer(pss_.get())), 1705 vss_(new rtc::VirtualSocketServer(pss_.get())),
1711 ss_scope_(vss_.get()) {} 1706 ss_scope_(vss_.get()) {}
1712 1707
1713 protected: 1708 protected:
1714 void PrepareChannel(cricket::P2PTransportChannel* ch) { 1709 void PrepareChannel(cricket::P2PTransportChannel* ch) {
1715 ch->SignalRequestSignaling.connect(
1716 this, &P2PTransportChannelPingTest::OnChannelRequestSignaling);
1717 ch->SetIceProtocolType(cricket::ICEPROTO_RFC5245); 1710 ch->SetIceProtocolType(cricket::ICEPROTO_RFC5245);
1718 ch->SetIceRole(cricket::ICEROLE_CONTROLLING); 1711 ch->SetIceRole(cricket::ICEROLE_CONTROLLING);
1719 ch->SetIceCredentials(kIceUfrag[0], kIcePwd[0]); 1712 ch->SetIceCredentials(kIceUfrag[0], kIcePwd[0]);
1720 ch->SetRemoteIceCredentials(kIceUfrag[1], kIcePwd[1]); 1713 ch->SetRemoteIceCredentials(kIceUfrag[1], kIcePwd[1]);
1721 } 1714 }
1722 1715
1723 void OnChannelRequestSignaling(cricket::TransportChannelImpl* channel) {
1724 channel->OnSignalingReady();
1725 }
1726
1727 cricket::Candidate CreateCandidate(const std::string& ip, 1716 cricket::Candidate CreateCandidate(const std::string& ip,
1728 int port, 1717 int port,
1729 int priority) { 1718 int priority) {
1730 cricket::Candidate c; 1719 cricket::Candidate c;
1731 c.set_address(rtc::SocketAddress(ip, port)); 1720 c.set_address(rtc::SocketAddress(ip, port));
1732 c.set_component(1); 1721 c.set_component(1);
1733 c.set_protocol(cricket::UDP_PROTOCOL_NAME); 1722 c.set_protocol(cricket::UDP_PROTOCOL_NAME);
1734 c.set_priority(priority); 1723 c.set_priority(priority);
1735 return c; 1724 return c;
1736 } 1725 }
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
1877 ch.OnCandidate(CreateCandidate("1.1.1.1", 1, 1)); 1866 ch.OnCandidate(CreateCandidate("1.1.1.1", 1, 1));
1878 cricket::Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1); 1867 cricket::Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1);
1879 ASSERT_TRUE(conn1 != nullptr); 1868 ASSERT_TRUE(conn1 != nullptr);
1880 1869
1881 conn1->ReceivedPing(); 1870 conn1->ReceivedPing();
1882 conn1->OnReadPacket("ABC", 3, rtc::CreatePacketTime(0)); 1871 conn1->OnReadPacket("ABC", 3, rtc::CreatePacketTime(0));
1883 EXPECT_TRUE_WAIT(ch.best_connection() != nullptr, 1000) 1872 EXPECT_TRUE_WAIT(ch.best_connection() != nullptr, 1000)
1884 EXPECT_TRUE_WAIT(ch.receiving(), 1000); 1873 EXPECT_TRUE_WAIT(ch.receiving(), 1000);
1885 EXPECT_TRUE_WAIT(!ch.receiving(), 1000); 1874 EXPECT_TRUE_WAIT(!ch.receiving(), 1000);
1886 } 1875 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698