Ignore:
Timestamp:
Feb 11, 2010, 11:19:06 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.1 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/testlib/qtestcase.cpp

    r2 r561  
    22**
    33** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
    4 ** Contact: Qt Software Information (qt-info@nokia.com)
     4** All rights reserved.
     5** Contact: Nokia Corporation (qt-info@nokia.com)
    56**
    67** This file is part of the QtTest module of the Qt Toolkit.
     
    2122** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    2223**
    23 ** In addition, as a special exception, Nokia gives you certain
    24 ** additional rights. These rights are described in the Nokia Qt LGPL
    25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
    26 ** package.
     24** In addition, as a special exception, Nokia gives you certain additional
     25** rights.  These rights are described in the Nokia Qt LGPL Exception
     26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
    2727**
    2828** GNU General Public License Usage
     
    3434** met: http://www.gnu.org/copyleft/gpl.html.
    3535**
    36 ** If you are unsure which license is appropriate for your use, please
    37 ** contact the sales department at qt-sales@nokia.com.
     36** If you have questions regarding the use of this file, please contact
     37** Nokia at qt-info@nokia.com.
    3838** $QT_END_LICENSE$
    3939**
     
    5555#include <QtCore/qprocess.h>
    5656#include <QtCore/qdebug.h>
     57#include <QtCore/qlibraryinfo.h>
    5758
    5859#include "QtTest/private/qtestlog_p.h"
     
    7273#endif
    7374#ifdef Q_OS_UNIX
     75#include <errno.h>
     76#include <signal.h>
    7477#include <time.h>
    7578#endif
     
    301304    Use this macro to build stand-alone executables.
    302305
     306    \bold {Note:} On platforms that have keypad navigation enabled by default (eg: Symbian),
     307    this macro will forcfully disable it to simplify the usage of key events when writing
     308    autotests. If you wish to write a test case that uses keypad navigation, you should
     309    enable it either in the \c {initTestCase()} or \c {init()} functions of your test case.
     310
    303311    Example:
    304312    \snippet doc/src/snippets/code/src_qtestlib_qtestcase.cpp 11
    305313
    306     \sa QTEST_APPLESS_MAIN(), QTest::qExec()
     314    \sa QTEST_APPLESS_MAIN(), QTest::qExec(), QApplication::setNavigationMode()
    307315*/
    308316
     
    348356        {Chapter 5: Writing a Benchmark}{Writing a Benchmark}
    349357*/
     358
     359/*!
     360    \macro QBENCHMARK_ONCE
     361    \since 4.6
     362
     363    \relates QTest
     364
     365    \brief The QBENCHMARK_ONCE macro is for measuring performance of a
     366    code block by running it once.
     367
     368    This macro is used to measure the performance of code within a test.
     369    The code to be benchmarked is contained within a code block following
     370    this macro.
     371
     372    Unlike QBENCHMARK, the contents of the contained code block is only run
     373    once. The elapsed time will be reported as "0" if it's to short to
     374    be measured by the selected backend. (Use)
     375
     376    \sa {QTestLib Manual#Creating a Benchmark}{Creating a Benchmark},
     377    {Chapter 5: Writing a Benchmark}{Writing a Benchmark}
     378*/
     379
     380
    350381
    351382/*! \enum QTest::SkipMode
     
    401432    \overload
    402433
    403     Simulates clicking of \a key with an optional \a modifier on a \a widget. If \a delay is larger than 0, the test will wait for \a delay milliseconds.
     434    Simulates clicking of \a key with an optional \a modifier on a \a widget.
     435    If \a delay is larger than 0, the test will wait for \a delay milliseconds.
    404436
    405437    Example:
     
    414446/*! \fn void QTest::keyClick(QWidget *widget, Qt::Key key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1)
    415447
    416     Simulates clicking of \a key with an optional \a modifier on a \a widget. If \a delay is larger than 0, the test will wait for \a delay milliseconds.
     448    Simulates clicking of \a key with an optional \a modifier on a \a widget.
     449    If \a delay is larger than 0, the test will wait for \a delay milliseconds.
    417450
    418451    Examples:
     
    429462/*! \fn void QTest::keyEvent(KeyAction action, QWidget *widget, Qt::Key key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1)
    430463
    431     Sends a Qt key event to \a widget with the given \a key and an associated \a action. Optionally, a keyboard \a modifier can be specified, as well as a \a delay (in milliseconds) of the test before sending the event.
     464    Sends a Qt key event to \a widget with the given \a key and an associated \a action.
     465    Optionally, a keyboard \a modifier can be specified, as well as a \a delay
     466    (in milliseconds) of the test before sending the event.
    432467*/
    433468
     
    436471    \overload
    437472
    438     Sends a Qt key event to \a widget with the given key \a ascii and an associated \a action. Optionally, a keyboard \a modifier can be specified, as well as a \a delay (in milliseconds) of the test before sending the event.
     473    Sends a Qt key event to \a widget with the given key \a ascii and an associated \a action.
     474    Optionally, a keyboard \a modifier can be specified, as well as a \a delay
     475    (in milliseconds) of the test before sending the event.
    439476
    440477*/
     
    442479/*! \fn void QTest::keyPress(QWidget *widget, Qt::Key key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1)
    443480
    444     Simulates pressing a \a key with an optional \a modifier on a \a widget. If \a delay is larger than 0, the test will wait for \a delay milliseconds.
     481    Simulates pressing a \a key with an optional \a modifier on a \a widget. If \a delay
     482    is larger than 0, the test will wait for \a delay milliseconds.
    445483
    446484    \bold {Note:} At some point you should release the key using \l keyRelease().
     
    453491    \overload
    454492
    455     Simulates pressing a \a key with an optional \a modifier on a \a widget. If \a delay is larger than 0, the test will wait for \a delay milliseconds.
     493    Simulates pressing a \a key with an optional \a modifier on a \a widget.
     494    If \a delay is larger than 0, the test will wait for \a delay milliseconds.
    456495
    457496    \bold {Note:} At some point you should release the key using \l keyRelease().
     
    462501/*! \fn void QTest::keyRelease(QWidget *widget, Qt::Key key, Qt::KeyboardModifiers modifier = Qt::NoModifier, int delay=-1)
    463502
    464     Simulates releasing a \a key with an optional \a modifier on a \a widget. If \a delay is larger than 0, the test will wait for \a delay milliseconds.
     503    Simulates releasing a \a key with an optional \a modifier on a \a widget.
     504    If \a delay is larger than 0, the test will wait for \a delay milliseconds.
    465505
    466506    \sa QTest::keyPress(), QTest::keyClick()
     
    471511    \overload
    472512
    473     Simulates releasing a \a key with an optional \a modifier on a \a widget. If \a delay is larger than 0, the test will wait for \a delay milliseconds.
     513    Simulates releasing a \a key with an optional \a modifier on a \a widget.
     514    If \a delay is larger than 0, the test will wait for \a delay milliseconds.
    474515
    475516    \sa QTest::keyClick()
     
    673714*/
    674715
     716/*!
     717    \fn char *QTest::toString(const QVariant &variant)
     718    \overload
     719
     720    Returns a textual representation of the given \a variant.
     721*/
     722
    675723/*! \fn void QTest::qWait(int ms)
    676724
     
    687735*/
    688736
     737/*! \fn bool QTest::qWaitForWindowShown(QWidget *window)
     738    \since 4.6
     739
     740    Waits until the \a window is shown in the screen. This is mainly useful for
     741    asynchronous systems like X11, where a window will be mapped to screen some
     742    time after being asked to show itself on the screen. Returns true.
     743
     744    Example:
     745    \snippet doc/src/snippets/code/src_qtestlib_qtestcase.cpp 24
     746*/
     747
     748/*!
     749    \class QTest::QTouchEventSequence
     750    \inmodule QtTest
     751    \since 4.6
     752
     753    \brief The QTouchEventSequence class is used to simulate a sequence of touch events.
     754
     755    To simulate a sequence of touch events on a specific device for a widget, call
     756    QTest::touchEvent to create a QTouchEventSequence instance. Add touch events to
     757    the sequence by calling press(), move(), release() and stationary(), and let the
     758    instance run out of scope to commit the sequence to the event system.
     759*/
     760
     761/*!
     762    \fn QTest::QTouchEventSequence::~QTouchEventSequence()
     763
     764    Commits this sequence of touch events and frees allocated resources.
     765*/
     766
     767/*!
     768    \fn QTouchEventSequence &QTest::QTouchEventSequence::press(int touchId, const QPoint &pt, QWidget *widget)
     769
     770    Adds a press event for touchpoint \a touchId at position \a pt to this sequence and returns
     771    a reference to this QTouchEventSequence.
     772
     773    The position \a pt is interpreted as relative to \a widget. If \a widget is the null pointer, then
     774    \a pt is interpreted as relative to the widget provided when instantiating this QTouchEventSequence.
     775
     776    Simulates that the user pressed the touch screen or pad with the finger identified by \a touchId.
     777*/
     778
     779/*!
     780    \fn QTouchEventSequence &QTest::QTouchEventSequence::move(int touchId, const QPoint &pt, QWidget *widget)
     781
     782    Adds a move event for touchpoint \a touchId at position \a pt to this sequence and returns
     783    a reference to this QTouchEventSequence.
     784
     785    The position \a pt is interpreted as relative to \a widget. If \a widget is the null pointer, then
     786    \a pt is interpreted as relative to the widget provided when instantiating this QTouchEventSequence.
     787
     788    Simulates that the user moved the finger identified by \a touchId.
     789*/
     790
     791/*!
     792    \fn QTouchEventSequence &QTest::QTouchEventSequence::release(int touchId, const QPoint &pt, QWidget *widget)
     793
     794    Adds a release event for touchpoint \a touchId at position \a pt to this sequence and returns
     795    a reference to this QTouchEventSequence.
     796
     797    The position \a pt is interpreted as relative to \a widget. If \a widget is the null pointer, then
     798    \a pt is interpreted as relative to the widget provided when instantiating this QTouchEventSequence.
     799
     800    Simulates that the user lifted the finger identified by \a touchId.
     801*/
     802
     803/*!
     804    \fn QTouchEventSequence &QTest::QTouchEventSequence::stationary(int touchId)
     805
     806    Adds a stationary event for touchpoint \a touchId to this sequence and returns
     807    a reference to this QTouchEventSequence.
     808
     809    Simulates that the user did not move the finger identified by \a touchId.
     810*/
     811
     812/*!
     813    \fn QTouchEventSequence QTest::touchEvent(QWidget *widget, QTouchEvent::DeviceType deviceType)
     814
     815    Creates and returns a QTouchEventSequence for the device \a deviceType to
     816    simulate events for \a widget.
     817
     818    When adding touch events to the sequence, \a widget will also be used to translate
     819    the position provided to screen coordinates, unless another widget is provided in the
     820    respective calls to press(), move() etc.
     821
     822    The touch events are committed to the event system when the destructor of the
     823    QTouchEventSequence is called (ie when the object returned runs out of scope).
     824*/
     825
    689826namespace QTest
    690827{
    691828    static QObject *currentTestObject = 0;
    692829
    693     struct TestFunction {
     830    static struct TestFunction {
    694831        TestFunction():function(0), data(0) {}
    695832        ~TestFunction() { delete [] data; }
    696833        int function;
    697834        char *data;
    698     } testFuncs[512];
     835    } *testFuncs;
    699836
    700837    /**
     
    711848    static int keyVerbose = -1;
    712849
    713 /*! \internal
    714  */
    715 int qt_snprintf(char *str, int size, const char *format, ...)
    716 {
    717     va_list ap;
    718     int res = 0;
    719 
    720     va_start(ap, format);
    721     qvsnprintf(str, size, format, ap);
    722     va_end(ap);
    723     str[size - 1] = '\0';
    724 
     850void filter_unprintable(char *str)
     851{
    725852    char *idx = str;
    726853    while (*idx) {
     
    729856        ++idx;
    730857    }
     858}
     859
     860/*! \internal
     861 */
     862int qt_snprintf(char *str, int size, const char *format, ...)
     863{
     864    va_list ap;
     865    int res = 0;
     866
     867    va_start(ap, format);
     868    qvsnprintf(str, size, format, ap);
     869    va_end(ap);
     870    str[size - 1] = '\0';
     871
     872    filter_unprintable(str);
     873
    731874    return res;
    732875}
     
    819962         " options:\n"
    820963         " -functions : Returns a list of current testfunctions\n"
     964         " -xunitxml  : Outputs results as XML XUnit document\n"
    821965         " -xml       : Outputs results as XML document\n"
    822966         " -lightxml  : Outputs results as stream of XML tags\n"
     967         " -flush     : Flushes the resutls\n"
    823968         " -o filename: Writes all output into a file\n"
    824969         " -silent    : Only outputs warnings and failures\n"
     
    845990        " -median  n      : Sets the number of median iterations.\n"
    846991        " -vb             : Print out verbose benchmarking information.\n"
    847 #ifndef QT_NO_PROCESS
    848 // Will be enabled when tools are integrated.   
    849 //        " -chart          : Runs the chart generator after the test. No output is printed to the console\n"
     992#if !defined(QT_NO_PROCESS) && !defined(QT_NO_SETTINGS)
     993        " -chart          : Create chart based on the benchmark result.\n"
    850994#endif
    851995         "\n"
     
    8621006            qPrintTestSlots();
    8631007            exit(0);
     1008        } else if(strcmp(argv[i], "-xunitxml") == 0){
     1009            QTestLog::setLogMode(QTestLog::XunitXML);
    8641010        } else if (strcmp(argv[i], "-xml") == 0) {
    8651011            QTestLog::setLogMode(QTestLog::XML);
    8661012        } else if (strcmp(argv[i], "-lightxml") == 0) {
    8671013            QTestLog::setLogMode(QTestLog::LightXML);
     1014        }else if(strcmp(argv[i], "-flush") == 0){
     1015            QTestLog::setFlushMode(QTestLog::FLushOn);
    8681016        } else if (strcmp(argv[i], "-silent") == 0) {
    8691017            QTestLog::setVerboseLevel(-1);
     
    9581106        } else if (strcmp(argv[i], "-vb") == 0) {
    9591107            QBenchmarkGlobalData::current->verboseOutput = true;
    960 #ifndef QT_NO_PROCESS
     1108#if !defined(QT_NO_PROCESS) && !defined(QT_NO_SETTINGS)
    9611109        } else if (strcmp(argv[i], "-chart") == 0) {
    9621110            QBenchmarkGlobalData::current->createChart = true;
     
    9921140            }
    9931141            ++QTest::lastTestFuncIdx;
     1142            if (!QTest::testFuncs) {
     1143                struct Cleanup { ~Cleanup() { delete[] QTest::testFuncs; } };
     1144                static Cleanup cleanup;
     1145                QTest::testFuncs = new TestFunction[512];
     1146            }
    9941147            QTest::testFuncs[QTest::lastTestFuncIdx].function = idx;
    9951148            QTest::testFuncs[QTest::lastTestFuncIdx].data = data;
     
    10071160    if (count == 1)
    10081161        return container.at(0);
    1009    
     1162
    10101163    QList<QBenchmarkResult> containerCopy = container;
    10111164    qSort(containerCopy);
     
    10571210                    ? QTestResult::currentDataTag() : "");
    10581211
    1059             invokeOk = QMetaObject::invokeMethod(QTest::currentTestObject, slot, 
     1212            invokeOk = QMetaObject::invokeMethod(QTest::currentTestObject, slot,
    10601213                                                 Qt::DirectConnection);
    10611214            if (!invokeOk)
     
    10781231            results.append(QBenchmarkTestMethodData::current->result);
    10791232
    1080         if (QBenchmarkTestMethodData::current->isBenchmark() && 
     1233        if (QBenchmarkTestMethodData::current->isBenchmark() &&
    10811234            QBenchmarkGlobalData::current->verboseOutput) {
    10821235                if (i == -1) {
     
    12091362/*!
    12101363  \fn char* QTest::toHexRepresentation(const char *ba, int length)
    1211  
     1364
    12121365  Returns a pointer to a string that is the string \a ba represented
    12131366  as a space-separated sequence of hex characters. If the input is
     
    12151368  the returned string as an ellipsis at the end.
    12161369
    1217   \a length is the length of the string \a ba. 
     1370  \a length is the length of the string \a ba.
    12181371 */
    12191372char *toHexRepresentation(const char *ba, int length)
     
    12741427}
    12751428
    1276 static void qInvokeTestMethods(QObject *testObject)
    1277 {
    1278     const QMetaObject *metaObject = testObject->metaObject();
    1279     QTEST_ASSERT(metaObject);
    1280  
    1281     QTestLog::startLogging();
    1282  
    1283     QTestResult::setCurrentTestFunction("initTestCase");
    1284     QTestResult::setCurrentTestLocation(QTestResult::DataFunc);
    1285     QTestTable::globalTestTable();
    1286     QMetaObject::invokeMethod(testObject, "initTestCase_data", Qt::DirectConnection);
    1287  
    1288     if (!QTestResult::skipCurrentTest() && !QTest::currentTestFailed()) {
    1289         QTestResult::setCurrentTestLocation(QTestResult::InitFunc);
    1290         QMetaObject::invokeMethod(testObject, "initTestCase");
    1291  
    1292         // finishedCurrentTestFunction() resets QTestResult::testFailed(), so use a local copy.
    1293         const bool previousFailed = QTestResult::testFailed();
    1294         QTestResult::finishedCurrentTestFunction();
    1295  
    1296         if(!QTestResult::skipCurrentTest() && !previousFailed) {
    1297  
    1298             if (lastTestFuncIdx >= 0) {
    1299                 for (int i = 0; i <= lastTestFuncIdx; ++i) {
    1300                     if (!qInvokeTestMethod(metaObject->method(testFuncs[i].function).signature(),
    1301                                            testFuncs[i].data))
    1302                         break;
    1303                 }
    1304             } else {
    1305                 int methodCount = metaObject->methodCount();
    1306                 for (int i = 0; i < methodCount; ++i) {
    1307                     QMetaMethod slotMethod = metaObject->method(i);
    1308                     if (!isValidSlot(slotMethod))
    1309                         continue;
    1310                     if (!qInvokeTestMethod(slotMethod.signature()))
    1311                         break;
    1312                 }
    1313             }
    1314         }
    1315  
    1316         QTestResult::setSkipCurrentTest(false);
    1317         QTestResult::setCurrentTestFunction("cleanupTestCase");
    1318         QMetaObject::invokeMethod(testObject, "cleanupTestCase");
    1319     }
    1320     QTestResult::finishedCurrentTestFunction();
    1321     QTestResult::setCurrentTestFunction(0);
    1322     QTestTable::clearGlobalTestTable();
    1323  
    1324     QTestLog::stopLogging();
    1325 }
     1429static void qInvokeTestMethods(QObject *testObject)
     1430{
     1431    const QMetaObject *metaObject = testObject->metaObject();
     1432    QTEST_ASSERT(metaObject);
     1433
     1434    QTestLog::startLogging();
     1435
     1436    QTestResult::setCurrentTestFunction("initTestCase");
     1437    QTestResult::setCurrentTestLocation(QTestResult::DataFunc);
     1438    QTestTable::globalTestTable();
     1439    QMetaObject::invokeMethod(testObject, "initTestCase_data", Qt::DirectConnection);
     1440
     1441    if (!QTestResult::skipCurrentTest() && !QTest::currentTestFailed()) {
     1442        QTestResult::setCurrentTestLocation(QTestResult::InitFunc);
     1443        QMetaObject::invokeMethod(testObject, "initTestCase");
     1444
     1445        // finishedCurrentTestFunction() resets QTestResult::testFailed(), so use a local copy.
     1446        const bool previousFailed = QTestResult::testFailed();
     1447        QTestResult::finishedCurrentTestFunction();
     1448
     1449        if(!QTestResult::skipCurrentTest() && !previousFailed) {
     1450
     1451            if (lastTestFuncIdx >= 0) {
     1452                for (int i = 0; i <= lastTestFuncIdx; ++i) {
     1453                    if (!qInvokeTestMethod(metaObject->method(testFuncs[i].function).signature(),
     1454                                           testFuncs[i].data))
     1455                        break;
     1456                }
     1457            } else {
     1458                int methodCount = metaObject->methodCount();
     1459                for (int i = 0; i < methodCount; ++i) {
     1460                    QMetaMethod slotMethod = metaObject->method(i);
     1461                    if (!isValidSlot(slotMethod))
     1462                        continue;
     1463                    if (!qInvokeTestMethod(slotMethod.signature()))
     1464                        break;
     1465                }
     1466            }
     1467        }
     1468
     1469        QTestResult::setSkipCurrentTest(false);
     1470        QTestResult::setCurrentTestFunction("cleanupTestCase");
     1471        QMetaObject::invokeMethod(testObject, "cleanupTestCase");
     1472    }
     1473    QTestResult::finishedCurrentTestFunction();
     1474    QTestResult::setCurrentTestFunction(0);
     1475    QTestTable::clearGlobalTestTable();
     1476
     1477    QTestLog::stopLogging();
     1478}
     1479
     1480#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN)
     1481class FatalSignalHandler
     1482{
     1483public:
     1484    FatalSignalHandler();
     1485    ~FatalSignalHandler();
     1486
     1487private:
     1488    static void signal(int);
     1489    sigset_t handledSignals;
     1490};
     1491
     1492void FatalSignalHandler::signal(int signum)
     1493{
     1494    qFatal("Received signal %d", signum);
     1495}
     1496
     1497FatalSignalHandler::FatalSignalHandler()
     1498{
     1499    sigemptyset(&handledSignals);
     1500
     1501    const int fatalSignals[] = {
     1502         SIGHUP, SIGINT, SIGQUIT, SIGILL, SIGFPE, SIGSEGV, SIGPIPE, SIGTERM, 0 };
     1503
     1504    struct sigaction act;
     1505    memset(&act, 0, sizeof(act));
     1506    act.sa_handler = FatalSignalHandler::signal;
     1507
     1508    // Remove the handler after it is invoked.
     1509    act.sa_flags = SA_RESETHAND;
     1510
     1511    // Block all fatal signals in our signal handler so we don't try to close
     1512    // the testlog twice.
     1513    sigemptyset(&act.sa_mask);
     1514    for (int i = 0; fatalSignals[i]; ++i)
     1515        sigaddset(&act.sa_mask, fatalSignals[i]);
     1516
     1517    struct sigaction oldact;
     1518
     1519    for (int i = 0; fatalSignals[i]; ++i) {
     1520        sigaction(fatalSignals[i], &act, &oldact);
     1521#ifndef Q_WS_QWS
     1522        // Don't overwrite any non-default handlers
     1523        // however, we need to replace the default QWS handlers
     1524        if (oldact.sa_flags & SA_SIGINFO || oldact.sa_handler != SIG_DFL) {
     1525            sigaction(fatalSignals[i], &oldact, 0);
     1526        } else
     1527#endif
     1528        {
     1529            sigaddset(&handledSignals, fatalSignals[i]);
     1530        }
     1531    }
     1532}
     1533
     1534
     1535FatalSignalHandler::~FatalSignalHandler()
     1536{
     1537    // Unregister any of our remaining signal handlers
     1538    struct sigaction act;
     1539    memset(&act, 0, sizeof(act));
     1540    act.sa_handler = SIG_DFL;
     1541
     1542    struct sigaction oldact;
     1543
     1544    for (int i = 1; i < 32; ++i) {
     1545        if (!sigismember(&handledSignals, i))
     1546            continue;
     1547        sigaction(i, &act, &oldact);
     1548
     1549        // If someone overwrote it in the mean time, put it back
     1550        if (oldact.sa_handler != FatalSignalHandler::signal)
     1551            sigaction(i, &oldact, 0);
     1552    }
     1553}
     1554
     1555#endif
     1556
    13261557
    13271558} // namespace
     
    14001631#endif
    14011632
     1633#if defined(Q_OS_SYMBIAN) && defined(Q_CC_NOKIAX86)
     1634    // Delay execution of tests in Symbian emulator.
     1635    // Needed to allow worst of other higher priority apps and services launched by emulator
     1636    // to get out of the way before we run our test. Otherwise some of the timing sensitive tests
     1637    // will not work properly.
     1638    qSleep(3000);
     1639#endif
     1640
    14021641    QTestResult::reset();
    14031642
     
    14191658        QBenchmarkValgrindUtils::cleanup();
    14201659
    1421     } else {
    1422 #endif
    1423 
     1660    } else
     1661#endif
     1662    {
     1663#if defined(Q_OS_UNIX) && !defined(Q_OS_SYMBIAN)
     1664        FatalSignalHandler handler;
     1665#endif
    14241666        qInvokeTestMethods(testObject);
    1425 
    1426 #ifdef QTESTLIB_USE_VALGRIND
    14271667    }
    1428 #endif
    1429 
    1430  #ifndef QT_NO_EXCEPTIONS
     1668
     1669#ifndef QT_NO_EXCEPTIONS
    14311670     } catch (...) {
    14321671         QTestResult::addFailure("Caught unhandled exception", __FILE__, __LINE__);
     
    14421681         }
    14431682#endif
    1444  #ifdef Q_OS_WIN
    1445          // rethrow exception to make debugging easier
     1683         // Rethrow exception to make debugging easier.
    14461684         throw;
    1447  #endif
    1448          return -1;
     1685         return 1;
    14491686     }
    1450  #endif
     1687endif
    14511688
    14521689    currentTestObject = 0;
     
    14581695
    14591696
    1460 #ifndef QT_NO_PROCESS
     1697#if !defined(QT_NO_PROCESS) && !defined(QT_NO_SETTINGS)
    14611698    if (QBenchmarkGlobalData::current->createChart) {
    1462 
    1463 #define XSTR(s) STR(s)
    1464 #define STR(s) #s
     1699        QString chartLocation = QLibraryInfo::location(QLibraryInfo::BinariesPath);
    14651700#ifdef Q_OS_WIN
    1466     const char * path = XSTR(QBENCHLIB_BASE) "/tools/generatereport/generatereport.exe";
     1701        chartLocation += QLatin1String("/../tools/qtestlib/chart/release/chart.exe");
    14671702#else
    1468     const char * path = XSTR(QBENCHLIB_BASE) "/tools/generatereport/generatereport";
    1469 #endif
    1470 #undef XSTR
    1471 #undef STR
    1472 
    1473         if (QFile::exists(QLatin1String(path))) {
     1703        chartLocation += QLatin1String("/../tools/qtestlib/chart/chart");
     1704#endif
     1705        if (QFile::exists(chartLocation)) {
    14741706            QProcess p;
    14751707            p.setProcessChannelMode(QProcess::ForwardedChannels);
    1476             p.start(QLatin1String(path), QStringList() << QLatin1String("results.xml"));
     1708            p.start(chartLocation, QStringList() << QLatin1String("results.xml"));
    14771709            p.waitForFinished(-1);
    14781710        } else {
    1479             qWarning("Could not find %s, please make sure it is compiled.", path);
     1711            qDebug() << QLatin1String("Could not find the chart tool in ") + chartLocation + QLatin1String(", please make sure it is compiled.");
    14801712        }
    14811713    }
    14821714#endif
    14831715
    1484 #if defined(QTEST_NOEXITCODE) || (defined(QT_BUILD_INTERNAL) && !defined(QTEST_FORCE_EXITCODE))
     1716#if defined(QTEST_NOEXITCODE)
    14851717    return 0;
    14861718#else
     
    17561988 */
    17571989template <>
    1758 bool QTest::qCompare<float>(float const &t1, float const &t2, const char *actual, const char *expected,
     1990Q_TESTLIB_EXPORT bool QTest::qCompare<float>(float const &t1, float const &t2, const char *actual, const char *expected,
    17591991                    const char *file, int line)
    17601992{
     
    17692001 */
    17702002template <>
    1771 bool QTest::qCompare<double>(double const &t1, double const &t2, const char *actual, const char *expected,
     2003Q_TESTLIB_EXPORT bool QTest::qCompare<double>(double const &t1, double const &t2, const char *actual, const char *expected,
    17722004                    const char *file, int line)
    17732005{
     
    17792011
    17802012#define COMPARE_IMPL2(TYPE, FORMAT) \
    1781 template <> char *QTest::toString<TYPE >(const TYPE &t) \
     2013template <> Q_TESTLIB_EXPORT char *QTest::toString<TYPE >(const TYPE &t) \
    17822014{ \
    17832015    char *msg = new char[128]; \
     
    18012033COMPARE_IMPL2(bool, %d)
    18022034COMPARE_IMPL2(char, %c)
    1803 COMPARE_IMPL2(float, %g);
    1804 COMPARE_IMPL2(double, %lg);
     2035COMPARE_IMPL2(float, %g)
     2036COMPARE_IMPL2(double, %lg)
    18052037
    18062038/*! \internal
     
    19112143*/
    19122144
     2145/*! \fn bool QTest::qCompare(bool const &t1, int const &t2, const char *actual, const char *expected, const char *file, int line)
     2146  \internal
     2147 */
     2148
    19132149/*! \fn bool QTest::qTest(const T& actual, const char *elementName, const char *actualStr, const char *expected, const char *file, int line)
    19142150    \internal
     
    19272163*/
    19282164
    1929 /*! \fn int QTest::qt_snprintf(char *str, int size, const char *format, ...)
    1930     \internal
    1931 */
    1932 
    19332165QT_END_NAMESPACE
Note: See TracChangeset for help on using the changeset viewer.