4 * Copyright (c) 2013 Samsung Electronics Co., Ltd.
6 * This library is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU Lesser General Public License as published by the
8 * Free Software Foundation; either version 2.1 of the License, or (at your option)
11 * This library is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 * License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this library; if not, write to the Free Software Foundation, Inc., 51
18 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 * @file utc_webkit2_ewk_view_text_matches_count_func.c
24 * @author Krzysztof Czech <k.czech@samsung.com>
26 * @brief Tests EWK function ewk_view_text_matches_count
29 #define TESTED_FUN_NAME ewk_view_text_matches_count
30 #define POSITIVE_TEST_FUN_NUM 4
31 #define NEGATIVE_TEST_FUN_NUM 2
33 #include "utc_webkit2_ewk.h"
35 static int matchCount = -1;
37 static const char textHtml[] =
40 "one one Two two two three THREE twoTwo text ONE"
44 static void onLoadFinished(void* userData, Evas_Object* obj, void* eventInfo)
46 utc_message("=========== onLoadFinished ===========\n");
47 utc_webkit2_main_loop_quit();
50 static void onTextFound(void* userData, Evas_Object* obj, void* eventInfo)
52 utc_message("\n=========== onTextFound ==============\n");
53 int *result = (int*)userData;
54 unsigned *count = (unsigned*)eventInfo;
59 /* Startup and cleanup functions */
60 static void startup(void)
62 utc_webkit2_ewk_test_init();
63 evas_object_smart_callback_add(test_view.webview, "load,finished", onLoadFinished, 0);
64 evas_object_smart_callback_add(test_view.webview, "text,found", onTextFound, &matchCount);
67 static void cleanup(void)
69 evas_object_smart_callback_del(test_view.webview, "load,finished", onLoadFinished);
70 evas_object_smart_callback_del(test_view.webview, "text,found", onTextFound);
71 utc_webkit2_ewk_test_end();
75 * @brief Checking whether correct number of words are returned.
79 ewk_view_html_string_load(test_view.webview, textHtml, 0, 0);
80 utc_webkit2_main_loop_begin();
82 ewk_view_text_matches_count(test_view.webview, "one", EWK_FIND_OPTIONS_NONE, 100);
83 while (matchCount < 0)
84 ecore_main_loop_iterate();
86 utc_check_eq(matchCount, 2);
90 * @brief Checking whether correct number of words are returned, case insensitive.
96 ewk_view_text_matches_count(test_view.webview, "one", EWK_FIND_OPTIONS_CASE_INSENSITIVE, 100);
97 while (matchCount < 0)
98 ecore_main_loop_iterate();
100 utc_check_eq(matchCount, 3);
104 * @brief Checking whether correct number of words are returned, first occurrence.
110 ewk_view_text_matches_count(test_view.webview, "Two", EWK_FIND_OPTIONS_AT_WORD_STARTS, 100);
111 while (matchCount < 0)
112 ecore_main_loop_iterate();
114 utc_check_eq(matchCount, 1);
118 * @brief Checking whether correct number of words are returned, capital letter at the beginning.
124 ewk_view_text_matches_count(test_view.webview, "Two", EWK_FIND_OPTIONS_TREAT_MEDIAL_CAPITAL_AS_WORD_START, 100);
125 while (matchCount < 0)
126 ecore_main_loop_iterate();
128 utc_check_eq(matchCount, 2);
132 * @brief Checking whether function works properly in case of NULL of a webview.
136 utc_check_eq(ewk_view_text_matches_count(0, "one", EWK_FIND_OPTIONS_NONE, 100), EINA_FALSE);
140 * @brief Checking whether function works properly in case of NULL of a text.
144 utc_check_eq(ewk_view_text_matches_count(test_view.webview, 0, EWK_FIND_OPTIONS_NONE, 100), EINA_FALSE);