Title: [235399] trunk/Tools
Revision
235399
Author
simon.fra...@apple.com
Date
2018-08-27 14:11:22 -0700 (Mon, 27 Aug 2018)

Log Message

Convert timeout values in WebKitTestRunner to WTF::Seconds
https://bugs.webkit.org/show_bug.cgi?id=188987

Reviewed by Ryosuke Niwa.

Replace various 'int' timeout values with WTF::Seconds. The timeout argument
comes in as milliseconds, so convert on input. When sending messages to the InjectedBundle
using integers, convert to and from milliseconds.

Also do some #pragma once, and initializer cleanup.

* WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
(WTR::InjectedBundle::didReceiveMessageToPage):
(WTR::InjectedBundle::beginTesting):
(WTR::InjectedBundle::InjectedBundle): Deleted.
* WebKitTestRunner/InjectedBundle/InjectedBundle.h:
* WebKitTestRunner/InjectedBundle/TestRunner.h:
(WTR::TestRunner::timeout):
(WTR::TestRunner::setCustomTimeout):
* WebKitTestRunner/InjectedBundle/gtk/TestRunnerGtk.cpp:
(WTR::TestRunner::initializeWaitToDumpWatchdogTimerIfNeeded):
* WebKitTestRunner/InjectedBundle/mac/TestRunnerMac.mm:
(WTR::TestRunner::invalidateWaitToDumpWatchdogTimer):
(WTR::TestRunner::initializeWaitToDumpWatchdogTimerIfNeeded):
* WebKitTestRunner/InjectedBundle/wpe/TestRunnerWPE.cpp:
(WTR::TestRunner::initializeWaitToDumpWatchdogTimerIfNeeded):
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::TestController):
(WTR::parseInputLine):
(WTR::TestController::runTest):
(WTR::TestController::runUntil):
(WTR::TestController::didReceiveMessageFromInjectedBundle):
* WebKitTestRunner/TestController.h:
* WebKitTestRunner/TestInvocation.cpp:
(WTR::TestInvocation::shortTimeout const):
(WTR::TestInvocation::createTestSettingsDictionary):
* WebKitTestRunner/TestInvocation.h:
* WebKitTestRunner/TestOptions.h:
* WebKitTestRunner/cocoa/TestControllerCocoa.mm:
(WTR::TestController::platformRunUntil):
* WebKitTestRunner/gtk/TestControllerGtk.cpp:
(WTR::TestController::platformRunUntil):
* WebKitTestRunner/wpe/TestControllerWPE.cpp:
(WTR::TestController::platformRunUntil):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (235398 => 235399)


