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

Unified Diff: webrtc/p2p/base/transportcontroller_unittest.cc

Issue 2606123002: Remove the dependency of TransportChannel and TransportChannelImpl. (Closed)
Patch Set: Fix the memory leak. Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/p2p/base/transportcontroller.cc ('k') | webrtc/p2p/base/udptransport.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/p2p/base/transportcontroller_unittest.cc
diff --git a/webrtc/p2p/base/transportcontroller_unittest.cc b/webrtc/p2p/base/transportcontroller_unittest.cc
index bafffa031ed238132e7d13a3bb74029bb1c84c98..1fc71f1274c45aa1e81d4635e00373c42471c42c 100644
--- a/webrtc/p2p/base/transportcontroller_unittest.cc
+++ b/webrtc/p2p/base/transportcontroller_unittest.cc
@@ -71,15 +71,14 @@ class TransportControllerTest : public testing::Test,
this, &TransportControllerTest::OnCandidatesGathered);
}
- FakeTransportChannel* CreateChannel(const std::string& content,
- int component) {
- TransportChannel* channel =
- transport_controller_->CreateTransportChannel_n(content, component);
- return static_cast<FakeTransportChannel*>(channel);
+ FakeDtlsTransport* CreateChannel(const std::string& content, int component) {
+ DtlsTransportInternal* channel =
+ transport_controller_->CreateDtlsTransport_n(content, component);
+ return static_cast<FakeDtlsTransport*>(channel);
}
void DestroyChannel(const std::string& content, int component) {
- transport_controller_->DestroyTransportChannel_n(content, component);
+ transport_controller_->DestroyDtlsTransport_n(content, component);
}
Candidate CreateCandidate(int component) {
@@ -102,9 +101,9 @@ class TransportControllerTest : public testing::Test,
void CreateChannelsAndCompleteConnection_w() {
transport_controller_->SetIceRole(ICEROLE_CONTROLLING);
- FakeTransportChannel* channel1 = CreateChannel("audio", 1);
+ FakeDtlsTransport* channel1 = CreateChannel("audio", 1);
ASSERT_NE(nullptr, channel1);
- FakeTransportChannel* channel2 = CreateChannel("video", 1);
+ FakeDtlsTransport* channel2 = CreateChannel("video", 1);
ASSERT_NE(nullptr, channel2);
TransportDescription local_desc(std::vector<std::string>(), kIceUfrag1,
@@ -116,8 +115,10 @@ class TransportControllerTest : public testing::Test,
transport_controller_->SetLocalTransportDescription("video", local_desc,
CA_OFFER, &err);
transport_controller_->MaybeStartGathering();
- channel1->SignalCandidateGathered(channel1, CreateCandidate(1));
- channel2->SignalCandidateGathered(channel2, CreateCandidate(1));
+ channel1->ice_transport()->SignalCandidateGathered(
+ channel1->ice_transport(), CreateCandidate(1));
+ channel2->ice_transport()->SignalCandidateGathered(
+ channel2->ice_transport(), CreateCandidate(1));
channel1->SetCandidatesGatheringComplete();
channel2->SetCandidatesGatheringComplete();
channel1->SetConnectionCount(2);
@@ -195,7 +196,7 @@ class TransportControllerTest : public testing::Test,
};
TEST_F(TransportControllerTest, TestSetIceConfig) {
- FakeTransportChannel* channel1 = CreateChannel("audio", 1);
+ FakeDtlsTransport* channel1 = CreateChannel("audio", 1);
ASSERT_NE(nullptr, channel1);
transport_controller_->SetIceConfig(
@@ -206,7 +207,7 @@ TEST_F(TransportControllerTest, TestSetIceConfig) {
transport_controller_->SetIceConfig(
CreateIceConfig(1000, GATHER_CONTINUALLY_AND_RECOVER));
// Test that value stored in controller is applied to new channels.
- FakeTransportChannel* channel2 = CreateChannel("video", 1);
+ FakeDtlsTransport* channel2 = CreateChannel("video", 1);
ASSERT_NE(nullptr, channel2);
EXPECT_EQ(1000, channel2->receiving_timeout());
EXPECT_TRUE(channel2->gather_continually());
@@ -215,7 +216,7 @@ TEST_F(TransportControllerTest, TestSetIceConfig) {
TEST_F(TransportControllerTest, TestSetSslMaxProtocolVersion) {
EXPECT_TRUE(transport_controller_->SetSslMaxProtocolVersion(
rtc::SSL_PROTOCOL_DTLS_12));
- FakeTransportChannel* channel = CreateChannel("audio", 1);
+ FakeDtlsTransport* channel = CreateChannel("audio", 1);
ASSERT_NE(nullptr, channel);
EXPECT_EQ(rtc::SSL_PROTOCOL_DTLS_12, channel->ssl_max_protocol_version());
@@ -226,7 +227,7 @@ TEST_F(TransportControllerTest, TestSetSslMaxProtocolVersion) {
}
TEST_F(TransportControllerTest, TestSetIceRole) {
- FakeTransportChannel* channel1 = CreateChannel("audio", 1);
+ FakeDtlsTransport* channel1 = CreateChannel("audio", 1);
ASSERT_NE(nullptr, channel1);
transport_controller_->SetIceRole(ICEROLE_CONTROLLING);
@@ -235,7 +236,7 @@ TEST_F(TransportControllerTest, TestSetIceRole) {
EXPECT_EQ(ICEROLE_CONTROLLED, channel1->GetIceRole());
// Test that value stored in controller is applied to new channels.
- FakeTransportChannel* channel2 = CreateChannel("video", 1);
+ FakeDtlsTransport* channel2 = CreateChannel("video", 1);
ASSERT_NE(nullptr, channel2);
EXPECT_EQ(ICEROLE_CONTROLLED, channel2->GetIceRole());
}
@@ -243,28 +244,28 @@ TEST_F(TransportControllerTest, TestSetIceRole) {
// Test that when one channel encounters a role conflict, the ICE role is
// swapped on every channel.
TEST_F(TransportControllerTest, TestIceRoleConflict) {
- FakeTransportChannel* channel1 = CreateChannel("audio", 1);
+ FakeDtlsTransport* channel1 = CreateChannel("audio", 1);
ASSERT_NE(nullptr, channel1);
- FakeTransportChannel* channel2 = CreateChannel("video", 1);
+ FakeDtlsTransport* channel2 = CreateChannel("video", 1);
ASSERT_NE(nullptr, channel2);
transport_controller_->SetIceRole(ICEROLE_CONTROLLING);
EXPECT_EQ(ICEROLE_CONTROLLING, channel1->GetIceRole());
EXPECT_EQ(ICEROLE_CONTROLLING, channel2->GetIceRole());
- channel1->SignalRoleConflict(channel1);
+ channel1->ice_transport()->SignalRoleConflict(channel1->ice_transport());
EXPECT_EQ(ICEROLE_CONTROLLED, channel1->GetIceRole());
EXPECT_EQ(ICEROLE_CONTROLLED, channel2->GetIceRole());
// Should be able to handle a second role conflict. The remote endpoint can
// change its role/tie-breaker when it does an ICE restart.
- channel2->SignalRoleConflict(channel2);
+ channel2->ice_transport()->SignalRoleConflict(channel2->ice_transport());
EXPECT_EQ(ICEROLE_CONTROLLING, channel1->GetIceRole());
EXPECT_EQ(ICEROLE_CONTROLLING, channel2->GetIceRole());
}
TEST_F(TransportControllerTest, TestGetSslRole) {
- FakeTransportChannel* channel = CreateChannel("audio", 1);
+ FakeDtlsTransport* channel = CreateChannel("audio", 1);
ASSERT_NE(nullptr, channel);
ASSERT_TRUE(channel->SetSslRole(rtc::SSL_CLIENT));
rtc::SSLRole role;
@@ -282,7 +283,7 @@ TEST_F(TransportControllerTest, TestSetAndGetLocalCertificate) {
rtc::SSLIdentity::Generate("session2", rtc::KT_DEFAULT)));
rtc::scoped_refptr<rtc::RTCCertificate> returned_certificate;
- FakeTransportChannel* channel1 = CreateChannel("audio", 1);
+ FakeDtlsTransport* channel1 = CreateChannel("audio", 1);
ASSERT_NE(nullptr, channel1);
EXPECT_TRUE(transport_controller_->SetLocalCertificate(certificate1));
@@ -296,7 +297,7 @@ TEST_F(TransportControllerTest, TestSetAndGetLocalCertificate) {
"video", &returned_certificate));
// Test that identity stored in controller is applied to new channels.
- FakeTransportChannel* channel2 = CreateChannel("video", 1);
+ FakeDtlsTransport* channel2 = CreateChannel("video", 1);
ASSERT_NE(nullptr, channel2);
EXPECT_TRUE(transport_controller_->GetLocalCertificate(
"video", &returned_certificate));
@@ -310,7 +311,7 @@ TEST_F(TransportControllerTest, TestSetAndGetLocalCertificate) {
TEST_F(TransportControllerTest, TestGetRemoteSSLCertificate) {
rtc::FakeSSLCertificate fake_certificate("fake_data");
- FakeTransportChannel* channel = CreateChannel("audio", 1);
+ FakeDtlsTransport* channel = CreateChannel("audio", 1);
ASSERT_NE(nullptr, channel);
channel->SetRemoteSSLCertificate(&fake_certificate);
@@ -325,7 +326,7 @@ TEST_F(TransportControllerTest, TestGetRemoteSSLCertificate) {
}
TEST_F(TransportControllerTest, TestSetLocalTransportDescription) {
- FakeTransportChannel* channel = CreateChannel("audio", 1);
+ FakeDtlsTransport* channel = CreateChannel("audio", 1);
ASSERT_NE(nullptr, channel);
TransportDescription local_desc(std::vector<std::string>(), kIceUfrag1,
kIcePwd1, ICEMODE_FULL,
@@ -344,7 +345,7 @@ TEST_F(TransportControllerTest, TestSetLocalTransportDescription) {
}
TEST_F(TransportControllerTest, TestSetRemoteTransportDescription) {
- FakeTransportChannel* channel = CreateChannel("audio", 1);
+ FakeDtlsTransport* channel = CreateChannel("audio", 1);
ASSERT_NE(nullptr, channel);
TransportDescription remote_desc(std::vector<std::string>(), kIceUfrag1,
kIcePwd1, ICEMODE_FULL,
@@ -358,7 +359,7 @@ TEST_F(TransportControllerTest, TestSetRemoteTransportDescription) {
}
TEST_F(TransportControllerTest, TestAddRemoteCandidates) {
- FakeTransportChannel* channel = CreateChannel("audio", 1);
+ FakeDtlsTransport* channel = CreateChannel("audio", 1);
ASSERT_NE(nullptr, channel);
Candidates candidates;
candidates.push_back(CreateCandidate(1));
@@ -369,7 +370,7 @@ TEST_F(TransportControllerTest, TestAddRemoteCandidates) {
}
TEST_F(TransportControllerTest, TestReadyForRemoteCandidates) {
- FakeTransportChannel* channel = CreateChannel("audio", 1);
+ FakeDtlsTransport* channel = CreateChannel("audio", 1);
ASSERT_NE(nullptr, channel);
// We expect to be ready for remote candidates only after local and remote
// descriptions are set.
@@ -392,11 +393,11 @@ TEST_F(TransportControllerTest, TestReadyForRemoteCandidates) {
}
TEST_F(TransportControllerTest, TestGetStats) {
- FakeTransportChannel* channel1 = CreateChannel("audio", 1);
+ FakeDtlsTransport* channel1 = CreateChannel("audio", 1);
ASSERT_NE(nullptr, channel1);
- FakeTransportChannel* channel2 = CreateChannel("audio", 2);
+ FakeDtlsTransport* channel2 = CreateChannel("audio", 2);
ASSERT_NE(nullptr, channel2);
- FakeTransportChannel* channel3 = CreateChannel("video", 1);
+ FakeDtlsTransport* channel3 = CreateChannel("video", 1);
ASSERT_NE(nullptr, channel3);
TransportStats stats;
@@ -407,12 +408,12 @@ TEST_F(TransportControllerTest, TestGetStats) {
// Test that transport gets destroyed when it has no more channels.
TEST_F(TransportControllerTest, TestCreateAndDestroyChannel) {
- FakeTransportChannel* channel1 = CreateChannel("audio", 1);
+ FakeDtlsTransport* channel1 = CreateChannel("audio", 1);
ASSERT_NE(nullptr, channel1);
- FakeTransportChannel* channel2 = CreateChannel("audio", 1);
+ FakeDtlsTransport* channel2 = CreateChannel("audio", 1);
ASSERT_NE(nullptr, channel2);
ASSERT_EQ(channel1, channel2);
- FakeTransportChannel* channel3 = CreateChannel("audio", 2);
+ FakeDtlsTransport* channel3 = CreateChannel("audio", 2);
ASSERT_NE(nullptr, channel3);
// Using GetStats to check if transport is destroyed from an outside class's
@@ -429,9 +430,9 @@ TEST_F(TransportControllerTest, TestCreateAndDestroyChannel) {
TEST_F(TransportControllerTest, TestSignalConnectionStateFailed) {
// Need controlling ICE role to get in failed state.
transport_controller_->SetIceRole(ICEROLE_CONTROLLING);
- FakeTransportChannel* channel1 = CreateChannel("audio", 1);
+ FakeDtlsTransport* channel1 = CreateChannel("audio", 1);
ASSERT_NE(nullptr, channel1);
- FakeTransportChannel* channel2 = CreateChannel("video", 1);
+ FakeDtlsTransport* channel2 = CreateChannel("video", 1);
ASSERT_NE(nullptr, channel2);
// Should signal "failed" if any channel failed; channel is considered failed
@@ -446,11 +447,11 @@ TEST_F(TransportControllerTest, TestSignalConnectionStateFailed) {
TEST_F(TransportControllerTest, TestSignalConnectionStateConnected) {
transport_controller_->SetIceRole(ICEROLE_CONTROLLING);
- FakeTransportChannel* channel1 = CreateChannel("audio", 1);
+ FakeDtlsTransport* channel1 = CreateChannel("audio", 1);
ASSERT_NE(nullptr, channel1);
- FakeTransportChannel* channel2 = CreateChannel("video", 1);
+ FakeDtlsTransport* channel2 = CreateChannel("video", 1);
ASSERT_NE(nullptr, channel2);
- FakeTransportChannel* channel3 = CreateChannel("video", 2);
+ FakeDtlsTransport* channel3 = CreateChannel("video", 2);
ASSERT_NE(nullptr, channel3);
// First, have one channel connect, and another fail, to ensure that
@@ -479,15 +480,15 @@ TEST_F(TransportControllerTest, TestSignalConnectionStateConnected) {
TEST_F(TransportControllerTest, TestSignalConnectionStateComplete) {
transport_controller_->SetIceRole(ICEROLE_CONTROLLING);
- FakeTransportChannel* channel1 = CreateChannel("audio", 1);
+ FakeDtlsTransport* channel1 = CreateChannel("audio", 1);
ASSERT_NE(nullptr, channel1);
- FakeTransportChannel* channel2 = CreateChannel("video", 1);
+ FakeDtlsTransport* channel2 = CreateChannel("video", 1);
ASSERT_NE(nullptr, channel2);
- FakeTransportChannel* channel3 = CreateChannel("video", 2);
+ FakeDtlsTransport* channel3 = CreateChannel("video", 2);
ASSERT_NE(nullptr, channel3);
// Similar to above test, but we're now reaching the completed state, which
- // means only one connection per FakeTransportChannel.
+ // means only one connection per FakeDtlsTransport.
channel1->SetCandidatesGatheringComplete();
channel1->SetConnectionCount(1);
channel1->SetWritable(true);
@@ -519,9 +520,9 @@ TEST_F(TransportControllerTest, TestSignalConnectionStateComplete) {
// Make sure that if we're "connected" and remove a transport, we stay in the
// "connected" state.
TEST_F(TransportControllerTest, TestDestroyTransportAndStayConnected) {
- FakeTransportChannel* channel1 = CreateChannel("audio", 1);
+ FakeDtlsTransport* channel1 = CreateChannel("audio", 1);
ASSERT_NE(nullptr, channel1);
- FakeTransportChannel* channel2 = CreateChannel("video", 1);
+ FakeDtlsTransport* channel2 = CreateChannel("video", 1);
ASSERT_NE(nullptr, channel2);
channel1->SetCandidatesGatheringComplete();
@@ -545,7 +546,7 @@ TEST_F(TransportControllerTest, TestDestroyTransportAndStayConnected) {
// If we destroy the last/only transport, we should simply transition to
// "connecting".
TEST_F(TransportControllerTest, TestDestroyLastTransportWhileConnected) {
- FakeTransportChannel* channel = CreateChannel("audio", 1);
+ FakeDtlsTransport* channel = CreateChannel("audio", 1);
ASSERT_NE(nullptr, channel);
channel->SetCandidatesGatheringComplete();
@@ -561,9 +562,9 @@ TEST_F(TransportControllerTest, TestDestroyLastTransportWhileConnected) {
}
TEST_F(TransportControllerTest, TestSignalReceiving) {
- FakeTransportChannel* channel1 = CreateChannel("audio", 1);
+ FakeDtlsTransport* channel1 = CreateChannel("audio", 1);
ASSERT_NE(nullptr, channel1);
- FakeTransportChannel* channel2 = CreateChannel("video", 1);
+ FakeDtlsTransport* channel2 = CreateChannel("video", 1);
ASSERT_NE(nullptr, channel2);
// Should signal receiving as soon as any channel is receiving.
@@ -579,23 +580,23 @@ TEST_F(TransportControllerTest, TestSignalReceiving) {
}
TEST_F(TransportControllerTest, TestSignalGatheringStateGathering) {
- FakeTransportChannel* channel = CreateChannel("audio", 1);
+ FakeDtlsTransport* channel = CreateChannel("audio", 1);
ASSERT_NE(nullptr, channel);
- channel->MaybeStartGathering();
+ channel->ice_transport()->MaybeStartGathering();
// Should be in the gathering state as soon as any transport starts gathering.
EXPECT_EQ_WAIT(kIceGatheringGathering, gathering_state_, kTimeout);
EXPECT_EQ(1, gathering_state_signal_count_);
}
TEST_F(TransportControllerTest, TestSignalGatheringStateComplete) {
- FakeTransportChannel* channel1 = CreateChannel("audio", 1);
+ FakeDtlsTransport* channel1 = CreateChannel("audio", 1);
ASSERT_NE(nullptr, channel1);
- FakeTransportChannel* channel2 = CreateChannel("video", 1);
+ FakeDtlsTransport* channel2 = CreateChannel("video", 1);
ASSERT_NE(nullptr, channel2);
- FakeTransportChannel* channel3 = CreateChannel("data", 1);
+ FakeDtlsTransport* channel3 = CreateChannel("data", 1);
ASSERT_NE(nullptr, channel3);
- channel3->MaybeStartGathering();
+ channel3->ice_transport()->MaybeStartGathering();
EXPECT_EQ_WAIT(kIceGatheringGathering, gathering_state_, kTimeout);
EXPECT_EQ(1, gathering_state_signal_count_);
@@ -607,8 +608,8 @@ TEST_F(TransportControllerTest, TestSignalGatheringStateComplete) {
EXPECT_EQ(2, gathering_state_signal_count_);
// Make remaining channels start and then finish gathering.
- channel1->MaybeStartGathering();
- channel2->MaybeStartGathering();
+ channel1->ice_transport()->MaybeStartGathering();
+ channel2->ice_transport()->MaybeStartGathering();
EXPECT_EQ_WAIT(kIceGatheringGathering, gathering_state_, kTimeout);
EXPECT_EQ(3, gathering_state_signal_count_);
@@ -625,9 +626,9 @@ TEST_F(TransportControllerTest, TestSignalGatheringStateComplete) {
TEST_F(TransportControllerTest,
TestSignalingWhenLastIncompleteTransportDestroyed) {
transport_controller_->SetIceRole(ICEROLE_CONTROLLING);
- FakeTransportChannel* channel1 = CreateChannel("audio", 1);
+ FakeDtlsTransport* channel1 = CreateChannel("audio", 1);
ASSERT_NE(nullptr, channel1);
- FakeTransportChannel* channel2 = CreateChannel("video", 1);
+ FakeDtlsTransport* channel2 = CreateChannel("video", 1);
ASSERT_NE(nullptr, channel2);
channel1->SetCandidatesGatheringComplete();
@@ -644,7 +645,7 @@ TEST_F(TransportControllerTest,
}
TEST_F(TransportControllerTest, TestSignalCandidatesGathered) {
- FakeTransportChannel* channel = CreateChannel("audio", 1);
+ FakeDtlsTransport* channel = CreateChannel("audio", 1);
ASSERT_NE(nullptr, channel);
// Transport won't signal candidates until it has a local description.
@@ -656,7 +657,8 @@ TEST_F(TransportControllerTest, TestSignalCandidatesGathered) {
"audio", local_desc, CA_OFFER, &err));
transport_controller_->MaybeStartGathering();
- channel->SignalCandidateGathered(channel, CreateCandidate(1));
+ channel->ice_transport()->SignalCandidateGathered(channel->ice_transport(),
+ CreateCandidate(1));
EXPECT_EQ_WAIT(1, candidates_signal_count_, kTimeout);
EXPECT_EQ(1U, candidates_["audio"].size());
}
@@ -690,7 +692,7 @@ TEST_F(TransportControllerTest, TestSignalingOccursOnSignalingThread) {
// TODO(deadbeef): Remove this when these old versions of Chrome reach a low
// enough population.
TEST_F(TransportControllerTest, IceRoleRedeterminedOnIceRestartByDefault) {
- FakeTransportChannel* channel = CreateChannel("audio", 1);
+ FakeDtlsTransport* channel = CreateChannel("audio", 1);
ASSERT_NE(nullptr, channel);
std::string err;
// Do an initial offer answer, so that the next offer is an ICE restart.
@@ -723,7 +725,7 @@ TEST_F(TransportControllerTest, IceRoleRedeterminedOnIceRestartByDefault) {
TEST_F(TransportControllerTest, IceRoleNotRedetermined) {
bool redetermine_role = false;
transport_controller_.reset(new TransportControllerForTest(redetermine_role));
- FakeTransportChannel* channel = CreateChannel("audio", 1);
+ FakeDtlsTransport* channel = CreateChannel("audio", 1);
ASSERT_NE(nullptr, channel);
std::string err;
// Do an initial offer answer, so that the next offer is an ICE restart.
@@ -751,7 +753,7 @@ TEST_F(TransportControllerTest, IceRoleNotRedetermined) {
// Tests channel role is reversed after receiving ice-lite from remote.
TEST_F(TransportControllerTest, TestSetRemoteIceLiteInOffer) {
- FakeTransportChannel* channel = CreateChannel("audio", 1);
+ FakeDtlsTransport* channel = CreateChannel("audio", 1);
ASSERT_NE(nullptr, channel);
std::string err;
@@ -771,7 +773,7 @@ TEST_F(TransportControllerTest, TestSetRemoteIceLiteInOffer) {
// Tests ice-lite in remote answer.
TEST_F(TransportControllerTest, TestSetRemoteIceLiteInAnswer) {
- FakeTransportChannel* channel = CreateChannel("audio", 1);
+ FakeDtlsTransport* channel = CreateChannel("audio", 1);
ASSERT_NE(nullptr, channel);
std::string err;
« no previous file with comments | « webrtc/p2p/base/transportcontroller.cc ('k') | webrtc/p2p/base/udptransport.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698