mirror of
https://github.com/pion/ice.git
synced 2025-10-31 02:36:32 +08:00
committed by
Sean DuBois
parent
f88c7d2cfa
commit
e928d7b932
@@ -3,6 +3,7 @@ package ice
|
||||
import (
|
||||
"context"
|
||||
"net"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -318,6 +319,7 @@ func TestConnectivityOnStartup(t *testing.T) {
|
||||
|
||||
cfg := &AgentConfig{
|
||||
Urls: []*URL{},
|
||||
Trickle: false,
|
||||
NetworkTypes: supportedNetworkTypes,
|
||||
taskLoopInterval: time.Hour,
|
||||
LoggerFactory: logging.NewDefaultLoggerFactory(),
|
||||
@@ -513,10 +515,14 @@ func TestConnectionStateCallback(t *testing.T) {
|
||||
lim := test.TimeOut(time.Second * 5)
|
||||
defer lim.Stop()
|
||||
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(2)
|
||||
|
||||
timeoutDuration := time.Second
|
||||
KeepaliveInterval := time.Duration(0)
|
||||
cfg := &AgentConfig{
|
||||
Urls: []*URL{},
|
||||
Trickle: true,
|
||||
NetworkTypes: supportedNetworkTypes,
|
||||
ConnectionTimeout: &timeoutDuration,
|
||||
KeepaliveInterval: &KeepaliveInterval,
|
||||
@@ -527,11 +533,35 @@ func TestConnectionStateCallback(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
err = aAgent.OnCandidate(func(candidate Candidate) {
|
||||
if candidate == nil {
|
||||
wg.Done()
|
||||
}
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
err = aAgent.GatherCandidates(cfg.Urls, cfg.NetworkTypes)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
bAgent, err := NewAgent(cfg)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
err = bAgent.OnCandidate(func(candidate Candidate) {
|
||||
if candidate == nil {
|
||||
wg.Done()
|
||||
}
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
err = bAgent.GatherCandidates(cfg.Urls, cfg.NetworkTypes)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
isChecking := make(chan interface{})
|
||||
isConnected := make(chan interface{})
|
||||
@@ -553,6 +583,7 @@ func TestConnectionStateCallback(t *testing.T) {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
wg.Wait()
|
||||
connect(aAgent, bAgent)
|
||||
|
||||
<-isChecking
|
||||
|
||||
Reference in New Issue
Block a user