add notification_level tc 72/36072/2
authorBoram Park <boram1288.park@samsung.com>
Thu, 26 Feb 2015 04:57:05 +0000 (13:57 +0900)
committerBoram Park <boram1288.park@samsung.com>
Tue, 3 Mar 2015 09:50:47 +0000 (18:50 +0900)
Change-Id: Idbf9454830b6b2c89228d482edb021e806a6f1ce

configure.ac
packaging/e-tizen-testcase.spec
src/0120_notification_level.c [new file with mode: 0644]
src/Makefile.am
src/e_test_case_main.c
src/e_test_case_main.h
src/e_test_case_util.c

index 97d45f2..859f7ee 100644 (file)
@@ -24,6 +24,7 @@ requirements="\
    elementary \
    eldbus \
    enlightenment \
+   capi-ui-efl-util \
    "
 
 PKG_CHECK_MODULES(E_TEST_CASE, [${requirements}])
index 746d58c..63486b0 100644 (file)
@@ -8,6 +8,7 @@ Source0: %{name}-%{version}.tar.gz
 License: BSD-2-Clause
 BuildRequires: pkgconfig(enlightenment)
 BuildRequires: pkgconfig(eldbus)
+BuildRequires: pkgconfig(capi-ui-efl-util)
 BuildRequires:  gettext
 
 %description
@@ -24,7 +25,7 @@ export LDFLAGS+=" -Wl,--hash-style=both -Wl,--as-needed -Wl,--rpath=/usr/lib"
 
 %autogen
 %configure --prefix=/usr
-make
+make %{?_smp_mflags}
 
 %install
 rm -rf %{buildroot}
