From dbb63c4c60ff283fa078b50053ab91182c292174 Mon Sep 17 00:00:00 2001 From: junkyu han Date: Fri, 21 Apr 2017 15:18:59 +0900 Subject: [PATCH] Add test code for checking proper behavior according to on / off type Change-Id: I48bc71d898fd78c6ac71c5a1ddff24300380d122 --- inc/boot.h | 5 +++ src/boot.c | 52 ++++++++++++++++----------- test/function_test/group_function_animation.c | 24 ++++++++++++- 3 files changed, 59 insertions(+), 22 deletions(-) diff --git a/inc/boot.h b/inc/boot.h index a25ee01..73909c6 100644 --- a/inc/boot.h +++ b/inc/boot.h @@ -42,6 +42,11 @@ #define NICE_VALUE -20 #define FILE_PATH_MAX 128 +struct args { + int argc; + char **argv; +}; + enum { TYPE_UNKNOWN, TYPE_ON, diff --git a/src/boot.c b/src/boot.c index 786626b..74d1e79 100644 --- a/src/boot.c +++ b/src/boot.c @@ -48,11 +48,6 @@ extern char *optarg; extern int optind, opterr, optopt; -struct args { - int argc; - char **argv; -}; - //#define SOUND_PROFILE #ifdef SOUND_PROFILE #include @@ -85,9 +80,10 @@ static int get_wav_file(int state, char *wavpath) } #endif -static int __prepare_animation(keynode_t * node, void *user_data) +static int __check_on_off_type(void *user_data) { int c; + int i; int argc; char **argv; int type = TYPE_UNKNOWN; @@ -99,23 +95,9 @@ static int __prepare_animation(keynode_t * node, void *user_data) {"clear", no_argument, 0, 'c' }, {0, 0, 0, 0 }, }; - static int invoked_flag = 0; - - _D("xready_cb"); - printf("xready_cb\n"); - - if (invoked_flag == 1) { - _E("Already launched"); - printf("Error Already launched\n"); - return EXIT_FAILURE; - } - - invoked_flag = 1; - argc = args->argc; argv = args->argv; - int i; for (i = 0; i < argc; i++) { _D("argc %d [%s]", i, argv[i]); printf("argc %d [%s]\n", i, argv[i]); @@ -147,11 +129,17 @@ static int __prepare_animation(keynode_t * node, void *user_data) } } + return type; +} + +static int __prepare_animation(keynode_t * node, void *user_data) +{ #ifdef SOUND_PROFILE /* Sound is not supported Since Tizen 4.0 */ /* check sound profile */ char wav_path[256]; int soundon = 1; /* default sound on */ + if (vconf_get_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &soundon) < 0) { _D("VCONFKEY_SETAPPL_SOUND_STATUS_BOOL ==> FAIL!!"); printf("VCONFKEY_SETAPPL_SOUND_STATUS_BOOL ==> FAIL!!\n"); @@ -161,8 +149,15 @@ static int __prepare_animation(keynode_t * node, void *user_data) printf("Sound status: %d\n", soundon); #endif + int type = -1; + type = __check_on_off_type(user_data); + if (type < 0) { + _E("Failed to get on off type or UNKNOWN_TYPE: %d", type); + return EXIT_FAILURE; + } + if (init_animation(type) != EXIT_SUCCESS) { - _D("Exit boot-animation"); + _E("Exit boot-animation"); printf("Exit boot-animation\n"); return EXIT_FAILURE; } @@ -228,6 +223,12 @@ int main(int argc, char *argv[]) args.argc = argc; args.argv = argv; + static int invoked_flag = 0; + if (invoked_flag == 1) { + return -1; + } + invoked_flag = 1; + #if 0 _boot_ani_ui_set_scale(); #endif @@ -255,4 +256,13 @@ int main(int argc, char *argv[]) return 0; } + +#endif + +#include "test.h" +#if TEST_MODE +int __t__check_on_off_type(void *user_data) +{ + return __check_on_off_type(user_data); +} #endif diff --git a/test/function_test/group_function_animation.c b/test/function_test/group_function_animation.c index e162676..28221a7 100755 --- a/test/function_test/group_function_animation.c +++ b/test/function_test/group_function_animation.c @@ -3,14 +3,17 @@ #include "function_test.h" #include "animation.h" +#include "boot.h" #include #define LAYOUT "/usr/share/edje/720x1280_PowerOn.edj" #define LAYOUT_W 720 #define LAYOUT_H 1280 -#define STATE 1 +#define TYPE_POWER_ON 1 +#define TYPE_POWER_OFF 2 +extern int __t__check_on_off_type(void *user_data); static void __case_get_layout_file_name(bool * is_passed); static struct { @@ -34,6 +37,24 @@ static void __tear_down(void) s_info.win = NULL; } +static void __case_check_on_off_type(bool * is_passed) +{ + struct args args; + args.argc = 2; + args.argv = (char *)malloc(4 * 2); + + args.argv[0] = "/usr/bin/boot-animation"; + args.argv[1] = "--start"; + TEST_ASSERT_EQUAL_INT(TYPE_POWER_ON, __t__check_on_off_type(&args)); + + args.argv[1] = "--off"; + TEST_ASSERT_EQUAL_INT(TYPE_POWER_OFF, __t__check_on_off_type(&args)); + + free(args.argv); + + *is_passed = true; +} + static void __case_create_win(bool * is_passed) { TEST_ASSERT_TRUE(s_info.win != NULL); @@ -167,6 +188,7 @@ static void __case_is_layout_file_exist(bool * is_passed) void group_function_create_animation(unit_group_t * group) { + TEST_CASE(group, __case_check_on_off_type); TEST_CASE(group, __case_create_win); TEST_CASE(group, __case_get_layout_file_name); TEST_CASE(group, __case_is_layout_file_exist); -- 2.7.4