Move missing codec test to media_test

So it doesn't conflict with WASM.

Related to #449
This commit is contained in:
Max Hawkins
2019-04-09 17:55:54 -07:00
parent 141ef8b71a
commit 7f6c01d5bc
2 changed files with 44 additions and 44 deletions

View File

@@ -7,11 +7,13 @@ import (
"fmt"
"io"
"math/rand"
"reflect"
"sync"
"testing"
"time"
"github.com/pion/rtcp"
"github.com/pion/sdp/v2"
"github.com/pion/transport/test"
"github.com/pion/webrtc/v2/pkg/media"
)
@@ -452,3 +454,45 @@ func TestPeerConnection_Media_Closed(t *testing.T) {
t.Fatal(err)
}
}
func TestOfferRejectionMissingCodec(t *testing.T) {
api := NewAPI()
api.mediaEngine.RegisterDefaultCodecs()
pc, err := api.NewPeerConnection(Configuration{})
if err != nil {
t.Fatal(err)
}
noCodecAPI := NewAPI()
noCodecPC, err := noCodecAPI.NewPeerConnection(Configuration{})
if err != nil {
t.Fatal(err)
}
track, err := pc.NewTrack(DefaultPayloadTypeVP8, rand.Uint32(), "video", "pion2")
if err != nil {
t.Fatal(err)
}
if _, err := pc.AddTrack(track); err != nil {
t.Fatal(err)
}
if err := signalPair(pc, noCodecPC); err != nil {
t.Fatal(err)
}
var sdes sdp.SessionDescription
if err := sdes.Unmarshal([]byte(pc.RemoteDescription().SDP)); err != nil {
t.Fatal(err)
}
var videoDesc sdp.MediaDescription
for _, m := range sdes.MediaDescriptions {
if m.MediaName.Media == "video" {
videoDesc = *m
}
}
if got, want := videoDesc.MediaName.Formats, []string{"0"}; !reflect.DeepEqual(got, want) {
t.Fatalf("rejecting unknown codec: sdp m=%s, want trailing 0", *videoDesc.MediaName.String())
}
}

View File

@@ -2,13 +2,11 @@ package webrtc
import (
"fmt"
"math/rand"
"reflect"
"sync"
"testing"
"time"
"github.com/pion/sdp/v2"
"github.com/pion/webrtc/v2/pkg/rtcerr"
"github.com/stretchr/testify/assert"
)
@@ -318,48 +316,6 @@ func TestCreateOfferAnswer(t *testing.T) {
}
}
func TestOfferRejectionMissingCodec(t *testing.T) {
api := NewAPI()
api.mediaEngine.RegisterDefaultCodecs()
pc, err := api.NewPeerConnection(Configuration{})
if err != nil {
t.Fatal(err)
}
noCodecAPI := NewAPI()
noCodecPC, err := noCodecAPI.NewPeerConnection(Configuration{})
if err != nil {
t.Fatal(err)
}
track, err := pc.NewTrack(DefaultPayloadTypeVP8, rand.Uint32(), "video", "pion2")
if err != nil {
t.Fatal(err)
}
if _, err := pc.AddTrack(track); err != nil {
t.Fatal(err)
}
if err := signalPair(pc, noCodecPC); err != nil {
t.Fatal(err)
}
var sdes sdp.SessionDescription
if err := sdes.Unmarshal([]byte(pc.RemoteDescription().SDP)); err != nil {
t.Fatal(err)
}
var videoDesc sdp.MediaDescription
for _, m := range sdes.MediaDescriptions {
if m.MediaName.Media == "video" {
videoDesc = *m
}
}
if got, want := videoDesc.MediaName.Formats, []string{"0"}; !reflect.DeepEqual(got, want) {
t.Fatalf("rejecting unknown codec: sdp m=%s, want trailing 0", *videoDesc.MediaName.String())
}
}
func TestPeerConnection_EventHandlers(t *testing.T) {
pcOffer, err := NewPeerConnection(Configuration{})
assert.NoError(t, err)