diff --git a/src/0120_notification_level.c b/src/0120_notification_level.c
new file mode 100644 (file)
index 0000000..7c909ab
--- /dev/null
@@ -0,0 +1,453 @@
+#include "e.h"
+#include "e_test_case_main.h"
+#include "e_test_case_util.h"
+
+#include <efl_util.h>
+
+#define TC_NWIN_W   400
+#define TC_NWIN_H   400
+
+typedef struct
+{
+   Evas_Object *obj;
+   Ecore_Window win;
+} E_TC_Win;
+
+static E_TC_Win *_tc_normal_win;
+static E_TC_Win *_tc_noti_win1;
+static E_TC_Win *_tc_noti_win2;
+
+static Eina_Bool registered;
+static Eina_Bool loop_running;
+
+static void
+_notification_level_cb_register_window(void *data,
+                                       const Eldbus_Message *msg,
+                                       Eldbus_Pending *pending EINA_UNUSED)
+{
+   Eina_Bool accepted = EINA_FALSE;
+   const char *errname, *errmsg;
+
+   EINA_SAFETY_ON_NULL_GOTO(_tc_normal_win, exit_reg_loop);
+   EINA_SAFETY_ON_NULL_GOTO(_tc_noti_win1, exit_reg_loop);
+   EINA_SAFETY_ON_NULL_GOTO(_tc_noti_win2, exit_reg_loop);
+
+   if (eldbus_message_error_get(msg, &errname, &errmsg))
+     {
+        ERR("%s %s\n", errname, errmsg);
+        goto exit_reg_loop;
+     }
+
+   if (!eldbus_message_arguments_get(msg, "b", &accepted))
+     {
+        ERR("Error on eldbus_message_arguments_get()\n");
+        goto exit_reg_loop;
+     }
+
+   if (!accepted)
+     {
+        ERR("WM rejected the request for register!!(0x%08x)\n", (Ecore_Window)data);
+        goto exit_reg_loop;
+     }
+
+   evas_object_show(_tc_normal_win->obj);
+   evas_object_show(_tc_noti_win1->obj);
+   evas_object_show(_tc_noti_win2->obj);
+
+//   INF("%s (0x%08x)\n", __FUNCTION__, (Ecore_Window)data);
+
+   registered = EINA_TRUE;
+   return;
+
+exit_reg_loop:
+   if (loop_running)
+      elm_exit();
+}
+
+static void
+_notification_level_cb_deregister_window(void *data,
+                                         const Eldbus_Message *msg,
+                                         Eldbus_Pending *pending EINA_UNUSED)
+{
+   const char *errname, *errmsg;
+   Eina_Bool allowed = EINA_TRUE;
+
+   if (eldbus_message_error_get(msg, &errname, &errmsg))
+     {
+        ERR("%s %s\n", errname, errmsg);
+        goto exit_dereg_loop;
+     }
+
+   if (!eldbus_message_arguments_get(msg, "b", &allowed))
+     {
+        ERR("Error on eldbus_message_arguments_get()\n");
+        goto exit_dereg_loop;
+     }
+
+   if (allowed)
+      goto exit_dereg_loop;
+
+   registered = EINA_FALSE;
+   return;
+
+exit_dereg_loop:
+   if (loop_running)
+      elm_exit();
+}
+
+static void
+_notification_level_cb_change_visibility(void *data,
+                                         const Eldbus_Message *msg)
+{
+   const char *errname, *errmsg;
+   Eina_Bool visible;
+   Ecore_Window win;
+
+   if (eldbus_message_error_get(msg, &errname, &errmsg))
+      ERR("%s %s", errname, errmsg);
+
+   if (!eldbus_message_arguments_get(msg, "ub", &win, &visible))
+      ERR("Error on eldbus_message_arguments_get()\n");
+
+   if ((Ecore_Window)data != win) return;
+
+   if (loop_running)
+      elm_exit();
+}
+
+static Eina_Bool
+_notification_level_visibility_change_wait(E_Test_Case *tc, E_TC_Win *tc_win)
+{
+   Eldbus_Signal_Handler *handler;
+
+   handler = eldbus_proxy_signal_handler_add(dbus_proxy, "ChangeVisibility",
+                                             _notification_level_cb_change_visibility,
+                                             (void*)(uintptr_t)tc_win->win);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(handler, EINA_FALSE);
+
+   loop_running = EINA_TRUE;
+   elm_run();
+
+   eldbus_signal_handler_del(handler);
+
+   return EINA_TRUE;
+}
+
+static Eina_Bool
+_notification_level_windows_show(E_Test_Case *tc)
+{
+   Eldbus_Pending *ret;
+
+   ret = eldbus_proxy_call(dbus_proxy,
+                           "RegisterWindow",
+                           _notification_level_cb_register_window,
+                           (void*)(uintptr_t)_tc_normal_win->win,
+                           -1, "u", _tc_normal_win->win);
+   EINA_SAFETY_ON_NULL_RETURN_VAL(ret, EINA_FALSE);
+
+   _notification_level_visibility_change_wait(tc, _tc_normal_win);
+
+   EINA_SAFETY_ON_FALSE_RETURN_VAL(registered, EINA_FALSE);
+
+   return EINA_TRUE;
+}
+
+static void
+_notification_level_windows_hide(E_Test_Case *tc)
+{
+   if (!registered) return;
+   if (!eldbus_proxy_call(dbus_proxy,
+                          "DeregisterWindow", _notification_level_cb_deregister_window,
+                          (void*)(uintptr_t)_tc_normal_win->win,
+                          -1, "u", _tc_normal_win->win))
+      return;
+
+   _notification_level_visibility_change_wait(tc, _tc_normal_win);
+}
+
+static void
+_notification_level_windows_destroy(E_Test_Case *tc)
+{
+   if (_tc_noti_win2)
+     {
+        evas_object_hide(_tc_noti_win2->obj);
+        evas_object_del(_tc_noti_win2->obj);
+        E_FREE(_tc_noti_win2);
+     }
+   if (_tc_noti_win1)
+     {
+        evas_object_hide(_tc_noti_win1->obj);
+        evas_object_del(_tc_noti_win1->obj);
+        E_FREE(_tc_noti_win1);
+     }
+   if (_tc_normal_win)
+     {
+        evas_object_hide(_tc_normal_win->obj);
+        evas_object_del(_tc_normal_win->obj);
+        E_FREE(_tc_normal_win);
+     }
+}
+
+static Eina_Bool
+_notification_level_windows_create(E_Test_Case *tc)
+{
+   if (!_tc_normal_win)
+     {
+        Evas_Object *bg;
+
+        _tc_normal_win = E_NEW(E_TC_Win, 1);
+        EINA_SAFETY_ON_NULL_GOTO(_tc_normal_win, create_fail);
+
+        _tc_normal_win->obj = elm_win_add(NULL, "_tc_normal_win", ELM_WIN_BASIC);
+        _tc_normal_win->win = elm_win_xwindow_get(_tc_normal_win->obj);
+        elm_win_title_set(_tc_normal_win->obj, "_tc_normal_win");
+        elm_win_autodel_set(_tc_normal_win->obj, EINA_FALSE);
+
+        bg = elm_bg_add(_tc_normal_win->obj);
+        evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+        elm_win_resize_object_add(_tc_normal_win->obj, bg);
+        elm_bg_color_set(bg, 0xff, 0, 0);
+        evas_object_show(bg);
+     }
+
+   if (!_tc_noti_win1)
+     {
+        Evas_Object *bg;
+
+        _tc_noti_win1 = E_NEW(E_TC_Win, 1);
+        EINA_SAFETY_ON_NULL_GOTO(_tc_noti_win1, create_fail);
+
+        _tc_noti_win1->obj = elm_win_add(NULL, "_tc_noti_win1", ELM_WIN_NOTIFICATION);
+        _tc_noti_win1->win = elm_win_xwindow_get(_tc_noti_win1->obj);
+        elm_win_title_set(_tc_noti_win1->obj, "_tc_noti_win1");
+        elm_win_autodel_set(_tc_noti_win1->obj, EINA_FALSE);
+
+        bg = elm_bg_add(_tc_noti_win1->obj);
+        evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+        elm_win_resize_object_add(_tc_noti_win1->obj, bg);
+        elm_bg_color_set(bg, 0, 0, 0xff);
+        evas_object_show(bg);
+     }
+
+   if (!_tc_noti_win2)
+     {
+        Evas_Object *bg;
+
+        _tc_noti_win2 = E_NEW(E_TC_Win, 1);
+        EINA_SAFETY_ON_NULL_GOTO(_tc_noti_win2, create_fail);
+
+        _tc_noti_win2->obj = elm_win_add(NULL, "_tc_noti_win2", ELM_WIN_NOTIFICATION);
+        _tc_noti_win2->win = elm_win_xwindow_get(_tc_noti_win2->obj);
+        elm_win_title_set(_tc_noti_win2->obj, "_tc_noti_win2");
+        elm_win_autodel_set(_tc_noti_win2->obj, EINA_FALSE);
+
+        bg = elm_bg_add(_tc_noti_win2->obj);
+        evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+        elm_win_resize_object_add(_tc_noti_win2->obj, bg);
+        elm_bg_color_set(bg, 0, 0, 0xff);
+        evas_object_show(bg);
+     }
+
+   return EINA_TRUE;
+
+create_fail:
+   _notification_level_windows_destroy(tc);
+
+   return EINA_FALSE;
+}
+
+static void
+_notification_level_tc_finish(E_Test_Case *tc)
+{
+   _notification_level_windows_destroy(tc);
+
+   registered = EINA_FALSE;
+}
+
+static Eina_Bool
+_notification_level_tc_prepare(E_Test_Case *tc)
+{
+   if (!_notification_level_windows_create(tc)) return EINA_FALSE;
+
+   registered = EINA_FALSE;
+
+   return EINA_TRUE;
+}
+
+static Eina_Bool
+_notification_level_check_stack(E_Test_Case *tc,
+                                E_TC_Win *bottom,
+                                E_TC_Win *middle,
+                                E_TC_Win *top)
+{
+   E_TC_Data tc_data = {0,};
+   E_TC_Client *client = NULL;
+   Eina_List *l;
+   int t_layer = 0, m_layer = 0, b_layer = 0;
+
+   e_test_case_util_get_clients(&tc_data);
+
+   EINA_LIST_FOREACH(tc_data.clients, l, client)
+     {
+        if (top->win == client->win)
+        {
+           t_layer = client->layer;
+           continue;
+        }
+        else if (middle->win == client->win)
+        {
+           m_layer = client->layer;
+           continue;
+        }
+        else if (bottom->win == client->win)
+        {
+           b_layer = client->layer;
+           continue;
+        }
+     }
+
+   if (b_layer < m_layer && m_layer < t_layer)
+      return EINA_TRUE;
+
+   return EINA_FALSE;
+}
+
+Eina_Bool
+test_case_0120_notification_level(E_Test_Case *tc)
+{
+   Eina_Bool passed = EINA_TRUE;
+
+   passed = passed && e_test_case_inner_do(tc);
+
+   return passed;
+}
+
+Eina_Bool
+test_case_0121_notification_level_1(E_Test_Case *tc)
+{
+   efl_util_notification_level_e level = -1;
+   int ret;
+   Eina_Bool result = EINA_FALSE;
+
+   EINA_SAFETY_ON_NULL_GOTO(tc, test_shutdown);
+
+   if (!_notification_level_tc_prepare(tc)) goto test_shutdown;
+
+   ret = efl_util_set_notification_window_level(_tc_noti_win1->obj,
+                                                EFL_UTIL_NOTIFICATION_LEVEL_1);
+   EINA_SAFETY_ON_FALSE_GOTO(ret == EFL_UTIL_ERROR_NONE, test_shutdown);
+
+   ret = efl_util_get_notification_window_level(_tc_noti_win1->obj, &level);
+   EINA_SAFETY_ON_FALSE_GOTO(ret == EFL_UTIL_ERROR_NONE, test_shutdown);
+   EINA_SAFETY_ON_FALSE_GOTO(level == EFL_UTIL_NOTIFICATION_LEVEL_1, test_shutdown);
+
+   if (!_notification_level_windows_show(tc)) goto test_shutdown;
+
+   result = _notification_level_check_stack (tc, _tc_normal_win, _tc_noti_win2, _tc_noti_win1);
+   EINA_SAFETY_ON_FALSE_GOTO(result, test_shutdown);
+
+test_shutdown:
+   _notification_level_windows_hide(tc);
+   _notification_level_tc_finish(tc);
+
+   return result;
+}
+
+Eina_Bool
+test_case_0122_notification_level_2(E_Test_Case *tc)
+{
+   efl_util_notification_level_e level = -1;
+   int ret;
+   Eina_Bool result = EINA_FALSE;
+
+   EINA_SAFETY_ON_NULL_GOTO(tc, test_shutdown);
+
+   if (!_notification_level_tc_prepare(tc)) goto test_shutdown;
+
+   ret = efl_util_set_notification_window_level(_tc_noti_win1->obj,
+                                                EFL_UTIL_NOTIFICATION_LEVEL_2);
+   EINA_SAFETY_ON_FALSE_GOTO(ret == EFL_UTIL_ERROR_NONE, test_shutdown);
+
+   ret = efl_util_get_notification_window_level(_tc_noti_win1->obj, &level);
+   EINA_SAFETY_ON_FALSE_GOTO(ret == EFL_UTIL_ERROR_NONE, test_shutdown);
+   EINA_SAFETY_ON_FALSE_GOTO(level == EFL_UTIL_NOTIFICATION_LEVEL_2, test_shutdown);
+
+   if (!_notification_level_windows_show(tc)) goto test_shutdown;
+
+   result = _notification_level_check_stack (tc, _tc_normal_win, _tc_noti_win2, _tc_noti_win1);
+   EINA_SAFETY_ON_FALSE_GOTO(result, test_shutdown);
+
+test_shutdown:
+   _notification_level_windows_hide(tc);
+   _notification_level_tc_finish(tc);
+
+   return result;
+}
+
+Eina_Bool
+test_case_0123_notification_level_3(E_Test_Case *tc)
+{
+   efl_util_notification_level_e level = -1;
+   int ret;
+   Eina_Bool result = EINA_FALSE;
+
+   EINA_SAFETY_ON_NULL_GOTO(tc, test_shutdown);
+
+   if (!_notification_level_tc_prepare(tc)) goto test_shutdown;
+
+   ret = efl_util_set_notification_window_level(_tc_noti_win1->obj,
+                                                EFL_UTIL_NOTIFICATION_LEVEL_3);
+   EINA_SAFETY_ON_FALSE_GOTO(ret == EFL_UTIL_ERROR_NONE, test_shutdown);
+
+   ret = efl_util_get_notification_window_level(_tc_noti_win1->obj, &level);
+   EINA_SAFETY_ON_FALSE_GOTO(ret == EFL_UTIL_ERROR_NONE, test_shutdown);
+   EINA_SAFETY_ON_FALSE_GOTO(level == EFL_UTIL_NOTIFICATION_LEVEL_3, test_shutdown);
+
+   if (!_notification_level_windows_show(tc)) goto test_shutdown;
+
+   result = _notification_level_check_stack (tc, _tc_normal_win, _tc_noti_win2, _tc_noti_win1);
+   EINA_SAFETY_ON_FALSE_GOTO(result, test_shutdown);
+
+test_shutdown:
+   _notification_level_windows_hide(tc);
+   _notification_level_tc_finish(tc);
+
+   return result;
+}
+
+Eina_Bool
+test_case_0124_notification_level_change(E_Test_Case *tc)
+{
+   int ret;
+   Eina_Bool result = EINA_FALSE;
+
+   EINA_SAFETY_ON_NULL_GOTO(tc, test_shutdown);
+
+   if (!_notification_level_tc_prepare(tc)) goto test_shutdown;
+
+   ret = efl_util_set_notification_window_level(_tc_noti_win2->obj,
+                                                EFL_UTIL_NOTIFICATION_LEVEL_2);
+   EINA_SAFETY_ON_FALSE_GOTO(ret == EFL_UTIL_ERROR_NONE, test_shutdown);
+
+   ret = efl_util_set_notification_window_level(_tc_noti_win1->obj,
+                                                EFL_UTIL_NOTIFICATION_LEVEL_3);
+   EINA_SAFETY_ON_FALSE_GOTO(ret == EFL_UTIL_ERROR_NONE, test_shutdown);
+
+   if (!_notification_level_windows_show(tc)) goto test_shutdown;
+
+   result = _notification_level_check_stack (tc, _tc_normal_win, _tc_noti_win2, _tc_noti_win1);
+   EINA_SAFETY_ON_FALSE_GOTO(result, test_shutdown);
+
+   ret = efl_util_set_notification_window_level(_tc_noti_win1->obj,
+                                                EFL_UTIL_NOTIFICATION_LEVEL_1);
+   EINA_SAFETY_ON_FALSE_GOTO(ret == EFL_UTIL_ERROR_NONE, test_shutdown);
+
+   result = _notification_level_check_stack (tc, _tc_normal_win, _tc_noti_win1, _tc_noti_win2);
+   EINA_SAFETY_ON_FALSE_GOTO(result, test_shutdown);
+
+test_shutdown:
+   _notification_level_windows_hide(tc);
+   _notification_level_tc_finish(tc);
+
+   return result;
+}
index bce50e8..a19a07d 100644 (file)
@@ -23,7 +23,8 @@ e_test_case_util.h \
 0111_transient_for_raise.c \
 0112_transient_for_lower.c \
 0113_transient_for_stack_above.c \
