Changeset 235399 in webkit
- Timestamp:
- Aug 27, 2018, 2:11:22 PM (7 years ago)
- Location:
- trunk/Tools
- Files:
-
- 16 edited
-
ChangeLog (modified) (1 diff)
-
WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl (modified) (1 diff)
-
WebKitTestRunner/InjectedBundle/InjectedBundle.cpp (modified) (4 diffs)
-
WebKitTestRunner/InjectedBundle/InjectedBundle.h (modified) (4 diffs)
-
WebKitTestRunner/InjectedBundle/TestRunner.h (modified) (4 diffs)
-
WebKitTestRunner/InjectedBundle/gtk/TestRunnerGtk.cpp (modified) (1 diff)
-
WebKitTestRunner/InjectedBundle/mac/TestRunnerMac.mm (modified) (2 diffs)
-
WebKitTestRunner/InjectedBundle/wpe/TestRunnerWPE.cpp (modified) (1 diff)
-
WebKitTestRunner/TestController.cpp (modified) (6 diffs)
-
WebKitTestRunner/TestController.h (modified) (7 diffs)
-
WebKitTestRunner/TestInvocation.cpp (modified) (3 diffs)
-
WebKitTestRunner/TestInvocation.h (modified) (3 diffs)
-
WebKitTestRunner/TestOptions.h (modified) (2 diffs)
-
WebKitTestRunner/cocoa/TestControllerCocoa.mm (modified) (1 diff)
-
WebKitTestRunner/gtk/TestControllerGtk.cpp (modified) (1 diff)
-
WebKitTestRunner/wpe/TestControllerWPE.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r235397 r235399 1 2018-08-27 Simon Fraser <simon.fraser@apple.com> 2 3 Convert timeout values in WebKitTestRunner to WTF::Seconds 4 https://bugs.webkit.org/show_bug.cgi?id=188987 5 6 Reviewed by Ryosuke Niwa. 7 8 Replace various 'int' timeout values with WTF::Seconds. The timeout argument 9 comes in as milliseconds, so convert on input. When sending messages to the InjectedBundle 10 using integers, convert to and from milliseconds. 11 12 Also do some #pragma once, and initializer cleanup. 13 14 * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp: 15 (WTR::InjectedBundle::didReceiveMessageToPage): 16 (WTR::InjectedBundle::beginTesting): 17 (WTR::InjectedBundle::InjectedBundle): Deleted. 18 * WebKitTestRunner/InjectedBundle/InjectedBundle.h: 19 * WebKitTestRunner/InjectedBundle/TestRunner.h: 20 (WTR::TestRunner::timeout): 21 (WTR::TestRunner::setCustomTimeout): 22 * WebKitTestRunner/InjectedBundle/gtk/TestRunnerGtk.cpp: 23 (WTR::TestRunner::initializeWaitToDumpWatchdogTimerIfNeeded): 24 * WebKitTestRunner/InjectedBundle/mac/TestRunnerMac.mm: 25 (WTR::TestRunner::invalidateWaitToDumpWatchdogTimer): 26 (WTR::TestRunner::initializeWaitToDumpWatchdogTimerIfNeeded): 27 * WebKitTestRunner/InjectedBundle/wpe/TestRunnerWPE.cpp: 28 (WTR::TestRunner::initializeWaitToDumpWatchdogTimerIfNeeded): 29 * WebKitTestRunner/TestController.cpp: 30 (WTR::TestController::TestController): 31 (WTR::parseInputLine): 32 (WTR::TestController::runTest): 33 (WTR::TestController::runUntil): 34 (WTR::TestController::didReceiveMessageFromInjectedBundle): 35 * WebKitTestRunner/TestController.h: 36 * WebKitTestRunner/TestInvocation.cpp: 37 (WTR::TestInvocation::shortTimeout const): 38 (WTR::TestInvocation::createTestSettingsDictionary): 39 * WebKitTestRunner/TestInvocation.h: 40 * WebKitTestRunner/TestOptions.h: 41 * WebKitTestRunner/cocoa/TestControllerCocoa.mm: 42 (WTR::TestController::platformRunUntil): 43 * WebKitTestRunner/gtk/TestControllerGtk.cpp: 44 (WTR::TestController::platformRunUntil): 45 * WebKitTestRunner/wpe/TestControllerWPE.cpp: 46 (WTR::TestController::platformRunUntil): 47 48 2018-08-27 Simon Fraser <simon.fraser@apple.com> 49 50 Convert timeout values in WebKitTestRunner to WTF::Seconds 51 https://bugs.webkit.org/show_bug.cgi?id=188987 52 53 Reviewed by Ryosuke Niwa. 54 55 Replace various 'int' timeout values with WTF::Seconds. The timeout argument 56 comes in as milliseconds, so convert on input. When sending messages to the InjectedBundle 57 using integers, convert to and from milliseconds. 58 59 Also do some #pragma once, and initializer cleanup. 60 61 * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp: 62 (WTR::InjectedBundle::didReceiveMessageToPage): 63 (WTR::InjectedBundle::beginTesting): 64 (WTR::InjectedBundle::InjectedBundle): Deleted. 65 * WebKitTestRunner/InjectedBundle/InjectedBundle.h: 66 * WebKitTestRunner/InjectedBundle/TestRunner.h: 67 (WTR::TestRunner::timeout): 68 (WTR::TestRunner::setCustomTimeout): 69 * WebKitTestRunner/InjectedBundle/gtk/TestRunnerGtk.cpp: 70 (WTR::TestRunner::initializeWaitToDumpWatchdogTimerIfNeeded): 71 * WebKitTestRunner/InjectedBundle/mac/TestRunnerMac.mm: 72 (WTR::TestRunner::invalidateWaitToDumpWatchdogTimer): 73 (WTR::TestRunner::initializeWaitToDumpWatchdogTimerIfNeeded): 74 * WebKitTestRunner/InjectedBundle/wpe/TestRunnerWPE.cpp: 75 (WTR::TestRunner::initializeWaitToDumpWatchdogTimerIfNeeded): 76 * WebKitTestRunner/TestController.cpp: 77 (WTR::TestController::TestController): 78 (WTR::parseInputLine): 79 (WTR::TestController::runTest): 80 (WTR::TestController::runUntil): 81 (WTR::TestController::didReceiveMessageFromInjectedBundle): 82 * WebKitTestRunner/TestController.h: 83 * WebKitTestRunner/TestInvocation.cpp: 84 (WTR::TestInvocation::shortTimeout const): 85 (WTR::TestInvocation::createTestSettingsDictionary): 86 * WebKitTestRunner/TestInvocation.h: 87 * WebKitTestRunner/TestOptions.h: 88 * WebKitTestRunner/cocoa/TestControllerCocoa.mm: 89 (WTR::TestController::platformRunUntil): 90 * WebKitTestRunner/gtk/TestControllerGtk.cpp: 91 (WTR::TestController::platformRunUntil): 92 * WebKitTestRunner/wpe/TestControllerWPE.cpp: 93 (WTR::TestController::platformRunUntil): 94 1 95 2018-08-27 Alex Christensen <achristensen@webkit.org> 2 96 -
trunk/Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl
r235125 r235399 33 33 void waitUntilDone(); 34 34 void notifyDone(); 35 double preciseTime(); 36 readonly attribute double timeout; 35 double preciseTime(); // seconds since the epoch 36 readonly attribute double timeout; // milliseconds 37 37 38 38 // Downloads. -
trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
r234440 r235399 65 65 } 66 66 67 InjectedBundle::InjectedBundle()68 : m_bundle(0)69 , m_topLoadingFrame(0)70 , m_state(Idle)71 , m_dumpPixels(false)72 , m_useWaitToDumpWatchdogTimer(true)73 , m_useWorkQueue(false)74 , m_timeout(0)75 {76 }77 78 67 void InjectedBundle::didCreatePage(WKBundleRef bundle, WKBundlePageRef page, const void* clientInfo) 79 68 { … … 206 195 207 196 WKRetainPtr<WKStringRef> timeoutKey(AdoptWK, WKStringCreateWithUTF8CString("Timeout")); 208 m_timeout = (int)WKUInt64GetValue(static_cast<WKUInt64Ref>(WKDictionaryGetItemForKey(messageBodyDictionary, timeoutKey.get())));197 m_timeout = Seconds::fromMilliseconds(WKUInt64GetValue(static_cast<WKUInt64Ref>(WKDictionaryGetItemForKey(messageBodyDictionary, timeoutKey.get())))); 209 198 210 199 WKRetainPtr<WKStringRef> dumpJSConsoleLogInStdErrKey(AdoptWK, WKStringCreateWithUTF8CString("DumpJSConsoleLogInStdErr")); … … 232 221 WKRetainPtr<WKStringRef> shouldGCKey(AdoptWK, WKStringCreateWithUTF8CString("ShouldGC")); 233 222 bool shouldGC = WKBooleanGetValue(static_cast<WKBooleanRef>(WKDictionaryGetItemForKey(messageBodyDictionary, shouldGCKey.get()))); 234 235 223 if (shouldGC) 236 224 WKBundleGarbageCollectJavaScriptObjects(m_bundle); … … 488 476 m_testRunner->clearTestRunnerCallbacks(); 489 477 490 if (m_timeout > 0 )478 if (m_timeout > 0_s) 491 479 m_testRunner->setCustomTimeout(m_timeout); 492 480 -
trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h
r233782 r235399 146 146 147 147 private: 148 InjectedBundle() ;148 InjectedBundle() = default; 149 149 ~InjectedBundle(); 150 150 … … 171 171 bool booleanForKey(WKDictionaryRef, const char* key); 172 172 173 WKBundleRef m_bundle ;174 WKBundlePageGroupRef m_pageGroup ;173 WKBundleRef m_bundle { nullptr }; 174 WKBundlePageGroupRef m_pageGroup { nullptr }; 175 175 Vector<std::unique_ptr<InjectedBundlePage>> m_pages; 176 176 … … 183 183 RefPtr<TextInputController> m_textInputController; 184 184 185 WKBundleFrameRef m_topLoadingFrame ;185 WKBundleFrameRef m_topLoadingFrame { nullptr }; 186 186 187 187 enum State { … … 190 190 Stopping 191 191 }; 192 State m_state; 193 194 bool m_dumpPixels; 195 bool m_useWaitToDumpWatchdogTimer; 196 bool m_useWorkQueue; 197 int m_timeout; 192 State m_state { Idle }; 193 194 bool m_dumpPixels { false }; 195 bool m_useWaitToDumpWatchdogTimer { true }; 196 bool m_useWorkQueue { false }; 198 197 bool m_pixelResultIsPending { false }; 199 198 bool m_dumpJSConsoleLogInStdErr { false }; 199 200 WTF::Seconds m_timeout; 200 201 201 202 WKRetainPtr<WKDataRef> m_audioResult; -
trunk/Tools/WebKitTestRunner/InjectedBundle/TestRunner.h
r235125 r235399 34 34 #include <string> 35 35 #include <wtf/Ref.h> 36 #include <wtf/Seconds.h> 36 37 #include <wtf/text/WTFString.h> 37 38 … … 72 73 void notifyDone(); 73 74 double preciseTime(); 74 double timeout() { return m_timeout ; }75 double timeout() { return m_timeout.milliseconds(); } 75 76 76 77 // Other dumping. … … 316 317 bool callShouldCloseOnWebView(); 317 318 318 void setCustomTimeout( intduration) { m_timeout = duration; }319 void setCustomTimeout(WTF::Seconds duration) { m_timeout = duration; } 319 320 320 321 // Work queue. … … 513 514 bool m_customFullScreenBehavior; 514 515 515 intm_timeout;516 WTF::Seconds m_timeout; 516 517 517 518 double m_databaseDefaultQuota; -
trunk/Tools/WebKitTestRunner/InjectedBundle/gtk/TestRunnerGtk.cpp
r232832 r235399 50 50 return; 51 51 52 m_waitToDumpWatchdogTimer.startOneShot( 1_ms *m_timeout);52 m_waitToDumpWatchdogTimer.startOneShot(m_timeout); 53 53 } 54 54 -
trunk/Tools/WebKitTestRunner/InjectedBundle/mac/TestRunnerMac.mm
r225641 r235399 49 49 50 50 CFRunLoopTimerInvalidate(m_waitToDumpWatchdogTimer.get()); 51 m_waitToDumpWatchdogTimer = 0;51 m_waitToDumpWatchdogTimer = nullptr; 52 52 } 53 53 … … 62 62 return; 63 63 64 CFTimeInterval interval = m_timeout / 1000.0;64 CFTimeInterval interval = m_timeout.seconds(); 65 65 m_waitToDumpWatchdogTimer = adoptCF(CFRunLoopTimerCreate(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent() + interval, 0, 0, 0, WTR::waitUntilDoneWatchdogTimerFired, NULL)); 66 66 CFRunLoopAddTimer(CFRunLoopGetCurrent(), m_waitToDumpWatchdogTimer.get(), kCFRunLoopCommonModes); -
trunk/Tools/WebKitTestRunner/InjectedBundle/wpe/TestRunnerWPE.cpp
r229256 r235399 53 53 { 54 54 if (!m_waitToDumpWatchdogTimer.isActive()) 55 m_waitToDumpWatchdogTimer.startOneShot( 1_ms *m_timeout);55 m_waitToDumpWatchdogTimer.startOneShot(m_timeout); 56 56 } 57 57 -
trunk/Tools/WebKitTestRunner/TestController.cpp
r235125 r235399 95 95 const unsigned TestController::w3cSVGViewHeight = 360; 96 96 97 const double TestController::defaultShortTimeout = 5.0; 98 99 const double TestController::noTimeout = -1; 97 const WTF::Seconds TestController::defaultShortTimeout = 5_s; 98 const WTF::Seconds TestController::noTimeout = -1_s; 100 99 101 100 static WKURLRef blankURL() … … 130 129 controller = this; 131 130 run(); 132 controller = 0;131 controller = nullptr; 133 132 } 134 133 … … 1253 1252 if (arg == std::string("--timeout")) { 1254 1253 std::string timeoutToken = tokenizer.next(); 1255 result.timeout = atoi(timeoutToken.c_str());1254 result.timeout = Seconds::fromMilliseconds(atoi(timeoutToken.c_str())); 1256 1255 } else if (arg == std::string("-p") || arg == std::string("--pixel-test")) { 1257 1256 result.shouldDumpPixels = true; … … 1284 1283 if (command.shouldDumpPixels || m_shouldDumpPixelsForAllTests) 1285 1284 m_currentInvocation->setIsPixelTest(command.expectedPixelHash); 1286 if (command.timeout > 0) 1285 1286 if (command.timeout > 0_s) 1287 1287 m_currentInvocation->setCustomTimeout(command.timeout); 1288 1288 1289 m_currentInvocation->setDumpJSConsoleLogInStdErr(command.dumpJSConsoleLogInStdErr || options.dumpJSConsoleLogInStdErr); 1289 1290 … … 1324 1325 } 1325 1326 1326 void TestController::runUntil(bool& done, doubletimeout)1327 void TestController::runUntil(bool& done, WTF::Seconds timeout) 1327 1328 { 1328 1329 if (m_forceNoTimeout) … … 1415 1416 if (WKStringIsEqualToUTF8CString(subMessageName, "KeyDown")) { 1416 1417 didReceiveKeyDownMessageFromInjectedBundle(messageBodyDictionary, false); 1417 1418 1418 return; 1419 1419 } -
trunk/Tools/WebKitTestRunner/TestController.h
r235125 r235399 24 24 */ 25 25 26 #ifndef TestController_h 27 #define TestController_h 26 #pragma once 28 27 29 28 #include "GeolocationProviderMock.h" … … 35 34 #include <vector> 36 35 #include <wtf/HashMap.h> 36 #include <wtf/Seconds.h> 37 37 #include <wtf/Vector.h> 38 38 #include <wtf/text/StringHash.h> … … 60 60 static const unsigned w3cSVGViewHeight; 61 61 62 static const doubledefaultShortTimeout;63 static const doublenoTimeout;62 static const WTF::Seconds defaultShortTimeout; 63 static const WTF::Seconds noTimeout; 64 64 65 65 TestController(int argc, const char* argv[]); … … 80 80 // Runs the run loop until `done` is true or the timeout elapses. 81 81 bool useWaitToDumpWatchdogTimer() { return m_useWaitToDumpWatchdogTimer; } 82 void runUntil(bool& done, double timeoutSeconds);82 void runUntil(bool& done, WTF::Seconds timeout); 83 83 void notifyDone(); 84 84 … … 248 248 void platformConfigureViewForTest(const TestInvocation&); 249 249 void platformWillRunTest(const TestInvocation&); 250 void platformRunUntil(bool& done, doubletimeout);250 void platformRunUntil(bool& done, WTF::Seconds timeout); 251 251 void platformDidCommitLoadForFrame(WKPageRef, WKFrameRef); 252 252 WKContextRef platformContext(); … … 292 292 void didFinishNavigation(WKPageRef, WKNavigationRef); 293 293 294 295 294 // WKContextDownloadClient 296 295 static void downloadDidStart(WKContextRef, WKDownloadRef, const void*); … … 451 450 std::string pathOrURL; 452 451 std::string absolutePath; 452 std::string expectedPixelHash; 453 WTF::Seconds timeout; 453 454 bool shouldDumpPixels { false }; 454 std::string expectedPixelHash;455 int timeout { 0 };456 455 bool dumpJSConsoleLogInStdErr { false }; 457 456 }; 458 457 459 458 } // namespace WTR 460 461 #endif // TestController_h -
trunk/Tools/WebKitTestRunner/TestInvocation.cpp
r235243 r235399 102 102 } 103 103 104 doubleTestInvocation::shortTimeout() const104 WTF::Seconds TestInvocation::shortTimeout() const 105 105 { 106 106 if (!m_timeout) { … … 113 113 // for each test individually. 114 114 // But there shouldn't be any observable negative consequences from this. 115 return m_timeout / 1000. /4;115 return m_timeout / 4; 116 116 } 117 117 … … 138 138 139 139 WKRetainPtr<WKStringRef> timeoutKey = adoptWK(WKStringCreateWithUTF8CString("Timeout")); 140 WKRetainPtr<WKUInt64Ref> timeoutValue = adoptWK(WKUInt64Create(m_timeout ));140 WKRetainPtr<WKUInt64Ref> timeoutValue = adoptWK(WKUInt64Create(m_timeout.milliseconds())); 141 141 WKDictionarySetItem(beginTestMessageBody.get(), timeoutKey.get(), timeoutValue.get()); 142 142 -
trunk/Tools/WebKitTestRunner/TestInvocation.h
r234440 r235399 34 34 #include <string> 35 35 #include <wtf/Noncopyable.h> 36 #include <wtf/Seconds.h> 36 37 #include <wtf/text/StringBuilder.h> 37 38 … … 51 52 void setIsPixelTest(const std::string& expectedPixelHash); 52 53 53 // Milliseconds 54 void setCustomTimeout(int duration) { m_timeout = duration; } 54 void setCustomTimeout(WTF::Seconds duration) { m_timeout = duration; } 55 55 void setDumpJSConsoleLogInStdErr(bool value) { m_dumpJSConsoleLogInStdErr = value; } 56 56 57 // Seconds 58 double shortTimeout() const; 57 WTF::Seconds shortTimeout() const; 59 58 60 59 void invoke(); … … 117 116 std::string m_expectedPixelHash; 118 117 119 int m_timeout { 0 };118 WTF::Seconds m_timeout; 120 119 bool m_dumpJSConsoleLogInStdErr { false }; 121 120 -
trunk/Tools/WebKitTestRunner/TestOptions.h
r233897 r235399 24 24 */ 25 25 26 #ifndef TestOptions_h 27 #define TestOptions_h 26 #pragma once 28 27 29 28 #include <wtf/Vector.h> … … 112 111 113 112 } 114 115 #endif // TestOptions_h -
trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm
r234440 r235399 197 197 } 198 198 199 void TestController::platformRunUntil(bool& done, doubletimeout)200 { 201 NSDate *endDate = (timeout > 0 ) ? [NSDate dateWithTimeIntervalSinceNow:timeout] : [NSDate distantFuture];199 void TestController::platformRunUntil(bool& done, WTF::Seconds timeout) 200 { 201 NSDate *endDate = (timeout > 0_s) ? [NSDate dateWithTimeIntervalSinceNow:timeout.seconds()] : [NSDate distantFuture]; 202 202 203 203 while (!done && [endDate compare:[NSDate date]] == NSOrderedDescending) -
trunk/Tools/WebKitTestRunner/gtk/TestControllerGtk.cpp
r226349 r235399 75 75 } 76 76 77 void TestController::platformRunUntil(bool&, doubletimeout)77 void TestController::platformRunUntil(bool&, WTF::Seconds timeout) 78 78 { 79 if (timeout > 0 ) {79 if (timeout > 0_s) { 80 80 // FIXME: This conversion is now repeated in several places, it should be moved to a common place in WTF and used everywhere. 81 auto timeoutDuration = Seconds { timeout };82 81 gint64 currentTime = g_get_monotonic_time(); 83 gint64 targetTime = currentTime + std::min<gint64>(G_MAXINT64 - currentTime, timeout Duration.microsecondsAs<int64_t>());82 gint64 targetTime = currentTime + std::min<gint64>(G_MAXINT64 - currentTime, timeout.microsecondsAs<int64_t>()); 84 83 ASSERT(targetTime >= currentTime); 85 84 g_source_set_ready_time(timeoutSource(), targetTime); -
trunk/Tools/WebKitTestRunner/wpe/TestControllerWPE.cpp
r229256 r235399 59 59 } 60 60 61 void TestController::platformRunUntil(bool& condition, doubletimeout)61 void TestController::platformRunUntil(bool& condition, WTF::Seconds timeout) 62 62 { 63 63 struct TimeoutTimer { … … 71 71 72 72 timeoutTimer.timer.setPriority(G_PRIORITY_DEFAULT_IDLE); 73 if (timeout >= 0 )74 timeoutTimer.timer.startOneShot( Seconds(timeout));73 if (timeout >= 0_s) 74 timeoutTimer.timer.startOneShot(timeout); 75 75 76 76 RunLoop::main().run();
Note:
See TracChangeset
for help on using the changeset viewer.