Modified: trunk/Source/WebKit2/ChangeLog (152413 => 152414)
--- trunk/Source/WebKit2/ChangeLog 2013-07-05 10:26:42 UTC (rev 152413)
+++ trunk/Source/WebKit2/ChangeLog 2013-07-05 10:29:12 UTC (rev 152414)
@@ -1,3 +1,24 @@
+2013-07-05 Krzysztof Wolanski <[email protected]>
+
+ [EFL][WK2] Implement unit test callbacks: onWordLearn and onWordIgnore.
+ https://bugs.webkit.org/show_bug.cgi?id=118392
+
+ Reviewed by Christophe Dumez.
+
+ Simulate behavior of Learn and Ignore Word in the text field.
+
+ * UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp:
+ (EWK2UnitTest::EWK2UnitTestBase::mouseDoubleClick):
+ Select the entire word in the text field.
+
+ * UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h:
+ * UIProcess/API/efl/tests/test_ewk2_text_checker.cpp:
+ (onSpellingForKnownWord):
+ (onWordLearn):
+ (onWordIgnore):
+ (selectLearnSpelling):
+ (selectIgnoreSpelling):
+
2013-07-05 Xabier Rodriguez Calvar <[email protected]>
[GTK] WebKit2 test TestWebKitFaviconDatabase times out with recent glib
Modified: trunk/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp (152413 => 152414)
--- trunk/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp 2013-07-05 10:26:42 UTC (rev 152413)
+++ trunk/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp 2013-07-05 10:29:12 UTC (rev 152414)
@@ -243,6 +243,14 @@
evas_event_feed_mouse_up(evas, button, EVAS_BUTTON_NONE, 0, 0);
}
+void EWK2UnitTestBase::mouseDoubleClick(int x, int y, int button)
+{
+ Evas* evas = evas_object_evas_get(m_webView);
+ evas_event_feed_mouse_move(evas, x, y, 0, 0);
+ evas_event_feed_mouse_down(evas, button, EVAS_BUTTON_DOUBLE_CLICK, 0, 0);
+ evas_event_feed_mouse_up(evas, button, EVAS_BUTTON_NONE, 0, 0);
+}
+
void EWK2UnitTestBase::mouseDown(int x, int y, int button)
{
Evas* evas = evas_object_evas_get(m_webView);
Modified: trunk/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h (152413 => 152414)
--- trunk/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h 2013-07-05 10:26:42 UTC (rev 152413)
+++ trunk/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h 2013-07-05 10:29:12 UTC (rev 152414)
@@ -53,6 +53,7 @@
bool waitUntilTrue(bool &flag, double timeoutSeconds = defaultTimeoutSeconds);
void mouseClick(int x, int y, int button = 1 /*Left*/);
+ void mouseDoubleClick(int x, int y, int button = 1 /*Left*/);
void mouseDown(int x, int y, int button = 1 /*Left*/);
void mouseUp(int x, int y, int button = 1 /*Left*/);
void mouseMove(int x, int y);
Modified: trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_text_checker.cpp (152413 => 152414)
--- trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_text_checker.cpp 2013-07-05 10:26:42 UTC (rev 152413)
+++ trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_text_checker.cpp 2013-07-05 10:29:12 UTC (rev 152414)
@@ -52,6 +52,7 @@
static const char* clientSuggestionsForWord[] = { "clientSuggestion1", "clientSuggestion2", "clientSuggestion3" };
static unsigned contextMenuItemsNumber = 0;
+static String knownWord;
/**
* Structure keeps information which callbacks were called.
@@ -168,6 +169,28 @@
}
/**
+ * Checks spelling for the given @a text and compares it with the knownWord.
+ *
+ * @internal
+ *
+ * @param text the text containing the words to spellcheck
+ * @param misspelling_location a pointer to store the beginning of the misspelled @a text, @c -1 if the @a text is correct
+ * @param misspelling_length a pointer to store the length of misspelled @a text, @c 0 if the @a text is correct
+ */
+static void onSpellingForKnownWord(uint64_t, const char* text, int32_t* misspellingLocation, int32_t* misspellingLength)
+{
+ ASSERT_STREQ(knownWord.utf8().data(), text);
+
+ ASSERT_TRUE(misspellingLocation);
+ ASSERT_TRUE(misspellingLength);
+
+ *misspellingLocation = -1;
+ *misspellingLength = 0;
+
+ callbacksExecutionStats.spellingCheck = true;
+}
+
+/**
* Gets a list of suggested spellings for a misspelled @a word.
*
* @internal
@@ -203,6 +226,7 @@
{
ASSERT_EQ(defaultDocumentTag, tag);
ASSERT_STREQ(expectedMisspelledWord, word);
+ knownWord = word;
callbacksExecutionStats.wordLearn = true;
}
@@ -218,6 +242,7 @@
{
ASSERT_EQ(defaultDocumentTag, tag);
ASSERT_STREQ(expectedMisspelledWord, word);
+ knownWord = word;
callbacksExecutionStats.wordIgnore = true;
}
@@ -305,6 +330,16 @@
return true;
}
+static Eina_Bool selectLearnSpelling(Ewk_View_Smart_Data*, Evas_Coord, Evas_Coord, Ewk_Context_Menu* contextMenu)
+{
+ return ewk_context_menu_item_select(contextMenu, findContextMenuItem(contextMenu, EWK_CONTEXT_MENU_ITEM_TAG_LEARN_SPELLING, EWK_ACTION_TYPE));
+}
+
+static Eina_Bool selectIgnoreSpelling(Ewk_View_Smart_Data*, Evas_Coord, Evas_Coord, Ewk_Context_Menu* contextMenu)
+{
+ return ewk_context_menu_item_select(contextMenu, findContextMenuItem(contextMenu, EWK_CONTEXT_MENU_ITEM_TAG_IGNORE_SPELLING, EWK_ACTION_TYPE));
+}
+
/**
* Count number of elements in context menu.
*/
@@ -763,40 +798,64 @@
/**
* Test whether the client's callback (onWordLearn) is called when
- * the context menu option "Learn spelling" was choosen.
+ * the context menu option "Learn spelling" was chosen. In the next step,
+ * check whether the learned word is treated as spelled correctly while spell checking.
*/
TEST_F(EWK2UnitTestBase, ewk_text_checker_word_learn_cb_set)
{
resetCallbacksExecutionStats();
+ knownWord = emptyString();
defaultView = webView();
- ewk_text_checker_continuous_spell_checking_enabled_set(true);
-
ewk_text_checker_word_learn_cb_set(onWordLearn);
+ ewkViewClass()->context_menu_show = selectLearnSpelling;
ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_test.html").data()));
+ mouseDoubleClick(10, 20);
+ mouseClick(10, 20, 3 /* Right button - invoke context menu */);
- /* FIXME:
- 1) Invoke the context menu on the misspelled word (not implemented for WK2),
- the word has to be selected first.
- 2) Check whether the callback was called. */
+ ASSERT_TRUE(waitUntilTrue(callbacksExecutionStats.wordLearn));
+
+ // Open html again and check whether the learned word
+ // is treated as spelled correctly while spell checking.
+ resetCallbacksExecutionStats();
+ ewk_text_checker_string_spelling_check_cb_set(onSpellingForKnownWord);
+
+ ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_test.html").data()));
+
+ ASSERT_TRUE(callbacksExecutionStats.spellingCheck);
+
+ ewk_text_checker_string_spelling_check_cb_set(0);
+ ewk_text_checker_word_learn_cb_set(0);
}
/**
* Test whether the client's callback (onWordIgnore) is called when
- * the context menu option "Ignore spelling" was choosen.
+ * the context menu option "Ignore spelling" was chosen. In the next step,
+ * check whether the ignored word is treated as spelled correctly while spell checking.
*/
TEST_F(EWK2UnitTestBase, ewk_text_checker_word_ignore_cb_set)
{
resetCallbacksExecutionStats();
+ knownWord = emptyString();
defaultView = webView();
- ewk_text_checker_continuous_spell_checking_enabled_set(true);
-
ewk_text_checker_word_ignore_cb_set(onWordIgnore);
+ ewkViewClass()->context_menu_show = selectIgnoreSpelling;
ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_test.html").data()));
+ mouseDoubleClick(10, 20);
+ mouseClick(10, 20, 3 /* Right button - invoke context menu */);
- /* FIXME:
- 1) Invoke the context menu on the misspelled word (not implemented for WK2),
- the word has to be selected first.
- 2) Check whether the callback was called. */
+ ASSERT_TRUE(waitUntilTrue(callbacksExecutionStats.wordIgnore));
+
+ // Open html again and check whether the ignored word
+ // is treated as spelled correctly while spell checking.
+ resetCallbacksExecutionStats();
+ ewk_text_checker_string_spelling_check_cb_set(onSpellingForKnownWord);
+
+ ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_test.html").data()));
+
+ ASSERT_TRUE(callbacksExecutionStats.spellingCheck);
+
+ ewk_text_checker_string_spelling_check_cb_set(0);
+ ewk_text_checker_word_ignore_cb_set(0);
}