forked from pion/webrtc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
icetransport_test.go
47 lines (36 loc) · 1.03 KB
/
icetransport_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// +build !js
package webrtc
import (
"sync/atomic"
"testing"
"time"
"github.com/pion/transport/test"
"github.com/stretchr/testify/assert"
)
func TestICETransport_OnSelectedCandidatePairChange(t *testing.T) {
report := test.CheckRoutines(t)
defer report()
lim := test.TimeOut(time.Second * 30)
defer lim.Stop()
pcOffer, pcAnswer, err := newPair()
if err != nil {
t.Fatal(err)
}
iceComplete := make(chan bool)
pcAnswer.OnICEConnectionStateChange(func(iceState ICEConnectionState) {
if iceState == ICEConnectionStateConnected {
time.Sleep(3 * time.Second)
close(iceComplete)
}
})
senderCalledCandidateChange := int32(0)
pcOffer.SCTP().Transport().ICETransport().OnSelectedCandidatePairChange(func(pair *ICECandidatePair) {
atomic.StoreInt32(&senderCalledCandidateChange, 1)
})
assert.NoError(t, signalPair(pcOffer, pcAnswer))
<-iceComplete
if atomic.LoadInt32(&senderCalledCandidateChange) == 0 {
t.Fatalf("Sender ICETransport OnSelectedCandidateChange was never called")
}
closePairNow(t, pcOffer, pcAnswer)
}