Initialize Tizen 2.3
[framework/telephony/libslp-tapi.git] / wearable / TC / testcase / utc_sat.c
1 /*
2  * libslp-tapi
3  *
4  * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Shaik Alimulla <alimulla.s@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20
21 #include <tet_api.h>
22 #include <stdlib.h>
23
24 #include <tapi_common.h>
25 #include <ITapiSat.h>
26 #include <TapiUtility.h>
27
28 #include "util_common.h"
29
30 TapiHandle *handle;
31 enum async_state async_flag;
32 TelSatSetupMenuInfo_t main_menu;
33
34 /**
35  * tel_get_sat_main_menu_info
36  * Synchronous call
37  *
38  */
39
40 static void utc_tel_get_sat_main_menu_info (void)
41 {
42         int ret;
43
44         ret = tel_get_sat_main_menu_info (handle, &main_menu);
45         if (ret != TAPI_API_SUCCESS) {
46                 dts_fail("tel_get_sat_main_menu_info", "Unexpected return");
47         }
48
49         dts_pass("tel_get_sat_main_menu_info");
50 }
51
52 static void utc_fail_tel_get_sat_main_menu_info (void)
53 {
54         int ret;
55
56         ret = tel_get_sat_main_menu_info (NULL, NULL);
57         if (ret == TAPI_API_SUCCESS) {
58                 dts_fail("tel_get_sat_main_menu_info", "Parameter check failed");
59         }
60
61         ret = tel_get_sat_main_menu_info (handle, NULL);
62         if (ret == TAPI_API_SUCCESS) {
63                 dts_fail("tel_get_sat_main_menu_info", "Parameter check failed");
64         }
65
66         dts_pass("tel_get_sat_main_menu_info");
67 }
68
69 /**
70  * tel_select_sat_menu
71  *
72  */
73 static void on_tel_select_sat_menu (TapiHandle *handle, int result,
74                 void *data, void *user_data)
75 {
76         int *value = user_data;
77
78         async_flag = ASYNC_DONE;
79         util_stop_loop ();
80
81         if (*value != 0xC0FFEE) {
82                 dts_fail("tel_select_sat_menu", "Callback userdata crashed");
83         }
84 }
85
86 static void utc_tel_select_sat_menu (void)
87 {
88         int ret;
89         int value = 0xC0FFEE;
90         TelSatMenuSelectionReqInfo_t selected_menu;
91
92         selected_menu.bIsHelpRequested = 0;
93         selected_menu.itemIdentifier = 0x01;
94
95         util_init_loop ();
96
97         async_flag = ASYNC_READY;
98         ret = tel_select_sat_menu (handle, &selected_menu,      on_tel_select_sat_menu, &value);
99         if (ret != TAPI_API_SUCCESS) {
100                 dts_fail("tel_select_sat_menu", "Unexpected return");
101         }
102
103         util_start_loop ();
104         util_free_loop ();
105
106         if (async_flag != ASYNC_DONE) {
107                 dts_fail("tel_select_sat_menu", "Callback not invoked");
108         }
109
110         dts_pass("tel_select_sat_menu");
111 }
112
113 static void utc_fail_tel_select_sat_menu (void)
114 {
115         int ret;
116
117         ret = tel_select_sat_menu (NULL, NULL, NULL, NULL);
118         if (ret == TAPI_API_SUCCESS) {
119                 dts_fail("tel_select_sat_menu", "Parameter check failed");
120         }
121
122         ret = tel_select_sat_menu (handle, NULL, NULL, NULL);
123         if (ret == TAPI_API_SUCCESS) {
124                 dts_fail("tel_select_sat_menu", "Parameter check failed");
125         }
126
127         dts_pass("tel_select_sat_menu");
128 }
129
130 /**
131  * tel_download_sat_event
132  *
133  */
134 static void on_tel_download_sat_event (TapiHandle *handle, int result,
135                 void *data, void *user_data)
136 {
137         int *value = user_data;
138
139         async_flag = ASYNC_DONE;
140         util_stop_loop ();
141
142         if (*value != 0xC0FFEE) {
143                 dts_fail("tel_download_sat_event", "Callback userdata crashed");
144         }
145 }
146
147 static void utc_tel_download_sat_event (void)
148 {
149         int ret;
150         int value = 0xC0FFEE;
151         TelSatEventDownloadReqInfo_t event_data;
152
153         event_data.eventDownloadType = TAPI_EVENT_SAT_DW_TYPE_CALL_CONNECTED;
154
155         util_init_loop ();
156
157         async_flag = ASYNC_READY;
158         ret = tel_download_sat_event (handle, &event_data, on_tel_download_sat_event, &value);
159         if (ret != TAPI_API_SUCCESS) {
160                 dts_fail("tel_download_sat_event", "Unexpected return");
161         }
162
163         util_start_loop ();
164         util_free_loop ();
165
166         if (async_flag != ASYNC_DONE) {
167                 dts_fail("tel_download_sat_event", "Callback not invoked");
168         }
169
170         dts_pass("tel_download_sat_event");
171 }
172
173 static void utc_fail_tel_download_sat_event (void)
174 {
175         int ret;
176
177         ret = tel_download_sat_event (NULL, NULL, NULL, NULL);
178         if (ret == TAPI_API_SUCCESS) {
179                 dts_fail("tel_download_sat_event", "Parameter check failed");
180         }
181
182         ret = tel_download_sat_event (handle, NULL, NULL, NULL);
183         if (ret == TAPI_API_SUCCESS) {
184                 dts_fail("tel_download_sat_event", "Parameter check failed");
185         }
186
187         dts_pass("tel_download_sat_event");
188 }
189
190 /**
191  * tel_send_sat_ui_display_status
192  *
193  */
194 static void utc_tel_send_sat_ui_display_status (void)
195 {
196         int ret;
197         TelSatUiDisplayStatusType_t status;
198
199         status = TAPI_SAT_DISPLAY_SUCCESS;
200
201         ret = tel_send_sat_ui_display_status (handle, 0, status);
202         if (ret != TAPI_API_SUCCESS) {
203                 dts_fail("tel_send_sat_ui_display_status", "Unexpected return");
204         }
205
206         dts_pass("tel_send_sat_ui_display_status");
207 }
208
209 static void utc_fail_tel_send_sat_ui_display_status (void)
210 {
211         int ret;
212
213         ret = tel_send_sat_ui_display_status (NULL, 0, 0);
214         if (ret == TAPI_API_SUCCESS) {
215                 dts_fail("tel_send_sat_ui_display_status", "Parameter check failed");
216         }
217
218         dts_pass("tel_send_sat_ui_display_status");
219 }
220
221 /**
222  * tel_send_sat_ui_user_confirm
223  *
224  */
225 static void utc_tel_send_sat_ui_user_confirm (void)
226 {
227         int ret;
228         TelSatUiUserConfirmInfo_t user_confirm_data;
229
230         user_confirm_data.commandId = 0;
231         user_confirm_data.commandType = TAPI_SAT_CMD_TYPE_DISPLAY_TEXT;
232         user_confirm_data.keyType = TAPI_SAT_USER_CONFIRM_YES;
233         user_confirm_data.dataLen = 0;
234         user_confirm_data.pAdditionalData = NULL;
235
236
237         ret = tel_send_sat_ui_user_confirm (handle, &user_confirm_data);
238         if (ret != TAPI_API_SUCCESS) {
239                 dts_fail("tel_send_sat_ui_user_confirm", "Unexpected return");
240         }
241
242         dts_pass("tel_send_sat_ui_user_confirm");
243 }
244
245 static void utc_fail_tel_send_sat_ui_user_confirm (void)
246 {
247         int ret;
248
249         ret = tel_send_sat_ui_user_confirm (NULL, NULL);
250         if (ret == TAPI_API_SUCCESS) {
251                 dts_fail("tel_send_sat_ui_user_confirm", "Parameter check failed");
252         }
253
254         ret = tel_send_sat_ui_user_confirm (handle, NULL );
255         if (ret == TAPI_API_SUCCESS) {
256                 dts_fail("tel_send_sat_ui_user_confirm", "Parameter check failed");
257         }
258
259         dts_pass("tel_send_sat_ui_user_confirm");
260 }
261
262 /**
263  * tel_send_sat_app_exec_result
264  *
265  */
266 static void utc_tel_send_sat_app_exec_result (void)
267 {
268         int ret;
269         TelSatAppsRetInfo_t app_ret_info;
270
271         app_ret_info.commandId = 0;
272         app_ret_info.commandType = TAPI_SAT_CMD_TYPE_DISPLAY_TEXT;
273         app_ret_info.appsRet.displayText.resp = TAPI_SAT_R_SUCCESS;
274         app_ret_info.appsRet.displayText.meProblem = TAPI_SAT_ME_PROBLEM_NO_SPECIFIC_CAUSE;
275
276         ret = tel_send_sat_app_exec_result (handle, &app_ret_info);
277         if (ret != TAPI_API_SUCCESS) {
278                 dts_fail("tel_send_sat_app_exec_result", "Unexpected return");
279         }
280
281         dts_pass("tel_send_sat_app_exec_result");
282 }
283
284 static void utc_fail_tel_send_sat_app_exec_result (void)
285 {
286         int ret;
287
288         ret = tel_send_sat_app_exec_result (NULL, NULL);
289         if (ret == TAPI_API_SUCCESS) {
290                 dts_fail("tel_send_sat_app_exec_result", "Parameter check failed");
291         }
292
293         ret = tel_send_sat_app_exec_result (handle, NULL );
294         if (ret == TAPI_API_SUCCESS) {
295                 dts_fail("tel_send_sat_app_exec_result", "Parameter check failed");
296         }
297
298         dts_pass("tel_send_sat_app_exec_result");
299 }
300
301 struct tet_testlist tet_testlist[] = {
302         /* generated TC */
303         { utc_tel_get_sat_main_menu_info, 1 },
304         { utc_fail_tel_get_sat_main_menu_info, 2 },
305         { utc_tel_select_sat_menu, 1 },
306         { utc_fail_tel_select_sat_menu, 2 },
307         { utc_tel_download_sat_event, 1 },
308         { utc_fail_tel_download_sat_event, 2 },
309         { utc_tel_send_sat_ui_display_status, 1 },
310         { utc_fail_tel_send_sat_ui_display_status, 2 },
311         { utc_tel_send_sat_ui_user_confirm, 1 },
312         { utc_fail_tel_send_sat_ui_user_confirm, 2 },
313         { utc_tel_send_sat_app_exec_result, 1 },
314         { utc_fail_tel_send_sat_app_exec_result, 2 },
315         { NULL, 0 },
316 };
317
318 static void startup (void)
319 {
320         /* start of TC */
321         tet_printf ("\n TC start");
322
323         handle = tel_init (NULL);
324 }
325
326 static void cleanup (void)
327 {
328         tel_deinit (handle);
329
330         /* end of TC */
331         tet_printf ("\n TC end");
332 }
333
334 void (*tet_startup) (void) = startup;
335 void (*tet_cleanup) (void) = cleanup;