forked from pion/webrtc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathicegatherer_test.go
63 lines (48 loc) · 1.05 KB
/
icegatherer_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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// +build !js
package webrtc
import (
"testing"
"time"
"github.com/pion/transport/test"
)
func TestNewICEGatherer_Success(t *testing.T) {
// Limit runtime in case of deadlocks
lim := test.TimeOut(time.Second * 20)
defer lim.Stop()
report := test.CheckRoutines(t)
defer report()
opts := ICEGatherOptions{
ICEServers: []ICEServer{{URLs: []string{"stun:stun.l.google.com:19302"}}},
}
api := NewAPI()
gatherer, err := api.NewICEGatherer(opts)
if err != nil {
t.Error(err)
}
if gatherer.State() != ICEGathererStateNew {
t.Fatalf("Expected gathering state new")
}
err = gatherer.Gather()
if err != nil {
t.Error(err)
}
params, err := gatherer.GetLocalParameters()
if err != nil {
t.Error(err)
}
if len(params.UsernameFragment) == 0 ||
len(params.Password) == 0 {
t.Fatalf("Empty local username or password frag")
}
candidates, err := gatherer.GetLocalCandidates()
if err != nil {
t.Error(err)
}
if len(candidates) == 0 {
t.Fatalf("No candidates gathered")
}
err = gatherer.Close()
if err != nil {
t.Error(err)
}
}