--- trunk/Tools/ChangeLog	2018-08-27 21:00:25 UTC (rev 235398)
+++ trunk/Tools/ChangeLog	2018-08-27 21:11:22 UTC (rev 235399)
@@ -1,3 +1,97 @@
+2018-08-27  Simon Fraser  <simon.fra...@apple.com>
+
+        Convert timeout values in WebKitTestRunner to WTF::Seconds
+        https://bugs.webkit.org/show_bug.cgi?id=188987
+
+        Reviewed by Ryosuke Niwa.
+        
+        Replace various 'int' timeout values with WTF::Seconds. The timeout argument
+        comes in as milliseconds, so convert on input. When sending messages to the InjectedBundle
+        using integers, convert to and from milliseconds.
+        
+        Also do some #pragma once, and initializer cleanup.
+
+        * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
+        (WTR::InjectedBundle::didReceiveMessageToPage):
+        (WTR::InjectedBundle::beginTesting):
+        (WTR::InjectedBundle::InjectedBundle): Deleted.
+        * WebKitTestRunner/InjectedBundle/InjectedBundle.h:
+        * WebKitTestRunner/InjectedBundle/TestRunner.h:
+        (WTR::TestRunner::timeout):
+        (WTR::TestRunner::setCustomTimeout):
+        * WebKitTestRunner/InjectedBundle/gtk/TestRunnerGtk.cpp:
+        (WTR::TestRunner::initializeWaitToDumpWatchdogTimerIfNeeded):
+        * WebKitTestRunner/InjectedBundle/mac/TestRunnerMac.mm:
+        (WTR::TestRunner::invalidateWaitToDumpWatchdogTimer):
+        (WTR::TestRunner::initializeWaitToDumpWatchdogTimerIfNeeded):
+        * WebKitTestRunner/InjectedBundle/wpe/TestRunnerWPE.cpp:
+        (WTR::TestRunner::initializeWaitToDumpWatchdogTimerIfNeeded):
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::TestController):
+        (WTR::parseInputLine):
+        (WTR::TestController::runTest):
+        (WTR::TestController::runUntil):
+        (WTR::TestController::didReceiveMessageFromInjectedBundle):
+        * WebKitTestRunner/TestController.h:
+        * WebKitTestRunner/TestInvocation.cpp:
+        (WTR::TestInvocation::shortTimeout const):
+        (WTR::TestInvocation::createTestSettingsDictionary):
+        * WebKitTestRunner/TestInvocation.h:
+        * WebKitTestRunner/TestOptions.h:
+        * WebKitTestRunner/cocoa/TestControllerCocoa.mm:
+        (WTR::TestController::platformRunUntil):
+        * WebKitTestRunner/gtk/TestControllerGtk.cpp:
+        (WTR::TestController::platformRunUntil):
+        * WebKitTestRunner/wpe/TestControllerWPE.cpp:
+        (WTR::TestController::platformRunUntil):
+
+2018-08-27  Simon Fraser  <simon.fra...@apple.com>
+
+        Convert timeout values in WebKitTestRunner to WTF::Seconds
+        https://bugs.webkit.org/show_bug.cgi?id=188987
+
+        Reviewed by Ryosuke Niwa.
+        
+        Replace various 'int' timeout values with WTF::Seconds. The timeout argument
+        comes in as milliseconds, so convert on input. When sending messages to the InjectedBundle
+        using integers, convert to and from milliseconds.
+        
+        Also do some #pragma once, and initializer cleanup.
+
+        * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
+        (WTR::InjectedBundle::didReceiveMessageToPage):
+        (WTR::InjectedBundle::beginTesting):
+        (WTR::InjectedBundle::InjectedBundle): Deleted.
+        * WebKitTestRunner/InjectedBundle/InjectedBundle.h:
+        * WebKitTestRunner/InjectedBundle/TestRunner.h:
+        (WTR::TestRunner::timeout):
+        (WTR::TestRunner::setCustomTimeout):
+        * WebKitTestRunner/InjectedBundle/gtk/TestRunnerGtk.cpp:
+        (WTR::TestRunner::initializeWaitToDumpWatchdogTimerIfNeeded):
+        * WebKitTestRunner/InjectedBundle/mac/TestRunnerMac.mm:
+        (WTR::TestRunner::invalidateWaitToDumpWatchdogTimer):
+        (WTR::TestRunner::initializeWaitToDumpWatchdogTimerIfNeeded):
+        * WebKitTestRunner/InjectedBundle/wpe/TestRunnerWPE.cpp:
+        (WTR::TestRunner::initializeWaitToDumpWatchdogTimerIfNeeded):
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::TestController):
+        (WTR::parseInputLine):
+        (WTR::TestController::runTest):
+        (WTR::TestController::runUntil):
+        (WTR::TestController::didReceiveMessageFromInjectedBundle):
+        * WebKitTestRunner/TestController.h:
+        * WebKitTestRunner/TestInvocation.cpp:
+        (WTR::TestInvocation::shortTimeout const):
+        (WTR::TestInvocation::createTestSettingsDictionary):
+        * WebKitTestRunner/TestInvocation.h:
+        * WebKitTestRunner/TestOptions.h:
+        * WebKitTestRunner/cocoa/TestControllerCocoa.mm:
+        (WTR::TestController::platformRunUntil):
+        * WebKitTestRunner/gtk/TestControllerGtk.cpp:
+        (WTR::TestController::platformRunUntil):
+        * WebKitTestRunner/wpe/TestControllerWPE.cpp:
+        (WTR::TestController::platformRunUntil):
+
 2018-08-27  Alex Christensen  <achristen...@webkit.org>
 
         REGRESSION(r234985/r234989) WKPageLoadHTMLString with a 16-bit String has the wrong encoding

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl (235398 => 235399)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl	2018-08-27 21:00:25 UTC (rev 235398)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl	2018-08-27 21:11:22 UTC (rev 235399)
@@ -32,8 +32,8 @@
     void waitForPolicyDelegate();
     void waitUntilDone();
     void notifyDone();
