diff options
author | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2011-12-21 09:06:26 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-12-21 15:35:22 +0100 |
commit | 8249c72213bc7d212c05aa086b3145a5742706a3 (patch) | |
tree | 4a34b97b0d57a05707c65b7328d5ab1bf4254920 /tests/auto/qtquick2/qquickflipable | |
parent | 3c211558f6b571555558bd1fc59774e36a6da710 (diff) |
QDeclarative tests: Introduce base class for data tests.
In tests/auto/shared/util.* replace macros/find functions by
a base class QDeclarativeDataTest with accessors for the
data directory helper functions to create URLs from it.
The class relies on QFINDTESTDATA, which is the standard
way of locating test data. Using the class should reduce
the number of calls to QFileInfo.exists(), etc significantly.
In addition, provide utility functions for messages.
Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
Change-Id: Id2beacb157922ee9412f9e45cf9695cec1f8379a
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Diffstat (limited to 'tests/auto/qtquick2/qquickflipable')
-rw-r--r-- | tests/auto/qtquick2/qquickflipable/qquickflipable.pro | 4 | ||||
-rw-r--r-- | tests/auto/qtquick2/qquickflipable/tst_qquickflipable.cpp | 27 |
2 files changed, 9 insertions, 22 deletions
diff --git a/tests/auto/qtquick2/qquickflipable/qquickflipable.pro b/tests/auto/qtquick2/qquickflipable/qquickflipable.pro index 532c42f79b..d1932fc3d5 100644 --- a/tests/auto/qtquick2/qquickflipable/qquickflipable.pro +++ b/tests/auto/qtquick2/qquickflipable/qquickflipable.pro @@ -2,7 +2,9 @@ CONFIG += testcase TARGET = tst_qquickflipable macx:CONFIG -= app_bundle -SOURCES += tst_qquickflipable.cpp +SOURCES += tst_qquickflipable.cpp \ + ../../shared/util.cpp +HEADERS += ../../shared/util.h testDataFiles.files = data testDataFiles.path = . diff --git a/tests/auto/qtquick2/qquickflipable/tst_qquickflipable.cpp b/tests/auto/qtquick2/qquickflipable/tst_qquickflipable.cpp index a217e26714..5624cf82b6 100644 --- a/tests/auto/qtquick2/qquickflipable/tst_qquickflipable.cpp +++ b/tests/auto/qtquick2/qquickflipable/tst_qquickflipable.cpp @@ -50,15 +50,12 @@ #include <QtOpenGL/QGLShaderProgram> #include "../../shared/util.h" -class tst_qquickflipable : public QObject +class tst_qquickflipable : public QDeclarativeDataTest { Q_OBJECT public: - tst_qquickflipable(); private slots: - void initTestCase(); - void cleanupTestCase(); void create(); void checkFrontAndBack(); void setFrontAndBack(); @@ -71,22 +68,10 @@ private: QDeclarativeEngine engine; }; -tst_qquickflipable::tst_qquickflipable() -{ -} -void tst_qquickflipable::initTestCase() -{ -} - -void tst_qquickflipable::cleanupTestCase() -{ - -} - void tst_qquickflipable::create() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("test-flipable.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("test-flipable.qml")); QQuickFlipable *obj = qobject_cast<QQuickFlipable*>(c.create()); QVERIFY(obj != 0); @@ -96,7 +81,7 @@ void tst_qquickflipable::create() void tst_qquickflipable::checkFrontAndBack() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("test-flipable.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("test-flipable.qml")); QQuickFlipable *obj = qobject_cast<QQuickFlipable*>(c.create()); QVERIFY(obj != 0); @@ -108,7 +93,7 @@ void tst_qquickflipable::checkFrontAndBack() void tst_qquickflipable::setFrontAndBack() { QDeclarativeEngine engine; - QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("test-flipable.qml"))); + QDeclarativeComponent c(&engine, testFileUrl("test-flipable.qml")); QQuickFlipable *obj = qobject_cast<QQuickFlipable*>(c.create()); QVERIFY(obj != 0); @@ -128,7 +113,7 @@ void tst_qquickflipable::setFrontAndBack() void tst_qquickflipable::QTBUG_9161_crash() { QQuickView *canvas = new QQuickView; - canvas->setSource(QUrl::fromLocalFile(TESTDATA("crash.qml"))); + canvas->setSource(testFileUrl("crash.qml")); QQuickItem *root = canvas->rootObject(); QVERIFY(root != 0); canvas->show(); @@ -138,7 +123,7 @@ void tst_qquickflipable::QTBUG_9161_crash() void tst_qquickflipable::QTBUG_8474_qgv_abort() { QQuickView *canvas = new QQuickView; - canvas->setSource(QUrl::fromLocalFile(TESTDATA("flipable-abort.qml"))); + canvas->setSource(testFileUrl("flipable-abort.qml")); QQuickItem *root = canvas->rootObject(); QVERIFY(root != 0); canvas->show(); |