Merge "Fix descriptions according to checking header tools" into tizen
[platform/core/uifw/tts.git] / tests / src / test_util.h
1 /*
2  * Copyright (c) 2023 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17
18 #ifndef __TTS_TEST_UTIL_H__
19 #define __TTS_TEST_UTIL_H__
20
21
22 #include <tts.h>
23 #include <tts_internal.h>
24
25
26 class TtsTestUtility {
27 public:
28         static void StateChangedCallback(tts_h tts, tts_state_e previous, tts_state_e current, void *user_data);
29         static void ServiceStateChangedCallback(tts_h tts, tts_service_state_e previous, tts_service_state_e current, void* user_data);
30         static void ScreenReaderChangedCallback(tts_h tts, bool is_on, void* user_data);
31         static void UtteranceStartedCallback(tts_h tts, int utt_id, void* user_data);
32         static void UtteranceCompletedCallback(tts_h tts, int utt_id, void *user_data);
33         static void ErrorCallback(tts_h tts, int utt_id, tts_error_e reason, void* user_data);
34
35         static void TerminateCurrentEngine();
36         static void WaitUntilEngineTerminated(int duration);
37         static bool IsFeatureSupported();
38
39 public:
40         TtsTestUtility();
41         ~TtsTestUtility();
42
43         void GetTestPCMData();
44
45         void CreateHandle();
46         void DestroyHandle();
47
48         bool Prepare();
49         bool Unprepare();
50
51         bool Play();
52         bool Pause();
53         bool Stop();
54
55         bool IsStateChanged(tts_state_e targetState, int duration);
56         bool IsServiceStateChanged(tts_service_state_e targetState, int duration);
57         bool IsScreenReaderOn(int duration);
58         bool IsUtteranceStarted(int duration);
59         bool IsUtteranceCompleted(int duration);
60         bool IsErrorOccurring(int duration);
61
62 public:
63         tts_h mHandle;
64         tts_state_e mCurrentState;
65         tts_service_state_e mCurrentServiceState;
66
67         char *mLanguage;
68         int mVoiceType;
69         bool mScreenReaderOn;
70         bool mUtteranceStarted;
71         bool mUtteranceCompleted;
72         bool mErrorOccurred;
73         int mUttId;
74
75         char* mPCMData;
76         size_t mPCMSize;
77
78 private:
79         static bool WaitCondition(std::function<bool(void)> checker, int duration);
80 };
81
82
83 #endif  /* __TTS_TEST_UTIL_H__ */