-    double preciseTime();
-    readonly attribute double timeout;
+    double preciseTime(); // seconds since the epoch
+    readonly attribute double timeout; // milliseconds
 
     // Downloads.
     void waitUntilDownloadFinished();

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp (235398 => 235399)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp	2018-08-27 21:00:25 UTC (rev 235398)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp	2018-08-27 21:11:22 UTC (rev 235399)
@@ -64,17 +64,6 @@
     return shared;
 }
 
-InjectedBundle::InjectedBundle()
-    : m_bundle(0)
-    , m_topLoadingFrame(0)
-    , m_state(Idle)
-    , m_dumpPixels(false)
-    , m_useWaitToDumpWatchdogTimer(true)
-    , m_useWorkQueue(false)
-    , m_timeout(0)
-{
-}
-
 void InjectedBundle::didCreatePage(WKBundleRef bundle, WKBundlePageRef page, const void* clientInfo)
 {
     static_cast<InjectedBundle*>(const_cast<void*>(clientInfo))->didCreatePage(page);
@@ -205,7 +194,7 @@
         m_useWaitToDumpWatchdogTimer = WKBooleanGetValue(static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(messageBodyDictionary, useWaitToDumpWatchdogTimerKey.get())));
 
         WKRetainPtr<WKStringRef> timeoutKey(AdoptWK, WKStringCreateWithUTF8CString("Timeout"));
-        m_timeout = (int)WKUInt64GetValue(static_cast<WKUInt64Ref>(WKDictionaryGetItemForKey(messageBodyDictionary, timeoutKey.get())));
+        m_timeout = Seconds::fromMilliseconds(WKUInt64GetValue(static_cast<WKUInt64Ref>(WKDictionaryGetItemForKey(messageBodyDictionary, timeoutKey.get()))));
 
         WKRetainPtr<WKStringRef> dumpJSConsoleLogInStdErrKey(AdoptWK, WKStringCreateWithUTF8CString("DumpJSConsoleLogInStdErr"));
         m_dumpJSConsoleLogInStdErr = WKBooleanGetValue(static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(messageBodyDictionary, dumpJSConsoleLogInStdErrKey.get())));
@@ -231,7 +220,6 @@
 
         WKRetainPtr<WKStringRef> shouldGCKey(AdoptWK, WKStringCreateWithUTF8CString("ShouldGC"));
         bool shouldGC = WKBooleanGetValue(static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(messageBodyDictionary, shouldGCKey.get())));
-
         if (shouldGC)
             WKBundleGarbageCollectJavaScriptObjects(m_bundle);
 
@@ -487,7 +475,7 @@
     m_testRunner->setTabKeyCyclesThroughElements(true);
     m_testRunner->clearTestRunnerCallbacks();
 
-    if (m_timeout > 0)
+    if (m_timeout > 0_s)
         m_testRunner->setCustomTimeout(m_timeout);
 
     page()->prepare();

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h (235398 => 235399)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h	2018-08-27 21:00:25 UTC (rev 235398)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h	2018-08-27 21:11:22 UTC (rev 235399)
@@ -145,7 +145,7 @@
     size_t userScriptInjectedCount() const { return m_userScriptInjectedCount; }
 
 private:
