Title: [152831] trunk/Source/WebKit2
Revision
152831
Author
[email protected]
Date
2013-07-18 00:27:08 -0700 (Thu, 18 Jul 2013)

Log Message

[EFL][WK2] Move all the static methods into EWK2TextCheckerTest in test_ewk2_text_checker.cpp
https://bugs.webkit.org/show_bug.cgi?id=118790

Patch by Dong-Gwan Kim <[email protected]> on 2013-07-18
Reviewed by Christophe Dumez.

All the static methods should be moved to EWK2TextCheckerTest.

* UIProcess/API/efl/tests/test_ewk2_text_checker.cpp:
(EWK2TextCheckerTest::resetCallbacksExecutionStats):
(EWK2TextCheckerTest::onTimeout):
(EWK2TextCheckerTest::onSettingChange):
(EWK2TextCheckerTest::onSpellDocumentTag):
(EWK2TextCheckerTest::onSpellDocumentTagClose):
(EWK2TextCheckerTest::onSpellingCheck):
(EWK2TextCheckerTest::onSpellingForKnownWord):
(EWK2TextCheckerTest::onWordGuesses):
(EWK2TextCheckerTest::onWordLearn):
(EWK2TextCheckerTest::onWordIgnore):
(EWK2TextCheckerTest::findContextMenuItem):
(EWK2TextCheckerTest::checkCorrectnessOfSpellingItems):
(EWK2TextCheckerTest::toogleCheckSpellingWhileTyping):
(EWK2TextCheckerTest::checkClientSuggestionsForWord):
(EWK2TextCheckerTest::selectLearnSpelling):
(EWK2TextCheckerTest::selectIgnoreSpelling):
(EWK2TextCheckerTest::countContextMenuItems):
(EWK2TextCheckerTest::clickButton):
(EWK2TextCheckerTest::showContextMenu):
(EWK2TextCheckerTest::selectFirstWord):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (152830 => 152831)


--- trunk/Source/WebKit2/ChangeLog	2013-07-18 06:36:26 UTC (rev 152830)
+++ trunk/Source/WebKit2/ChangeLog	2013-07-18 07:27:08 UTC (rev 152831)
@@ -1,3 +1,34 @@
+2013-07-18  Dong-Gwan Kim  <[email protected]>
+
+        [EFL][WK2] Move all the static methods into EWK2TextCheckerTest in test_ewk2_text_checker.cpp
+        https://bugs.webkit.org/show_bug.cgi?id=118790
+
+        Reviewed by Christophe Dumez.
+
+        All the static methods should be moved to EWK2TextCheckerTest.
+
+        * UIProcess/API/efl/tests/test_ewk2_text_checker.cpp:
+        (EWK2TextCheckerTest::resetCallbacksExecutionStats):
+        (EWK2TextCheckerTest::onTimeout):
+        (EWK2TextCheckerTest::onSettingChange):
+        (EWK2TextCheckerTest::onSpellDocumentTag):
+        (EWK2TextCheckerTest::onSpellDocumentTagClose):
+        (EWK2TextCheckerTest::onSpellingCheck):
+        (EWK2TextCheckerTest::onSpellingForKnownWord):
+        (EWK2TextCheckerTest::onWordGuesses):
+        (EWK2TextCheckerTest::onWordLearn):
+        (EWK2TextCheckerTest::onWordIgnore):
+        (EWK2TextCheckerTest::findContextMenuItem):
+        (EWK2TextCheckerTest::checkCorrectnessOfSpellingItems):
+        (EWK2TextCheckerTest::toogleCheckSpellingWhileTyping):
+        (EWK2TextCheckerTest::checkClientSuggestionsForWord):
+        (EWK2TextCheckerTest::selectLearnSpelling):
+        (EWK2TextCheckerTest::selectIgnoreSpelling):
+        (EWK2TextCheckerTest::countContextMenuItems):
+        (EWK2TextCheckerTest::clickButton):
+        (EWK2TextCheckerTest::showContextMenu):
+        (EWK2TextCheckerTest::selectFirstWord):
+
 2013-07-17  Tim Horton  <[email protected]>
 
         Update blocked/missing plug-in UI

