From 68e0d690db9c0c7c9e2c866fab6e5157e797e3f8 Mon Sep 17 00:00:00 2001 From: Gwanglim Lee Date: Thu, 1 Sep 2016 14:31:37 +0900 Subject: [PATCH] added a new TC: 0401 screensaver manager basic Change-Id: I07f1563ea97dce152b5ecca98a57a9e78fcb49ae --- src/0400_tzsh.c | 198 ++++++++++++++++++++++++++++++++++++++++++++++++---- src/e_test_runner.c | 102 ++++++++++++++++++++++++++- src/e_test_runner.h | 59 +++++++++++++++- 3 files changed, 343 insertions(+), 16 deletions(-) diff --git a/src/0400_tzsh.c b/src/0400_tzsh.c index 4fad532..ba6e416 100644 --- a/src/0400_tzsh.c +++ b/src/0400_tzsh.c @@ -3,7 +3,7 @@ #include "e_test_runner.h" /* Name: - * [0400] scrsaver basic + * [0400] screensaver basic * Description: * Check screensaver type window that is shown on the notification layer. * Steps: @@ -20,12 +20,16 @@ tc_0400_scrsaver_basic(E_TC *tc) Eina_Bool res = EINA_FALSE; Eina_List *l = NULL, *ll = NULL; E_TC_Win *tw = NULL, *tw2 = NULL; - Eina_Bool found = EINA_FALSE; tzsh_h tzsh = NULL; tzsh_window tz_win = NULL; tzsh_screensaver_service_h tz_scrsaver = NULL; + Eina_Bool chk_found = EINA_FALSE; + Eina_Bool chk_ly = EINA_FALSE; + Eina_Bool chk_vis = EINA_FALSE; + Eina_Bool chk_focus = EINA_FALSE; + EINA_SAFETY_ON_NULL_RETURN_VAL(tc, EINA_FALSE); tw = e_tc_win_add(NULL, ELM_WIN_BASIC, EINA_FALSE, NULL, @@ -54,22 +58,31 @@ tc_0400_scrsaver_basic(E_TC *tc) EINA_LIST_FOREACH(l, ll, tw2) { - if (tw2->layer < 650) break; + if (tw2->native_win != tw->native_win) continue; - if (tw2->native_win == tw->native_win) - { - found = EINA_TRUE; + chk_found = EINA_TRUE; - if (tw2->layer == 650) - tc->passed = EINA_TRUE; - else - EINA_SAFETY_ON_FALSE_GOTO(EINA_FALSE, cleanup); + if (tw2->layer == E_LAYER_CLIENT_NOTIFICATION_LOW) + chk_ly = EINA_TRUE; - break; - } + if ((tw2->vis.win) && + (tw2->vis.obj) && + (tw2->vis.type == E_VISIBILITY_UNOBSCURED)) + chk_vis = EINA_TRUE; + + if ((tw2->focus.obj) && + (tw2->focus.win)) + chk_focus = EINA_TRUE; + + break; } - EINA_SAFETY_ON_FALSE_GOTO(found, cleanup); + EINA_SAFETY_ON_FALSE_GOTO(chk_found, cleanup); + EINA_SAFETY_ON_FALSE_GOTO(chk_ly, cleanup); + EINA_SAFETY_ON_FALSE_GOTO(chk_vis, cleanup); + EINA_SAFETY_ON_FALSE_GOTO(chk_focus, cleanup); + + tc->passed = EINA_TRUE; cleanup: e_test_runner_req_win_info_list_free(l); @@ -82,3 +95,162 @@ cleanup: return tc->passed; } + +struct _E_TC_Data +{ + E_Test_Runner *runner; + Ecore_Timer *expire_timer; + + /* 0401 */ + Eina_Bool chk_timeout_val; + Eina_Bool chk_ev_state_idle_timeout; + Eina_Bool chk_ev_state_not_idle; + int chk_cb_called; +}; + +static Eina_Bool +_cb_timeout(void *data) +{ + E_TC_Data *tc_data = data; + + tc_data->expire_timer = NULL; + + elm_exit(); + + return ECORE_CALLBACK_DONE; +} + +static void +_cb_state_change(void *data, + tzsh_screensaver_manager_service_h service, + int states) +{ + E_TC_Data *tc_data = data; + unsigned int time; + + tc_data->chk_cb_called++; + + if (states & TZSH_SCREENSAVER_MANAGER_SERVICE_STATE_IDLE_TIMEOUT_EXPIRED) + { + EINA_SAFETY_ON_FALSE_RETURN(tc_data->chk_cb_called == 1); + + if (tc_data->expire_timer) + { + ecore_timer_del(tc_data->expire_timer); + tc_data->expire_timer = NULL; + } + tc_data->expire_timer = ecore_timer_add(1.0, _cb_timeout, tc_data); + + tc_data->chk_ev_state_idle_timeout = EINA_TRUE; + + e_test_runner_req_ev_thaw(tc_data->runner); + e_test_runner_req_ev_feed_mouse_down(tc_data->runner, 1, 1); + e_test_runner_req_ev_feed_mouse_up(tc_data->runner, 1, 1); + e_test_runner_req_ev_freeze(tc_data->runner); + } + else if (states & TZSH_SCREENSAVER_MANAGER_SERVICE_STATE_NOT_IDLE) + { + EINA_SAFETY_ON_FALSE_RETURN(tc_data->chk_cb_called == 2); + + if (tc_data->expire_timer) + { + ecore_timer_del(tc_data->expire_timer); + tc_data->expire_timer = NULL; + } + + tc_data->chk_ev_state_not_idle = EINA_TRUE; + + tzsh_screensaver_manager_service_idle_timeout_get(service, &time); + EINA_SAFETY_ON_FALSE_RETURN(time == 1000); + + tc_data->chk_timeout_val = EINA_TRUE; + + elm_exit(); + } + else + { + EINA_SAFETY_ON_FALSE_RETURN(EINA_FALSE); + } +} + +/* Name: + * [0401] screensaver manager basic + * Description: + * Check screensaver manager APIs and 'state changed' callback + * Steps: + * 01. Create an elm basic window that won't be shown + * 02. Set elm window to be screensaver manager using tzsh + * 03. Set idle timeout to 1.0 seconds + * 04. Set screensaver feature enabled + * 05. Check TZSH_SCREENSAVER_MANAGER_SERVICE_STATE_IDLE_TIMEOUT_EXPIRED event + * 06. Request to feed fake key event + * 07. Check TZSH_SCREENSAVER_MANAGER_SERVICE_STATE_NOT_IDLE event + * Expected results: + * TZSH_SCREENSAVER_MANAGER_SERVICE_STATE_IDLE_TIMEOUT_EXPIRED event occurs. + * TZSH_SCREENSAVER_MANAGER_SERVICE_STATE_NOT_IDLE event occurs. + */ +Eina_Bool +tc_0401_scrsaver_mng_basic(E_TC *tc) +{ + E_TC_Win *tw = NULL; + tzsh_h tzsh = NULL; + tzsh_window tz_win = NULL; + tzsh_screensaver_manager_service_h tz_scrsaver_mng = NULL; + int res = 0; + E_TC_Data *data; + + EINA_SAFETY_ON_NULL_RETURN_VAL(tc, EINA_FALSE); + + data = E_NEW(E_TC_Data, 1); + EINA_SAFETY_ON_NULL_RETURN_VAL(data, EINA_FALSE); + + tw = e_tc_win_add(NULL, ELM_WIN_BASIC, EINA_FALSE, NULL, + 0, 0, 0, 0, EINA_FALSE, + 0, E_TC_WIN_COLOR_RED); + EINA_SAFETY_ON_NULL_RETURN_VAL(tw, EINA_FALSE); + + tzsh = tzsh_create(TZSH_TOOLKIT_TYPE_EFL); + EINA_SAFETY_ON_NULL_GOTO(tzsh, cleanup); + + tz_win = elm_win_window_id_get(tw->elm_win); + EINA_SAFETY_ON_FALSE_GOTO(tz_win, cleanup); + + tz_scrsaver_mng = tzsh_screensaver_manager_service_create(tzsh, tz_win); + EINA_SAFETY_ON_NULL_GOTO(tz_scrsaver_mng, cleanup); + + res = tzsh_screensaver_manager_service_idle_timeout_set(tz_scrsaver_mng, 1000); + EINA_SAFETY_ON_FALSE_GOTO(res == 0, cleanup); + + res = tzsh_screensaver_manager_service_enable(tz_scrsaver_mng); + EINA_SAFETY_ON_FALSE_GOTO(res == 0, cleanup); + + res = tzsh_screensaver_manager_service_state_change_cb_set(tz_scrsaver_mng, + _cb_state_change, + data); + EINA_SAFETY_ON_FALSE_GOTO(res == 0, cleanup); + + data->expire_timer = ecore_timer_add(1.0, _cb_timeout, data); + data->runner = tc->runner; + + e_test_runner_req_ev_freeze(tc->runner); + + e_test_runner_work(); + + e_test_runner_req_ev_thaw(tc->runner); + + EINA_SAFETY_ON_FALSE_GOTO(data->chk_ev_state_idle_timeout, cleanup); + EINA_SAFETY_ON_FALSE_GOTO(data->chk_ev_state_not_idle, cleanup); + EINA_SAFETY_ON_FALSE_GOTO(data->chk_timeout_val, cleanup); + EINA_SAFETY_ON_FALSE_GOTO(data->chk_cb_called == 2, cleanup); + + tc->passed = EINA_TRUE; + +cleanup: + if (data->expire_timer) ecore_timer_del(data->expire_timer); + E_FREE(data); + e_tc_win_del(tw); + tzsh_screensaver_manager_service_destroy(tz_scrsaver_mng); + tzsh_destroy(tzsh); + + return tc->passed; +} diff --git a/src/e_test_runner.c b/src/e_test_runner.c index cdd5136..b1d6864 100644 --- a/src/e_test_runner.c +++ b/src/e_test_runner.c @@ -1,6 +1,6 @@ #include "e_test_runner.h" -#define E_TEST_RUNNER_WORK_TIME 0.3 +#define E_TEST_RUNNER_WORK_TIME 3.0 int _log_dom = -1; @@ -403,6 +403,105 @@ e_test_runner_req_win_info_list_free(Eina_List *l) } Eina_Bool +e_test_runner_req_dpms_on(E_Test_Runner *runner) +{ + Eldbus_Pending *p; + p = eldbus_proxy_call(runner->dbus.proxy, "DPMS", + NULL, NULL, -1, + "u", 1); + EINA_SAFETY_ON_TRUE_RETURN_VAL(p != NULL, EINA_FALSE); + return EINA_TRUE; +} + +Eina_Bool +e_test_runner_req_dpms_off(E_Test_Runner *runner) +{ + Eldbus_Pending *p; + p = eldbus_proxy_call(runner->dbus.proxy, "DPMS", + NULL, NULL, -1, + "u", 0); + EINA_SAFETY_ON_TRUE_RETURN_VAL(p != NULL, EINA_FALSE); + return EINA_TRUE; +} + +Eina_Bool +e_test_runner_req_ev_freeze(E_Test_Runner *runner) +{ + Eldbus_Pending *p; + p = eldbus_proxy_call(runner->dbus.proxy, "EventFreeze", + NULL, NULL, -1, + "u", 1); + EINA_SAFETY_ON_TRUE_RETURN_VAL(p != NULL, EINA_FALSE); + return EINA_TRUE; +} + +Eina_Bool +e_test_runner_req_ev_thaw(E_Test_Runner *runner) +{ + Eldbus_Pending *p; + p = eldbus_proxy_call(runner->dbus.proxy, "EventFreeze", + NULL, NULL, -1, + "u", 0); + EINA_SAFETY_ON_TRUE_RETURN_VAL(p != NULL, EINA_FALSE); + return EINA_TRUE; +} + +Eina_Bool +e_test_runner_req_ev_feed_mouse_down(E_Test_Runner *runner, int x, int y) +{ + Eldbus_Pending *p; + p = eldbus_proxy_call(runner->dbus.proxy, "EventMouse", + NULL, NULL, -1, + "uii", 0, x, y); + EINA_SAFETY_ON_TRUE_RETURN_VAL(p != NULL, EINA_FALSE); + return EINA_TRUE; +} + +Eina_Bool +e_test_runner_req_ev_feed_mouse_move(E_Test_Runner *runner, int x, int y) +{ + Eldbus_Pending *p; + p = eldbus_proxy_call(runner->dbus.proxy, "EventMouse", + NULL, NULL, -1, + "uii", 1, x, y); + EINA_SAFETY_ON_TRUE_RETURN_VAL(p != NULL, EINA_FALSE); + return EINA_TRUE; +} + +Eina_Bool +e_test_runner_req_ev_feed_mouse_up(E_Test_Runner *runner, int x, int y) +{ + Eldbus_Pending *p; + p = eldbus_proxy_call(runner->dbus.proxy, "EventMouse", + NULL, NULL, -1, + "uii", 2, x, y); + EINA_SAFETY_ON_TRUE_RETURN_VAL(p != NULL, EINA_FALSE); + return EINA_TRUE; +} + +Eina_Bool +e_test_runner_req_ev_feed_key_down(E_Test_Runner *runner, const char *key) +{ + Eldbus_Pending *p; + p = eldbus_proxy_call(runner->dbus.proxy, "EventKey", + NULL, NULL, -1, + "us", 0, key); + EINA_SAFETY_ON_TRUE_RETURN_VAL(p != NULL, EINA_FALSE); + return EINA_TRUE; +} + +Eina_Bool +e_test_runner_req_ev_feed_key_up(E_Test_Runner *runner, const char *key) +{ + Eldbus_Pending *p; + p = eldbus_proxy_call(runner->dbus.proxy, "EventKey", + NULL, NULL, -1, + "us", 1, key); + EINA_SAFETY_ON_TRUE_RETURN_VAL(p != NULL, EINA_FALSE); + return EINA_TRUE; +} + +Eina_Bool e_test_runner_ev_wait(E_Test_Runner *runner, E_TC_Event_Type ev) { @@ -747,6 +846,7 @@ _e_test_runner_init(E_Test_Runner *runner) /* [0400 - 0499] tizen-ws-shell */ TC_ADD( 400, "Screensaver: Basic", T_FUNC( 400, scrsaver_basic ), 1); + TC_ADD( 401, "Screensaver Manager: Basic", T_FUNC( 401, scrsaver_mng_basic ), 1); #undef T_FUNC } diff --git a/src/e_test_runner.h b/src/e_test_runner.h index 289a7c6..90586b3 100644 --- a/src/e_test_runner.h +++ b/src/e_test_runner.h @@ -85,6 +85,50 @@ typedef enum _E_TC_Win_Color E_TC_WIN_COLOR_PURPLE, } E_TC_Win_Color; +/* NB: These types are originally defined in the enlightenment. + * But, we can't use original types in the header files of enlightenment, + * because e_test_runner needs to use tizen-extension-client-protocol that + * conflicts with tizen-extension-server-protocol enlightenment header had. + * + * Duplicated enum types: E_Layer, E_Visibility + */ +typedef enum _E_Layer +{ + E_LAYER_BOTTOM = -100, + E_LAYER_BG = -1, + E_LAYER_DESKTOP = 0, + E_LAYER_DESKTOP_TOP = 10, + E_LAYER_CLIENT_DESKTOP = 100, + E_LAYER_CLIENT_BELOW = 150, + E_LAYER_CLIENT_NORMAL = 200, + E_LAYER_CLIENT_ABOVE = 250, + E_LAYER_CLIENT_EDGE = 300, + E_LAYER_CLIENT_FULLSCREEN = 350, + E_LAYER_CLIENT_EDGE_FULLSCREEN = 400, + E_LAYER_CLIENT_POPUP = 450, + E_LAYER_CLIENT_TOP = 500, + E_LAYER_CLIENT_DRAG = 550, + E_LAYER_CLIENT_PRIO = 600, + E_LAYER_CLIENT_NOTIFICATION_LOW = 650, + E_LAYER_CLIENT_NOTIFICATION_NORMAL = 700, + E_LAYER_CLIENT_NOTIFICATION_HIGH = 750, + E_LAYER_CLIENT_NOTIFICATION_TOP = 800, + E_LAYER_CLIENT_ALERT = 850, + E_LAYER_POPUP = 999, + E_LAYER_EFFECT = 1999, + E_LAYER_MENU = 5000, + E_LAYER_DESKLOCK = 9999, + E_LAYER_MAX = 32767 +} E_Layer; + +typedef enum _E_Visibility +{ + E_VISIBILITY_UNKNOWN = -1, + E_VISIBILITY_UNOBSCURED = 0, + E_VISIBILITY_PARTIALLY_OBSCURED = 1, + E_VISIBILITY_FULLY_OBSCURED = 2 +} E_Visibility; + typedef struct _E_Test_Runner E_Test_Runner; typedef struct _E_TC_Win E_TC_Win; typedef struct _E_TC E_TC; @@ -117,14 +161,14 @@ struct _E_TC_Win Ecore_Window native_win; // native window id const char *name; // name of client window int x, y, w, h; // geometry - int layer; // value of E_Layer + E_Layer layer; Eina_Bool effect; struct { Eina_Bool win; Eina_Bool obj; int opaque; - int type; + E_Visibility type; Eina_Bool skip; } vis; Eina_Bool iconic; @@ -152,6 +196,16 @@ Eina_Bool e_test_runner_req_win_deregister(E_Test_Runner *runner, E_TC_Win *tw) Eina_List *e_test_runner_req_win_info_list_get(E_Test_Runner *runner); void e_test_runner_req_win_info_list_free(Eina_List *l); Eina_Bool e_test_runner_req_win_stack_set(E_Test_Runner *runner, E_TC_Win *tw, E_TC_Win *sibling, Eina_Bool above); +Eina_Bool e_test_runner_req_dpms_on(E_Test_Runner *runner); +Eina_Bool e_test_runner_req_dpms_off(E_Test_Runner *runner); +Eina_Bool e_test_runner_req_ev_freeze(E_Test_Runner *runner); +Eina_Bool e_test_runner_req_ev_thaw(E_Test_Runner *runner); +Eina_Bool e_test_runner_req_ev_feed_mouse_down(E_Test_Runner *runner, int x, int y); +Eina_Bool e_test_runner_req_ev_feed_mouse_move(E_Test_Runner *runner, int x, int y); +Eina_Bool e_test_runner_req_ev_feed_mouse_up(E_Test_Runner *runner, int x, int y); +Eina_Bool e_test_runner_req_ev_feed_key_down(E_Test_Runner *runner, const char *key); +Eina_Bool e_test_runner_req_ev_feed_key_up(E_Test_Runner *runner, const char *key); + Eina_Bool e_test_runner_ev_wait(E_Test_Runner *runner, E_TC_Event_Type ev); E_TC_Win *e_tc_win_add(E_TC_Win *parent, Elm_Win_Type type, Eina_Bool alpha, const char *name, int x, int y, int w, int h, Eina_Bool usr_geom, int layer, E_TC_Win_Color color); @@ -205,5 +259,6 @@ Eina_Bool tc_0302_notification_level_3(E_TC *tc); Eina_Bool tc_0303_notification_level_change(E_TC *tc); Eina_Bool tc_0400_scrsaver_basic(E_TC *tc); +Eina_Bool tc_0401_scrsaver_mng_basic(E_TC *tc); #endif -- 2.7.4