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 Window Control API
23 #include "ico_syc_common.h"
24 #include "ico_syc_winctl.h"
26 #include "tst_common.h"
28 /* ----------------------------------------------- */
30 /* ----------------------------------------------- */
33 /* ----------------------------------------------- */
34 /* Define of static function */
35 /* ----------------------------------------------- */
36 static void _check_win_info(const char *ev_name, ico_syc_win_info_t *info);
37 static void _check_win_attr(const char *ev_name, ico_syc_win_attr_t *attr);
38 static void _check_thumb_info(const char *ev_name, ico_syc_thumb_info_t *info);
39 static void _check_layer_attr(const char *ev_name, ico_syc_layer_attr_t *attr);
41 static void _syc_callback(const ico_syc_ev_e event,
42 const void *detail, void *user_data);
44 static void tst_show(const char *appid, int surface,
45 ico_syc_animation_t *animation);
46 static void tst_hide(const char *appid, int surface,
47 ico_syc_animation_t *animation);
48 static void tst_move(const char *appid, int surface,
49 ico_syc_win_move_t *move,
50 ico_syc_animation_t *animation, const char *type);
51 static void tst_change_active(const char *appid, int surface);
52 static void tst_change_layer(const char *appid, int surface, int layer);
54 static void tst_map_thumb(int surface, int framerate);
55 static void tst_unmap_thumb(int surface);
57 static void tst_show_layer(int layer);
58 static void tst_hide_layer(int layer);
60 static Eina_Bool ico_syc_winctl_test(void *data);
62 /* ----------------------------------------------- */
64 /* ----------------------------------------------- */
66 _check_win_info(const char *ev_name, ico_syc_win_info_t *info)
68 printf("--- %s ", ev_name);
69 printf("(appid[%s], name[%s], surface[%d])\n",
70 info->appid, info->name, info->surface);
72 if (strcmp(info->appid, TST_APPID) == 0
73 && strcmp(info->name, TST_WIN_NAME) == 0
74 && info->surface == TST_SURFACE) {
75 print_ok("callback (%s)", ev_name);
78 print_ng("callback (%s)", ev_name);
85 _check_win_attr(const char *ev_name, ico_syc_win_attr_t *attr)
87 printf("--- %s\n", ev_name);
88 printf("\t(appid[%s], name[%s], surface[%d], node[%d], layer[%d],\n",
89 attr->appid, attr->name, attr->surface, attr->nodeid, attr->layer);
90 printf("\t (x,y)[%d, %d], width[%d], height[%d], ",
91 attr->pos_x, attr->pos_y, attr->width, attr->height);
92 printf("raise[%d], visible[%d], active[%d])\n",
93 attr->raise, attr->visible, attr->active);
96 if (strcmp(attr->name, "move") == 0) {
97 if ((attr->pos_x > 0) && (attr->pos_y > 0)) {
98 print_ok("callback (%s move (pos))", ev_name);
101 print_ok("callback (%s move (zone))", ev_name);
107 if (strcmp(attr->appid, TST_APPID) == 0
108 && attr->surface == TST_SURFACE && attr->nodeid == TST_NODE
109 && attr->layer == TST_LAYER && attr->pos_x == TST_POS_X
110 && attr->pos_y == TST_POS_Y && attr->width == TST_WIDTH
111 && attr->height == TST_HEIGHT && attr->raise == TST_RAISE
112 && attr->visible == TST_VISIBLE && attr->active == TST_ACTIVE) {
113 print_ok("callback (%s %s)", ev_name, attr->name);
116 print_ng("callback (%s %s)", ev_name, attr->name);
123 _check_thumb_info(const char *ev_name, ico_syc_thumb_info_t *info)
125 printf("--- %s ", ev_name);
126 printf("\t(appid[%s], surface[%d], width[%d], height[%d], ",
127 info->appid, info->surface, info->width, info->height);
128 printf("stride[%d], format[%d])\n",
129 info->stride, info->format);
131 if (strcmp(info->appid, TST_APPID) == 0
132 && info->surface == TST_SURFACE
133 && info->width == TST_WIDTH && info->height == TST_HEIGHT
134 && info->stride == TST_STRIDE && info->format == TST_FORMAT) {
135 print_ok("callback (%s)", ev_name);
138 print_ng("callback (%s)", ev_name);
145 _check_layer_attr(const char *ev_name, ico_syc_layer_attr_t *attr)
147 printf("--- %s ", ev_name);
148 printf("(layer[%d], visible[%d])\n",
149 attr->layer, attr->visible);
151 if (attr->layer == TST_LAYER && attr->visible == TST_VISIBLE) {
152 print_ok("callback (%s show)", ev_name);
154 else if (attr->layer == TST_LAYER && attr->visible == TST_INVISIBLE) {
155 print_ok("callback (%s hide)", ev_name);
158 print_ng("callback (%s)", ev_name);
165 _syc_callback(const ico_syc_ev_e event,
166 const void *detail, void *user_data)
170 case ICO_SYC_EV_WIN_CREATE:
171 _check_win_info("ICO_SYC_EV_WIN_CREATE", (ico_syc_win_info_t *)detail);
173 case ICO_SYC_EV_WIN_DESTROY:
174 _check_win_info("ICO_SYC_EV_WIN_DESTROY", (ico_syc_win_info_t *)detail);
176 case ICO_SYC_EV_WIN_ACTIVE:
177 _check_win_info("ICO_SYC_EV_WIN_ACTIVE", (ico_syc_win_info_t *)detail);
179 case ICO_SYC_EV_WIN_ATTR_CHANGE:
180 _check_win_attr("ICO_SYC_EV_WIN_ATTR_CHANGE",
181 (ico_syc_win_attr_t *)detail);
183 case ICO_SYC_EV_THUMB_ERROR:
184 _check_thumb_info("ICO_SYC_EV_THUMB_ERROR",
185 (ico_syc_thumb_info_t *)detail);
187 case ICO_SYC_EV_THUMB_CHANGE:
188 _check_thumb_info("ICO_SYC_EV_THUMB_CHANGE",
189 (ico_syc_thumb_info_t *)detail);
191 case ICO_SYC_EV_THUMB_UNMAP:
192 _check_thumb_info("ICO_SYC_EV_THUMB_UNMAP",
193 (ico_syc_thumb_info_t *)detail);
195 case ICO_SYC_EV_LAYER_ATTR_CHANGE:
196 _check_layer_attr("ICO_SYC_EV_LAYER_ATTR_CHANGE",
197 (ico_syc_layer_attr_t *)detail);
206 /* test show window */
208 tst_show(const char *appid, int surface, ico_syc_animation_t *animation)
211 char *func = "ico_syc_show";
213 ret = ico_syc_show(appid, surface, animation);
215 print_ng("%s (ret: %d)", func, ret);
218 print_ok("%s", func);
223 /* test hide window */
225 tst_hide(const char *appid, int surface, ico_syc_animation_t *animation)
228 char *func = "ico_syc_hide";
230 ret = ico_syc_hide(appid, surface, animation);
232 print_ng("%s (ret: %d)", func, ret);
235 print_ok("%s", func);
240 /* test move window */
242 tst_move(const char *appid, int surface,
243 ico_syc_win_move_t *move,
244 ico_syc_animation_t *animation, const char *type)
247 char *func = "ico_syc_move";
249 ret = ico_syc_move(appid, surface, move, animation);
251 print_ng("%s (%s) (ret: %d)", func, type, ret);
254 print_ok("%s (%s)", func, type);
259 /* test change active window */
261 tst_change_active(const char *appid, int surface)
264 char *func = "ico_syc_change_active";
266 ret = ico_syc_change_active(appid, surface);
268 print_ng("%s (ret: %d)", func, ret);
271 print_ok("%s", func);
276 /* test change window layer */
278 tst_change_layer(const char *appid, int surface, int layer)
281 char *func = "ico_syc_change_layer";
283 ret = ico_syc_change_layer(appid, surface, layer);
285 print_ng("%s (ret: %d)", func, ret);
288 print_ok("%s", func);
293 /* test map thumbnail */
295 tst_map_thumb(int surface, int framerate)
298 char *func = "ico_syc_map_thumb";
300 ret = ico_syc_map_thumb(surface, framerate, " ");
302 print_ng("%s (ret: %d)", func, ret);
305 print_ok("%s", func);
310 /* test unmap thumbnail */
312 tst_unmap_thumb(int surface)
315 char *func = "ico_syc_unmap_thumb";
317 ret = ico_syc_unmap_thumb(surface);
319 print_ng("%s (ret: %d)", func, ret);
322 print_ok("%s", func);
327 /* test show layer */
329 tst_show_layer(int layer)
332 char *func = "ico_syc_show_layer";
334 ret = ico_syc_show_layer(layer);
336 print_ng("%s (ret: %d)", func, ret);
339 print_ok("%s", func);
344 /* test hide layer */
346 tst_hide_layer(int layer)
349 char *func = "ico_syc_hide_layer";
351 ret = ico_syc_hide_layer(layer);
353 print_ng("%s (ret: %d)", func, ret);
356 print_ok("%s", func);
361 /* ------------------------------- */
363 /* ------------------------------- */
365 ico_syc_winctl_test(void *data)
367 const char *appid = "org.test.app.testapp";
370 ico_syc_win_move_t move, move_pos;
371 ico_syc_animation_t animation;
374 printf("##### ico_syc_winctl API Test Start #####\n");
376 /* set move info (zone) */
377 move.zone = "center:bottom";
378 move.width = ICO_SYC_WIN_NOCHANGE;
380 /* set move info (position) */
381 move_pos.zone = NULL;
384 move_pos.width = 1024;
385 move_pos.height = ICO_SYC_WIN_NOCHANGE;
387 /* set animation data */
388 animation.name = "fade";
389 animation.time = 200;
392 tst_show(appid, surface, &animation);
394 tst_hide(appid, surface, NULL);
396 tst_move(appid, surface, &move, &animation, "zone");
398 tst_move(appid, surface, &move_pos, NULL, "pos");
400 tst_change_active(appid, surface);
402 tst_change_layer(appid, surface, layer);
407 tst_map_thumb(surface, 200);
409 tst_unmap_thumb(surface);
414 tst_show_layer(layer);
416 tst_hide_layer(layer);
418 printf("##### ico_syc_winctl API Test End #####\n");
421 return ECORE_CALLBACK_CANCEL;
424 /* ------------------------ */
425 /* quit test callback */
426 /* ------------------------ */
428 quit_test(void *data)
430 ico_syc_disconnect();
431 ecore_main_loop_quit();
433 return ECORE_CALLBACK_CANCEL;
436 /* ----------------------------------------------- */
438 /* ----------------------------------------------- */
441 main(int argc, char **argv)
445 ico_syc_connect(_syc_callback, NULL);
447 ecore_timer_add(1, ico_syc_winctl_test, NULL);
448 ecore_timer_add(5, quit_test, NULL);
450 ecore_main_loop_begin();
455 /* vim: set expandtab ts=4 sw=4: */