Changeset 239401 in webkit


Ignore:
Timestamp:
Dec 19, 2018 3:44:48 PM (5 years ago)
Author:
Adrian Perez de Castro
Message:

[GTK][WPE] Unify TestController::platformRunUntil() and honor condition flag
https://bugs.webkit.org/show_bug.cgi?id=192855

Reviewed by Michael Catanzaro.

  • WebKitTestRunner/gtk/TestControllerGtk.cpp:

(WTR::TestController::notifyDone): Use the WPE implementation.
(WTR::TestController::platformRunUntil): Use the WPE implementation.

  • WebKitTestRunner/wpe/TestControllerWPE.cpp:

(WTR::TestController::platformRunUntil): Honor the condition flag.

Location:
trunk/Tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r239384 r239401  
     12018-12-19  Adrian Perez de Castro  <aperez@igalia.com>
     2
     3        [GTK][WPE] Unify TestController::platformRunUntil() and honor condition flag
     4        https://bugs.webkit.org/show_bug.cgi?id=192855
     5
     6        Reviewed by Michael Catanzaro.
     7
     8        * WebKitTestRunner/gtk/TestControllerGtk.cpp:
     9        (WTR::TestController::notifyDone): Use the WPE implementation.
     10        (WTR::TestController::platformRunUntil): Use the WPE implementation.
     11        * WebKitTestRunner/wpe/TestControllerWPE.cpp:
     12        (WTR::TestController::platformRunUntil): Honor the condition flag.
     13
    1142018-12-19  Megan Gardner  <megan_gardner@apple.com>
    215
  • trunk/Tools/WebKitTestRunner/gtk/TestControllerGtk.cpp

    r235399 r239401  
    3838namespace WTR {
    3939
    40 static GSource* timeoutSource()
    41 {
    42     static GRefPtr<GSource> source = nullptr;
    43     if (!source) {
    44         source = adoptGRef(g_timeout_source_new(0));
    45         g_source_set_ready_time(source.get(), -1);
    46         g_source_set_name(source.get(), "[WTR] Test timeout source");
    47         g_source_set_callback(source.get(), [](gpointer userData) -> gboolean {
    48             g_source_set_ready_time(static_cast<GSource*>(userData), -1);
    49             fprintf(stderr, "FAIL: TestControllerRunLoop timed out.\n");
    50             RunLoop::main().stop();
    51             return G_SOURCE_REMOVE;
    52         }, source.get(), nullptr);
    53         g_source_attach(source.get(), nullptr);
    54     }
    55     return source.get();
    56 }
    57 
    5840void TestController::notifyDone()
    5941{
    60     g_source_set_ready_time(timeoutSource(), -1);
    6142    RunLoop::main().stop();
    6243}
     
    7556}
    7657
    77 void TestController::platformRunUntil(bool&, WTF::Seconds timeout)
     58void TestController::platformRunUntil(bool& done, WTF::Seconds timeout)
    7859{
    79     if (timeout > 0_s) {
    80         // FIXME: This conversion is now repeated in several places, it should be moved to a common place in WTF and used everywhere.
    81         gint64 currentTime = g_get_monotonic_time();
    82         gint64 targetTime = currentTime + std::min<gint64>(G_MAXINT64 - currentTime, timeout.microsecondsAs<int64_t>());
    83         ASSERT(targetTime >= currentTime);
    84         g_source_set_ready_time(timeoutSource(), targetTime);
    85     } else
    86         g_source_set_ready_time(timeoutSource(), -1);
    87     RunLoop::main().run();
     60    struct TimeoutTimer {
     61        TimeoutTimer()
     62            : timer(RunLoop::main(), this, &TimeoutTimer::fired)
     63        { }
     64
     65        void fired()
     66        {
     67            timedOut = true;
     68            RunLoop::main().stop();
     69        }
     70
     71        RunLoop::Timer<TimeoutTimer> timer;
     72        bool timedOut { false };
     73    } timeoutTimer;
     74
     75    timeoutTimer.timer.setPriority(G_PRIORITY_DEFAULT_IDLE);
     76    if (timeout >= 0_s)
     77        timeoutTimer.timer.startOneShot(timeout);
     78
     79    while (!done && !timeoutTimer.timedOut)
     80        RunLoop::main().run();
     81
     82    timeoutTimer.timer.stop();
    8883}
    8984
  • trunk/Tools/WebKitTestRunner/wpe/TestControllerWPE.cpp

    r235399 r239401  
    5959}
    6060
    61 void TestController::platformRunUntil(bool& condition, WTF::Seconds timeout)
     61void TestController::platformRunUntil(bool& done, WTF::Seconds timeout)
    6262{
    6363    struct TimeoutTimer {
     
    6666        { }
    6767
    68         void fired() { RunLoop::main().stop(); }
     68        void fired()
     69        {
     70            timedOut = true;
     71            RunLoop::main().stop();
     72        }
     73
    6974        RunLoop::Timer<TimeoutTimer> timer;
     75        bool timedOut { false };
    7076    } timeoutTimer;
    7177
     
    7480        timeoutTimer.timer.startOneShot(timeout);
    7581
    76     RunLoop::main().run();
     82    while (!done && !timeoutTimer.timedOut)
     83        RunLoop::main().run();
    7784
    7885    timeoutTimer.timer.stop();
Note: See TracChangeset for help on using the changeset viewer.