(t *testing.T)
| 773 | } |
| 774 | |
| 775 | func TestRoomUpdate(t *testing.T) { |
| 776 | t.Run("updates are sent when participant joined", func(t *testing.T) { |
| 777 | rm := newRoomWithParticipants(t, testRoomOpts{num: 1}) |
| 778 | defer rm.Close(types.ParticipantCloseReasonNone) |
| 779 | |
| 780 | p1 := rm.GetParticipants()[0].(*typesfakes.FakeLocalParticipant) |
| 781 | require.Equal(t, 0, p1.SendRoomUpdateCallCount()) |
| 782 | |
| 783 | p2 := NewMockParticipant("p2", types.CurrentProtocol, false, false, rm.LocalParticipantListener()) |
| 784 | require.NoError(t, rm.Join(p2, nil, nil, iceServersForRoom)) |
| 785 | |
| 786 | // p1 should have received an update |
| 787 | time.Sleep(2 * defaultDelay) |
| 788 | require.LessOrEqual(t, 1, p1.SendRoomUpdateCallCount()) |
| 789 | require.EqualValues(t, 2, p1.SendRoomUpdateArgsForCall(p1.SendRoomUpdateCallCount()-1).NumParticipants) |
| 790 | }) |
| 791 | |
| 792 | t.Run("participants should receive metadata update", func(t *testing.T) { |
| 793 | rm := newRoomWithParticipants(t, testRoomOpts{num: 2}) |
| 794 | defer rm.Close(types.ParticipantCloseReasonNone) |
| 795 | |
| 796 | rm.SetMetadata("test metadata...") |
| 797 | |
| 798 | // callbacks are updated from goroutine |
| 799 | time.Sleep(2 * defaultDelay) |
| 800 | |
| 801 | for _, op := range rm.GetParticipants() { |
| 802 | fp := op.(*typesfakes.FakeLocalParticipant) |
| 803 | // room updates are now sent for both participant joining and room metadata |
| 804 | require.GreaterOrEqual(t, fp.SendRoomUpdateCallCount(), 1) |
| 805 | } |
| 806 | }) |
| 807 | } |
| 808 | |
| 809 | type testRoomOpts struct { |
| 810 | num int |
nothing calls this directly
no test coverage detected