Skip to content

Commit aea0781

Browse files
committed
Add leaving the call in tests if previous is still active + fix When_client_joins_call_with_video_expect_receiving_video_track test
1 parent 60d5f34 commit aea0781

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

Packages/StreamVideo/Tests/Runtime/CallsTests.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Linq;
44
using System.Threading.Tasks;
55
using NUnit.Framework;
6+
using StreamVideo.Core;
67
using StreamVideo.Core.StatefulModels.Tracks;
78
using StreamVideo.Tests.Shared;
89
using UnityEngine;
@@ -35,27 +36,32 @@ public IEnumerator When_client_joins_call_with_video_expect_receiving_video_trac
3536
private async Task When_client_joins_call_with_video_expect_receiving_video_track_Async(
3637
ITestClient clientA, ITestClient clientB)
3738
{
38-
var streamCall = await clientA.JoinRandomCallAsync();
39+
var clientACall = await clientA.JoinRandomCallAsync();
3940

4041
var cameraDevice = await TestUtils.TryGetFirstWorkingCameraDeviceAsync(clientA.Client);
4142
Debug.Log("Selected camera device: " + cameraDevice);
4243
clientA.Client.VideoDeviceManager.SelectDevice(cameraDevice, enable: true);
4344

44-
var call = await clientB.Client.JoinCallAsync(streamCall.Type, streamCall.Id, create: false,
45+
var clientBCall = await clientB.Client.JoinCallAsync(clientACall.Type, clientACall.Id, create: false,
4546
ring: false,
4647
notify: false);
4748

48-
var otherParticipant = call.Participants.First(p => !p.IsLocalParticipant);
49+
// Wait for client B to get client A participant
50+
await WaitForConditionAsync(()
51+
=> clientBCall.Participants.Any(p => p.SessionId == clientACall.GetLocalParticipant().SessionId));
52+
53+
var clientAParticipant = clientBCall.Participants.First(p => p.SessionId == clientACall.GetLocalParticipant().SessionId);
54+
clientAParticipant.UpdateRequestedVideoResolution(VideoResolution.Res_720p);
4955

5056
StreamVideoTrack streamTrack = null;
5157

52-
if (otherParticipant.VideoTrack != null)
58+
if (clientAParticipant.VideoTrack != null)
5359
{
54-
streamTrack = (StreamVideoTrack)otherParticipant.VideoTrack;
60+
streamTrack = (StreamVideoTrack)clientAParticipant.VideoTrack;
5561
}
5662
else
5763
{
58-
otherParticipant.TrackAdded += (_, track) => { streamTrack = (StreamVideoTrack)track; };
64+
clientAParticipant.TrackAdded += (_, track) => { streamTrack = (StreamVideoTrack)track; };
5965

6066
await WaitForConditionAsync(() => streamTrack != null);
6167
}

Packages/StreamVideo/Tests/Shared/TestClient.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ public TestClient(IStreamVideoClient client)
2323

2424
public async Task<IStreamCall> JoinRandomCallAsync()
2525
{
26+
if (Client.ActiveCall != null)
27+
{
28+
await Client.ActiveCall.LeaveAsync();
29+
}
30+
2631
var callId = Guid.NewGuid().ToString();
2732
return await Client.JoinCallAsync(StreamCallType.Default, callId, create: true, ring: false,
2833
notify: false);

0 commit comments

Comments
 (0)