[ITC][tts][ACR-1685][Add new API (ttse_terminate(), tts_prepare_sync())] 05/272105/4
authormanu.tiwari <manu.tiwari@samsung.com>
Wed, 9 Mar 2022 06:10:36 +0000 (11:40 +0530)
committershobhit verma <shobhit.v@samsung.com>
Wed, 9 Mar 2022 08:35:21 +0000 (08:35 +0000)
Change-Id: Icd5bb02ab4b6147446061cb72e3771b6b61d2085
Signed-off-by: manu.tiwari <manu.tiwari@samsung.com>
src/itc/tts/ITs-tts-common.h
src/itc/tts/ITs-tts.c
src/itc/tts/ITs-ttse.c
src/itc/tts/tct-tts-native_mobile.h
src/itc/tts/tct-tts-native_tizeniot.h
src/itc/tts/tct-tts-native_tv.h
src/itc/tts/tct-tts-native_wearable.h

index e1e1612be2c09f5fa5965b932db271b709e4b138..f5ed125e6e2972dde8000e99e73b05e5f838d21b 100755 (executable)
@@ -33,6 +33,7 @@
 #define TIMEOUT_CB                                     5000
 #define INPUT_TEXT                                     "1 2 3 4 5 6 7 8 9"
 #define SLEEP_TIME                                     5
+#define CONSTANT                    10
 #define TIMEOUT                                                20000
 #define API_NAMESPACE                          "TTS_ITC"
 #define SPEECH_SYNTHESIS_FEATURE       "http://tizen.org/feature/speech.synthesis"
index 3d2ccfdcb92bc4a72fd506cfd07367f0e62f6216..0cd6638b811f68e8fb1105dda89f3a637dcbc43c 100755 (executable)
 static bool g_CallBackValue = true;
 bool g_CallBackHit = false;
 