-0114_transient_for_stack_below.c
+0114_transient_for_stack_below.c \
+0120_notification_level.c
 
 MAINTAINERCLEANFILES = \
 Makefile.in
index 0d496ab..4268831 100644 (file)
@@ -86,6 +86,12 @@ _e_test_case_setup(void)
    ADD_INNER_TCS(T, 113, T_FUNC(113, transient_for_stack_above), "Transient For Stack Above", 1, 0);
    ADD_INNER_TCS(T, 114, T_FUNC(114, transient_for_stack_below), "Transient For STack Below", 1, 0);
 
+   ADD_TEST_CASE(T, 120, T_FUNC(120, notification_level), "Noti Level", 1, 0);
+   ADD_INNER_TCS(T, 121, T_FUNC(121, notification_level_1), "Noti Level 1", 1, 0);
+   ADD_INNER_TCS(T, 122, T_FUNC(122, notification_level_2), "Noti Level 2", 1, 0);
+   ADD_INNER_TCS(T, 123, T_FUNC(123, notification_level_3), "Noti Level 3", 1, 0);
+   ADD_INNER_TCS(T, 124, T_FUNC(124, notification_level_change), "Noti Level Change", 1, 0);
+
    /* [0200 - 0299] E_TEST_CASE_TYPE_WIN_ALPHA */
 #undef T
 #define T E_TEST_CASE_TYPE_WIN_ALPHA
