From b05039d5efcaec69d01d3737ccb5f0199765632b Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 8 Feb 2012 12:42:12 +0100 Subject: Add QDeclarativeDataTest base class to locate test data. - Remove TEST_FILE and TEST_DATA macros in favour of base class that uses QFINDTESTDATA to locate the data. This avoids repeated searching and handles Windows correctly (executables in release/debug subfolders). - Modeled after an existing class in the QtQuick2 tests (see qtdeclarative\tests\auto\shared\util.*). Change-Id: I9e595953328fb552648cef4c7f712d9000f53832 Reviewed-by: Matthew Vogt --- .../qdeclarativeproperty/qdeclarativeproperty.pro | 8 +------ .../tst_qdeclarativeproperty.cpp | 25 +++++++--------------- 2 files changed, 9 insertions(+), 24 deletions(-) (limited to 'tests/auto/declarative/qdeclarativeproperty') diff --git a/tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro b/tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro index 6c4d5604..09f93288 100644 --- a/tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro +++ b/tests/auto/declarative/qdeclarativeproperty/qdeclarativeproperty.pro @@ -7,13 +7,7 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativeproperty.cpp -symbian: { - importFiles.files = data - importFiles.path = . - DEPLOYMENT += importFiles -} else { - DEFINES += SRCDIR=\\\"$$PWD\\\" -} +include(../shared/qdeclarativedatatest.pri) CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp b/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp index 4fb519f5..e906dfb0 100644 --- a/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp +++ b/tests/auto/declarative/qdeclarativeproperty/tst_qdeclarativeproperty.cpp @@ -39,6 +39,7 @@ ** ****************************************************************************/ #include +#include #include #include #include @@ -48,17 +49,6 @@ #include #include -#ifdef Q_OS_SYMBIAN -// In Symbian OS test data is located in applications private dir -#define SRCDIR "." -#endif - -inline QUrl TEST_FILE(const QString &filename) -{ - QFileInfo fileInfo(__FILE__); - return QUrl::fromLocalFile(fileInfo.absoluteDir().filePath(QLatin1String("data/") + filename)); -} - class MyQmlObject : public QObject { Q_OBJECT @@ -66,7 +56,7 @@ public: MyQmlObject() {} }; -QML_DECLARE_TYPE(MyQmlObject); +QML_DECLARE_TYPE(MyQmlObject) class MyAttached : public QObject { @@ -99,10 +89,10 @@ private: QList m_children; }; -QML_DECLARE_TYPE(MyContainer); +QML_DECLARE_TYPE(MyContainer) QML_DECLARE_TYPEINFO(MyContainer, QML_HAS_ATTACHED_PROPERTIES) -class tst_qdeclarativeproperty : public QObject +class tst_qdeclarativeproperty : public QDeclarativeDataTest { Q_OBJECT public: @@ -1004,7 +994,7 @@ void tst_qdeclarativeproperty::read() QVERIFY(qvariant_cast(v) == o.qmlObject()); } { - QDeclarativeComponent component(&engine, TEST_FILE("readSynthesizedObject.qml")); + QDeclarativeComponent component(&engine, testFileUrl("readSynthesizedObject.qml")); QObject *object = component.create(); QVERIFY(object != 0); @@ -1019,7 +1009,7 @@ void tst_qdeclarativeproperty::read() QCOMPARE(qvariant_cast(v)->property("b").toInt(), 19); } { // static - QDeclarativeComponent component(&engine, TEST_FILE("readSynthesizedObject.qml")); + QDeclarativeComponent component(&engine, testFileUrl("readSynthesizedObject.qml")); QObject *object = component.create(); QVERIFY(object != 0); @@ -1374,7 +1364,7 @@ void tst_qdeclarativeproperty::crashOnValueProperty() // QTBUG-13719 void tst_qdeclarativeproperty::aliasPropertyBindings() { - QDeclarativeComponent component(&engine, TEST_FILE("aliasPropertyBindings.qml")); + QDeclarativeComponent component(&engine, testFileUrl("aliasPropertyBindings.qml")); QObject *object = component.create(); QVERIFY(object != 0); @@ -1483,6 +1473,7 @@ void tst_qdeclarativeproperty::copy() void tst_qdeclarativeproperty::initTestCase() { + QDeclarativeDataTest::initTestCase(); qmlRegisterType("Test",1,0,"MyQmlObject"); qmlRegisterType("Test",1,0,"PropertyObject"); qmlRegisterType("Test",1,0,"MyContainer"); -- cgit v1.2.3