Changeset 135496 in webkit
- Timestamp:
- Nov 22, 2012 1:44:45 AM (11 years ago)
- Location:
- trunk/Tools
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r135489 r135496 1 2012-11-22 Balazs Kelemen <kbalazs@webkit.org> 2 3 [Qt][WTR] TestController::platformRunUntil should not do busy waiting 4 https://bugs.webkit.org/show_bug.cgi?id=101327 5 6 Reviewed by Simon Hausmann. 7 8 Avoid busy waiting for events in platformRunUntil while making 9 sure we don't change the behavior of modal event loops. 10 11 * WebKitTestRunner/TestController.cpp: 12 (WTR::TestController::~TestController): 13 * WebKitTestRunner/TestController.h: 14 (TestController): 15 * WebKitTestRunner/efl/TestControllerEfl.cpp: 16 (WTR::TestController::platformDestroy): 17 (WTR): 18 * WebKitTestRunner/gtk/TestControllerGtk.cpp: 19 (WTR::TestController::platformDestroy): 20 (WTR): 21 * WebKitTestRunner/mac/TestControllerMac.mm: 22 (WTR::TestController::platformDestroy): 23 (WTR): 24 * WebKitTestRunner/qt/TestControllerQt.cpp: 25 (TestController::RunLoop): Helper class to handle 26 the event loop logic 27 (WTR): 28 (WTR::TestController::RunLoop::RunLoop): 29 (WTR::TestController::RunLoop::runUntil): Use QEventLoop to implement 30 the run loop. This is the appropriate API to push the WaitForMoreEvents 31 flag to QCoreApplication::processEvents and also being able to exit the 32 loop if we have timed out. 33 (WTR::TestController::RunLoop::notifyDone): 34 (WTR::TestController::RunLoop::timerFired): 35 (WTR::TestController::RunLoop::runModal): 36 (WTR::TestController::notifyDone): 37 (WTR::TestController::platformInitialize): 38 (WTR::TestController::platformDestroy): 39 (WTR::TestController::platformRunUntil): 40 (WTR::TestController::runModal): 41 * WebKitTestRunner/win/TestControllerWin.cpp: 42 (WTR::TestController::platformDestroy): 43 (WTR): 44 1 45 2012-11-22 Sudarsana Nagineni <sudarsana.nagineni@intel.com> 2 46 -
trunk/Tools/WebKitTestRunner/TestController.cpp
r135151 r135496 110 110 TestController::~TestController() 111 111 { 112 platformDestroy(); 112 113 } 113 114 -
trunk/Tools/WebKitTestRunner/TestController.h
r133676 r135496 93 93 94 94 void platformInitialize(); 95 void platformDestroy(); 95 96 void platformInitializeContext(); 96 97 void platformRunUntil(bool& done, double timeout); … … 183 184 #endif 184 185 186 #if PLATFORM(QT) 187 class RunLoop; 188 RunLoop* m_runLoop; 189 #endif 190 185 191 WorkQueueManager m_workQueueManager; 186 192 }; -
trunk/Tools/WebKitTestRunner/efl/TestControllerEfl.cpp
r132338 r135496 58 58 } 59 59 60 void TestController::platformDestroy() 61 { 62 } 63 60 64 void TestController::platformRunUntil(bool& condition, double timeout) 61 65 { -
trunk/Tools/WebKitTestRunner/gtk/TestControllerGtk.cpp
r110382 r135496 55 55 } 56 56 57 void TestController::platformDestroy() 58 { 59 } 60 57 61 static gboolean timeoutCallback(gpointer) 58 62 { -
trunk/Tools/WebKitTestRunner/mac/TestControllerMac.mm
r134780 r135496 41 41 } 42 42 43 void TestController::platformDestroy() 44 { 45 } 46 43 47 void TestController::initializeInjectedBundlePath() 44 48 { -
trunk/Tools/WebKitTestRunner/qt/TestControllerQt.cpp
r130623 r135496 33 33 #include <cstdlib> 34 34 #include <QCoreApplication> 35 #include <QElapsedTimer>36 35 #include <QEventLoop> 37 36 #include <QFileInfo> 38 37 #include <QLibrary> 39 38 #include <QObject> 39 #include <QTimer> 40 #include <QtGlobal> 40 41 #include <qquickwebview_p.h> 41 #include <QtGlobal>42 42 #include <wtf/Platform.h> 43 43 #include <wtf/text/WTFString.h> … … 45 45 namespace WTR { 46 46 47 class TestController::RunLoop : public QObject { 48 Q_OBJECT 49 public: 50 RunLoop(); 51 52 void runUntil(double timeout); 53 void notifyDone(); 54 void runModal(PlatformWebView*); 55 public Q_SLOTS: 56 void timerFired(); 57 private: 58 QEventLoop m_runUntilLoop; 59 QEventLoop m_modalLoop; 60 QTimer m_runUntilLoopTimer; 61 bool m_runUntilLoopClosePending; 62 }; 63 64 TestController::RunLoop::RunLoop() 65 : m_runUntilLoopClosePending(false) 66 { 67 m_runUntilLoopTimer.setSingleShot(true); 68 QObject::connect(&m_runUntilLoopTimer, SIGNAL(timeout()), this, SLOT(timerFired())); 69 } 70 71 void TestController::RunLoop::runUntil(double timeout) 72 { 73 ASSERT(!m_runUntilLoop.isRunning()); 74 if (timeout) { 75 const int timeoutInMilliSecs = timeout * 1000; 76 m_runUntilLoopTimer.start(timeoutInMilliSecs); 77 } 78 m_runUntilLoop.exec(QEventLoop::ExcludeUserInputEvents); 79 } 80 81 void TestController::RunLoop::notifyDone() 82 { 83 if (m_modalLoop.isRunning()) { 84 // Wait for the modal loop first. We only kill it if we timeout. 85 m_runUntilLoopClosePending = true; 86 return; 87 } 88 89 m_runUntilLoopTimer.stop(); 90 m_runUntilLoop.exit(); 91 } 92 93 void TestController::RunLoop::timerFired() 94 { 95 if (m_modalLoop.isRunning()) { 96 m_runUntilLoopClosePending = true; 97 m_modalLoop.exit(); 98 return; 99 } 100 101 m_runUntilLoop.exit(); 102 } 103 104 void TestController::RunLoop::runModal(PlatformWebView* view) 105 { 106 ASSERT(!m_modalLoop.isRunning()); 107 view->setModalEventLoop(&m_modalLoop); 108 m_modalLoop.exec(QEventLoop::ExcludeUserInputEvents); 109 110 if (m_runUntilLoopClosePending) 111 m_runUntilLoop.exit(); 112 } 113 47 114 void TestController::notifyDone() 48 115 { 116 m_runLoop->notifyDone(); 49 117 } 50 118 51 119 void TestController::platformInitialize() 52 120 { 121 m_runLoop = new RunLoop; 53 122 QQuickWebView::platformInitialize(); 123 } 124 125 void TestController::platformDestroy() 126 { 127 delete m_runLoop; 54 128 } 55 129 56 130 void TestController::platformRunUntil(bool& condition, double timeout) 57 131 { 58 if (qgetenv("QT_WEBKIT2_DEBUG") == "1" || timeout == m_noTimeout) { 59 // Never timeout if we are debugging or not meant to timeout. 60 while (!condition) 61 QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents, 50); 62 return; 63 } 64 65 int timeoutInMSecs = timeout * 1000; 66 QElapsedTimer timer; 67 timer.start(); 68 while (!condition) { 69 if (timer.elapsed() > timeoutInMSecs) 70 return; 71 QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents, timeoutInMSecs - timer.elapsed()); 72 } 132 UNUSED_PARAM(condition); 133 const bool shouldTimeout = !(qgetenv("QT_WEBKIT2_DEBUG") == "1" || timeout == m_noTimeout); 134 m_runLoop->runUntil(shouldTimeout ? timeout : 0); 73 135 } 74 136 … … 114 176 void TestController::runModal(PlatformWebView* view) 115 177 { 116 QEventLoop eventLoop; 117 view->setModalEventLoop(&eventLoop); 118 eventLoop.exec(QEventLoop::ExcludeUserInputEvents); 178 shared().m_runLoop->runModal(view); 119 179 } 120 180 … … 125 185 126 186 } // namespace WTR 187 188 #include "TestControllerQt.moc" -
trunk/Tools/WebKitTestRunner/win/TestControllerWin.cpp
r110382 r135496 122 122 } 123 123 124 void TestController::platformDestroy() 125 { 126 } 127 124 128 void TestController::initializeInjectedBundlePath() 125 129 {
Note: See TracChangeset
for help on using the changeset viewer.