index c4b62f9..deafd49 100644 (file)
@@ -82,6 +82,13 @@ Eina_Bool test_case_0112_transient_for_lower(E_Test_Case *tc);
 Eina_Bool test_case_0113_transient_for_stack_above(E_Test_Case *tc);
 Eina_Bool test_case_0114_transient_for_stack_below(E_Test_Case *tc);
 
+//notification_level
+Eina_Bool test_case_0120_notification_level(E_Test_Case *tc);
+Eina_Bool test_case_0121_notification_level_1(E_Test_Case *tc);
+Eina_Bool test_case_0122_notification_level_2(E_Test_Case *tc);
+Eina_Bool test_case_0123_notification_level_3(E_Test_Case *tc);
+Eina_Bool test_case_0124_notification_level_change(E_Test_Case *tc);
+
 /* 0200 - 0299 */
 /* 0300 - 9999 */
 
index 13ceecb..2f0abe8 100644 (file)
@@ -13,12 +13,14 @@ _method_cb_get_clients(void *data EINA_UNUSED, const Eldbus_Message *msg, Eldbus
    if (eldbus_message_error_get(msg, &errname, &errmsg))
      {
         ERR("%s %s", errname, errmsg);
+        elm_exit();
         return;
      }
 
    if (!eldbus_message_arguments_get(msg, "ua(usiiiiibb)", &target_win, &array_of_ec))
      {
         ERR("Error on eldbus_message_arguments_get()\n");
+        elm_exit();
         return;
      }