diff options
author | Yann Bodson <yann.bodson@nokia.com> | 2010-09-10 07:33:23 (GMT) |
---|---|---|
committer | Yann Bodson <yann.bodson@nokia.com> | 2010-09-10 07:33:23 (GMT) |
commit | 003d09ab22f4d53995efc2d390c451e60afbe8c9 (patch) | |
tree | 3d19e4959d0b035a2e2ec5e63c0b41a278c958df /tests/auto | |
parent | 4c62387c530787b0db8b159b8a535401a5bb7310 (diff) | |
download | Qt-003d09ab22f4d53995efc2d390c451e60afbe8c9.zip Qt-003d09ab22f4d53995efc2d390c451e60afbe8c9.tar.gz Qt-003d09ab22f4d53995efc2d390c451e60afbe8c9.tar.bz2 |
Autotests cleanup.
Diffstat (limited to 'tests/auto')
6 files changed, 52 insertions, 107 deletions
diff --git a/tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp b/tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp index 1001278..da15a85 100644 --- a/tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp +++ b/tests/auto/declarative/qdeclarativeanimatedimage/tst_qdeclarativeanimatedimage.cpp @@ -47,22 +47,13 @@ #include <private/qdeclarativeanimatedimage_p.h> #include "../shared/testhttpserver.h" +#include "../../../shared/util.h" #ifdef Q_OS_SYMBIAN // In Symbian OS test data is located in applications private dir #define SRCDIR "." #endif -#define TRY_WAIT(expr) \ - do { \ - for (int ii = 0; ii < 6; ++ii) { \ - if ((expr)) break; \ - QTest::qWait(50); \ - } \ - QVERIFY((expr)); \ - } while (false) - - class tst_qdeclarativeanimatedimage : public QObject { Q_OBJECT @@ -152,14 +143,14 @@ void tst_qdeclarativeanimatedimage::remote() QDeclarativeEngine engine; QDeclarativeComponent component(&engine, QUrl("http://127.0.0.1:14449/" + fileName)); - TRY_WAIT(component.isReady()); + QTRY_VERIFY(component.isReady()); QDeclarativeAnimatedImage *anim = qobject_cast<QDeclarativeAnimatedImage *>(component.create()); QVERIFY(anim); - TRY_WAIT(anim->isPlaying()); + QTRY_VERIFY(anim->isPlaying()); if (paused) { - TRY_WAIT(anim->isPaused()); + QTRY_VERIFY(anim->isPaused()); QCOMPARE(anim->currentFrame(), 2); } QVERIFY(anim->status() != QDeclarativeAnimatedImage::Error); diff --git a/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp b/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp index 1b73cf7..c77d395 100644 --- a/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp +++ b/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp @@ -53,6 +53,7 @@ #include <QtDeclarative/qdeclarativecontext.h> #include "../shared/testhttpserver.h" +#include "../../../shared/util.h" #ifdef Q_OS_SYMBIAN // In Symbian OS test data is located in applications private dir @@ -62,16 +63,6 @@ #define SERVER_PORT 14446 #define SERVER_ADDR "http://127.0.0.1:14446" -#define TRY_WAIT(expr) \ - do { \ - for (int ii = 0; ii < 60; ++ii) { \ - if ((expr)) break; \ - QTest::qWait(50); \ - } \ - QVERIFY((expr)); \ - } while (false) - - class tst_qdeclarativeborderimage : public QObject { @@ -154,18 +145,18 @@ void tst_qdeclarativeborderimage::imageSource() QVERIFY(obj != 0); if (remote) - TRY_WAIT(obj->status() == QDeclarativeBorderImage::Loading); + QTRY_VERIFY(obj->status() == QDeclarativeBorderImage::Loading); QCOMPARE(obj->source(), remote ? source : QUrl(source)); if (error.isEmpty()) { - TRY_WAIT(obj->status() == QDeclarativeBorderImage::Ready); + QTRY_VERIFY(obj->status() == QDeclarativeBorderImage::Ready); QCOMPARE(obj->width(), 120.); QCOMPARE(obj->height(), 120.); QCOMPARE(obj->horizontalTileMode(), QDeclarativeBorderImage::Stretch); QCOMPARE(obj->verticalTileMode(), QDeclarativeBorderImage::Stretch); } else { - TRY_WAIT(obj->status() == QDeclarativeBorderImage::Error); + QTRY_VERIFY(obj->status() == QDeclarativeBorderImage::Error); } delete obj; @@ -273,14 +264,14 @@ void tst_qdeclarativeborderimage::sciSource() QVERIFY(obj != 0); if (remote) - TRY_WAIT(obj->status() == QDeclarativeBorderImage::Loading); + QTRY_VERIFY(obj->status() == QDeclarativeBorderImage::Loading); QCOMPARE(obj->source(), remote ? source : QUrl(source)); QCOMPARE(obj->width(), 300.); QCOMPARE(obj->height(), 300.); if (valid) { - TRY_WAIT(obj->status() == QDeclarativeBorderImage::Ready); + QTRY_VERIFY(obj->status() == QDeclarativeBorderImage::Ready); QCOMPARE(obj->border()->left(), 10); QCOMPARE(obj->border()->top(), 20); QCOMPARE(obj->border()->right(), 30); @@ -288,7 +279,7 @@ void tst_qdeclarativeborderimage::sciSource() QCOMPARE(obj->horizontalTileMode(), QDeclarativeBorderImage::Round); QCOMPARE(obj->verticalTileMode(), QDeclarativeBorderImage::Repeat); } else { - TRY_WAIT(obj->status() == QDeclarativeBorderImage::Error); + QTRY_VERIFY(obj->status() == QDeclarativeBorderImage::Error); } delete obj; diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index 33bf7ea..c10a110 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -52,6 +52,7 @@ #include <private/qdeclarativeglobalscriptclass_p.h> #include "testtypes.h" #include "testhttpserver.h" +#include "../../../shared/util.h" #ifdef Q_OS_SYMBIAN // In Symbian OS test data is located in applications private dir @@ -2416,15 +2417,6 @@ void tst_qdeclarativeecmascript::function() delete o; } -#define TRY_WAIT(expr) \ - do { \ - for (int ii = 0; ii < 6; ++ii) { \ - if ((expr)) break; \ - QTest::qWait(50); \ - } \ - QVERIFY((expr)); \ - } while (false) - // Test the "Qt.include" method void tst_qdeclarativeecmascript::include() { @@ -2496,8 +2488,8 @@ void tst_qdeclarativeecmascript::include() QObject *o = component.create(); QVERIFY(o != 0); - TRY_WAIT(o->property("done").toBool() == true); - TRY_WAIT(o->property("done2").toBool() == true); + QTRY_VERIFY(o->property("done").toBool() == true); + QTRY_VERIFY(o->property("done2").toBool() == true); QCOMPARE(o->property("test1").toBool(), true); QCOMPARE(o->property("test2").toBool(), true); @@ -2524,7 +2516,7 @@ void tst_qdeclarativeecmascript::include() QObject *o = component.create(); QVERIFY(o != 0); - TRY_WAIT(o->property("done").toBool() == true); + QTRY_VERIFY(o->property("done").toBool() == true); QCOMPARE(o->property("test1").toBool(), true); QCOMPARE(o->property("test2").toBool(), true); diff --git a/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp b/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp index d0afc8a..d38160d 100644 --- a/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp +++ b/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp @@ -45,26 +45,15 @@ #include <private/qdeclarativeimage_p.h> #include <QImageReader> #include <QWaitCondition> +#include "../../../shared/util.h" #ifdef Q_OS_SYMBIAN // In Symbian OS test data is located in applications private dir #define SRCDIR "." #endif -// QDeclarativeImageProvider::request() is run in an idle thread where possible -// Be generous in our timeout. -#define TRY_WAIT(expr) \ - do { \ - for (int ii = 0; ii < 10; ++ii) { \ - if ((expr)) break; \ - QTest::qWait(100); \ - } \ - QVERIFY((expr)); \ - } while (false) - Q_DECLARE_METATYPE(QDeclarativeImageProvider*); - class tst_qdeclarativeimageprovider : public QObject { Q_OBJECT @@ -212,13 +201,13 @@ void tst_qdeclarativeimageprovider::runTest(bool async, QDeclarativeImageProvide QVERIFY(obj != 0); if (async) - TRY_WAIT(obj->status() == QDeclarativeImage::Loading); + QTRY_VERIFY(obj->status() == QDeclarativeImage::Loading); QCOMPARE(obj->source(), QUrl(source)); if (error.isEmpty()) { if (async) - TRY_WAIT(obj->status() == QDeclarativeImage::Ready); + QTRY_VERIFY(obj->status() == QDeclarativeImage::Ready); else QVERIFY(obj->status() == QDeclarativeImage::Ready); QCOMPARE(obj->width(), qreal(size.width())); @@ -229,7 +218,7 @@ void tst_qdeclarativeimageprovider::runTest(bool async, QDeclarativeImageProvide QCOMPARE(obj->progress(), 1.0); } else { if (async) - TRY_WAIT(obj->status() == QDeclarativeImage::Error); + QTRY_VERIFY(obj->status() == QDeclarativeImage::Error); else QVERIFY(obj->status() == QDeclarativeImage::Error); } @@ -391,7 +380,7 @@ void tst_qdeclarativeimageprovider::threadTest() provider->cond.wakeAll(); QTest::qWait(250); foreach(QDeclarativeImage *img, images) { - TRY_WAIT(img->status() == QDeclarativeImage::Ready); + QTRY_VERIFY(img->status() == QDeclarativeImage::Ready); } } diff --git a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp index 3baf848..b62392d 100644 --- a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp +++ b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp @@ -61,15 +61,6 @@ inline QUrl TEST_FILE(const QString &filename) return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename); } -#define TRY_WAIT(expr) \ - do { \ - for (int ii = 0; ii < 6; ++ii) { \ - if ((expr)) break; \ - QTest::qWait(50); \ - } \ - QVERIFY((expr)); \ - } while (false) - class tst_QDeclarativeLoader : public QObject { @@ -460,7 +451,7 @@ void tst_QDeclarativeLoader::networkRequestUrl() QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create()); QVERIFY(loader != 0); - TRY_WAIT(loader->status() == QDeclarativeLoader::Ready); + QTRY_VERIFY(loader->status() == QDeclarativeLoader::Ready); QVERIFY(loader->item()); QCOMPARE(loader->progress(), 1.0); @@ -491,7 +482,7 @@ void tst_QDeclarativeLoader::networkComponent() QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(item->QGraphicsObject::children().at(1)); QVERIFY(loader); - TRY_WAIT(loader->status() == QDeclarativeLoader::Ready); + QTRY_VERIFY(loader->status() == QDeclarativeLoader::Ready); QVERIFY(loader->item()); QCOMPARE(loader->progress(), 1.0); @@ -515,7 +506,7 @@ void tst_QDeclarativeLoader::failNetworkRequest() QDeclarativeLoader *loader = qobject_cast<QDeclarativeLoader*>(component.create()); QVERIFY(loader != 0); - TRY_WAIT(loader->status() == QDeclarativeLoader::Error); + QTRY_VERIFY(loader->status() == QDeclarativeLoader::Error); QVERIFY(loader->item() == 0); QCOMPARE(loader->progress(), 0.0); diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp b/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp index ecce349..89252fb 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp @@ -45,6 +45,7 @@ #include <QDebug> #include <QNetworkCookieJar> #include "testhttpserver.h" +#include "../../../shared/util.h" #define SERVER_PORT 14445 @@ -156,16 +157,6 @@ void tst_qdeclarativexmlhttprequest::domExceptionCodes() delete object; } -#define TRY_WAIT(expr) \ - do { \ - for (int ii = 0; ii < 6; ++ii) { \ - if ((expr)) break; \ - QTest::qWait(50); \ - } \ - QVERIFY((expr)); \ - } while (false) - - void tst_qdeclarativexmlhttprequest::callbackException_data() { QTest::addColumn<QString>("which"); @@ -193,7 +184,7 @@ void tst_qdeclarativexmlhttprequest::callbackException() object->setProperty("which", which); component.completeCreate(); - TRY_WAIT(object->property("threw").toBool() == true); + QTRY_VERIFY(object->property("threw").toBool() == true); delete object; } @@ -289,7 +280,7 @@ void tst_qdeclarativexmlhttprequest::open() QCOMPARE(object->property("responseText").toBool(), true); QCOMPARE(object->property("responseXML").toBool(), true); - TRY_WAIT(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool() == true); delete server; delete object; @@ -372,7 +363,7 @@ void tst_qdeclarativexmlhttprequest::setRequestHeader() object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); component.completeCreate(); - TRY_WAIT(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool() == true); delete object; } @@ -442,7 +433,7 @@ void tst_qdeclarativexmlhttprequest::setRequestHeader_illegalName() QCOMPARE(object->property("responseText").toBool(), true); QCOMPARE(object->property("responseXML").toBool(), true); - TRY_WAIT(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool() == true); delete object; } @@ -464,7 +455,7 @@ void tst_qdeclarativexmlhttprequest::setRequestHeader_sent() QCOMPARE(object->property("test").toBool(), true); - TRY_WAIT(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool() == true); delete object; } @@ -501,7 +492,7 @@ void tst_qdeclarativexmlhttprequest::send_alreadySent() QVERIFY(object != 0); QCOMPARE(object->property("test").toBool(), true); - TRY_WAIT(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool() == true); delete object; } @@ -523,7 +514,7 @@ void tst_qdeclarativexmlhttprequest::send_ignoreData() object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); component.completeCreate(); - TRY_WAIT(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool() == true); delete object; } @@ -542,7 +533,7 @@ void tst_qdeclarativexmlhttprequest::send_ignoreData() object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); component.completeCreate(); - TRY_WAIT(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool() == true); delete object; } @@ -566,7 +557,7 @@ void tst_qdeclarativexmlhttprequest::send_withdata() object->setProperty("url", "http://127.0.0.1:14445/testdocument.html"); component.completeCreate(); - TRY_WAIT(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool() == true); delete object; } @@ -601,7 +592,7 @@ void tst_qdeclarativexmlhttprequest::abort_unsent() QCOMPARE(object->property("responseText").toBool(), true); QCOMPARE(object->property("responseXML").toBool(), true); - TRY_WAIT(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool() == true); delete object; } @@ -622,7 +613,7 @@ void tst_qdeclarativexmlhttprequest::abort_opened() QCOMPARE(object->property("responseText").toBool(), true); QCOMPARE(object->property("responseXML").toBool(), true); - TRY_WAIT(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool() == true); delete object; } @@ -647,7 +638,7 @@ void tst_qdeclarativexmlhttprequest::abort() QCOMPARE(object->property("didNotSeeUnsent").toBool(), true); QCOMPARE(object->property("endStateUnsent").toBool(), true); - TRY_WAIT(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool() == true); delete object; } @@ -674,7 +665,7 @@ void tst_qdeclarativexmlhttprequest::getResponseHeader() QCOMPARE(object->property("readyState").toBool(), true); QCOMPARE(object->property("openedState").toBool(), true); - TRY_WAIT(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool() == true); QCOMPARE(object->property("headersReceivedState").toBool(), true); QCOMPARE(object->property("headersReceivedNullHeader").toBool(), true); @@ -722,7 +713,7 @@ void tst_qdeclarativexmlhttprequest::getResponseHeader_args() QObject *object = component.create(); QVERIFY(object != 0); - TRY_WAIT(object->property("exceptionThrown").toBool() == true); + QTRY_VERIFY(object->property("exceptionThrown").toBool() == true); delete object; } @@ -748,7 +739,7 @@ void tst_qdeclarativexmlhttprequest::getAllResponseHeaders() QCOMPARE(object->property("readyState").toBool(), true); QCOMPARE(object->property("openedState").toBool(), true); - TRY_WAIT(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool() == true); QCOMPARE(object->property("headersReceivedState").toBool(), true); QCOMPARE(object->property("headersReceivedHeader").toBool(), true); @@ -790,7 +781,7 @@ void tst_qdeclarativexmlhttprequest::getAllResponseHeaders_args() QObject *object = component.create(); QVERIFY(object != 0); - TRY_WAIT(object->property("exceptionThrown").toBool() == true); + QTRY_VERIFY(object->property("exceptionThrown").toBool() == true); delete object; } @@ -813,7 +804,7 @@ void tst_qdeclarativexmlhttprequest::status() object->setProperty("expectedStatus", status); component.completeCreate(); - TRY_WAIT(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool() == true); QCOMPARE(object->property("unsentException").toBool(), true); QCOMPARE(object->property("openedException").toBool(), true); @@ -853,7 +844,7 @@ void tst_qdeclarativexmlhttprequest::statusText() object->setProperty("expectedStatus", statusText); component.completeCreate(); - TRY_WAIT(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool() == true); QCOMPARE(object->property("unsentException").toBool(), true); QCOMPARE(object->property("openedException").toBool(), true); @@ -894,7 +885,7 @@ void tst_qdeclarativexmlhttprequest::responseText() object->setProperty("expectedText", responseText); component.completeCreate(); - TRY_WAIT(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool() == true); QCOMPARE(object->property("unsent").toBool(), true); QCOMPARE(object->property("opened").toBool(), true); @@ -931,7 +922,7 @@ void tst_qdeclarativexmlhttprequest::nonUtf8() object->setProperty("fileName", fileName); QMetaObject::invokeMethod(object, "startRequest"); - TRY_WAIT(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool() == true); QCOMPARE(object->property("responseText").toString(), responseText); @@ -1000,7 +991,7 @@ void tst_qdeclarativexmlhttprequest::redirects() object->setProperty("expectedText", ""); component.completeCreate(); - TRY_WAIT(object->property("done").toBool() == true); + QTRY_VERIFY(object->property("done").toBool() == true); QCOMPARE(object->property("dataOK").toBool(), true); delete object; @@ -1019,7 +1010,7 @@ void tst_qdeclarativexmlhttprequest::redirects() object->setProperty("expectedText", ""); component.completeCreate(); - TRY_WAIT(object->property("done").toBool() == true); + QTRY_VERIFY(object->property("done").toBool() == true); QCOMPARE(object->property("dataOK").toBool(), true); delete object; @@ -1056,7 +1047,7 @@ void tst_qdeclarativexmlhttprequest::responseXML_invalid() QObject *object = component.create(); QVERIFY(object != 0); - TRY_WAIT(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool() == true); QCOMPARE(object->property("xmlNull").toBool(), true); @@ -1070,7 +1061,7 @@ void tst_qdeclarativexmlhttprequest::document() QObject *object = component.create(); QVERIFY(object != 0); - TRY_WAIT(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool() == true); QCOMPARE(object->property("xmlTest").toBool(), true); @@ -1084,7 +1075,7 @@ void tst_qdeclarativexmlhttprequest::element() QObject *object = component.create(); QVERIFY(object != 0); - TRY_WAIT(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool() == true); QCOMPARE(object->property("xmlTest").toBool(), true); @@ -1098,7 +1089,7 @@ void tst_qdeclarativexmlhttprequest::attr() QObject *object = component.create(); QVERIFY(object != 0); - TRY_WAIT(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool() == true); QCOMPARE(object->property("xmlTest").toBool(), true); @@ -1112,7 +1103,7 @@ void tst_qdeclarativexmlhttprequest::text() QObject *object = component.create(); QVERIFY(object != 0); - TRY_WAIT(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool() == true); QCOMPARE(object->property("xmlTest").toBool(), true); @@ -1126,7 +1117,7 @@ void tst_qdeclarativexmlhttprequest::cdata() QObject *object = component.create(); QVERIFY(object != 0); - TRY_WAIT(object->property("dataOK").toBool() == true); + QTRY_VERIFY(object->property("dataOK").toBool() == true); QCOMPARE(object->property("xmlTest").toBool(), true); |