mirror of
https://github.com/pion/webrtc.git
synced 2025-10-05 07:06:51 +08:00

This only does parsing, does not generate them. In the future this option will be exposed via the SettingEngine, including the ability to opt out of mDNS completely for security/scaling concerns Relates to pion/webrtc#699
100 lines
2.0 KiB
Go
100 lines
2.0 KiB
Go
// +build !js
|
|
|
|
package webrtc
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/pion/sdp/v2"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestICECandidateToSDP(t *testing.T) {
|
|
testCases := []struct {
|
|
native ICECandidate
|
|
|
|
sdp sdp.ICECandidate
|
|
}{
|
|
{
|
|
ICECandidate{
|
|
Foundation: "foundation",
|
|
Priority: 128,
|
|
Address: "1.0.0.1",
|
|
Protocol: ICEProtocolUDP,
|
|
Port: 1234,
|
|
Typ: ICECandidateTypeHost,
|
|
Component: 1,
|
|
},
|
|
|
|
sdp.ICECandidate{
|
|
Foundation: "foundation",
|
|
Priority: 128,
|
|
Address: "1.0.0.1",
|
|
Protocol: "udp",
|
|
Port: 1234,
|
|
Typ: "host",
|
|
Component: 1,
|
|
},
|
|
},
|
|
{
|
|
ICECandidate{
|
|
Foundation: "foundation",
|
|
Priority: 128,
|
|
Address: "::1",
|
|
Protocol: ICEProtocolUDP,
|
|
Port: 1234,
|
|
Typ: ICECandidateTypeSrflx,
|
|
Component: 1,
|
|
RelatedAddress: "1.0.0.1",
|
|
RelatedPort: 4321,
|
|
},
|
|
|
|
sdp.ICECandidate{
|
|
Foundation: "foundation",
|
|
Priority: 128,
|
|
Address: "::1",
|
|
Protocol: "udp",
|
|
Port: 1234,
|
|
Typ: "srflx",
|
|
Component: 1,
|
|
RelatedAddress: "1.0.0.1",
|
|
RelatedPort: 4321,
|
|
},
|
|
},
|
|
{
|
|
ICECandidate{
|
|
Foundation: "foundation",
|
|
Priority: 128,
|
|
Address: "::1",
|
|
Protocol: ICEProtocolUDP,
|
|
Port: 1234,
|
|
Typ: ICECandidateTypePrflx,
|
|
Component: 1,
|
|
RelatedAddress: "1.0.0.1",
|
|
RelatedPort: 4321,
|
|
},
|
|
|
|
sdp.ICECandidate{
|
|
Foundation: "foundation",
|
|
Priority: 128,
|
|
Address: "::1",
|
|
Protocol: "udp",
|
|
Port: 1234,
|
|
Typ: "prflx",
|
|
Component: 1,
|
|
RelatedAddress: "1.0.0.1",
|
|
RelatedPort: 4321,
|
|
},
|
|
},
|
|
}
|
|
|
|
for i, testCase := range testCases {
|
|
actualSDP := iceCandidateToSDP(testCase.native)
|
|
assert.Equal(t,
|
|
testCase.sdp,
|
|
actualSDP,
|
|
"testCase: %d sdp not equal %v", i, actualSDP,
|
|
)
|
|
}
|
|
}
|