Modified: trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_text_checker.cpp (152830 => 152831)


--- trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_text_checker.cpp	2013-07-18 06:36:26 UTC (rev 152830)
+++ trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_text_checker.cpp	2013-07-18 07:27:08 UTC (rev 152831)
@@ -54,51 +54,6 @@
 static unsigned contextMenuItemsNumber = 0;
 static String knownWord;
 
-class EWK2TextCheckerTest : public EWK2UnitTestBase {
-protected:
-    enum Line { FirstLine, SecondLine };
-    enum Button { SelectAllWordsWithSpellcheckButton, SelectAllWordsWithoutSpellcheckButton, SelectSubWordWithSpellcheckButton };
-
-    void clickButton(Button button)
-    {
-        switch (button) {
-        case SelectAllWordsWithSpellcheckButton:
-            mouseClick(60, 60);
-            break;
-        case SelectAllWordsWithoutSpellcheckButton:
-            mouseClick(500, 60);
-            break;
-        case SelectSubWordWithSpellcheckButton :
-            mouseClick(200, 60);
-            break;
-        }
-    }
-
-    void showContextMenu(Line line)
-    {
-        switch (line) {
-        case FirstLine:
-            mouseClick(10, 20, 3);
-            break;
-        case SecondLine:
-            mouseClick(35, 35, 3);
-            break;
-        }
-    }
-
-    void selectFirstWord(Line line)
-    {
-        switch (line) {
-        case FirstLine:
-            mouseDoubleClick(10, 20);
-            break;
-        case SecondLine:
-            mouseDoubleClick(35, 35);
-            break;
-        }
-    }
-};
-
 /**
  * Structure keeps information which callbacks were called.
  * Its values are reset before each test.
@@ -113,288 +68,334 @@
     bool wordIgnore;
 } callbacksExecutionStats;
 
-static void resetCallbacksExecutionStats()
-{
-    callbacksExecutionStats.settingChange = false;
-    callbacksExecutionStats.spellDocumentTag = false;
-    callbacksExecutionStats.spellDocumentTagClose = false;
-    callbacksExecutionStats.spellingCheck = false;
-    callbacksExecutionStats.wordGuesses = false;
-    callbacksExecutionStats.wordLearn = false;
-    callbacksExecutionStats.wordIgnore = false;
-}
+class EWK2TextCheckerTest : public EWK2UnitTestBase {
+public:
+    static void resetCallbacksExecutionStats()
+    {
+        callbacksExecutionStats.settingChange = false;
+        callbacksExecutionStats.spellDocumentTag = false;
+        callbacksExecutionStats.spellDocumentTagClose = false;
+        callbacksExecutionStats.spellingCheck = false;
+        callbacksExecutionStats.wordGuesses = false;
+        callbacksExecutionStats.wordLearn = false;
+        callbacksExecutionStats.wordIgnore = false;
+    }
 
-/**
- * Handle the timeout, it may happen for the asynchronous tests.
- *
- * @internal
- *
- * @return the ECORE_CALLBACK_CANCEL flag to delete the timer automatically
- */
-static Eina_Bool onTimeout(void*)
-{
-    ecore_main_loop_quit();
-    return ECORE_CALLBACK_CANCEL;
-}
+    /**
+     * Handle the timeout, it may happen for the asynchronous tests.
+     *
+     * @internal
+     *
+     * @return the ECORE_CALLBACK_CANCEL flag to delete the timer automatically
+     */
+    static Eina_Bool onTimeout(void*)
+    {
+        ecore_main_loop_quit();
+        return ECORE_CALLBACK_CANCEL;
+    }
 
