2009-12-07 Benjamin Poulain <benjamin.poulain@nokia.com>
authoreric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 7 Dec 2009 14:13:45 +0000 (14:13 +0000)
committereric@webkit.org <eric@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 7 Dec 2009 14:13:45 +0000 (14:13 +0000)
        Reviewed by Kenneth Rohde Christiansen.

        [Qt] Improve the autotests of QtWebkit
        https://bugs.webkit.org/show_bug.cgi?id=32216

        Refactor the test of QGraphicsWebView:
        -make waitForSignal() available to all the tests.
        -remove QTest::qWait()

        * tests/qgraphicswebview/tst_qgraphicswebview.cpp:
        (tst_QGraphicsWebView::crashOnViewlessWebPages):
        * tests/util.h:
        (waitForSignal):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@51761 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKit/qt/ChangeLog
WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp
WebKit/qt/tests/util.h

index 35144eb5dfb6b6040a9ad911bfb3682aafa36040..74a25b73a4b3d20e42797168707d4534ee8d8cbf 100644 (file)
@@ -1,3 +1,19 @@
+2009-12-07  Benjamin Poulain  <benjamin.poulain@nokia.com>
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        [Qt] Improve the autotests of QtWebkit
+        https://bugs.webkit.org/show_bug.cgi?id=32216
+
+        Refactor the test of QGraphicsWebView:
+        -make waitForSignal() available to all the tests.
+        -remove QTest::qWait()
+
+        * tests/qgraphicswebview/tst_qgraphicswebview.cpp:
+        (tst_QGraphicsWebView::crashOnViewlessWebPages):
+        * tests/util.h:
+        (waitForSignal):
+
 2009-12-07  Girish Ramakrishnan  <girish@forwardbias.in>
 
         Reviewed by Simon Hausmann.
 2009-12-07  Girish Ramakrishnan  <girish@forwardbias.in>
 
         Reviewed by Simon Hausmann.
index a52e167c2eeb1f39fe7c6a7dd5464ab30096aff9..657e09f52705f389fdd4532aaea2ee1b11868be8 100644 (file)
     Boston, MA 02110-1301, USA.
 */
 
     Boston, MA 02110-1301, USA.
 */
 
+#include "../util.h"
 #include <QtTest/QtTest>
 #include <QtTest/QtTest>
-
 #include <QGraphicsView>
 #include <qgraphicswebview.h>
 #include <qwebpage.h>
 #include <qwebframe.h>
 
 #include <QGraphicsView>
 #include <qgraphicswebview.h>
 #include <qwebpage.h>
 #include <qwebframe.h>
 
-/**
- * Starts an event loop that runs until the given signal is received.
- * Optionally the event loop
- * can return earlier on a timeout.
- *
- * \return \p true if the requested signal was received
- *         \p false on timeout
- */
-static bool waitForSignal(QObject* obj, const char* signal, int timeout = 10000)
-{
-    QEventLoop loop;
-    QObject::connect(obj, signal, &loop, SLOT(quit()));
-    QTimer timer;
-    QSignalSpy timeoutSpy(&timer, SIGNAL(timeout()));
-    if (timeout > 0) {
-        QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
-        timer.setSingleShot(true);
-        timer.start(timeout);
-    }
-    loop.exec();
-    return timeoutSpy.isEmpty();
-}
-
 class tst_QGraphicsWebView : public QObject
 {
     Q_OBJECT
 class tst_QGraphicsWebView : public QObject
 {
     Q_OBJECT
@@ -113,7 +90,7 @@ void tst_QGraphicsWebView::crashOnViewlessWebPages()
     view.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
     view.resize(600, 480);
     webView->resize(view.geometry().size());
     view.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
     view.resize(600, 480);
     webView->resize(view.geometry().size());
-    QTest::qWait(200);
+    QCoreApplication::processEvents();
     view.show();
 
     page->mainFrame()->setHtml(QString("data:text/html,"
     view.show();
 
     page->mainFrame()->setHtml(QString("data:text/html,"
@@ -122,7 +99,7 @@ void tst_QGraphicsWebView::crashOnViewlessWebPages()
                                                 "<frame src=\"data:text/html,bar\">"
                                             "</frameset>"));
 
                                                 "<frame src=\"data:text/html,bar\">"
                                             "</frameset>"));
 
-    QVERIFY(::waitForSignal(page, SIGNAL(loadFinished(bool))));
+    QVERIFY(waitForSignal(page, SIGNAL(loadFinished(bool))));
 }
 
 QTEST_MAIN(tst_QGraphicsWebView)
 }
 
 QTEST_MAIN(tst_QGraphicsWebView)
index 7f7e6137bc0bb195a14fc175cb27905fb9cc29dd..15af262cd477541dc577a8758d37e92aa72fad57 100644 (file)
 */
 // Functions and macros that really need to be in QTestLib
 
 */
 // Functions and macros that really need to be in QTestLib
 
+#include <QEventLoop>
+#include <QSignalSpy>
+#include <QTimer>
+
+/**
+ * Starts an event loop that runs until the given signal is received.
+ * Optionally the event loop
+ * can return earlier on a timeout.
+ *
+ * \return \p true if the requested signal was received
+ *         \p false on timeout
+ */
+static bool waitForSignal(QObject* obj, const char* signal, int timeout = 10000)
+{
+    QEventLoop loop;
+    QObject::connect(obj, signal, &loop, SLOT(quit()));
+    QTimer timer;
+    QSignalSpy timeoutSpy(&timer, SIGNAL(timeout()));
+    if (timeout > 0) {
+        QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
+        timer.setSingleShot(true);
+        timer.start(timeout);
+    }
+    loop.exec();
+    return timeoutSpy.isEmpty();
+}
+
 // Will try to wait for the condition while allowing event processing
 #define QTRY_VERIFY(__expr) \
     do { \
 // Will try to wait for the condition while allowing event processing
 #define QTRY_VERIFY(__expr) \
     do { \
@@ -45,4 +72,3 @@
         } \
         QCOMPARE(__expr, __expected); \
     } while(0)
         } \
         QCOMPARE(__expr, __expected); \
     } while(0)
-