From: Doyoun Kang Date: Fri, 6 Aug 2021 05:00:10 +0000 (+0900) Subject: Rename to etTestTzshScreenSaver from et_TestTzsh X-Git-Tag: submit/tizen/20210818.025436~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d94f5fc72e56c639ab73f5426ea40d9af4d873b3;p=platform%2Fcore%2Fuifw%2Fe-tizen-testcase.git Rename to etTestTzshScreenSaver from et_TestTzsh Change-Id: I02422f04de2e0651ef04af927e34f1cf738a8f32 --- diff --git a/data/img/mobile/etTestTzsh/scrsaver_basic.png b/data/img/mobile/etTestTzsh/scrsaver_basic.png deleted file mode 100644 index 2a479ac..0000000 Binary files a/data/img/mobile/etTestTzsh/scrsaver_basic.png and /dev/null differ diff --git a/data/img/mobile/etTestTzsh/scrsaver_mng_basic.png b/data/img/mobile/etTestTzsh/scrsaver_mng_basic.png deleted file mode 100644 index 8f3152d..0000000 Binary files a/data/img/mobile/etTestTzsh/scrsaver_mng_basic.png and /dev/null differ diff --git a/data/img/mobile/etTestTzshScreenSaver/scrsaver_basic.png b/data/img/mobile/etTestTzshScreenSaver/scrsaver_basic.png new file mode 100644 index 0000000..2a479ac Binary files /dev/null and b/data/img/mobile/etTestTzshScreenSaver/scrsaver_basic.png differ diff --git a/data/img/mobile/etTestTzshScreenSaver/scrsaver_mng_basic.png b/data/img/mobile/etTestTzshScreenSaver/scrsaver_mng_basic.png new file mode 100644 index 0000000..8f3152d Binary files /dev/null and b/data/img/mobile/etTestTzshScreenSaver/scrsaver_mng_basic.png differ diff --git a/packaging/e-tizen-unittests.spec b/packaging/e-tizen-unittests.spec index a72d9a5..c11619d 100644 --- a/packaging/e-tizen-unittests.spec +++ b/packaging/e-tizen-unittests.spec @@ -63,8 +63,8 @@ rm -rf %{buildroot} %__cp -afr data/img/mobile/etTestSplash/*.png %{buildroot}/usr/share/e_tizen_unittests/data/mobile/etTestSplash/ %__mkdir_p %{buildroot}/usr/share/e_tizen_unittests/data/mobile/etTestTransientFor/ %__cp -afr data/img/mobile/etTestTransientFor/*.png %{buildroot}/usr/share/e_tizen_unittests/data/mobile/etTestTransientFor/ -%__mkdir_p %{buildroot}/usr/share/e_tizen_unittests/data/mobile/etTestTzsh/ -%__cp -afr data/img/mobile/etTestTzsh/*.png %{buildroot}/usr/share/e_tizen_unittests/data/mobile/etTestTzsh/ +%__mkdir_p %{buildroot}/usr/share/e_tizen_unittests/data/mobile/etTestTzshScreenSaver/ +%__cp -afr data/img/mobile/etTestTzshScreenSaver/*.png %{buildroot}/usr/share/e_tizen_unittests/data/mobile/etTestTzshScreenSaver/ %__mkdir_p %{buildroot}/usr/share/e_tizen_unittests/data/mobile/etTestInput/ %__cp -afr data/img/mobile/etTestInput/*.png %{buildroot}/usr/share/e_tizen_unittests/data/mobile/etTestInput/ %__mkdir_p %{buildroot}/usr/share/e_tizen_unittests/data/mobile/etTestFocus/ diff --git a/src/Makefile.am b/src/Makefile.am index 5845136..626e597 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -15,7 +15,7 @@ testcase/0002_base_operation.cpp \ testcase/0003_base_operation_multi_wins.cpp \ testcase/0004_transient_for.cpp \ testcase/0005_notification.cpp \ -testcase/0006_tzsh.cpp \ +testcase/0006_tzsh_screensaver.cpp \ testcase/0007_rotation.cpp \ testcase/0008_focus.cpp \ testcase/0009_input.cpp \ diff --git a/src/testcase/0006_tzsh.cpp b/src/testcase/0006_tzsh.cpp deleted file mode 100644 index d6a3036..0000000 --- a/src/testcase/0006_tzsh.cpp +++ /dev/null @@ -1,215 +0,0 @@ -#include "e_test_event.h" -#include "e_test_base.h" - -#include -#include - -#define E_TEST_WORK_TIME 3.0 - -class etTestTzsh : public ::etTCBase -{ - public: - Eina_Bool chk_timeout_val_ = EINA_FALSE; - Eina_Bool chk_ev_state_idle_timeout_ = EINA_FALSE; - Eina_Bool chk_ev_state_not_idle_ = EINA_FALSE; - int chk_cb_called_ = 0; - - tzsh_h tzsh = NULL; - tzsh_window tz_win = 0x0; - tzsh_screensaver_service_h tz_scrsaver = NULL; - tzsh_screensaver_manager_service_h tz_scrsaver_mng = NULL; - - etTestTzsh() - { - chk_timeout_val_ = EINA_FALSE; - chk_ev_state_idle_timeout_ = EINA_FALSE; - chk_ev_state_not_idle_ = EINA_FALSE; - chk_cb_called_ = 0; - }; - - ~etTestTzsh() - { - if (tz_scrsaver_mng) tzsh_screensaver_manager_service_destroy(tz_scrsaver_mng); - if (tz_scrsaver) tzsh_screensaver_service_destroy(tz_scrsaver); - if (tzsh) tzsh_destroy(tzsh); - }; - - protected: - etWin *tw_base = NULL; - std::string testCaseName; - std::string testName; - - void initTC(); -}; - -void -etTestTzsh::initTC() -{ - const ::testing::TestInfo *const test_info = ::testing::UnitTest::GetInstance()->current_test_info(); - - tw_base = initNormalWin("TCWin_Normal_base", EINA_FALSE); - ASSERT_TRUE(tw_base != NULL) << "failed to initiation window"; - - testCaseName = test_info->test_case_name(); - testName = test_info->name(); -} - -/****************** - callbacks - *******************/ -static void -_cb_state_change(void *data, - tzsh_screensaver_manager_service_h service, - int states) -{ - etTestTzsh *tc_data = (etTestTzsh *)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); - - etRunner::get().addTimer(); - - tc_data->chk_ev_state_idle_timeout_ = EINA_TRUE; - - etRunner::get().thawEvent(); - etRunner::get().feedMouseDown(1, 1); - etRunner::get().feedMouseUp(1, 1); - etRunner::get().freezeEvent(); - } - else if (states & TZSH_SCREENSAVER_MANAGER_SERVICE_STATE_NOT_IDLE) - { - EINA_SAFETY_ON_FALSE_RETURN(tc_data->chk_cb_called_ == 2); - - etRunner::get().delTimer(); - - 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; - - etRunner::get().finishWork(); - } - else - { - EINA_SAFETY_ON_FALSE_RETURN(EINA_FALSE); - } -} - -/* Name: - * etTestTzsh.scrsaver_basic - * Description: - * Check screensaver type window that is shown on the notification layer. - * Steps: - * 01. Create an elm basic window - * 02. Set elm window to be screensaver type using tzsh - * 03. Show window - * 04. Check window stack - * Expected results: - * A window is shown on the notification layer. - */ -TEST_F(etTestTzsh, scrsaver_basic) -{ - Eina_List *list = NULL, *l = NULL; - etWin *tw = NULL; - - initTC(); - - tzsh = tzsh_create(TZSH_TOOLKIT_TYPE_EFL); - ASSERT_TRUE(tzsh != NULL); - - tz_win = elm_win_window_id_get(tw_base->elm_win); - ASSERT_NE(0, tz_win); - - tz_scrsaver = tzsh_screensaver_service_create(tzsh, tz_win); - ASSERT_TRUE(tz_scrsaver != NULL); - - showTCWin(tw_base); - ASSERT_VIS_ON(tw_base); - - list = etRunner::get().getWinInfoList(); - ASSERT_TRUE(list != NULL); - - EINA_LIST_CAST_FOREACH(list, l, tw, etWin*) - { - if (tw->native_win != tw_base->native_win) - continue; - - // check layer - ASSERT_EQ(E_LAYER_CLIENT_ALERT, tw->layer); - - // check visibility - ASSERT_TRUE(tw->Vis.win); - ASSERT_TRUE(tw->Vis.obj); - ASSERT_EQ(E_VISIBILITY_UNOBSCURED, tw->Vis.type); - - // check focus - ASSERT_TRUE(tw->Focus.obj); - ASSERT_TRUE(tw->Focus.win); - - break; - } - - etRunner::get().freeWinInfoList(list); - - ASSERT_EQ(etRunner::get().verifyTC(testCaseName, testName), EINA_TRUE); -} - -/* Name: - * etTestTzsh.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. - */ -TEST_F(etTestTzsh, scrsaver_mng_basic) -{ - Eina_Bool res = EINA_FALSE; - - initTC(); - - tzsh = tzsh_create(TZSH_TOOLKIT_TYPE_EFL); - ASSERT_TRUE(tzsh != NULL); - - tz_win = elm_win_window_id_get(tw_base->elm_win); - ASSERT_NE(0, tz_win); - - tz_scrsaver_mng = tzsh_screensaver_manager_service_create(tzsh, tz_win); - ASSERT_TRUE(tz_scrsaver_mng != NULL); - - res = tzsh_screensaver_manager_service_idle_timeout_set(tz_scrsaver_mng, 1000); - ASSERT_EQ(TZSH_ERROR_NONE, res); - - res = tzsh_screensaver_manager_service_enable(tz_scrsaver_mng); - ASSERT_EQ(TZSH_ERROR_NONE, res); - - res = tzsh_screensaver_manager_service_state_change_cb_set(tz_scrsaver_mng, - _cb_state_change, - this); - ASSERT_EQ(TZSH_ERROR_NONE, res); - - etRunner::get().freezeEvent(); - etRunner::get().work(1.1); - etRunner::get().thawEvent(); - - ASSERT_TRUE(chk_ev_state_idle_timeout_); - ASSERT_TRUE(chk_ev_state_not_idle_); - ASSERT_TRUE(chk_timeout_val_); - ASSERT_EQ(2, chk_cb_called_); - - ASSERT_EQ(etRunner::get().verifyTC(testCaseName, testName), EINA_TRUE); -} diff --git a/src/testcase/0006_tzsh_screensaver.cpp b/src/testcase/0006_tzsh_screensaver.cpp new file mode 100644 index 0000000..caa53a0 --- /dev/null +++ b/src/testcase/0006_tzsh_screensaver.cpp @@ -0,0 +1,215 @@ +#include "e_test_event.h" +#include "e_test_base.h" + +#include +#include + +#define E_TEST_WORK_TIME 3.0 + +class etTestTzshScreenSaver : public ::etTCBase +{ + public: + Eina_Bool chk_timeout_val_ = EINA_FALSE; + Eina_Bool chk_ev_state_idle_timeout_ = EINA_FALSE; + Eina_Bool chk_ev_state_not_idle_ = EINA_FALSE; + int chk_cb_called_ = 0; + + tzsh_h tzsh = NULL; + tzsh_window tz_win = 0x0; + tzsh_screensaver_service_h tz_scrsaver = NULL; + tzsh_screensaver_manager_service_h tz_scrsaver_mng = NULL; + + etTestTzshScreenSaver() + { + chk_timeout_val_ = EINA_FALSE; + chk_ev_state_idle_timeout_ = EINA_FALSE; + chk_ev_state_not_idle_ = EINA_FALSE; + chk_cb_called_ = 0; + }; + + ~etTestTzshScreenSaver() + { + if (tz_scrsaver_mng) tzsh_screensaver_manager_service_destroy(tz_scrsaver_mng); + if (tz_scrsaver) tzsh_screensaver_service_destroy(tz_scrsaver); + if (tzsh) tzsh_destroy(tzsh); + }; + + protected: + etWin *tw_base = NULL; + std::string testCaseName; + std::string testName; + + void initTC(); +}; + +void +etTestTzshScreenSaver::initTC() +{ + const ::testing::TestInfo *const test_info = ::testing::UnitTest::GetInstance()->current_test_info(); + + tw_base = initNormalWin("TCWin_Normal_base", EINA_FALSE); + ASSERT_TRUE(tw_base != NULL) << "failed to initiation window"; + + testCaseName = test_info->test_case_name(); + testName = test_info->name(); +} + +/****************** + callbacks + *******************/ +static void +_cb_state_change(void *data, + tzsh_screensaver_manager_service_h service, + int states) +{ + etTestTzshScreenSaver *tc_data = (etTestTzshScreenSaver *)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); + + etRunner::get().addTimer(); + + tc_data->chk_ev_state_idle_timeout_ = EINA_TRUE; + + etRunner::get().thawEvent(); + etRunner::get().feedMouseDown(1, 1); + etRunner::get().feedMouseUp(1, 1); + etRunner::get().freezeEvent(); + } + else if (states & TZSH_SCREENSAVER_MANAGER_SERVICE_STATE_NOT_IDLE) + { + EINA_SAFETY_ON_FALSE_RETURN(tc_data->chk_cb_called_ == 2); + + etRunner::get().delTimer(); + + 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; + + etRunner::get().finishWork(); + } + else + { + EINA_SAFETY_ON_FALSE_RETURN(EINA_FALSE); + } +} + +/* Name: + * etTestTzshScreenSaver.scrsaver_basic + * Description: + * Check screensaver type window that is shown on the notification layer. + * Steps: + * 01. Create an elm basic window + * 02. Set elm window to be screensaver type using tzsh + * 03. Show window + * 04. Check window stack + * Expected results: + * A window is shown on the notification layer. + */ +TEST_F(etTestTzshScreenSaver, scrsaver_basic) +{ + Eina_List *list = NULL, *l = NULL; + etWin *tw = NULL; + + initTC(); + + tzsh = tzsh_create(TZSH_TOOLKIT_TYPE_EFL); + ASSERT_TRUE(tzsh != NULL); + + tz_win = elm_win_window_id_get(tw_base->elm_win); + ASSERT_NE(0, tz_win); + + tz_scrsaver = tzsh_screensaver_service_create(tzsh, tz_win); + ASSERT_TRUE(tz_scrsaver != NULL); + + showTCWin(tw_base); + ASSERT_VIS_ON(tw_base); + + list = etRunner::get().getWinInfoList(); + ASSERT_TRUE(list != NULL); + + EINA_LIST_CAST_FOREACH(list, l, tw, etWin*) + { + if (tw->native_win != tw_base->native_win) + continue; + + // check layer + ASSERT_EQ(E_LAYER_CLIENT_ALERT, tw->layer); + + // check visibility + ASSERT_TRUE(tw->Vis.win); + ASSERT_TRUE(tw->Vis.obj); + ASSERT_EQ(E_VISIBILITY_UNOBSCURED, tw->Vis.type); + + // check focus + ASSERT_TRUE(tw->Focus.obj); + ASSERT_TRUE(tw->Focus.win); + + break; + } + + etRunner::get().freeWinInfoList(list); + + ASSERT_EQ(etRunner::get().verifyTC(testCaseName, testName), EINA_TRUE); +} + +/* Name: + * etTestTzshScreenSaver.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. + */ +TEST_F(etTestTzshScreenSaver, scrsaver_mng_basic) +{ + Eina_Bool res = EINA_FALSE; + + initTC(); + + tzsh = tzsh_create(TZSH_TOOLKIT_TYPE_EFL); + ASSERT_TRUE(tzsh != NULL); + + tz_win = elm_win_window_id_get(tw_base->elm_win); + ASSERT_NE(0, tz_win); + + tz_scrsaver_mng = tzsh_screensaver_manager_service_create(tzsh, tz_win); + ASSERT_TRUE(tz_scrsaver_mng != NULL); + + res = tzsh_screensaver_manager_service_idle_timeout_set(tz_scrsaver_mng, 1000); + ASSERT_EQ(TZSH_ERROR_NONE, res); + + res = tzsh_screensaver_manager_service_enable(tz_scrsaver_mng); + ASSERT_EQ(TZSH_ERROR_NONE, res); + + res = tzsh_screensaver_manager_service_state_change_cb_set(tz_scrsaver_mng, + _cb_state_change, + this); + ASSERT_EQ(TZSH_ERROR_NONE, res); + + etRunner::get().freezeEvent(); + etRunner::get().work(1.1); + etRunner::get().thawEvent(); + + ASSERT_TRUE(chk_ev_state_idle_timeout_); + ASSERT_TRUE(chk_ev_state_not_idle_); + ASSERT_TRUE(chk_timeout_val_); + ASSERT_EQ(2, chk_cb_called_); + + ASSERT_EQ(etRunner::get().verifyTC(testCaseName, testName), EINA_TRUE); +}