-/**
- * This callback tests whether the client's callback is called when the spell checking setting was changed.
- *
- * @internal
- *
- * Verify the new setting value (passes in the @a flag parameter) if it equals to the previously set.
- *
- * @internal
- *
- * @param flag the new setting value
- */
-static void onSettingChange(Eina_Bool flag)
-{
-    EXPECT_EQ(isSettingEnabled, flag);
-    callbacksExecutionStats.settingChange = true;
-}
+    /**
+     * This callback tests whether the client's callback is called when the spell checking setting was changed.
+     *
+     * @internal
+     *
+     * Verify the new setting value (passes in the @a flag parameter) if it equals to the previously set.
+     *
+     * @internal
+     *
+     * @param flag the new setting value
+     */
+    static void onSettingChange(Eina_Bool flag)
+    {
+        EXPECT_EQ(isSettingEnabled, flag);
+        callbacksExecutionStats.settingChange = true;
+    }
 
-/**
- * Returns unique tag (an identifier).
- *
- * @internal
- *
- * It will be used for onSpellingCheck, onWordGuesses etc. to notify
- * the client on which object (associated to the tag) the spelling is being invoked.
- *
- * @param ewkView the view object to get unique tag
- *
- * @return unique tag for the given @a ewkView object
- */
-static uint64_t onSpellDocumentTag(const Evas_Object* ewkView)
-{
-    EXPECT_EQ(defaultView, ewkView);
-    callbacksExecutionStats.spellDocumentTag = true;
+    /**
+     * Returns unique tag (an identifier).
+     *
+     * @internal
+     *
+     * It will be used for onSpellingCheck, onWordGuesses etc. to notify
+     * the client on which object (associated to the tag) the spelling is being invoked.
+     *
+     * @param ewkView the view object to get unique tag
+     *
+     * @return unique tag for the given @a ewkView object
+     */
+    static uint64_t onSpellDocumentTag(const Evas_Object* ewkView)
+    {
+        EXPECT_EQ(defaultView, ewkView);
+        callbacksExecutionStats.spellDocumentTag = true;
 
-    return defaultDocumentTag;
-}
+        return defaultDocumentTag;
+    }
 
-/**
- * The view which is associated to the @a tag has been destroyed.
- *
- * @internal
- *
- * @param tag the tag to be closed
- */
-static void onSpellDocumentTagClose(uint64_t tag)
-{
-    ASSERT_EQ(defaultDocumentTag, tag);
-    callbacksExecutionStats.spellDocumentTagClose = true;
-}
+    /**
+     * The view which is associated to the @a tag has been destroyed.
+     *
+     * @internal
+     *
+     * @param tag the tag to be closed
+     */
+    static void onSpellDocumentTagClose(uint64_t tag)
+    {
+        ASSERT_EQ(defaultDocumentTag, tag);
+        callbacksExecutionStats.spellDocumentTagClose = true;
+    }
 
