[Non-ACR][WebRTC] Add TCs for ErrorOccurred event and its EventArgs class 78/277178/2
authorHaesu Gwon <haesu.gwon@samsung.com>
Fri, 1 Jul 2022 08:20:00 +0000 (17:20 +0900)
committerHaesu Gwon <haesu.gwon@samsung.com>
Wed, 20 Jul 2022 10:52:00 +0000 (10:52 +0000)
Change-Id: Ibd2224ff7f0441b62925645cc017efb841269cad

tct-suite-vs/Tizen.WebRTC.Tests/testcase/TSMediaStreamTrack.cs
tct-suite-vs/Tizen.WebRTC.Tests/testcase/TSWebRTC.Events.ErrorOccurred.cs [new file with mode: 0755]
tct-suite-vs/Tizen.WebRTC.Tests/testcase/TSWebRTCErrorOccurredEventArgs.cs [new file with mode: 0755]
tct-suite-vs/Tizen.WebRTC.Tests/testcase/support/TestBase.cs

index 8d91ad5..907bbe4 100755 (executable)
@@ -453,7 +453,7 @@ namespace Tizen.Multimedia.Remoting.Tests
                 tcsAnswerTrackAdded.TrySetResult(false);
             };
 
-            _answerClient.AudioFrameEncoded += (s, e) => Log.Info(LogInfo.Tag, "Enter");
+            _answerClient.AudioFrameEncoded += (s, e) => Log.Info(WebRTCTestLog.Tag, "Enter");
 
             var offerSource = new MediaTestSource(MediaType.Audio);
 
@@ -499,7 +499,7 @@ namespace Tizen.Multimedia.Remoting.Tests
                 tcsAnswerTrackAdded.TrySetResult(false);
             };
 
-            _answerClient.AudioFrameEncoded += (s, e) => Log.Info(LogInfo.Tag, "Enter");
+            _answerClient.AudioFrameEncoded += (s, e) => Log.Info(WebRTCTestLog.Tag, "Enter");
 
             var offerSource = new MediaTestSource(MediaType.Audio);
 
@@ -542,7 +542,7 @@ namespace Tizen.Multimedia.Remoting.Tests
                 tcsAnswerTrackAdded.TrySetResult(false);
             };
 
-            _answerClient.AudioFrameEncoded += (s, e) => Log.Info(LogInfo.Tag, "Enter");
+            _answerClient.AudioFrameEncoded += (s, e) => Log.Info(WebRTCTestLog.Tag, "Enter");
 
             var offerSource = new MediaTestSource(MediaType.Audio);
 
