Changeset 152708 in webkit


Ignore:
Timestamp:
Jul 16, 2013 12:35:49 AM (11 years ago)
Author:
commit-queue@webkit.org
Message:

Replace mouseClick with more meaningful method in test_ewk2_text_checker.cpp
https://bugs.webkit.org/show_bug.cgi?id=118699

Patch by Dong-Gwan Kim <donggwan.kim@samsung.com> on 2013-07-16
Reviewed by Christophe Dumez.

Many mouseClick methods are used in test_ewk2_text_checker.cpp.
But it is difficult to understand what they mean.
So i would like to replace those with more meaningful method for readability.

  • UIProcess/API/efl/tests/test_ewk2_text_checker.cpp:

(EWK2TextCheckerTest::clickSelectAllWordsWithSpellcheckButton):
(EWK2TextCheckerTest::clickSelectAllWordsWithoutSpellcheckButton):
(EWK2TextCheckerTest::clickSelectSubWordWithSpellcheckButton):
(EWK2TextCheckerTest::showContextMenuWithFirstLineText):
(EWK2TextCheckerTest::showContextMenuWithSecondLineText):
(EWK2TextCheckerTest::selectFirstWordInFirstLineText):
(EWK2TextCheckerTest::selectFirstWordInSecondLineText):
(TEST_F):

