*/
using NUnit.Framework;
using System;
+using System.Threading.Tasks;
namespace Tizen.Multimedia.Remoting.Tests {
[TestFixture]
[Description("Tizen.Multimedia.Remoting.WebRTCDataChannel Tests")]
- public class WebRTCDataChannelTests
+ public class WebRTCDataChannelTests : TestBase
{
private WebRTC _webRtc;
[Property("CRITERIA", "MR")]
[Property("COVPARAM", "string")]
[Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
- public void Send_CHECK_RETURN()
+ public async Task Send_CHECK_RETURN()
{
- var webRtcDataChannel = new WebRTCDataChannel(_webRtc, "test");
- Assert.That(() => webRtcDataChannel.Send("test"), Throws.Nothing,
- "Should not throw exception");
+ using (var offerClient = new WebRTC())
+ using (var answerClient = new WebRTC())
+ {
+ var tcsAnswerTrackAdded =
+ new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
+ var tcsOfferDataChannel =
+ new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
+
+ answerClient.TrackAdded += (s, e) => tcsAnswerTrackAdded.TrySetResult(true);
+ answerClient.DataChannel += (s, e) => tcsOfferDataChannel.TrySetResult(true);
+
+ offerClient.AddSource(new MediaTestSource(MediaType.Video));
+ var offerDataChannel = new WebRTCDataChannel(offerClient, "offerDataChannel");
+
+ await offerClient.StartAsync();
+ await answerClient.StartAsync();
+
+ await ConnectPeerAsync(offerClient, answerClient);
+
+ await Task.WhenAll(tcsOfferDataChannel.Task, tcsAnswerTrackAdded.Task);
+
+ Assert.That(() => offerDataChannel.Send("test"), Throws.Nothing,
+ "Should not throw exception");
+ }
}
[Test]
[Property("CRITERIA", "MR")]
[Property("COVPARAM", "byte[]")]
[Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
- public void Send_WITH_BYTE_CHECK_RETURN()
+ public async Task Send_WITH_BYTE_CHECK_RETURN()
{
- var webRtcDataChannel = new WebRTCDataChannel(_webRtc, "test");
- var data = new byte[10];
+ using (var offerClient = new WebRTC())
+ using (var answerClient = new WebRTC())
+ {
+ var tcsAnswerTrackAdded =
+ new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
+ var tcsOfferDataChannel =
+ new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
+
+ answerClient.TrackAdded += (s, e) => tcsAnswerTrackAdded.TrySetResult(true);
+ answerClient.DataChannel += (s, e) => tcsOfferDataChannel.TrySetResult(true);
+
+ offerClient.AddSource(new MediaTestSource(MediaType.Video));
+ var offerDataChannel = new WebRTCDataChannel(offerClient, "offerDataChannel");
- Assert.That(() => webRtcDataChannel.Send(data), Throws.Nothing,
- "Should not throw exception");
+ await offerClient.StartAsync();
+ await answerClient.StartAsync();
+
+ await ConnectPeerAsync(offerClient, answerClient);
+
+ await Task.WhenAll(tcsOfferDataChannel.Task, tcsAnswerTrackAdded.Task);
+
+ var data = new byte[10];
+ Assert.That(() => offerDataChannel.Send(data), Throws.Nothing,
+ "Should not throw exception");
+ }
}
[Test]