[Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
public async Task AddIceCandidate_NO_EXCEPTION()
{
+ var tcsIceGatheringStateChanged = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
_webRtc.AddSource(new MediaTestSource(MediaType.Video));
await _webRtc.StartAsync();
var offer = await _webRtc.CreateOfferAsync();
- using (var eventWaiter = EventAwaiter<WebRTCIceCandidateEventArgs>.Create())
+ using (var eventWaiterIceCandidate = EventAwaiter<WebRTCIceCandidateEventArgs>.Create())
{
- _webRtc.IceCandidate += eventWaiter;
+ _webRtc.IceCandidate += eventWaiterIceCandidate;
+ _webRtc.IceGatheringStateChanged += IceGatheringStateChanged;
try
{
_webRtc.SetLocalDescription(offer);
- var result = await eventWaiter.GetResultAsync();
+ var result = await eventWaiterIceCandidate.GetResultAsync();
Assert.That(() => _webRtc.AddIceCandidate(result.ICECandidate), Throws.Nothing,
"Should not throw exception");
+
+ await tcsIceGatheringStateChanged.Task;
}
finally
{
- _webRtc.IceCandidate -= eventWaiter;
+ _webRtc.IceCandidate -= eventWaiterIceCandidate;
+ _webRtc.IceGatheringStateChanged -= IceGatheringStateChanged;
+ }
+ }
+
+ void IceGatheringStateChanged(object s, WebRTCIceGatheringStateChangedEventArgs e)
+ {
+ if (e.State == WebRTCIceGatheringState.Completed)
+ {
+ tcsIceGatheringStateChanged.TrySetResult(true);
}
}
}
[Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
public async Task AddIceCandidates_NO_EXCEPTION()
{
+ var tcsIceGatheringStateChanged = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
_webRtc.AddSource(new MediaTestSource(MediaType.Video));
await _webRtc.StartAsync();
var offer = await _webRtc.CreateOfferAsync();
try
{
_webRtc.IceCandidate += eventWaiter;
+ _webRtc.IceGatheringStateChanged += IceGatheringStateChanged;
_webRtc.SetLocalDescription(offer);
Assert.That(() => _webRtc.AddIceCandidates(new List<string>{ result.ICECandidate }), Throws.Nothing,
"Should not throw exception");
+
+ await tcsIceGatheringStateChanged.Task;
}
finally
{
_webRtc.IceCandidate -= eventWaiter;
+ _webRtc.IceGatheringStateChanged -= IceGatheringStateChanged;
+ }
+ }
+
+ void IceGatheringStateChanged(object s, WebRTCIceGatheringStateChangedEventArgs e)
+ {
+ if (e.State == WebRTCIceGatheringState.Completed)
+ {
+ tcsIceGatheringStateChanged.TrySetResult(true);
}
}
}