Changeset 152153 in webkit


Ignore:
Timestamp:
Jun 28, 2013 12:34:43 AM (11 years ago)
Author:
commit-queue@webkit.org
Message:

[EFL][WK2] Add spellcheck API tests in unit tests.
https://bugs.webkit.org/show_bug.cgi?id=118123

Patch by Dariusz Frankiewicz <Dariusz Frankiewicz> on 2013-06-28
Reviewed by Christophe Dumez.

According to discussion in bug https://bugs.webkit.org/show_bug.cgi?id=113742
we're moving spelling tests from layout tests to unit tests.

  • UIProcess/API/efl/tests/resources/spelling_selection_tests.html: Added.

New file is needed to make tests, with and without spellcheck attribute.
File contains basic site with content editable fields and buttons which select
different parts of misspelled words.

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

(countContextMenuItems):
Added method used to count number of items in context menu.

Location:
trunk/Source/WebKit2
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r152149 r152153  
     12013-06-28  Dariusz Frankiewicz  <d.frankiewic@samsung.com>
     2
     3        [EFL][WK2] Add spellcheck API tests in unit tests.
     4        https://bugs.webkit.org/show_bug.cgi?id=118123
     5
     6        Reviewed by Christophe Dumez.
     7
     8        According to discussion in bug https://bugs.webkit.org/show_bug.cgi?id=113742
     9        we're moving spelling tests from layout tests to unit tests.
     10
     11        * UIProcess/API/efl/tests/resources/spelling_selection_tests.html: Added.
     12        New file is needed to make tests, with and without spellcheck attribute.
     13        File contains basic site with content editable fields and buttons which select
     14        different parts of misspelled words.
     15
     16        * UIProcess/API/efl/tests/test_ewk2_text_checker.cpp:
     17        (countContextMenuItems):
     18        Added method used to count number of items in context menu.
     19
    1202013-06-27  Kangil Han  <kangil.han@samsung.com>
    221
  • trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_text_checker.cpp

    r151904 r152153  
    5252
    5353static const char* clientSuggestionsForWord[] = { "clientSuggestion1", "clientSuggestion2", "clientSuggestion3" };
     54static unsigned contextMenuItemsNumber = 0;
    5455
    5556/**
     
    306307
    307308/**
     309 * Count number of elements in context menu.
     310 */
     311static Eina_Bool countContextMenuItems(Ewk_View_Smart_Data*, Evas_Coord, Evas_Coord, Ewk_Context_Menu* contextMenu)
     312{
     313    contextMenuItemsNumber = eina_list_count(ewk_context_menu_items_get(contextMenu));
     314    wasContextMenuShown = true;
     315    return true;
     316}
     317
     318/**
     319 * Test whether there are spelling suggestions when misspelled word is directly context clicked.
     320 */
     321TEST_F(EWK2UnitTestBase, spelling_suggestion_for_context_click)
     322{
     323    wasContextMenuShown = false;
     324
     325    // Checking number of context menu items when element has no spellcheck suggestions.
     326    ewkViewClass()->context_menu_show = countContextMenuItems;
     327    ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_selection_tests.html").data()));
     328    mouseClick(10, 20, 3 /* Right button - invoke context menu */);
     329
     330    ASSERT_TRUE(waitUntilTrue(wasContextMenuShown));
     331    unsigned numberItemsWithoutSpellCheck = contextMenuItemsNumber;
     332
     333    wasContextMenuShown = false;
     334
     335    // Testing how many items are in context menu when spellcheck is enabled.
     336    ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_selection_tests.html").data()));
     337    mouseClick(35, 35, 3 /* Right button - invoke context menu */);
     338
     339    ASSERT_TRUE(waitUntilTrue(wasContextMenuShown));
     340
     341    EXPECT_LT(numberItemsWithoutSpellCheck, contextMenuItemsNumber);
     342}
     343
     344/**
     345 * Test whether there are no spelling suggestions when multiple words are selected (that are not a single misspelling).
     346 */
     347TEST_F(EWK2UnitTestBase, no_spelling_suggestion_for_multiword_selection)
     348{
     349    wasContextMenuShown = false;
     350
     351    // Checking number of context menu items when element has no spellcheck suggestions.
     352    ewkViewClass()->context_menu_show = countContextMenuItems;
     353    ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_selection_tests.html").data()));
     354    mouseClick(500, 60, 1 /* Left button - select all words in field without spellcheck */);
     355    mouseClick(10, 20, 3 /* Right button - invoke context menu */);
     356
     357    ASSERT_TRUE(waitUntilTrue(wasContextMenuShown));
     358    unsigned numberItemsWithoutSpellCheck = contextMenuItemsNumber;
     359
     360    wasContextMenuShown = false;
     361
     362    // Testing how many items are in context menu when multiple words are selected.
     363    ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_selection_tests.html").data()));
     364    mouseClick(60, 60, 1 /* Left button - select all words in field with spellcheck */);
     365    mouseClick(35, 35, 3 /* Right button - invoke context menu */);
     366
     367    ASSERT_TRUE(waitUntilTrue(wasContextMenuShown));
     368
     369    EXPECT_EQ(numberItemsWithoutSpellCheck, contextMenuItemsNumber);
     370}
     371
     372/**
     373 * Test whether there are no spelling suggestions when part of misspelled word are selected.
     374 */
     375TEST_F(EWK2UnitTestBase, no_spelling_suggestion_for_subword_selection)
     376{
     377    wasContextMenuShown = false;
     378
     379    // Checking number of context menu items when element has no spellcheck suggestions.
     380    ewkViewClass()->context_menu_show = countContextMenuItems;
     381    ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_selection_tests.html").data()));
     382    mouseClick(500, 60, 1 /* Left button - select all words in field without spellcheck */);
     383    mouseClick(10, 20, 3 /* Right button - invoke context menu */);
     384
     385    ASSERT_TRUE(waitUntilTrue(wasContextMenuShown));
     386    unsigned numberItemsWithoutSpellCheck = contextMenuItemsNumber;
     387
     388    wasContextMenuShown = false;
     389
     390    // Testing how many items are in context menu when part of word is selected.
     391    ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_selection_tests.html").data()));
     392    mouseClick(200, 60, 1 /* Left button - select part of word in field with spellcheck */);
     393    mouseClick(35, 35, 3 /* Right button - invoke context menu */);
     394
     395    ASSERT_TRUE(waitUntilTrue(wasContextMenuShown));
     396
     397    EXPECT_EQ(numberItemsWithoutSpellCheck, contextMenuItemsNumber);
     398}
     399
     400/**
     401 * Test whether context menu spelling items are available when misspelled word has selection as the double click.
     402 */
     403TEST_F(EWK2UnitTestBase, spelling_suggestion_for_double_clicked_word)
     404{
     405    wasContextMenuShown = false;
     406
     407    // Checking number of context menu items when element has no spell check suggestions.
     408    ewkViewClass()->context_menu_show = countContextMenuItems;
     409    ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_selection_tests.html").data()));
     410    mouseClick(500, 60, 1 /* Left button - select all words in field without spellcheck */);
     411    mouseClick(10, 20, 3 /* Right button - invoke context menu */);
     412
     413    ASSERT_TRUE(waitUntilTrue(wasContextMenuShown));
     414    unsigned numberItemsWithoutSpellCheck = contextMenuItemsNumber;
     415
     416    wasContextMenuShown = false;
     417
     418    // Making double click on misspelled word to select it, and checking are there context menu spell check suggestions.
     419    ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_selection_tests.html").data()));
     420    mouseClick(35, 35, 1 /* Left button - 1st click of doubleclick */);
     421    mouseClick(35, 35, 1 /* Left button - 2nd click of doubleclick */);
     422    mouseClick(35, 35, 3 /* Right button - invoke context menu */);
     423
     424    ASSERT_TRUE(waitUntilTrue(wasContextMenuShown));
     425
     426    EXPECT_LT(numberItemsWithoutSpellCheck, contextMenuItemsNumber);
     427}
     428
     429/**
    308430 * Test whether the default language is loaded independently of
    309431 * continuous spell checking setting.
Note: See TracChangeset for help on using the changeset viewer.