+static bool TtsIsStateChanged(tts_state_e state, int sleep_time)
+{
+       int max_count = sleep_time * CONSTANT;
+       int count = 0;
+       while (max_count > count && state != g_eCurrent_state) {
+               ecore_main_loop_iterate();
+               usleep(TIMEOUT);
+               count++;
+       }
+
+       if (state != g_eCurrent_state) {
+               return false;
+       }
+
+       return true;
+}
+
 /**
 * @function            ITs_tts_startup
 * @description         Called before each test, created tts handle
@@ -457,7 +474,7 @@ int ITc_tts_get_state_p(void)
 
 //& purpose: Prepare and unprepare the tts.
 //& type: auto
-/**
+/*
 * @testcase                            ITc_tts_prepare_unprepare_p
 * @since_tizen                                 2.3
 * @author                                      SRID(anshul1.jain)
@@ -523,7 +540,78 @@ int ITc_tts_prepare_unprepare_p(void)
        TtsUnSetStateChangedCallBacks();
        return 0;
 }
+//& purpose: Connects the daemon synchronously.
+//& type: auto
+/*
+* @testcase                            ITc_tts_prepare_sync_p
+* @since_tizen                                 7.0
+* @author                                      SRID(manu.tiwari)
+* @reviewer                    SRID(shobhit.v)
+* @type                                        auto
+* @description                         Connects the daemon synchronously.
+* @scenario                                    Prepares tts\n
+*                                                      Destroy tts
+* @apicovered                          tts_prepare_sync, tts_unprepare
+* @passcase                                    If tts_prepare_sync pass
+* @failcase                            If tts_prepare_sync failes
+* @precondition                                The tts state should be TTS_STATE_CREATED by tts_create(), tts_create() or tts_unprepare().
+* @postcondition                       The tts state will be TTS_STATE_READY. If tts handle is created by tts_create_videotts(), camera state will be changed to CAMERA_STATE_PREVIEW.
+*/
+int ITc_tts_prepare_sync_p(void)
+{
+       START_TEST;
+
+       if ( TtsSetStateChangedCallBacks(TtsStateChangedCallback) == 1 )
+       {
+               return 1;
+       }
+
+       //Target API
+       int nRet = tts_prepare_sync(g_pstTts);
+       PRINT_RESULT_CLEANUP(TTS_ERROR_NONE, nRet, "tts_prepare_sync", TtsGetError(nRet),TtsUnSetStateChangedCallBacks());
+
+       if ( TtsIsStateChanged(TTS_STATE_READY, SLEEP_TIME) == false ){
+               FPRINTF("[Line : %d][%s] TtsIsStateChanged failed \\n", __LINE__, API_NAMESPACE);
+               tts_unprepare(g_pstTts);
+               TtsUnSetStateChangedCallBacks();
+       }
+
+       if ( !g_bTtsStateChangedCallback )
+       {
+               FPRINTF("[Line : %d][%s] tts_set_state_changed_cb failed, error returned = callback not invoked\\n \\n", __LINE__, API_NAMESPACE);
+               tts_unprepare(g_pstTts);
+               TtsUnSetStateChangedCallBacks();
+               return 1;
+       }
+       if(!g_CallBackValue)
+       {
+               FPRINTF("[Line : %d][%s] Callback input values are invalid \n", __LINE__, API_NAMESPACE);
+               tts_unprepare(g_pstTts);
+               TtsUnSetStateChangedCallBacks();
+               return 1;
+       }
+
+       g_bTtsStateChangedCallback = false;
+
+       nRet = tts_unprepare(g_pstTts);
+       PRINT_RESULT_CLEANUP(TTS_ERROR_NONE, nRet, "tts_unprepare", TtsGetError(nRet), TtsUnSetStateChangedCallBacks());
 
+       if ( !g_bTtsStateChangedCallback )
+       {
+               FPRINTF("[Line : %d][%s] tts_set_state_changed_cb failed, error returned = callback not invoked\\n \\n", __LINE__, API_NAMESPACE);
+               TtsUnSetStateChangedCallBacks();
+               return 1;
+       }
+       if(!g_CallBackValue)
+       {
+               FPRINTF("[Line : %d][%s] Callback input values are invalid \n", __LINE__, API_NAMESPACE);
+               TtsUnSetStateChangedCallBacks();
+               return 1;
+       }
+
+       TtsUnSetStateChangedCallBacks();
+       return 0;
+}
 //& type: auto
 //& purpose: To register a callback function for state change
 /**
index b52d60b884986d257c611f86c78a0384f42f2564..48f0552bfe93d3c4a25401d3eeabcb7dba185e94 100755 (executable)
@@ -198,6 +198,34 @@ int ITc_ttse_main_p(void)
 
        return 0;
 }
+//& purpose ttse terminate function
+//& type: auto
+/**
+* @testcase                            ITc_ttse_terminate_p
+* @since_tizen                 7.0
+* @author              SRID(manu.tiwari)
+* @reviewer            SRID(shobhit.v)
+* @type                                auto
+* @description                 ttse terminate function
+* @scenario                            call ttse_main then call ttse_terminate
+* @apicovered                  ttse_main, ttse_terminate
+* @passcase                            If ttse_terminate api gets pass
+* @failcase                            If ttse_terminate api gets fail
+* @precondition                        NA
+* @postcondition               NA
+*/
+int ITc_ttse_terminate_p(void)
+{
+       START_TEST_TTSE;
+
+       int nRet = ttse_main(g_argc, g_argv, &g_tts_engine_callback);
+       PRINT_RESULT(TTSE_ERROR_NONE, nRet, "ttse_main", TtseGetError(nRet));
+       //Target API
+       nRet = ttse_terminate();
+       PRINT_RESULT(TTSE_ERROR_NONE, nRet, "ttse_terminate", TtseGetError(nRet));
+
+       return 0;
+}
 /**
 * @testcase                            ITc_ttse_get_speed_range_p
 * @since_tizen                 3.0
index 388473eb81d361d3ecc355b4e3af1bd3f249bfad..cf9d370099c6e8e8a327ab54f0a00a2ea50f6563 100755 (executable)
@@ -49,6 +49,8 @@ extern int ITc_ttse_set_private_data_set_cb_p(void);
 extern int ITc_ttse_set_private_data_requested_cb_p(void);
 extern int ITc_tts_check_screen_reader_on_p(void);
 extern int ITc_tts_set_unset_screen_reader_changed_cb_p(void);
+extern int ITc_tts_prepare_sync_p(void);
+extern int ITc_ttse_terminate_p(void);
 
 testcase tc_array[] = {
        {"ITc_tts_create_destroy_p",ITc_tts_create_destroy_p,ITs_tts_startup,ITs_tts_cleanup},
@@ -76,6 +78,9 @@ testcase tc_array[] = {
        {"ITc_ttse_set_private_data_requested_cb_p",ITc_ttse_set_private_data_requested_cb_p,ITs_ttse_startup,ITs_ttse_cleanup},
        {"ITc_tts_check_screen_reader_on_p",ITc_tts_check_screen_reader_on_p,ITs_tts_startup,ITs_tts_cleanup},
        {"ITc_tts_set_unset_screen_reader_changed_cb_p",ITc_tts_set_unset_screen_reader_changed_cb_p,ITs_tts_startup,ITs_tts_cleanup},
+       {"ITc_tts_prepare_sync_p",ITc_tts_prepare_sync_p,ITs_tts_startup,ITs_tts_cleanup},
+       {"ITc_ttse_terminate_p",ITc_ttse_terminate_p,ITs_ttse_startup,ITs_ttse_cleanup},
+
        {NULL, NULL}
 };
 
index 5f63f6c8374e1a66bf7f4dae5ff95b6e72d0780b..4db48962ebfb2b8bcbbc379e95528db1a0052077 100755 (executable)
@@ -48,6 +48,8 @@ extern int ITc_ttse_set_private_data_set_cb_p(void);
 extern int ITc_ttse_set_private_data_requested_cb_p(void);
 extern int ITc_tts_check_screen_reader_on_p(void);
 extern int ITc_tts_set_unset_screen_reader_changed_cb_p(void);
+extern int ITc_tts_prepare_sync_p(void);
+extern int ITc_ttse_terminate_p(void);
 
 testcase tc_array[] = {
        {"ITc_tts_create_destroy_p",ITc_tts_create_destroy_p,ITs_tts_startup,ITs_tts_cleanup},
@@ -74,6 +76,8 @@ testcase tc_array[] = {
        {"ITc_ttse_set_private_data_requested_cb_p",ITc_ttse_set_private_data_requested_cb_p,ITs_ttse_startup,ITs_ttse_cleanup},
        {"ITc_tts_check_screen_reader_on_p",ITc_tts_check_screen_reader_on_p,ITs_tts_startup,ITs_tts_cleanup},
        {"ITc_tts_set_unset_screen_reader_changed_cb_p",ITc_tts_set_unset_screen_reader_changed_cb_p,ITs_tts_startup,ITs_tts_cleanup},
+       {"ITc_tts_prepare_sync_p",ITc_tts_prepare_sync_p,ITs_tts_startup,ITs_tts_cleanup},
+       {"ITc_ttse_terminate_p",ITc_ttse_terminate_p,ITs_ttse_startup,ITs_ttse_cleanup},
        {NULL, NULL}
 };
 
index c20813cc0bca701085544bffc506957c28ed41c2..a896bda693f5daf1a9f5d51a8ea7928792e13a1e 100755 (executable)
@@ -44,6 +44,7 @@ extern int ITc_tts_set_get_private_data_p(void);
 extern int ITc_tts_set_unset_engine_changed_cb_p(void);
 extern int ITc_tts_check_screen_reader_on_p(void);
 extern int ITc_tts_set_unset_screen_reader_changed_cb_p(void);
+extern int ITc_tts_prepare_sync_p(void);
 
 testcase tc_array[] = {
        {"ITc_tts_create_destroy_p",ITc_tts_create_destroy_p,ITs_tts_startup,ITs_tts_cleanup},
@@ -66,6 +67,7 @@ testcase tc_array[] = {
        {"ITc_tts_set_unset_engine_changed_cb_p",ITc_tts_set_unset_engine_changed_cb_p,ITs_tts_startup,ITs_tts_cleanup},
        {"ITc_tts_check_screen_reader_on_p",ITc_tts_check_screen_reader_on_p,ITs_tts_startup,ITs_tts_cleanup},
        {"ITc_tts_set_unset_screen_reader_changed_cb_p",ITc_tts_set_unset_screen_reader_changed_cb_p,ITs_tts_startup,ITs_tts_cleanup},
+       {"ITc_tts_prepare_sync_p",ITc_tts_prepare_sync_p,ITs_tts_startup,ITs_tts_cleanup},
        {NULL, NULL}
 };
 
index 388473eb81d361d3ecc355b4e3af1bd3f249bfad..4b1f5d2d6ea5598a18113a52f09f0248b2c86116 100755 (executable)
@@ -49,6 +49,8 @@ extern int ITc_ttse_set_private_data_set_cb_p(void);
 extern int ITc_ttse_set_private_data_requested_cb_p(void);
 extern int ITc_tts_check_screen_reader_on_p(void);
 extern int ITc_tts_set_unset_screen_reader_changed_cb_p(void);
+extern int ITc_tts_prepare_sync_p(void);
+extern int ITc_ttse_terminate_p(void);
 
 testcase tc_array[] = {
        {"ITc_tts_create_destroy_p",ITc_tts_create_destroy_p,ITs_tts_startup,ITs_tts_cleanup},
@@ -76,6 +78,8 @@ testcase tc_array[] = {
        {"ITc_ttse_set_private_data_requested_cb_p",ITc_ttse_set_private_data_requested_cb_p,ITs_ttse_startup,ITs_ttse_cleanup},
        {"ITc_tts_check_screen_reader_on_p",ITc_tts_check_screen_reader_on_p,ITs_tts_startup,ITs_tts_cleanup},
        {"ITc_tts_set_unset_screen_reader_changed_cb_p",ITc_tts_set_unset_screen_reader_changed_cb_p,ITs_tts_startup,ITs_tts_cleanup},
+       {"ITc_tts_prepare_sync_p",ITc_tts_prepare_sync_p,ITs_tts_startup,ITs_tts_cleanup},
+       {"ITc_ttse_terminate_p",ITc_ttse_terminate_p,ITs_ttse_startup,ITs_ttse_cleanup},
        {NULL, NULL}
 };