From: junkyu han Date: Tue, 18 Apr 2017 08:01:33 +0000 (+0900) Subject: Modified 'create_layout' function test X-Git-Tag: submit/tizen/20170425.085126~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d414e6b72d9a54c9f515cbc857bb2fdfe73a75f8;p=apps%2Fnative%2Fboot-animation.git Modified 'create_layout' function test Change-Id: Iadd1a5ed4768a6516f55d96d9c87d0e947908a4f --- diff --git a/inc/animation.h b/inc/animation.h index e57356c..92035cf 100644 --- a/inc/animation.h +++ b/inc/animation.h @@ -15,5 +15,11 @@ * */ -extern int init_animation(int state); -extern int fini_animation(void); +#include + +int init_animation(int state); +int fini_animation(void); +Evas_Object *create_layout(Evas_Object *win, const char *file_name); +Evas_Object *create_window(void); +char *get_layout_file_name(int state, int w, int h); +Eina_Bool is_layout_file_exist(const char *file_name); diff --git a/inc/boot.h b/inc/boot.h index 262409c..a80500d 100644 --- a/inc/boot.h +++ b/inc/boot.h @@ -22,8 +22,7 @@ #define FILE_PATH PREFIX"/share/edje/" #define DEFAULT_ON PREFIX"/share/edje/720x1280_PowerOn.edj" #define DEFAULT_OFF PREFIX"/share/edje/720x1280_PowerOff.edj" -#define GRP_OFF "poweroff" -#define GRP_ON "poweron" +#define GRP_ANIM "animation" #ifdef ARM_TYPE #define DEFAULT_POWERON_WAV PREFIX"/share/keysound/poweron.ogg" diff --git a/res/edje/360x360/360x360_PowerOff.edc b/res/edje/360x360/360x360_PowerOff.edc index 4dec54c..6769f56 100644 --- a/res/edje/360x360/360x360_PowerOff.edc +++ b/res/edje/360x360/360x360_PowerOff.edc @@ -20,7 +20,7 @@ images { } collections { - group { name: "poweroff"; + group { name: "animation"; parts { part { name: "bg"; diff --git a/res/edje/360x360/360x360_PowerOn.edc b/res/edje/360x360/360x360_PowerOn.edc index 5c52a01..ce1d994 100644 --- a/res/edje/360x360/360x360_PowerOn.edc +++ b/res/edje/360x360/360x360_PowerOn.edc @@ -21,7 +21,7 @@ images { collections { group { - name: "poweron"; + name: "animation"; parts { part { diff --git a/res/edje/360x480/360x480_PowerOff.edc b/res/edje/360x480/360x480_PowerOff.edc index 144be0a..0c33009 100644 --- a/res/edje/360x480/360x480_PowerOff.edc +++ b/res/edje/360x480/360x480_PowerOff.edc @@ -20,7 +20,7 @@ images { } collections { - group { name: "poweroff"; + group { name: "animation"; parts { part { name: "bg"; diff --git a/res/edje/360x480/360x480_PowerOn.edc b/res/edje/360x480/360x480_PowerOn.edc index ad8fc1d..cc9ad65 100644 --- a/res/edje/360x480/360x480_PowerOn.edc +++ b/res/edje/360x480/360x480_PowerOn.edc @@ -21,7 +21,7 @@ images { collections { group { - name: "poweron"; + name: "animation"; parts { part { diff --git a/res/edje/480x800/480x800_PowerOff.edc b/res/edje/480x800/480x800_PowerOff.edc index e583678..488ee37 100644 --- a/res/edje/480x800/480x800_PowerOff.edc +++ b/res/edje/480x800/480x800_PowerOff.edc @@ -20,7 +20,7 @@ images { } collections { - group { name: "poweroff"; + group { name: "animation"; parts { part { name: "bg"; diff --git a/res/edje/480x800/480x800_PowerOn.edc b/res/edje/480x800/480x800_PowerOn.edc index 4c3361c..9870e9e 100644 --- a/res/edje/480x800/480x800_PowerOn.edc +++ b/res/edje/480x800/480x800_PowerOn.edc @@ -21,7 +21,7 @@ images { collections { group { - name: "poweron"; + name: "animation"; parts { part { diff --git a/res/edje/720x1280/720x1280_PowerOff.edc b/res/edje/720x1280/720x1280_PowerOff.edc index 12becb9..92f3a42 100755 --- a/res/edje/720x1280/720x1280_PowerOff.edc +++ b/res/edje/720x1280/720x1280_PowerOff.edc @@ -21,7 +21,7 @@ images { } collections { - group { name: "poweroff"; + group { name: "animation"; parts { part { name: "poweroff"; diff --git a/res/edje/720x1280/720x1280_PowerOn.edc b/res/edje/720x1280/720x1280_PowerOn.edc index 8c101f0..508436b 100755 --- a/res/edje/720x1280/720x1280_PowerOn.edc +++ b/res/edje/720x1280/720x1280_PowerOn.edc @@ -22,7 +22,7 @@ images { collections { group { - name: "poweron"; + name: "animation"; parts { part { diff --git a/src/animation.c b/src/animation.c index d91b8e4..261474f 100644 --- a/src/animation.c +++ b/src/animation.c @@ -28,7 +28,6 @@ #include #include -#include #include #include "boot.h" @@ -94,23 +93,6 @@ static void __animation_finished_cb(void *d, Evas_Object * obj, const char *e, c } } -static Eina_Bool __layout_file_set(Evas_Object *layout, const char *file_name, int state) -{ - if (state == TYPE_OFF) { - if (!elm_layout_file_set(layout, file_name, GRP_OFF)) { - return EINA_FALSE; - } - } else { - if (!elm_layout_file_set(layout, file_name, GRP_ON)) { - return EINA_FALSE; - } - } - - evas_object_show(layout); - - return EINA_TRUE; -} - static void __fini_layout(void) { if (s_animation.layout) { @@ -123,7 +105,7 @@ static void __fini_layout(void) } } -static Evas_Object *__create_window(void) +Evas_Object *create_window(void) { _D("Create Window"); printf("Create Window\n"); @@ -150,15 +132,15 @@ static Evas_Object *__create_window(void) return win; } -static char *__get_layout_file_name(int state, int w, int h) +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); + snprintf(file_name, sizeof(file_name), FILE_PATH"%dx%d_PowerOff.edj", w, h); } else { - snprintf(file_name, sizeof(file_name), FILE_PATH"%dx%d_PowerOn.edj", s_animation.w, s_animation.h); + snprintf(file_name, sizeof(file_name), FILE_PATH"%dx%d_PowerOn.edj", w, h); } _D("File name for Animation is: %s", file_name); @@ -182,7 +164,7 @@ static char *__get_layout_file_name(int state, int w, int h) return strdup(file_name); } -Eina_Bool __is_layout_file_exist(const char *file_name) +Eina_Bool is_layout_file_exist(const char *file_name) { int ret = 0; @@ -193,7 +175,8 @@ Eina_Bool __is_layout_file_exist(const char *file_name) return EINA_FALSE; } } -static Evas_Object *__create_layout(Evas_Object *win) + +Evas_Object *create_layout(Evas_Object *win, const char *file_name) { Evas_Object *layout = elm_layout_add(win); if (!layout) { @@ -204,6 +187,13 @@ static Evas_Object *__create_layout(Evas_Object *win) elm_win_resize_object_add(s_animation.win, layout); elm_layout_signal_callback_add(layout, "end", "animation", __animation_finished_cb, NULL); + if (!elm_layout_file_set(layout, file_name, GRP_ANIM)) { + _E("Failed to layout file set"); + return NULL; + } + + evas_object_show(layout); + return layout; } @@ -214,36 +204,31 @@ int init_animation(int state) s_animation.state = state; - s_animation.win = __create_window(); + s_animation.win = create_window(); if (!s_animation.win) { _E("Failed to create a new window"); printf("Failed to create a new window\n"); return EXIT_FAILURE; } - s_animation.layout = __create_layout(s_animation.win); - if (!s_animation.layout) { - _E("Failed to create layout"); - 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); + 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)) { + 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"); + s_animation.layout = create_layout(s_animation.win, layout_file_name); + if (!s_animation.layout) { + _E("Failed to create layout"); free(layout_file_name); + evas_object_del(s_animation.win); return EXIT_FAILURE; } @@ -261,30 +246,3 @@ 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/test/feature_test/feature_test.c b/test/feature_test/feature_test.c index 77b173f..3151114 100755 --- a/test/feature_test/feature_test.c +++ b/test/feature_test/feature_test.c @@ -5,11 +5,11 @@ #include -#define TEST_GROUP_COUNT 0 - static void __complete_group_cb(void); static void __run_next_group(void); +#define TEST_GROUP_COUNT 1 + static struct { int current_group; char group_name[TEST_GROUP_COUNT + 1][128]; @@ -17,9 +17,11 @@ static struct { } s_info = { .current_group = 0, .group_name = { + "group_feature_on_animation", "" }, .group_starter_pool = { + group_feature_on_animation, NULL, }, }; @@ -34,6 +36,7 @@ static void __complete_group_cb(void) static void __run_next_group(void) { if (s_info.group_starter_pool[s_info.current_group] == NULL) { + elm_exit(); return ; } diff --git a/test/feature_test/feature_test.h b/test/feature_test/feature_test.h index bd373c2..9d1a6cb 100755 --- a/test/feature_test/feature_test.h +++ b/test/feature_test/feature_test.h @@ -9,6 +9,7 @@ #include void feature_test(void); +void group_feature_on_animation(unit_group_t * group); #endif diff --git a/test/feature_test/group_feature_on_animation.c b/test/feature_test/group_feature_on_animation.c new file mode 100755 index 0000000..60f19e8 --- /dev/null +++ b/test/feature_test/group_feature_on_animation.c @@ -0,0 +1,90 @@ +#include "test.h" +#if TEST_MODE + +#include "feature_test.h" +#include "boot.h" +#include "animation.h" + +#include +#include + +static void __case_start_on_animation(bool * is_passed); +static void __case_check_animation(bool * is_passed); +static void __case_check_finish_animation(bool * is_passed); + +#define CASE_COUNT 10 + +static struct { + Ecore_Timer * group_timer; + unit_group_t * group; + int current_case; + void(*case_pool[CASE_COUNT + 1])(bool * is_passed); +} s_info = { + .group_timer = NULL, + .group = NULL, + .current_case = 0, + .case_pool = { + __case_start_on_animation, + __case_check_animation, + __case_check_finish_animation, + NULL, + }, +}; + +static Eina_Bool __group_timer_callback(void * data); + +static void __set_up(void) {} +static void __tear_down(void) {} + +static void __case_start_on_animation(bool * is_passed) +{ + int is_finished = -1; + vconf_set_int(VCONFKEY_BOOT_ANIMATION_FINISHED, 0); + + vconf_get_int(VCONFKEY_BOOT_ANIMATION_FINISHED, &is_finished); + TEST_ASSERT_TRUE(is_finished == 0); + + //init_animation(TYPE_ON); + + *is_passed = true; +} + +static void __case_check_animation(bool * is_passed) +{ + *is_passed = true; +} + +static void __case_check_finish_animation(bool * is_passed) +{ + *is_passed = true; +} + +static Eina_Bool __group_timer_callback(void * data) +{ + if (s_info.case_pool[s_info.current_case] == NULL) { + s_info.group->finish(s_info.group); + + s_info.group_timer = NULL; + return ECORE_CALLBACK_CANCEL; + } + + TEST_CASE(s_info.group, s_info.case_pool[s_info.current_case]); + s_info.current_case += 1; + + return ECORE_CALLBACK_RENEW; +} + +void group_feature_on_animation(unit_group_t * group) +{ + if (s_info.group_timer) { + ecore_timer_del(s_info.group_timer); + s_info.group_timer = NULL; + } + + s_info.current_case = 0; + s_info.group = group; + s_info.group_timer = ecore_timer_add(0.5, __group_timer_callback, NULL); +} + +#endif + diff --git a/test/function_test/group_function_animation.c b/test/function_test/group_function_animation.c index bfd6f17..6cf17ba 100755 --- a/test/function_test/group_function_animation.c +++ b/test/function_test/group_function_animation.c @@ -2,6 +2,8 @@ #if TEST_MODE #include "function_test.h" +#include "animation.h" + #include #define LAYOUT "/usr/share/edje/720x1280_PowerOn.edj" @@ -9,11 +11,7 @@ #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 void __case_get_layout_file_name(bool * is_passed); static struct { Evas_Object *win; @@ -25,7 +23,7 @@ static struct { static void __set_up(void) { - s_info.win = __t_create_window(); + s_info.win = create_window(); } static void __tear_down(void) { @@ -54,12 +52,115 @@ static void __case_create_layout(bool * is_passed) { TEST_ASSERT_TRUE(s_info.win != NULL); - Evas_Object *layout = __t_create_layout(s_info.win); + char *file_name = "/usr/share/edje/720x1280_PowerOn.edj"; + + Evas_Object *layout = create_layout(s_info.win, file_name); + TEST_ASSERT_TRUE(layout != NULL); + TEST_ASSERT_TRUE(evas_object_visible_get(layout)); + evas_object_del(layout); + + file_name = "/usr/share/edje/720x1280_PowerOff.edj"; + layout = create_layout(s_info.win, file_name); + TEST_ASSERT_TRUE(layout != NULL); + TEST_ASSERT_TRUE(evas_object_visible_get(layout)); + evas_object_del(layout); + + file_name = "/usr/share/edje/360x360_PowerOn.edj"; + layout = create_layout(s_info.win, file_name); + TEST_ASSERT_TRUE(layout != NULL); + TEST_ASSERT_TRUE(evas_object_visible_get(layout)); + evas_object_del(layout); + + file_name = "/usr/share/edje/360x360_PowerOff.edj"; + layout = create_layout(s_info.win, file_name); 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)); + evas_object_del(layout); + + file_name = "/usr/share/edje/480x800_PowerOff.edj"; + layout = create_layout(s_info.win, file_name); + TEST_ASSERT_TRUE(layout != NULL); + TEST_ASSERT_TRUE(evas_object_visible_get(layout)); + evas_object_del(layout); + + file_name = "/usr/share/edje/480x800_PowerOn.edj"; + layout = create_layout(s_info.win, file_name); + TEST_ASSERT_TRUE(layout != NULL); + TEST_ASSERT_TRUE(evas_object_visible_get(layout)); + evas_object_del(layout); + + file_name = "/usr/share/720x1280_PowerOn.edj"; + layout = create_layout(s_info.win, file_name); + TEST_ASSERT_TRUE(layout == NULL); + evas_object_del(layout); + + file_name = "/usr/share/edje/2x2_PowerOn.edj"; + layout = create_layout(s_info.win, file_name); + TEST_ASSERT_TRUE(layout == NULL); + evas_object_del(layout); + + *is_passed = true; +} + +static void __case_get_layout_file_name(bool * is_passed) +{ + char * file_name = get_layout_file_name(0, 720, 1280); + TEST_ASSERT_EQUAL_STRING("/usr/share/edje/720x1280_PowerOn.edj", file_name); + free(file_name); + + file_name = get_layout_file_name(3, 720, 1280); + TEST_ASSERT_EQUAL_STRING("/usr/share/edje/720x1280_PowerOn.edj", file_name); + free(file_name); + + file_name = get_layout_file_name(2, 1280, 720); + TEST_ASSERT_EQUAL_STRING("/usr/share/edje/720x1280_PowerOff.edj", file_name); + free(file_name); + + file_name = get_layout_file_name(1, 360, 360); + TEST_ASSERT_EQUAL_STRING("/usr/share/edje/360x360_PowerOn.edj", file_name); + free(file_name); + + file_name = get_layout_file_name(2, 360, 360); + TEST_ASSERT_EQUAL_STRING("/usr/share/edje/360x360_PowerOff.edj", file_name); + free(file_name); + + file_name = get_layout_file_name(1, 480, 800); + TEST_ASSERT_EQUAL_STRING("/usr/share/edje/480x800_PowerOn.edj", file_name); + free(file_name); + + file_name = get_layout_file_name(2, 480, 800); + TEST_ASSERT_EQUAL_STRING("/usr/share/edje/480x800_PowerOff.edj", file_name); + free(file_name); + + file_name = get_layout_file_name(3, 480, 800); + TEST_ASSERT_EQUAL_STRING("/usr/share/edje/480x800_PowerOn.edj", file_name); + free(file_name); + + *is_passed = true; +} + +static void __case_is_layout_file_exist(bool * is_passed) +{ + char *file_name = "/usr/share/edje/480x800_PowerOn.edj"; + TEST_ASSERT_TRUE(is_layout_file_exist(file_name)); + + file_name = "/usr/share/edje/360x360_PowerOff.edj"; + TEST_ASSERT_TRUE(is_layout_file_exist(file_name)); + + file_name = "/usr/share/edje/720x1280_PowerOff.edj"; + TEST_ASSERT_TRUE(is_layout_file_exist(file_name)); + + file_name = "/usr/share/edje/720x1280_PowerOn.edj"; + TEST_ASSERT_TRUE(is_layout_file_exist(file_name)); + + file_name = "/usr/share/edje/1280x720_PowerOn.edj"; + TEST_ASSERT_TRUE(is_layout_file_exist(file_name) == EINA_FALSE); + + file_name = "/usr/share/edje/800x_480_PowerOn.edj"; + TEST_ASSERT_TRUE(is_layout_file_exist(file_name) == EINA_FALSE); + + file_name = "/usr/share/720x1280_PowerOn.edj"; + TEST_ASSERT_TRUE(is_layout_file_exist(file_name) == EINA_FALSE); *is_passed = true; } @@ -67,6 +168,8 @@ static void __case_create_layout(bool * is_passed) void group_function_create_window(unit_group_t * group) { TEST_CASE(group, __case_create_win); + TEST_CASE(group, __case_get_layout_file_name); + TEST_CASE(group, __case_is_layout_file_exist); TEST_CASE(group, __case_create_layout); group->finish(group); diff --git a/test/test_main.c b/test/test_main.c index bdd1457..cd8e541 100755 --- a/test/test_main.c +++ b/test/test_main.c @@ -17,6 +17,8 @@ static struct { static Eina_Bool __run_timer_callback(void * data) { + feature_test(); + s_info.feature_test_run_timer = NULL; return ECORE_CALLBACK_CANCEL; } @@ -29,7 +31,14 @@ int main(int argc, char *argv[]) function_test(); - init_animation(1); + Evas_Object * win = create_window(); + + if (s_info.feature_test_run_timer) { + ecore_timer_del(s_info.feature_test_run_timer); + s_info.feature_test_run_timer = NULL; + } + + s_info.feature_test_run_timer = ecore_timer_add(1, __run_timer_callback, NULL); elm_run();