<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[163779] trunk/Source/WebKit2</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/163779">163779</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2014-02-10 05:04:58 -0800 (Mon, 10 Feb 2014)</dd>
</dl>

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

Patch by Lukasz Bialek &lt;l.bialek@samsung.com&gt; on 2014-02-10
Reviewed by Gyuyoung Kim.

<a href="http://trac.webkit.org/projects/webkit/changeset/148670">r148670</a> 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):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIefltestsUnitTestUtilsEWK2UnitTestBasecpp">trunk/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIefltestsUnitTestUtilsEWK2UnitTestBaseh">trunk/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIeflteststest_ewk2_text_checkercpp">trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_text_checker.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (163778 => 163779)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2014-02-10 13:02:35 UTC (rev 163778)
+++ trunk/Source/WebKit2/ChangeLog        2014-02-10 13:04:58 UTC (rev 163779)
</span><span class="lines">@@ -1,3 +1,24 @@
</span><ins>+2014-02-10  Lukasz Bialek  &lt;l.bialek@samsung.com&gt;
+
+        [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):
+
</ins><span class="cx"> 2014-02-09  Carlos Garnacho  &lt;carlosg@gnome.org&gt;
</span><span class="cx"> 
</span><span class="cx">         [GTK] Implement support touch events
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIefltestsUnitTestUtilsEWK2UnitTestBasecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp (163778 => 163779)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp        2014-02-10 13:02:35 UTC (rev 163778)
+++ trunk/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp        2014-02-10 13:04:58 UTC (rev 163779)
</span><span class="lines">@@ -235,6 +235,29 @@
</span><span class="cx">     return !data.didTimeOut();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+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&lt;bool&gt; data(true, timeoutValue);
+    while ((eina_list_count(loadedLanguages) != expectedLanguageCount) &amp;&amp; !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&lt;const char*&gt;(actual));
+        }
+
+        loadedLanguages = ewk_text_checker_spell_checking_languages_get();
+        ecore_main_loop_iterate();
+    }
+
+    return loadedLanguages;
+}
+
</ins><span class="cx"> void EWK2UnitTestBase::mouseClick(int x, int y, int button)
</span><span class="cx"> {
</span><span class="cx">     Evas* evas = evas_object_evas_get(m_webView);
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIefltestsUnitTestUtilsEWK2UnitTestBaseh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h (163778 => 163779)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h        2014-02-10 13:02:35 UTC (rev 163778)
+++ trunk/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h        2014-02-10 13:04:58 UTC (rev 163779)
</span><span class="lines">@@ -51,6 +51,7 @@
</span><span class="cx">     bool waitUntilTitleChangedTo(const char* expectedTitle, double timeoutSeconds = defaultTimeoutSeconds);
</span><span class="cx">     bool waitUntilURLChangedTo(const char* expectedURL, double timeoutSeconds = defaultTimeoutSeconds);
</span><span class="cx">     bool waitUntilTrue(bool &amp;flag, double timeoutSeconds = defaultTimeoutSeconds);
</span><ins>+    Eina_List* waitUntilSpellingLanguagesLoaded(unsigned expectedLanguageCount, double timeoutValue = defaultTimeoutSeconds);
</ins><span class="cx"> 
</span><span class="cx">     void mouseClick(int x, int y, int button = 1 /*Left*/);
</span><span class="cx">     void mouseDoubleClick(int x, int y, int button = 1 /*Left*/);
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIeflteststest_ewk2_text_checkercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_text_checker.cpp (163778 => 163779)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_text_checker.cpp        2014-02-10 13:02:35 UTC (rev 163778)
+++ trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_text_checker.cpp        2014-02-10 13:04:58 UTC (rev 163779)
</span><span class="lines">@@ -42,7 +42,6 @@
</span><span class="cx"> static const char expectedMisspelledWord[] = &quot;aa&quot;;
</span><span class="cx"> static const Evas_Object* defaultView = 0;
</span><span class="cx"> static bool isSettingEnabled = false;
</span><del>-static Ecore_Timer* timeoutTimer = 0;
</del><span class="cx"> static double defaultTimeoutInSeconds = 0.5;
</span><span class="cx"> 
</span><span class="cx"> static bool wasContextMenuShown = false;
</span><span class="lines">@@ -79,19 +78,6 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     /**
</span><del>-     * 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;
-    }
-
-    /**
</del><span class="cx">      * This callback tests whether the client's callback is called when the spell checking setting was changed.
</span><span class="cx">      *
</span><span class="cx">      * @internal
</span><span class="lines">@@ -505,11 +491,8 @@
</span><span class="cx"> TEST_F(EWK2TextCheckerTest, ewk_text_checker_spell_checking_languages_get)
</span><span class="cx"> {
</span><span class="cx">     ewk_text_checker_continuous_spell_checking_enabled_set(false);
</span><del>-    // The language is being loaded on the idler, wait for it.
-    timeoutTimer = ecore_timer_add(defaultTimeoutInSeconds, onTimeout, 0);
-    ecore_main_loop_begin();
</del><span class="cx"> 
</span><del>-    Eina_List* loadedLanguages = ewk_text_checker_spell_checking_languages_get();
</del><ins>+    Eina_List* loadedLanguages = waitUntilSpellingLanguagesLoaded(1, defaultTimeoutInSeconds);
</ins><span class="cx">     // No dictionary is available/installed.
</span><span class="cx">     if (!loadedLanguages)
</span><span class="cx">         return;
</span><span class="lines">@@ -522,10 +505,8 @@
</span><span class="cx"> 
</span><span class="cx">     // Repeat the checking when continuous spell checking setting is on.
</span><span class="cx">     ewk_text_checker_continuous_spell_checking_enabled_set(true);
</span><del>-    timeoutTimer = ecore_timer_add(defaultTimeoutInSeconds, onTimeout, 0);
-    ecore_main_loop_begin();
</del><span class="cx"> 
</span><del>-    loadedLanguages = ewk_text_checker_spell_checking_languages_get();
</del><ins>+    loadedLanguages = waitUntilSpellingLanguagesLoaded(1, defaultTimeoutInSeconds);
</ins><span class="cx">     if (!loadedLanguages)
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="lines">@@ -664,12 +645,8 @@
</span><span class="cx">     // Set all available languages.
</span><span class="cx">     ewk_text_checker_spell_checking_languages_set(languages.toString().utf8().data());
</span><span class="cx"> 
</span><del>-    // Languages are being loaded on the idler, wait for them.
-    timeoutTimer = ecore_timer_add(defaultTimeoutInSeconds, onTimeout, 0);
-    ecore_main_loop_begin();
-
</del><span class="cx">     // Get the languages in use.
</span><del>-    Eina_List* loadedLanguages = ewk_text_checker_spell_checking_languages_get();
</del><ins>+    Eina_List* loadedLanguages = waitUntilSpellingLanguagesLoaded(eina_list_count(availableLanguages), defaultTimeoutInSeconds);
</ins><span class="cx">     ASSERT_EQ(eina_list_count(loadedLanguages), eina_list_count(availableLanguages));
</span><span class="cx"> 
</span><span class="cx">     i = 0;
</span><span class="lines">@@ -698,11 +675,7 @@
</span><span class="cx">     // Set the default language.
</span><span class="cx">     ewk_text_checker_spell_checking_languages_set(0);
</span><span class="cx"> 
</span><del>-    // 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();
</del><ins>+    Eina_List* loadedLanguages = waitUntilSpellingLanguagesLoaded(1, defaultTimeoutInSeconds);
</ins><span class="cx">     // No dictionary is available/installed or the SPELLCHECK macro is disabled.
</span><span class="cx">     if (!loadedLanguages)
</span><span class="cx">         return;
</span><span class="lines">@@ -734,10 +707,7 @@
</span><span class="cx">     // Set both languages (the first and the last) from the list.
</span><span class="cx">     ewk_text_checker_spell_checking_languages_set(languages.toString().utf8().data());
</span><span class="cx"> 
</span><del>-    timeoutTimer = ecore_timer_add(defaultTimeoutInSeconds, onTimeout, 0);
-    ecore_main_loop_begin();
-
-    loadedLanguages = ewk_text_checker_spell_checking_languages_get();
</del><ins>+    loadedLanguages = waitUntilSpellingLanguagesLoaded(2, defaultTimeoutInSeconds);
</ins><span class="cx">     ASSERT_EQ(2, eina_list_count(loadedLanguages));
</span><span class="cx"> 
</span><span class="cx">     EXPECT_STREQ(firstExpected, static_cast&lt;const char*&gt;(eina_list_nth(loadedLanguages, 0)));
</span></span></pre>
</div>
</div>

</body>
</html>