Skip to content
Permalink
Browse files
[EFL] Spelling unit tests should use ecore_main_loop_iterate()
https://bugs.webkit.org/show_bug.cgi?id=127427

Patch by Lukasz Bialek <l.bialek@samsung.com> on 2014-02-10
Reviewed by Gyuyoung Kim.

r148670 gets rid of EFL's idlers in a favor of timers to load languages.
ecore_main_loop_iterate() can be used now.

Add function that loads spellchecking languages and waits for loading
to be finished:
* UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp:
(EWK2UnitTest::EWK2UnitTestBase::waitForLanguageLoading):
* UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h:

Apply added function to tests that should wait for languages to be loaded:
* UIProcess/API/efl/tests/test_ewk2_text_checker.cpp:
(EWK2TextCheckerTest::resetCallbacksExecutionStats):
(TEST_F):

Canonical link: https://commits.webkit.org/146541@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@163779 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Lukasz Bialek authored and webkit-commit-queue committed Feb 10, 2014
1 parent eb894d1 commit 3b1cfab97647203e8f6dc6ef7c68e29716010963
@@ -1,3 +1,24 @@
2014-02-10 Lukasz Bialek <l.bialek@samsung.com>

[EFL] Spelling unit tests should use ecore_main_loop_iterate()
https://bugs.webkit.org/show_bug.cgi?id=127427

Reviewed by Gyuyoung Kim.

r148670 gets rid of EFL's idlers in a favor of timers to load languages.
ecore_main_loop_iterate() can be used now.

Add function that loads spellchecking languages and waits for loading
to be finished:
* UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp:
(EWK2UnitTest::EWK2UnitTestBase::waitForLanguageLoading):
* UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h:

Apply added function to tests that should wait for languages to be loaded:
* UIProcess/API/efl/tests/test_ewk2_text_checker.cpp:
(EWK2TextCheckerTest::resetCallbacksExecutionStats):
(TEST_F):

2014-02-09 Carlos Garnacho <carlosg@gnome.org>

[GTK] Implement support touch events
@@ -235,6 +235,29 @@ bool EWK2UnitTestBase::waitUntilTrue(bool &flag, double timeoutSeconds)
return !data.didTimeOut();
}

Eina_List* EWK2UnitTestBase::waitUntilSpellingLanguagesLoaded(unsigned expectedLanguageCount, double timeoutValue)
{
// Keep waiting until all languages has been loaded or leave afqter timeout.
// Languages are being loaded in the timer, we have to wait for them.
Eina_List* loadedLanguages = nullptr;
void* actual = nullptr;

CallbackDataExpectedValue<bool> data(true, timeoutValue);
while ((eina_list_count(loadedLanguages) != expectedLanguageCount) && !data.isDone()) {
if (loadedLanguages) {
// List has to be freed before acquiring new one.
actual = nullptr;
EINA_LIST_FREE(loadedLanguages, actual)
eina_stringshare_del(static_cast<const char*>(actual));
}

loadedLanguages = ewk_text_checker_spell_checking_languages_get();
ecore_main_loop_iterate();
}

return loadedLanguages;
}

