Parameterize PeerConnection end to end tests for Unified Plan

Bug: webrtc:8765
Change-Id: If4b797be7876a7680e99c698631c29b412f7a455
Reviewed-on: https://webrtc-review.googlesource.com/41540
Commit-Queue: Steve Anton <steveanton@webrtc.org>
Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21755}
This commit is contained in:
Steve Anton
2018-01-24 19:35:55 -08:00
committed by Commit Bot
parent ad7bffccd1
commit 191c39f307
4 changed files with 54 additions and 27 deletions

View File

@ -34,6 +34,7 @@
using testing::AtLeast; using testing::AtLeast;
using testing::Invoke; using testing::Invoke;
using testing::StrictMock; using testing::StrictMock;
using testing::Values;
using testing::_; using testing::_;
using webrtc::DataChannelInterface; using webrtc::DataChannelInterface;
@ -41,6 +42,7 @@ using webrtc::FakeConstraints;
using webrtc::MediaConstraintsInterface; using webrtc::MediaConstraintsInterface;
using webrtc::MediaStreamInterface; using webrtc::MediaStreamInterface;
using webrtc::PeerConnectionInterface; using webrtc::PeerConnectionInterface;
using webrtc::SdpSemantics;
namespace { namespace {
@ -48,14 +50,13 @@ const int kMaxWait = 10000;
} // namespace } // namespace
class PeerConnectionEndToEndTest class PeerConnectionEndToEndBaseTest : public sigslot::has_slots<>,
: public sigslot::has_slots<>,
public testing::Test { public testing::Test {
public: public:
typedef std::vector<rtc::scoped_refptr<DataChannelInterface> > typedef std::vector<rtc::scoped_refptr<DataChannelInterface> >
DataChannelList; DataChannelList;
PeerConnectionEndToEndTest() { explicit PeerConnectionEndToEndBaseTest(SdpSemantics sdp_semantics) {
network_thread_ = rtc::Thread::CreateWithSocketServer(); network_thread_ = rtc::Thread::CreateWithSocketServer();
worker_thread_ = rtc::Thread::Create(); worker_thread_ = rtc::Thread::Create();
RTC_CHECK(network_thread_->Start()); RTC_CHECK(network_thread_->Start());
@ -67,6 +68,7 @@ class PeerConnectionEndToEndTest
webrtc::PeerConnectionInterface::IceServer ice_server; webrtc::PeerConnectionInterface::IceServer ice_server;
ice_server.uri = "stun:stun.l.google.com:19302"; ice_server.uri = "stun:stun.l.google.com:19302";
config_.servers.push_back(ice_server); config_.servers.push_back(ice_server);
config_.sdp_semantics = sdp_semantics;
#ifdef WEBRTC_ANDROID #ifdef WEBRTC_ANDROID
webrtc::InitializeAndroidObjects(); webrtc::InitializeAndroidObjects();
@ -85,9 +87,9 @@ class PeerConnectionEndToEndTest
PeerConnectionTestWrapper::Connect(caller_.get(), callee_.get()); PeerConnectionTestWrapper::Connect(caller_.get(), callee_.get());
caller_->SignalOnDataChannel.connect( caller_->SignalOnDataChannel.connect(
this, &PeerConnectionEndToEndTest::OnCallerAddedDataChanel); this, &PeerConnectionEndToEndBaseTest::OnCallerAddedDataChanel);
callee_->SignalOnDataChannel.connect( callee_->SignalOnDataChannel.connect(
this, &PeerConnectionEndToEndTest::OnCalleeAddedDataChannel); this, &PeerConnectionEndToEndBaseTest::OnCalleeAddedDataChannel);
} }
void GetAndAddUserMedia() { void GetAndAddUserMedia() {
@ -181,6 +183,13 @@ class PeerConnectionEndToEndTest
webrtc::PeerConnectionInterface::RTCConfiguration config_; webrtc::PeerConnectionInterface::RTCConfiguration config_;
}; };
class PeerConnectionEndToEndTest
: public PeerConnectionEndToEndBaseTest,
public ::testing::WithParamInterface<SdpSemantics> {
protected:
PeerConnectionEndToEndTest() : PeerConnectionEndToEndBaseTest(GetParam()) {}
};
namespace { namespace {
std::unique_ptr<webrtc::AudioDecoder> CreateForwardingMockDecoder( std::unique_ptr<webrtc::AudioDecoder> CreateForwardingMockDecoder(
@ -343,7 +352,7 @@ struct AudioDecoderUnicornSparklesRainbow {
#else #else
#define MAYBE_Call Call #define MAYBE_Call Call
#endif #endif
TEST_F(PeerConnectionEndToEndTest, MAYBE_Call) { TEST_P(PeerConnectionEndToEndTest, MAYBE_Call) {
rtc::scoped_refptr<webrtc::AudioDecoderFactory> real_decoder_factory = rtc::scoped_refptr<webrtc::AudioDecoderFactory> real_decoder_factory =
webrtc::CreateBuiltinAudioDecoderFactory(); webrtc::CreateBuiltinAudioDecoderFactory();
CreatePcs(nullptr, webrtc::CreateBuiltinAudioEncoderFactory(), CreatePcs(nullptr, webrtc::CreateBuiltinAudioEncoderFactory(),
@ -354,7 +363,7 @@ TEST_F(PeerConnectionEndToEndTest, MAYBE_Call) {
} }
#if !defined(ADDRESS_SANITIZER) #if !defined(ADDRESS_SANITIZER)
TEST_F(PeerConnectionEndToEndTest, CallWithLegacySdp) { TEST_P(PeerConnectionEndToEndTest, CallWithLegacySdp) {
FakeConstraints pc_constraints; FakeConstraints pc_constraints;
pc_constraints.AddMandatory(MediaConstraintsInterface::kEnableDtlsSrtp, pc_constraints.AddMandatory(MediaConstraintsInterface::kEnableDtlsSrtp,
false); false);
@ -366,7 +375,7 @@ TEST_F(PeerConnectionEndToEndTest, CallWithLegacySdp) {
} }
#endif // !defined(ADDRESS_SANITIZER) #endif // !defined(ADDRESS_SANITIZER)
TEST_F(PeerConnectionEndToEndTest, CallWithCustomCodec) { TEST_P(PeerConnectionEndToEndTest, CallWithCustomCodec) {
CreatePcs( CreatePcs(
nullptr, nullptr,
webrtc::CreateAudioEncoderFactory<AudioEncoderUnicornSparklesRainbow>(), webrtc::CreateAudioEncoderFactory<AudioEncoderUnicornSparklesRainbow>(),
@ -379,7 +388,7 @@ TEST_F(PeerConnectionEndToEndTest, CallWithCustomCodec) {
#ifdef HAVE_SCTP #ifdef HAVE_SCTP
// Verifies that a DataChannel created before the negotiation can transition to // Verifies that a DataChannel created before the negotiation can transition to
// "OPEN" and transfer data. // "OPEN" and transfer data.
TEST_F(PeerConnectionEndToEndTest, CreateDataChannelBeforeNegotiate) { TEST_P(PeerConnectionEndToEndTest, CreateDataChannelBeforeNegotiate) {
CreatePcs(nullptr, webrtc::CreateBuiltinAudioEncoderFactory(), CreatePcs(nullptr, webrtc::CreateBuiltinAudioEncoderFactory(),
webrtc::MockAudioDecoderFactory::CreateEmptyFactory()); webrtc::MockAudioDecoderFactory::CreateEmptyFactory());
@ -404,7 +413,7 @@ TEST_F(PeerConnectionEndToEndTest, CreateDataChannelBeforeNegotiate) {
// Verifies that a DataChannel created after the negotiation can transition to // Verifies that a DataChannel created after the negotiation can transition to
// "OPEN" and transfer data. // "OPEN" and transfer data.
TEST_F(PeerConnectionEndToEndTest, CreateDataChannelAfterNegotiate) { TEST_P(PeerConnectionEndToEndTest, CreateDataChannelAfterNegotiate) {
CreatePcs(nullptr, webrtc::CreateBuiltinAudioEncoderFactory(), CreatePcs(nullptr, webrtc::CreateBuiltinAudioEncoderFactory(),
webrtc::MockAudioDecoderFactory::CreateEmptyFactory()); webrtc::MockAudioDecoderFactory::CreateEmptyFactory());
@ -436,7 +445,7 @@ TEST_F(PeerConnectionEndToEndTest, CreateDataChannelAfterNegotiate) {
} }
// Verifies that DataChannel IDs are even/odd based on the DTLS roles. // Verifies that DataChannel IDs are even/odd based on the DTLS roles.
TEST_F(PeerConnectionEndToEndTest, DataChannelIdAssignment) { TEST_P(PeerConnectionEndToEndTest, DataChannelIdAssignment) {
CreatePcs(nullptr, webrtc::CreateBuiltinAudioEncoderFactory(), CreatePcs(nullptr, webrtc::CreateBuiltinAudioEncoderFactory(),
webrtc::MockAudioDecoderFactory::CreateEmptyFactory()); webrtc::MockAudioDecoderFactory::CreateEmptyFactory());
@ -463,7 +472,7 @@ TEST_F(PeerConnectionEndToEndTest, DataChannelIdAssignment) {
// Verifies that the message is received by the right remote DataChannel when // Verifies that the message is received by the right remote DataChannel when
// there are multiple DataChannels. // there are multiple DataChannels.
TEST_F(PeerConnectionEndToEndTest, TEST_P(PeerConnectionEndToEndTest,
MessageTransferBetweenTwoPairsOfDataChannels) { MessageTransferBetweenTwoPairsOfDataChannels) {
CreatePcs(nullptr, webrtc::CreateBuiltinAudioEncoderFactory(), CreatePcs(nullptr, webrtc::CreateBuiltinAudioEncoderFactory(),
webrtc::MockAudioDecoderFactory::CreateEmptyFactory()); webrtc::MockAudioDecoderFactory::CreateEmptyFactory());
@ -507,7 +516,7 @@ TEST_F(PeerConnectionEndToEndTest,
// caused by the fact that a data channel signals that it's closed before it // caused by the fact that a data channel signals that it's closed before it
// really is. Re-enable this test once that's fixed. // really is. Re-enable this test once that's fixed.
// See: https://bugs.chromium.org/p/webrtc/issues/detail?id=4453 // See: https://bugs.chromium.org/p/webrtc/issues/detail?id=4453
TEST_F(PeerConnectionEndToEndTest, TEST_P(PeerConnectionEndToEndTest,
DISABLED_DataChannelFromOpenWorksAfterClose) { DISABLED_DataChannelFromOpenWorksAfterClose) {
CreatePcs(nullptr, webrtc::CreateBuiltinAudioEncoderFactory(), CreatePcs(nullptr, webrtc::CreateBuiltinAudioEncoderFactory(),
webrtc::MockAudioDecoderFactory::CreateEmptyFactory()); webrtc::MockAudioDecoderFactory::CreateEmptyFactory());
@ -535,7 +544,7 @@ TEST_F(PeerConnectionEndToEndTest,
// by the application (meaning only the PeerConnection contributes to its // by the application (meaning only the PeerConnection contributes to its
// reference count), no memory access violation will occur. // reference count), no memory access violation will occur.
// See: https://code.google.com/p/chromium/issues/detail?id=565048 // See: https://code.google.com/p/chromium/issues/detail?id=565048
TEST_F(PeerConnectionEndToEndTest, CloseDataChannelRemotelyWhileNotReferenced) { TEST_P(PeerConnectionEndToEndTest, CloseDataChannelRemotelyWhileNotReferenced) {
CreatePcs(nullptr, webrtc::CreateBuiltinAudioEncoderFactory(), CreatePcs(nullptr, webrtc::CreateBuiltinAudioEncoderFactory(),
webrtc::MockAudioDecoderFactory::CreateEmptyFactory()); webrtc::MockAudioDecoderFactory::CreateEmptyFactory());
@ -557,3 +566,8 @@ TEST_F(PeerConnectionEndToEndTest, CloseDataChannelRemotelyWhileNotReferenced) {
rtc::Thread::Current()->ProcessMessages(100); rtc::Thread::Current()->ProcessMessages(100);
} }
#endif // HAVE_SCTP #endif // HAVE_SCTP
INSTANTIATE_TEST_CASE_P(PeerConnectionEndToEndTest,
PeerConnectionEndToEndTest,
Values(SdpSemantics::kPlanB,
SdpSemantics::kUnifiedPlan));

View File

@ -10,6 +10,7 @@
#include <string> #include <string>
#include <utility> #include <utility>
#include <vector>
#include "p2p/base/fakeportallocator.h" #include "p2p/base/fakeportallocator.h"
#include "pc/sdputils.h" #include "pc/sdputils.h"
@ -24,8 +25,10 @@ using webrtc::FakeVideoTrackRenderer;
using webrtc::IceCandidateInterface; using webrtc::IceCandidateInterface;
using webrtc::MediaConstraintsInterface; using webrtc::MediaConstraintsInterface;
using webrtc::MediaStreamInterface; using webrtc::MediaStreamInterface;
using webrtc::MediaStreamTrackInterface;
using webrtc::MockSetSessionDescriptionObserver; using webrtc::MockSetSessionDescriptionObserver;
using webrtc::PeerConnectionInterface; using webrtc::PeerConnectionInterface;
using webrtc::RtpReceiverInterface;
using webrtc::SdpType; using webrtc::SdpType;
using webrtc::SessionDescriptionInterface; using webrtc::SessionDescriptionInterface;
using webrtc::VideoTrackInterface; using webrtc::VideoTrackInterface;
@ -99,12 +102,14 @@ PeerConnectionTestWrapper::CreateDataChannel(
return peer_connection_->CreateDataChannel(label, &init); return peer_connection_->CreateDataChannel(label, &init);
} }
void PeerConnectionTestWrapper::OnAddStream( void PeerConnectionTestWrapper::OnAddTrack(
rtc::scoped_refptr<MediaStreamInterface> stream) { rtc::scoped_refptr<RtpReceiverInterface> receiver,
RTC_LOG(LS_INFO) << "PeerConnectionTestWrapper " << name_ << ": OnAddStream"; const std::vector<rtc::scoped_refptr<MediaStreamInterface>>& streams) {
// TODO(ronghuawu): support multiple streams. RTC_LOG(LS_INFO) << "PeerConnectionTestWrapper " << name_ << ": OnAddTrack";
if (stream->GetVideoTracks().size() > 0) { if (receiver->track()->kind() == MediaStreamTrackInterface::kVideoKind) {
renderer_.reset(new FakeVideoTrackRenderer(stream->GetVideoTracks()[0])); auto* video_track =
static_cast<VideoTrackInterface*>(receiver->track().get());
renderer_ = rtc::MakeUnique<FakeVideoTrackRenderer>(video_track);
} }
} }
@ -244,7 +249,14 @@ void PeerConnectionTestWrapper::GetAndAddUserMedia(
bool video, const webrtc::FakeConstraints& video_constraints) { bool video, const webrtc::FakeConstraints& video_constraints) {
rtc::scoped_refptr<webrtc::MediaStreamInterface> stream = rtc::scoped_refptr<webrtc::MediaStreamInterface> stream =
GetUserMedia(audio, audio_constraints, video, video_constraints); GetUserMedia(audio, audio_constraints, video, video_constraints);
EXPECT_TRUE(peer_connection_->AddStream(stream)); for (auto audio_track : stream->GetAudioTracks()) {
EXPECT_TRUE(
peer_connection_->AddTrack(audio_track, {stream->label()}).ok());
}
for (auto video_track : stream->GetVideoTracks()) {
EXPECT_TRUE(
peer_connection_->AddTrack(video_track, {stream->label()}).ok());
}
} }
rtc::scoped_refptr<webrtc::MediaStreamInterface> rtc::scoped_refptr<webrtc::MediaStreamInterface>

View File

@ -13,6 +13,7 @@
#include <memory> #include <memory>
#include <string> #include <string>
#include <vector>
#include "api/peerconnectioninterface.h" #include "api/peerconnectioninterface.h"
#include "api/test/fakeconstraints.h" #include "api/test/fakeconstraints.h"
@ -48,10 +49,10 @@ class PeerConnectionTestWrapper
// Implements PeerConnectionObserver. // Implements PeerConnectionObserver.
void OnSignalingChange( void OnSignalingChange(
webrtc::PeerConnectionInterface::SignalingState new_state) override {} webrtc::PeerConnectionInterface::SignalingState new_state) override {}
void OnAddStream( void OnAddTrack(
rtc::scoped_refptr<webrtc::MediaStreamInterface> stream) override; rtc::scoped_refptr<webrtc::RtpReceiverInterface> receiver,
void OnRemoveStream( const std::vector<rtc::scoped_refptr<webrtc::MediaStreamInterface>>&
rtc::scoped_refptr<webrtc::MediaStreamInterface> stream) override {} streams) override;
void OnDataChannel( void OnDataChannel(
rtc::scoped_refptr<webrtc::DataChannelInterface> data_channel) override; rtc::scoped_refptr<webrtc::DataChannelInterface> data_channel) override;
void OnRenegotiationNeeded() override {} void OnRenegotiationNeeded() override {}

View File

@ -1,7 +1,7 @@
# Tests that are failing when run under memcheck. # Tests that are failing when run under memcheck.
# https://code.google.com/p/webrtc/issues/detail?id=4387 # https://code.google.com/p/webrtc/issues/detail?id=4387
DtmfSenderTest.* DtmfSenderTest.*
PeerConnectionEndToEndTest.* PeerConnectionEndToEndTest*
PeerConnectionIntegrationTest.* PeerConnectionIntegrationTest.*
PeerConnectionInterfaceTest.* PeerConnectionInterfaceTest.*
RTCStatsIntegrationTest.* RTCStatsIntegrationTest.*