-    InjectedBundle();
+    InjectedBundle() = default;
     ~InjectedBundle();
 
     static void didCreatePage(WKBundleRef, WKBundlePageRef, const void* clientInfo);
@@ -170,8 +170,8 @@
 
     bool booleanForKey(WKDictionaryRef, const char* key);
 
-    WKBundleRef m_bundle;
-    WKBundlePageGroupRef m_pageGroup;
+    WKBundleRef m_bundle { nullptr };
+    WKBundlePageGroupRef m_pageGroup { nullptr };
     Vector<std::unique_ptr<InjectedBundlePage>> m_pages;
 
 #if HAVE(ACCESSIBILITY)
@@ -182,7 +182,7 @@
     RefPtr<EventSendingController> m_eventSendingController;
     RefPtr<TextInputController> m_textInputController;
 
-    WKBundleFrameRef m_topLoadingFrame;
+    WKBundleFrameRef m_topLoadingFrame { nullptr };
 
     enum State {
         Idle,
@@ -189,15 +189,16 @@
         Testing,
         Stopping
     };
-    State m_state;
+    State m_state { Idle };
 
-    bool m_dumpPixels;
-    bool m_useWaitToDumpWatchdogTimer;
-    bool m_useWorkQueue;
-    int m_timeout;
+    bool m_dumpPixels { false };
+    bool m_useWaitToDumpWatchdogTimer { true };
+    bool m_useWorkQueue { false };
     bool m_pixelResultIsPending { false };
     bool m_dumpJSConsoleLogInStdErr { false };
 
+    WTF::Seconds m_timeout;
+
     WKRetainPtr<WKDataRef> m_audioResult;
     WKRetainPtr<WKImageRef> m_pixelResult;
     WKRetainPtr<WKArrayRef> m_repaintRects;

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h (235398 => 235399)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h	2018-08-27 21:00:25 UTC (rev 235398)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h	2018-08-27 21:11:22 UTC (rev 235399)
@@ -33,6 +33,7 @@
 #include <WebKit/WKRetainPtr.h>
 #include <string>
 #include <wtf/Ref.h>
+#include <wtf/Seconds.h>
 #include <wtf/text/WTFString.h>
 
 #if PLATFORM(COCOA)
@@ -71,7 +72,7 @@
     void waitUntilDone();
     void notifyDone();
     double preciseTime();
-    double timeout() { return m_timeout; }
+    double timeout() { return m_timeout.milliseconds(); }
 
     // Other dumping.
     void dumpBackForwardList() { m_shouldDumpBackForwardListsForAllWindows = true; }
@@ -315,7 +316,7 @@
 
     bool callShouldCloseOnWebView();
 
-    void setCustomTimeout(int duration) { m_timeout = duration; }
+    void setCustomTimeout(WTF::Seconds duration) { m_timeout = duration; }
 
     // Work queue.
     void queueBackNavigation(unsigned howFarBackward);
@@ -512,7 +513,7 @@
     bool m_globalFlag;
     bool m_customFullScreenBehavior;
 
-    int m_timeout;
+    WTF::Seconds m_timeout;
 
     double m_databaseDefaultQuota;
     double m_databaseMaxQuota;

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/gtk/TestRunnerGtk.cpp (235398 => 235399)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/gtk/TestRunnerGtk.cpp	2018-08-27 21:00:25 UTC (rev 235398)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/gtk/TestRunnerGtk.cpp	2018-08-27 21:11:22 UTC (rev 235399)
@@ -49,7 +49,7 @@
     if (m_waitToDumpWatchdogTimer.isActive())
         return;
 
