Changeset 51761 in webkit
- Timestamp:
- Dec 7, 2009 6:13:45 AM (14 years ago)
- Location:
- trunk/WebKit/qt
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKit/qt/ChangeLog
r51759 r51761 1 2009-12-07 Benjamin Poulain <benjamin.poulain@nokia.com> 2 3 Reviewed by Kenneth Rohde Christiansen. 4 5 [Qt] Improve the autotests of QtWebkit 6 https://bugs.webkit.org/show_bug.cgi?id=32216 7 8 Refactor the test of QGraphicsWebView: 9 -make waitForSignal() available to all the tests. 10 -remove QTest::qWait() 11 12 * tests/qgraphicswebview/tst_qgraphicswebview.cpp: 13 (tst_QGraphicsWebView::crashOnViewlessWebPages): 14 * tests/util.h: 15 (waitForSignal): 16 1 17 2009-12-07 Girish Ramakrishnan <girish@forwardbias.in> 2 18 -
trunk/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp
r50647 r51761 18 18 */ 19 19 20 #include "../util.h" 20 21 #include <QtTest/QtTest> 21 22 22 #include <QGraphicsView> 23 23 #include <qgraphicswebview.h> 24 24 #include <qwebpage.h> 25 25 #include <qwebframe.h> 26 27 /**28 * Starts an event loop that runs until the given signal is received.29 * Optionally the event loop30 * can return earlier on a timeout.31 *32 * \return \p true if the requested signal was received33 * \p false on timeout34 */35 static bool waitForSignal(QObject* obj, const char* signal, int timeout = 10000)36 {37 QEventLoop loop;38 QObject::connect(obj, signal, &loop, SLOT(quit()));39 QTimer timer;40 QSignalSpy timeoutSpy(&timer, SIGNAL(timeout()));41 if (timeout > 0) {42 QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));43 timer.setSingleShot(true);44 timer.start(timeout);45 }46 loop.exec();47 return timeoutSpy.isEmpty();48 }49 26 50 27 class tst_QGraphicsWebView : public QObject … … 114 91 view.resize(600, 480); 115 92 webView->resize(view.geometry().size()); 116 Q Test::qWait(200);93 QCoreApplication::processEvents(); 117 94 view.show(); 118 95 … … 123 100 "</frameset>")); 124 101 125 QVERIFY( ::waitForSignal(page, SIGNAL(loadFinished(bool))));102 QVERIFY(waitForSignal(page, SIGNAL(loadFinished(bool)))); 126 103 } 127 104 -
trunk/WebKit/qt/tests/util.h
r48561 r51761 18 18 */ 19 19 // Functions and macros that really need to be in QTestLib 20 21 #include <QEventLoop> 22 #include <QSignalSpy> 23 #include <QTimer> 24 25 /** 26 * Starts an event loop that runs until the given signal is received. 27 * Optionally the event loop 28 * can return earlier on a timeout. 29 * 30 * \return \p true if the requested signal was received 31 * \p false on timeout 32 */ 33 static bool waitForSignal(QObject* obj, const char* signal, int timeout = 10000) 34 { 35 QEventLoop loop; 36 QObject::connect(obj, signal, &loop, SLOT(quit())); 37 QTimer timer; 38 QSignalSpy timeoutSpy(&timer, SIGNAL(timeout())); 39 if (timeout > 0) { 40 QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit())); 41 timer.setSingleShot(true); 42 timer.start(timeout); 43 } 44 loop.exec(); 45 return timeoutSpy.isEmpty(); 46 } 20 47 21 48 // Will try to wait for the condition while allowing event processing … … 46 73 QCOMPARE(__expr, __expected); \ 47 74 } while(0) 48
Note: See TracChangeset
for help on using the changeset viewer.