From 43fd677ed9772674f8b17aa850fe19ef48cd778b Mon Sep 17 00:00:00 2001 From: "huiyu,eun" Date: Tue, 8 Aug 2017 10:53:34 +0900 Subject: [PATCH] [UTC][sdl2][ACR-1017][Add new TC for initializing application] Change-Id: Iadadbb82018fd78170be57d4302889869b0f8894 Signed-off-by: huiyu,eun --- src/utc/sdl2/public.list | 1 + src/utc/sdl2/tct-sdl2-core.c | 15 +---- src/utc/sdl2/tct-sdl2-core_mobile.h | 12 ++++ src/utc/sdl2/tct-sdl2-core_wearable.h | 12 ++++ src/utc/sdl2/utc-sdl2.c | 97 ++++++++++++++++++++++++++- 5 files changed, 122 insertions(+), 15 deletions(-) diff --git a/src/utc/sdl2/public.list b/src/utc/sdl2/public.list index f8fcb98d2..f6b6d1b73 100755 --- a/src/utc/sdl2/public.list +++ b/src/utc/sdl2/public.list @@ -1,2 +1,3 @@ +SDL_tizen_app_init SDL_Vulkan_GetInstanceExtensions SDL_Vulkan_CreateSurface diff --git a/src/utc/sdl2/tct-sdl2-core.c b/src/utc/sdl2/tct-sdl2-core.c index 69aa8d59f..8c0ef5f1d 100755 --- a/src/utc/sdl2/tct-sdl2-core.c +++ b/src/utc/sdl2/tct-sdl2-core.c @@ -41,7 +41,7 @@ int gArgc; char ** gArgv; int test_return_value; -int SDL_main(int argc, char *argv[]) +int main(int argc, char *argv[]) { int result = -1; int i; @@ -67,7 +67,6 @@ int SDL_main(int argc, char *argv[]) } char* func_name = (char*)argv[1]; - if (smack_mode) { encoded_byte=(char*)argv[3]; @@ -93,21 +92,13 @@ int SDL_main(int argc, char *argv[]) dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] Coverage *.gcda File location set to /tmp/home/abuild/rpmbuild/BUILD/ ", __FUNCTION__, __LINE__); dlog_print(DLOG_INFO, "NativeTCT", "[%s:%d] Executing TC Name = %s", __FUNCTION__, __LINE__, func_name); - //Initialize SDL - if( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_EVENTS ) < 0 ) { - printf( "SDL could not initialize! SDL_Error: %s\n", SDL_GetError() ); - SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "SDL could not initialize! SDL_Error: %s", SDL_GetError()); - - PRINT_TC_RESULT("%d", result=-1); - return result; - } - - + setArgument(argc, argv); for (i = 0; tc_array[i].name; i++) { if (!strncmp(func_name, tc_array[i].name, strlen(func_name))) { if ( tc_array[i].startup ) { dlog_print(DLOG_INFO, "NativeTCT", "%s : Start up", func_name); + initSDLApp(); tc_array[i].startup(); } diff --git a/src/utc/sdl2/tct-sdl2-core_mobile.h b/src/utc/sdl2/tct-sdl2-core_mobile.h index 17156e6d5..aec5cfd05 100755 --- a/src/utc/sdl2/tct-sdl2-core_mobile.h +++ b/src/utc/sdl2/tct-sdl2-core_mobile.h @@ -19,6 +19,14 @@ #include "testcase.h" #include "tct_common.h" +extern void setArgument(int argc, char* argv[]); +extern void initSDLApp(); + +extern int utc_SDL_tizen_app_init_p(void); +extern int utc_SDL_tizen_app_init_n(void); +extern int utc_SDL_tizen_app_init_n2(void); +extern int utc_SDL_tizen_app_init_n3(void); + extern void utc_sdl_startup(void); extern void utc_sdl_cleanup(void); @@ -34,6 +42,10 @@ extern int utc_SDL_Vulkan_CreateSurface_n3(void); extern int utc_SDL_Vulkan_CreateSurface_n4(void); testcase tc_array[] = { + {"utc_SDL_tizen_app_init_p", utc_SDL_tizen_app_init_p, NULL, NULL}, + {"utc_SDL_tizen_app_init_n", utc_SDL_tizen_app_init_n, NULL, NULL}, + {"utc_SDL_tizen_app_init_n2", utc_SDL_tizen_app_init_n2, NULL, NULL}, + {"utc_SDL_tizen_app_init_n3", utc_SDL_tizen_app_init_n3, NULL, NULL}, {"utc_SDL_Vulkan_GetInstanceExtensions_p",utc_SDL_Vulkan_GetInstanceExtensions_p,utc_sdl_startup,utc_sdl_cleanup}, {"utc_SDL_Vulkan_GetInstanceExtensions_p2",utc_SDL_Vulkan_GetInstanceExtensions_p2,utc_sdl_startup,utc_sdl_cleanup}, {"utc_SDL_Vulkan_GetInstanceExtensions_n",utc_SDL_Vulkan_GetInstanceExtensions_n,utc_sdl_startup,utc_sdl_cleanup}, diff --git a/src/utc/sdl2/tct-sdl2-core_wearable.h b/src/utc/sdl2/tct-sdl2-core_wearable.h index 47d7a4b06..58e2a23f2 100755 --- a/src/utc/sdl2/tct-sdl2-core_wearable.h +++ b/src/utc/sdl2/tct-sdl2-core_wearable.h @@ -19,6 +19,14 @@ #include "testcase.h" #include "tct_common.h" +extern void setArgument(int argc, char* argv[]); +extern void initSDLApp(); + +extern int utc_SDL_tizen_app_init_p(void); +extern int utc_SDL_tizen_app_init_n(void); +extern int utc_SDL_tizen_app_init_n2(void); +extern int utc_SDL_tizen_app_init_n3(void); + extern void utc_sdl_startup(void); extern void utc_sdl_cleanup(void); @@ -34,6 +42,10 @@ extern int utc_SDL_Vulkan_CreateSurface_n3(void); extern int utc_SDL_Vulkan_CreateSurface_n4(void); testcase tc_array[] = { + {"utc_SDL_tizen_app_init_p", utc_SDL_tizen_app_init_p, NULL, NULL}, + {"utc_SDL_tizen_app_init_n", utc_SDL_tizen_app_init_n, NULL, NULL}, + {"utc_SDL_tizen_app_init_n2", utc_SDL_tizen_app_init_n2, NULL, NULL}, + {"utc_SDL_tizen_app_init_n3", utc_SDL_tizen_app_init_n3, NULL, NULL}, {"utc_SDL_Vulkan_GetInstanceExtensions_p", utc_SDL_Vulkan_GetInstanceExtensions_p, utc_sdl_startup, utc_sdl_cleanup}, {"utc_SDL_Vulkan_GetInstanceExtensions_p2", utc_SDL_Vulkan_GetInstanceExtensions_p2, utc_sdl_startup, utc_sdl_cleanup}, {"utc_SDL_Vulkan_GetInstanceExtensions_n", utc_SDL_Vulkan_GetInstanceExtensions_n, utc_sdl_startup, utc_sdl_cleanup}, diff --git a/src/utc/sdl2/utc-sdl2.c b/src/utc/sdl2/utc-sdl2.c index 44d8d8396..ff4c160f3 100755 --- a/src/utc/sdl2/utc-sdl2.c +++ b/src/utc/sdl2/utc-sdl2.c @@ -18,6 +18,7 @@ #include "assert.h" #include "tct_common.h" +#include #include #include #include @@ -25,6 +26,90 @@ #include #include +static int argc; +static char **argv; + +/** + * @function setArgument + * @description sets global arguments variable + * @parameter argc : argument count + * @parameter argv : argument vector + * @return NA + */ +void setArgument(int _argc, char* _argv[]) +{ + argc = _argc; + argv = _argv; +} + +/** + * @function initSDLApp + * @description initialize SDL application + * @return NA + */ +void initSDLApp() +{ + SDL_tizen_app_init(argc, argv); + SDL_SetMainReady(); +} + +/** + * @testcase utc_SDL_tizen_app_init_p + * @since_tizen 4.0 + * @description testcase for check normal inputs + */ +int utc_SDL_tizen_app_init_p(void) +{ + int ret = SDL_tizen_app_init(argc, argv); + assert_eq(ret, APP_ERROR_NONE); + return 0; +} + +/** + * @testcase utc_SDL_tizen_app_init_n + * @since_tizen 4.0 + * @description testcase for calling api twice + */ +int utc_SDL_tizen_app_init_n(void) +{ + int ret = SDL_tizen_app_init(argc, argv); + assert_eq(ret, APP_ERROR_NONE); + if(ret == APP_ERROR_NONE) + { + ret = SDL_tizen_app_init(argc, argv); + } + assert_eq(ret, APP_ERROR_ALREADY_RUNNING); + return 0; +} + +/** + * @testcase utc_SDL_tizen_app_init_n2 + * @since_tizen 4.0 + * @description testcase for check invalid input + (argc is 0) + */ +int utc_SDL_tizen_app_init_n2(void) +{ + argc = 0; + int ret = SDL_tizen_app_init(argc, argv); + assert_eq(ret, APP_ERROR_INVALID_PARAMETER); + return 0; +} + +/** + * @testcase utc_SDL_tizen_app_init_n3 + * @since_tizen 4.0 + * @description testcase for check invalid input + (argv is NULL) + */ +int utc_SDL_tizen_app_init_n3(void) +{ + argv = NULL; + int ret = SDL_tizen_app_init(argc, argv); + assert_eq(ret, APP_ERROR_INVALID_PARAMETER); + return 0; +} + void *vulkan_handle; PFN_vkGetInstanceProcAddr fn_vkGetInstanceProcAddr; @@ -322,6 +407,12 @@ void utc_sdl_startup(void) } //Initialize SDL + if( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_EVENTS ) < 0 ) { + printf( "SDL could not initialize! SDL_Error: %s\n", SDL_GetError() ); + SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "SDL could not initialize! SDL_Error: %s", SDL_GetError()); + + return; + } SDL_GetDisplayMode(0, 0, &(tcData.sdl_mode)); tcData.width = tcData.sdl_mode.w; @@ -689,7 +780,7 @@ int utc_SDL_Vulkan_GetInstanceExtensions_p2(void) /** * @testcase utc_SDL_Vulkan_GetInstanceExtension_n * @since_tizen 3.0 - * @description testcase for check invalid input + * @description testcase for check invalid input * (SDL_Window* window : NULL, unsigned int* count : NULL, char** names : NULL) */ int utc_SDL_Vulkan_GetInstanceExtensions_n(void) @@ -710,7 +801,7 @@ int utc_SDL_Vulkan_GetInstanceExtensions_n(void) /** * @testcase utc_SDL_Vulkan_GetInstanceExtension_n2 * @since_tizen 3.0 - * @description testcase for check invalid input + * @description testcase for check invalid input * (SDL_Window* window : valid, unsigned int* count : NULL, char** names : NULL) */ int utc_SDL_Vulkan_GetInstanceExtensions_n2(void) @@ -731,7 +822,7 @@ int utc_SDL_Vulkan_GetInstanceExtensions_n2(void) /** * @testcase utc_SDL_Vulkan_GetInstanceExtension_n3 * @since_tizen 3.0 - * @description testcase for check invalid input + * @description testcase for check invalid input * (SDL_Window* window : valid, unsigned int* count : NULL, char** names : valid) */ int utc_SDL_Vulkan_GetInstanceExtensions_n3(void) -- 2.34.1