summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativeworkerscript
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>2012-02-08 12:42:12 +0100
committerAndrew den Exter <andrew.den-exter@nokia.com>2012-02-09 05:58:14 +0100
commitb05039d5efcaec69d01d3737ccb5f0199765632b (patch)
tree162ad7dc2965087dc38e75e03e25031707309881 /tests/auto/declarative/qdeclarativeworkerscript
parent5217eddc405565f09340d5ff4a881d833c03a201 (diff)
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 <matthew.vogt@nokia.com>
Diffstat (limited to 'tests/auto/declarative/qdeclarativeworkerscript')
-rw-r--r--tests/auto/declarative/qdeclarativeworkerscript/qdeclarativeworkerscript.pro8
-rw-r--r--tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp37
2 files changed, 14 insertions, 31 deletions
diff --git a/tests/auto/declarative/qdeclarativeworkerscript/qdeclarativeworkerscript.pro b/tests/auto/declarative/qdeclarativeworkerscript/qdeclarativeworkerscript.pro
index f86dcb02..3015d3d8 100644
--- a/tests/auto/declarative/qdeclarativeworkerscript/qdeclarativeworkerscript.pro
+++ b/tests/auto/declarative/qdeclarativeworkerscript/qdeclarativeworkerscript.pro
@@ -7,13 +7,7 @@ macx:CONFIG -= app_bundle
SOURCES += tst_qdeclarativeworkerscript.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/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp b/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp
index ee176f90..b11564cd 100644
--- a/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp
+++ b/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp
@@ -39,6 +39,7 @@
**
****************************************************************************/
#include <qtest.h>
+#include <qdeclarativedatatest.h>
#include <QtCore/qdebug.h>
#include <QtCore/qtimer.h>
#include <QtCore/qdir.h>
@@ -54,19 +55,7 @@
Q_DECLARE_METATYPE(QScriptValue)
-#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(filename));
-}
-
-
-class tst_QDeclarativeWorkerScript : public QObject
+class tst_QDeclarativeWorkerScript : public QDeclarativeDataTest
{
Q_OBJECT
public:
@@ -99,7 +88,7 @@ private:
void tst_QDeclarativeWorkerScript::source()
{
- QDeclarativeComponent component(&m_engine, SRCDIR "/data/worker.qml");
+ QDeclarativeComponent component(&m_engine, testFileUrl("worker.qml"));
QDeclarativeWorkerScript *worker = qobject_cast<QDeclarativeWorkerScript*>(component.create());
QVERIFY(worker != 0);
const QMetaObject *mo = worker->metaObject();
@@ -109,7 +98,7 @@ void tst_QDeclarativeWorkerScript::source()
waitForEchoMessage(worker);
QCOMPARE(mo->property(mo->indexOfProperty("response")).read(worker).value<QVariant>(), value);
- QUrl source = QUrl::fromLocalFile(SRCDIR "/data/script_fixed_return.js");
+ const QUrl source = testFileUrl("script_fixed_return.js");
worker->setSource(source);
QCOMPARE(worker->source(), source);
QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value)));
@@ -124,7 +113,7 @@ void tst_QDeclarativeWorkerScript::messaging()
{
QFETCH(QVariant, value);
- QDeclarativeComponent component(&m_engine, SRCDIR "/data/worker.qml");
+ QDeclarativeComponent component(&m_engine, testFileUrl("worker.qml"));
QDeclarativeWorkerScript *worker = qobject_cast<QDeclarativeWorkerScript*>(component.create());
QVERIFY(worker != 0);
@@ -161,7 +150,7 @@ void tst_QDeclarativeWorkerScript::messaging_sendQObjectList()
// instances. If objects are sent in a list, they will be sent as 'undefined'
// js values.
- QDeclarativeComponent component(&m_engine, SRCDIR "/data/worker.qml");
+ QDeclarativeComponent component(&m_engine, testFileUrl("worker.qml"));
QDeclarativeWorkerScript *worker = qobject_cast<QDeclarativeWorkerScript*>(component.create());
QVERIFY(worker != 0);
@@ -182,7 +171,7 @@ void tst_QDeclarativeWorkerScript::messaging_sendQObjectList()
void tst_QDeclarativeWorkerScript::messaging_sendJsObject()
{
- QDeclarativeComponent component(&m_engine, SRCDIR "/data/worker.qml");
+ QDeclarativeComponent component(&m_engine, testFileUrl("worker.qml"));
QDeclarativeWorkerScript *worker = qobject_cast<QDeclarativeWorkerScript*>(component.create());
QVERIFY(worker != 0);
@@ -212,7 +201,7 @@ void tst_QDeclarativeWorkerScript::script_with_pragma()
{
QVariant value(100);
- QDeclarativeComponent component(&m_engine, SRCDIR "/data/worker_pragma.qml");
+ QDeclarativeComponent component(&m_engine, testFileUrl("worker_pragma.qml"));
QDeclarativeWorkerScript *worker = qobject_cast<QDeclarativeWorkerScript*>(component.create());
QVERIFY(worker != 0);
@@ -228,7 +217,7 @@ void tst_QDeclarativeWorkerScript::script_with_pragma()
void tst_QDeclarativeWorkerScript::script_included()
{
- QDeclarativeComponent component(&m_engine, SRCDIR "/data/worker_include.qml");
+ QDeclarativeComponent component(&m_engine, testFileUrl("worker_include.qml"));
QDeclarativeWorkerScript *worker = qobject_cast<QDeclarativeWorkerScript*>(component.create());
QVERIFY(worker != 0);
@@ -253,14 +242,14 @@ static void qdeclarativeworkerscript_warningsHandler(QtMsgType type, const char
void tst_QDeclarativeWorkerScript::scriptError_onLoad()
{
- QDeclarativeComponent component(&m_engine, SRCDIR "/data/worker_error_onLoad.qml");
+ QDeclarativeComponent component(&m_engine, testFileUrl("worker_error_onLoad.qml"));
QtMsgHandler previousMsgHandler = qInstallMsgHandler(qdeclarativeworkerscript_warningsHandler);
QDeclarativeWorkerScript *worker = qobject_cast<QDeclarativeWorkerScript*>(component.create());
QVERIFY(worker != 0);
QTRY_COMPARE(qdeclarativeworkerscript_lastWarning,
- TEST_FILE("data/script_error_onLoad.js").toString() + QLatin1String(":3: SyntaxError: Parse error"));
+ testFileUrl("script_error_onLoad.js").toString() + QLatin1String(":3: SyntaxError: Parse error"));
qInstallMsgHandler(previousMsgHandler);
qApp->processEvents();
@@ -269,7 +258,7 @@ void tst_QDeclarativeWorkerScript::scriptError_onLoad()
void tst_QDeclarativeWorkerScript::scriptError_onCall()
{
- QDeclarativeComponent component(&m_engine, SRCDIR "/data/worker_error_onCall.qml");
+ QDeclarativeComponent component(&m_engine, testFileUrl("worker_error_onCall.qml"));
QDeclarativeWorkerScript *worker = qobject_cast<QDeclarativeWorkerScript*>(component.create());
QVERIFY(worker != 0);
@@ -278,7 +267,7 @@ void tst_QDeclarativeWorkerScript::scriptError_onCall()
QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value)));
QTRY_COMPARE(qdeclarativeworkerscript_lastWarning,
- TEST_FILE("data/script_error_onCall.js").toString() + QLatin1String(":4: ReferenceError: Can't find variable: getData"));
+ testFileUrl("script_error_onCall.js").toString() + QLatin1String(":4: ReferenceError: Can't find variable: getData"));
qInstallMsgHandler(previousMsgHandler);
qApp->processEvents();