-    m_waitToDumpWatchdogTimer.startOneShot(1_ms * m_timeout);
+    m_waitToDumpWatchdogTimer.startOneShot(m_timeout);
 }
 
 JSRetainPtr<JSStringRef> TestRunner::pathToLocalResource(JSStringRef url)

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/mac/TestRunnerMac.mm (235398 => 235399)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/mac/TestRunnerMac.mm	2018-08-27 21:00:25 UTC (rev 235398)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/mac/TestRunnerMac.mm	2018-08-27 21:11:22 UTC (rev 235399)
@@ -48,7 +48,7 @@
         return;
 
     CFRunLoopTimerInvalidate(m_waitToDumpWatchdogTimer.get());
-    m_waitToDumpWatchdogTimer = 0;
+    m_waitToDumpWatchdogTimer = nullptr;
 }
 
 static void waitUntilDoneWatchdogTimerFired(CFRunLoopTimerRef timer, void* info)
@@ -61,7 +61,7 @@
     if (m_waitToDumpWatchdogTimer)
         return;
 
-    CFTimeInterval interval = m_timeout / 1000.0;
+    CFTimeInterval interval = m_timeout.seconds();
     m_waitToDumpWatchdogTimer = adoptCF(CFRunLoopTimerCreate(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent() + interval, 0, 0, 0, WTR::waitUntilDoneWatchdogTimerFired, NULL));
     CFRunLoopAddTimer(CFRunLoopGetCurrent(), m_waitToDumpWatchdogTimer.get(), kCFRunLoopCommonModes);
 }

Modified: trunk/Tools/WebKitTestRunner/InjectedBundle/wpe/TestRunnerWPE.cpp (235398 => 235399)


--- trunk/Tools/WebKitTestRunner/InjectedBundle/wpe/TestRunnerWPE.cpp	2018-08-27 21:00:25 UTC (rev 235398)
+++ trunk/Tools/WebKitTestRunner/InjectedBundle/wpe/TestRunnerWPE.cpp	2018-08-27 21:11:22 UTC (rev 235399)
@@ -52,7 +52,7 @@
 void TestRunner::initializeWaitToDumpWatchdogTimerIfNeeded()
 {
     if (!m_waitToDumpWatchdogTimer.isActive())
-        m_waitToDumpWatchdogTimer.startOneShot(1_ms * m_timeout);
+        m_waitToDumpWatchdogTimer.startOneShot(m_timeout);
 }
 
 void TestRunner::installFakeHelvetica(JSStringRef configuration)

Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (235398 => 235399)


--- trunk/Tools/WebKitTestRunner/TestController.cpp	2018-08-27 21:00:25 UTC (rev 235398)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp	2018-08-27 21:11:22 UTC (rev 235399)
@@ -94,10 +94,9 @@
 const unsigned TestController::w3cSVGViewWidth = 480;
 const unsigned TestController::w3cSVGViewHeight = 360;
 
-const double TestController::defaultShortTimeout = 5.0;
+const WTF::Seconds TestController::defaultShortTimeout = 5_s;
+const WTF::Seconds TestController::noTimeout = -1_s;
 
-const double TestController::noTimeout = -1;
-
 static WKURLRef blankURL()
 {
     static WKURLRef staticBlankURL = WKURLCreateWithUTF8CString("about:blank");
@@ -129,7 +128,7 @@
     initialize(argc, argv);
     controller = this;
     run();
-    controller = 0;
+    controller = nullptr;
 }
 
 TestController::~TestController()
