Changeset 52111 in webkit


Ignore:
Timestamp:
Dec 14, 2009 12:42:41 PM (14 years ago)
Author:
eric@webkit.org
Message:

2009-12-14 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_qwebelement to remove the qWait()

  • tests/qwebelement/tst_qwebelement.cpp: (tst_QWebElement::style):
Location:
trunk/WebKit/qt
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit/qt/ChangeLog

    r52110 r52111  
     12009-12-14  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_qwebelement to remove the qWait()
     9
     10        * tests/qwebelement/tst_qwebelement.cpp:
     11        (tst_QWebElement::style):
     12
    1132009-12-14  Andreas Kling  <andreas.kling@nokia.com>
    214
  • trunk/WebKit/qt/tests/qwebelement/tst_qwebelement.cpp

    r51111 r52111  
    1919
    2020
     21#include <../util.h>
    2122#include <QtTest/QtTest>
    22 
    2323#include <qwebpage.h>
    2424#include <qwidget.h>
     
    2828//TESTED_CLASS=
    2929//TESTED_FILES=
    30 
    31 /**
    32  * Starts an event loop that runs until the given signal is received.
    33  Optionally the event loop
    34  * can return earlier on a timeout.
    35  *
    36  * \return \p true if the requested signal was received
    37  *         \p false on timeout
    38  */
    39 static bool waitForSignal(QObject* obj, const char* signal, int timeout = 0)
    40 {
    41     QEventLoop loop;
    42     QObject::connect(obj, signal, &loop, SLOT(quit()));
    43     QTimer timer;
    44     QSignalSpy timeoutSpy(&timer, SIGNAL(timeout()));
    45     if (timeout > 0) {
    46         QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
    47         timer.setSingleShot(true);
    48         timer.start(timeout);
    49     }
    50     loop.exec();
    51     return timeoutSpy.isEmpty();
    52 }
    5330
    5431class tst_QWebElement : public QObject
     
    577554
    578555    // in few seconds, the CSS should be completey loaded
    579     QSignalSpy spy(m_page, SIGNAL(loadFinished(bool)));
    580556    m_mainFrame->setHtml(html6);
    581     QTest::qWait(200);
     557    waitForSignal(m_page, SIGNAL(loadFinished(bool)), 200);
    582558
    583559    p = m_mainFrame->documentElement().findAll("p").at(0);
     
    597573    // in few seconds, the style should be completey loaded
    598574    m_mainFrame->setHtml(html7);
    599     QTest::qWait(200);
     575    waitForSignal(m_page, SIGNAL(loadFinished(bool)), 200);
    600576
    601577    p = m_mainFrame->documentElement().findAll("p").at(0);
Note: See TracChangeset for help on using the changeset viewer.