From: junkyu han Date: Thu, 20 Apr 2017 08:25:25 +0000 (+0900) Subject: Add power off feature test X-Git-Tag: submit/tizen/20170425.085126~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F47%2F126147%2F3;p=apps%2Fnative%2Fboot-animation.git Add power off feature test Change-Id: Iab8a5e84ea1a2a4bd122da2ed881667edb1a827c --- diff --git a/src/animation.c b/src/animation.c index 31f21a1..6662a75 100644 --- a/src/animation.c +++ b/src/animation.c @@ -38,16 +38,23 @@ static struct animation { Evas_Object *win; + Evas_Object *layout; + Evas_Object *txt; + Evas_Object *display_block; Evas_Coord w; Evas_Coord h; - int t; - Evas *evas; - Ecore_Evas *ee; - Evas_Object *layout; int state; - Evas_Object *txt; + int t; } s_animation = { - .txt = NULL,}; + .win = NULL, + .layout = NULL, + .txt = NULL, + .display_block = NULL, + .w = 0, + .h = 0, + .state = 0, + .t = 0, +}; static void win_del(void *data, Evas_Object * obj, void *event_info) { @@ -55,6 +62,17 @@ static void win_del(void *data, Evas_Object * obj, void *event_info) elm_exit(); } +static void __block_display(void) +{ + Evas_Object *display_block = NULL; + display_block = evas_object_rectangle_add(evas_object_evas_get(s_animation.win)); + elm_win_resize_object_add(s_animation.win, display_block); + evas_object_color_set(display_block, 0, 0, 0, 255); + evas_object_show(display_block); + + s_animation.display_block = display_block; +} + static Eina_Bool __end_cb(void *data) { int type = (int) data; @@ -62,13 +80,12 @@ static Eina_Bool __end_cb(void *data) if (type == TYPE_OFF) { _D("EXIT on SHUTDOWN"); /* Delete Previous Layout */ - if (s_animation.layout) evas_object_del(s_animation.layout); + if (s_animation.layout) { + evas_object_del(s_animation.layout); + s_animation.layout = NULL; + } - Evas_Object *disp_block = NULL; - disp_block = evas_object_rectangle_add(evas_object_evas_get(s_animation.win)); - 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); + __block_display(); } else { _D("EXIT on BOOTING"); if (vconf_set_int(VCONFKEY_BOOT_ANIMATION_FINISHED, 1) != 0) { @@ -95,8 +112,14 @@ static void __animation_finished_cb(void *d, Evas_Object * obj, const char *e, c static void __fini_layout(void) { + if (s_animation.display_block) { + evas_object_del(s_animation.display_block); + s_animation.display_block = NULL; + } + if (s_animation.layout) { evas_object_del(s_animation.layout); + s_animation.layout = NULL; } if (s_animation.txt) { @@ -257,5 +280,10 @@ Evas_Object *__t__get_layout(void) { return s_animation.layout; } + +Evas_Object *__t__get_display_block(void) +{ + return s_animation.display_block; +} #endif diff --git a/test/feature_test/feature_test.c b/test/feature_test/feature_test.c index 3151114..a2ecbeb 100755 --- a/test/feature_test/feature_test.c +++ b/test/feature_test/feature_test.c @@ -8,20 +8,18 @@ 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]; - void(*group_starter_pool[TEST_GROUP_COUNT + 1])(unit_group_t * group); + char group_name[GROUP_COUNT_MAX + 1][128]; + void(*group_starter_pool[GROUP_COUNT_MAX + 1])(unit_group_t * group); } s_info = { .current_group = 0, .group_name = { - "group_feature_on_animation", + "group_feature_on_off_animation", "" }, .group_starter_pool = { - group_feature_on_animation, + group_feature_on_off_animation, NULL, }, }; diff --git a/test/feature_test/feature_test.h b/test/feature_test/feature_test.h index 29ec816..ce3643e 100755 --- a/test/feature_test/feature_test.h +++ b/test/feature_test/feature_test.h @@ -14,7 +14,7 @@ #define BOOT_H 1280 void feature_test(void); -void group_feature_on_animation(unit_group_t * group); +void group_feature_on_off_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 deleted file mode 100755 index 01d7e0c..0000000 --- a/test/feature_test/group_feature_on_animation.c +++ /dev/null @@ -1,129 +0,0 @@ -#include "test.h" -#if TEST_MODE - -#include "feature_test.h" -#include "boot.h" -#include "animation.h" - -#include -#include - -extern Evas_Object *__t__get_window(void); -extern Evas_Object *__t__get_layout(void); - -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 { - int current_step; - Ecore_Timer * group_timer; - unit_group_t * group; - int current_case; - void(*case_pool[CASE_COUNT + 1])(bool * is_passed); -} s_info = { - .current_step = 0, - .group_timer = NULL, - .group = NULL, - .current_case = 0, - .case_pool = { - __case_start_on_animation, - __case_check_animation, /* x 8 */ - __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 test_elm_exit(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); - - boot_exit = test_elm_exit; - init_animation(TYPE_ON); - - *is_passed = true; -} - -static void __case_check_animation(bool * is_passed) -{ - int rx, ry, rw, rh; - Evas_Object *window = __t__get_window(); - evas_object_geometry_get(window, &rx, &ry, &rw, &rh); - TEST_ASSERT_EQUAL_INT(rx, BOOT_X); - TEST_ASSERT_EQUAL_INT(ry, BOOT_Y); - TEST_ASSERT_EQUAL_INT(rw, BOOT_W); - TEST_ASSERT_EQUAL_INT(rh, BOOT_H); - TEST_ASSERT_TRUE(evas_object_visible_get(window)); - - Evas_Object *layout = __t__get_layout(); - evas_object_geometry_get(window, &rx, &ry, &rw, &rh); - TEST_ASSERT_EQUAL_INT(rx, BOOT_X); - TEST_ASSERT_EQUAL_INT(ry, BOOT_Y); - TEST_ASSERT_EQUAL_INT(rw, BOOT_W); - TEST_ASSERT_EQUAL_INT(rh, BOOT_H); - TEST_ASSERT_TRUE(evas_object_visible_get(layout)); - - if (s_info.current_step < 8) { - s_info.current_case -= 1; - } - - s_info.current_step += 1; - - *is_passed = true; -} - -static void __case_check_finish_animation(bool * is_passed) -{ - int is_finished = -1; - - vconf_get_int(VCONFKEY_BOOT_ANIMATION_FINISHED, &is_finished); - TEST_ASSERT_TRUE(is_finished == 1); - - *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_step = 0; - s_info.current_case = 0; - s_info.group = group; - /* 0.7 because boot-animation take 6 sec, we should not use divisor */ - s_info.group_timer = ecore_timer_add(0.7, __group_timer_callback, NULL); -} - -#endif - diff --git a/test/feature_test/group_feature_on_off_animation.c b/test/feature_test/group_feature_on_off_animation.c new file mode 100755 index 0000000..6dd2968 --- /dev/null +++ b/test/feature_test/group_feature_on_off_animation.c @@ -0,0 +1,181 @@ +#include "test.h" +#if TEST_MODE + +#include "feature_test.h" +#include "boot.h" +#include "animation.h" + +#include +#include + +extern Evas_Object *__t__get_window(void); +extern Evas_Object *__t__get_layout(void); +extern Evas_Object *__t__get_display_block(void); + +static void __case_start_on_animation(bool * is_passed); +static void __case_start_off_animation(bool * is_passed); +static void __case_check_animation(bool * is_passed); +static void __case_check_finish_on_animation(bool * is_passed); +static void __case_check_finish_off_animation(bool * is_passed); + +static struct { + bool is_exit; + int current_step; + int step_max; + Ecore_Timer * group_timer; + unit_group_t * group; + int current_case; + void(*case_pool[CASE_COUNT_MAX + 1])(bool * is_passed); +} s_info = { + .is_exit = false, + .current_step = 0, + .group_timer = NULL, + .group = NULL, + .current_case = 0, + .case_pool = { + __case_start_on_animation, + __case_check_animation, /* x 8 */ + __case_check_finish_on_animation, + __case_start_off_animation, + __case_check_animation, /* x 3 */ + __case_check_finish_off_animation, + NULL, + }, +}; + +static Eina_Bool __group_timer_callback(void * data); + +static void __set_up(void) {} +static void __tear_down(void) {} + +static void test_elm_exit(void) +{ + s_info.is_exit = true; +} + +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_EQUAL_INT(0, is_finished); + + boot_exit = test_elm_exit; + s_info.is_exit = false; + + init_animation(TYPE_ON); + + s_info.current_step = 1; + s_info.step_max = 7; + + *is_passed = true; +} + +static void __case_start_off_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_EQUAL_INT(0, is_finished); + + init_animation(TYPE_OFF); + + s_info.current_step = 1; + s_info.step_max = 3; + + *is_passed = true; +} + +static void __case_check_animation(bool * is_passed) +{ + int rx, ry, rw, rh; + Evas_Object *window = __t__get_window(); + TEST_ASSERT_TRUE(window != NULL); + evas_object_geometry_get(window, &rx, &ry, &rw, &rh); + TEST_ASSERT_EQUAL_INT(BOOT_X, rx); + TEST_ASSERT_EQUAL_INT(BOOT_Y, ry); + TEST_ASSERT_EQUAL_INT(BOOT_W, rw); + TEST_ASSERT_EQUAL_INT(BOOT_H, rh); + TEST_ASSERT_TRUE(evas_object_visible_get(window)); + + Evas_Object *layout = __t__get_layout(); + TEST_ASSERT_TRUE(layout != NULL); + evas_object_geometry_get(layout, &rx, &ry, &rw, &rh); + TEST_ASSERT_EQUAL_INT(BOOT_X, rx); + TEST_ASSERT_EQUAL_INT(BOOT_Y, ry); + TEST_ASSERT_EQUAL_INT(BOOT_W, rw); + TEST_ASSERT_EQUAL_INT(BOOT_H, rh); + TEST_ASSERT_TRUE(evas_object_visible_get(layout)); + + if (s_info.current_step < s_info.step_max) { + s_info.current_case -= 1; + } + + s_info.current_step += 1; + + *is_passed = true; +} + +static void __case_check_finish_on_animation(bool * is_passed) +{ + int is_finished = -1; + + vconf_get_int(VCONFKEY_BOOT_ANIMATION_FINISHED, &is_finished); + TEST_ASSERT_TRUE(is_finished == 1); + + TEST_ASSERT_TRUE(s_info.is_exit == true); + s_info.is_exit = false; + + *is_passed = true; +} + +static void __case_check_finish_off_animation(bool * is_passed) +{ + Evas_Object *display_block = __t__get_display_block(); + + int rx, ry, rw, rh; + evas_object_geometry_get(display_block, &rx, &ry, &rw, &rh); + TEST_ASSERT_TRUE(display_block != NULL); + TEST_ASSERT_EQUAL_INT(rx, BOOT_X); + TEST_ASSERT_EQUAL_INT(ry, BOOT_Y); + TEST_ASSERT_EQUAL_INT(rw, BOOT_W); + TEST_ASSERT_EQUAL_INT(rh, BOOT_H); + TEST_ASSERT_TRUE(evas_object_visible_get(display_block)); + + *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_off_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_step = 0; + s_info.current_case = 0; + s_info.group = group; + /* 0.8 because boot-animation take 6 sec, we should not use divisor */ + s_info.group_timer = ecore_timer_add(0.8, __group_timer_callback, NULL); +} + +#endif diff --git a/test/function_test/function_test.c b/test/function_test/function_test.c index d3f8a1d..26fce35 100755 --- a/test/function_test/function_test.c +++ b/test/function_test/function_test.c @@ -3,12 +3,10 @@ #include "function_test.h" -#define TEST_GROUP_COUNT 1 - static struct { int current_group; - char group_name[TEST_GROUP_COUNT + 1][128]; - void(*group_starter_pool[TEST_GROUP_COUNT + 1])(unit_group_t * group); + char group_name[GROUP_COUNT_MAX + 1][128]; + void(*group_starter_pool[GROUP_COUNT_MAX + 1])(unit_group_t * group); } s_info = { .current_group = 0, .group_name = { diff --git a/test/unit/inc/unit.h b/test/unit/inc/unit.h index 3bc372f..b79a9a9 100755 --- a/test/unit/inc/unit.h +++ b/test/unit/inc/unit.h @@ -12,6 +12,9 @@ #include +#define GROUP_COUNT_MAX 100 +#define CASE_COUNT_MAX 100 + #define TEST_GROUP(group_name, group_starter, group_complete_cb) unit_add_group(group_name, group_starter, group_complete_cb) #define TEST_CASE(group, case_starter) { \ bool is_passed = false; \