@@ -1252,7 +1251,7 @@
         arg = tokenizer.next();
         if (arg == std::string("--timeout")) {
             std::string timeoutToken = tokenizer.next();
-            result.timeout = atoi(timeoutToken.c_str());
+            result.timeout = Seconds::fromMilliseconds(atoi(timeoutToken.c_str()));
         } else if (arg == std::string("-p") || arg == std::string("--pixel-test")) {
             result.shouldDumpPixels = true;
             if (tokenizer.hasNext())
@@ -1283,8 +1282,10 @@
 
     if (command.shouldDumpPixels || m_shouldDumpPixelsForAllTests)
         m_currentInvocation->setIsPixelTest(command.expectedPixelHash);
-    if (command.timeout > 0)
+
+    if (command.timeout > 0_s)
         m_currentInvocation->setCustomTimeout(command.timeout);
+
     m_currentInvocation->setDumpJSConsoleLogInStdErr(command.dumpJSConsoleLogInStdErr || options.dumpJSConsoleLogInStdErr);
 
     platformWillRunTest(*m_currentInvocation);
@@ -1323,7 +1324,7 @@
     }
 }
 
-void TestController::runUntil(bool& done, double timeout)
+void TestController::runUntil(bool& done, WTF::Seconds timeout)
 {
     if (m_forceNoTimeout)
         timeout = noTimeout;
@@ -1414,7 +1415,6 @@
 
         if (WKStringIsEqualToUTF8CString(subMessageName, "KeyDown")) {
             didReceiveKeyDownMessageFromInjectedBundle(messageBodyDictionary, false);
-
             return;
         }
 

Modified: trunk/Tools/WebKitTestRunner/TestController.h (235398 => 235399)


--- trunk/Tools/WebKitTestRunner/TestController.h	2018-08-27 21:00:25 UTC (rev 235398)
+++ trunk/Tools/WebKitTestRunner/TestController.h	2018-08-27 21:11:22 UTC (rev 235399)
@@ -23,8 +23,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TestController_h
-#define TestController_h
+#pragma once
 
 #include "GeolocationProviderMock.h"
 #include "WebNotificationProvider.h"
@@ -34,6 +33,7 @@
 #include <string>
 #include <vector>
 #include <wtf/HashMap.h>
+#include <wtf/Seconds.h>
 #include <wtf/Vector.h>
 #include <wtf/text/StringHash.h>
 
@@ -59,8 +59,8 @@
     static const unsigned w3cSVGViewWidth;
     static const unsigned w3cSVGViewHeight;
 
-    static const double defaultShortTimeout;
-    static const double noTimeout;
+    static const WTF::Seconds defaultShortTimeout;
+    static const WTF::Seconds noTimeout;
 
     TestController(int argc, const char* argv[]);
     ~TestController();
@@ -79,7 +79,7 @@
     
     // Runs the run loop until `done` is true or the timeout elapses.
     bool useWaitToDumpWatchdogTimer() { return m_useWaitToDumpWatchdogTimer; }
-    void runUntil(bool& done, double timeoutSeconds);
+    void runUntil(bool& done, WTF::Seconds timeout);
     void notifyDone();
 
     bool shouldShowWebView() const { return m_shouldShowWebView; }
@@ -247,7 +247,7 @@
 #endif
     void platformConfigureViewForTest(const TestInvocation&);
     void platformWillRunTest(const TestInvocation&);
-    void platformRunUntil(bool& done, double timeout);
+    void platformRunUntil(bool& done, WTF::Seconds timeout);
     void platformDidCommitLoadForFrame(WKPageRef, WKFrameRef);
     WKContextRef platformContext();
     WKPreferencesRef platformPreferences();
@@ -291,7 +291,6 @@
     static void didFinishNavigation(WKPageRef, WKNavigationRef, WKTypeRef userData, const void*);
     void didFinishNavigation(WKPageRef, WKNavigationRef);
 
-    
     // WKContextDownloadClient
     static void downloadDidStart(WKContextRef, WKDownloadRef, const void*);
     void downloadDidStart(WKContextRef, WKDownloadRef);
@@ -450,12 +449,10 @@
 struct TestCommand {
     std::string pathOrURL;
     std::string absolutePath;
+    std::string expectedPixelHash;
+    WTF::Seconds timeout;
     bool shouldDumpPixels { false };
-    std::string expectedPixelHash;
-    int timeout { 0 };
     bool dumpJSConsoleLogInStdErr { false };
 };
 
 } // namespace WTR
