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/declarative/v4 | |
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/declarative/v4')
-rw-r--r-- | tests/auto/declarative/v4/tst_v4.cpp | 31 | ||||
-rw-r--r-- | tests/auto/declarative/v4/v4.pro | 6 |
2 files changed, 15 insertions, 22 deletions
diff --git a/tests/auto/declarative/v4/tst_v4.cpp b/tests/auto/declarative/v4/tst_v4.cpp index 791610d541..46b4488b4d 100644 --- a/tests/auto/declarative/v4/tst_v4.cpp +++ b/tests/auto/declarative/v4/tst_v4.cpp @@ -51,17 +51,7 @@ #include "../../shared/util.h" #include "testtypes.h" -inline QUrl TEST_FILE(const QString &filename) -{ - return QUrl::fromLocalFile(TESTDATA(filename)); -} - -inline QUrl TEST_FILE(const char *filename) -{ - return TEST_FILE(QLatin1String(filename)); -} - -class tst_v4 : public QObject +class tst_v4 : public QDeclarativeDataTest { Q_OBJECT public: @@ -86,6 +76,7 @@ private: void tst_v4::initTestCase() { + QDeclarativeDataTest::initTestCase(); registerTypes(); } @@ -102,7 +93,7 @@ void tst_v4::qtscript() QFETCH(QString, file); QV4Compiler::enableBindingsTest(true); - QDeclarativeComponent component(&engine, TEST_FILE(file)); + QDeclarativeComponent component(&engine, testFileUrl(file)); v4ErrorsMsgCount = 0; QtMsgHandler old = qInstallMsgHandler(v4ErrorsMsgHandler); @@ -132,7 +123,7 @@ void tst_v4::qtscript_data() void tst_v4::unnecessaryReeval() { - QDeclarativeComponent component(&engine, TEST_FILE("unnecessaryReeval.qml")); + QDeclarativeComponent component(&engine, testFileUrl("unnecessaryReeval.qml")); QObject *o = component.create(); QVERIFY(o != 0); @@ -166,7 +157,7 @@ void tst_v4::unnecessaryReeval() void tst_v4::logicalOr() { { - QDeclarativeComponent component(&engine, TEST_FILE("logicalOr.qml")); + QDeclarativeComponent component(&engine, testFileUrl("logicalOr.qml")); QObject *o = component.create(); QVERIFY(o != 0); @@ -179,7 +170,7 @@ void tst_v4::logicalOr() } { - QDeclarativeComponent component(&engine, TEST_FILE("logicalOr.2.qml")); + QDeclarativeComponent component(&engine, testFileUrl("logicalOr.2.qml")); QObject *o = component.create(); QVERIFY(o != 0); @@ -195,7 +186,7 @@ void tst_v4::logicalOr() void tst_v4::conditionalExpr() { { - QDeclarativeComponent component(&engine, TEST_FILE("conditionalExpr.qml")); + QDeclarativeComponent component(&engine, testFileUrl("conditionalExpr.qml")); QObject *o = component.create(); QVERIFY(o != 0); @@ -213,7 +204,7 @@ void tst_v4::conditionalExpr() // NestedObject::result. void tst_v4::nestedObjectAccess() { - QDeclarativeComponent component(&engine, TEST_FILE("nestedObjectAccess.qml")); + QDeclarativeComponent component(&engine, testFileUrl("nestedObjectAccess.qml")); QObject *o = component.create(); QVERIFY(o != 0); @@ -228,7 +219,7 @@ void tst_v4::nestedObjectAccess() void tst_v4::subscriptionsInConditionalExpressions() { - QDeclarativeComponent component(&engine, TEST_FILE("subscriptionsInConditionalExpressions.qml")); + QDeclarativeComponent component(&engine, testFileUrl("subscriptionsInConditionalExpressions.qml")); QObject *o = component.create(); QVERIFY(o != 0); @@ -244,7 +235,7 @@ void tst_v4::subscriptionsInConditionalExpressions() // Crash test void tst_v4::qtbug_21883() { - QDeclarativeComponent component(&engine, TEST_FILE("qtbug_21883.qml")); + QDeclarativeComponent component(&engine, testFileUrl("qtbug_21883.qml")); QString warning = component.url().toString() + ":4: Unable to assign null to ResultObject*"; QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData()); @@ -256,7 +247,7 @@ void tst_v4::qtbug_21883() void tst_v4::qtbug_22816() { - QDeclarativeComponent component(&engine, TEST_FILE("qtbug_22816.qml")); + QDeclarativeComponent component(&engine, testFileUrl("qtbug_22816.qml")); QObject *o = component.create(); QVERIFY(o != 0); diff --git a/tests/auto/declarative/v4/v4.pro b/tests/auto/declarative/v4/v4.pro index 04d20f0fc3..b14be36475 100644 --- a/tests/auto/declarative/v4/v4.pro +++ b/tests/auto/declarative/v4/v4.pro @@ -3,8 +3,10 @@ TARGET = tst_qdeclarativev4 macx:CONFIG -= app_bundle SOURCES += tst_v4.cpp \ - testtypes.cpp -HEADERS += testtypes.h + testtypes.cpp \ + ../../shared/util.cpp +HEADERS += testtypes.h \ + ../../shared/util.h testDataFiles.files = data testDataFiles.path = . |