[UT] ewk_view_text_find, ewk_view_text_find_highlight
authorKrzysztof Czech <k.czech@samsung.com>
Thu, 4 Apr 2013 07:43:05 +0000 (09:43 +0200)
committerKrzysztof Czech <k.czech@samsung.com>
Thu, 4 Apr 2013 07:57:26 +0000 (09:57 +0200)
Change-Id: I708c7005b5e7c874aa6a3b0eb296b73f042afcbd

Source/WebKit2/UIProcess/API/efl/ewk_view.h
TC/unit_test/webkit2/tslist
TC/unit_test/webkit2/utc_webkit2_ewk_view_text_find_func.c [new file with mode: 0644]
TC/unit_test/webkit2/utc_webkit2_ewk_view_text_find_highlight_clear_func.c [new file with mode: 0644]

index 7153ded..c240161 100755 (executable)
@@ -1497,7 +1497,7 @@ EAPI Eina_Bool    ewk_view_custom_encoding_set(Evas_Object *o, const char *encod
  * Searches and hightlights the given string in the document.
  *
  * @param o view object to find text
- * @param text text to find
+ * @param text text to find, must @b not be @c NULL
  * @param options options to find
  * @param max_match_count maximum match count to find, unlimited if 0
  *
index 105fe25..c3783f8 100644 (file)
 /unit_test/webkit2/utc_webkit2_ewk_view_stop_func
 /unit_test/webkit2/utc_webkit2_ewk_view_string_find_func
 /unit_test/webkit2/utc_webkit2_ewk_view_suspend_func
+/unit_test/webkit2/utc_webkit2_ewk_view_text_find_func
+/unit_test/webkit2/utc_webkit2_ewk_view_text_find_highlight_clear_func
 /unit_test/webkit2/utc_webkit2_ewk_view_text_zoom_get_func
 /unit_test/webkit2/utc_webkit2_ewk_view_text_zoom_set_func
 /unit_test/webkit2/utc_webkit2_ewk_view_theme_get_func
diff --git a/TC/unit_test/webkit2/utc_webkit2_ewk_view_text_find_func.c b/TC/unit_test/webkit2/utc_webkit2_ewk_view_text_find_func.c
new file mode 100644 (file)
index 0000000..73da431
--- /dev/null
@@ -0,0 +1,207 @@
+/*
+ * 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_view_text_find_func.c
+ * @author Krzysztof Czech <k.czech@samsung.com>
+ * @date 2013-03-20
+ * @brief Tests EWK function ewk_view_text_find()
+ */
+
+/* Define those macros _before_ you include the utc_webkit2_ewk.h header file. */
+#define TESTED_FUN_NAME ewk_view_text_find
+#define POSITIVE_TEST_FUN_NUM 7
+#define NEGATIVE_TEST_FUN_NUM 2
+
+#include "utc_webkit2_ewk.h"
+
+static int matchCount = -1;
+
+static const char textHtml[] =
+        "<html>"
+        "<body>"
+        "one one one two two three THREE twoTwo text"
+        "</body>"
+        "</html>";
+
+
+static void onLoadFinished(void* userData, Evas_Object* obj, void* eventInfo)
+{
+    utc_message("=========== onLoadFinished ===========\n");
+    utc_webkit2_main_loop_quit();
+}
+
+static void onTextFound(void* userData, Evas_Object* obj, void* eventInfo)
+{
+    utc_message("\n=========== onFoundText ==============\n");
+    int *result = (int*)userData;
+    unsigned *count = (unsigned*)eventInfo;
+
+    *result = *count;
+}
+
+/* Startup and cleanup functions */
+static void startup(void)
+{
+    utc_webkit2_ewk_test_init();
+    evas_object_smart_callback_add(test_view.webview, "load,finished", onLoadFinished, 0);
+    evas_object_smart_callback_add(test_view.webview, "text,found", onTextFound, &matchCount);
+}
+
+static void cleanup(void)
+{
+    evas_object_smart_callback_del(test_view.webview, "load,finished", onLoadFinished);
+    evas_object_smart_callback_del(test_view.webview, "text,found", onTextFound);
+    utc_webkit2_ewk_test_end();
+}
+
+/**
+* @brief Checking whether correct number of words are returned.
+*
+* No search flags.
+*/
+POS_TEST_FUN(1)
+{
+    ewk_view_html_string_load(test_view.webview, textHtml, 0, 0);
+    utc_webkit2_main_loop_begin();
+
+    ewk_view_text_find(test_view.webview, "one", EWK_FIND_OPTIONS_NONE | EWK_FIND_OPTIONS_SHOW_OVERLAY, 100);
+    while (matchCount < 0)
+        ecore_main_loop_iterate();
+
+    utc_check_eq(matchCount, 3);
+}
+
+/**
+* @brief Checking whether correct number of words are returned.
+*
+* Checking case insensitive searching.
+*/
+POS_TEST_FUN(2)
+{
+    matchCount = -1;
+
+    ewk_view_text_find(test_view.webview, "three", EWK_FIND_OPTIONS_CASE_INSENSITIVE | EWK_FIND_OPTIONS_SHOW_OVERLAY, 100);
+    while (matchCount < 0)
+        ecore_main_loop_iterate();
+
+    utc_check_eq(matchCount, 2);
+}
+
+/**
+* @brief Checking whether correct number of words are returned.
+*
+* Search text only at the beginning of the words
+*/
+POS_TEST_FUN(3)
+{
+    matchCount = -1;
+    ewk_view_text_find(test_view.webview, "two", EWK_FIND_OPTIONS_AT_WORD_STARTS | EWK_FIND_OPTIONS_SHOW_OVERLAY, 100);
+
+    while (matchCount < 0)
+        ecore_main_loop_iterate();
+
+    utc_check_eq(matchCount, 3);
+}
+
+/**
+* @brief Checking whether correct number of words are returned.
+*
+* Treat capital letters in the middle of words as a start word.
+*/
+POS_TEST_FUN(4)
+{
+    matchCount = -1;
+
+    ewk_view_text_find(test_view.webview, "Two", EWK_FIND_OPTIONS_TREAT_MEDIAL_CAPITAL_AS_WORD_START | EWK_FIND_OPTIONS_SHOW_OVERLAY, 100);
+
+    while (matchCount < 0)
+        ecore_main_loop_iterate();
+
+    utc_check_eq(matchCount, 1);
+}
+
+/**
+* @brief Checking whether correct number of words are returned.
+*
+* Search backwards.
+*/
+POS_TEST_FUN(5)
+{
+    matchCount = -1;
+
+    ewk_view_text_find(test_view.webview, "three", EWK_FIND_OPTIONS_BACKWARDS | EWK_FIND_OPTIONS_SHOW_OVERLAY, 100);
+
+    while (matchCount < 0)
+        ecore_main_loop_iterate();
+
+    utc_check_eq(matchCount, 1);
+}
+
+/**
+* @brief Checking whether correct number of words are returned.
+*
+* Show overlay.
+*/
+POS_TEST_FUN(6)
+{
+    matchCount = -1;
+
+    ewk_view_text_find(test_view.webview, "two", EWK_FIND_OPTIONS_SHOW_OVERLAY, 100);
+
+    while (matchCount < 0)
+        ecore_main_loop_iterate();
+
+    utc_check_eq(matchCount, 3);
+}
+
+/**
+* @brief Checking whether correct number of words are returned.
+*
+* Find indicator.
+*/
+POS_TEST_FUN(7)
+{
+    matchCount = -1;
+
+    ewk_view_text_find(test_view.webview, "text", EWK_FIND_OPTIONS_SHOW_FIND_INDICATOR | EWK_FIND_OPTIONS_SHOW_OVERLAY, 100);
+
+    while (matchCount < 0)
+        ecore_main_loop_iterate();
+
+    utc_check_eq(matchCount, 1);
+}
+
+/**
+* @brief Checking whether function returns FALSE in case of NULL of a webview.
+*/
+NEG_TEST_FUN(1)
+{
+    utc_check_eq(ewk_view_text_find(0, "text", EWK_FIND_OPTIONS_SHOW_OVERLAY, 100), EINA_FALSE);
+}
+
+/**
+* @brief Checking whether function returns FALSE in case of NULL of a search text.
+*/
+NEG_TEST_FUN(2)
+{
+    utc_check_eq(ewk_view_text_find(test_view.webview, 0, EWK_FIND_OPTIONS_SHOW_OVERLAY, 100), EINA_FALSE);
+}
diff --git a/TC/unit_test/webkit2/utc_webkit2_ewk_view_text_find_highlight_clear_func.c b/TC/unit_test/webkit2/utc_webkit2_ewk_view_text_find_highlight_clear_func.c
new file mode 100644 (file)
index 0000000..4bcdc4c
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * 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_view_text_find_highlight_clear_func.c
+ * @author Krzysztof Czech <k.czech@samsung.com>
+ * @date 2013-03-20
+ * @brief Tests EWK function ewk_view_text_find_highlight_clear()
+ */
+
+/* Define those macros _before_ you include the utc_webkit2_ewk.h header file. */
+#define TESTED_FUN_NAME ewk_view_text_find_highlight_clear
+#define POSITIVE_TEST_FUN_NUM 1
+#define NEGATIVE_TEST_FUN_NUM 1
+
+#include "utc_webkit2_ewk.h"
+
+/* Startup and cleanup functions */
+static void startup(void)
+{
+    utc_webkit2_ewk_test_init();
+}
+
+static void cleanup(void)
+{
+    utc_webkit2_ewk_test_end();
+}
+
+/**
+* @brief Checking whether function clears text's highlight properly.
+*/
+POS_TEST_FUN(1)
+{
+    utc_check_eq(ewk_view_text_find_highlight_clear(test_view.webview), EINA_TRUE);
+}
+
+/**
+* @brief Checking whether function returns FALSE in case of NULL of a webview.
+*/
+NEG_TEST_FUN(1)
+{
+    utc_check_eq(ewk_view_text_find_highlight_clear(0), EINA_FALSE);
+}