Changeset 51763 in webkit


Ignore:
Timestamp:
Dec 7, 2009 6:34:50 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 tst_qwebframe to remove qWait() and use
the function waitForSignal() from util.h

  • tests/qwebframe/tst_qwebframe.cpp:
Location:
trunk/WebKit/qt
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit/qt/ChangeLog

    r51761 r51763  
     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 tst_qwebframe to remove qWait() and use
     9        the function waitForSignal() from util.h
     10
     11        * tests/qwebframe/tst_qwebframe.cpp:
     12
    1132009-12-07  Benjamin Poulain  <benjamin.poulain@nokia.com>
    214
  • trunk/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp

    r51306 r51763  
    4242# define SRCDIR ""
    4343#endif
    44 
    45 //TESTED_CLASS=
    46 //TESTED_FILES=
    47 
    48 // Task 160192
    49 /**
    50  * Starts an event loop that runs until the given signal is received.
    51  Optionally the event loop
    52  * can return earlier on a timeout.
    53  *
    54  * \return \p true if the requested signal was received
    55  *         \p false on timeout
    56  */
    57 static bool waitForSignal(QObject* obj, const char* signal, int timeout = 0)
    58 {
    59     QEventLoop loop;
    60     QObject::connect(obj, signal, &loop, SLOT(quit()));
    61     QTimer timer;
    62     QSignalSpy timeoutSpy(&timer, SIGNAL(timeout()));
    63     if (timeout > 0) {
    64         QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
    65         timer.setSingleShot(true);
    66         timer.start(timeout);
    67     }
    68     loop.exec();
    69     return timeoutSpy.isEmpty();
    70 }
    71 
    72 /* Mostly a test for the JavaScript related parts of QWebFrame */
    73 
    7444
    7545struct CustomType {
     
    22722242
    22732243    frame->setUrl(QUrl("qrc:/test1.html"));
    2274     QTest::qWait(200);
     2244    waitForSignal(frame, SIGNAL(loadFinished(bool)), 200);
    22752245    QCOMPARE(spy.count(), 1);
    22762246    QCOMPARE(frame->requestedUrl(), QUrl("qrc:/test1.html"));
     
    22782248
    22792249    frame->setUrl(QUrl("qrc:/non-existent.html"));
    2280     QTest::qWait(200);
     2250    waitForSignal(frame, SIGNAL(loadFinished(bool)), 200);
    22812251    QCOMPARE(spy.count(), 2);
    22822252    QCOMPARE(frame->requestedUrl(), QUrl("qrc:/non-existent.html"));
     
    22842254
    22852255    frame->setUrl(QUrl("http://abcdef.abcdef"));
    2286     QTest::qWait(200);
     2256    waitForSignal(frame, SIGNAL(loadFinished(bool)), 200);
    22872257    QCOMPARE(spy.count(), 3);
    22882258    QCOMPARE(frame->requestedUrl(), QUrl("http://abcdef.abcdef/"));
     
    22952265    QSignalSpy spy2(page.networkAccessManager(), SIGNAL(sslErrors(QNetworkReply*,QList<QSslError>)));
    22962266    frame->setUrl(QUrl("qrc:/fake-ssl-error.html"));
    2297     QTest::qWait(200);
     2267    waitForSignal(frame, SIGNAL(loadFinished(bool)), 200);
    22982268    QCOMPARE(spy2.count(), 1);
    22992269    QCOMPARE(frame->requestedUrl(), QUrl("qrc:/fake-ssl-error.html"));
     
    23532323    QSignalSpy spy(&page, SIGNAL(loadFinished(bool)));
    23542324    frame->setHtml(html);
    2355     QTest::qWait(200);
     2325    waitForSignal(frame, SIGNAL(loadFinished(bool)), 200);
    23562326    QCOMPARE(spy.count(), 1);
    23572327
     
    23722342    // in few seconds, the CSS should be completey loaded
    23732343    frame->setHtml(html2);
    2374     QTest::qWait(200);
     2344    waitForSignal(frame, SIGNAL(loadFinished(bool)), 200);
    23752345    QCOMPARE(spy.size(), 2);
    23762346
     
    23902360
    23912361    frame->setHtml(html, QUrl::fromLocalFile(QDir::currentPath()));
    2392     QTest::qWait(200);
     2362    waitForSignal(frame, SIGNAL(loadFinished(bool)), 200);
    23932363    QCOMPARE(spy.count(), 1);
    23942364
     
    25012471    QTRY_VERIFY(view.hasFocus() && !combo->view()->hasFocus()); // Focus should be back on the WebView
    25022472
    2503     // triple the flashing time, should at least blink twice already
    2504     int delay = qApp->cursorFlashTime() * 3;
     2473    // double the flashing time, should at least blink once already
     2474    int delay = qApp->cursorFlashTime() * 2;
    25052475
    25062476    // focus the lineedit and check if it blinks
     
    25092479    view.installEventFilter( this );
    25102480    QTest::qWait(delay);
    2511     QVERIFY2(m_popupTestPaintCount >= 4,
     2481    QVERIFY2(m_popupTestPaintCount >= 3,
    25122482             "The input field should have a blinking caret");
    25132483}
     
    26532623    m_page->mainFrame()->setHtml(html);
    26542624
    2655     QTest::qWait(200);
     2625    waitForSignal(m_page->mainFrame(), SIGNAL(loadFinished(bool)), 200);
    26562626    QCOMPARE(loadSpy.size(), 1);
    26572627
     
    26632633    frame->setHtml(innerHtml);
    26642634
    2665     QTest::qWait(200);
     2635    waitForSignal(frame, SIGNAL(loadFinished(bool)), 200);
    26662636    QCOMPARE(loadSpy.size(), 2);
    26672637
     
    27502720    view.show();
    27512721
    2752     QTest::qWait(200);
     2722    QTest::qWaitForWindowShown(&view);
    27532723
    27542724    view.page()->mainFrame()->evaluateJavaScript(
     
    27562726
    27572727    ::waitForSignal(view.page(), SIGNAL(repaintRequested(QRect)));
    2758 
    2759     QTest::qWait(2000);
    27602728}
    27612729
Note: See TracChangeset for help on using the changeset viewer.