-
-#endif // TestController_h

Modified: trunk/Tools/WebKitTestRunner/TestInvocation.cpp (235398 => 235399)


--- trunk/Tools/WebKitTestRunner/TestInvocation.cpp	2018-08-27 21:00:25 UTC (rev 235398)
+++ trunk/Tools/WebKitTestRunner/TestInvocation.cpp	2018-08-27 21:11:22 UTC (rev 235399)
@@ -101,7 +101,7 @@
     m_expectedPixelHash = expectedPixelHash;
 }
 
-double TestInvocation::shortTimeout() const
+WTF::Seconds TestInvocation::shortTimeout() const
 {
     if (!m_timeout) {
         // Running WKTR directly, without webkitpy.
@@ -112,7 +112,7 @@
     // but it currently does. There is no way to know what a normal test's timeout is, as webkitpy only passes timeouts
     // for each test individually.
     // But there shouldn't be any observable negative consequences from this.
-    return m_timeout / 1000. / 4;
+    return m_timeout / 4;
 }
 
 bool TestInvocation::shouldLogHistoryClientCallbacks() const
@@ -137,7 +137,7 @@
     WKDictionarySetItem(beginTestMessageBody.get(), useWaitToDumpWatchdogTimerKey.get(), useWaitToDumpWatchdogTimerValue.get());
 
     WKRetainPtr<WKStringRef> timeoutKey = adoptWK(WKStringCreateWithUTF8CString("Timeout"));
-    WKRetainPtr<WKUInt64Ref> timeoutValue = adoptWK(WKUInt64Create(m_timeout));
+    WKRetainPtr<WKUInt64Ref> timeoutValue = adoptWK(WKUInt64Create(m_timeout.milliseconds()));
     WKDictionarySetItem(beginTestMessageBody.get(), timeoutKey.get(), timeoutValue.get());
 
     WKRetainPtr<WKStringRef> dumpJSConsoleLogInStdErrKey = adoptWK(WKStringCreateWithUTF8CString("DumpJSConsoleLogInStdErr"));

Modified: trunk/Tools/WebKitTestRunner/TestInvocation.h (235398 => 235399)


--- trunk/Tools/WebKitTestRunner/TestInvocation.h	2018-08-27 21:00:25 UTC (rev 235398)
+++ trunk/Tools/WebKitTestRunner/TestInvocation.h	2018-08-27 21:11:22 UTC (rev 235399)
@@ -33,6 +33,7 @@
 #include <WebKit/WKRetainPtr.h>
 #include <string>
 #include <wtf/Noncopyable.h>
+#include <wtf/Seconds.h>
 #include <wtf/text/StringBuilder.h>
 
 namespace WTR {
@@ -50,12 +51,10 @@
 
     void setIsPixelTest(const std::string& expectedPixelHash);
 
-    // Milliseconds
-    void setCustomTimeout(int duration) { m_timeout = duration; }
+    void setCustomTimeout(WTF::Seconds duration) { m_timeout = duration; }
     void setDumpJSConsoleLogInStdErr(bool value) { m_dumpJSConsoleLogInStdErr = value; }
 
-    // Seconds
-    double shortTimeout() const;
+    WTF::Seconds shortTimeout() const;
 
     void invoke();
     void didReceiveMessageFromInjectedBundle(WKStringRef messageName, WKTypeRef messageBody);
@@ -116,7 +115,7 @@
 
     std::string m_expectedPixelHash;
 
-    int m_timeout { 0 };
+    WTF::Seconds m_timeout;
     bool m_dumpJSConsoleLogInStdErr { false };
 
     // Invocation state

Modified: trunk/Tools/WebKitTestRunner/TestOptions.h (235398 => 235399)


--- trunk/Tools/WebKitTestRunner/TestOptions.h	2018-08-27 21:00:25 UTC (rev 235398)
+++ trunk/Tools/WebKitTestRunner/TestOptions.h	2018-08-27 21:11:22 UTC (rev 235399)
@@ -23,8 +23,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef TestOptions_h
-#define TestOptions_h
+#pragma once
 
 #include <wtf/Vector.h>
 #include <wtf/text/WTFString.h>
@@ -111,5 +110,3 @@
 };
 
 }
