(t *testing.T)
| 597 | } |
| 598 | |
| 599 | func TestMultipleCreateChannel(t *testing.T) { |
| 600 | var wg sync.WaitGroup |
| 601 | |
| 602 | report := test.CheckRoutines(t) |
| 603 | defer report() |
| 604 | |
| 605 | // Two OnDataChannel |
| 606 | // One OnNegotiationNeeded |
| 607 | wg.Add(3) |
| 608 | |
| 609 | pcOffer, _ := NewPeerConnection(Configuration{}) |
| 610 | pcAnswer, _ := NewPeerConnection(Configuration{}) |
| 611 | |
| 612 | pcAnswer.OnDataChannel(func(*DataChannel) { |
| 613 | wg.Done() |
| 614 | }) |
| 615 | |
| 616 | pcOffer.OnNegotiationNeeded(func() { |
| 617 | offer, err := pcOffer.CreateOffer(nil) |
| 618 | assert.NoError(t, err) |
| 619 | |
| 620 | offerGatheringComplete := GatheringCompletePromise(pcOffer) |
| 621 | assert.NoError(t, pcOffer.SetLocalDescription(offer)) |
| 622 | <-offerGatheringComplete |
| 623 | assert.NoError(t, pcAnswer.SetRemoteDescription(*pcOffer.LocalDescription())) |
| 624 | |
| 625 | answer, err := pcAnswer.CreateAnswer(nil) |
| 626 | assert.NoError(t, err) |
| 627 | |
| 628 | answerGatheringComplete := GatheringCompletePromise(pcAnswer) |
| 629 | assert.NoError(t, pcAnswer.SetLocalDescription(answer)) |
| 630 | <-answerGatheringComplete |
| 631 | err = pcOffer.SetRemoteDescription(*pcAnswer.LocalDescription()) |
| 632 | assert.NoError(t, err) |
| 633 | |
| 634 | wg.Done() |
| 635 | }) |
| 636 | |
| 637 | _, err := pcOffer.CreateDataChannel("initial_data_channel_0", nil) |
| 638 | assert.NoError(t, err) |
| 639 | |
| 640 | _, err = pcOffer.CreateDataChannel("initial_data_channel_1", nil) |
| 641 | assert.NoError(t, err) |
| 642 | wg.Wait() |
| 643 | |
| 644 | closePairNow(t, pcOffer, pcAnswer) |
| 645 | } |
| 646 | |
| 647 | // Assert that candidates are gathered by calling SetLocalDescription, not SetRemoteDescription. |
| 648 | func TestGatherOnSetLocalDescription(t *testing.T) { //nolint:cyclop |
nothing calls this directly
no test coverage detected
searching dependent graphs…