[TCSACR-480][WebRTC] Add new DataChannel buffered amount APIs 97/277397/2
authorHaesu Gwon <haesu.gwon@samsung.com>
Wed, 6 Jul 2022 07:45:53 +0000 (16:45 +0900)
committerHaesu Gwon <haesu.gwon@samsung.com>
Wed, 6 Jul 2022 12:15:31 +0000 (21:15 +0900)
Change-Id: I94bc651352fa226e843c971958f1a2553cfd079c

tct-suite-vs/Tizen.WebRTC.Tests/testcase/TSWebRTCDataChannel.Events.cs
tct-suite-vs/Tizen.WebRTC.Tests/testcase/TSWebRTCDataChannel.cs

index c69f8e2..c551030 100755 (executable)
@@ -162,5 +162,45 @@ namespace Tizen.Multimedia.Remoting.Tests {
 
             Assert.That(await tcsDataChannelMessageReceived.Task, "Event should be raised");
         }
+
+        [Test]
+        [Category("P1")]
+        [Description("Check whether BufferedAmountLow event is invoked or not.")]
+        [Property("SPEC", "Tizen.Multimedia.Remoting.WebRTCDataChannel.BufferedAmountLow E")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "EVL")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public async Task BufferedAmountLow_CHECK_EVENT()
+        {
+            var greetingMessage = "BufferedAmountLow event check message.";
+
+            var tcsDataChannel = new TaskCompletionSource<WebRTCDataChannel>(TaskCreationOptions.RunContinuationsAsynchronously);
+            var tcsDataChannelBufferedAmountLow = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
+
+            _answerClient.DataChannel += (s, e) =>
+            {
+                // DataChannel from peer
+                tcsDataChannel.TrySetResult(e.DataChannel);
+            };
+
+            await _offerClient.StartAsync();
+            await _answerClient.StartAsync();
+
+            await ConnectPeerAsync(_offerClient, _answerClient);
+
+            var answerDataChannel = await tcsDataChannel.Task;
+
+            await _tcsAnswerTrackAdded.Task;
+
+            _offerDataChannel.BufferedAmountLowThreshold = 10;
+            _offerDataChannel.BufferedAmountLow += (s, e) =>
+            {
+                tcsDataChannelBufferedAmountLow.TrySetResult(true);
+            };
+
+            _offerDataChannel.Send(greetingMessage);
+
+            Assert.That(await tcsDataChannelBufferedAmountLow.Task, "Event should be raised");
+        }
     }
 }
\ No newline at end of file
index 938185e..5e06a3b 100755 (executable)
@@ -175,5 +175,92 @@ namespace Tizen.Multimedia.Remoting.Tests {
             Assert.That(() => webRtcDataChannel.Send(data), Throws.TypeOf<ObjectDisposedException>(),
                 "Should throw ObjectDisposedException");
         }
+
+        [Test]
+        [Category("P1")]
+        [Description("Check whether BufferedAmount returns expected value or not.")]
+        [Property("SPEC", "Tizen.Multimedia.Remoting.WebRTCDataChannel.BufferedAmount A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PRO")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void BufferedAmount_READ_ONLY()
+        {
+            using (var webRtcDataChannel = new WebRTCDataChannel(_webRtc, "test"))
+            {
+                Assert.That(() => webRtcDataChannel.BufferedAmount, Is.GreaterThanOrEqualTo(0),
+                    "Should be greater than or equal to zero");
+                AssertHelper.PropertyReadOnly<WebRTCDataChannel>(nameof(WebRTCDataChannel.BufferedAmount));
+            }
+        }
+
+        [Test]
+        [Category("P2")]
+        [Description("Check whether BufferedAmount throw ObjectDisposedException or not.")]
+        [Property("SPEC", "Tizen.Multimedia.Remoting.WebRTCDataChannel.BufferedAmount A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PEX")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void BufferedAmount_THROWS_IF_ALREADY_DISPOSED()
+        {
+            var webRtcDataChannel = new WebRTCDataChannel(_webRtc, "test");
+            webRtcDataChannel.Dispose();
+
+            Assert.That(() =>  webRtcDataChannel.BufferedAmount, Throws.TypeOf<ObjectDisposedException>(),
+                "Should throw ObjectDisposedException");
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Check whether BufferedAmountLowThreshold returns expected value or not.")]
+        [Property("SPEC", "Tizen.Multimedia.Remoting.WebRTCDataChannel.BufferedAmountLowThreshold A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PRW")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void BufferedAmountLowThreshold_READ_WRITE()
+        {
+            using (var webRtcDataChannel = new WebRTCDataChannel(_webRtc, "test"))
+            {
+                Assert.That(() => webRtcDataChannel.BufferedAmountLowThreshold = 10, Throws.Nothing,
+                    "Default value should be zero.");
+
+                Assert.That(() => webRtcDataChannel.BufferedAmountLowThreshold, Is.EqualTo(10),
+                    "Default value should be zero.");
+            }
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Check whether BufferedAmountLowThreshold returns expected value or not.")]
+        [Property("SPEC", "Tizen.Multimedia.Remoting.WebRTCDataChannel.BufferedAmountLowThreshold A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PDV")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void BufferedAmountLowThreshold_CHECK_DEFAULT_VALUE()
+        {
+            using (var webRtcDataChannel = new WebRTCDataChannel(_webRtc, "test"))
+            {
+                Assert.That(webRtcDataChannel.BufferedAmountLowThreshold, Is.EqualTo(0),
+                    "Default value should be zero.");
+            }
+        }
+
+        [Test]
+        [Category("P2")]
+        [Description("Check whether BufferedAmountLowThreshold throw ObjectDisposedException or not.")]
+        [Property("SPEC", "Tizen.Multimedia.Remoting.WebRTCDataChannel.BufferedAmountLowThreshold A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PEX")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public void BufferedAmountLowThreshold_THROWS_IF_ALREADY_DISPOSED()
+        {
+            var webRtcDataChannel = new WebRTCDataChannel(_webRtc, "test");
+            webRtcDataChannel.Dispose();
+
+            Assert.That(() => webRtcDataChannel.BufferedAmountLowThreshold, Throws.TypeOf<ObjectDisposedException>(),
+                "Should throw ObjectDisposedException");
+
+            Assert.That(() => webRtcDataChannel.BufferedAmountLowThreshold = 10, Throws.TypeOf<ObjectDisposedException>(),
+                "Should throw ObjectDisposedException");
+        }
     }
 }
\ No newline at end of file