MCPcopy Create free account
hub / github.com/pion/ice / TestRunTaskInConnectionStateCallback

Function TestRunTaskInConnectionStateCallback

agent_test.go:2157–2200  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2155}
2156
2157func TestRunTaskInConnectionStateCallback(t *testing.T) {
2158 defer test.CheckRoutines(t)()
2159
2160 defer test.TimeOut(time.Second * 5).Stop()
2161
2162 oneSecond := time.Second
2163 KeepaliveInterval := time.Duration(0)
2164 CheckInterval := 50 * time.Millisecond
2165
2166 cfg := &AgentConfig{
2167 Urls: []*stun.URI{},
2168 NetworkTypes: supportedNetworkTypes(),
2169 DisconnectedTimeout: &oneSecond,
2170 FailedTimeout: &oneSecond,
2171 KeepaliveInterval: &KeepaliveInterval,
2172 CheckInterval: &CheckInterval,
2173 }
2174
2175 aAgent, err := NewAgent(cfg)
2176 require.NoError(t, err)
2177 defer func() {
2178 require.NoError(t, aAgent.Close())
2179 }()
2180 bAgent, err := NewAgent(cfg)
2181 require.NoError(t, err)
2182 defer func() {
2183 require.NoError(t, bAgent.Close())
2184 }()
2185
2186 isComplete := make(chan any)
2187 err = aAgent.OnConnectionStateChange(func(c ConnectionState) {
2188 if c == ConnectionStateConnected {
2189 _, _, errCred := aAgent.GetLocalUserCredentials()
2190 require.NoError(t, errCred)
2191 require.NoError(t, aAgent.Restart("", ""))
2192 close(isComplete)
2193 }
2194 })
2195 require.NoError(t, err)
2196
2197 connect(t, aAgent, bAgent)
2198
2199 <-isComplete
2200}
2201
2202func TestRunTaskInSelectedCandidatePairChangeCallback(t *testing.T) {
2203 defer test.CheckRoutines(t)()

Callers

nothing calls this directly

Calls 7

CloseMethod · 0.95
RestartMethod · 0.95
supportedNetworkTypesFunction · 0.85
NewAgentFunction · 0.85
connectFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…