From 23b4066c69dd9818f4ad3df99542b8e06caa831a Mon Sep 17 00:00:00 2001 From: "JunSeok, Kim" Date: Thu, 26 Oct 2017 11:28:40 +0900 Subject: [PATCH] TC0600_focus: add focus testcase Change-Id: I65a3d9a7f47e00462b92f247d6111fde88f2fb22 --- src/0600_focus.c | 332 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/Makefile.am | 3 +- src/e_test_runner.c | 6 + src/e_test_runner.h | 5 + 4 files changed, 345 insertions(+), 1 deletion(-) create mode 100755 src/0600_focus.c diff --git a/src/0600_focus.c b/src/0600_focus.c new file mode 100755 index 0000000..9b5743a --- /dev/null +++ b/src/0600_focus.c @@ -0,0 +1,332 @@ +#include "e_test_runner.h" + +struct _E_TC_Data +{ + E_TC_Win *tw_red; + E_TC_Win *tw_green; + E_TC_Win *tw_blue; + E_TC_Win *tw_register; +}; + +static Eina_Bool _tc_win_register(E_TC *tc, E_TC_Win *win); +static void _tc_win_unregister(E_TC *tc); +static Eina_Bool _tc_focus_pre_run(E_TC *tc, Eina_Bool show_win, Eina_Bool use_geom); +static void _tc_focus_post_run(E_TC *tc); +static void _tc_focus_shutdown(E_TC *tc); + + +static Eina_Bool +_tc_win_register(E_TC *tc, E_TC_Win *win) +{ + Eina_Bool res; + + EINA_SAFETY_ON_NULL_RETURN_VAL(tc, EINA_FALSE); + EINA_SAFETY_ON_NULL_RETURN_VAL(tc->data, EINA_FALSE); + + EINA_SAFETY_ON_NULL_RETURN_VAL(win, EINA_FALSE); + + if (tc->data->tw_register) + { + e_test_runner_req_win_deregister(tc->runner, tc->data->tw_register); + tc->data->tw_register = NULL; + } + + tc->data->tw_register = win; + + res = e_test_runner_req_win_register(tc->runner, tc->data->tw_register); + EINA_SAFETY_ON_FALSE_RETURN_VAL(res, EINA_FALSE); + + return EINA_TRUE; +} + +static void +_tc_win_unregister(E_TC *tc) +{ + EINA_SAFETY_ON_NULL_RETURN(tc); + EINA_SAFETY_ON_NULL_RETURN(tc->data); + EINA_SAFETY_ON_NULL_RETURN(tc->data->tw_register); + + e_test_runner_req_win_deregister(tc->runner, tc->data->tw_register); + tc->data->tw_register = NULL; +} + + +static Eina_Bool +_tc_focus_pre_run(E_TC *tc, Eina_Bool show_win, Eina_Bool use_geom) +{ + tc->data = E_NEW(E_TC_Data, 1); + EINA_SAFETY_ON_NULL_RETURN_VAL(tc->data, EINA_FALSE); + + tc->data->tw_red = e_tc_win_add(NULL, ELM_WIN_BASIC, + EINA_FALSE, "red", + 0, 0, 400, 400, use_geom, + 200, E_TC_WIN_COLOR_RED); + EINA_SAFETY_ON_NULL_GOTO(tc->data->tw_red, cleanup); + + if (show_win) + { + e_tc_win_geom_update(tc->data->tw_red); + e_tc_win_show(tc->data->tw_red); + } + + tc->data->tw_green = e_tc_win_add(NULL, ELM_WIN_BASIC, + EINA_FALSE, "green", + 150, 150, 400, 400, use_geom, + 200, E_TC_WIN_COLOR_GREEN); + EINA_SAFETY_ON_NULL_GOTO(tc->data->tw_green, cleanup); + + if (show_win) + { + e_tc_win_geom_update(tc->data->tw_green); + e_tc_win_show(tc->data->tw_green); + } + + tc->data->tw_blue = e_tc_win_add(NULL, ELM_WIN_BASIC, + EINA_FALSE, "blue", + 20, 350, 400, 400, use_geom, + 200, E_TC_WIN_COLOR_BLUE); + EINA_SAFETY_ON_NULL_GOTO(tc->data->tw_blue, cleanup); + + if (show_win) + { + _tc_win_register(tc, tc->data->tw_blue); + + e_tc_win_geom_update(tc->data->tw_blue); + e_tc_win_show(tc->data->tw_blue); + } + + e_test_runner_ev_wait(tc->runner, E_TC_EVENT_TYPE_VIS_ON); + e_test_runner_work(); + + return EINA_TRUE; + +cleanup: + _tc_focus_shutdown(tc); + return EINA_FALSE; +} + +static void +_tc_focus_post_run(E_TC *tc) +{ + EINA_SAFETY_ON_NULL_RETURN(tc->data); + + e_tc_win_hide(tc->data->tw_red); + e_tc_win_hide(tc->data->tw_green); + e_tc_win_hide(tc->data->tw_blue); +} + +static void +_tc_focus_shutdown(E_TC *tc) +{ + EINA_SAFETY_ON_NULL_RETURN(tc->data); + + _tc_win_unregister(tc); + e_tc_win_del(tc->data->tw_red); + e_tc_win_del(tc->data->tw_green); + e_tc_win_del(tc->data->tw_blue); + + E_FREE(tc->data); +} + +Eina_Bool +tc_0600_focus_basic(E_TC *tc) +{ + E_TC_Win *tw; + E_TC_Win *tw_red, *tw_green, *tw_blue; + Eina_Bool res = EINA_FALSE; + Eina_List *list = NULL, *l; + + EINA_SAFETY_ON_NULL_RETURN_VAL(tc, EINA_FALSE); + + res = _tc_focus_pre_run(tc, EINA_TRUE, EINA_FALSE); + EINA_SAFETY_ON_FALSE_GOTO(res, cleanup); + + tw_red = tc->data->tw_red; + tw_green = tc->data->tw_green; + tw_blue = tc->data->tw_blue; + + // Expected focus result: + // [Top] Blue[focused] -> Green -> Red [Bottom] + list = e_test_runner_req_win_info_list_get(tc->runner); + EINA_SAFETY_ON_NULL_GOTO(list, cleanup); + + EINA_LIST_FOREACH(list, l, tw) + { + if (tw->native_win == tw_blue->native_win) + { + EINA_SAFETY_ON_FALSE_GOTO((tw->focus.obj == EINA_TRUE), cleanup); + } + else if (tw->native_win == tw_green->native_win) + { + EINA_SAFETY_ON_FALSE_GOTO((tw->focus.obj == EINA_FALSE), cleanup); + } + else if (tw->native_win == tw_red->native_win) + { + EINA_SAFETY_ON_FALSE_GOTO((tw->focus.obj == EINA_FALSE), cleanup); + } + } + + tc->passed = EINA_TRUE; + +cleanup: + _tc_focus_post_run(tc); + _tc_focus_shutdown(tc); + E_FREE_LIST(list, e_tc_win_del); + + return tc->passed; +} + +Eina_Bool +tc_0601_focus_lower(E_TC *tc) +{ + E_TC_Win *tw; + E_TC_Win *tw_red, *tw_green, *tw_blue; + Eina_Bool res = EINA_FALSE; + Eina_List *list = NULL, *l; + + EINA_SAFETY_ON_NULL_RETURN_VAL(tc, EINA_FALSE); + + res = _tc_focus_pre_run(tc, EINA_TRUE, EINA_FALSE); + EINA_SAFETY_ON_FALSE_GOTO(res, cleanup); + + tw_red = tc->data->tw_red; + tw_green = tc->data->tw_green; + tw_blue = tc->data->tw_blue; + + // make tw_blue stack lower + e_test_runner_req_win_stack_set(tc->runner, tw_blue, NULL, EINA_FALSE); + e_test_runner_ev_wait(tc->runner, E_TC_EVENT_TYPE_STACK_LOWER); + + // Expected focus result: + // [Top] Green[focused] -> Red -> ... -> Blue [Bottom] + list = e_test_runner_req_win_info_list_get(tc->runner); + EINA_SAFETY_ON_NULL_GOTO(list, cleanup); + + EINA_LIST_FOREACH(list, l, tw) + { + if (tw->native_win == tw_blue->native_win) + { + EINA_SAFETY_ON_FALSE_GOTO((tw->focus.obj == EINA_FALSE), cleanup); + } + else if (tw->native_win == tw_green->native_win) + { + EINA_SAFETY_ON_FALSE_GOTO((tw->focus.obj == EINA_TRUE), cleanup); + } + else if (tw->native_win == tw_red->native_win) + { + EINA_SAFETY_ON_FALSE_GOTO((tw->focus.obj == EINA_FALSE), cleanup); + } + } + + tc->passed = EINA_TRUE; + +cleanup: + _tc_focus_post_run(tc); + _tc_focus_shutdown(tc); + E_FREE_LIST(list, e_tc_win_del); + + return tc->passed; +} + +Eina_Bool +tc_0602_focus_raise(E_TC *tc) +{ + E_TC_Win *tw; + E_TC_Win *tw_red, *tw_green, *tw_blue; + Eina_Bool res = EINA_FALSE; + Eina_List *list = NULL, *l; + + EINA_SAFETY_ON_NULL_RETURN_VAL(tc, EINA_FALSE); + + res = _tc_focus_pre_run(tc, EINA_TRUE, EINA_FALSE); + EINA_SAFETY_ON_FALSE_GOTO(res, cleanup); + + tw_red = tc->data->tw_red; + tw_green = tc->data->tw_green; + tw_blue = tc->data->tw_blue; + + // make tw_red stack raise + e_test_runner_req_win_stack_set(tc->runner, tw_red, NULL, EINA_TRUE); + e_test_runner_ev_wait(tc->runner, E_TC_EVENT_TYPE_STACK_ABOVE); + + // Expected focus result: + // [Top] Red[focused] -> Blue -> Green [Bottom] + list = e_test_runner_req_win_info_list_get(tc->runner); + EINA_SAFETY_ON_NULL_GOTO(list, cleanup); + + EINA_LIST_FOREACH(list, l, tw) + { + if (tw->native_win == tw_blue->native_win) + { + EINA_SAFETY_ON_FALSE_GOTO((tw->focus.obj == EINA_FALSE), cleanup); + } + else if (tw->native_win == tw_green->native_win) + { + EINA_SAFETY_ON_FALSE_GOTO((tw->focus.obj == EINA_FALSE), cleanup); + } + else if (tw->native_win == tw_red->native_win) + { + EINA_SAFETY_ON_FALSE_GOTO((tw->focus.obj == EINA_TRUE), cleanup); + } + } + + tc->passed = EINA_TRUE; + +cleanup: + _tc_focus_post_run(tc); + _tc_focus_shutdown(tc); + E_FREE_LIST(list, e_tc_win_del); + + return tc->passed; +} + +Eina_Bool +tc_0603_focus_destroy(E_TC *tc) +{ + E_TC_Win *tw; + E_TC_Win *tw_red, *tw_green; + Eina_Bool res = EINA_FALSE; + Eina_List *list = NULL, *l; + + EINA_SAFETY_ON_NULL_RETURN_VAL(tc, EINA_FALSE); + + res = _tc_focus_pre_run(tc, EINA_TRUE, EINA_FALSE); + EINA_SAFETY_ON_FALSE_GOTO(res, cleanup); + + tw_red = tc->data->tw_red; + tw_green = tc->data->tw_green; + + // delete tw_blue + e_tc_win_hide(tc->data->tw_blue); + e_tc_win_del(tc->data->tw_blue); + tc->data->tw_blue = NULL; // for skipping delete of tw_blue in _tc_focus_shutdown + + // wait for delete tw_blue + e_test_runner_ev_wait(tc->runner, E_TC_EVENT_TYPE_VIS_OFF); + + // Expected focus result: + // [Top] Green[focused] -> Red [Bottom] + list = e_test_runner_req_win_info_list_get(tc->runner); + EINA_SAFETY_ON_NULL_GOTO(list, cleanup); + + EINA_LIST_FOREACH(list, l, tw) + { + if (tw->native_win == tw_green->native_win) + { + EINA_SAFETY_ON_FALSE_GOTO((tw->focus.obj == EINA_TRUE), cleanup); + } + else if (tw->native_win == tw_red->native_win) + { + EINA_SAFETY_ON_FALSE_GOTO((tw->focus.obj == EINA_FALSE), cleanup); + } + } + + tc->passed = EINA_TRUE; + +cleanup: + _tc_focus_post_run(tc); + _tc_focus_shutdown(tc); + E_FREE_LIST(list, e_tc_win_del); + + return tc->passed; +} diff --git a/src/Makefile.am b/src/Makefile.am index 496e7a6..60a4e49 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -16,7 +16,8 @@ e_test_runner.h \ 0200_transient_for.c \ 0300_notification.c \ 0400_tzsh.c \ -0500_rotation.c +0500_rotation.c \ +0600_focus.c MAINTAINERCLEANFILES = \ Makefile.in diff --git a/src/e_test_runner.c b/src/e_test_runner.c index 2b34025..6692bae 100644 --- a/src/e_test_runner.c +++ b/src/e_test_runner.c @@ -1056,6 +1056,12 @@ _e_test_runner_init(E_Test_Runner *runner, TC_ADD( 401, "Screensaver Manager: Basic", T_FUNC( 401, scrsaver_mng_basic ), 1); TC_ADD( 500, "Rotation: Available Rotation", T_FUNC( 500, rotation_available_rots ), 1); + + /* [0600 - 0699] focus */ + TC_ADD( 600, "Focus: Basic", T_FUNC( 600, focus_basic ), 1); + TC_ADD( 601, "Focus: lower", T_FUNC( 601, focus_lower ), 1); + TC_ADD( 602, "Focus: raise", T_FUNC( 602, focus_raise ), 1); + TC_ADD( 603, "Focus: destroy", T_FUNC( 603, focus_destroy ), 1); #undef T_FUNC } diff --git a/src/e_test_runner.h b/src/e_test_runner.h index 9d0d735..76eb101 100644 --- a/src/e_test_runner.h +++ b/src/e_test_runner.h @@ -294,6 +294,11 @@ Eina_Bool tc_0311_notification_fullsize_level_change(E_TC *tc); Eina_Bool tc_0400_scrsaver_basic(E_TC *tc); Eina_Bool tc_0401_scrsaver_mng_basic(E_TC *tc); +Eina_Bool tc_0600_focus_basic(E_TC *tc); +Eina_Bool tc_0601_focus_lower(E_TC *tc); +Eina_Bool tc_0602_focus_raise(E_TC *tc); +Eina_Bool tc_0603_focus_destroy(E_TC *tc); + #include "0500_rotation.h" #endif -- 2.7.4