Title: [176921] trunk/Tools
Revision
176921
Author
[email protected]
Date
2014-12-07 06:08:09 -0800 (Sun, 07 Dec 2014)

Log Message

[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.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (176920 => 176921)


--- trunk/Tools/ChangeLog	2014-12-07 13:40:56 UTC (rev 176920)
+++ trunk/Tools/ChangeLog	2014-12-07 14:08:09 UTC (rev 176921)
@@ -1,5 +1,23 @@
 2014-12-07  Carlos Garcia Campos  <[email protected]>
 
+        [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  <[email protected]>
+
         [GTK] Missing API detected in GObject DOM bindings after r176630
         https://bugs.webkit.org/show_bug.cgi?id=139201
 

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h (176920 => 176921)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h	2014-12-07 13:40:56 UTC (rev 176920)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h	2014-12-07 14:08:09 UTC (rev 176921)
@@ -38,7 +38,8 @@
 #include <CoreFoundation/CFRunLoop.h>
 typedef RetainPtr<CFRunLoopTimerRef> PlatformTimerRef;
 #elif PLATFORM(GTK)
-typedef unsigned int PlatformTimerRef;
+#include <wtf/gobject/GMainLoopSource.h>
+typedef GMainLoopSource PlatformTimerRef;
 #elif PLATFORM(EFL)
 typedef Ecore_Timer* PlatformTimerRef;
 #endif

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/gtk/TestRunnerGtk.cpp (176920 => 176921)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/gtk/TestRunnerGtk.cpp	2014-12-07 13:40:56 UTC (rev 176920)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/gtk/TestRunnerGtk.cpp	2014-12-07 14:08:09 UTC (rev 176921)
@@ -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::microseconds>(std::chrono::duration<double>(waitToDumpWatchdogTimerInterval)));
 }
 
 JSRetainPtr<JSStringRef> TestRunner::pathToLocalResource(JSStringRef url)

Modified: trunk/Tools/WebKitTestRunner/gtk/TestControllerGtk.cpp (176920 => 176921)


--- trunk/Tools/WebKitTestRunner/gtk/TestControllerGtk.cpp	2014-12-07 13:40:56 UTC (rev 176920)
+++ trunk/Tools/WebKitTestRunner/gtk/TestControllerGtk.cpp	2014-12-07 14:08:09 UTC (rev 176921)
@@ -29,25 +29,18 @@
 
 #include <gtk/gtk.h>
 #include <wtf/Platform.h>
+#include <wtf/gobject/GMainLoopSource.h>
 #include <wtf/gobject/GUniquePtr.h>
 #include <wtf/text/WTFString.h>
 
 namespace WTR {
 
-static guint gTimeoutSourceId = 0;
+static GMainLoopSource timeoutSource;
 
-static void cancelTimeout()
-{
-    if (!gTimeoutSourceId)
-        return;
-    g_source_remove(gTimeoutSourceId);
-    gTimeoutSourceId = 0;
-}
-
 void TestController::notifyDone()
 {
     gtk_main_quit();
-    cancelTimeout();
+    timeoutSource.cancel();
 }
 
 void TestController::platformInitialize()
@@ -58,24 +51,19 @@
 {
 }
 
-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::microseconds>(std::chrono::duration<double>(timeout)));
+    } else
+        timeoutSource.cancel();
     gtk_main();
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to