-
Notifications
You must be signed in to change notification settings - Fork 204
Expand file tree
/
Copy pathagent_on_selected_candidate_pair_change_test.go
More file actions
55 lines (39 loc) · 1.14 KB
/
agent_on_selected_candidate_pair_change_test.go
File metadata and controls
55 lines (39 loc) · 1.14 KB
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
// SPDX-FileCopyrightText: 2026 The Pion community <https://pion.ly>
// SPDX-License-Identifier: MIT
//go:build !js
package ice
import (
"context"
"testing"
"github.com/stretchr/testify/require"
)
func TestOnSelectedCandidatePairChange(t *testing.T) {
agent, candidatePair := fixtureTestOnSelectedCandidatePairChange(t)
defer func() {
require.NoError(t, agent.Close())
}()
callbackCalled := make(chan struct{}, 1)
err := agent.OnSelectedCandidatePairChange(func(_, _ Candidate) {
close(callbackCalled)
})
require.NoError(t, err)
err = agent.loop.Run(context.Background(), func(_ context.Context) {
agent.setSelectedPair(candidatePair)
})
require.NoError(t, err)
<-callbackCalled
}
func fixtureTestOnSelectedCandidatePairChange(t *testing.T) (*Agent, *CandidatePair) {
t.Helper()
agent, err := NewAgent(&AgentConfig{})
require.NoError(t, err)
candidatePair := makeCandidatePair(t)
return agent, candidatePair
}
func makeCandidatePair(t *testing.T) *CandidatePair {
t.Helper()
hostLocal := newHostLocal(t)
relayRemote := newRelayRemote(t)
candidatePair := newCandidatePair(hostLocal, relayRemote, false)
return candidatePair
}