Changeset 176566 in webkit


Ignore:
Timestamp:
Nov 28, 2014 8:39:36 AM (9 years ago)
Author:
Carlos Garcia Campos
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.

Location:
trunk/Tools
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r176564 r176566  
     12014-11-28  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [GTK] Use GMainLoopSource in WebKitTestRunner
     4        https://bugs.webkit.org/show_bug.cgi?id=138831
     5
     6        Reviewed by Sergio Villar Senin.
     7
     8        * WebKitTestRunner/InjectedBundle/TestRunner.h:
     9        * WebKitTestRunner/InjectedBundle/gtk/TestRunnerGtk.cpp:
     10        (WTR::TestRunner::platformInitialize):
     11        (WTR::TestRunner::invalidateWaitToDumpWatchdogTimer):
     12        (WTR::TestRunner::initializeWaitToDumpWatchdogTimerIfNeeded):
     13        (WTR::waitToDumpWatchdogTimerCallback): Deleted.
     14        * WebKitTestRunner/gtk/TestControllerGtk.cpp:
     15        (WTR::TestController::notifyDone):
     16        (WTR::TestController::platformRunUntil):
     17        (WTR::cancelTimeout): Deleted.
     18
    1192014-11-24  Philippe Normand  <pnormand@igalia.com>
    220
  • trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h

    r176011 r176566  
    3939typedef RetainPtr<CFRunLoopTimerRef> PlatformTimerRef;
    4040#elif PLATFORM(GTK)
    41 typedef unsigned int PlatformTimerRef;
     41#include <wtf/gobject/GMainLoopSource.h>
     42typedef GMainLoopSource PlatformTimerRef;
    4243#elif PLATFORM(EFL)
    4344typedef Ecore_Timer* PlatformTimerRef;
  • trunk/Tools/WebKitTestRunner/InjectedBundle/gtk/TestRunnerGtk.cpp

    r162599 r176566  
    3535namespace WTR {
    3636
    37 static gboolean waitToDumpWatchdogTimerCallback(gpointer)
    38 {
    39     InjectedBundle::shared().testRunner()->waitToDumpWatchdogTimerFired();
    40     return FALSE;
    41 }
    42 
    4337void TestRunner::platformInitialize()
    4438{
    45     m_waitToDumpWatchdogTimer = 0;
    4639}
    4740
    4841void TestRunner::invalidateWaitToDumpWatchdogTimer()
    4942{
    50     if (!m_waitToDumpWatchdogTimer)
    51         return;
    52     g_source_remove(m_waitToDumpWatchdogTimer);
    53     m_waitToDumpWatchdogTimer = 0;
     43    m_waitToDumpWatchdogTimer.cancel();
    5444}
    5545
    5646void TestRunner::initializeWaitToDumpWatchdogTimerIfNeeded()
    5747{
    58     if (m_waitToDumpWatchdogTimer)
     48    if (m_waitToDumpWatchdogTimer.isScheduled())
    5949        return;
    6050
    61     m_waitToDumpWatchdogTimer = g_timeout_add(waitToDumpWatchdogTimerInterval * 1000,
    62                                               waitToDumpWatchdogTimerCallback, 0);
    63     g_source_set_name_by_id(m_waitToDumpWatchdogTimer, "[WebKit] waitToDumpWatchdogTimerCallback");
     51    m_waitToDumpWatchdogTimer.scheduleAfterDelay("[WTR] waitToDumpWatchdogTimerCallback", [this] { waitToDumpWatchdogTimerFired(); },
     52        std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::duration<double>(waitToDumpWatchdogTimerInterval)));
    6453}
    6554
  • trunk/Tools/WebKitTestRunner/gtk/TestControllerGtk.cpp

    r168045 r176566  
    3030#include <gtk/gtk.h>
    3131#include <wtf/Platform.h>
     32#include <wtf/gobject/GMainLoopSource.h>
    3233#include <wtf/gobject/GUniquePtr.h>
    3334#include <wtf/text/WTFString.h>
     
    3536namespace WTR {
    3637
    37 static guint gTimeoutSourceId = 0;
    38 
    39 static void cancelTimeout()
    40 {
    41     if (!gTimeoutSourceId)
    42         return;
    43     g_source_remove(gTimeoutSourceId);
    44     gTimeoutSourceId = 0;
    45 }
     38static GMainLoopSource timeoutSource;
    4639
    4740void TestController::notifyDone()
    4841{
    4942    gtk_main_quit();
    50     cancelTimeout();
     43    timeoutSource.cancel();
    5144}
    5245
     
    5952}
    6053
    61 static gboolean timeoutCallback(gpointer)
    62 {
    63     fprintf(stderr, "FAIL: TestControllerRunLoop timed out.\n");
    64     gtk_main_quit();
    65     return FALSE;
    66 }
    67 
    6854void TestController::platformWillRunTest(const TestInvocation&)
    6955{
     
    7258void TestController::platformRunUntil(bool&, double timeout)
    7359{
    74     cancelTimeout();
    75     if (timeout != m_noTimeout) {
    76         gTimeoutSourceId = g_timeout_add(timeout * 1000, timeoutCallback, 0);
    77         g_source_set_name_by_id(gTimeoutSourceId, "[WebKit] timeoutCallback");
    78     }
     60    timeoutSource.scheduleAfterDelay("[WTR] Test timeout source", [] {
     61        fprintf(stderr, "FAIL: TestControllerRunLoop timed out.\n");
     62        gtk_main_quit();
     63    }, std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::duration<double>(timeout)));
    7964    gtk_main();
    8065}
Note: See TracChangeset for help on using the changeset viewer.