Location:
trunk/Source/WebKit2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r152704 r152708  
     12013-07-16  Dong-Gwan Kim  <donggwan.kim@samsung.com>
     2
     3        Replace mouseClick with more meaningful method in test_ewk2_text_checker.cpp
     4        https://bugs.webkit.org/show_bug.cgi?id=118699
     5
     6        Reviewed by Christophe Dumez.
     7
     8        Many mouseClick methods are used in test_ewk2_text_checker.cpp.
     9        But it is difficult to understand what they mean.
     10        So i would like to replace those with more meaningful method for readability.
     11
     12        * UIProcess/API/efl/tests/test_ewk2_text_checker.cpp:
     13        (EWK2TextCheckerTest::clickSelectAllWordsWithSpellcheckButton):
     14        (EWK2TextCheckerTest::clickSelectAllWordsWithoutSpellcheckButton):
     15        (EWK2TextCheckerTest::clickSelectSubWordWithSpellcheckButton):
     16        (EWK2TextCheckerTest::showContextMenuWithFirstLineText):
     17        (EWK2TextCheckerTest::showContextMenuWithSecondLineText):
     18        (EWK2TextCheckerTest::selectFirstWordInFirstLineText):
     19        (EWK2TextCheckerTest::selectFirstWordInSecondLineText):
     20        (TEST_F):
     21
    1222013-07-15  Kangil Han  <kangil.han@samsung.com>
    223
  • trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_text_checker.cpp

    r152414 r152708  
    5454static unsigned contextMenuItemsNumber = 0;
    5555static String knownWord;
     56
     57class EWK2TextCheckerTest : public EWK2UnitTestBase {
     58protected:
     59    enum Line { FirstLine, SecondLine };
     60    enum Button { SelectAllWordsWithSpellcheckButton, SelectAllWordsWithoutSpellcheckButton, SelectSubWordWithSpellcheckButton };
     61
     62    void clickButton(Button button)
     63    {
     64        switch (button) {
     65        case SelectAllWordsWithSpellcheckButton:
     66            mouseClick(60, 60);
     67            break;
     68        case SelectAllWordsWithoutSpellcheckButton:
     69            mouseClick(500, 60);
     70            break;
     71        case SelectSubWordWithSpellcheckButton :
     72            mouseClick(200, 60);
     73            break;
     74        }
     75    }
     76
     77    void showContextMenu(Line line)
     78    {
     79        switch (line) {
     80        case FirstLine:
     81            mouseClick(10, 20, 3);
     82            break;
     83        case SecondLine:
     84            mouseClick(35, 35, 3);
     85            break;
     86        }
     87    }
     88
     89    void selectFirstWord(Line line)
     90    {
     91        switch (line) {
     92        case FirstLine:
     93            mouseDoubleClick(10, 20);
     94            break;
     95        case SecondLine:
     96            mouseDoubleClick(35, 35);
     97            break;
     98        }
     99    }
     100};
    56101
    57102/**
     
    354399 * Test whether there are spelling suggestions when misspelled word is directly context clicked.
    355400 */
    356 TEST_F(EWK2UnitTestBase, spelling_suggestion_for_context_click)
     401TEST_F(EWK2TextCheckerTest, spelling_suggestion_for_context_click)
    357402{
    358403    wasContextMenuShown = false;
     
    361406    ewkViewClass()->context_menu_show = countContextMenuItems;
    362407    ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_selection_tests.html").data()));
    363     mouseClick(10, 20, 3 /* Right button - invoke context menu */);
     408    showContextMenu(FirstLine);
    364409
    365410    ASSERT_TRUE(waitUntilTrue(wasContextMenuShown));
     
    370415    // Testing how many items are in context menu when spellcheck is enabled.
    371416    ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_selection_tests.html").data()));
    372     mouseClick(35, 35, 3 /* Right button - invoke context menu */);
     417    showContextMenu(SecondLine);
    373418
    374419    ASSERT_TRUE(waitUntilTrue(wasContextMenuShown));
     
    380425 * Test whether there are no spelling suggestions when multiple words are selected (that are not a single misspelling).
    381426 */
    382 TEST_F(EWK2UnitTestBase, no_spelling_suggestion_for_multiword_selection)
     427TEST_F(EWK2TextCheckerTest, no_spelling_suggestion_for_multiword_selection)
    383428{
    384429    wasContextMenuShown = false;
     
    387432    ewkViewClass()->context_menu_show = countContextMenuItems;
    388433    ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_selection_tests.html").data()));
    389     mouseClick(500, 60, 1 /* Left button - select all words in field without spellcheck */);
    390     mouseClick(10, 20, 3 /* Right button - invoke context menu */);
     434    clickButton(SelectAllWordsWithoutSpellcheckButton);
     435    showContextMenu(FirstLine);
    391436
    392437    ASSERT_TRUE(waitUntilTrue(wasContextMenuShown));
     
    397442    // Testing how many items are in context menu when multiple words are selected.
    398443    ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_selection_tests.html").data()));
    399     mouseClick(60, 60, 1 /* Left button - select all words in field with spellcheck */);
    400     mouseClick(35, 35, 3 /* Right button - invoke context menu */);
     444    clickButton(SelectAllWordsWithSpellcheckButton);
     445    showContextMenu(SecondLine);
    401446
    402447    ASSERT_TRUE(waitUntilTrue(wasContextMenuShown));
     
    408453 * Test whether there are no spelling suggestions when part of misspelled word are selected.
    409454 */
    410 TEST_F(EWK2UnitTestBase, no_spelling_suggestion_for_subword_selection)
     455TEST_F(EWK2TextCheckerTest, no_spelling_suggestion_for_subword_selection)
    411456{
    412457    wasContextMenuShown = false;
     
    415460    ewkViewClass()->context_menu_show = countContextMenuItems;
    416461    ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_selection_tests.html").data()));
    417     mouseClick(500, 60, 1 /* Left button - select all words in field without spellcheck */);
    418     mouseClick(10, 20, 3 /* Right button - invoke context menu */);
     462    clickButton(SelectAllWordsWithoutSpellcheckButton);
     463    showContextMenu(FirstLine);
    419464
    420465    ASSERT_TRUE(waitUntilTrue(wasContextMenuShown));
     
    425470    // Testing how many items are in context menu when part of word is selected.
    426471    ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_selection_tests.html").data()));
    427     mouseClick(200, 60, 1 /* Left button - select part of word in field with spellcheck */);
    428     mouseClick(35, 35, 3 /* Right button - invoke context menu */);
     472    clickButton(SelectSubWordWithSpellcheckButton);
     473    showContextMenu(SecondLine);
    429474
    430475    ASSERT_TRUE(waitUntilTrue(wasContextMenuShown));
     
    436481 * Test whether context menu spelling items are available when misspelled word has selection as the double click.
    437482 */
    438 TEST_F(EWK2UnitTestBase, spelling_suggestion_for_double_clicked_word)
     483TEST_F(EWK2TextCheckerTest, spelling_suggestion_for_double_clicked_word)
    439484{
    440485    wasContextMenuShown = false;
     
    443488    ewkViewClass()->context_menu_show = countContextMenuItems;
    444489    ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_selection_tests.html").data()));
    445     mouseClick(500, 60, 1 /* Left button - select all words in field without spellcheck */);
    446     mouseClick(10, 20, 3 /* Right button - invoke context menu */);
     490    clickButton(SelectAllWordsWithoutSpellcheckButton);
     491    showContextMenu(FirstLine);
    447492
    448493    ASSERT_TRUE(waitUntilTrue(wasContextMenuShown));
     
    453498    // Making double click on misspelled word to select it, and checking are there context menu spell check suggestions.
    454499    ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_selection_tests.html").data()));
    455     mouseClick(35, 35, 1 /* Left button - 1st click of doubleclick */);
    456     mouseClick(35, 35, 1 /* Left button - 2nd click of doubleclick */);
    457     mouseClick(35, 35, 3 /* Right button - invoke context menu */);
     500    selectFirstWord(SecondLine);
     501    showContextMenu(SecondLine);
    458502
    459503    ASSERT_TRUE(waitUntilTrue(wasContextMenuShown));
     
    466510 * continuous spell checking setting.
    467511 */
    468 TEST_F(EWK2UnitTestBase, ewk_text_checker_spell_checking_languages_get)
     512TEST_F(EWK2TextCheckerTest, ewk_text_checker_spell_checking_languages_get)
    469513{
    470514    ewk_text_checker_continuous_spell_checking_enabled_set(false);
     
    503547 * are available when continuous spell checking is off.
    504548 */
    505 TEST_F(EWK2UnitTestBase, context_menu_spelling_items_availability)
     549TEST_F(EWK2TextCheckerTest, context_menu_spelling_items_availability)
    506550{
    507551    ewk_text_checker_continuous_spell_checking_enabled_set(false);
     
    509553
    510554    ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_test.html").data()));
    511     mouseClick(10, 20, 3 /* Right button */);
     555    showContextMenu(FirstLine);
    512556
    513557    while (!wasContextMenuShown)
     
    520564 *  - ewk_text_checker_continuous_spell_checking_enabled_set
    521565 */
    522 TEST_F(EWK2UnitTestBase, ewk_text_checker_continuous_spell_checking_enabled)
     566TEST_F(EWK2TextCheckerTest, ewk_text_checker_continuous_spell_checking_enabled)
    523567{
    524568    ewk_text_checker_continuous_spell_checking_enabled_set(true);
     
    539583 *  - "Check Spelling While Typing" is disabled.
    540584 */
    541 TEST_F(EWK2UnitTestBase, ewk_text_checker_check_spelling_while_typing_toggle)
     585TEST_F(EWK2TextCheckerTest, ewk_text_checker_check_spelling_while_typing_toggle)
    542586{
    543587    resetCallbacksExecutionStats();
     
    549593    ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_test.html").data()));
    550594
    551     EWK2UnitTestBase::mouseClick(10, 20, /*Right button*/ 3);
     595    showContextMenu(FirstLine);
    552596    ASSERT_TRUE(waitUntilTrue(callbacksExecutionStats.settingChange));
    553597
     
    557601    isSettingEnabled = !isSettingEnabled;
    558602
    559     EWK2UnitTestBase::mouseClick(10, 20, /*Right button*/ 3);
     603    showContextMenu(FirstLine);
    560604    ASSERT_TRUE(waitUntilTrue(callbacksExecutionStats.settingChange));
    561605
     
    566610 * Test whether the onSettingChange callback is not called when the spell checking setting was changed by client.
    567611 */
    568 TEST_F(EWK2UnitTestBase, ewk_text_checker_continuous_spell_checking_change_cb_set)
     612TEST_F(EWK2TextCheckerTest, ewk_text_checker_continuous_spell_checking_change_cb_set)
    569613{
    570614    resetCallbacksExecutionStats();
     
    588632 * "Check Spelling While Typing" option is toggled in context menu.
    589633 */
    590 TEST_F(EWK2UnitTestBase, ewk_text_checker_continuous_spell_checking_change_cb_unset)
     634TEST_F(EWK2TextCheckerTest, ewk_text_checker_continuous_spell_checking_change_cb_unset)
    591635{
    592636    resetCallbacksExecutionStats();
     
    595639    ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_test.html").data()));
    596640
    597     EWK2UnitTestBase::mouseClick(10, 20, /*Right button*/ 3);
     641    showContextMenu(FirstLine);
    598642    ASSERT_FALSE(waitUntilTrue(callbacksExecutionStats.settingChange, /*Timeout*/ 0));
    599643}
     
    604648 * All the dictionaries from the list can be set to perform spellchecking.
    605649 */
    606 TEST_F(EWK2UnitTestBase, ewk_text_checker_spell_checking_available_languages_get)
     650TEST_F(EWK2TextCheckerTest, ewk_text_checker_spell_checking_available_languages_get)
    607651{
    608652    Eina_List* availableLanguages = ewk_text_checker_spell_checking_available_languages_get();
     
    656700 *  - if two arbitrarily selected dictionaries are set correctly.
    657701 */
    658 TEST_F(EWK2UnitTestBase, ewk_text_checker_spell_checking_languages)
     702TEST_F(EWK2TextCheckerTest, ewk_text_checker_spell_checking_languages)
    659703{
    660704    // Set the default language.
     
    717761 * Test whether the client's callbacks aren't called (if not specified).
    718762 */
    719 TEST_F(EWK2UnitTestBase, ewk_text_checker)
     763TEST_F(EWK2TextCheckerTest, ewk_text_checker)
    720764{
    721765    resetCallbacksExecutionStats();
     
    738782 * Test whether the client's callbacks (onSpellDocumentTag, onSpellDocumentTagClose) are called.
    739783 */
    740 TEST_F(EWK2UnitTestBase, ewk_text_checker_unique_spell_document_tag)
     784TEST_F(EWK2TextCheckerTest, ewk_text_checker_unique_spell_document_tag)
    741785{
    742786    resetCallbacksExecutionStats();
     
    760804 * the word to input field was put.
    761805 */
    762 TEST_F(EWK2UnitTestBase, ewk_text_checker_string_spelling_check_cb_set)
     806TEST_F(EWK2TextCheckerTest, ewk_text_checker_string_spelling_check_cb_set)
    763807{
    764808    resetCallbacksExecutionStats();
     
    778822 * the context menu was shown on the misspelled word.
    779823 */
    780 TEST_F(EWK2UnitTestBase, ewk_text_checker_word_guesses_get_cb_set)
     824TEST_F(EWK2TextCheckerTest, ewk_text_checker_word_guesses_get_cb_set)
    781825{
    782826    resetCallbacksExecutionStats();
     
    788832    ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_test.html").data()));
    789833
    790     EWK2UnitTestBase::mouseClick(10, 20, /*Right button*/ 3);
     834    showContextMenu(FirstLine);
    791835    ASSERT_TRUE(waitUntilTrue(wasContextMenuShown));
    792836
     
    802846 * check whether the learned word is treated as spelled correctly while spell checking.
    803847 */
    804 TEST_F(EWK2UnitTestBase, ewk_text_checker_word_learn_cb_set)
     848TEST_F(EWK2TextCheckerTest, ewk_text_checker_word_learn_cb_set)
    805849{
    806850    resetCallbacksExecutionStats();
     
    811855
    812856    ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_test.html").data()));
    813     mouseDoubleClick(10, 20);
    814     mouseClick(10, 20, 3 /* Right button - invoke context menu */);
     857    selectFirstWord(FirstLine);
     858    showContextMenu(FirstLine);
    815859
    816860    ASSERT_TRUE(waitUntilTrue(callbacksExecutionStats.wordLearn));
     
    834878 * check whether the ignored word is treated as spelled correctly while spell checking.
    835879 */
    836 TEST_F(EWK2UnitTestBase, ewk_text_checker_word_ignore_cb_set)
     880TEST_F(EWK2TextCheckerTest, ewk_text_checker_word_ignore_cb_set)
    837881{
    838882    resetCallbacksExecutionStats();
     
    843887
    844888    ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_test.html").data()));
    845     mouseDoubleClick(10, 20);
    846     mouseClick(10, 20, 3 /* Right button - invoke context menu */);
     889    selectFirstWord(FirstLine);
     890    showContextMenu(FirstLine);
    847891
    848892    ASSERT_TRUE(waitUntilTrue(callbacksExecutionStats.wordIgnore));
Note: See TracChangeset for help on using the changeset viewer.