Changeset 51761 in webkit


Ignore:
Timestamp:
Dec 7, 2009 6:13:45 AM (14 years ago)
Author:
eric@webkit.org
Message:

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):
Location:
trunk/WebKit/qt
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit/qt/ChangeLog

    r51759 r51761  
     12009-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
    1172009-12-07  Girish Ramakrishnan  <girish@forwardbias.in>
    218
  • trunk/WebKit/qt/tests/qgraphicswebview/tst_qgraphicswebview.cpp

    r50647 r51761  
    1818*/
    1919
     20#include "../util.h"
    2021#include <QtTest/QtTest>
    21 
    2222#include <QGraphicsView>
    2323#include <qgraphicswebview.h>
    2424#include <qwebpage.h>
    2525#include <qwebframe.h>
    26 
    27 /**
    28  * Starts an event loop that runs until the given signal is received.
    29  * Optionally the event loop
    30  * can return earlier on a timeout.
    31  *
    32  * \return \p true if the requested signal was received
    33  *         \p false on timeout
    34  */
    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 }
    4926
    5027class tst_QGraphicsWebView : public QObject
     
    11491    view.resize(600, 480);
    11592    webView->resize(view.geometry().size());
    116     QTest::qWait(200);
     93    QCoreApplication::processEvents();
    11794    view.show();
    11895
     
    123100                                            "</frameset>"));
    124101
    125     QVERIFY(::waitForSignal(page, SIGNAL(loadFinished(bool))));
     102    QVERIFY(waitForSignal(page, SIGNAL(loadFinished(bool))));
    126103}
    127104
  • trunk/WebKit/qt/tests/util.h

    r48561 r51761  
    1818*/
    1919// 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 */
     33static 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}
    2047
    2148// Will try to wait for the condition while allowing event processing
     
    4673        QCOMPARE(__expr, __expected); \
    4774    } while(0)
    48 
Note: See TracChangeset for help on using the changeset viewer.