-
-#endif // TestOptions_h

Modified: trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm (235398 => 235399)


--- trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm	2018-08-27 21:00:25 UTC (rev 235398)
+++ trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm	2018-08-27 21:11:22 UTC (rev 235399)
@@ -196,9 +196,9 @@
 #endif
 }
 
-void TestController::platformRunUntil(bool& done, double timeout)
+void TestController::platformRunUntil(bool& done, WTF::Seconds timeout)
 {
-    NSDate *endDate = (timeout > 0) ? [NSDate dateWithTimeIntervalSinceNow:timeout] : [NSDate distantFuture];
+    NSDate *endDate = (timeout > 0_s) ? [NSDate dateWithTimeIntervalSinceNow:timeout.seconds()] : [NSDate distantFuture];
 
     while (!done && [endDate compare:[NSDate date]] == NSOrderedDescending)
         [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:endDate];

Modified: trunk/Tools/WebKitTestRunner/gtk/TestControllerGtk.cpp (235398 => 235399)


--- trunk/Tools/WebKitTestRunner/gtk/TestControllerGtk.cpp	2018-08-27 21:00:25 UTC (rev 235398)
+++ trunk/Tools/WebKitTestRunner/gtk/TestControllerGtk.cpp	2018-08-27 21:11:22 UTC (rev 235399)
@@ -74,13 +74,12 @@
 {
 }
 
-void TestController::platformRunUntil(bool&, double timeout)
+void TestController::platformRunUntil(bool&, WTF::Seconds timeout)
 {
-    if (timeout > 0) {
+    if (timeout > 0_s) {
         // FIXME: This conversion is now repeated in several places, it should be moved to a common place in WTF and used everywhere.
-        auto timeoutDuration = Seconds { timeout };
         gint64 currentTime = g_get_monotonic_time();
-        gint64 targetTime = currentTime + std::min<gint64>(G_MAXINT64 - currentTime, timeoutDuration.microsecondsAs<int64_t>());
+        gint64 targetTime = currentTime + std::min<gint64>(G_MAXINT64 - currentTime, timeout.microsecondsAs<int64_t>());
         ASSERT(targetTime >= currentTime);
         g_source_set_ready_time(timeoutSource(), targetTime);
     } else

Modified: trunk/Tools/WebKitTestRunner/wpe/TestControllerWPE.cpp (235398 => 235399)


--- trunk/Tools/WebKitTestRunner/wpe/TestControllerWPE.cpp	2018-08-27 21:00:25 UTC (rev 235398)
+++ trunk/Tools/WebKitTestRunner/wpe/TestControllerWPE.cpp	2018-08-27 21:11:22 UTC (rev 235399)
@@ -58,7 +58,7 @@
 {
 }
 
-void TestController::platformRunUntil(bool& condition, double timeout)
+void TestController::platformRunUntil(bool& condition, WTF::Seconds timeout)
 {
     struct TimeoutTimer {
         TimeoutTimer()
@@ -70,8 +70,8 @@
     } timeoutTimer;
 
     timeoutTimer.timer.setPriority(G_PRIORITY_DEFAULT_IDLE);
-    if (timeout >= 0)
-        timeoutTimer.timer.startOneShot(Seconds(timeout));
+    if (timeout >= 0_s)
+        timeoutTimer.timer.startOneShot(timeout);
 
     RunLoop::main().run();
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to