-/**
- * Checks spelling for the given @a text.
- *
- * @internal
- *
- * @param tag unique tag to notify the client on which object the spelling is being performed
- * @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 onSpellingCheck(uint64_t tag, const char* text, int32_t* misspellingLocation, int32_t* misspellingLength)
-{
-    ASSERT_EQ(defaultDocumentTag, tag);
-    ASSERT_STREQ(expectedMisspelledWord, text);
+    /**
+     * Checks spelling for the given @a text.
+     *
+     * @internal
+     *
+     * @param tag unique tag to notify the client on which object the spelling is being performed
+     * @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 onSpellingCheck(uint64_t tag, const char* text, int32_t* misspellingLocation, int32_t* misspellingLength)
+    {
+        ASSERT_EQ(defaultDocumentTag, tag);
+        ASSERT_STREQ(expectedMisspelledWord, text);
 
-    ASSERT_TRUE(misspellingLocation);
-    ASSERT_TRUE(misspellingLength);
+        ASSERT_TRUE(misspellingLocation);
+        ASSERT_TRUE(misspellingLength);
 
-    // The client is able to show the misselled text through its location (the beginning of misspelling)
-    // and length (the end of misspelling).
-    *misspellingLocation = 0;
-    *misspellingLength = strlen(expectedMisspelledWord);
+        // The client is able to show the misselled text through its location (the beginning of misspelling)
+        // and length (the end of misspelling).
+        *misspellingLocation = 0;
+        *misspellingLength = strlen(expectedMisspelledWord);
 
-    callbacksExecutionStats.spellingCheck = true;
-}
+        callbacksExecutionStats.spellingCheck = true;
+    }
 
-/**
- * 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);
+    /**
+     * 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);
+        ASSERT_TRUE(misspellingLocation);
+        ASSERT_TRUE(misspellingLength);
 
-    *misspellingLocation = -1;
-    *misspellingLength = 0;
+        *misspellingLocation = -1;
+        *misspellingLength = 0;
 
-    callbacksExecutionStats.spellingCheck = true;
-}
+        callbacksExecutionStats.spellingCheck = true;
+    }
 
-/**
- * Gets a list of suggested spellings for a misspelled @a word.
- *
- * @internal
- *
- * @param tag unique tag to notify the client on which object the spelling is being performed
- * @param word the word to get guesses
- * @return a list of dynamically allocated strings (as char*) and
- *         caller is responsible for destroying them.
- */
-static Eina_List* onWordGuesses(uint64_t tag, const char* word)
-{
-    EXPECT_EQ(defaultDocumentTag, tag);
-    EXPECT_STREQ(expectedMisspelledWord, word);
+    /**
+     * Gets a list of suggested spellings for a misspelled @a word.
+     *
+     * @internal
+     *
+     * @param tag unique tag to notify the client on which object the spelling is being performed
+     * @param word the word to get guesses
+     * @return a list of dynamically allocated strings (as char*) and
+     *         caller is responsible for destroying them.
+     */
+    static Eina_List* onWordGuesses(uint64_t tag, const char* word)
+    {
+        EXPECT_EQ(defaultDocumentTag, tag);
+        EXPECT_STREQ(expectedMisspelledWord, word);
 
-    Eina_List* suggestionsForWord = 0;
-    size_t numberOfSuggestions = WTF_ARRAY_LENGTH(clientSuggestionsForWord);
-    for (size_t i = 0; i < numberOfSuggestions; ++i)
-        suggestionsForWord = eina_list_append(suggestionsForWord, strdup(clientSuggestionsForWord[i]));
+        Eina_List* suggestionsForWord = 0;
+        size_t numberOfSuggestions = WTF_ARRAY_LENGTH(clientSuggestionsForWord);
+        for (size_t i = 0; i < numberOfSuggestions; ++i)
+            suggestionsForWord = eina_list_append(suggestionsForWord, strdup(clientSuggestionsForWord[i]));
 
-    callbacksExecutionStats.wordGuesses = true;
-    return suggestionsForWord;
-}
+        callbacksExecutionStats.wordGuesses = true;
+        return suggestionsForWord;
+    }
 
-/**
- * Adds the @a word to the spell checker dictionary.
- *
- * @internal
- *
- * @param tag unique tag to notify the client on which object the spelling is being performed
- * @param word the word to add
- */
-static void onWordLearn(uint64_t tag, const char* word)
-{
-    ASSERT_EQ(defaultDocumentTag, tag);
-    ASSERT_STREQ(expectedMisspelledWord, word);
-    knownWord = word;
-    callbacksExecutionStats.wordLearn = true;
-}
+    /**
+     * Adds the @a word to the spell checker dictionary.
+     *
+     * @internal
+     *
+     * @param tag unique tag to notify the client on which object the spelling is being performed
+     * @param word the word to add
+     */
+    static void onWordLearn(uint64_t tag, const char* word)
+    {
+        ASSERT_EQ(defaultDocumentTag, tag);
+        ASSERT_STREQ(expectedMisspelledWord, word);
+        knownWord = word;
+        callbacksExecutionStats.wordLearn = true;
+    }
 
