Modified: trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_text_checker.cpp (152707 => 152708)
--- trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_text_checker.cpp 2013-07-16 06:55:31 UTC (rev 152707)
+++ trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_text_checker.cpp 2013-07-16 07:35:49 UTC (rev 152708)
@@ -54,6 +54,51 @@
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.
@@ -353,14 +398,14 @@
/**
* Test whether there are spelling suggestions when misspelled word is directly context clicked.
*/
-TEST_F(EWK2UnitTestBase, spelling_suggestion_for_context_click)
+TEST_F(EWK2TextCheckerTest, spelling_suggestion_for_context_click)
{
wasContextMenuShown = false;
// Checking number of context menu items when element has no spellcheck suggestions.
ewkViewClass()->context_menu_show = countContextMenuItems;
ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_selection_tests.html").data()));
- mouseClick(10, 20, 3 /* Right button - invoke context menu */);
+ showContextMenu(FirstLine);
ASSERT_TRUE(waitUntilTrue(wasContextMenuShown));
unsigned numberItemsWithoutSpellCheck = contextMenuItemsNumber;
@@ -369,7 +414,7 @@
// Testing how many items are in context menu when spellcheck is enabled.
ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_selection_tests.html").data()));
- mouseClick(35, 35, 3 /* Right button - invoke context menu */);
+ showContextMenu(SecondLine);
ASSERT_TRUE(waitUntilTrue(wasContextMenuShown));
@@ -379,15 +424,15 @@
/**
* Test whether there are no spelling suggestions when multiple words are selected (that are not a single misspelling).
*/
-TEST_F(EWK2UnitTestBase, no_spelling_suggestion_for_multiword_selection)
+TEST_F(EWK2TextCheckerTest, no_spelling_suggestion_for_multiword_selection)
{
wasContextMenuShown = false;
// Checking number of context menu items when element has no spellcheck suggestions.
ewkViewClass()->context_menu_show = countContextMenuItems;
ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_selection_tests.html").data()));
- mouseClick(500, 60, 1 /* Left button - select all words in field without spellcheck */);
- mouseClick(10, 20, 3 /* Right button - invoke context menu */);
+ clickButton(SelectAllWordsWithoutSpellcheckButton);
+ showContextMenu(FirstLine);
ASSERT_TRUE(waitUntilTrue(wasContextMenuShown));
unsigned numberItemsWithoutSpellCheck = contextMenuItemsNumber;
@@ -396,8 +441,8 @@
// Testing how many items are in context menu when multiple words are selected.
ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_selection_tests.html").data()));
- mouseClick(60, 60, 1 /* Left button - select all words in field with spellcheck */);
- mouseClick(35, 35, 3 /* Right button - invoke context menu */);
+ clickButton(SelectAllWordsWithSpellcheckButton);
+ showContextMenu(SecondLine);
ASSERT_TRUE(waitUntilTrue(wasContextMenuShown));
@@ -407,15 +452,15 @@
/**
* Test whether there are no spelling suggestions when part of misspelled word are selected.
*/
-TEST_F(EWK2UnitTestBase, no_spelling_suggestion_for_subword_selection)
+TEST_F(EWK2TextCheckerTest, no_spelling_suggestion_for_subword_selection)
{
wasContextMenuShown = false;
// Checking number of context menu items when element has no spellcheck suggestions.
ewkViewClass()->context_menu_show = countContextMenuItems;
ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_selection_tests.html").data()));
- mouseClick(500, 60, 1 /* Left button - select all words in field without spellcheck */);
- mouseClick(10, 20, 3 /* Right button - invoke context menu */);
+ clickButton(SelectAllWordsWithoutSpellcheckButton);
+ showContextMenu(FirstLine);
ASSERT_TRUE(waitUntilTrue(wasContextMenuShown));
unsigned numberItemsWithoutSpellCheck = contextMenuItemsNumber;
@@ -424,8 +469,8 @@
// Testing how many items are in context menu when part of word is selected.
ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_selection_tests.html").data()));
- mouseClick(200, 60, 1 /* Left button - select part of word in field with spellcheck */);
- mouseClick(35, 35, 3 /* Right button - invoke context menu */);
+ clickButton(SelectSubWordWithSpellcheckButton);
+ showContextMenu(SecondLine);
ASSERT_TRUE(waitUntilTrue(wasContextMenuShown));
@@ -435,15 +480,15 @@
/**
* Test whether context menu spelling items are available when misspelled word has selection as the double click.
*/
-TEST_F(EWK2UnitTestBase, spelling_suggestion_for_double_clicked_word)
+TEST_F(EWK2TextCheckerTest, spelling_suggestion_for_double_clicked_word)
{
wasContextMenuShown = false;
// Checking number of context menu items when element has no spell check suggestions.
ewkViewClass()->context_menu_show = countContextMenuItems;
ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_selection_tests.html").data()));
- mouseClick(500, 60, 1 /* Left button - select all words in field without spellcheck */);
- mouseClick(10, 20, 3 /* Right button - invoke context menu */);
+ clickButton(SelectAllWordsWithoutSpellcheckButton);
+ showContextMenu(FirstLine);
ASSERT_TRUE(waitUntilTrue(wasContextMenuShown));
unsigned numberItemsWithoutSpellCheck = contextMenuItemsNumber;
@@ -452,9 +497,8 @@
// Making double click on misspelled word to select it, and checking are there context menu spell check suggestions.
ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_selection_tests.html").data()));
- mouseClick(35, 35, 1 /* Left button - 1st click of doubleclick */);
- mouseClick(35, 35, 1 /* Left button - 2nd click of doubleclick */);
- mouseClick(35, 35, 3 /* Right button - invoke context menu */);
+ selectFirstWord(SecondLine);
+ showContextMenu(SecondLine);
ASSERT_TRUE(waitUntilTrue(wasContextMenuShown));
@@ -465,7 +509,7 @@
* Test whether the default language is loaded independently of
* continuous spell checking setting.
*/
-TEST_F(EWK2UnitTestBase, ewk_text_checker_spell_checking_languages_get)
+TEST_F(EWK2TextCheckerTest, ewk_text_checker_spell_checking_languages_get)
{
ewk_text_checker_continuous_spell_checking_enabled_set(false);
// The language is being loaded on the idler, wait for it.
@@ -502,13 +546,13 @@
* Test whether the context menu spelling items (suggestions, learn and ignore spelling)
* are available when continuous spell checking is off.
*/
-TEST_F(EWK2UnitTestBase, context_menu_spelling_items_availability)
+TEST_F(EWK2TextCheckerTest, context_menu_spelling_items_availability)
{
ewk_text_checker_continuous_spell_checking_enabled_set(false);
ewkViewClass()->context_menu_show = checkCorrectnessOfSpellingItems;
ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_test.html").data()));
- mouseClick(10, 20, 3 /* Right button */);
+ showContextMenu(FirstLine);
while (!wasContextMenuShown)
ecore_main_loop_iterate();
@@ -519,7 +563,7 @@
* - ewk_text_checker_continuous_spell_checking_enabled_get
* - ewk_text_checker_continuous_spell_checking_enabled_set
*/
-TEST_F(EWK2UnitTestBase, ewk_text_checker_continuous_spell_checking_enabled)
+TEST_F(EWK2TextCheckerTest, ewk_text_checker_continuous_spell_checking_enabled)
{
ewk_text_checker_continuous_spell_checking_enabled_set(true);
#if ENABLE(SPELLCHECK)
@@ -538,7 +582,7 @@
* - "Check Spelling While Typing" is enabled,
* - "Check Spelling While Typing" is disabled.
*/
-TEST_F(EWK2UnitTestBase, ewk_text_checker_check_spelling_while_typing_toggle)
+TEST_F(EWK2TextCheckerTest, ewk_text_checker_check_spelling_while_typing_toggle)
{
resetCallbacksExecutionStats();
ewkViewClass()->context_menu_show = toogleCheckSpellingWhileTyping;
@@ -548,7 +592,7 @@
ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_test.html").data()));
- EWK2UnitTestBase::mouseClick(10, 20, /*Right button*/ 3);
+ showContextMenu(FirstLine);
ASSERT_TRUE(waitUntilTrue(callbacksExecutionStats.settingChange));
resetCallbacksExecutionStats();
@@ -556,7 +600,7 @@
// Test case, when "Check Spelling While Typing" is in reverse to the previous one.
isSettingEnabled = !isSettingEnabled;
- EWK2UnitTestBase::mouseClick(10, 20, /*Right button*/ 3);
+ showContextMenu(FirstLine);
ASSERT_TRUE(waitUntilTrue(callbacksExecutionStats.settingChange));
ewk_text_checker_continuous_spell_checking_change_cb_set(0);
@@ -565,7 +609,7 @@
/**
* Test whether the onSettingChange callback is not called when the spell checking setting was changed by client.
*/
-TEST_F(EWK2UnitTestBase, ewk_text_checker_continuous_spell_checking_change_cb_set)
+TEST_F(EWK2TextCheckerTest, ewk_text_checker_continuous_spell_checking_change_cb_set)
{
resetCallbacksExecutionStats();
@@ -587,14 +631,14 @@
* Test whether the onSettingChange callback is not called, if the client does not set it.
* "Check Spelling While Typing" option is toggled in context menu.
*/
-TEST_F(EWK2UnitTestBase, ewk_text_checker_continuous_spell_checking_change_cb_unset)
+TEST_F(EWK2TextCheckerTest, ewk_text_checker_continuous_spell_checking_change_cb_unset)
{
resetCallbacksExecutionStats();
ewkViewClass()->context_menu_show = toogleCheckSpellingWhileTyping;
ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_test.html").data()));
- EWK2UnitTestBase::mouseClick(10, 20, /*Right button*/ 3);
+ showContextMenu(FirstLine);
ASSERT_FALSE(waitUntilTrue(callbacksExecutionStats.settingChange, /*Timeout*/ 0));
}
@@ -603,7 +647,7 @@
* if they are in use.
* All the dictionaries from the list can be set to perform spellchecking.
*/
-TEST_F(EWK2UnitTestBase, ewk_text_checker_spell_checking_available_languages_get)
+TEST_F(EWK2TextCheckerTest, ewk_text_checker_spell_checking_available_languages_get)
{
Eina_List* availableLanguages = ewk_text_checker_spell_checking_available_languages_get();
// No dictionary is available/installed or the SPELLCHECK macro is disabled.
@@ -655,7 +699,7 @@
* - setting the default language,
* - if two arbitrarily selected dictionaries are set correctly.
*/
-TEST_F(EWK2UnitTestBase, ewk_text_checker_spell_checking_languages)
+TEST_F(EWK2TextCheckerTest, ewk_text_checker_spell_checking_languages)
{
// Set the default language.
ewk_text_checker_spell_checking_languages_set(0);
@@ -716,7 +760,7 @@
/**
* Test whether the client's callbacks aren't called (if not specified).
*/
-TEST_F(EWK2UnitTestBase, ewk_text_checker)
+TEST_F(EWK2TextCheckerTest, ewk_text_checker)
{
resetCallbacksExecutionStats();
ewk_text_checker_continuous_spell_checking_enabled_set(true);
@@ -737,7 +781,7 @@
/**
* Test whether the client's callbacks (onSpellDocumentTag, onSpellDocumentTagClose) are called.
*/
-TEST_F(EWK2UnitTestBase, ewk_text_checker_unique_spell_document_tag)
+TEST_F(EWK2TextCheckerTest, ewk_text_checker_unique_spell_document_tag)
{
resetCallbacksExecutionStats();
defaultView = webView();
@@ -759,7 +803,7 @@
* Test whether the client's callback (onSpellingCheck) is called when
* the word to input field was put.
*/
-TEST_F(EWK2UnitTestBase, ewk_text_checker_string_spelling_check_cb_set)
+TEST_F(EWK2TextCheckerTest, ewk_text_checker_string_spelling_check_cb_set)
{
resetCallbacksExecutionStats();
defaultView = webView();
@@ -777,7 +821,7 @@
* Test whether the client's callback (onWordGuesses) is called when
* the context menu was shown on the misspelled word.
*/
-TEST_F(EWK2UnitTestBase, ewk_text_checker_word_guesses_get_cb_set)
+TEST_F(EWK2TextCheckerTest, ewk_text_checker_word_guesses_get_cb_set)
{
resetCallbacksExecutionStats();
wasContextMenuShown = false;
@@ -787,7 +831,7 @@
ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_test.html").data()));
- EWK2UnitTestBase::mouseClick(10, 20, /*Right button*/ 3);
+ showContextMenu(FirstLine);
ASSERT_TRUE(waitUntilTrue(wasContextMenuShown));
// Check whether the callback is called.
@@ -801,7 +845,7 @@
* 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)
+TEST_F(EWK2TextCheckerTest, ewk_text_checker_word_learn_cb_set)
{
resetCallbacksExecutionStats();
knownWord = emptyString();
@@ -810,8 +854,8 @@
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 */);
+ selectFirstWord(FirstLine);
+ showContextMenu(FirstLine);
ASSERT_TRUE(waitUntilTrue(callbacksExecutionStats.wordLearn));
@@ -833,7 +877,7 @@
* 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)
+TEST_F(EWK2TextCheckerTest, ewk_text_checker_word_ignore_cb_set)
{
resetCallbacksExecutionStats();
knownWord = emptyString();
@@ -842,8 +886,8 @@
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 */);
+ selectFirstWord(FirstLine);
+ showContextMenu(FirstLine);
ASSERT_TRUE(waitUntilTrue(callbacksExecutionStats.wordIgnore));