Modified: trunk/Source/WebKit2/ChangeLog (128974 => 128975)
--- trunk/Source/WebKit2/ChangeLog 2012-09-19 08:00:33 UTC (rev 128974)
+++ trunk/Source/WebKit2/ChangeLog 2012-09-19 08:04:40 UTC (rev 128975)
@@ -1,3 +1,37 @@
+2012-09-19 Byungwoo Lee <bw80....@samsung.com>
+
+ [EFL][WK2] waitUntilTitleChangedTo() and waitUntilLoadFinished() needs timeout.
+ https://bugs.webkit.org/show_bug.cgi?id=96910
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ Currently, the waitUntilTitleChangedTo() and waitUntilLoadFinished()
+ functions doesn't handle timeout by itself.
+ And if there are some failed cases that loading is not finished or
+ title is not changed to the expected string, test case just stopped
+ with timeout and there is no more information about this such as line
+ number.
+
+ To handle timeout status more properly, timeout parameter is added to
+ these functions.
+
+ * UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp:
+ (EWK2UnitTest::LoadFinishedData::LoadFinishedData):
+ (LoadFinishedData):
+ (EWK2UnitTest::LoadFinishedData::~LoadFinishedData):
+ (EWK2UnitTest):
+ (EWK2UnitTest::onLoadFinished):
+ (EWK2UnitTest::timeOutWhileWaitingUntilLoadFinished):
+ (EWK2UnitTest::EWK2UnitTestBase::waitUntilLoadFinished):
+ (EWK2UnitTest::TitleChangedData::TitleChangedData):
+ (TitleChangedData):
+ (EWK2UnitTest::TitleChangedData::~TitleChangedData):
+ (EWK2UnitTest::onTitleChanged):
+ (EWK2UnitTest::timeOutWhileWaitingUntilTitleChangedTo):
+ (EWK2UnitTest::EWK2UnitTestBase::waitUntilTitleChangedTo):
+ * UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h:
+ (EWK2UnitTestBase):
+
2012-09-18 Byungwoo Lee <bw80....@samsung.com>
[EFL][WK2] Add _javascript_ popup API.
Modified: trunk/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp (128974 => 128975)
--- trunk/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp 2012-09-19 08:00:33 UTC (rev 128974)
+++ trunk/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.cpp 2012-09-19 08:04:40 UTC (rev 128975)
@@ -29,15 +29,6 @@
namespace EWK2UnitTest {
-static void onLoadFinished(void* userData, Evas_Object* webView, void* eventInfo)
-{
- UNUSED_PARAM(webView);
- UNUSED_PARAM(eventInfo);
-
- bool* loadFinished = static_cast<bool*>(userData);
- *loadFinished = true;
-}
-
static Ewk_View_Smart_Class ewk2UnitTestBrowserViewSmartClass()
{
static Ewk_View_Smart_Class ewkViewClass = EWK_VIEW_SMART_CLASS_INIT_NAME_VERSION("Browser_View");
@@ -89,40 +80,135 @@
waitUntilLoadFinished();
}
-void EWK2UnitTestBase::waitUntilLoadFinished()
+struct LoadFinishedData {
+ LoadFinishedData(double timeoutSeconds, Ecore_Task_Cb callback)
+ : loadFinished(false)
+ , timer(0)
+ , didTimeOut(false)
+ {
+ if (timeoutSeconds >= 0)
+ timer = ecore_timer_add(timeoutSeconds, callback, this);
+ }
+
+ ~LoadFinishedData()
+ {
+ if (timer)
+ ecore_timer_del(timer);
+ }
+
+ bool loadFinished;
+ Ecore_Timer* timer;
+ bool didTimeOut;
+};
+
+static void onLoadFinished(void* userData, Evas_Object* webView, void* eventInfo)
{
- bool loadFinished = false;
+ UNUSED_PARAM(webView);
+ UNUSED_PARAM(eventInfo);
- evas_object_smart_callback_add(m_webView, "load,finished", onLoadFinished, &loadFinished);
+ LoadFinishedData* data = ""
+ data->loadFinished = true;
- while (!loadFinished)
+ if (data->timer) {
+ ecore_timer_del(data->timer);
+ data->timer = 0;
+ }
+}
+
+static bool timeOutWhileWaitingUntilLoadFinished(void* userData)
+{
+ LoadFinishedData* data = ""
+
+ data->timer = 0;
+
+ if (data->loadFinished)
+ return ECORE_CALLBACK_CANCEL;
+
+ data->loadFinished = true;
+ data->didTimeOut = true;
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+bool EWK2UnitTestBase::waitUntilLoadFinished(double timeoutSeconds)
+{
+ LoadFinishedData data(timeoutSeconds, reinterpret_cast<Ecore_Task_Cb>(timeOutWhileWaitingUntilLoadFinished));
+
+ evas_object_smart_callback_add(m_webView, "load,finished", onLoadFinished, &data);
+
+ while (!data.loadFinished)
ecore_main_loop_iterate();
evas_object_smart_callback_del(m_webView, "load,finished", onLoadFinished);
+
+ return !data.didTimeOut;
}
struct TitleChangedData {
+ TitleChangedData(const char* title, double timeoutSeconds, Ecore_Task_Cb callback)
+ : expectedTitle(title)
+ , done(false)
+ , timer(0)
+ , didTimeOut(false)
+ {
+ if (timeoutSeconds >= 0)
+ timer = ecore_timer_add(timeoutSeconds, callback, this);
+ }
+
+ ~TitleChangedData()
+ {
+ if (timer)
+ ecore_timer_del(timer);
+ }
+
CString expectedTitle;
bool done;
+ Ecore_Timer* timer;
+ bool didTimeOut;
};
static void onTitleChanged(void* userData, Evas_Object* webView, void* eventInfo)
{
TitleChangedData* data = ""
- if (!strcmp(ewk_view_title_get(webView), data->expectedTitle.data()))
- data->done = true;
+ if (strcmp(ewk_view_title_get(webView), data->expectedTitle.data()))
+ return;
+
+ if (data->timer) {
+ ecore_timer_del(data->timer);
+ data->timer = 0;
+ }
+
+ data->done = true;
}
-void EWK2UnitTestBase::waitUntilTitleChangedTo(const char* expectedTitle)
+static bool timeOutWhileWaitingUntilTitleChangedTo(void* userData)
{
- TitleChangedData data = { expectedTitle, false };
+ TitleChangedData* data = ""
+
+ data->timer = 0;
+
+ if (data->done)
+ return ECORE_CALLBACK_CANCEL;
+
+ data->done = true;
+ data->didTimeOut = true;
+
+ return ECORE_CALLBACK_CANCEL;
+}
+
+bool EWK2UnitTestBase::waitUntilTitleChangedTo(const char* expectedTitle, double timeoutSeconds)
+{
+ TitleChangedData data(expectedTitle, timeoutSeconds, reinterpret_cast<Ecore_Task_Cb>(timeOutWhileWaitingUntilTitleChangedTo));
+
evas_object_smart_callback_add(m_webView, "title,changed", onTitleChanged, &data);
while (!data.done)
ecore_main_loop_iterate();
evas_object_smart_callback_del(m_webView, "title,changed", onTitleChanged);
+
+ return !data.didTimeOut;
}
void EWK2UnitTestBase::mouseClick(int x, int y)
Modified: trunk/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h (128974 => 128975)
--- trunk/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h 2012-09-19 08:00:33 UTC (rev 128974)
+++ trunk/Source/WebKit2/UIProcess/API/efl/tests/UnitTestUtils/EWK2UnitTestBase.h 2012-09-19 08:04:40 UTC (rev 128975)
@@ -41,8 +41,8 @@
virtual void TearDown();
void loadUrlSync(const char* url);
- void waitUntilLoadFinished();
- void waitUntilTitleChangedTo(const char* expectedTitle);
+ bool waitUntilLoadFinished(double timeoutSeconds = -1);
+ bool waitUntilTitleChangedTo(const char* expectedTitle, double timeoutSeconds = -1);
void mouseClick(int x, int y);
private: