<!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>[161139] 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/161139">161139</a></dd>
<dt>Author</dt> <dd>m.pakula@samsung.com</dd>
<dt>Date</dt> <dd>2013-12-30 02:26:00 -0800 (Mon, 30 Dec 2013)</dd>
</dl>
<h3>Log Message</h3>
<pre>[EFL][WK2] Replace ecore_main_loop_iterate with waitUntilTrue in ewk tests
https://bugs.webkit.org/show_bug.cgi?id=125919
Reviewed by Gyuyoung Kim.
Using ecore_main_loop_iterate in while loop may result in tests hang-up when
condition is not met. Replacing it with waitUntilTrue introduces a timer
after which internal loop is canceled. This will cause test to fail instead
of running infinitely.
* UIProcess/API/efl/tests/test_ewk2_auth_request.cpp:
(TEST_F):
* UIProcess/API/efl/tests/test_ewk2_color_picker.cpp:
(TEST_F):
* UIProcess/API/efl/tests/test_ewk2_cookie_manager.cpp:
(TEST_F):
* UIProcess/API/efl/tests/test_ewk2_view.cpp:
(EWK2ViewTest::onVibrate):
(EWK2ViewTest::onCancelVibration):
(EWK2ViewTest::loadVibrationHTMLString):
(TEST_F):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIeflteststest_ewk2_auth_requestcpp">trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_auth_request.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIeflteststest_ewk2_color_pickercpp">trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_color_picker.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIeflteststest_ewk2_cookie_managercpp">trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_cookie_manager.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIeflteststest_ewk2_viewcpp">trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (161138 => 161139)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2013-12-30 09:58:14 UTC (rev 161138)
+++ trunk/Source/WebKit2/ChangeLog        2013-12-30 10:26:00 UTC (rev 161139)
</span><span class="lines">@@ -1,3 +1,27 @@
</span><ins>+2013-12-30 Michał Pakuła vel Rutka <m.pakula@samsung.com>
+
+ [EFL][WK2] Replace ecore_main_loop_iterate with waitUntilTrue in ewk tests
+ https://bugs.webkit.org/show_bug.cgi?id=125919
+
+ Reviewed by Gyuyoung Kim.
+
+ Using ecore_main_loop_iterate in while loop may result in tests hang-up when
+ condition is not met. Replacing it with waitUntilTrue introduces a timer
+ after which internal loop is canceled. This will cause test to fail instead
+ of running infinitely.
+
+ * UIProcess/API/efl/tests/test_ewk2_auth_request.cpp:
+ (TEST_F):
+ * UIProcess/API/efl/tests/test_ewk2_color_picker.cpp:
+ (TEST_F):
+ * UIProcess/API/efl/tests/test_ewk2_cookie_manager.cpp:
+ (TEST_F):
+ * UIProcess/API/efl/tests/test_ewk2_view.cpp:
+ (EWK2ViewTest::onVibrate):
+ (EWK2ViewTest::onCancelVibration):
+ (EWK2ViewTest::loadVibrationHTMLString):
+ (TEST_F):
+
</ins><span class="cx"> 2013-12-30 Carlos Garcia Campos <cgarcia@igalia.com>
</span><span class="cx">
</span><span class="cx"> [GTK] Split WebKit2APITests/TestWebKitWebView
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIeflteststest_ewk2_auth_requestcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_auth_request.cpp (161138 => 161139)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_auth_request.cpp        2013-12-30 09:58:14 UTC (rev 161138)
+++ trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_auth_request.cpp        2013-12-30 10:26:00 UTC (rev 161139)
</span><span class="lines">@@ -182,8 +182,7 @@
</span><span class="cx"> // Will attempt to continue without authentication by default.
</span><span class="cx"> ewk_object_unref(authenticationRequest);
</span><span class="cx">
</span><del>- while (!isFinished)
- ecore_main_loop_iterate();
</del><ins>+ waitUntilTrue(isFinished);
</ins><span class="cx">
</span><span class="cx"> ASSERT_STRNE(expectedSuccessTitle, ewk_view_title_get(webView()));
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIeflteststest_ewk2_color_pickercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_color_picker.cpp (161138 => 161139)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_color_picker.cpp        2013-12-30 09:58:14 UTC (rev 161138)
+++ trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_color_picker.cpp        2013-12-30 10:26:00 UTC (rev 161139)
</span><span class="lines">@@ -155,21 +155,18 @@
</span><span class="cx">
</span><span class="cx"> bool handled = false;
</span><span class="cx"> evas_object_smart_callback_add(webView(), "input,type,color,request", onColorPickerDone, &handled);
</span><del>- while (!handled)
- ecore_main_loop_iterate();
</del><ins>+ waitUntilTrue(handled);
</ins><span class="cx">
</span><span class="cx"> clickButton(ShowColorPickerButton);
</span><span class="cx">
</span><span class="cx"> handled = false;
</span><del>- while (!handled)
- ecore_main_loop_iterate();
</del><ins>+ waitUntilTrue(handled);
</ins><span class="cx">
</span><span class="cx"> api->input_picker_color_dismiss = hideColorPickerByRemovingElement;
</span><span class="cx"> clickButton(HideColorPickerButton);
</span><span class="cx">
</span><span class="cx"> handled = false;
</span><del>- while (!handled)
- ecore_main_loop_iterate();
</del><ins>+ waitUntilTrue(handled);
</ins><span class="cx"> evas_object_smart_callback_del(webView(), "input,type,color,request", onColorPickerDone);
</span><span class="cx"> }
</span><span class="cx"> #endif // ENABLE(INPUT_TYPE_COLOR)
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIeflteststest_ewk2_cookie_managercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_cookie_manager.cpp (161138 => 161139)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_cookie_manager.cpp        2013-12-30 09:58:14 UTC (rev 161138)
+++ trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_cookie_manager.cpp        2013-12-30 10:26:00 UTC (rev 161139)
</span><span class="lines">@@ -182,15 +182,11 @@
</span><span class="cx"> // Check for cookie changes notifications
</span><span class="cx"> ASSERT_TRUE(loadUrlSync(httpServer->getURLForPath("/index.html").data()));
</span><span class="cx">
</span><del>- while (!cookiesChanged)
- ecore_main_loop_iterate();
- ASSERT_TRUE(cookiesChanged);
</del><ins>+ ASSERT_TRUE(waitUntilTrue(cookiesChanged));
</ins><span class="cx">
</span><span class="cx"> cookiesChanged = false;
</span><span class="cx"> ewk_cookie_manager_cookies_clear(cookieManager);
</span><del>- while (!cookiesChanged)
- ecore_main_loop_iterate();
- ASSERT_TRUE(cookiesChanged);
</del><ins>+ ASSERT_TRUE(waitUntilTrue(cookiesChanged));
</ins><span class="cx">
</span><span class="cx"> // Stop watching for notifications
</span><span class="cx"> ewk_cookie_manager_changes_watch(cookieManager, 0, 0);
</span></span></pre></div>
<a id="trunkSourceWebKit2UIProcessAPIeflteststest_ewk2_viewcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp (161138 => 161139)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp        2013-12-30 09:58:14 UTC (rev 161138)
+++ trunk/Source/WebKit2/UIProcess/API/efl/tests/test_ewk2_view.cpp        2013-12-30 10:26:00 UTC (rev 161139)
</span><span class="lines">@@ -54,6 +54,7 @@
</span><span class="cx"> struct VibrationCbData {
</span><span class="cx"> bool didReceiveVibrate; // Whether the vibration event received.
</span><span class="cx"> bool didReceiveCancelVibration; // Whether the cancel vibration event received.
</span><ins>+ bool testFinished;
</ins><span class="cx"> unsigned vibrateCalledCount; // Vibrate callbacks count.
</span><span class="cx"> unsigned expectedVibrationTime; // Expected vibration time.
</span><span class="cx"> };
</span><span class="lines">@@ -158,8 +159,10 @@
</span><span class="cx"> {
</span><span class="cx"> VibrationCbData* data = static_cast<VibrationCbData*>(userData);
</span><span class="cx"> unsigned* vibrationTime = static_cast<unsigned*>(eventInfo);
</span><del>- if (*vibrationTime == data->expectedVibrationTime)
</del><ins>+ if (*vibrationTime == data->expectedVibrationTime) {
</ins><span class="cx"> data->didReceiveVibrate = true;
</span><ins>+ data->testFinished = true;
+ }
</ins><span class="cx"> data->vibrateCalledCount++;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -167,6 +170,7 @@
</span><span class="cx"> {
</span><span class="cx"> VibrationCbData* data = static_cast<VibrationCbData*>(userData);
</span><span class="cx"> data->didReceiveCancelVibration = true;
</span><ins>+ data->testFinished = true;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void loadVibrationHTMLString(Evas_Object* webView, const char* vibrationPattern, bool waitForVibrationEvent, VibrationCbData* data)
</span><span class="lines">@@ -178,6 +182,7 @@
</span><span class="cx"> data->didReceiveVibrate = false;
</span><span class="cx"> data->didReceiveCancelVibration = false;
</span><span class="cx"> data->vibrateCalledCount = 0;
</span><ins>+ data->testFinished = false;
</ins><span class="cx"> Eina_Strbuf* buffer = eina_strbuf_new();
</span><span class="cx"> eina_strbuf_append_printf(buffer, content, vibrationPattern);
</span><span class="cx"> ewk_view_html_string_load(webView, eina_strbuf_string_get(buffer), 0, 0);
</span><span class="lines">@@ -185,9 +190,6 @@
</span><span class="cx">
</span><span class="cx"> if (!waitForVibrationEvent)
</span><span class="cx"> return;
</span><del>-
- while (!data->didReceiveVibrate && !data->didReceiveCancelVibration)
- ecore_main_loop_iterate();
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void onContentsSizeChangedPortrait(void* userData, Evas_Object*, void* eventInfo)
</span><span class="lines">@@ -361,9 +363,7 @@
</span><span class="cx"> ewk_view_html_string_load(webView(), formHTML, "file:///", 0);
</span><span class="cx"> bool handled = false;
</span><span class="cx"> evas_object_smart_callback_add(webView(), "form,submission,request", onFormAboutToBeSubmitted, &handled);
</span><del>- while (!handled)
- ecore_main_loop_iterate();
- ASSERT_TRUE(handled);
</del><ins>+ ASSERT_TRUE(waitUntilTrue(handled));
</ins><span class="cx"> evas_object_smart_callback_del(webView(), "form,submission,request", onFormAboutToBeSubmitted);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -924,19 +924,23 @@
</span><span class="cx">
</span><span class="cx"> // Vibrate for 5 seconds.
</span><span class="cx"> loadVibrationHTMLString(webView(), "5000", true, &data);
</span><ins>+ waitUntilTrue(data.testFinished);
</ins><span class="cx"> ASSERT_TRUE(data.didReceiveVibrate);
</span><span class="cx">
</span><span class="cx"> // Cancel any existing vibrations.
</span><span class="cx"> loadVibrationHTMLString(webView(), "0", true, &data);
</span><ins>+ waitUntilTrue(data.testFinished);
</ins><span class="cx"> ASSERT_TRUE(data.didReceiveCancelVibration);
</span><span class="cx">
</span><span class="cx"> // This case the pattern will cause the device to vibrate for 200 ms, be still for 100 ms, and then vibrate for 5000 ms.
</span><span class="cx"> loadVibrationHTMLString(webView(), "[200, 100, 5000]", true, &data);
</span><ins>+ waitUntilTrue(data.testFinished);
</ins><span class="cx"> ASSERT_EQ(2, data.vibrateCalledCount);
</span><span class="cx"> ASSERT_TRUE(data.didReceiveVibrate);
</span><span class="cx">
</span><span class="cx"> // Cancel outstanding vibration pattern.
</span><span class="cx"> loadVibrationHTMLString(webView(), "[0]", true, &data);
</span><ins>+ waitUntilTrue(data.testFinished);
</ins><span class="cx"> ASSERT_TRUE(data.didReceiveCancelVibration);
</span><span class="cx">
</span><span class="cx"> // Stop listening for vibration events, by calling the function with null for the callbacks.
</span><span class="lines">@@ -945,12 +949,14 @@
</span><span class="cx">
</span><span class="cx"> // Make sure we don't receive vibration event.
</span><span class="cx"> loadVibrationHTMLString(webView(), "[5000]", false, &data);
</span><ins>+ waitUntilTrue(data.testFinished);
</ins><span class="cx"> ASSERT_TRUE(waitUntilTitleChangedTo("Loaded"));
</span><span class="cx"> ASSERT_STREQ("Loaded", ewk_view_title_get(webView()));
</span><span class="cx"> ASSERT_FALSE(data.didReceiveVibrate);
</span><span class="cx">
</span><span class="cx"> // Make sure we don't receive cancel vibration event.
</span><span class="cx"> loadVibrationHTMLString(webView(), "0", false, &data);
</span><ins>+ waitUntilTrue(data.testFinished);
</ins><span class="cx"> ASSERT_TRUE(waitUntilTitleChangedTo("Loaded"));
</span><span class="cx"> ASSERT_STREQ("Loaded", ewk_view_title_get(webView()));
</span><span class="cx"> ASSERT_FALSE(data.didReceiveCancelVibration);
</span><span class="lines">@@ -968,30 +974,26 @@
</span><span class="cx"> bool sizeChanged = false;
</span><span class="cx"> evas_object_smart_callback_add(webView(), "contents,size,changed", onContentsSizeChangedPortrait, &sizeChanged);
</span><span class="cx"> ewk_view_html_string_load(webView(), contentsSizeHTMLPortrait, 0, 0);
</span><del>- while (!sizeChanged)
- ecore_main_loop_iterate();
</del><ins>+ waitUntilTrue(sizeChanged);
</ins><span class="cx"> evas_object_smart_callback_del(webView(), "contents,size,changed", onContentsSizeChangedPortrait);
</span><span class="cx">
</span><span class="cx"> evas_object_smart_callback_add(webView(), "contents,size,changed", onContentsSizeChangedLandscape, &sizeChanged);
</span><span class="cx"> ewk_view_device_pixel_ratio_set(webView(), 2);
</span><span class="cx"> ewk_view_html_string_load(webView(), contentsSizeHTMLLandscape, 0, 0);
</span><span class="cx"> sizeChanged = false;
</span><del>- while (!sizeChanged)
- ecore_main_loop_iterate();
</del><ins>+ waitUntilTrue(sizeChanged);
</ins><span class="cx"> evas_object_smart_callback_del(webView(), "contents,size,changed", onContentsSizeChangedLandscape);
</span><span class="cx">
</span><span class="cx"> evas_object_smart_callback_add(webView(), "contents,size,changed", onContentsSizeChangedPortrait, &sizeChanged);
</span><span class="cx"> ewk_view_scale_set(webView(), 3, 0, 0);
</span><span class="cx"> ewk_view_html_string_load(webView(), contentsSizeHTMLPortrait, 0, 0);
</span><span class="cx"> sizeChanged = false;
</span><del>- while (!sizeChanged)
- ecore_main_loop_iterate();
</del><ins>+ waitUntilTrue(sizeChanged);
</ins><span class="cx">
</span><span class="cx"> // Make sure we get signal after loaded the contents having same size with previous one.
</span><span class="cx"> sizeChanged = false;
</span><span class="cx"> ewk_view_html_string_load(webView(), contentsSizeHTMLPortrait, 0, 0);
</span><del>- while (!sizeChanged)
- ecore_main_loop_iterate();
</del><ins>+ waitUntilTrue(sizeChanged);
</ins><span class="cx">
</span><span class="cx"> evas_object_smart_callback_del(webView(), "contents,size,changed", onContentsSizeChangedPortrait);
</span><span class="cx"> }
</span><span class="lines">@@ -1003,13 +1005,11 @@
</span><span class="cx"> waitUntilLoadFinished();
</span><span class="cx">
</span><span class="cx"> ASSERT_TRUE(ewk_view_page_contents_get(webView(), EWK_PAGE_CONTENTS_TYPE_MHTML, PageContentsAsMHTMLCallback, 0));
</span><del>- while (!obtainedPageContents)
- ecore_main_loop_iterate();
</del><ins>+ waitUntilTrue(obtainedPageContents);
</ins><span class="cx">
</span><span class="cx"> obtainedPageContents = false;
</span><span class="cx"> ASSERT_TRUE(ewk_view_page_contents_get(webView(), EWK_PAGE_CONTENTS_TYPE_STRING, PageContentsAsStringCallback, 0));
</span><del>- while (!obtainedPageContents)
- ecore_main_loop_iterate();
</del><ins>+ waitUntilTrue(obtainedPageContents);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> TEST_F(EWK2ViewTest, ewk_view_source_mode)
</span></span></pre>
</div>
</div>
</body>
</html>