Changeset 152414 in webkit


Ignore:
Timestamp:
Jul 5, 2013 3:29:12 AM (11 years ago)
Author:
commit-queue@webkit.org
Message:

[EFL][WK2] Implement unit test callbacks: onWordLearn and onWordIgnore.
https://bugs.webkit.org/show_bug.cgi?id=118392

Patch by Krzysztof Wolanski <k.wolanski@samsung.com> on 2013-07-05
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):

Location:
trunk/Source/WebKit2
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r152412 r152414  
     12013-07-05  Krzysztof Wolanski  <k.wolanski@samsung.com>
     2
     3        [EFL][WK2] Implement unit test callbacks: onWordLearn and onWordIgnore.
     4        https://bugs.webkit.org/show_bug.cgi?id=118392
     5
     6        Reviewed by Christophe Dumez.
     7
     8        Simulate behavior of Learn and Ignore Word in the text field.
     9
     10        * UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp:
     11        (EWK2UnitTest::EWK2UnitTestBase::mouseDoubleClick):
     12        Select the entire word in the text field.
     13
     14        * UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h:
     15        * UIProcess/API/efl/tests/test_ewk2_text_checker.cpp:
     16        (onSpellingForKnownWord):
     17        (onWordLearn):
     18        (onWordIgnore):
     19        (selectLearnSpelling):
     20        (selectIgnoreSpelling):
     21
    1222013-07-05  Xabier Rodriguez Calvar  <calvaris@igalia.com>
    223
  • trunk/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp

    r151433 r152414  
    244244}
    245245
     246void EWK2UnitTestBase::mouseDoubleClick(int x, int y, int button)
     247{
     248    Evas* evas = evas_object_evas_get(m_webView);
     249    evas_event_feed_mouse_move(evas, x, y, 0, 0);
     250    evas_event_feed_mouse_down(evas, button, EVAS_BUTTON_DOUBLE_CLICK, 0, 0);
     251    evas_event_feed_mouse_up(evas, button, EVAS_BUTTON_NONE, 0, 0);
     252}
     253
    246254void EWK2UnitTestBase::mouseDown(int x, int y, int button)
    247255{
  • trunk/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h

    r151428 r152414  
    5454
    5555    void mouseClick(int x, int y, int button = 1 /*Left*/);
     56    void mouseDoubleClick(int x, int y, int button = 1 /*Left*/);
    5657    void mouseDown(int x, int y, int button = 1 /*Left*/);
    5758    void mouseUp(int x, int y, int button = 1 /*Left*/);
  • trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_text_checker.cpp

    r152153 r152414  
    5353static const char* clientSuggestionsForWord[] = { "clientSuggestion1", "clientSuggestion2", "clientSuggestion3" };
    5454static unsigned contextMenuItemsNumber = 0;
     55static String knownWord;
    5556
    5657/**
     
    169170
    170171/**
     172 * Checks spelling for the given @a text and compares it with the knownWord.
     173 *
     174 * @internal
     175 *
     176 * @param text the text containing the words to spellcheck
     177 * @param misspelling_location a pointer to store the beginning of the misspelled @a text, @c -1 if the @a text is correct
     178 * @param misspelling_length a pointer to store the length of misspelled @a text, @c 0 if the @a text is correct
     179 */
     180static void onSpellingForKnownWord(uint64_t, const char* text, int32_t* misspellingLocation, int32_t* misspellingLength)
     181{
     182    ASSERT_STREQ(knownWord.utf8().data(), text);
     183
     184    ASSERT_TRUE(misspellingLocation);
     185    ASSERT_TRUE(misspellingLength);
     186
     187    *misspellingLocation = -1;
     188    *misspellingLength = 0;
     189
     190    callbacksExecutionStats.spellingCheck = true;
     191}
     192
     193/**
    171194 * Gets a list of suggested spellings for a misspelled @a word.
    172195 *
     
    204227    ASSERT_EQ(defaultDocumentTag, tag);
    205228    ASSERT_STREQ(expectedMisspelledWord, word);
     229    knownWord = word;
    206230    callbacksExecutionStats.wordLearn = true;
    207231}
     
    219243    ASSERT_EQ(defaultDocumentTag, tag);
    220244    ASSERT_STREQ(expectedMisspelledWord, word);
     245    knownWord = word;
    221246    callbacksExecutionStats.wordIgnore = true;
    222247}
     
    306331}
    307332
     333static Eina_Bool selectLearnSpelling(Ewk_View_Smart_Data*, Evas_Coord, Evas_Coord, Ewk_Context_Menu* contextMenu)
     334{
     335    return ewk_context_menu_item_select(contextMenu, findContextMenuItem(contextMenu, EWK_CONTEXT_MENU_ITEM_TAG_LEARN_SPELLING, EWK_ACTION_TYPE));
     336}
     337
     338static Eina_Bool selectIgnoreSpelling(Ewk_View_Smart_Data*, Evas_Coord, Evas_Coord, Ewk_Context_Menu* contextMenu)
     339{
     340    return ewk_context_menu_item_select(contextMenu, findContextMenuItem(contextMenu, EWK_CONTEXT_MENU_ITEM_TAG_IGNORE_SPELLING, EWK_ACTION_TYPE));
     341}
     342
    308343/**
    309344 * Count number of elements in context menu.
     
    764799/**
    765800 * Test whether the client's callback (onWordLearn) is called when
    766  * the context menu option "Learn spelling" was choosen.
     801 * the context menu option "Learn spelling" was chosen. In the next step,
     802 * check whether the learned word is treated as spelled correctly while spell checking.
    767803 */
    768804TEST_F(EWK2UnitTestBase, ewk_text_checker_word_learn_cb_set)
    769805{
    770806    resetCallbacksExecutionStats();
     807    knownWord = emptyString();
    771808    defaultView = webView();
    772     ewk_text_checker_continuous_spell_checking_enabled_set(true);
    773 
    774809    ewk_text_checker_word_learn_cb_set(onWordLearn);
    775 
    776     ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_test.html").data()));
    777 
    778     /* FIXME:
    779         1) Invoke the context menu on the misspelled word (not implemented for WK2),
    780            the word has to be selected first.
    781         2) Check whether the callback was called. */
     810    ewkViewClass()->context_menu_show = selectLearnSpelling;
     811
     812    ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_test.html").data()));
     813    mouseDoubleClick(10, 20);
     814    mouseClick(10, 20, 3 /* Right button - invoke context menu */);
     815
     816    ASSERT_TRUE(waitUntilTrue(callbacksExecutionStats.wordLearn));
     817
     818    // Open html again and check whether the learned word
     819    // is treated as spelled correctly while spell checking.
     820    resetCallbacksExecutionStats();
     821    ewk_text_checker_string_spelling_check_cb_set(onSpellingForKnownWord);
     822
     823    ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_test.html").data()));
     824
     825    ASSERT_TRUE(callbacksExecutionStats.spellingCheck);
     826
     827    ewk_text_checker_string_spelling_check_cb_set(0);
     828    ewk_text_checker_word_learn_cb_set(0);
    782829}
    783830
    784831/**
    785832 * Test whether the client's callback (onWordIgnore) is called when
    786  * the context menu option "Ignore spelling" was choosen.
     833 * the context menu option "Ignore spelling" was chosen. In the next step,
     834 * check whether the ignored word is treated as spelled correctly while spell checking.
    787835 */
    788836TEST_F(EWK2UnitTestBase, ewk_text_checker_word_ignore_cb_set)
    789837{
    790838    resetCallbacksExecutionStats();
     839    knownWord = emptyString();
    791840    defaultView = webView();
    792     ewk_text_checker_continuous_spell_checking_enabled_set(true);
    793 
    794841    ewk_text_checker_word_ignore_cb_set(onWordIgnore);
    795 
    796     ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_test.html").data()));
    797 
    798     /* FIXME:
    799         1) Invoke the context menu on the misspelled word (not implemented for WK2),
    800            the word has to be selected first.
    801         2) Check whether the callback was called. */
    802 }
     842    ewkViewClass()->context_menu_show = selectIgnoreSpelling;
     843
     844    ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_test.html").data()));
     845    mouseDoubleClick(10, 20);
     846    mouseClick(10, 20, 3 /* Right button - invoke context menu */);
     847
     848    ASSERT_TRUE(waitUntilTrue(callbacksExecutionStats.wordIgnore));
     849
     850    // Open html again and check whether the ignored word
     851    // is treated as spelled correctly while spell checking.
     852    resetCallbacksExecutionStats();
     853    ewk_text_checker_string_spelling_check_cb_set(onSpellingForKnownWord);
     854
     855    ASSERT_TRUE(loadUrlSync(environment->urlForResource("spelling_test.html").data()));
     856
     857    ASSERT_TRUE(callbacksExecutionStats.spellingCheck);
     858
     859    ewk_text_checker_string_spelling_check_cb_set(0);
     860    ewk_text_checker_word_ignore_cb_set(0);
     861}
Note: See TracChangeset for help on using the changeset viewer.