internal bool ReadyStateFlag = false;
internal bool CreatedStateFlag = false;
internal bool TestFlag = false;
+ internal bool ServiceStateFlag = 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 Tts.Error TtsError;
internal bool TtsErrorFlag = false;
internal int UtteranceId = 0;
}
}
+ internal async Task WaitServiceStateFlag(int times)
+ {
+ int count = 0;
+ while (true)
+ {
+ count++;
+ if (ServiceStateFlag)
+ {
+ TtsHelper.PrintLog(Type.DLogAndlogUtil, "ServiceStateFlag is true at count " + count);
+ break;
+ }
+
+ if (count == times * 10)
+ {
+ TtsHelper.PrintLog(Type.DLogAndlogUtil, "count " + count + " expired");
+ break;
+ }
+
+ await Task.Delay(100);
+ }
+ }
+
internal void TtsStateChanged(object sender, StateChangedEventArgs e)
{
TtsHelper.PrintLog(Type.DLogAndlogUtil, "State Changed, Previous State:"+e.Previous+" Current State:"+e.Current);
}
}
+ internal void TtsServiceStateChanged(object sender, ServiceStateChangedEventArgs e)
+ {
+ TtsHelper.PrintLog(Type.DLogAndlogUtil, "Service State Changed, Previous State:"+e.Previous+" Current State:"+e.Current);
+ CurrentService = e.Current;
+ PreviousService = e.Previous;
+ ServiceStateFlag = true;
+ }
+
internal void TtsErrorOccurred(object sender, ErrorOccurredEventArgs e)
{
TtsHelper.PrintLog(Type.DLogAndlogUtil, "Error Occured:"+e.ErrorValue);
--- /dev/null
+using System;
+using System.Threading.Tasks;
+using NUnit.Framework;
+
+namespace Tizen.Uix.Tts.Tests
+{
+ [TestFixture]
+ [Description("Tizen.Uix.Tts.ServiceStateChangedEventArgs Tests")]
+ public class ServiceStateChangedEventArgsTests
+ {
+ TtsWrapper obj = null;
+ private static bool _featureSupported = false;
+ private static 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
+ {
+ if (obj == null)
+ obj = new TtsWrapper();
+
+ Assert.IsInstanceOf<Tizen.Uix.Tts.TtsClient>(obj.TtsInst, "Tts object is not of correct instance");
+ Assert.IsNotNull(obj.TtsInst);
+ }
+ 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()
+ {
+ TtsHelper.PrintLog(Type.DLogAndlogUtil, "Executing Destroy");
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Check working of ServiceStateChangedEventArgs Current Property for no exception")]
+ [Property("SPEC", "Tizen.Uix.Tts.ServiceStateChangedEventArgs.Current A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRO")]
+ [Property("AUTHOR", "Suyeon Hwang, stom.hwang@samsung.com")]
+ public async Task Current_READ_ONLY()
+ {
+ try
+ {
+ /*
+ * PRECONDITION
+ * 1. Prepare
+ */
+ obj.ReadyStateFlag = false;
+ obj.TestFlag = false;
+ obj.TtsInst.ServiceStateChanged += obj.TtsServiceStateChanged;
+ obj.TtsInst.StateChanged += obj.TtsStateChanged;
+ obj.TtsInst.Prepare();
+ await obj.WaitFlag(15);
+ obj.GetSupportedVoices();
+ Assert.True(obj.list.Count > 0, "Languages are not present");
+ 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:Current_READ_ONLY");
+ obj.TtsInst.Play();
+ obj.ServiceStateFlag = false;
+ await obj.WaitServiceStateFlag(10);
+ Assert.IsNotNull(obj.CurrentService, "Object is Null");
+ Assert.IsInstanceOf<Tts.ServiceState>(obj.CurrentService, "Object is not of correct type");
+ Assert.IsTrue(obj.CurrentService == ServiceState.Synthesizing, "CurrentService is not Synthesizing");
+ TtsHelper.PrintLog(Type.DLogAndlogUtil, "Completed TC:Current_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());
+ }
+ }
+ finally
+ {
+ /*
+ * POSTCONDITION
+ * 1. Unprepare
+ */
+ if (_featureSupported)
+ {
+ obj.TtsInst.Stop();
+ obj.TtsInst.Unprepare();
+ obj.TtsInst.ServiceStateChanged -= obj.TtsServiceStateChanged;
+ obj.TtsInst.StateChanged -= obj.TtsStateChanged;
+ }
+ }
+ }
+
+ [Test]
+ [Category("P1")]
+ [Description("Check working of ServiceStateChangedEventArgs Previous Property for no exception")]
+ [Property("SPEC", "Tizen.Uix.Tts.ServiceStateChangedEventArgs.Previous A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRO")]
+ [Property("AUTHOR", "Suyeon Hwang, stom.hwang@samsung.com")]
+ public async Task Previous_READ_ONLY()
+ {
+ try
+ {
+ /*
+ * PRECONDITION
+ * 1. Prepare
+ */
+ obj.ReadyStateFlag = false;
+ obj.TestFlag = false;
+ obj.TtsInst.ServiceStateChanged += obj.TtsServiceStateChanged;
+ obj.TtsInst.StateChanged += obj.TtsStateChanged;
+ obj.TtsInst.Prepare();
+ await obj.WaitFlag(15);
+ obj.GetSupportedVoices();
+ Assert.True(obj.list.Count > 0, "Languages are not present");
+ 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:Previous_READ_ONLY");
+ obj.TtsInst.Play();
+ obj.ServiceStateFlag = false;
+ await obj.WaitServiceStateFlag(10);
+ Assert.IsNotNull(obj.PreviousService, "Object is Null");
+ Assert.IsInstanceOf<Tts.ServiceState>(obj.PreviousService, "Object is not of correct type");
+ Assert.IsTrue(obj.PreviousService == ServiceState.Ready, "PreviousService is not Ready");
+ TtsHelper.PrintLog(Type.DLogAndlogUtil, "Completed TC:Previous_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());
+ }
+ }
+ finally
+ {
+ /*
+ * POSTCONDITION
+ * 1. Unprepare
+ */
+ if (_featureSupported)
+ {
+ obj.TtsInst.Stop();
+ obj.TtsInst.Unprepare();
+ obj.TtsInst.ServiceStateChanged -= obj.TtsServiceStateChanged;
+ obj.TtsInst.StateChanged -= obj.TtsStateChanged;
+ }
+ }
+ }
+ }
+}
{
}
+ private static void _tts_ServiceStateChanged(object sender, ServiceStateChangedEventArgs e)
+ {
+ }
+
[Test]
[Category("P1")]
[Description("Check working of Tts Constructor API for no exception")]
[Test]
[Category("P1")]
+ [Description("Check working of Tts CurrentServiceState Property")]
+ [Property("SPEC", "Tizen.Uix.Tts.TtsClient.CurrentServiceState A")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "PRE")]
+ [Property("AUTHOR", "Suyeon Hwang, stom.hwang@samsung.com")]
+ public async Task CurrentServiceState_GET_ENUM_ALL()
+ {
+ try
+ {
+ /*
+ * TEST CODE
+ */
+ obj.TtsInst = new Tts.TtsClient();
+ obj.TtsInst.ServiceStateChanged += obj.TtsServiceStateChanged;
+ obj.TtsInst.UtteranceStarted += obj.TtsUtteranceStarted;
+ obj.DoPrepare();
+ await obj.WaitFlag(30);
+ Assert.IsTrue(obj.TtsInst.CurrentServiceState == ServiceState.Ready, "ServiceState is not Ready");
+ obj.GetSupportedVoices();
+ Assert.True(obj.list.Count > 0, "Languages are not present");
+ obj.TtsInst.AddText("Hi how are you doing. What is the current date today. What is the current month. What is the current year", obj.list[0].Language, 0, 0);
+
+ TtsHelper.PrintLog(Type.DLogAndlogUtil, "Executing TC:CurrentServiceState_GET_ENUM_ALL");
+ obj.TtsInst.Play();
+ obj.ServiceStateFlag = false;
+ await obj.WaitServiceStateFlag(10);
+ Assert.IsTrue(obj.TtsInst.CurrentServiceState == ServiceState.Synthesizing, "ServiceState is not Synthesizing");
+ obj.ServiceStateFlag = false;
+ await obj.WaitServiceStateFlag(10);
+ Assert.IsTrue(obj.TtsInst.CurrentServiceState == ServiceState.Playing, "ServiceState is not Playing");
+ TtsHelper.PrintLog(Type.DLogAndlogUtil, "Completed TC:CurrentServiceState_GET_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());
+ }
+ }
+ finally
+ {
+ /*
+ * POSTCONDITION
+ * 1. Unprepare
+ */
+ if (_featureSupported)
+ {
+ obj.TtsInst.Stop();
+ obj.DoUnprepare();
+ obj.Unregister();
+ }
+ }
+ }
+
+ [Test]
+ [Category("P1")]
[Description("Check working of Tts GetSupportedVoices Method for no exception")]
[Property("SPEC", "Tizen.Uix.Tts.TtsClient.GetSupportedVoices M")]
[Property("SPEC_URL", "-")]
[Test]
[Category("P1")]
+ [Description("Adding Tts ServiceStateChanged Event and check for no exception")]
+ [Property("SPEC", "Tizen.Uix.Tts.TtsClient.ServiceStateChanged E")]
+ [Property("SPEC_URL", "-")]
+ [Property("CRITERIA", "EVL")]
+ [Property("AUTHOR", "Suyeon, stom.hwang@samsung.com")]
+ public void ServiceStateChanged_ADD_EVENT()
+ {
+ try
+ {
+ /*
+ * TEST CODE
+ */
+ TtsHelper.PrintLog(Type.DLogAndlogUtil, "Executing TC:ServiceStateChanged_ADD_EVENT");
+ obj.TtsInst.ServiceStateChanged += _tts_ServiceStateChanged;
+ TtsHelper.PrintLog(Type.DLogAndlogUtil, "Completed TC:ServiceStateChanged_ADD_EVENT");
+ obj.TtsInst.ServiceStateChanged -= _tts_ServiceStateChanged;
+ }
+ 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", "-")]