-/**
- * Tells the spell checker to ignore a given @a word.
- *
- * @internal
- *
- * @param tag unique tag to notify the client on which object the spelling is being performed
- * @param word the word to ignore
- */
-static void onWordIgnore(uint64_t tag, const char* word)
-{
-    ASSERT_EQ(defaultDocumentTag, tag);
-    ASSERT_STREQ(expectedMisspelledWord, word);
-    knownWord = word;
-    callbacksExecutionStats.wordIgnore = true;
-}
+    /**
+     * Tells the spell checker to ignore a given @a word.
+     *
+     * @internal
+     *
+     * @param tag unique tag to notify the client on which object the spelling is being performed
+     * @param word the word to ignore
+     */
+    static void onWordIgnore(uint64_t tag, const char* word)
+    {
+        ASSERT_EQ(defaultDocumentTag, tag);
+        ASSERT_STREQ(expectedMisspelledWord, word);
+        knownWord = word;
+        callbacksExecutionStats.wordIgnore = true;
+    }
 
-/**
- * Helper, get required item from context menu.
- *
- * @param contextMenu the context menu object
- * @param itemAction action of item to get
- * @param itemType type of item to get
- *
- * @return required item
- */
-static Ewk_Context_Menu_Item* findContextMenuItem(const Ewk_Context_Menu* contextMenu, Ewk_Context_Menu_Item_Action itemAction, Ewk_Context_Menu_Item_Type itemType)
-{
-    const Eina_List* contextMenuItems = ewk_context_menu_items_get(contextMenu);
+    /**
+     * Helper, get required item from context menu.
+     *
+     * @param contextMenu the context menu object
+     * @param itemAction action of item to get
+     * @param itemType type of item to get
+     *
+     * @return required item
+     */
+    static Ewk_Context_Menu_Item* findContextMenuItem(const Ewk_Context_Menu* contextMenu, Ewk_Context_Menu_Item_Action itemAction, Ewk_Context_Menu_Item_Type itemType)
+    {
+        const Eina_List* contextMenuItems = ewk_context_menu_items_get(contextMenu);
 
-    void* itemData;
-    const Eina_List* listIterator;
-    EINA_LIST_FOREACH(contextMenuItems, listIterator, itemData) {
-        Ewk_Context_Menu_Item* item = static_cast<Ewk_Context_Menu_Item*>(itemData);
-        if (ewk_context_menu_item_action_get(item) == itemAction
-            && ewk_context_menu_item_type_get(item) == itemType)
-            return item;
+        void* itemData;
+        const Eina_List* listIterator;
+        EINA_LIST_FOREACH(contextMenuItems, listIterator, itemData) {
+            Ewk_Context_Menu_Item* item = static_cast<Ewk_Context_Menu_Item*>(itemData);
+            if (ewk_context_menu_item_action_get(item) == itemAction
+                && ewk_context_menu_item_type_get(item) == itemType)
+                return item;
+        }
+
+        ADD_FAILURE();
+        return 0;
     }
 
-    ADD_FAILURE();
-    return 0;
-}
+    static Eina_Bool checkCorrectnessOfSpellingItems(Ewk_View_Smart_Data*, Evas_Coord, Evas_Coord, Ewk_Context_Menu* contextMenu)
+    {
+        const Eina_List* contextMenuItems = ewk_context_menu_items_get(contextMenu);
 
-static Eina_Bool checkCorrectnessOfSpellingItems(Ewk_View_Smart_Data*, Evas_Coord, Evas_Coord, Ewk_Context_Menu* contextMenu)
-{
-    const Eina_List* contextMenuItems = ewk_context_menu_items_get(contextMenu);
+        bool noGuessesAvailable = false;
+        bool isIgnoreSpellingAvailable = false;
+        bool isLearnSpellingAvailable = false;
 
-    bool noGuessesAvailable = false;
-    bool isIgnoreSpellingAvailable = false;
-    bool isLearnSpellingAvailable = false;
+        const Eina_List* listIterator;
+        void* itemData;
+        EINA_LIST_FOREACH(contextMenuItems, listIterator, itemData) {
+            Ewk_Context_Menu_Item* item = static_cast<Ewk_Context_Menu_Item*>(itemData);
+            if (!strcmp(ewk_context_menu_item_title_get(item), noGuessesString))
+                noGuessesAvailable = true;
+            else if (!strcmp(ewk_context_menu_item_title_get(item), ignoreSpellingString))
+                isIgnoreSpellingAvailable = true;
+            else if (!strcmp(ewk_context_menu_item_title_get(item), learnSpellingString))
+                isLearnSpellingAvailable = true;
+        }
 
-    const Eina_List* listIterator;
-    void* itemData;
-    EINA_LIST_FOREACH(contextMenuItems, listIterator, itemData) {
-        Ewk_Context_Menu_Item* item = static_cast<Ewk_Context_Menu_Item*>(itemData);
-        if (!strcmp(ewk_context_menu_item_title_get(item), noGuessesString))
-            noGuessesAvailable = true;
-        else if (!strcmp(ewk_context_menu_item_title_get(item), ignoreSpellingString))
-            isIgnoreSpellingAvailable = true;
-        else if (!strcmp(ewk_context_menu_item_title_get(item), learnSpellingString))
-            isLearnSpellingAvailable = true;
+        EXPECT_FALSE(noGuessesAvailable);
+        EXPECT_TRUE(isIgnoreSpellingAvailable);
+        EXPECT_TRUE(isLearnSpellingAvailable);
+
+        wasContextMenuShown = true;
+        return true;
     }
 
-    EXPECT_FALSE(noGuessesAvailable);
-    EXPECT_TRUE(isIgnoreSpellingAvailable);
-    EXPECT_TRUE(isLearnSpellingAvailable);
+    static Eina_Bool toogleCheckSpellingWhileTyping(Ewk_View_Smart_Data*, Evas_Coord, Evas_Coord, Ewk_Context_Menu* contextMenu)
+    {
+        Ewk_Context_Menu_Item* spellingAndGrammarItem = findContextMenuItem(contextMenu, EWK_CONTEXT_MENU_ITEM_TAG_SPELLING_MENU, EWK_SUBMENU_TYPE);
+        Ewk_Context_Menu* spellingAndGrammarSubmenu = ewk_context_menu_item_submenu_get(spellingAndGrammarItem);
+        Ewk_Context_Menu_Item* checkSpellingWhileTypingItem = findContextMenuItem(spellingAndGrammarSubmenu, EWK_CONTEXT_MENU_ITEM_TAG_CHECK_SPELLING_WHILE_TYPING, EWK_CHECKABLE_ACTION_TYPE);
 
-    wasContextMenuShown = true;
-    return true;
-}
+        return ewk_context_menu_item_select(spellingAndGrammarSubmenu, checkSpellingWhileTypingItem);
+    }
 
-static Eina_Bool toogleCheckSpellingWhileTyping(Ewk_View_Smart_Data*, Evas_Coord, Evas_Coord, Ewk_Context_Menu* contextMenu)
-{
-    Ewk_Context_Menu_Item* spellingAndGrammarItem = findContextMenuItem(contextMenu, EWK_CONTEXT_MENU_ITEM_TAG_SPELLING_MENU, EWK_SUBMENU_TYPE);
-    Ewk_Context_Menu* spellingAndGrammarSubmenu = ewk_context_menu_item_submenu_get(spellingAndGrammarItem);
-    Ewk_Context_Menu_Item* checkSpellingWhileTypingItem = findContextMenuItem(spellingAndGrammarSubmenu, EWK_CONTEXT_MENU_ITEM_TAG_CHECK_SPELLING_WHILE_TYPING, EWK_CHECKABLE_ACTION_TYPE);
+    static Eina_Bool checkClientSuggestionsForWord(Ewk_View_Smart_Data*, Evas_Coord, Evas_Coord, Ewk_Context_Menu* contextMenu)
+    {
+        const Eina_List* contextMenuItems = ewk_context_menu_items_get(contextMenu);
 
-    return ewk_context_menu_item_select(spellingAndGrammarSubmenu, checkSpellingWhileTypingItem);
-}
+        size_t numberOfSuggestions = WTF_ARRAY_LENGTH(clientSuggestionsForWord);
+        // contextMenuItems should contain suggestions and another options.
+        if (numberOfSuggestions > eina_list_count(contextMenuItems)) {
+            ADD_FAILURE();
+            return true;
+        }
+        // Verify suggestions from the top of context menu list.
+        for (size_t i = 0; i < numberOfSuggestions; ++i) {
+            Ewk_Context_Menu_Item* item = static_cast<Ewk_Context_Menu_Item*>(eina_list_data_get(contextMenuItems));
+            EXPECT_STREQ(clientSuggestionsForWord[i], ewk_context_menu_item_title_get(item));
+            contextMenuItems = eina_list_next(contextMenuItems);
+        }
 
-static Eina_Bool checkClientSuggestionsForWord(Ewk_View_Smart_Data*, Evas_Coord, Evas_Coord, Ewk_Context_Menu* contextMenu)
-{
-    const Eina_List* contextMenuItems = ewk_context_menu_items_get(contextMenu);
-
-    size_t numberOfSuggestions = WTF_ARRAY_LENGTH(clientSuggestionsForWord);
-    // contextMenuItems should contain suggestions and another options.
-    if (numberOfSuggestions > eina_list_count(contextMenuItems)) {
-        ADD_FAILURE();
+        wasContextMenuShown = true;
         return true;
     }
-    // Verify suggestions from the top of context menu list.
-    for (size_t i = 0; i < numberOfSuggestions; ++i) {
-        Ewk_Context_Menu_Item* item = static_cast<Ewk_Context_Menu_Item*>(eina_list_data_get(contextMenuItems));
-        EXPECT_STREQ(clientSuggestionsForWord[i], ewk_context_menu_item_title_get(item));
-        contextMenuItems = eina_list_next(contextMenuItems);
+
+    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));
     }
 
-    wasContextMenuShown = true;
-    return true;
-}
+    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));
+    }
 
