Changeset 92199 in webkit


Ignore:
Timestamp:
Aug 2, 2011 10:00:28 AM (13 years ago)
Author:
jocelyn.turcotte@nokia.com
Message:

[Qt] Add QtWebProcess in PATH at runtime for WebKit2 API auto tests.
https://bugs.webkit.org/show_bug.cgi?id=65378

Reviewed by Benjamin Poulain.

This prevent the runner of the tests from having to add it to PATH himself.

  • UIProcess/API/qt/tests/commonviewtests/tst_commonviewtests.cpp:

(tst_CommonViewTests::tst_CommonViewTests):

  • UIProcess/API/qt/tests/qdesktopwebview/tst_qdesktopwebview.cpp:

(tst_QDesktopWebView::tst_QDesktopWebView):

  • UIProcess/API/qt/tests/qtouchwebview/tst_qtouchwebview.cpp:

(tst_QTouchWebView::tst_QTouchWebView):

  • UIProcess/API/qt/tests/tests.pri:
  • UIProcess/API/qt/tests/util.cpp: Copied from Source/WebKit2/UIProcess/API/qt/tests/util.h.

Move definitions to a cpp file to prevent unused static symbol warnings.
(addQtWebProcessToPath):
(waitForSignal):

  • UIProcess/API/qt/tests/util.h:
Location:
trunk/Source/WebKit2
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r92198 r92199  
     12011-07-29  Jocelyn Turcotte  <jocelyn.turcotte@nokia.com>
     2
     3        [Qt] Add QtWebProcess in PATH at runtime for WebKit2 API auto tests.
     4        https://bugs.webkit.org/show_bug.cgi?id=65378
     5
     6        Reviewed by Benjamin Poulain.
     7
     8        This prevent the runner of the tests from having to add it to PATH himself.
     9
     10        * UIProcess/API/qt/tests/commonviewtests/tst_commonviewtests.cpp:
     11        (tst_CommonViewTests::tst_CommonViewTests):
     12        * UIProcess/API/qt/tests/qdesktopwebview/tst_qdesktopwebview.cpp:
     13        (tst_QDesktopWebView::tst_QDesktopWebView):
     14        * UIProcess/API/qt/tests/qtouchwebview/tst_qtouchwebview.cpp:
     15        (tst_QTouchWebView::tst_QTouchWebView):
     16        * UIProcess/API/qt/tests/tests.pri:
     17        * UIProcess/API/qt/tests/util.cpp: Copied from Source/WebKit2/UIProcess/API/qt/tests/util.h.
     18        Move definitions to a cpp file to prevent unused static symbol warnings.
     19        (addQtWebProcessToPath):
     20        (waitForSignal):
     21        * UIProcess/API/qt/tests/util.h:
     22
    1232011-07-12  Jocelyn Turcotte  <jocelyn.turcotte@nokia.com>
    224
  • trunk/Source/WebKit2/UIProcess/API/qt/tests/commonviewtests/tst_commonviewtests.cpp

    r91985 r92199  
    2626class tst_CommonViewTests : public QObject {
    2727    Q_OBJECT
     28public:
     29    tst_CommonViewTests();
     30
    2831private slots:
    2932    void init();
     
    4447    QScopedPointer<WebViewAbstraction> viewAbstraction;
    4548};
     49
     50tst_CommonViewTests::tst_CommonViewTests()
     51{
     52    addQtWebProcessToPath();
     53}
    4654
    4755void tst_CommonViewTests::init()
  • trunk/Source/WebKit2/UIProcess/API/qt/tests/qdesktopwebview/tst_qdesktopwebview.cpp

    r90844 r92199  
    2727class tst_QDesktopWebView : public QObject {
    2828    Q_OBJECT
     29public:
     30    tst_QDesktopWebView();
    2931
    3032private slots:
     
    3941    QScopedPointer<TestWindow> m_window;
    4042};
     43
     44tst_QDesktopWebView::tst_QDesktopWebView()
     45{
     46    addQtWebProcessToPath();
     47}
    4148
    4249void tst_QDesktopWebView::init()
  • trunk/Source/WebKit2/UIProcess/API/qt/tests/qtouchwebview/tst_qtouchwebview.cpp

    r90837 r92199  
    2323#include <qtouchwebview.h>
    2424#include "../testwindow.h"
     25#include "../util.h"
    2526
    2627Q_DECLARE_METATYPE(QTouchWebPage*);
     
    4445tst_QTouchWebView::tst_QTouchWebView()
    4546{
     47    addQtWebProcessToPath();
    4648    qRegisterMetaType<QTouchWebPage*>("QTouchWebPage*");
    4749}
  • trunk/Source/WebKit2/UIProcess/API/qt/tests/tests.pri

    r91863 r92199  
    77ELSE { TARGET = tst_$$TARGET }
    88
    9 SOURCES += $${TARGET}.cpp
     9SOURCES += $${TARGET}.cpp \
     10           ../util.cpp
    1011INCLUDEPATH += $$PWD
    1112
     
    1415
    1516QMAKE_RPATHDIR = $$OUTPUT_DIR/lib $$QMAKE_RPATHDIR
    16 DEFINES += TESTS_SOURCE_DIR=\\\"$$PWD\\\"
     17DEFINES += TESTS_SOURCE_DIR=\\\"$$PWD\\\" \
     18           QWP_PATH=\\\"$$OUTPUT_DIR/bin\\\"
  • trunk/Source/WebKit2/UIProcess/API/qt/tests/util.cpp

    r92198 r92199  
    1717    Boston, MA 02110-1301, USA.
    1818*/
    19 // Functions and macros that really need to be in QTestLib
    2019
    21 #include <QEventLoop>
    22 #include <QSignalSpy>
    23 #include <QTimer>
     20#include "util.h"
    2421
    25 #if !defined(TESTS_SOURCE_DIR)
    26 #define TESTS_SOURCE_DIR ""
    27 #endif
     22void addQtWebProcessToPath()
     23{
     24    // Since tests won't find ./QtWebProcess, add it to PATH (at the end to prevent surprises).
     25    // QWP_PATH should be defined by qmake.
     26    qputenv("PATH", qgetenv("PATH") + ":" + QWP_PATH);
     27}
    2828
    2929/**
     
    3535 *         \p false on timeout
    3636 */
    37 static bool waitForSignal(QObject* obj, const char* signal, int timeout = 10000)
     37bool waitForSignal(QObject* obj, const char* signal, int timeout)
    3838{
    3939    QEventLoop loop;
     
    5050}
    5151
    52 // Will try to wait for the condition while allowing event processing
    53 #define QTRY_VERIFY(__expr) \
    54     do { \
    55         const int __step = 50; \
    56         const int __timeout = 5000; \
    57         if (!(__expr)) { \
    58             QTest::qWait(0); \
    59         } \
    60         for (int __i = 0; __i < __timeout && !(__expr); __i+=__step) { \
    61             QTest::qWait(__step); \
    62         } \
    63         QVERIFY(__expr); \
    64     } while(0)
    65 
    66 // Will try to wait for the condition while allowing event processing
    67 #define QTRY_COMPARE(__expr, __expected) \
    68     do { \
    69         const int __step = 50; \
    70         const int __timeout = 5000; \
    71         if ((__expr) != (__expected)) { \
    72             QTest::qWait(0); \
    73         } \
    74         for (int __i = 0; __i < __timeout && ((__expr) != (__expected)); __i+=__step) { \
    75             QTest::qWait(__step); \
    76         } \
    77         QCOMPARE(__expr, __expected); \
    78     } while(0)
  • trunk/Source/WebKit2/UIProcess/API/qt/tests/util.h

    r79945 r92199  
    2727#endif
    2828
    29 /**
    30  * Starts an event loop that runs until the given signal is received.
    31  * Optionally the event loop
    32  * can return earlier on a timeout.
    33  *
    34  * \return \p true if the requested signal was received
    35  *         \p false on timeout
    36  */
    37 static bool waitForSignal(QObject* obj, const char* signal, int timeout = 10000)
    38 {
    39     QEventLoop loop;
    40     QObject::connect(obj, signal, &loop, SLOT(quit()));
    41     QTimer timer;
    42     QSignalSpy timeoutSpy(&timer, SIGNAL(timeout()));
    43     if (timeout > 0) {
    44         QObject::connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
    45         timer.setSingleShot(true);
    46         timer.start(timeout);
    47     }
    48     loop.exec();
    49     return timeoutSpy.isEmpty();
    50 }
     29void addQtWebProcessToPath();
     30bool waitForSignal(QObject*, const char* signal, int timeout = 10000);
    5131
    5232// Will try to wait for the condition while allowing event processing
Note: See TracChangeset for help on using the changeset viewer.