From ca55fb6b4cf1413d0f7680e6a3646bb08097c272 Mon Sep 17 00:00:00 2001 From: Suyeon Hwang Date: Wed, 30 Aug 2023 14:45:12 +0900 Subject: [PATCH] [Tts][TCSACR-553] Add new TCs for synthesized pcm feature Change-Id: I606d5c70755848ff217a4e6710fb0489ab4efe47 Signed-off-by: Suyeon Hwang --- tct-suite-vs/Tizen.Tts.Tests/support/TtsWrapper.cs | 35 +++ .../testcase/TSSynthesizedPcmEventArgs.cs | 253 +++++++++++++++++++++ .../Tizen.Tts.Tests/testcase/TSTtsClient.cs | 119 +++++++++- 3 files changed, 406 insertions(+), 1 deletion(-) create mode 100644 tct-suite-vs/Tizen.Tts.Tests/testcase/TSSynthesizedPcmEventArgs.cs diff --git a/tct-suite-vs/Tizen.Tts.Tests/support/TtsWrapper.cs b/tct-suite-vs/Tizen.Tts.Tests/support/TtsWrapper.cs index ac72c0d..9f991c1 100755 --- a/tct-suite-vs/Tizen.Tts.Tests/support/TtsWrapper.cs +++ b/tct-suite-vs/Tizen.Tts.Tests/support/TtsWrapper.cs @@ -9,11 +9,13 @@ namespace Tizen.Uix.Tts.Tests internal bool CreatedStateFlag = false; internal bool TestFlag = false; internal bool ServiceStateFlag = false; + internal bool SynthesizedPcmFlag = false; internal Tizen.Uix.Tts.TtsClient TtsInst = null; internal Tts.State Current; internal Tts.State Previous; internal Tts.ServiceState CurrentService; internal Tts.ServiceState PreviousService; + internal SynthesizedPcmEventArgs SynthesizedPcmEventArgs; internal Tts.Error TtsError; internal bool TtsErrorFlag = false; internal int UtteranceId = 0; @@ -91,6 +93,30 @@ namespace Tizen.Uix.Tts.Tests } } + internal async Task WaitSynthesizedPcmFlag(int times) + { + int count = 0; + int timeout = times * 100; + + while (true) + { + count++; + if (SynthesizedPcmFlag) + { + TtsHelper.PrintLog(Type.DLogAndlogUtil, "SynthesizedPcmFlag is true at count " + count); + break; + } + + if (count == timeout) + { + TtsHelper.PrintLog(Type.DLogAndlogUtil, "count " + count + " expired"); + break; + } + + await Task.Delay(10); + } + } + internal void TtsStateChanged(object sender, StateChangedEventArgs e) { TtsHelper.PrintLog(Type.DLogAndlogUtil, "State Changed, Previous State:"+e.Previous+" Current State:"+e.Current); @@ -119,6 +145,15 @@ namespace Tizen.Uix.Tts.Tests ServiceStateFlag = true; } + internal void TtsSynthesizedPcm(object sender, SynthesizedPcmEventArgs e) + { + TtsHelper.PrintLog(Type.DLogAndlogUtil, $"Syntehsized PCM, utterance id : {e.UtteranceId}"); + if (!SynthesizedPcmFlag) { + SynthesizedPcmEventArgs = e; + SynthesizedPcmFlag = true; + } + } + internal void TtsErrorOccurred(object sender, ErrorOccurredEventArgs e) { TtsHelper.PrintLog(Type.DLogAndlogUtil, "Error Occured:"+e.ErrorValue); diff --git a/tct-suite-vs/Tizen.Tts.Tests/testcase/TSSynthesizedPcmEventArgs.cs b/tct-suite-vs/Tizen.Tts.Tests/testcase/TSSynthesizedPcmEventArgs.cs new file mode 100644 index 0000000..21ddf10 --- /dev/null +++ b/tct-suite-vs/Tizen.Tts.Tests/testcase/TSSynthesizedPcmEventArgs.cs @@ -0,0 +1,253 @@ +using System; +using System.Threading.Tasks; +using NUnit.Framework; + +namespace Tizen.Uix.Tts.Tests +{ + [TestFixture] + [Description("Tizen.Uix.Tts.SynthesizedPcmEventArgs Tests")] + public class SynthesizedPcmEventArgsTests + { + TtsWrapper obj = null; + private static bool _featureSupported = false; + private static readonly string _ttsFeature = "http://tizen.org/feature/speech.synthesis"; + + [SetUp] + public void Init() + { + TtsHelper.PrintLog(Type.DLogAndlogUtil, "Executing Init"); + System.Information.TryGetValue(_ttsFeature, out _featureSupported); + + try + { + obj ??= new TtsWrapper(); + + Assert.IsInstanceOf(obj.TtsInst, "Tts object is not of correct instance"); + Assert.IsNotNull(obj.TtsInst); + + obj.TtsInst.PlayingMode = PlayingMode.ByClient; + obj.TtsInst.SynthesizedPcm += obj.TtsSynthesizedPcm; + obj.DoPrepare(); + } + catch (Exception e) + { + TtsHelper.PrintLog(Type.DLogAndlogUtil, "Caught Exception :" + e.ToString()); + if (e is NotSupportedException) { + Assert.IsFalse(_featureSupported, "Invalid NotSupportedException"); + Assert.Pass("TTS speech.synthesis is Not supported"); + } else { + Assert.IsTrue(false, "Caught Exception" + e.ToString()); + } + } + } + + [TearDown] + public void Destroy() + { + if (_featureSupported) + { + TtsHelper.PrintLog(Type.DLogAndlogUtil, "Unprepare TTS"); + obj.TtsInst.Stop(); + obj.DoUnprepare(); + obj.Unregister(); + obj.TtsInst.SynthesizedPcm -= obj.TtsSynthesizedPcm; + } + + TtsHelper.PrintLog(Type.DLogAndlogUtil, "Executing Destroy"); + } + + [Test] + [Category("P1")] + [Description("Check working of SynthesizedPcmEventArgs UtteranceId Property for no exception")] + [Property("SPEC", "Tizen.Uix.Tts.SynthesizedPcmEventArgs.UtteranceId A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Suyeon Hwang, stom.hwang@samsung.com")] + public async Task UtteranceId_READ_ONLY() + { + try + { + await obj.WaitFlag(15); + obj.GetSupportedVoices(); + Assert.True(obj.list.Count > 0, "Languages are not present"); + var uttId = obj.TtsInst.AddText("Hello. This is a test about property of service state changed event arguments", obj.list[0].Language, 0, 0); + + /* + * TEST CODE + */ + TtsHelper.PrintLog(Type.DLogAndlogUtil, "Executing TC:UtteranceId_READ_ONLY"); + obj.TtsInst.Play(); + obj.SynthesizedPcmFlag = false; + await obj.WaitSynthesizedPcmFlag(10); + + Assert.AreEqual(uttId, obj.SynthesizedPcmEventArgs.UtteranceId, $"UtteranceId is not expected. expect{uttId} / actual{obj.SynthesizedPcmEventArgs.UtteranceId}"); + TtsHelper.PrintLog(Type.DLogAndlogUtil, "Completed TC:UtteranceId_READ_ONLY"); + } + catch (Exception e) + { + TtsHelper.PrintLog(Type.DLogAndlogUtil, "Caught Exception :" + e.ToString()); + if (e is NotSupportedException) { + Assert.IsFalse(_featureSupported, "Invalid NotSupportedException"); + } else { + Assert.IsTrue(false, "Caught Exception" + e.ToString()); + } + } + } + + [Test] + [Category("P1")] + [Description("Check working of SynthesizedPcmEventArgs EventType Property for no exception")] + [Property("SPEC", "Tizen.Uix.Tts.SynthesizedPcmEventArgs.EventType A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Suyeon Hwang, stom.hwang@samsung.com")] + public async Task EventType_READ_ONLY() + { + try + { + await obj.WaitFlag(15); + obj.GetSupportedVoices(); + Assert.True(obj.list.Count > 0, "Languages are not present"); + var uttId = obj.TtsInst.AddText("Hello. This is a test about property of service state changed event arguments", obj.list[0].Language, 0, 0); + + /* + * TEST CODE + */ + TtsHelper.PrintLog(Type.DLogAndlogUtil, "Executing TC:EventType_READ_ONLY"); + obj.TtsInst.Play(); + obj.SynthesizedPcmFlag = false; + await obj.WaitSynthesizedPcmFlag(10); + + Assert.AreEqual(uttId, obj.SynthesizedPcmEventArgs.UtteranceId, $"UtteranceId is not expected. expect{uttId} / actual{obj.SynthesizedPcmEventArgs.UtteranceId}"); + Assert.AreEqual(SynthesizedPcmEvent.Start, obj.SynthesizedPcmEventArgs.EventType, $"EventType is not start. actual{obj.SynthesizedPcmEventArgs.EventType}"); + TtsHelper.PrintLog(Type.DLogAndlogUtil, "Completed TC:EventType_READ_ONLY"); + } + catch (Exception e) + { + TtsHelper.PrintLog(Type.DLogAndlogUtil, "Caught Exception :" + e.ToString()); + if (e is NotSupportedException) { + Assert.IsFalse(_featureSupported, "Invalid NotSupportedException"); + } else { + Assert.IsTrue(false, "Caught Exception" + e.ToString()); + } + } + } + + [Test] + [Category("P1")] + [Description("Check working of SynthesizedPcmEventArgs Data Property for no exception")] + [Property("SPEC", "Tizen.Uix.Tts.SynthesizedPcmEventArgs.Data A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Suyeon Hwang, stom.hwang@samsung.com")] + public async Task Data_READ_ONLY() + { + try + { + await obj.WaitFlag(15); + obj.GetSupportedVoices(); + Assert.True(obj.list.Count > 0, "Languages are not present"); + var uttId = obj.TtsInst.AddText("Hello. This is a test about property of service state changed event arguments", obj.list[0].Language, 0, 0); + + /* + * TEST CODE + */ + TtsHelper.PrintLog(Type.DLogAndlogUtil, "Executing TC:Data_READ_ONLY"); + obj.TtsInst.Play(); + obj.SynthesizedPcmFlag = false; + await obj.WaitSynthesizedPcmFlag(10); + + Assert.AreEqual(uttId, obj.SynthesizedPcmEventArgs.UtteranceId, $"UtteranceId is not expected. expect{uttId} / actual{obj.SynthesizedPcmEventArgs.UtteranceId}"); + Assert.Greater(obj.SynthesizedPcmEventArgs.Data.Length, 0, $"Data is not exist. size{obj.SynthesizedPcmEventArgs.Data.Length}"); + TtsHelper.PrintLog(Type.DLogAndlogUtil, "Completed TC:PcmEvent_READ_ONLY"); + } + catch (Exception e) + { + TtsHelper.PrintLog(Type.DLogAndlogUtil, "Caught Exception :" + e.ToString()); + if (e is NotSupportedException) { + Assert.IsFalse(_featureSupported, "Invalid NotSupportedException"); + } else { + Assert.IsTrue(false, "Caught Exception" + e.ToString()); + } + } + } + + [Test] + [Category("P1")] + [Description("Check working of SynthesizedPcmEventArgs AudioType Property for no exception")] + [Property("SPEC", "Tizen.Uix.Tts.SynthesizedPcmEventArgs.AudioType A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Suyeon Hwang, stom.hwang@samsung.com")] + public async Task AudioType_READ_ONLY() + { + try + { + await obj.WaitFlag(15); + obj.GetSupportedVoices(); + Assert.True(obj.list.Count > 0, "Languages are not present"); + var uttId = obj.TtsInst.AddText("Hello. This is a test about property of service state changed event arguments", obj.list[0].Language, 0, 0); + + /* + * TEST CODE + */ + TtsHelper.PrintLog(Type.DLogAndlogUtil, "Executing TC:AudioType_READ_ONLY"); + obj.TtsInst.Play(); + obj.SynthesizedPcmFlag = false; + await obj.WaitSynthesizedPcmFlag(10); + + Assert.AreEqual(uttId, obj.SynthesizedPcmEventArgs.UtteranceId, $"UtteranceId is not expected. expect{uttId} / actual{obj.SynthesizedPcmEventArgs.UtteranceId}"); + Assert.IsInstanceOf(obj.SynthesizedPcmEventArgs.AudioType, $"AudioType is not valid. actual{obj.SynthesizedPcmEventArgs.AudioType}"); + TtsHelper.PrintLog(Type.DLogAndlogUtil, "Completed TC:PcmEvent_READ_ONLY"); + } + catch (Exception e) + { + TtsHelper.PrintLog(Type.DLogAndlogUtil, "Caught Exception :" + e.ToString()); + if (e is NotSupportedException) { + Assert.IsFalse(_featureSupported, "Invalid NotSupportedException"); + } else { + Assert.IsTrue(false, "Caught Exception" + e.ToString()); + } + } + } + + [Test] + [Category("P1")] + [Description("Check working of SynthesizedPcmEventArgs SampleRate Property for no exception")] + [Property("SPEC", "Tizen.Uix.Tts.SynthesizedPcmEventArgs.SampleRate A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRO")] + [Property("AUTHOR", "Suyeon Hwang, stom.hwang@samsung.com")] + public async Task SampleRate_READ_ONLY() + { + try + { + await obj.WaitFlag(15); + obj.GetSupportedVoices(); + Assert.True(obj.list.Count > 0, "Languages are not present"); + var uttId = obj.TtsInst.AddText("Hello. This is a test about property of service state changed event arguments", obj.list[0].Language, 0, 0); + + /* + * TEST CODE + */ + TtsHelper.PrintLog(Type.DLogAndlogUtil, "Executing TC:SampleRate_READ_ONLY"); + obj.TtsInst.Play(); + obj.SynthesizedPcmFlag = false; + await obj.WaitSynthesizedPcmFlag(10); + + Assert.AreEqual(uttId, obj.SynthesizedPcmEventArgs.UtteranceId, $"UtteranceId is not expected. expect{uttId} / actual{obj.SynthesizedPcmEventArgs.UtteranceId}"); + Assert.Greater(obj.SynthesizedPcmEventArgs.SampleRate, 0, $"SampleRate is not valid. actual{obj.SynthesizedPcmEventArgs.SampleRate}"); + TtsHelper.PrintLog(Type.DLogAndlogUtil, "Completed TC:PcmEvent_READ_ONLY"); + } + catch (Exception e) + { + TtsHelper.PrintLog(Type.DLogAndlogUtil, "Caught Exception :" + e.ToString()); + if (e is NotSupportedException) { + Assert.IsFalse(_featureSupported, "Invalid NotSupportedException"); + } else { + Assert.IsTrue(false, "Caught Exception" + e.ToString()); + } + } + } + } +} diff --git a/tct-suite-vs/Tizen.Tts.Tests/testcase/TSTtsClient.cs b/tct-suite-vs/Tizen.Tts.Tests/testcase/TSTtsClient.cs index 4931653..38b783c 100755 --- a/tct-suite-vs/Tizen.Tts.Tests/testcase/TSTtsClient.cs +++ b/tct-suite-vs/Tizen.Tts.Tests/testcase/TSTtsClient.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Threading.Tasks; using NUnit.Framework; @@ -52,6 +52,7 @@ namespace Tizen.Uix.Tts.Tests private static void TtsInst_UtteranceCompleted(object sender, UtteranceEventArgs e) { } + private static void _tts_StateChanged(object sender, StateChangedEventArgs e) { } @@ -77,6 +78,10 @@ namespace Tizen.Uix.Tts.Tests { } + private static void TestSynthesizedPcm(object sender, SynthesizedPcmEventArgs e) + { + } + [Test] [Category("P1")] [Description("Check working of Tts Constructor API for no exception")] @@ -206,6 +211,88 @@ namespace Tizen.Uix.Tts.Tests [Test] [Category("P1")] + [Description("Check working of Tts PlayingMode Property for no exception")] + [Property("SPEC", "Tizen.Uix.Tts.TtsClient.PlayingMode A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PRE")] + [Property("AUTHOR", "Suyeon Hwang, stom.hwang@samsung.com")] + public void PlayingMode_ENUM_ALL() + { + try + { + /* + * TEST CODE + */ + TtsHelper.PrintLog(Type.DLogAndlogUtil, "Executing TC:PlayingMode_ENUM_ALL"); + obj.TtsInst.PlayingMode = PlayingMode.ByClient; + Assert.AreEqual(PlayingMode.ByClient, obj.TtsInst.PlayingMode); + obj.TtsInst.PlayingMode = PlayingMode.ByService; + Assert.AreEqual(PlayingMode.ByService, obj.TtsInst.PlayingMode); + TtsHelper.PrintLog(Type.DLogAndlogUtil, "Completed TC:PlayingMode_ENUM_ALL"); + } + catch (Exception e) + { + TtsHelper.PrintLog(Type.DLogAndlogUtil, "Caught Exception :" + e.ToString()); + if (e is NotSupportedException) { + Assert.IsFalse(_featureSupported, "Invalid NotSupportedException"); + } else { + Assert.IsTrue(false, "Caught Exception" + e.ToString()); + } + } + } + + [Test] + [Category("P2")] + [Description("Check working of Tts PlayingMode Property with invalid state")] + [Property("SPEC", "Tizen.Uix.Tts.TtsClient.PlayingMode A")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "PEX")] + [Property("AUTHOR", "Suyeon Hwang, stom.hwang@samsung.com")] + public async Task PlayingMode_INVALID_OPERATION() + { + try + { + /* + * PRECONDITION + * 1. Prepare + */ + obj.TtsInst.CurrentMode = Tts.Mode.Default; + obj.DoPrepare(); + await obj.WaitFlag(15); + + /* + * TEST CODE + */ + TtsHelper.PrintLog(Type.DLogAndlogUtil, "Executing TC:PlayingMode_INVALID_OPERATION"); + Assert.Throws(() => obj.TtsInst.PlayingMode = PlayingMode.ByClient); + TtsHelper.PrintLog(Type.DLogAndlogUtil, "Completed TC:PlayingMode_INVALID_OPERATION"); + } + catch (Exception e) + { + TtsHelper.PrintLog(Type.DLogAndlogUtil, "Caught Exception :" + e.ToString()); + if (e is NotSupportedException) { + Assert.IsFalse(_featureSupported, "Invalid NotSupportedException"); + } else { + Assert.IsTrue(false, "Caught Exception" + e.ToString()); + } + } + finally + { + /* + * POSTCONDITION + * 1. Unprepare + */ + if (_featureSupported) + { + obj.DoUnprepare(); + await obj.WaitFlag(30); + obj.Unregister(); + } + } + } + + [Test] + [Category("P1")] [Description("Check working of Tts CurrentState Property")] [Property("SPEC", "Tizen.Uix.Tts.TtsClient.CurrentState A")] [Property("SPEC_URL", "-")] @@ -688,6 +775,36 @@ namespace Tizen.Uix.Tts.Tests [Test] [Category("P1")] + [Description("Adding Tts SynthesizedPcm Event and check for no exception")] + [Property("SPEC", "Tizen.Uix.Tts.TtsClient.SynthesizedPcm E")] + [Property("SPEC_URL", "-")] + [Property("CRITERIA", "EVL")] + [Property("AUTHOR", "Suyeon, stom.hwang@samsung.com")] + public void SynthesizedPcm_ADD_EVENT() + { + try + { + /* + * TEST CODE + */ + TtsHelper.PrintLog(Type.DLogAndlogUtil, "Executing TC:SynthesizedPcm_ADD_EVENT"); + obj.TtsInst.SynthesizedPcm += TestSynthesizedPcm; + TtsHelper.PrintLog(Type.DLogAndlogUtil, "Completed TC:SynthesizedPcm_ADD_EVENT"); + obj.TtsInst.SynthesizedPcm -= TestSynthesizedPcm; + } + catch (Exception e) + { + TtsHelper.PrintLog(Type.DLogAndlogUtil, "Caught Exception :" + e.ToString()); + if (e is NotSupportedException) { + Assert.IsFalse(_featureSupported, "Invalid NotSupportedException"); + } else { + Assert.IsTrue(false, "Caught Exception" + e.ToString()); + } + } + } + + [Test] + [Category("P1")] [Description("Check working of Tts Prepare Method for no exception")] [Property("SPEC", "Tizen.Uix.Tts.TtsClient.Prepare M")] [Property("SPEC_URL", "-")] -- 2.7.4