2 * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
4 * This program is licensed under the terms and conditions of the
5 * Apache License, version 2.0. The full text of the Apache License is at
6 * http://www.apache.org/licenses/LICENSE-2.0
10 * @brief test suite for App Resource Control API
23 #include "ico_syc_appresctl.h"
24 #include "ico_syc_common.h"
26 #include "tst_common.h"
28 /* ----------------------------------------------- */
30 /* ----------------------------------------------- */
31 static struct ico_syc_res_context *res_context = NULL;
33 /* ----------------------------------------------- */
34 /* Define of static function */
35 /* ----------------------------------------------- */
36 static void _check_res_info(const char *ev_name, ico_syc_res_info_t *info);
37 static void _check_input_region(const char *ev_name,
38 ico_syc_input_region_t *region);
39 static void _syc_callback(const ico_syc_ev_e event,
40 const void *detail, void *user_data);
41 static void tst_acquire_res(const ico_syc_res_window_t *window,
42 const ico_syc_res_sound_t *sound,
43 const ico_syc_res_input_t *input,
45 static void tst_release_res(void);
46 static void tst_set_input_region(const ico_syc_input_region_t *region, int attr);
47 static void tst_unset_input_region(const ico_syc_input_region_t *region);
48 static Eina_Bool ico_syc_appresctl_test(void *data);
50 /* ----------------------------------------------- */
52 /* ----------------------------------------------- */
54 _check_res_info(const char *ev_name, ico_syc_res_info_t *info)
56 ico_syc_res_window_t *window = NULL;
57 ico_syc_res_sound_t *sound = NULL;
58 ico_syc_res_input_t *input = NULL;
61 printf("--- %s\n", ev_name);
63 window = info->window;
67 ico_syc_res_window_t *w = window;
68 printf("\t(window ECU[%s].display[%s].layer[%s].layout[%s].area[%s], app[%s], role[%s], resId[%d]",
69 w->ECU, w->display, w->layer, w->layout, w->area,
70 w->dispatchApp, w->role, w->resourceId);
72 if ((0 != strcmp(w->ECU, TST_ECU)) ||
73 (0 != strcmp(w->display, TST_display)) ||
74 (0 != strcmp(w->layer, TST_layer)) ||
75 (0 != strcmp(w->layout, TST_layout)) ||
76 (0 != strcmp(w->area, TST_area)) ||
77 (0 != strcmp(w->dispatchApp, TST_dispatchApp)) ||
78 (0 != strcmp(w->role, TST_role)) ||
79 (w->resourceId != TST_resourceId)) {
84 printf("\t sound zone[%s], name[%s], id[%s], adjust[%d]\n",
85 sound->zone, sound->name, sound->id, sound->adjust);
86 if (strcmp(sound->zone, TST_ZONE_B) != 0
87 || strcmp(sound->name, TST_NAME_B) != 0
88 || strcmp(sound->id, TST_ID_B) != 0
89 || sound->adjust != TST_ADJUST) {
94 printf("\t input name[%s], event[%d])\n", input->name, input->event);
95 if (strcmp(input->name, TST_NAME_C) != 0
96 || input->event != TST_INPUT_EV) {
101 if (check_flag == 0) {
102 print_ok("callback (%s)", ev_name);
105 print_ng("callback (%s)", ev_name);
112 _check_input_region(const char *ev_name, ico_syc_input_region_t *region)
114 printf("--- %s\n", ev_name);
115 printf("\t(winname[%s], (x,y)[%d, %d], width[%d], height[%d], hot[%d,%d], "
116 "cursor[%d.%d-%d,%d], attr[%d])\n",
117 region->winname, region->pos_x, region->pos_y,
118 region->width, region->height, region->hotspot_x, region->hotspot_y,
119 region->cursor_x, region->cursor_y, region->cursor_width,
120 region->cursor_height, region->attr);
122 if ((strcmp(region->winname, TST_WIN_NAME) == 0)
123 && region->pos_x == TST_POS_X && region->pos_y == TST_POS_Y
124 && region->width == TST_REG_WIDTH && region->height == TST_REG_HEIGHT
125 && region->hotspot_x == TST_REG_HOT_X && region->hotspot_y == TST_REG_HOT_Y
126 && region->cursor_x == TST_REG_CUR_X && region->cursor_y == TST_REG_CUR_Y
127 && region->cursor_width == TST_REG_CUR_WIDTH
128 && region->cursor_height == TST_REG_CUR_HEIGHT
129 && region->attr == TST_REG_ATTR) {
130 print_ok("callback (%s)", ev_name);
133 print_ng("callback (%s)", ev_name);
140 _syc_callback(const ico_syc_ev_e event,
141 const void *detail, void *user_data)
144 case ICO_SYC_EV_RES_ACQUIRE:
145 _check_res_info("ICO_SYC_EV_RES_ACQUIRE", (ico_syc_res_info_t *)detail);
147 case ICO_SYC_EV_RES_DEPRIVE:
148 _check_res_info("ICO_SYC_EV_RES_DEPRIVE", (ico_syc_res_info_t *)detail);
150 case ICO_SYC_EV_RES_WAITING:
151 _check_res_info("ICO_SYC_EV_RES_WAITING", (ico_syc_res_info_t *)detail);
153 case ICO_SYC_EV_RES_REVERT:
154 _check_res_info("ICO_SYC_EV_RES_REVERT", (ico_syc_res_info_t *)detail);
156 case ICO_SYC_EV_RES_RELEASE:
157 _check_res_info("ICO_SYC_EV_RES_RELEASE", (ico_syc_res_info_t *)detail);
159 case ICO_SYC_EV_INPUT_SET:
160 _check_input_region("ICO_SYC_EV_INPUT_SET",
161 (ico_syc_input_region_t *)detail);
163 case ICO_SYC_EV_INPUT_UNSET:
164 _check_input_region("ICO_SYC_EV_INPUT_UNSET",
165 (ico_syc_input_region_t *)detail);
174 /* test acquire resource */
176 tst_acquire_res(const ico_syc_res_window_t *window,
177 const ico_syc_res_sound_t *sound,
178 const ico_syc_res_input_t *input,
181 char *func = "ico_syc_acquire_res";
183 res_context = ico_syc_acquire_res(window, sound, input, type);
184 if (res_context == NULL) {
185 print_ng("%s (context is NULL)", func);
188 print_ok("%s", func);
193 /* test release resource */
195 tst_release_res(void)
198 char *func = "ico_syc_release_res";
200 ret = ico_syc_release_res(res_context);
202 print_ng("%s (ret: %d)", func, ret);
205 print_ok("%s", func);
210 /* test set input region */
212 tst_set_input_region(const ico_syc_input_region_t *region, int attr)
215 char *func = "ico_syc_set_input_region";
217 ret = ico_syc_set_input_region(region, attr);
219 print_ng("%s (ret: %d)", func, ret);
222 print_ok("%s", func);
227 /* test unset input region */
229 tst_unset_input_region(const ico_syc_input_region_t *region)
232 char *func = "ico_syc_unset_input_region";
234 ret = ico_syc_unset_input_region(region);
236 print_ng("%s (ret: %d)", func, ret);
239 print_ok("%s", func);
244 /* ------------------------ */
246 /* ------------------------ */
248 Eina_Bool ico_syc_appresctl_test(void *data)
251 printf("##### ico_syc_appresctl API Test Start #####\n");
253 /* window/sound resource */
254 ico_syc_res_window_t window;
255 ico_syc_res_sound_t sound;
256 int type = ICO_SYC_RES_BASIC;
258 ico_syc_res_input_t input;
260 ico_syc_input_region_t region;
263 /* set window resource info */
264 window.ECU = "Center";
265 window.display = "Center";
266 window.layer = "OnScreen";
267 window.layout = "Full";
268 window.area = "Full";
269 window.dispatchApp = "zzzzzzzz";
270 window.role = "Message";
271 window.resourceId = 8888;
272 /* set sound resource info */
274 sound.name = "sound B";
276 sound.adjust = ICO_SYC_SOUND_MUTE;
277 /* set sound resource info */
278 input.name = "input C";
280 /* set input region info */
281 strcpy(region.winname, TST_WIN_NAME);
286 region.hotspot_x = 28;
287 region.hotspot_y = 16;
288 region.cursor_x = 35;
289 region.cursor_y = 25;
290 region.cursor_width = 150;
291 region.cursor_height= 80;
292 region.attr = 98765432;
294 /* acquire window/sound/input */
295 tst_acquire_res((const ico_syc_res_window_t *)&window,
296 (const ico_syc_res_sound_t *)&sound,
297 (const ico_syc_res_input_t *)&input,
300 /* set input region */
301 tst_set_input_region(®ion, attr);
305 /* release window/sound/input */
308 /* unset input region */
309 tst_unset_input_region(®ion);
313 printf("##### ico_syc_appresctl API Test End #####\n");
317 return ECORE_CALLBACK_CANCEL;
320 /* ------------------------ */
321 /* quit test callback */
322 /* ------------------------ */
324 quit_test(void *data)
326 ico_syc_disconnect();
327 ecore_main_loop_quit();
329 return ECORE_CALLBACK_CANCEL;
332 /* ----------------------------------------------- */
334 /* ----------------------------------------------- */
337 main(int argc, char **argv)
341 ico_syc_connect(_syc_callback, NULL);
343 ecore_timer_add(1, ico_syc_appresctl_test, NULL);
344 ecore_timer_add(5, quit_test, NULL);
346 ecore_main_loop_begin();
351 /* vim: set expandtab ts=4 sw=4: */