[ut] tests of methods: - ewk_view_popup_menu_close - ewk_view_popup_menu_select
authorLukasz Gajowy <l.gajowy@samsung.com@samsung.com>
Thu, 4 Apr 2013 12:34:35 +0000 (14:34 +0200)
committerGerrit Code Review <gerrit2@kim11>
Fri, 5 Apr 2013 08:53:16 +0000 (17:53 +0900)
Change-Id: Ie7c4ae1033256fb4e41b2b7446e6504de5331bcc

TC/unit_test/webkit2/Makefile
TC/unit_test/webkit2/tslist
TC/unit_test/webkit2/utc_webkit2_ewk_view_popup_menu_close_func.c [new file with mode: 0644]
TC/unit_test/webkit2/utc_webkit2_ewk_view_popup_menu_select_func.c [new file with mode: 0644]

index feda66d..8318ce7 100644 (file)
@@ -167,6 +167,8 @@ TARGETS = \
           utc_webkit2_ewk_view_page_get_func \
           utc_webkit2_ewk_view_page_visibility_state_set_func \
           utc_webkit2_ewk_view_plain_text_get_func \
+          utc_webkit2_ewk_view_popup_menu_close_func \
+          utc_webkit2_ewk_view_popup_menu_select_func \
           utc_webkit2_ewk_view_reload_bypass_cache_func \
           utc_webkit2_ewk_view_reload_func \
           utc_webkit2_ewk_view_resume_func \
index c3783f8..eda5fcf 100644 (file)
 /unit_test/webkit2/utc_webkit2_ewk_view_page_get_func
 /unit_test/webkit2/utc_webkit2_ewk_view_page_visibility_state_set_func
 /unit_test/webkit2/utc_webkit2_ewk_view_plain_text_get_func
+/unit_test/webkit2/utc_webkit2_ewk_view_popup_menu_close_func
+/unit_test/webkit2/utc_webkit2_ewk_view_popup_menu_select_func
 /unit_test/webkit2/utc_webkit2_ewk_view_reload_bypass_cache_func
 /unit_test/webkit2/utc_webkit2_ewk_view_reload_func
 /unit_test/webkit2/utc_webkit2_ewk_view_resume_func
diff --git a/TC/unit_test/webkit2/utc_webkit2_ewk_view_popup_menu_close_func.c b/TC/unit_test/webkit2/utc_webkit2_ewk_view_popup_menu_close_func.c
new file mode 100644 (file)
index 0000000..78ce2c0
--- /dev/null
@@ -0,0 +1,164 @@
+/*
+ * WebKit2 EFL
+ *
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd.
+ *
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+/**
+ * @file utc_webkit2_ewk_popup_menu_close_func.c
+ * @author Lukasz Gajowy <l.gajowy@samsung.com>
+ * @date 2013-03-27
+ * @brief Tests EWK function ewk_view_popup_menu_close(Evas_Object *o)
+ */
+
+#define TESTED_FUN_NAME "ewk_view_popup_menu_close"
+#define POS_STRING_FAIL "failed in positive test case"
+#define NEG_STRING_FAIL "failed in negative test case"
+
+#include <Ecore_Evas.h>
+#include <Ecore.h>
+#include <Elementary.h>
+#include <EWebKit2.h>
+#include <tet_api.h>
+
+static Evas_Object* webview;
+static Evas_Object* window;
+static Evas_Smart* evasSmartClass;
+static Ewk_View_Smart_Class ewkViewSmartClass;
+static Ecore_Timer* timer;
+
+static const unsigned xClick = 46;
+static const unsigned yClick = 19;
+static const double timeout = 2;
+static const char selectHTML[] =
+        "<body>"
+        "<select>"
+        "<option>one</option>"
+        "</select>"
+        "</body>";
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utcWebkit2EwkWiewPopupMenuClosePositive(void);
+static void utcWebkit2EwkWiewPopupMenuCloseNegative(void);
+
+enum {
+    POSITIVE_TC_IDX = 1,
+    NEGATIVE_TC_IDX
+};
+
+struct tet_testlist tet_testlist[] = {
+    {utcWebkit2EwkWiewPopupMenuClosePositive, POSITIVE_TC_IDX},
+    {utcWebkit2EwkWiewPopupMenuCloseNegative, NEGATIVE_TC_IDX},
+    {NULL, 0}
+};
+
+static Ewk_View_Smart_Class smartClass()
+{
+    static Ewk_View_Smart_Class smart = EWK_VIEW_SMART_CLASS_INIT_NAME_VERSION("tcwebkit2");
+    return smart;
+}
+
+static void onLoadFinished(void* data, Evas_Object* obj, void* eventInfo)
+{
+    tet_infoline("====== onLoadFinished ======\n");
+    ecore_main_loop_quit();
+}
+
+static void startup(void)
+{
+    tet_infoline("====== startup ======\n");
+
+    g_type_init();
+    elm_init(0, NULL);
+
+    elm_config_preferred_engine_set("opengl_x11");
+
+    window = elm_win_add(NULL, "TC Launcher", ELM_WIN_BASIC);
+    elm_win_title_set(window, "TC Launcher");
+    evas_object_show(window);
+
+    Evas *evas = evas_object_evas_get(window);
+
+    ewkViewSmartClass = smartClass();
+    ewk_view_smart_class_set(&ewkViewSmartClass);
+    evasSmartClass = evas_smart_class_new(&ewkViewSmartClass.sc);
+    Ewk_Context *context = ewk_context_default_get();
+    webview = ewk_view_smart_add(evas, evasSmartClass, context);
+
+    evas_object_resize(webview, 800, 600);
+    evas_object_show(webview);
+
+    evas_object_smart_callback_add(webview, "load,finished", onLoadFinished, 0);
+}
+
+static void cleanup(void)
+{
+    evas_object_smart_callback_del(webview, "load,finished", onLoadFinished);
+    evas_smart_free(evasSmartClass);
+    evas_object_del(webview);
+}
+
+static void mouseClick(int x, int y)
+{
+    Evas *evas = evas_object_evas_get(window);
+    evas_event_feed_mouse_move(evas, x, y, 0, 0);
+    evas_event_feed_mouse_down(evas, 1, EVAS_BUTTON_NONE, 0, 0);
+    evas_event_feed_mouse_up(evas, 1, EVAS_BUTTON_NONE, 0, 0);
+}
+
+static Eina_Bool onTimeout(void* data)
+{
+    ecore_main_loop_quit();
+    return ECORE_CALLBACK_CANCEL;
+}
+
+static Eina_Bool popupMenuShow(Ewk_View_Smart_Data *sd, Eina_Rectangle rect, Ewk_Text_Direction text_direction, double page_scale_factor, Eina_List* items, int selected_index)
+{
+    tet_infoline("====== popup_menu_show ======\n");
+    Eina_Bool result = ewk_view_popup_menu_close(webview);
+    dts_check_eq(TESTED_FUN_NAME, result, EINA_TRUE, POS_STRING_FAIL);
+    ecore_main_loop_quit();
+    ecore_timer_delete(timer);
+    return EINA_TRUE;
+}
+
+/*
+ * @brief Checking whether popup menu is closed properly.
+ */
+static void utcWebkit2EwkWiewPopupMenuClosePositive(void)
+{
+    ewkViewSmartClass.popup_menu_show = popupMenuShow;
+    ewk_view_html_string_load(webview, selectHTML, 0, 0);
+    ecore_main_loop_begin();
+    mouseClick(xClick, yClick);
+    timer = ecore_timer_add(timeout, onTimeout, 0);
+    ecore_main_loop_begin();
+}
+
+/**
+* @brief Checking whether function works properly in case of a null Evas_Object given as an argument.
+*/
+static void utcWebkit2EwkWiewPopupMenuCloseNegative(void)
+{
+    dts_check_eq(TESTED_FUN_NAME, ewk_view_popup_menu_close(0), EINA_FALSE, NEG_STRING_FAIL);
+}
diff --git a/TC/unit_test/webkit2/utc_webkit2_ewk_view_popup_menu_select_func.c b/TC/unit_test/webkit2/utc_webkit2_ewk_view_popup_menu_select_func.c
new file mode 100644 (file)
index 0000000..d1570df
--- /dev/null
@@ -0,0 +1,188 @@
+/*
+ * Webkit2 EFL
+ *
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd.
+ *
+ * This library is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU Lesser General Public License as published by the
+ * Free Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library; if not, write to the Free Software Foundation, Inc., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+/**
+ * @file utc_webkit2_ewk_popup_menu_select_func.c
+ * @author Lukasz Gajowy <l.gajowy@samsung.com>
+ * @date 2013-03-27
+ * @brief Tests EWK function ewk_view_popup_menu_select(Evas_Object *o, unsigned int index)
+ */
+
+#define TESTED_FUN_NAME "ewk_view_popup_menu_select"
+#define POS_STRING_FAIL "failed in positive test case"
+#define NEG_STRING_FAIL "failed in negative test case"
+
+#include <Ecore_Evas.h>
+#include <Ecore.h>
+#include <Elementary.h>
+#include <EWebKit2.h>
+#include <tet_api.h>
+
+static Evas_Object* webview;
+static Evas_Object* window;
+static Evas_Smart* evasSmartClass;
+static Ewk_View_Smart_Class ewkViewSmartClass;
+static Ecore_Timer* timer;
+
+static const unsigned xClick = 46;
+static const unsigned yClick = 19;
+static const double timeout = 2;
+static const char selectHTML[] =
+        "<body>"
+        "<select>"
+        "<option>one</option>"
+        "</select>"
+        "</body>";
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void EwkWiewPopupMenuSelectPositive(void);
+static void EwkWiewPopupMenuSelectNegative1(void);
+static void EwkWiewPopupMenuSelectNegative2(void);
+
+enum {
+    POSITIVE_TC_IDX = 1,
+    NEGATIVE_TC_IDX
+};
+
+struct tet_testlist tet_testlist[] = {
+    {EwkWiewPopupMenuSelectPositive, POSITIVE_TC_IDX},
+    {EwkWiewPopupMenuSelectNegative1, NEGATIVE_TC_IDX},
+    {EwkWiewPopupMenuSelectNegative2, NEGATIVE_TC_IDX},
+    {NULL, 0}
+};
+
+static Ewk_View_Smart_Class smartClass()
+{
+    static Ewk_View_Smart_Class smart = EWK_VIEW_SMART_CLASS_INIT_NAME_VERSION("tcwebkit2");
+    return smart;
+}
+
+static void onLoadFinished(void* data, Evas_Object* obj, void* eventInfo)
+{
+    tet_infoline("====== onLoadFinished ======\n");
+    ecore_main_loop_quit();
+}
+
+static void startup(void)
+{
+    tet_infoline("====== startup ======\n");
+    g_type_init();
+    elm_init(0, NULL);
+
+    elm_config_preferred_engine_set("opengl_x11");
+
+    window = elm_win_add(NULL, "TC Launcher", ELM_WIN_BASIC);
+    elm_win_title_set(window, "TC Launcher");
+    evas_object_show(window);
+
+    Evas *evas = evas_object_evas_get(window);
+
+    ewkViewSmartClass = smartClass();
+    ewk_view_smart_class_set(&ewkViewSmartClass);
+    evasSmartClass = evas_smart_class_new(&ewkViewSmartClass.sc);
+    Ewk_Context *context = ewk_context_default_get();
+    webview = ewk_view_smart_add(evas, evasSmartClass, context);
+
+    evas_object_resize(webview, 800, 600);
+    evas_object_show(webview);
+
+    evas_object_smart_callback_add(webview, "load,finished", onLoadFinished, 0);
+}
+
+static void cleanup(void)
+{
+    evas_object_smart_callback_del(webview, "load,finished", onLoadFinished);
+    evas_smart_free(evasSmartClass);
+    evas_object_del(webview);
+}
+
+static void mouseClick(int x, int y)
+{
+    Evas *evas = evas_object_evas_get(window);
+    evas_event_feed_mouse_move(evas, x, y, 0, 0);
+    evas_event_feed_mouse_down(evas, 1, EVAS_BUTTON_NONE, 0, 0);
+    evas_event_feed_mouse_up(evas, 1, EVAS_BUTTON_NONE, 0, 0);
+}
+
+static Eina_Bool onTimeout(void* data)
+{
+    ecore_main_loop_quit();
+    return ECORE_CALLBACK_CANCEL;
+}
+
+static Eina_Bool popupMenuShow(Ewk_View_Smart_Data *sd, Eina_Rectangle rect, Ewk_Text_Direction text_direction, double page_scale_factor, Eina_List* items, int selected_index)
+{
+    tet_infoline("====== popup_menu_show ======\n");
+    Eina_Bool result =  ewk_view_popup_menu_select(webview, 0);
+    dts_check_eq(TESTED_FUN_NAME, result, EINA_TRUE, POS_STRING_FAIL);
+    ecore_main_loop_quit();
+    ecore_timer_delete(timer);
+    return EINA_TRUE;
+}
+
+static Eina_Bool popupMenuShowWrongIndex(Ewk_View_Smart_Data *sd, Eina_Rectangle rect, Ewk_Text_Direction text_direction, double page_scale_factor, Eina_List* items, int selected_index)
+{
+    tet_infoline("====== popup_menu_show_wrong_index======\n");
+    Eina_Bool result =  ewk_view_popup_menu_select(webview, 1);
+    dts_check_eq(TESTED_FUN_NAME, result, EINA_FALSE, NEG_STRING_FAIL);
+    ecore_main_loop_quit();
+    ecore_timer_delete(timer);
+    return EINA_TRUE;
+}
+
+/**
+ * @brief Checking whether popup menu is selected properly.
+ */
+static void EwkWiewPopupMenuSelectPositive(void)
+{
+    ewkViewSmartClass.popup_menu_show = popupMenuShow;
+    ewk_view_html_string_load(webview, selectHTML, 0, 0);
+    ecore_main_loop_begin();
+    mouseClick(xClick, yClick);
+    timer = ecore_timer_add(timeout, onTimeout, 0);
+    ecore_main_loop_begin();
+}
+
+/**
+ * @brief Checking whether function works properly in case of a null Evas_Object given as an argument.
+ */
+static void EwkWiewPopupMenuSelectNegative1(void)
+{
+    dts_check_eq(TESTED_FUN_NAME, ewk_view_popup_menu_select(0, 0), EINA_FALSE, NEG_STRING_FAIL);
+}
+
+/**
+ * @brief Checking whether function works properly in case of a wrong index given as an argument.
+ */
+static void EwkWiewPopupMenuSelectNegative2(void)
+{
+    ewkViewSmartClass.popup_menu_show = popupMenuShowWrongIndex;
+    ewk_view_html_string_load(webview, selectHTML, 0, 0);
+    ecore_main_loop_begin();
+    mouseClick(xClick, yClick);
+    timer = ecore_timer_add(timeout, onTimeout, 0);
+    ecore_main_loop_begin();
+}