Make TC for ewk_view_feed_touch_event().
authorEunmi Lee <eunmi15.lee@samsung.com>
Fri, 22 Mar 2013 02:25:29 +0000 (11:25 +0900)
committerEunmi Lee <eunmi15.lee@samsung.com>
Tue, 26 Mar 2013 07:39:38 +0000 (16:39 +0900)
[Title] Make TC for ewk_view_feed_touch_event().
[Issue#] N/A
[Problem] TC for ewk_view_feed_touch_event() does not exist.
[Cause] None.
[Solution] Make TC for ewk_view_feed_touch_event().

Change-Id: I9f110aa137dbea982a9b08e3961c7847224b650d

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

index 85075d2..a7abff1 100644 (file)
@@ -141,6 +141,7 @@ TARGETS = \
           utc_webkit2_ewk_view_contents_size_get_func \
           utc_webkit2_ewk_view_context_get_func \
           utc_webkit2_ewk_view_custom_header_add_func \
+          utc_webkit2_ewk_view_feed_touch_event_func \
           utc_webkit2_ewk_view_focused_frame_get_func \
           utc_webkit2_ewk_view_forward_func \
           utc_webkit2_ewk_view_forward_possible_func \
index e068cf9..79a2393 100644 (file)
 /unit_test/webkit2/utc_webkit2_ewk_view_contents_size_get_func
 /unit_test/webkit2/utc_webkit2_ewk_view_context_get_func
 /unit_test/webkit2/utc_webkit2_ewk_view_custom_header_add_func
+/unit_test/webkit2/utc_webkit2_ewk_view_feed_touch_event_func
 /unit_test/webkit2/utc_webkit2_ewk_view_focused_frame_get_func
 /unit_test/webkit2/utc_webkit2_ewk_view_forward_func
 /unit_test/webkit2/utc_webkit2_ewk_view_forward_possible_func
diff --git a/TC/unit_test/webkit2/utc_webkit2_ewk_view_feed_touch_event_func.c b/TC/unit_test/webkit2/utc_webkit2_ewk_view_feed_touch_event_func.c
new file mode 100644 (file)
index 0000000..33218d1
--- /dev/null
@@ -0,0 +1,147 @@
+/*
+ * WebKit2 EFL
+ *
+ * Copyright (c) 2012 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
+ *
+ */
+
+/* Define those macros _before_ you include the utc_webkit2_ewk.h header file. */
+#define TESTED_FUN_NAME ewk_view_feed_touch_event
+#define POSITIVE_TEST_FUN_NUM 2
+#define NEGATIVE_TEST_FUN_NUM 1
+
+#include "utc_webkit2_ewk.h"
+#include "ewk_touch.h"
+
+#ifndef NULL
+#define NULL 0x0
+#endif
+
+#define RESOURCE_PATH "/ewk_view/index_big_red_square.html"
+
+static void loadFinished(void* data, Evas_Object* eObject, void* dataFinished)
+{
+    utc_message("[loadFinished] :: \n");
+}
+
+/* Callback for load error */
+static void loadError(void* data, Evas_Object* webview, void* event_info)
+{
+    utc_message("[load_error] :: \n");
+    utc_webkit2_main_loop_quit();
+
+    utc_fail();
+}
+
+static void frameRendered(void* data, Evas_Object* eObject, void* dataFinished)
+{
+    utc_message("[frameRendered] :: \n");
+    utc_webkit2_main_loop_quit();
+}
+
+static void startup(void)
+{
+    utc_webkit2_ewk_test_init();
+    evas_object_smart_callback_add(test_view.webview, "load,finished", loadFinished, NULL);
+    evas_object_smart_callback_add(test_view.webview, "load,error", loadError, NULL);
+    evas_object_smart_callback_add(test_view.webview, "frame,rendered", frameRendered, NULL);
+}
+
+static void cleanup(void)
+{
+    evas_object_smart_callback_del(test_view.webview, "load,finished", loadFinished);
+    evas_object_smart_callback_del(test_view.webview, "load,error", loadError);
+    evas_object_smart_callback_del(test_view.webview, "frame,rendered", frameRendered);
+    utc_webkit2_ewk_test_end();
+}
+
+static void loadURL(const char* url)
+{
+    char* full_path = generate_full_resource_path(url);
+    if (!full_path)
+        utc_fail();
+
+    Eina_Bool result = ewk_view_url_set(test_view.webview, full_path);
+    free(full_path);
+
+    if (!result)
+        utc_fail();
+}
+
+
+/**
+ * @brief Positive test case of ewk_view_feed_touch_event(), testing start of touch.
+ */
+
+POS_TEST_FUN(1)
+{
+    loadURL(RESOURCE_PATH);
+    utc_webkit2_main_loop_begin();
+
+    Eina_List* points = 0;
+    unsigned i = 0;
+    for (i = 0; i < 2; ++i) {
+        Ewk_Touch_Point* point = (Ewk_Touch_Point*)calloc(sizeof(Ewk_Touch_Point), 1);
+        point->id = i;
+        point->x = 10;
+        point->y = 10;
+        point->state = EVAS_TOUCH_POINT_DOWN;
+        points = eina_list_append(points, point);
+    }
+
+    Eina_Bool result = ewk_view_feed_touch_event(test_view.webview, EWK_TOUCH_START, points, evas_key_modifier_get(evas_object_evas_get(test_view.webview)));
+
+    void* data;
+    EINA_LIST_FREE(points, data)
+        free((Ewk_Touch_Point*)data);
+
+    utc_check_eq(result, EINA_TRUE);
+}
+
+/**
+ * @brief Positive test case of ewk_view_feed_touch_event(), testing end of touch.
+ */
+
+POS_TEST_FUN(2)
+{
+    Eina_List* points = 0;
+    unsigned i = 0;
+    for (i = 0; i < 2; ++i) {
+        Ewk_Touch_Point* point = (Ewk_Touch_Point*)calloc(sizeof(Ewk_Touch_Point), 1);
+        point->id = i;
+        point->x = 10;
+        point->y = 10;
+        point->state = EVAS_TOUCH_POINT_UP;
+        points = eina_list_append(points, point);
+    }
+
+    Eina_Bool result = ewk_view_feed_touch_event(test_view.webview, EWK_TOUCH_END, points, evas_key_modifier_get(evas_object_evas_get(test_view.webview)));
+
+    void* data;
+    EINA_LIST_FREE(points, data)
+        free((Ewk_Touch_Point*)data);
+
+    utc_check_eq(result, EINA_TRUE);
+}
+
+/**
+ * @brief Negative test case of ewk_view_feed_touch_event(), testing for null
+ */
+NEG_TEST_FUN(1)
+{
+    utc_check_eq(ewk_view_feed_touch_event(0, 0, 0, 0), EINA_FALSE);
+}