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

Unified Diff: webrtc/pc/channel_unittest.cc

Issue 2517883002: Refactoring that removes P2PTransport and DtlsTransport classes. (Closed)
Patch Set: Rename Transport to JsepTransport. Created 4 years 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
Index: webrtc/pc/channel_unittest.cc
diff --git a/webrtc/pc/channel_unittest.cc b/webrtc/pc/channel_unittest.cc
index 16b5be71e1fc3e9c6574e8471023b4963af673c1..58198eb5e876dfd4430458e5d36fb0d0bc3213a0 100644
--- a/webrtc/pc/channel_unittest.cc
+++ b/webrtc/pc/channel_unittest.cc
@@ -21,6 +21,7 @@
#include "webrtc/media/base/mediachannel.h"
#include "webrtc/media/base/testutils.h"
#include "webrtc/p2p/base/faketransportcontroller.h"
+#include "webrtc/p2p/base/transportchannelimpl.h"
#include "webrtc/pc/channel.h"
#define MAYBE_SKIP_TEST(feature) \
@@ -270,17 +271,22 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
return channel1_->RemoveRecvStream(id);
}
- cricket::FakeTransport* GetTransport1() {
- std::string name = channel1_->content_name();
- return network_thread_->Invoke<cricket::FakeTransport*>(
- RTC_FROM_HERE,
- [this, name] { return transport_controller1_->GetTransport_n(name); });
+ std::vector<cricket::TransportChannelImpl*> GetChannels1() {
+ return transport_controller1_->channels_for_testing();
}
- cricket::FakeTransport* GetTransport2() {
- std::string name = channel2_->content_name();
- return network_thread_->Invoke<cricket::FakeTransport*>(
- RTC_FROM_HERE,
- [this, name] { return transport_controller2_->GetTransport_n(name); });
+
+ std::vector<cricket::TransportChannelImpl*> GetChannels2() {
+ return transport_controller2_->channels_for_testing();
+ }
+
+ cricket::FakeTransportChannel* GetFakeChannel1(int component) {
+ return transport_controller1_->GetFakeTransportChannel_n(
+ channel1_->content_name(), component);
+ }
+
+ cricket::FakeTransportChannel* GetFakeChannel2(int component) {
+ return transport_controller2_->GetFakeTransportChannel_n(
+ channel2_->content_name(), component);
}
void SendRtp1() {
@@ -1013,10 +1019,8 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
CreateChannels(0, 0);
EXPECT_TRUE(SendInitiate());
EXPECT_TRUE(SendAccept());
- ASSERT_TRUE(GetTransport1());
- ASSERT_TRUE(GetTransport2());
- EXPECT_EQ(1U, GetTransport1()->channels().size());
- EXPECT_EQ(1U, GetTransport2()->channels().size());
+ EXPECT_EQ(1U, GetChannels1().size());
+ EXPECT_EQ(1U, GetChannels2().size());
SendRtp1();
SendRtp2();
WaitForThreads();
@@ -1044,10 +1048,8 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
CreateChannels(0, 0);
EXPECT_TRUE(SendInitiate());
EXPECT_TRUE(SendAccept());
- ASSERT_TRUE(GetTransport1());
- ASSERT_TRUE(GetTransport2());
- EXPECT_EQ(1U, GetTransport1()->channels().size());
- EXPECT_EQ(1U, GetTransport2()->channels().size());
+ EXPECT_EQ(1U, GetChannels1().size());
+ EXPECT_EQ(1U, GetChannels2().size());
SendRtcp1();
SendRtcp2();
WaitForThreads();
@@ -1060,10 +1062,8 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
CreateChannels(0, RTCP);
EXPECT_TRUE(SendInitiate());
EXPECT_TRUE(SendAccept());
- ASSERT_TRUE(GetTransport1());
- ASSERT_TRUE(GetTransport2());
- EXPECT_EQ(1U, GetTransport1()->channels().size());
- EXPECT_EQ(2U, GetTransport2()->channels().size());
+ EXPECT_EQ(1U, GetChannels1().size());
+ EXPECT_EQ(2U, GetChannels2().size());
SendRtcp1();
SendRtcp2();
WaitForThreads();
@@ -1076,10 +1076,8 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
CreateChannels(RTCP, 0);
EXPECT_TRUE(SendInitiate());
EXPECT_TRUE(SendAccept());
- ASSERT_TRUE(GetTransport1());
- ASSERT_TRUE(GetTransport2());
- EXPECT_EQ(2U, GetTransport1()->channels().size());
- EXPECT_EQ(1U, GetTransport2()->channels().size());
+ EXPECT_EQ(2U, GetChannels1().size());
+ EXPECT_EQ(1U, GetChannels2().size());
SendRtcp1();
SendRtcp2();
WaitForThreads();
@@ -1092,10 +1090,8 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
CreateChannels(RTCP, RTCP);
EXPECT_TRUE(SendInitiate());
EXPECT_TRUE(SendAccept());
- ASSERT_TRUE(GetTransport1());
- ASSERT_TRUE(GetTransport2());
- EXPECT_EQ(2U, GetTransport1()->channels().size());
- EXPECT_EQ(2U, GetTransport2()->channels().size());
+ EXPECT_EQ(2U, GetChannels1().size());
+ EXPECT_EQ(2U, GetChannels2().size());
SendRtcp1();
SendRtcp2();
WaitForThreads();
@@ -1110,10 +1106,8 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
CreateChannels(RTCP | RTCP_MUX, RTCP);
EXPECT_TRUE(SendInitiate());
EXPECT_TRUE(SendAccept());
- ASSERT_TRUE(GetTransport1());
- ASSERT_TRUE(GetTransport2());
- EXPECT_EQ(2U, GetTransport1()->channels().size());
- EXPECT_EQ(2U, GetTransport2()->channels().size());
+ EXPECT_EQ(2U, GetChannels1().size());
+ EXPECT_EQ(2U, GetChannels2().size());
SendRtcp1();
SendRtcp2();
WaitForThreads();
@@ -1127,12 +1121,10 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
void SendRtcpMuxToRtcpMux() {
CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX);
EXPECT_TRUE(SendInitiate());
- ASSERT_TRUE(GetTransport1());
- ASSERT_TRUE(GetTransport2());
- EXPECT_EQ(2U, GetTransport1()->channels().size());
- EXPECT_EQ(1U, GetTransport2()->channels().size());
+ EXPECT_EQ(2U, GetChannels1().size());
+ EXPECT_EQ(1U, GetChannels2().size());
EXPECT_TRUE(SendAccept());
- EXPECT_EQ(1U, GetTransport1()->channels().size());
+ EXPECT_EQ(1U, GetChannels1().size());
SendRtp1();
SendRtp2();
SendRtcp1();
@@ -1154,10 +1146,8 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX);
channel1_->ActivateRtcpMux();
EXPECT_TRUE(SendInitiate());
- ASSERT_TRUE(GetTransport1());
- ASSERT_TRUE(GetTransport2());
- EXPECT_EQ(1U, GetTransport1()->channels().size());
- EXPECT_EQ(1U, GetTransport2()->channels().size());
+ EXPECT_EQ(1U, GetChannels1().size());
+ EXPECT_EQ(1U, GetChannels2().size());
EXPECT_TRUE(SendAccept());
SendRtp1();
SendRtp2();
@@ -1180,12 +1170,10 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX);
channel2_->ActivateRtcpMux();
EXPECT_TRUE(SendInitiate());
- ASSERT_TRUE(GetTransport1());
- ASSERT_TRUE(GetTransport2());
- EXPECT_EQ(2U, GetTransport1()->channels().size());
- EXPECT_EQ(1U, GetTransport2()->channels().size());
+ EXPECT_EQ(2U, GetChannels1().size());
+ EXPECT_EQ(1U, GetChannels2().size());
EXPECT_TRUE(SendAccept());
- EXPECT_EQ(1U, GetTransport1()->channels().size());
+ EXPECT_EQ(1U, GetChannels1().size());
SendRtp1();
SendRtp2();
SendRtcp1();
@@ -1208,12 +1196,10 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
channel1_->ActivateRtcpMux();
channel2_->ActivateRtcpMux();
EXPECT_TRUE(SendInitiate());
- ASSERT_TRUE(GetTransport1());
- ASSERT_TRUE(GetTransport2());
- EXPECT_EQ(1U, GetTransport1()->channels().size());
- EXPECT_EQ(1U, GetTransport2()->channels().size());
+ EXPECT_EQ(1U, GetChannels1().size());
+ EXPECT_EQ(1U, GetChannels2().size());
EXPECT_TRUE(SendAccept());
- EXPECT_EQ(1U, GetTransport1()->channels().size());
+ EXPECT_EQ(1U, GetChannels1().size());
SendRtp1();
SendRtp2();
SendRtcp1();
@@ -1235,10 +1221,8 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
CreateChannels(RTCP | RTCP_MUX, RTCP);
channel1_->ActivateRtcpMux();
EXPECT_TRUE(SendInitiate());
- ASSERT_TRUE(GetTransport1());
- ASSERT_TRUE(GetTransport2());
- EXPECT_EQ(1U, GetTransport1()->channels().size());
- EXPECT_EQ(2U, GetTransport2()->channels().size());
+ EXPECT_EQ(1U, GetChannels1().size());
+ EXPECT_EQ(2U, GetChannels2().size());
EXPECT_FALSE(SendAccept());
}
@@ -1246,10 +1230,8 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
void SendEarlyRtcpMuxToRtcp() {
CreateChannels(RTCP | RTCP_MUX, RTCP);
EXPECT_TRUE(SendInitiate());
- ASSERT_TRUE(GetTransport1());
- ASSERT_TRUE(GetTransport2());
- EXPECT_EQ(2U, GetTransport1()->channels().size());
- EXPECT_EQ(2U, GetTransport2()->channels().size());
+ EXPECT_EQ(2U, GetChannels1().size());
+ EXPECT_EQ(2U, GetChannels2().size());
// RTCP can be sent before the call is accepted, if the transport is ready.
// It should not be muxed though, as the remote side doesn't support mux.
@@ -1266,7 +1248,7 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
// Complete call setup and ensure everything is still OK.
EXPECT_TRUE(SendAccept());
- EXPECT_EQ(2U, GetTransport1()->channels().size());
+ EXPECT_EQ(2U, GetChannels1().size());
SendRtcp1();
SendRtcp2();
WaitForThreads();
@@ -1281,10 +1263,8 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
void SendEarlyRtcpMuxToRtcpMux() {
CreateChannels(RTCP | RTCP_MUX, RTCP | RTCP_MUX);
EXPECT_TRUE(SendInitiate());
- ASSERT_TRUE(GetTransport1());
- ASSERT_TRUE(GetTransport2());
- EXPECT_EQ(2U, GetTransport1()->channels().size());
- EXPECT_EQ(1U, GetTransport2()->channels().size());
+ EXPECT_EQ(2U, GetChannels1().size());
+ EXPECT_EQ(1U, GetChannels2().size());
// RTCP can't be sent yet, since the RTCP transport isn't writable, and
// we haven't yet received the accept that says we should mux.
@@ -1300,7 +1280,7 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
// Complete call setup and ensure everything is still OK.
EXPECT_TRUE(SendAccept());
- EXPECT_EQ(1U, GetTransport1()->channels().size());
+ EXPECT_EQ(1U, GetChannels1().size());
SendRtcp1();
SendRtcp2();
WaitForThreads();
@@ -1388,10 +1368,8 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
EXPECT_TRUE(SendProvisionalAnswer());
EXPECT_TRUE(channel1_->secure());
EXPECT_TRUE(channel2_->secure());
- ASSERT_TRUE(GetTransport1());
- ASSERT_TRUE(GetTransport2());
- EXPECT_EQ(2U, GetTransport1()->channels().size());
- EXPECT_EQ(2U, GetTransport2()->channels().size());
+ EXPECT_EQ(2U, GetChannels1().size());
+ EXPECT_EQ(2U, GetChannels2().size());
WaitForThreads(); // Wait for 'sending' flag go through network thread.
SendCustomRtcp1(kSsrc1);
SendCustomRtp1(kSsrc1, ++sequence_number1_1);
@@ -1408,8 +1386,8 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
// Complete call setup and ensure everything is still OK.
EXPECT_TRUE(SendFinalAnswer());
- EXPECT_EQ(1U, GetTransport1()->channels().size());
- EXPECT_EQ(1U, GetTransport2()->channels().size());
+ EXPECT_EQ(1U, GetChannels1().size());
+ EXPECT_EQ(1U, GetChannels2().size());
EXPECT_TRUE(channel1_->secure());
EXPECT_TRUE(channel2_->secure());
SendCustomRtcp1(kSsrc1);
@@ -1475,10 +1453,8 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
CreateChannels(0, 0);
EXPECT_TRUE(SendInitiate());
EXPECT_TRUE(SendAccept());
- ASSERT_TRUE(GetTransport1());
- ASSERT_TRUE(GetTransport2());
- EXPECT_EQ(1U, GetTransport1()->channels().size());
- EXPECT_EQ(1U, GetTransport2()->channels().size());
+ EXPECT_EQ(1U, GetChannels1().size());
+ EXPECT_EQ(1U, GetChannels2().size());
SendRtp1();
SendRtp2();
WaitForThreads();
@@ -1489,7 +1465,7 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
// Lose writability, which should fail.
network_thread_->Invoke<void>(
- RTC_FROM_HERE, [this] { GetTransport1()->SetWritable(false); });
+ RTC_FROM_HERE, [this] { GetFakeChannel1(1)->SetWritable(false); });
SendRtp1();
SendRtp2();
WaitForThreads();
@@ -1498,7 +1474,7 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
// Regain writability
network_thread_->Invoke<void>(
- RTC_FROM_HERE, [this] { GetTransport1()->SetWritable(true); });
+ RTC_FROM_HERE, [this] { GetFakeChannel1(1)->SetWritable(true); });
EXPECT_TRUE(media_channel1_->sending());
SendRtp1();
SendRtp2();
@@ -1510,7 +1486,7 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
// Lose writability completely
network_thread_->Invoke<void>(
- RTC_FROM_HERE, [this] { GetTransport1()->SetDestination(NULL); });
+ RTC_FROM_HERE, [this] { GetFakeChannel1(1)->SetDestination(nullptr); });
EXPECT_TRUE(media_channel1_->sending());
// Should fail also.
@@ -1522,7 +1498,7 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
// Gain writability back
network_thread_->Invoke<void>(RTC_FROM_HERE, [this] {
- GetTransport1()->SetDestination(GetTransport2());
+ GetFakeChannel1(1)->SetDestination(GetFakeChannel2(1));
});
EXPECT_TRUE(media_channel1_->sending());
SendRtp1();
@@ -1551,13 +1527,11 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
}
CreateChannels(flags, flags);
EXPECT_TRUE(SendInitiate());
- ASSERT_TRUE(GetTransport1());
- ASSERT_TRUE(GetTransport2());
- EXPECT_EQ(2U, GetTransport1()->channels().size());
- EXPECT_EQ(expected_channels, GetTransport2()->channels().size());
+ EXPECT_EQ(2U, GetChannels1().size());
+ EXPECT_EQ(expected_channels, GetChannels2().size());
EXPECT_TRUE(SendAccept());
- EXPECT_EQ(expected_channels, GetTransport1()->channels().size());
- EXPECT_EQ(expected_channels, GetTransport2()->channels().size());
+ EXPECT_EQ(expected_channels, GetChannels1().size());
+ EXPECT_EQ(expected_channels, GetChannels2().size());
EXPECT_TRUE(channel1_->bundle_filter()->FindPayloadType(pl_type1));
EXPECT_TRUE(channel2_->bundle_filter()->FindPayloadType(pl_type1));
EXPECT_FALSE(channel1_->bundle_filter()->FindPayloadType(pl_type2));
@@ -1738,10 +1712,8 @@ class ChannelTest : public testing::Test, public sigslot::has_slots<> {
CreateChannels(RTCP, RTCP);
EXPECT_TRUE(SendInitiate());
EXPECT_TRUE(SendAccept());
- ASSERT_TRUE(GetTransport1());
- ASSERT_TRUE(GetTransport2());
- EXPECT_EQ(2U, GetTransport1()->channels().size());
- EXPECT_EQ(2U, GetTransport2()->channels().size());
+ EXPECT_EQ(2U, GetChannels1().size());
+ EXPECT_EQ(2U, GetChannels2().size());
// Send RTCP1 from a different thread.
ScopedCallThread send_rtcp([this] { SendRtcp1(); });

Powered by Google App Engine
This is Rietveld 408576698