From e91c9d3f0eaeebec6c52bbfe0b010b7d680bd748 Mon Sep 17 00:00:00 2001 From: "carlosgc@webkit.org" Date: Sun, 7 Dec 2014 14:08:09 +0000 Subject: [PATCH] [GTK] Use GMainLoopSource in WebKitTestRunner https://bugs.webkit.org/show_bug.cgi?id=138831 Reviewed by Sergio Villar Senin. * WebKitTestRunner/InjectedBundle/TestRunner.h: * WebKitTestRunner/InjectedBundle/gtk/TestRunnerGtk.cpp: (WTR::TestRunner::platformInitialize): (WTR::TestRunner::invalidateWaitToDumpWatchdogTimer): (WTR::TestRunner::initializeWaitToDumpWatchdogTimerIfNeeded): (WTR::waitToDumpWatchdogTimerCallback): Deleted. * WebKitTestRunner/gtk/TestControllerGtk.cpp: (WTR::TestController::notifyDone): (WTR::TestController::platformRunUntil): (WTR::cancelTimeout): Deleted. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@176921 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Tools/ChangeLog | 18 +++++++++++++ Tools/WebKitTestRunner/InjectedBundle/TestRunner.h | 3 ++- .../InjectedBundle/gtk/TestRunnerGtk.cpp | 19 +++----------- Tools/WebKitTestRunner/gtk/TestControllerGtk.cpp | 30 +++++++--------------- 4 files changed, 33 insertions(+), 37 deletions(-) diff --git a/Tools/ChangeLog b/Tools/ChangeLog index 4dbeade..94de14e 100644 --- a/Tools/ChangeLog +++ b/Tools/ChangeLog @@ -1,5 +1,23 @@ 2014-12-07 Carlos Garcia Campos + [GTK] Use GMainLoopSource in WebKitTestRunner + https://bugs.webkit.org/show_bug.cgi?id=138831 + + Reviewed by Sergio Villar Senin. + + * WebKitTestRunner/InjectedBundle/TestRunner.h: + * WebKitTestRunner/InjectedBundle/gtk/TestRunnerGtk.cpp: + (WTR::TestRunner::platformInitialize): + (WTR::TestRunner::invalidateWaitToDumpWatchdogTimer): + (WTR::TestRunner::initializeWaitToDumpWatchdogTimerIfNeeded): + (WTR::waitToDumpWatchdogTimerCallback): Deleted. + * WebKitTestRunner/gtk/TestControllerGtk.cpp: + (WTR::TestController::notifyDone): + (WTR::TestController::platformRunUntil): + (WTR::cancelTimeout): Deleted. + +2014-12-07 Carlos Garcia Campos + [GTK] Missing API detected in GObject DOM bindings after r176630 https://bugs.webkit.org/show_bug.cgi?id=139201 diff --git a/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h b/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h index 9dbf1fa..642e6a4 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h +++ b/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h @@ -38,7 +38,8 @@ #include typedef RetainPtr PlatformTimerRef; #elif PLATFORM(GTK) -typedef unsigned int PlatformTimerRef; +#include +typedef GMainLoopSource PlatformTimerRef; #elif PLATFORM(EFL) typedef Ecore_Timer* PlatformTimerRef; #endif diff --git a/Tools/WebKitTestRunner/InjectedBundle/gtk/TestRunnerGtk.cpp b/Tools/WebKitTestRunner/InjectedBundle/gtk/TestRunnerGtk.cpp index 2543748..850e737 100644 --- a/Tools/WebKitTestRunner/InjectedBundle/gtk/TestRunnerGtk.cpp +++ b/Tools/WebKitTestRunner/InjectedBundle/gtk/TestRunnerGtk.cpp @@ -34,33 +34,22 @@ namespace WTR { -static gboolean waitToDumpWatchdogTimerCallback(gpointer) -{ - InjectedBundle::shared().testRunner()->waitToDumpWatchdogTimerFired(); - return FALSE; -} - void TestRunner::platformInitialize() { - m_waitToDumpWatchdogTimer = 0; } void TestRunner::invalidateWaitToDumpWatchdogTimer() { - if (!m_waitToDumpWatchdogTimer) - return; - g_source_remove(m_waitToDumpWatchdogTimer); - m_waitToDumpWatchdogTimer = 0; + m_waitToDumpWatchdogTimer.cancel(); } void TestRunner::initializeWaitToDumpWatchdogTimerIfNeeded() { - if (m_waitToDumpWatchdogTimer) + if (m_waitToDumpWatchdogTimer.isScheduled()) return; - m_waitToDumpWatchdogTimer = g_timeout_add(waitToDumpWatchdogTimerInterval * 1000, - waitToDumpWatchdogTimerCallback, 0); - g_source_set_name_by_id(m_waitToDumpWatchdogTimer, "[WebKit] waitToDumpWatchdogTimerCallback"); + m_waitToDumpWatchdogTimer.scheduleAfterDelay("[WTR] waitToDumpWatchdogTimerCallback", [this] { waitToDumpWatchdogTimerFired(); }, + std::chrono::duration_cast(std::chrono::duration(waitToDumpWatchdogTimerInterval))); } JSRetainPtr TestRunner::pathToLocalResource(JSStringRef url) diff --git a/Tools/WebKitTestRunner/gtk/TestControllerGtk.cpp b/Tools/WebKitTestRunner/gtk/TestControllerGtk.cpp index e5cb71e..5fc83e2 100644 --- a/Tools/WebKitTestRunner/gtk/TestControllerGtk.cpp +++ b/Tools/WebKitTestRunner/gtk/TestControllerGtk.cpp @@ -29,25 +29,18 @@ #include #include +#include #include #include namespace WTR { -static guint gTimeoutSourceId = 0; - -static void cancelTimeout() -{ - if (!gTimeoutSourceId) - return; - g_source_remove(gTimeoutSourceId); - gTimeoutSourceId = 0; -} +static GMainLoopSource timeoutSource; void TestController::notifyDone() { gtk_main_quit(); - cancelTimeout(); + timeoutSource.cancel(); } void TestController::platformInitialize() @@ -58,24 +51,19 @@ void TestController::platformDestroy() { } -static gboolean timeoutCallback(gpointer) -{ - fprintf(stderr, "FAIL: TestControllerRunLoop timed out.\n"); - gtk_main_quit(); - return FALSE; -} - void TestController::platformWillRunTest(const TestInvocation&) { } void TestController::platformRunUntil(bool&, double timeout) { - cancelTimeout(); if (timeout != m_noTimeout) { - gTimeoutSourceId = g_timeout_add(timeout * 1000, timeoutCallback, 0); - g_source_set_name_by_id(gTimeoutSourceId, "[WebKit] timeoutCallback"); - } + timeoutSource.scheduleAfterDelay("[WTR] Test timeout source", [] { + fprintf(stderr, "FAIL: TestControllerRunLoop timed out.\n"); + gtk_main_quit(); + }, std::chrono::duration_cast(std::chrono::duration(timeout))); + } else + timeoutSource.cancel(); gtk_main(); } -- 1.8.3.1