From: junkyu han Date: Fri, 14 Apr 2017 10:31:10 +0000 (+0900) Subject: Add group function_test X-Git-Tag: accepted/tizen/unified/20170426.195557~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F82%2F125282%2F4;p=apps%2Fnative%2Fboot-animation.git Add group function_test Change-Id: I6cc407810ef88c46af8cf0fff9ac2667468e7ec1 --- diff --git a/inc/animation.h b/inc/animation.h index 799c2d7..e57356c 100644 --- a/inc/animation.h +++ b/inc/animation.h @@ -15,5 +15,5 @@ * */ -extern int init_animation(int state, const char *msg); +extern int init_animation(int state); extern int fini_animation(void); diff --git a/packaging/shutdown-animation.service b/packaging/shutdown-animation.service index f463609..9f6a1bc 100644 --- a/packaging/shutdown-animation.service +++ b/packaging/shutdown-animation.service @@ -12,4 +12,4 @@ EnvironmentFile=/run/xdg-root-env Type=oneshot SmackProcessLabel=System -ExecStart=/usr/bin/boot-animation --offmsg " " --clear +ExecStart=/usr/bin/boot-animation --off diff --git a/src/animation.c b/src/animation.c index 9c18bba..d91b8e4 100644 --- a/src/animation.c +++ b/src/animation.c @@ -60,15 +60,9 @@ static Eina_Bool __end_cb(void *data) { int type = (int) data; - if (type == TYPE_ON) { - _D("EXIT on BOOTING"); - if (vconf_set_int(VCONFKEY_BOOT_ANIMATION_FINISHED, 1) != 0) { - _E("Failed to set finished set"); - } - elm_exit(); - } else { - /* Delete Previous Layout */ + if (type == TYPE_OFF) { _D("EXIT on SHUTDOWN"); + /* Delete Previous Layout */ if (s_animation.layout) evas_object_del(s_animation.layout); Evas_Object *disp_block = NULL; @@ -76,35 +70,23 @@ static Eina_Bool __end_cb(void *data) elm_win_resize_object_add(s_animation.win, disp_block); evas_object_color_set(disp_block, 0, 0, 0, 255); evas_object_show(disp_block); + } else { + _D("EXIT on BOOTING"); + if (vconf_set_int(VCONFKEY_BOOT_ANIMATION_FINISHED, 1) != 0) { + _E("Failed to set finished set"); + } + elm_exit(); } return ECORE_CALLBACK_CANCEL; } -static void __set_poweroff_message(void) -{ - Evas_Coord w; - Evas_Coord h; - - evas_object_size_hint_weight_set(s_animation.txt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_fill_set(s_animation.txt, EVAS_HINT_FILL, EVAS_HINT_FILL); - evas_object_resize(s_animation.txt, s_animation.w, s_animation.h); - evas_object_color_set(s_animation.txt, 255, 255, 255, 255); - evas_object_text_font_set(s_animation.txt, "SLP:style=medium", 30); - evas_object_geometry_get(s_animation.txt, NULL, NULL, &w, &h); - evas_object_move(s_animation.txt, (s_animation.w - w) >> 1, (s_animation.h - h) >> 1); - evas_object_show(s_animation.txt); -} - -static void __edje_cb(void *d, Evas_Object * obj, const char *e, const char *s) +static void __animation_finished_cb(void *d, Evas_Object * obj, const char *e, const char *s) { - if (s_animation.state == TYPE_OFF || s_animation.state == TYPE_OFF_WITH_MSG) { + if (s_animation.state == TYPE_OFF) { _D("TYPE OFF"); if (vconf_set_int(VCONFKEY_BOOT_ANIMATION_FINISHED, 1) != 0) { _E("Failed to set finished set"); } - if (s_animation.txt) { - __set_poweroff_message(); - } ecore_timer_add(1, __end_cb, (void *)TYPE_OFF); } else { _D("TYPE_ON"); @@ -112,73 +94,21 @@ static void __edje_cb(void *d, Evas_Object * obj, const char *e, const char *s) } } -static Eina_Bool __layout_file_set(Evas_Object *layout, int state) +static Eina_Bool __layout_file_set(Evas_Object *layout, const char *file_name, int state) { - char file_name[1024]; - char *on_off; - int ret; - - if (state == TYPE_ON) { - snprintf(file_name, sizeof(file_name), FILE_PATH"%dx%d_PowerOn.edj", s_animation.w, s_animation.h); - on_off = GRP_ON; - } else { - snprintf(file_name, sizeof(file_name), FILE_PATH"%dx%d_PowerOff.edj", s_animation.w, s_animation.h); - on_off = GRP_OFF; - } - _D("File name for Animation is: %s", file_name); - - ret = access(file_name, 0); - if (ret == 0) { - _D("This Resolution[%d]x[%d] is supported !!", s_animation.w, s_animation.h); - if (!elm_layout_file_set(layout, file_name, on_off)) return EINA_FALSE; + if (state == TYPE_OFF) { + if (!elm_layout_file_set(layout, file_name, GRP_OFF)) { + return EINA_FALSE; + } } else { - _E("This Resolution[%d]x[%d] is STRANGE !!, Set default image '720x1280'", s_animation.w, s_animation.h); - if (state == TYPE_ON) { - if (!elm_layout_file_set(layout, DEFAULT_ON, on_off)) return EINA_FALSE; - } else { - if (!elm_layout_file_set(layout, DEFAULT_OFF, on_off)) return EINA_FALSE; + if (!elm_layout_file_set(layout, file_name, GRP_ON)) { + return EINA_FALSE; } } - return EINA_TRUE; -} - -static Evas_Object *__create_layout(const char *msg) -{ - Eina_Bool ret; - Evas_Object *layout = elm_layout_add(s_animation.win); - if (!layout) { - _E("Failed to create layout"); - return NULL; - } - - ret = __layout_file_set(layout, s_animation.state); - if (ret != EINA_TRUE) { - _E("Failed to set layout file"); - evas_object_del(layout); - return NULL; - } - - evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - elm_win_resize_object_add(s_animation.win, layout); - edje_object_signal_callback_add(elm_layout_edje_get(layout), "end", "animation", __edje_cb, NULL); evas_object_show(layout); - if (msg) { - if (!s_animation.txt) { - s_animation.txt = evas_object_text_add(evas_object_evas_get(s_animation.win)); - if (!s_animation.txt) { - _E("Failed to add text"); - evas_object_del(layout); - return NULL; - } - } - - evas_object_text_text_set(s_animation.txt, msg); - evas_object_hide(s_animation.txt); - } - - return layout; + return EINA_TRUE; } static void __fini_layout(void) @@ -198,27 +128,21 @@ static Evas_Object *__create_window(void) _D("Create Window"); printf("Create Window\n"); - int x, y = 0; Evas_Object *win; win = elm_win_add(NULL, "BOOT_ANIMATION", ELM_WIN_NOTIFICATION); - elm_win_aux_hint_add(win, "wm.comp.win.always.selective.mode", "1"); - - elm_win_role_set(win, "alert"); if (!win) { _E("Failed to create a new window"); printf("Failed to create a new window\n"); return NULL; } - if (s_animation.state == TYPE_OFF || s_animation.state == TYPE_OFF_WITH_MSG) { - _D("We are turning off the Tizen"); - } + elm_win_aux_hint_add(win, "wm.comp.win.always.selective.mode", "1"); + elm_win_role_set(win, "alert"); efl_util_set_notification_window_level(win, EFL_UTIL_NOTIFICATION_LEVEL_HIGH); evas_object_smart_callback_add(win, "delete-request", win_del, NULL); - elm_win_screen_size_get(win, &x, &y, &s_animation.w, &s_animation.h); - _D("Window size is x: %d, y: %d, w: %d, h: %d", x, y, s_animation.w, s_animation.h); - elm_win_borderless_set(win, 1); + elm_win_screen_size_get(win, NULL, NULL, &s_animation.w, &s_animation.h); + elm_win_borderless_set(win, EINA_TRUE); elm_win_indicator_mode_set(win, ELM_WIN_INDICATOR_HIDE); evas_object_move(win, 0, 0); evas_object_show(win); @@ -226,7 +150,64 @@ static Evas_Object *__create_window(void) return win; } -int init_animation(int state, const char *msg) +static char *__get_layout_file_name(int state, int w, int h) +{ + char file_name[1024]; + int ret = 0; + + if (state == TYPE_OFF) { + snprintf(file_name, sizeof(file_name), FILE_PATH"%dx%d_PowerOff.edj", s_animation.w, s_animation.h); + } else { + snprintf(file_name, sizeof(file_name), FILE_PATH"%dx%d_PowerOn.edj", s_animation.w, s_animation.h); + } + _D("File name for Animation is: %s", file_name); + + ret = access(file_name, 0); + if (ret == 0) { + } else { + _W("There's no Image same with [%s], So set Default[720x1280] image", file_name); + if (state == TYPE_OFF) { + snprintf(file_name, sizeof(file_name), "%s", DEFAULT_OFF); + } else { + snprintf(file_name, sizeof(file_name), "%s", DEFAULT_ON); + } + + ret = access(file_name, 0); + if (ret) { + _E("There's no Image file[%s] on target", file_name); + return NULL; + } + } + + return strdup(file_name); +} + +Eina_Bool __is_layout_file_exist(const char *file_name) +{ + int ret = 0; + + ret = access(file_name, 0); + if (ret == 0) { + return EINA_TRUE; + } else { + return EINA_FALSE; + } +} +static Evas_Object *__create_layout(Evas_Object *win) +{ + Evas_Object *layout = elm_layout_add(win); + if (!layout) { + _E("Failed to create layout"); + return NULL; + } + evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_win_resize_object_add(s_animation.win, layout); + elm_layout_signal_callback_add(layout, "end", "animation", __animation_finished_cb, NULL); + + return layout; +} + +int init_animation(int state) { _D("Init animation"); printf("Init animation\n"); @@ -240,16 +221,34 @@ int init_animation(int state, const char *msg) return EXIT_FAILURE; } - s_animation.layout = __create_layout(msg); + s_animation.layout = __create_layout(s_animation.win); if (!s_animation.layout) { _E("Failed to create layout"); - if (s_animation.txt) { - evas_object_del(s_animation.txt); - } evas_object_del(s_animation.win); return EXIT_FAILURE; } + char *layout_file_name = NULL; + layout_file_name = __get_layout_file_name(state, s_animation.w, s_animation.h); + if (!layout_file_name) { + _E("Failed to get layout file name"); + return EXIT_FAILURE; + } + + if (!__is_layout_file_exist(layout_file_name)) { + _E("This file is not exist"); + free(layout_file_name); + return EXIT_FAILURE; + } + + if (!__layout_file_set(s_animation.layout, layout_file_name, state)) { + _E("Failed to set layaout file"); + free(layout_file_name); + return EXIT_FAILURE; + } + + free(layout_file_name); + return EXIT_SUCCESS; } @@ -262,9 +261,30 @@ int fini_animation(void) return EXIT_SUCCESS; } +#include "test.h" #if TEST_MODE Evas_Object *__t_create_window(void) { return __create_window(); } + +Evas_Object *__t_create_layout(Evas_Object *win) +{ + return __create_layout(win); +} + +char *__t_get_layout_file_name(int state, int w, int h) +{ + return __get_layout_file_name(state, w, h); +} + +Eina_Bool __t_layout_file_set(Evas_Object *layout, const char *layout_file_name, int state) +{ + return __layout_file_set(layout, layout_file_name, state); +} + +Eina_Bool __t_is_layout_file_exist(const char *file_name) +{ + return __is_layout_file_exist(file_name); +} #endif diff --git a/src/boot.c b/src/boot.c index 35285f1..cc1f2bc 100644 --- a/src/boot.c +++ b/src/boot.c @@ -51,7 +51,6 @@ extern int optind, opterr, optopt; struct args { int argc; char **argv; - char *msg; }; //#define SOUND_PROFILE @@ -65,9 +64,7 @@ static void print_usages(char *argv0) " Ex:" " # %s --start\n" " # %s --stop\n" - " # %s --off\n" - " # %s --offmsg YOUR_MESSAGE\n", argv0, argv0, argv0, argv0, - argv0); + " # %s --off\n", argv0, argv0, argv0, argv0); } @@ -95,9 +92,8 @@ static int __prepare_animation(keynode_t * node, void *user_data) struct args *args = user_data; static struct option long_options[] = { {"start", no_argument, 0, 's' }, - {"stop", no_argument, 0, 'p' }, {"off", no_argument, 0, 'o' }, - {"offmsg", required_argument, 0, 'm' }, + {"stop", no_argument, 0, 'p' }, {"clear", no_argument, 0, 'c' }, {0, 0, 0, 0 }, }; @@ -127,21 +123,19 @@ static int __prepare_animation(keynode_t * node, void *user_data) switch (c) { case 's': type = TYPE_ON; + _D("type: s"); continue; case 'p': - type = TYPE_OFF; - continue; - case 'o': + _D("type: p"); type = TYPE_OFF_NOEXIT; continue; - case 'm': - if (args->msg) continue; - type = TYPE_OFF_WITH_MSG; - args->msg = strdup(optarg); - if (!args->msg) - perror("strdup"); + case 'o': + _D("type: o"); + type = TYPE_OFF; continue; case 'c': + _D("type: c"); + type = TYPE_OFF_NOEXIT; continue; default: type = TYPE_UNKNOWN; @@ -165,7 +159,7 @@ static int __prepare_animation(keynode_t * node, void *user_data) printf("Sound status: %d\n", soundon); #endif - if (init_animation(type, args->msg) != EXIT_SUCCESS) { + if (init_animation(type) != EXIT_SUCCESS) { _D("Exit boot-animation"); printf("Exit boot-animation\n"); return EXIT_FAILURE; @@ -231,7 +225,6 @@ int main(int argc, char *argv[]) args.argc = argc; args.argv = argv; - args.msg = NULL; #if 0 _boot_ani_ui_set_scale(); @@ -257,17 +250,6 @@ int main(int argc, char *argv[]) fini_animation(); - if (args.msg) - free(args.msg); return 0; } #endif - -#include "test.h" -#if TEST_MODE -int __t__prepare_animation(keynode_t * node, void *user_data) -{ - return __prepare_animation(node, user_data); -} -#endif - diff --git a/test/function_test/group_function_animation.c b/test/function_test/group_function_animation.c new file mode 100755 index 0000000..bfd6f17 --- /dev/null +++ b/test/function_test/group_function_animation.c @@ -0,0 +1,75 @@ +#include "test.h" +#if TEST_MODE + +#include "function_test.h" +#include + +#define LAYOUT "/usr/share/edje/720x1280_PowerOn.edj" +#define LAYOUT_W 720 +#define LAYOUT_H 1280 +#define STATE 1 + +extern Evas_Object *__t_create_window(void); +extern Evas_Object *__t_create_layout(Evas_Object *win); +extern char *__t_get_layout_file_name(int state, int w, int h); +extern Eina_Bool __t_is_layout_file_exist(const char *file_name); +extern Eina_Bool __t_layout_file_set(Evas_Object *layout, const char *file_name, int state); + +static struct { + Evas_Object *win; + Evas_Object *layout; +} s_info = { + .win = NULL, + .layout = NULL, +}; + +static void __set_up(void) +{ + s_info.win = __t_create_window(); +} +static void __tear_down(void) +{ + if (s_info.layout) evas_object_del(s_info.layout); + if (s_info.win) evas_object_del(s_info.win); + + s_info.layout = NULL; + s_info.win = NULL; +} + +static void __case_create_win(bool * is_passed) +{ + TEST_ASSERT_TRUE(s_info.win != NULL); + + int w, h; + elm_win_screen_size_get(s_info.win, NULL, NULL, &w, &h); + TEST_ASSERT_EQUAL_STRING(elm_win_role_get(s_info.win), "alert"); + TEST_ASSERT_TRUE(elm_win_borderless_get(s_info.win) == EINA_TRUE); + TEST_ASSERT_EQUAL_INT(elm_win_indicator_mode_get(s_info.win), ELM_WIN_INDICATOR_HIDE); + TEST_ASSERT_TRUE(evas_object_visible_get(s_info.win)); + + *is_passed = true; +} + +static void __case_create_layout(bool * is_passed) +{ + TEST_ASSERT_TRUE(s_info.win != NULL); + + Evas_Object *layout = __t_create_layout(s_info.win); + TEST_ASSERT_TRUE(layout != NULL); + TEST_ASSERT_EQUAL_STRING(__t_get_layout_file_name(STATE, LAYOUT_W, LAYOUT_H), LAYOUT); + TEST_ASSERT_TRUE(__t_is_layout_file_exist(LAYOUT)); + TEST_ASSERT_TRUE(__t_layout_file_set(layout, LAYOUT, STATE)); + TEST_ASSERT_TRUE(evas_object_visible_get(layout)); + + *is_passed = true; +} + +void group_function_create_window(unit_group_t * group) +{ + TEST_CASE(group, __case_create_win); + TEST_CASE(group, __case_create_layout); + + group->finish(group); +} + +#endif diff --git a/test/function_test/group_function_app_evas.c b/test/function_test/group_function_app_evas.c deleted file mode 100755 index 84e8b43..0000000 --- a/test/function_test/group_function_app_evas.c +++ /dev/null @@ -1,24 +0,0 @@ -#include "test.h" -#if TEST_MODE - -#include "function_test.h" -#include - -static void __set_up(void){} -static void __tear_down(void){} - -static void __case_create_win(bool * is_passed) -{ - Evas_Object *win = __t_create_window(); - - *is_passed = true; -} - -void group_function_create_window(unit_group_t * group) -{ - TEST_CASE(group, __case_create_win); - - group->finish(group); -} - -#endif diff --git a/test/test_main.c b/test/test_main.c index 9868363..bdd1457 100755 --- a/test/test_main.c +++ b/test/test_main.c @@ -9,8 +9,6 @@ #include #include -extern int __t__prepare_animation(keynode_t * node, void *user_data); - static struct { Ecore_Timer * feature_test_run_timer; } s_info = { @@ -23,12 +21,6 @@ static Eina_Bool __run_timer_callback(void * data) return ECORE_CALLBACK_CANCEL; } -struct args { - int argc; - char **argv; - char *msg; -}; - int main(int argc, char *argv[]) { unit_init(); @@ -37,7 +29,7 @@ int main(int argc, char *argv[]) function_test(); - init_animation(1, NULL); + init_animation(1); elm_run(); diff --git a/tizen-manifest.xml b/tizen-manifest.xml index a810db4..3242615 100644 --- a/tizen-manifest.xml +++ b/tizen-manifest.xml @@ -1,7 +1,7 @@ - + - + boot-animation.png