diff --git a/tct-suite-vs/Tizen.WebRTC.Tests/testcase/TSWebRTC.Events.ErrorOccurred.cs b/tct-suite-vs/Tizen.WebRTC.Tests/testcase/TSWebRTC.Events.ErrorOccurred.cs
new file mode 100755 (executable)
index 0000000..eb2b9db
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ *  Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License
+ */
+
+using NUnit.Framework;
+using System.Threading.Tasks;
+
+namespace Tizen.Multimedia.Remoting.Tests
+{
+    [TestFixture]
+    [Description("Tizen.Multimedia.Remoting.ErrorOccurred Tests")]
+    public class ErrorOccurredEventTests : TestBase
+    {
+        [Test]
+        [Category("P1")]
+        [Description("Check whether ErrorOccurred event is invoked or not.")]
+        [Property("SPEC", "Tizen.Multimedia.Remoting.WebRTC.ErrorOccurred E")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "EVL")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public async Task ErrorOccurred_CHECK_EVENT()
+        {
+            using (var webRtc = new WebRTC())
+            using (var eventAwaiter = EventAwaiter<WebRTCErrorOccurredEventArgs>.Create())
+            {
+                var tcs = new TaskCompletionSource<bool>();
+
+                var cameraSource = new MediaCameraSource();
+                webRtc.AddSource(cameraSource);
+
+                cameraSource.VideoFrameRate = 10000;
+
+                webRtc.ErrorOccurred += eventAwaiter;
+
+                webRtc.Start();
+
+                Assert.That(await eventAwaiter.IsRaisedAsync(), Is.EqualTo(true),
+                    "Should return InvalidOperation");
+            }
+        }
+    }
+}
diff --git a/tct-suite-vs/Tizen.WebRTC.Tests/testcase/TSWebRTCErrorOccurredEventArgs.cs b/tct-suite-vs/Tizen.WebRTC.Tests/testcase/TSWebRTCErrorOccurredEventArgs.cs
new file mode 100755 (executable)
index 0000000..8b950a2
--- /dev/null
@@ -0,0 +1,117 @@
+using System;
+/*
+ *  Copyright (c) 2022 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License
+ */
+
+using NUnit.Framework;
+using System.Threading.Tasks;
+
+namespace Tizen.Multimedia.Remoting.Tests
+{
+    [TestFixture]
+    [Description("Tizen.Multimedia.Remoting.WebRTCErrorOccurredEventArgs Test class")]
+    public class WebRTCErrorOccurredEventArgsTests
+    {
+        [Test]
+        [Category("P1")]
+        [Description("Check whether WebRTCErrorOccurredEventArgs.Error returns valid value or not.")]
+        [Property("SPEC", "Tizen.Multimedia.Remoting.WebRTCErrorOccurredEventArgs.Error A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PRO")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public async Task Error_READ_ONLY()
+        {
+            using (var webRtc = new WebRTC())
+            using (var eventAwaiter = EventAwaiter<WebRTCErrorOccurredEventArgs>.Create())
+            {
+                var tcs = new TaskCompletionSource<bool>();
+
+                var cameraSource = new MediaCameraSource();
+                webRtc.AddSource(cameraSource);
+
+                cameraSource.VideoFrameRate = 10000;
+
+                webRtc.ErrorOccurred += eventAwaiter;
+
+                webRtc.Start();
+
+                var args = await eventAwaiter.GetResultAsync();
+
+                Assert.IsNotNull(args.Error, "Error should not be null.");
+                Assert.IsInstanceOf<WebRTCError>(args.Error, "Should be same type");
+            }
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Check whether WebRTCErrorOccurredEventArgs.State returns valid value or not.")]
+        [Property("SPEC", "Tizen.Multimedia.Remoting.WebRTCErrorOccurredEventArgs.State A")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "PRO")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public async Task State_READ_ONLY()
+        {
+            using (var webRtc = new WebRTC())
+            using (var eventAwaiter = EventAwaiter<WebRTCErrorOccurredEventArgs>.Create())
+            {
+                var tcs = new TaskCompletionSource<bool>();
+
+                var cameraSource = new MediaCameraSource();
+                webRtc.AddSource(cameraSource);
+
+                cameraSource.VideoFrameRate = 10000;
+
+                webRtc.ErrorOccurred += eventAwaiter;
+
+                webRtc.Start();
+
+                var args = await eventAwaiter.GetResultAsync();
+
+                Assert.IsNotNull(args.State, "State should not be null.");
+                Assert.IsInstanceOf<WebRTCState>(args.State, "Should be same type");
+            }
+        }
+
+        [Test]
+        [Category("P1")]
+        [Description("Check whether ToString returns expected value or not.")]
+        [Property("SPEC", "Tizen.Multimedia.Remoting.WebRTCErrorOccurredEventArgs.ToString M")]
+        [Property("SPEC_URL", "-")]
+        [Property("CRITERIA", "MR")]
+        [Property("AUTHOR", "Haesu Gwon, haesu.gwon@samsung.com")]
+        public async Task ToString_CHECK_VALUE()
+        {
+            using (var webRtc = new WebRTC())
+            using (var eventAwaiter = EventAwaiter<WebRTCErrorOccurredEventArgs>.Create())
+            {
+                var tcs = new TaskCompletionSource<bool>();
+
+                var cameraSource = new MediaCameraSource();
+                webRtc.AddSource(cameraSource);
+
+                cameraSource.VideoFrameRate = 10000;
+
+                webRtc.ErrorOccurred += eventAwaiter;
+
+                webRtc.Start();
+
+                var args = await eventAwaiter.GetResultAsync();
+
+                Assert.AreEqual($"Error={args.Error}, State={args.State}", args.ToString(),
+                    "Should be the same string");
+            }
+        }
+    }
+}
index 4d2c816..fe72e66 100644 (file)
@@ -142,7 +142,7 @@ namespace Tizen.Multimedia.Remoting.Tests
         }
     }
 
-    internal static class LogInfo
+    internal static class WebRTCTestLog
     {
         internal static readonly string Tag = "Tizen.WebRTC.Tests";
     }