MCPcopy
hub / github.com/pion/webrtc / TestMultipleCreateChannel

Function TestMultipleCreateChannel

peerconnection_test.go:599–645  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

597}
598
599func TestMultipleCreateChannel(t *testing.T) {
600 var wg sync.WaitGroup
601
602 report := test.CheckRoutines(t)
603 defer report()
604
605 // Two OnDataChannel
606 // One OnNegotiationNeeded
607 wg.Add(3)
608
609 pcOffer, _ := NewPeerConnection(Configuration{})
610 pcAnswer, _ := NewPeerConnection(Configuration{})
611
612 pcAnswer.OnDataChannel(func(*DataChannel) {
613 wg.Done()
614 })
615
616 pcOffer.OnNegotiationNeeded(func() {
617 offer, err := pcOffer.CreateOffer(nil)
618 assert.NoError(t, err)
619
620 offerGatheringComplete := GatheringCompletePromise(pcOffer)
621 assert.NoError(t, pcOffer.SetLocalDescription(offer))
622 <-offerGatheringComplete
623 assert.NoError(t, pcAnswer.SetRemoteDescription(*pcOffer.LocalDescription()))
624
625 answer, err := pcAnswer.CreateAnswer(nil)
626 assert.NoError(t, err)
627
628 answerGatheringComplete := GatheringCompletePromise(pcAnswer)
629 assert.NoError(t, pcAnswer.SetLocalDescription(answer))
630 <-answerGatheringComplete
631 err = pcOffer.SetRemoteDescription(*pcAnswer.LocalDescription())
632 assert.NoError(t, err)
633
634 wg.Done()
635 })
636
637 _, err := pcOffer.CreateDataChannel("initial_data_channel_0", nil)
638 assert.NoError(t, err)
639
640 _, err = pcOffer.CreateDataChannel("initial_data_channel_1", nil)
641 assert.NoError(t, err)
642 wg.Wait()
643
644 closePairNow(t, pcOffer, pcAnswer)
645}
646
647// Assert that candidates are gathered by calling SetLocalDescription, not SetRemoteDescription.
648func TestGatherOnSetLocalDescription(t *testing.T) { //nolint:cyclop

Callers

nothing calls this directly

Calls 12

OnDataChannelMethod · 0.95
OnNegotiationNeededMethod · 0.95
CreateOfferMethod · 0.95
SetLocalDescriptionMethod · 0.95
SetRemoteDescriptionMethod · 0.95
LocalDescriptionMethod · 0.95
CreateAnswerMethod · 0.95
CreateDataChannelMethod · 0.95
GatheringCompletePromiseFunction · 0.85
closePairNowFunction · 0.85
NewPeerConnectionFunction · 0.70
DoneMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…