void EWK2UnitTestBase::mouseClick(int x, int y, int button)
{
Evas* evas = evas_object_evas_get(m_webView);
@@ -51,6 +51,7 @@ class EWK2UnitTestBase : public ::testing::Test {
bool waitUntilTitleChangedTo(const char* expectedTitle, double timeoutSeconds = defaultTimeoutSeconds);
bool waitUntilURLChangedTo(const char* expectedURL, double timeoutSeconds = defaultTimeoutSeconds);
bool waitUntilTrue(bool &flag, double timeoutSeconds = defaultTimeoutSeconds);
Eina_List* waitUntilSpellingLanguagesLoaded(unsigned expectedLanguageCount, double timeoutValue = defaultTimeoutSeconds);

void mouseClick(int x, int y, int button = 1 /*Left*/);
void mouseDoubleClick(int x, int y, int button = 1 /*Left*/);
@@ -42,7 +42,6 @@ static const uint64_t defaultDocumentTag = 123;
static const char expectedMisspelledWord[] = "aa";
static const Evas_Object* defaultView = 0;
static bool isSettingEnabled = false;
static Ecore_Timer* timeoutTimer = 0;
static double defaultTimeoutInSeconds = 0.5;

static bool wasContextMenuShown = false;
@@ -78,19 +77,6 @@ class EWK2TextCheckerTest : public EWK2UnitTestBase {
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;
}

/**
* This callback tests whether the client's callback is called when the spell checking setting was changed.
*
@@ -505,11 +491,8 @@ TEST_F(EWK2TextCheckerTest, spelling_suggestion_for_double_clicked_word)
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.
timeoutTimer = ecore_timer_add(defaultTimeoutInSeconds, onTimeout, 0);
ecore_main_loop_begin();

Eina_List* loadedLanguages = ewk_text_checker_spell_checking_languages_get();
Eina_List* loadedLanguages = waitUntilSpellingLanguagesLoaded(1, defaultTimeoutInSeconds);
// No dictionary is available/installed.
if (!loadedLanguages)
return;
@@ -522,10 +505,8 @@ TEST_F(EWK2TextCheckerTest, ewk_text_checker_spell_checking_languages_get)

// Repeat the checking when continuous spell checking setting is on.
ewk_text_checker_continuous_spell_checking_enabled_set(true);
timeoutTimer = ecore_timer_add(defaultTimeoutInSeconds, onTimeout, 0);
ecore_main_loop_begin();

loadedLanguages = ewk_text_checker_spell_checking_languages_get();
loadedLanguages = waitUntilSpellingLanguagesLoaded(1, defaultTimeoutInSeconds);
if (!loadedLanguages)
return;

@@ -664,12 +645,8 @@ TEST_F(EWK2TextCheckerTest, ewk_text_checker_spell_checking_available_languages_
// Set all available languages.
ewk_text_checker_spell_checking_languages_set(languages.toString().utf8().data());

// Languages are being loaded on the idler, wait for them.
timeoutTimer = ecore_timer_add(defaultTimeoutInSeconds, onTimeout, 0);
ecore_main_loop_begin();

// Get the languages in use.
Eina_List* loadedLanguages = ewk_text_checker_spell_checking_languages_get();
Eina_List* loadedLanguages = waitUntilSpellingLanguagesLoaded(eina_list_count(availableLanguages), defaultTimeoutInSeconds);
ASSERT_EQ(eina_list_count(loadedLanguages), eina_list_count(availableLanguages));

i = 0;
@@ -698,11 +675,7 @@ TEST_F(EWK2TextCheckerTest, ewk_text_checker_spell_checking_languages)
// Set the default language.
ewk_text_checker_spell_checking_languages_set(0);

// Languages are being loaded on the idler, wait for them.
timeoutTimer = ecore_timer_add(defaultTimeoutInSeconds, onTimeout, 0);
ecore_main_loop_begin();

Eina_List* loadedLanguages = ewk_text_checker_spell_checking_languages_get();
Eina_List* loadedLanguages = waitUntilSpellingLanguagesLoaded(1, defaultTimeoutInSeconds);
// No dictionary is available/installed or the SPELLCHECK macro is disabled.
if (!loadedLanguages)
return;
@@ -734,10 +707,7 @@ TEST_F(EWK2TextCheckerTest, ewk_text_checker_spell_checking_languages)
// Set both languages (the first and the last) from the list.
ewk_text_checker_spell_checking_languages_set(languages.toString().utf8().data());

timeoutTimer = ecore_timer_add(defaultTimeoutInSeconds, onTimeout, 0);
ecore_main_loop_begin();

loadedLanguages = ewk_text_checker_spell_checking_languages_get();
loadedLanguages = waitUntilSpellingLanguagesLoaded(2, defaultTimeoutInSeconds);
ASSERT_EQ(2, eina_list_count(loadedLanguages));

EXPECT_STREQ(firstExpected, static_cast<const char*>(eina_list_nth(loadedLanguages, 0)));

0 comments on commit 3b1cfab

Please sign in to comment.