-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));
-}
+    /**
+     * Count number of elements in context menu.
+     */
+    static Eina_Bool countContextMenuItems(Ewk_View_Smart_Data*, Evas_Coord, Evas_Coord, Ewk_Context_Menu* contextMenu)
+    {
+        contextMenuItemsNumber = eina_list_count(ewk_context_menu_items_get(contextMenu));
+        wasContextMenuShown = true;
+        return true;
+    }
 
-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));
-}
+protected:
+    enum Line { FirstLine, SecondLine };
+    enum Button { SelectAllWordsWithSpellcheckButton, SelectAllWordsWithoutSpellcheckButton, SelectSubWordWithSpellcheckButton };
 
-/**
- * Count number of elements in context menu.
- */
-static Eina_Bool countContextMenuItems(Ewk_View_Smart_Data*, Evas_Coord, Evas_Coord, Ewk_Context_Menu* contextMenu)
-{
-    contextMenuItemsNumber = eina_list_count(ewk_context_menu_items_get(contextMenu));
-    wasContextMenuShown = true;
-    return true;
-}
+    void clickButton(Button button)
+    {
+        switch (button) {
+        case SelectAllWordsWithSpellcheckButton:
+            mouseClick(60, 60);
+            break;
+        case SelectAllWordsWithoutSpellcheckButton:
+            mouseClick(500, 60);
+            break;
+        case SelectSubWordWithSpellcheckButton :
+            mouseClick(200, 60);
+            break;
+        }
+    }
 
+    void showContextMenu(Line line)
+    {
+        switch (line) {
+        case FirstLine:
+            mouseClick(10, 20, 3);
+            break;
+        case SecondLine:
+            mouseClick(35, 35, 3);
+            break;
+        }
+    }
+
+    void selectFirstWord(Line line)
+    {
+        switch (line) {
+        case FirstLine:
+            mouseDoubleClick(10, 20);
+            break;
+        case SecondLine:
+            mouseDoubleClick(35, 35);
+            break;
+        }
+    }
+};
+
 /**
  * Test whether there are spelling suggestions when misspelled word is directly context clicked.
  */
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to