QT += declarative-private testlib
macx:CONFIG -= app_bundle
-HEADERS += ../shared/debugutil_p.h
-
+HEADERS += ../shared/debugutil_p.h \
+ ../../../shared/util.h
SOURCES += tst_qdeclarativedebugjs.cpp \
- ../shared/debugutil.cpp
+ ../shared/debugutil.cpp \
+ ../../../shared/util.cpp
INCLUDEPATH += ../shared
class QJSDebugClient;
-class tst_QDeclarativeDebugJS : public QObject
+class tst_QDeclarativeDebugJS : public QDeclarativeDataTest
{
Q_OBJECT
void tst_QDeclarativeDebugJS::initTestCase()
{
+ QDeclarativeDataTest::initTestCase();
t.start();
process = 0;
client = 0;
systemEnvironment << "QML_DISABLE_OPTIMIZER=1";
process->setEnvironment(systemEnvironment);
if (blockMode)
- process->start(QStringList() << QLatin1String(BLOCKMODE) << TESTDATA(qmlFile));
+ process->start(QStringList() << QLatin1String(BLOCKMODE) << testFile(qmlFile));
else
- process->start(QStringList() << QLatin1String(NORMALMODE) << TESTDATA(qmlFile));
+ process->start(QStringList() << QLatin1String(NORMALMODE) << testFile(qmlFile));
if (!process->waitForSessionStart()) {
return false;
TARGET = tst_qdeclarativedebugtrace
macx:CONFIG -= app_bundle
-HEADERS += ../shared/debugutil_p.h
+HEADERS += ../shared/debugutil_p.h \
+ ../../../shared/util.h
SOURCES += tst_qdeclarativedebugtrace.cpp \
- ../shared/debugutil.cpp
+ ../shared/debugutil.cpp \
+ ../../../shared/util.cpp
OTHER_FILES += data/test.qml
void messageReceived(const QByteArray &message);
};
-class tst_QDeclarativeDebugTrace : public QObject
+class tst_QDeclarativeDebugTrace : public QDeclarativeDataTest
{
Q_OBJECT
else
arguments << QString("-qmljsdebugger=port:"STR_PORT);
- arguments << QString(TESTDATA(QLatin1String("test.qml")));
+ arguments << testFile("test.qml");
m_process = new QDeclarativeDebugProcess(executable);
m_process->start(QStringList() << arguments);
TARGET = tst_qv8profilerservice
macx:CONFIG -= app_bundle
-HEADERS += ../shared/debugutil_p.h
+HEADERS += ../shared/debugutil_p.h \
+ ../../../shared/util.h
SOURCES += tst_qv8profilerservice.cpp \
- ../shared/debugutil.cpp
+ ../shared/debugutil.cpp \
+ ../../../shared/util.cpp
OTHER_FILES += data/test.qml
void messageReceived(const QByteArray &message);
};
-class tst_QV8ProfilerService : public QObject
+class tst_QV8ProfilerService : public QDeclarativeDataTest
{
Q_OBJECT
else
arguments << QString("-qmljsdebugger=port:"STR_PORT);
- arguments << QString(TESTDATA(QLatin1String("test.qml")));
+ arguments << QDeclarativeDataTest::instance()->testFile("test.qml");
m_process = new QDeclarativeDebugProcess(executable);
m_process->start(QStringList() << arguments);
TARGET = tst_qdeclarativebinding
macx:CONFIG -= app_bundle
-SOURCES += tst_qdeclarativebinding.cpp
+SOURCES += tst_qdeclarativebinding.cpp \
+ ../../shared/util.cpp
+HEADERS += ../../shared/util.h
testDataFiles.files = data
testDataFiles.path = .
#include <QtQuick/private/qquickrectangle_p.h>
#include "../../shared/util.h"
-class tst_qdeclarativebinding : public QObject
+class tst_qdeclarativebinding : public QDeclarativeDataTest
{
Q_OBJECT
public:
void tst_qdeclarativebinding::binding()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("test-binding.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("test-binding.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect != 0);
void tst_qdeclarativebinding::whenAfterValue()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("test-binding2.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("test-binding2.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect != 0);
void tst_qdeclarativebinding::restoreBinding()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("restoreBinding.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("restoreBinding.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect != 0);
void tst_qdeclarativebinding::restoreBindingWithLoop()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("restoreBindingWithLoop.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("restoreBindingWithLoop.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect != 0);
void tst_qdeclarativebinding::deletedObject()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("deletedObject.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("deletedObject.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect != 0);
TARGET = tst_qdeclarativecomponent
macx:CONFIG -= app_bundle
-SOURCES += tst_qdeclarativecomponent.cpp
+SOURCES += tst_qdeclarativecomponent.cpp \
+ ../../shared/util.cpp
+HEADERS += ../../shared/util.h
testDataFiles.files = data
testDataFiles.path = .
}
};
-class tst_qdeclarativecomponent : public QObject
+class tst_qdeclarativecomponent : public QDeclarativeDataTest
{
Q_OBJECT
public:
void tst_qdeclarativecomponent::qmlIncubateObject()
{
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("incubateObject.qml")));
+ QDeclarativeComponent component(&engine, testFileUrl("incubateObject.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
QCOMPARE(object->property("test1").toBool(), true);
void tst_qdeclarativecomponent::qmlCreateObject()
{
QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("createObject.qml")));
+ QDeclarativeComponent component(&engine, testFileUrl("createObject.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
void tst_qdeclarativecomponent::qmlCreateObjectWithProperties()
{
QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("createObjectWithScript.qml")));
+ QDeclarativeComponent component(&engine, testFileUrl("createObjectWithScript.qml"));
QVERIFY2(component.errorString().isEmpty(), component.errorString().toUtf8());
QObject *object = component.create();
QVERIFY(object != 0);
TARGET = tst_qdeclarativeconnection
macx:CONFIG -= app_bundle
-SOURCES += tst_qdeclarativeconnection.cpp
+SOURCES += tst_qdeclarativeconnection.cpp \
+ ../../shared/util.cpp
+HEADERS += ../../shared/util.h
testDataFiles.files = data
testDataFiles.path = .
#include "../../shared/util.h"
#include <QtDeclarative/qdeclarativescriptstring.h>
-class tst_qdeclarativeconnection : public QObject
+class tst_qdeclarativeconnection : public QDeclarativeDataTest
{
Q_OBJECT
public:
void tst_qdeclarativeconnection::defaultValues()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("test-connection3.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("test-connection3.qml"));
QDeclarativeConnections *item = qobject_cast<QDeclarativeConnections*>(c.create());
QVERIFY(item != 0);
void tst_qdeclarativeconnection::properties()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("test-connection2.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("test-connection2.qml"));
QDeclarativeConnections *item = qobject_cast<QDeclarativeConnections*>(c.create());
QVERIFY(item != 0);
void tst_qdeclarativeconnection::connection()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("test-connection.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("test-connection.qml"));
QQuickItem *item = qobject_cast<QQuickItem*>(c.create());
QVERIFY(item != 0);
void tst_qdeclarativeconnection::trimming()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("trimming.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("trimming.qml"));
QQuickItem *item = qobject_cast<QQuickItem*>(c.create());
QVERIFY(item != 0);
void tst_qdeclarativeconnection::targetChanged()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("connection-targetchange.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("connection-targetchange.qml"));
QQuickItem *item = qobject_cast<QQuickItem*>(c.create());
QVERIFY(item != 0);
QFETCH(QString, file);
QFETCH(QString, error);
- QUrl url = QUrl::fromLocalFile(TESTDATA(file));
+ QUrl url = testFileUrl(file);
if (!error.isEmpty()) {
QTest::ignoreMessage(QtWarningMsg, (url.toString() + error).toLatin1());
} else {
QFETCH(QString, file);
QFETCH(QString, error);
- QUrl url = QUrl::fromLocalFile(TESTDATA(file));
+ QUrl url = testFileUrl(file);
QDeclarativeEngine engine;
QDeclarativeComponent c(&engine, url);
void tst_qdeclarativeconnection::moduleApiTarget()
{
qmlRegisterModuleApi("MyTestModuleApi", 1, 0, module_api_factory);
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("moduleapi-target.qml")));
+ QDeclarativeComponent component(&engine, testFileUrl("moduleapi-target.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
CONFIG += testcase
TARGET = tst_qdeclarativeconsole
-SOURCES += tst_qdeclarativeconsole.cpp
+SOURCES += tst_qdeclarativeconsole.cpp \
+ ../../shared/util.cpp
+HEADERS += ../../shared/util.h
macx:CONFIG -= app_bundle
testDataFiles.files = data
#include <QDeclarativeComponent>
#include "../../shared/util.h"
-class tst_qdeclarativeconsole : public QObject
+class tst_qdeclarativeconsole : public QDeclarativeDataTest
{
Q_OBJECT
public:
QDeclarativeEngine engine;
};
-inline QUrl TEST_FILE(const QString &filename)
-{
- return QUrl::fromLocalFile(TESTDATA(filename));
-}
-
void tst_qdeclarativeconsole::init()
{
qputenv("QML_CONSOLE_EXTENDED", QByteArray("1"));
void tst_qdeclarativeconsole::consoleLogExtended()
{
int startLineNumber = 15;
- QUrl testFileUrl = TEST_FILE("consoleLog.qml");
- QString testString = QString(QLatin1String("completed ok (%1:%2)")).arg(testFileUrl.toString());
+ QUrl testUrl = testFileUrl("consoleLog.qml");
+ const QString testUrlString = testUrl.toString();
+ QString testString = QString(QLatin1String("completed ok (%1:%2)")).arg(testUrlString);
QTest::ignoreMessage(QtDebugMsg, qPrintable(testString.arg(startLineNumber++)));
QTest::ignoreMessage(QtDebugMsg, qPrintable(testString.arg(startLineNumber++)));
QTest::ignoreMessage(QtDebugMsg, qPrintable(testString.arg(startLineNumber++)));
QTest::ignoreMessage(QtWarningMsg, qPrintable(testString.arg(startLineNumber++)));
QTest::ignoreMessage(QtCriticalMsg, qPrintable(testString.arg(startLineNumber++)));
- QString testArray = QString(QLatin1String("[1,2] (%1:%2)")).arg(testFileUrl.toString());
+ QString testArray = QString(QLatin1String("[1,2] (%1:%2)")).arg(testUrlString);
QTest::ignoreMessage(QtDebugMsg, qPrintable(testArray.arg(startLineNumber++)));
- QString testObject = QString(QLatin1String("Object (%1:%2)")).arg(testFileUrl.toString());
+ QString testObject = QString(QLatin1String("Object (%1:%2)")).arg(testUrlString);
QTest::ignoreMessage(QtDebugMsg, qPrintable(testObject.arg(startLineNumber++)));
- QString testUndefined = QString(QLatin1String("undefined (%1:%2)")).arg(testFileUrl.toString());
+ QString testUndefined = QString(QLatin1String("undefined (%1:%2)")).arg(testUrlString);
QTest::ignoreMessage(QtDebugMsg, qPrintable(testUndefined.arg(startLineNumber++)));
- QString testNumber = QString(QLatin1String("12 (%1:%2)")).arg(testFileUrl.toString());
+ QString testNumber = QString(QLatin1String("12 (%1:%2)")).arg(testUrlString);
QTest::ignoreMessage(QtDebugMsg, qPrintable(testNumber.arg(startLineNumber++)));
- QString testFunction = QString(QLatin1String("function () { return 5;} (%1:%2)")).arg(testFileUrl.toString());
+ QString testFunction = QString(QLatin1String("function () { return 5;} (%1:%2)")).arg(testUrlString);
QTest::ignoreMessage(QtDebugMsg, qPrintable(testFunction.arg(startLineNumber++)));
- QString testBoolean = QString(QLatin1String("true (%1:%2)")).arg(testFileUrl.toString());
+ QString testBoolean = QString(QLatin1String("true (%1:%2)")).arg(testUrlString);
QTest::ignoreMessage(QtDebugMsg, qPrintable(testBoolean.arg(startLineNumber++)));
QTest::ignoreMessage(QtDebugMsg, qPrintable(testObject.arg(startLineNumber++)));
QTest::ignoreMessage(QtDebugMsg, qPrintable(testObject.arg(startLineNumber++)));
- QString testMix = QString::fromLatin1("1 pong! Object (%1:%2)").arg(testFileUrl.toString());
+ QString testMix = QString::fromLatin1("1 pong! Object (%1:%2)").arg(testUrlString);
QTest::ignoreMessage(QtDebugMsg, qPrintable(testMix.arg(startLineNumber++)));
- testMix = QString::fromLatin1("1 [ping,pong] Object 2 (%1:%2)").arg(testFileUrl.toString());
+ testMix = QString::fromLatin1("1 [ping,pong] Object 2 (%1:%2)").arg(testUrlString);
QTest::ignoreMessage(QtDebugMsg, qPrintable(testMix.arg(startLineNumber++)));
- QString testException = QString(QLatin1String("%1:%2: ReferenceError: Can't find variable: exception")).arg(testFileUrl.toString());
+ QString testException = QString(QLatin1String("%1:%2: ReferenceError: Can't find variable: exception")).arg(testUrlString);
QTest::ignoreMessage(QtWarningMsg, qPrintable(testException.arg(startLineNumber++)));
- QDeclarativeComponent component(&engine, testFileUrl);
+ QDeclarativeComponent component(&engine, testUrl);
QObject *object = component.create();
QVERIFY(object != 0);
delete object;
CONFIG += testcase
TARGET = tst_qdeclarativecontext
-SOURCES += tst_qdeclarativecontext.cpp
+SOURCES += tst_qdeclarativecontext.cpp \
+ ../../shared/util.cpp
+HEADERS += ../../shared/util.h
macx:CONFIG -= app_bundle
testDataFiles.files = data
#include <private/qdeclarativecontext_p.h>
#include "../../shared/util.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_qdeclarativecontext : public QObject
+class tst_qdeclarativecontext : public QDeclarativeDataTest
{
Q_OBJECT
public:
void tst_qdeclarativecontext::refreshExpressions()
{
QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, TEST_FILE("refreshExpressions.qml"));
- QDeclarativeComponent component2(&engine, TEST_FILE("RefreshExpressionsType.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("refreshExpressions.qml"));
+ QDeclarativeComponent component2(&engine, testFileUrl("RefreshExpressionsType.qml"));
CountCommand command;
engine.rootContext()->setContextProperty("countCommand", &command);
CountCommand command;
engine.rootContext()->setContextProperty("countCommand", &command);
- QDeclarativeComponent component(&engine, TEST_FILE("refreshExpressions.qml"));
- QDeclarativeComponent component2(&engine, TEST_FILE("refreshExpressionsRootContext.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("refreshExpressions.qml"));
+ QDeclarativeComponent component2(&engine, testFileUrl("refreshExpressionsRootContext.qml"));
QDeclarativeContext context(engine.rootContext());
QDeclarativeContext context2(engine.rootContext());
void tst_qdeclarativecontext::qtbug_22535()
{
QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, TEST_FILE("qtbug_22535.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("qtbug_22535.qml"));
QDeclarativeContext context(engine.rootContext());
QObject *o = component.create(&context);
SOURCES += tst_qdeclarativeecmascript.cpp \
testtypes.cpp \
- ../../shared/testhttpserver.cpp
+ ../../shared/testhttpserver.cpp \
+ ../../shared/util.cpp
HEADERS += testtypes.h \
- ../../shared/testhttpserver.h
+ ../../shared/testhttpserver.h \
+ ../../shared/util.h
INCLUDEPATH += ../../shared
# QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage
Static QML language issues are covered in qmllanguage
*/
-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_qdeclarativeecmascript : public QObject
+class tst_qdeclarativeecmascript : public QDeclarativeDataTest
{
Q_OBJECT
public:
QDeclarativeEngine engine;
};
-void tst_qdeclarativeecmascript::initTestCase() { registerTypes(); }
+void tst_qdeclarativeecmascript::initTestCase()
+{
+ QDeclarativeDataTest::initTestCase();
+ registerTypes();
+}
void tst_qdeclarativeecmascript::assignBasicTypes()
{
{
- QDeclarativeComponent component(&engine, TEST_FILE("assignBasicTypes.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("assignBasicTypes.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
QCOMPARE(object->flagProperty(), MyTypeObject::FlagVal1 | MyTypeObject::FlagVal3);
delete object;
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("assignBasicTypes.2.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("assignBasicTypes.2.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
QCOMPARE(object->flagProperty(), MyTypeObject::FlagVal1 | MyTypeObject::FlagVal3);
void tst_qdeclarativeecmascript::idShortcutInvalidates()
{
{
- QDeclarativeComponent component(&engine, TEST_FILE("idShortcutInvalidates.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("idShortcutInvalidates.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
QVERIFY(object->objectProperty() != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("idShortcutInvalidates.1.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("idShortcutInvalidates.1.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
QVERIFY(object->objectProperty() != 0);
void tst_qdeclarativeecmascript::boolPropertiesEvaluateAsBool()
{
{
- QDeclarativeComponent component(&engine, TEST_FILE("boolPropertiesEvaluateAsBool.1.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("boolPropertiesEvaluateAsBool.1.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
QCOMPARE(object->stringProperty(), QLatin1String("pass"));
delete object;
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("boolPropertiesEvaluateAsBool.2.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("boolPropertiesEvaluateAsBool.2.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
QCOMPARE(object->stringProperty(), QLatin1String("pass"));
void tst_qdeclarativeecmascript::signalAssignment()
{
{
- QDeclarativeComponent component(&engine, TEST_FILE("signalAssignment.1.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("signalAssignment.1.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
QCOMPARE(object->string(), QString());
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("signalAssignment.2.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("signalAssignment.2.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
QCOMPARE(object->string(), QString());
void tst_qdeclarativeecmascript::methods()
{
{
- QDeclarativeComponent component(&engine, TEST_FILE("methods.1.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("methods.1.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
QCOMPARE(object->methodCalled(), false);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("methods.2.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("methods.2.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
QCOMPARE(object->methodCalled(), false);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("methods.3.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("methods.3.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
QCOMPARE(object->property("test").toInt(), 19);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("methods.4.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("methods.4.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
QCOMPARE(object->property("test").toInt(), 19);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("methods.5.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("methods.5.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
QCOMPARE(object->property("test").toInt(), 9);
void tst_qdeclarativeecmascript::bindingLoop()
{
- QDeclarativeComponent component(&engine, TEST_FILE("bindingLoop.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("bindingLoop.qml"));
QString warning = component.url().toString() + ":5:9: QML MyQmlObject: Binding loop detected for property \"stringProperty\"";
QTest::ignoreMessage(QtWarningMsg, warning.toLatin1().constData());
QObject *object = component.create();
void tst_qdeclarativeecmascript::deferredProperties()
{
- QDeclarativeComponent component(&engine, TEST_FILE("deferredProperties.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("deferredProperties.qml"));
MyDeferredObject *object =
qobject_cast<MyDeferredObject *>(component.create());
QVERIFY(object != 0);
// Check errors on deferred properties are correctly emitted
void tst_qdeclarativeecmascript::deferredPropertiesErrors()
{
- QDeclarativeComponent component(&engine, TEST_FILE("deferredPropertiesErrors.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("deferredPropertiesErrors.qml"));
MyDeferredObject *object =
qobject_cast<MyDeferredObject *>(component.create());
QVERIFY(object != 0);
void tst_qdeclarativeecmascript::extensionObjects()
{
- QDeclarativeComponent component(&engine, TEST_FILE("extensionObjects.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("extensionObjects.qml"));
MyExtendedObject *object =
qobject_cast<MyExtendedObject *>(component.create());
QVERIFY(object != 0);
void tst_qdeclarativeecmascript::overrideExtensionProperties()
{
- QDeclarativeComponent component(&engine, TEST_FILE("extensionObjectsPropertyOverride.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("extensionObjectsPropertyOverride.qml"));
OverrideDefaultPropertyObject *object =
qobject_cast<OverrideDefaultPropertyObject *>(component.create());
QVERIFY(object != 0);
void tst_qdeclarativeecmascript::attachedProperties()
{
{
- QDeclarativeComponent component(&engine, TEST_FILE("attachedProperty.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("attachedProperty.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
QCOMPARE(object->property("a").toInt(), 19);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("attachedProperty.2.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("attachedProperty.2.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
QCOMPARE(object->property("a").toInt(), 26);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("writeAttachedProperty.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("writeAttachedProperty.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
{
// Existent enums
{
- QDeclarativeComponent component(&engine, TEST_FILE("enums.1.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("enums.1.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
}
// Non-existent enums
{
- QDeclarativeComponent component(&engine, TEST_FILE("enums.2.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("enums.2.qml"));
QString warning1 = component.url().toString() + ":5: Unable to assign [undefined] to int";
QString warning2 = component.url().toString() + ":6: Unable to assign [undefined] to int";
void tst_qdeclarativeecmascript::valueTypeFunctions()
{
- QDeclarativeComponent component(&engine, TEST_FILE("valueTypeFunctions.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("valueTypeFunctions.qml"));
MyTypeObject *obj = qobject_cast<MyTypeObject*>(component.create());
QVERIFY(obj != 0);
QCOMPARE(obj->rectProperty(), QRect(0,0,100,100));
{
// From ECMAScript
{
- QDeclarativeComponent component(&engine, TEST_FILE("constantsOverrideBindings.1.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("constantsOverrideBindings.1.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
// During construction
{
- QDeclarativeComponent component(&engine, TEST_FILE("constantsOverrideBindings.2.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("constantsOverrideBindings.2.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
#if 0
// From C++
{
- QDeclarativeComponent component(&engine, TEST_FILE("constantsOverrideBindings.3.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("constantsOverrideBindings.3.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
// Using an alias
{
- QDeclarativeComponent component(&engine, TEST_FILE("constantsOverrideBindings.4.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("constantsOverrideBindings.4.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
void tst_qdeclarativeecmascript::outerBindingOverridesInnerBinding()
{
QDeclarativeComponent component(&engine,
- TEST_FILE("outerBindingOverridesInnerBinding.qml"));
+ testFileUrl("outerBindingOverridesInnerBinding.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
*/
void tst_qdeclarativeecmascript::nonExistentAttachedObject()
{
- QDeclarativeComponent component(&engine, TEST_FILE("nonExistentAttachedObject.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("nonExistentAttachedObject.qml"));
QString warning = component.url().toString() + ":4: Unable to assign [undefined] to QString";
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
void tst_qdeclarativeecmascript::scope()
{
{
- QDeclarativeComponent component(&engine, TEST_FILE("scope.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("scope.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("scope.2.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("scope.2.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("scope.3.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("scope.3.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
// Signal argument scope
{
- QDeclarativeComponent component(&engine, TEST_FILE("scope.4.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("scope.4.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("scope.5.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("scope.5.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("scope.6.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("scope.6.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
// importing context
void tst_qdeclarativeecmascript::importScope()
{
- QDeclarativeComponent component(&engine, TEST_FILE("importScope.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("importScope.qml"));
QObject *o = component.create();
QVERIFY(o != 0);
*/
void tst_qdeclarativeecmascript::signalParameterTypes()
{
- QDeclarativeComponent component(&engine, TEST_FILE("signalParameterTypes.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("signalParameterTypes.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
*/
void tst_qdeclarativeecmascript::objectsCompareAsEqual()
{
- QDeclarativeComponent component(&engine, TEST_FILE("objectsCompareAsEqual.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("objectsCompareAsEqual.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
*/
void tst_qdeclarativeecmascript::aliasPropertyAndBinding()
{
- QDeclarativeComponent component(&engine, TEST_FILE("aliasPropertyAndBinding.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("aliasPropertyAndBinding.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
QObject *object = 0;
// test that a manual write (of undefined) to a resettable aliased property succeeds
- QDeclarativeComponent c1(&engine, TEST_FILE("aliasreset/aliasPropertyReset.1.qml"));
+ QDeclarativeComponent c1(&engine, testFileUrl("aliasreset/aliasPropertyReset.1.qml"));
object = c1.create();
QVERIFY(object != 0);
QVERIFY(object->property("sourceComponentAlias").value<QDeclarativeComponent*>() != 0);
delete object;
// test that a manual write (of undefined) to a resettable alias property succeeds
- QDeclarativeComponent c2(&engine, TEST_FILE("aliasreset/aliasPropertyReset.2.qml"));
+ QDeclarativeComponent c2(&engine, testFileUrl("aliasreset/aliasPropertyReset.2.qml"));
object = c2.create();
QVERIFY(object != 0);
QVERIFY(object->property("sourceComponentAlias").value<QDeclarativeComponent*>() != 0);
delete object;
// test that an alias to a bound property works correctly
- QDeclarativeComponent c3(&engine, TEST_FILE("aliasreset/aliasPropertyReset.3.qml"));
+ QDeclarativeComponent c3(&engine, testFileUrl("aliasreset/aliasPropertyReset.3.qml"));
object = c3.create();
QVERIFY(object != 0);
QVERIFY(object->property("sourceComponentAlias").value<QDeclarativeComponent*>() != 0);
// test that a manual write (of undefined) to a resettable alias property
// whose aliased property's object has been deleted, does not crash.
- QDeclarativeComponent c4(&engine, TEST_FILE("aliasreset/aliasPropertyReset.4.qml"));
+ QDeclarativeComponent c4(&engine, testFileUrl("aliasreset/aliasPropertyReset.4.qml"));
object = c4.create();
QVERIFY(object != 0);
QVERIFY(object->property("sourceComponentAlias").value<QDeclarativeComponent*>() != 0);
delete object;
// test that binding an alias property to an undefined value works correctly
- QDeclarativeComponent c5(&engine, TEST_FILE("aliasreset/aliasPropertyReset.5.qml"));
+ QDeclarativeComponent c5(&engine, testFileUrl("aliasreset/aliasPropertyReset.5.qml"));
object = c5.create();
QVERIFY(object != 0);
QVERIFY(object->property("sourceComponentAlias").value<QDeclarativeComponent*>() == 0); // bound to undefined value.
delete object;
// test that a manual write (of undefined) to a non-resettable property fails properly
- QUrl url = TEST_FILE("aliasreset/aliasPropertyReset.error.1.qml");
+ QUrl url = testFileUrl("aliasreset/aliasPropertyReset.error.1.qml");
QString warning1 = url.toString() + QLatin1String(":15: Error: Cannot assign [undefined] to int");
QDeclarativeComponent e1(&engine, url);
object = e1.create();
QFETCH(QString, method);
QFETCH(QString, createdName);
- QDeclarativeComponent component(&engine, TEST_FILE("dynamicCreation.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("dynamicCreation.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
QVERIFY(object != 0);
void tst_qdeclarativeecmascript::dynamicDestruction()
{
{
- QDeclarativeComponent component(&engine, TEST_FILE("dynamicDeletion.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("dynamicDeletion.qml"));
QDeclarativeGuard<MyQmlObject> object = qobject_cast<MyQmlObject*>(component.create());
QVERIFY(object != 0);
QDeclarativeGuard<QObject> createdQmlObject = 0;
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("dynamicDeletion.2.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("dynamicDeletion.2.qml"));
QObject *o = component.create();
QVERIFY(o != 0);
*/
void tst_qdeclarativeecmascript::objectToString()
{
- QDeclarativeComponent component(&engine, TEST_FILE("declarativeToString.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("declarativeToString.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
QVERIFY(object != 0);
QMetaObject::invokeMethod(object, "testToString");
*/
void tst_qdeclarativeecmascript::objectHasOwnProperty()
{
- QUrl url = TEST_FILE("declarativeHasOwnProperty.qml");
+ QUrl url = testFileUrl("declarativeHasOwnProperty.qml");
QString warning1 = url.toString() + ":59: TypeError: Cannot call method 'hasOwnProperty' of undefined";
QString warning2 = url.toString() + ":64: TypeError: Cannot call method 'hasOwnProperty' of undefined";
QString warning3 = url.toString() + ":69: TypeError: Cannot call method 'hasOwnProperty' of undefined";
void tst_qdeclarativeecmascript::selfDeletingBinding()
{
{
- QDeclarativeComponent component(&engine, TEST_FILE("selfDeletingBinding.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("selfDeletingBinding.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
object->setProperty("triggerDelete", true);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("selfDeletingBinding.2.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("selfDeletingBinding.2.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
object->setProperty("triggerDelete", true);
*/
void tst_qdeclarativeecmascript::extendedObjectPropertyLookup()
{
- QDeclarativeComponent component(&engine, TEST_FILE("extendedObjectPropertyLookup.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("extendedObjectPropertyLookup.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
delete object;
*/
void tst_qdeclarativeecmascript::extendedObjectPropertyLookup2()
{
- QDeclarativeComponent component(&engine, TEST_FILE("extendedObjectPropertyLookup2.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("extendedObjectPropertyLookup2.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
*/
void tst_qdeclarativeecmascript::scriptErrors()
{
- QDeclarativeComponent component(&engine, TEST_FILE("scriptErrors.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("scriptErrors.qml"));
QString url = component.url().toString();
QString warning1 = url.left(url.length() - 3) + "js:2: Error: Invalid write to global property \"a\"";
*/
void tst_qdeclarativeecmascript::functionErrors()
{
- QDeclarativeComponent component(&engine, TEST_FILE("functionErrors.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("functionErrors.qml"));
QString url = component.url().toString();
QString warning = url + ":5: Error: Invalid write to global property \"a\"";
delete object;
// test that if an exception occurs while invoking js function from cpp, it is reported as expected.
- QDeclarativeComponent componentTwo(&engine, TEST_FILE("scarceResourceFunctionFail.var.qml"));
+ QDeclarativeComponent componentTwo(&engine, testFileUrl("scarceResourceFunctionFail.var.qml"));
url = componentTwo.url().toString();
object = componentTwo.create();
QVERIFY(object != 0);
*/
void tst_qdeclarativeecmascript::propertyAssignmentErrors()
{
- QDeclarativeComponent component(&engine, TEST_FILE("propertyAssignmentErrors.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("propertyAssignmentErrors.qml"));
QString url = component.url().toString();
*/
void tst_qdeclarativeecmascript::signalTriggeredBindings()
{
- QDeclarativeComponent component(&engine, TEST_FILE("signalTriggeredBindings.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("signalTriggeredBindings.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
QVERIFY(object != 0);
*/
void tst_qdeclarativeecmascript::listProperties()
{
- QDeclarativeComponent component(&engine, TEST_FILE("listProperties.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("listProperties.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
QVERIFY(object != 0);
void tst_qdeclarativeecmascript::exceptionClearsOnReeval()
{
- QDeclarativeComponent component(&engine, TEST_FILE("exceptionClearsOnReeval.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("exceptionClearsOnReeval.qml"));
QString url = component.url().toString();
QString warning = url + ":4: TypeError: Cannot read property 'objectProperty' of null";
void tst_qdeclarativeecmascript::exceptionSlotProducesWarning()
{
- QDeclarativeComponent component(&engine, TEST_FILE("exceptionProducesWarning.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("exceptionProducesWarning.qml"));
QString url = component.url().toString();
QString warning = component.url().toString() + ":6: Error: JS exception";
void tst_qdeclarativeecmascript::exceptionBindingProducesWarning()
{
- QDeclarativeComponent component(&engine, TEST_FILE("exceptionProducesWarning2.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("exceptionProducesWarning2.qml"));
QString url = component.url().toString();
QString warning = component.url().toString() + ":5: Error: JS exception";
void tst_qdeclarativeecmascript::transientErrors()
{
{
- QDeclarativeComponent component(&engine, TEST_FILE("transientErrors.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("transientErrors.qml"));
transientErrorsMsgCount = 0;
QtMsgHandler old = qInstallMsgHandler(transientErrorsMsgHandler);
// One binding erroring multiple times, but then resolving
{
- QDeclarativeComponent component(&engine, TEST_FILE("transientErrors.2.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("transientErrors.2.qml"));
transientErrorsMsgCount = 0;
QtMsgHandler old = qInstallMsgHandler(transientErrorsMsgHandler);
// Check that errors during shutdown are minimized
void tst_qdeclarativeecmascript::shutdownErrors()
{
- QDeclarativeComponent component(&engine, TEST_FILE("shutdownErrors.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("shutdownErrors.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
void tst_qdeclarativeecmascript::compositePropertyType()
{
- QDeclarativeComponent component(&engine, TEST_FILE("compositePropertyType.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("compositePropertyType.qml"));
QTest::ignoreMessage(QtDebugMsg, "hello world");
QObject *object = qobject_cast<QObject *>(component.create());
// QTBUG-5759
void tst_qdeclarativeecmascript::jsObject()
{
- QDeclarativeComponent component(&engine, TEST_FILE("jsObject.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("jsObject.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
void tst_qdeclarativeecmascript::undefinedResetsProperty()
{
{
- QDeclarativeComponent component(&engine, TEST_FILE("undefinedResetsProperty.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("undefinedResetsProperty.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
delete object;
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("undefinedResetsProperty.2.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("undefinedResetsProperty.2.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
// Aliases to variant properties should work
void tst_qdeclarativeecmascript::qtbug_22464()
{
- QDeclarativeComponent component(&engine, TEST_FILE("qtbug_22464.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("qtbug_22464.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
void tst_qdeclarativeecmascript::qtbug_21580()
{
- QDeclarativeComponent component(&engine, TEST_FILE("qtbug_21580.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("qtbug_21580.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
// QTBUG-6781
void tst_qdeclarativeecmascript::bug1()
{
- QDeclarativeComponent component(&engine, TEST_FILE("bug.1.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("bug.1.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
// Don't crash in createObject when the component has errors.
void tst_qdeclarativeecmascript::dynamicCreationCrash()
{
- QDeclarativeComponent component(&engine, TEST_FILE("dynamicCreation.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("dynamicCreation.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
QVERIFY(object != 0);
// allow the engine to go out of scope too.
{
QDeclarativeEngine dcoEngine;
- QDeclarativeComponent component(&dcoEngine, TEST_FILE("dynamicCreationOwnership.qml"));
+ QDeclarativeComponent component(&dcoEngine, testFileUrl("dynamicCreationOwnership.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
MyDynamicCreationDestructionObject *mdcdo = object->findChild<MyDynamicCreationDestructionObject*>("mdcdo");
//QTBUG-9367
void tst_qdeclarativeecmascript::regExpBug()
{
- QDeclarativeComponent component(&engine, TEST_FILE("regExp.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("regExp.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
QVERIFY(object != 0);
QCOMPARE(object->regExp().pattern(), QLatin1String("[a-zA-z]"));
// QTBUG-13047 (check that you can pass registered object types as args)
void tst_qdeclarativeecmascript::invokableObjectArg()
{
- QDeclarativeComponent component(&engine, TEST_FILE("invokableObjectArg.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("invokableObjectArg.qml"));
QObject *o = component.create();
QVERIFY(o);
// QTBUG-13047 (check that you can return registered object types from methods)
void tst_qdeclarativeecmascript::invokableObjectRet()
{
- QDeclarativeComponent component(&engine, TEST_FILE("invokableObjectRet.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("invokableObjectRet.qml"));
QObject *o = component.create();
QVERIFY(o);
// QTBUG-5675
void tst_qdeclarativeecmascript::listToVariant()
{
- QDeclarativeComponent component(&engine, TEST_FILE("listToVariant.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("listToVariant.qml"));
MyQmlContainer container;
Q_DECLARE_METATYPE(QDeclarativeListProperty<MyQmlObject>)
void tst_qdeclarativeecmascript::listAssignment()
{
- QDeclarativeComponent component(&engine, TEST_FILE("listAssignment.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("listAssignment.qml"));
QObject *obj = component.create();
QCOMPARE(obj->property("list1length").toInt(), 2);
QDeclarativeListProperty<MyQmlObject> list1 = obj->property("list1").value<QDeclarativeListProperty<MyQmlObject> >();
QDeclarativeEngine e1;
e1.rootContext()->setContextProperty("thing", &obj);
- QDeclarativeComponent c1(&e1, TEST_FILE("multiEngineObject.qml"));
+ QDeclarativeComponent c1(&e1, testFileUrl("multiEngineObject.qml"));
QDeclarativeEngine e2;
e2.rootContext()->setContextProperty("thing", &obj);
- QDeclarativeComponent c2(&e2, TEST_FILE("multiEngineObject.qml"));
+ QDeclarativeComponent c2(&e2, testFileUrl("multiEngineObject.qml"));
QObject *o1 = c1.create();
QObject *o2 = c2.create();
// Test that references to QObjects are cleanup when the object is destroyed
void tst_qdeclarativeecmascript::deletedObject()
{
- QDeclarativeComponent component(&engine, TEST_FILE("deletedObject.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("deletedObject.qml"));
QObject *object = component.create();
void tst_qdeclarativeecmascript::attachedPropertyScope()
{
- QDeclarativeComponent component(&engine, TEST_FILE("attachedPropertyScope.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("attachedPropertyScope.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
void tst_qdeclarativeecmascript::scriptConnect()
{
{
- QDeclarativeComponent component(&engine, TEST_FILE("scriptConnect.1.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("scriptConnect.1.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("scriptConnect.2.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("scriptConnect.2.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("scriptConnect.3.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("scriptConnect.3.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("scriptConnect.4.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("scriptConnect.4.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("scriptConnect.5.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("scriptConnect.5.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("scriptConnect.6.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("scriptConnect.6.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
void tst_qdeclarativeecmascript::scriptDisconnect()
{
{
- QDeclarativeComponent component(&engine, TEST_FILE("scriptDisconnect.1.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("scriptDisconnect.1.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("scriptDisconnect.2.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("scriptDisconnect.2.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("scriptDisconnect.3.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("scriptDisconnect.3.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
delete object;
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("scriptDisconnect.4.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("scriptDisconnect.4.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
context->setContextObject(&own);
{
- QDeclarativeComponent component(&engine, TEST_FILE("ownership.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("ownership.qml"));
QVERIFY(own.object != 0);
own.object = new QObject(&own);
{
- QDeclarativeComponent component(&engine, TEST_FILE("ownership.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("ownership.qml"));
QVERIFY(own.object != 0);
QDeclarativeContext *context = new QDeclarativeContext(engine.rootContext());
context->setContextObject(&obj);
- QDeclarativeComponent component(&engine, TEST_FILE("qlistqobjectMethods.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("qlistqobjectMethods.qml"));
QObject *object = component.create(context);
// QTBUG-9205
void tst_qdeclarativeecmascript::strictlyEquals()
{
- QDeclarativeComponent component(&engine, TEST_FILE("strictlyEquals.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("strictlyEquals.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
void tst_qdeclarativeecmascript::compiled()
{
- QDeclarativeComponent component(&engine, TEST_FILE("compiled.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("compiled.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
// Test that numbers assigned in bindings as strings work consistently
void tst_qdeclarativeecmascript::numberAssignment()
{
- QDeclarativeComponent component(&engine, TEST_FILE("numberAssignment.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("numberAssignment.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
void tst_qdeclarativeecmascript::propertySplicing()
{
- QDeclarativeComponent component(&engine, TEST_FILE("propertySplicing.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("propertySplicing.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
// QTBUG-16683
void tst_qdeclarativeecmascript::signalWithUnknownTypes()
{
- QDeclarativeComponent component(&engine, TEST_FILE("signalWithUnknownTypes.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("signalWithUnknownTypes.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
QFETCH(QString, expression);
QFETCH(QString, compare);
- QDeclarativeComponent component(&engine, TEST_FILE("signalWithJSValueInVariant.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("signalWithJSValueInVariant.qml"));
QScopedPointer<MyQmlObject> object(qobject_cast<MyQmlObject *>(component.create()));
QVERIFY(object != 0);
QFETCH(QString, expression);
QFETCH(QString, compare);
- QDeclarativeComponent component(&engine, TEST_FILE("signalWithJSValueInVariant.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("signalWithJSValueInVariant.qml"));
QScopedPointer<MyQmlObject> object(qobject_cast<MyQmlObject *>(component.create()));
QVERIFY(object != 0);
QFETCH(QString, expression);
QFETCH(QString, compare);
- QDeclarativeComponent component(&engine, TEST_FILE("signalWithQJSValue.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("signalWithQJSValue.qml"));
QScopedPointer<MyQmlObject> object(qobject_cast<MyQmlObject *>(component.create()));
QVERIFY(object != 0);
QTest::addColumn<QVariantList>("readBackExpectedValues");
QTest::newRow("qobject, register + read + method")
- << TEST_FILE("moduleapi/qobjectModuleApi.qml")
+ << testFileUrl("moduleapi/qobjectModuleApi.qml")
<< QString()
<< QStringList()
<< (QStringList() << "existingUriTest" << "qobjectTest" << "qobjectMethodTest"
<< QVariantList();
QTest::newRow("script, register + read")
- << TEST_FILE("moduleapi/scriptModuleApi.qml")
+ << testFileUrl("moduleapi/scriptModuleApi.qml")
<< QString()
<< QStringList()
<< (QStringList() << "scriptTest")
<< QVariantList();
QTest::newRow("qobject, caching + read")
- << TEST_FILE("moduleapi/qobjectModuleApiCaching.qml")
+ << testFileUrl("moduleapi/qobjectModuleApiCaching.qml")
<< QString()
<< QStringList()
<< (QStringList() << "existingUriTest" << "qobjectParentedTest")
<< QVariantList();
QTest::newRow("script, caching + read")
- << TEST_FILE("moduleapi/scriptModuleApiCaching.qml")
+ << testFileUrl("moduleapi/scriptModuleApiCaching.qml")
<< QString()
<< QStringList()
<< (QStringList() << "scriptTest")
<< QVariantList();
QTest::newRow("qobject, writing + readonly constraints")
- << TEST_FILE("moduleapi/qobjectModuleApiWriting.qml")
+ << testFileUrl("moduleapi/qobjectModuleApiWriting.qml")
<< QString()
- << (QStringList() << QString(QLatin1String("file://") + TEST_FILE("moduleapi/qobjectModuleApiWriting.qml").toLocalFile() + QLatin1String(":14: Error: Cannot assign to read-only property \"qobjectTestProperty\"")))
+ << (QStringList() << QString(QLatin1String("file://") + testFileUrl("moduleapi/qobjectModuleApiWriting.qml").toLocalFile() + QLatin1String(":14: Error: Cannot assign to read-only property \"qobjectTestProperty\"")))
<< (QStringList() << "readOnlyProperty" << "writableProperty")
<< (QVariantList() << 20 << 50)
<< (QStringList() << "firstProperty" << "writableProperty")
<< (QVariantList() << 20 << 30);
QTest::newRow("script, writing + readonly constraints")
- << TEST_FILE("moduleapi/scriptModuleApiWriting.qml")
+ << testFileUrl("moduleapi/scriptModuleApiWriting.qml")
<< QString()
- << (QStringList() << QString(QLatin1String("file://") + TEST_FILE("moduleapi/scriptModuleApiWriting.qml").toLocalFile() + QLatin1String(":21: Error: Cannot assign to read-only property \"scriptTestProperty\"")))
+ << (QStringList() << QString(QLatin1String("file://") + testFileUrl("moduleapi/scriptModuleApiWriting.qml").toLocalFile() + QLatin1String(":21: Error: Cannot assign to read-only property \"scriptTestProperty\"")))
<< (QStringList() << "readBack" << "unchanged")
<< (QVariantList() << 13 << 42)
<< (QStringList() << "firstProperty" << "secondProperty")
<< (QVariantList() << 30 << 42);
QTest::newRow("qobject module API enum values in JS")
- << TEST_FILE("moduleapi/qobjectModuleApiEnums.qml")
+ << testFileUrl("moduleapi/qobjectModuleApiEnums.qml")
<< QString()
<< QStringList()
<< (QStringList() << "enumValue" << "enumMethod")
<< QVariantList();
QTest::newRow("qobject, invalid major version fail")
- << TEST_FILE("moduleapi/moduleApiMajorVersionFail.qml")
+ << testFileUrl("moduleapi/moduleApiMajorVersionFail.qml")
<< QString("QDeclarativeComponent: Component is not ready")
<< QStringList()
<< QStringList()
<< QVariantList();
QTest::newRow("qobject, invalid minor version fail")
- << TEST_FILE("moduleapi/moduleApiMinorVersionFail.qml")
+ << testFileUrl("moduleapi/moduleApiMinorVersionFail.qml")
<< QString("QDeclarativeComponent: Component is not ready")
<< QStringList()
<< QStringList()
QTest::addColumn<QVariantList>("propertyValues");
QTest::newRow("basic functionality")
- << TEST_FILE("jsimport/testImport.qml")
+ << testFileUrl("jsimport/testImport.qml")
<< QString()
<< QStringList()
<< (QStringList() << QLatin1String("importedScriptStringValue")
<< QVariant(2));
QTest::newRow("import scoping")
- << TEST_FILE("jsimport/testImportScoping.qml")
+ << testFileUrl("jsimport/testImportScoping.qml")
<< QString()
<< QStringList()
<< (QStringList() << QLatin1String("componentError"))
<< (QVariantList() << QVariant(5));
QTest::newRow("parent scope shouldn't be inherited by import with imports")
- << TEST_FILE("jsimportfail/failOne.qml")
+ << testFileUrl("jsimportfail/failOne.qml")
<< QString()
- << (QStringList() << QString(QLatin1String("file://") + TEST_FILE("jsimportfail/failOne.qml").toLocalFile() + QLatin1String(":6: TypeError: Cannot call method 'greetingString' of undefined")))
+ << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/failOne.qml").toLocalFile() + QLatin1String(":6: TypeError: Cannot call method 'greetingString' of undefined")))
<< (QStringList() << QLatin1String("importScriptFunctionValue"))
<< (QVariantList() << QVariant(QString()));
QTest::newRow("javascript imports in an import should be private to the import scope")
- << TEST_FILE("jsimportfail/failTwo.qml")
+ << testFileUrl("jsimportfail/failTwo.qml")
<< QString()
- << (QStringList() << QString(QLatin1String("file://") + TEST_FILE("jsimportfail/failTwo.qml").toLocalFile() + QLatin1String(":6: ReferenceError: Can't find variable: ImportOneJs")))
+ << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/failTwo.qml").toLocalFile() + QLatin1String(":6: ReferenceError: Can't find variable: ImportOneJs")))
<< (QStringList() << QLatin1String("importScriptFunctionValue"))
<< (QVariantList() << QVariant(QString()));
QTest::newRow("module imports in an import should be private to the import scope")
- << TEST_FILE("jsimportfail/failThree.qml")
+ << testFileUrl("jsimportfail/failThree.qml")
<< QString()
- << (QStringList() << QString(QLatin1String("file://") + TEST_FILE("jsimportfail/failThree.qml").toLocalFile() + QLatin1String(":7: TypeError: Cannot read property 'JsQtTest' of undefined")))
+ << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/failThree.qml").toLocalFile() + QLatin1String(":7: TypeError: Cannot read property 'JsQtTest' of undefined")))
<< (QStringList() << QLatin1String("importedModuleAttachedPropertyValue"))
<< (QVariantList() << QVariant(false));
QTest::newRow("typenames in an import should be private to the import scope")
- << TEST_FILE("jsimportfail/failFour.qml")
+ << testFileUrl("jsimportfail/failFour.qml")
<< QString()
- << (QStringList() << QString(QLatin1String("file://") + TEST_FILE("jsimportfail/failFour.qml").toLocalFile() + QLatin1String(":6: ReferenceError: Can't find variable: JsQtTest")))
+ << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/failFour.qml").toLocalFile() + QLatin1String(":6: ReferenceError: Can't find variable: JsQtTest")))
<< (QStringList() << QLatin1String("importedModuleEnumValue"))
<< (QVariantList() << QVariant(0));
QTest::newRow("import with imports has it's own activation scope")
- << TEST_FILE("jsimportfail/failFive.qml")
+ << testFileUrl("jsimportfail/failFive.qml")
<< QString()
- << (QStringList() << QString(QLatin1String("file://") + TEST_FILE("jsimportfail/importWithImports.js").toLocalFile() + QLatin1String(":8: ReferenceError: Can't find variable: Component"))
- << QString(QLatin1String("file://") + TEST_FILE("jsimportfail/importPragmaLibrary.js").toLocalFile() + QLatin1String(":6: ReferenceError: Can't find variable: Component")))
+ << (QStringList() << QString(QLatin1String("file://") + testFileUrl("jsimportfail/importWithImports.js").toLocalFile() + QLatin1String(":8: ReferenceError: Can't find variable: Component"))
+ << QString(QLatin1String("file://") + testFileUrl("jsimportfail/importPragmaLibrary.js").toLocalFile() + QLatin1String(":6: ReferenceError: Can't find variable: Component")))
<< (QStringList() << QLatin1String("componentError"))
<< (QVariantList() << QVariant(0));
QTest::newRow("import pragma library script")
- << TEST_FILE("jsimport/testImportPragmaLibrary.qml")
+ << testFileUrl("jsimport/testImportPragmaLibrary.qml")
<< QString()
<< QStringList()
<< (QStringList() << QLatin1String("testValue"))
<< (QVariantList() << QVariant(31));
QTest::newRow("pragma library imports shouldn't inherit parent imports or scope")
- << TEST_FILE("jsimportfail/testImportPragmaLibrary.qml")
+ << testFileUrl("jsimportfail/testImportPragmaLibrary.qml")
<< QString()
<< QStringList()
<< (QStringList() << QLatin1String("testValue"))
<< (QVariantList() << QVariant(0));
QTest::newRow("import pragma library script which has an import")
- << TEST_FILE("jsimport/testImportPragmaLibraryWithImports.qml")
+ << testFileUrl("jsimport/testImportPragmaLibraryWithImports.qml")
<< QString()
<< QStringList()
<< (QStringList() << QLatin1String("testValue"))
<< (QVariantList() << QVariant(55));
QTest::newRow("import pragma library script which has a pragma library import")
- << TEST_FILE("jsimport/testImportPragmaLibraryWithPragmaLibraryImports.qml")
+ << testFileUrl("jsimport/testImportPragmaLibraryWithPragmaLibraryImports.qml")
<< QString()
<< QStringList()
<< (QStringList() << QLatin1String("testValue"))
/* property var semantics */
// test that scarce resources are handled properly in signal invocation
- QDeclarativeComponent varComponentTen(&engine, TEST_FILE("scarceResourceSignal.var.qml"));
+ QDeclarativeComponent varComponentTen(&engine, testFileUrl("scarceResourceSignal.var.qml"));
object = varComponentTen.create();
srsc = object->findChild<QObject*>("srsc");
QVERIFY(srsc);
delete object;
// test that scarce resources are handled properly from js functions in qml files
- QDeclarativeComponent varComponentEleven(&engine, TEST_FILE("scarceResourceFunction.var.qml"));
+ QDeclarativeComponent varComponentEleven(&engine, testFileUrl("scarceResourceFunction.var.qml"));
object = varComponentEleven.create();
QVERIFY(object != 0);
QVERIFY(!object->property("scarceResourceCopy").isValid()); // not yet assigned, so should not be valid
delete object;
// test that if an exception occurs while invoking js function from cpp, that the resources are released.
- QDeclarativeComponent varComponentTwelve(&engine, TEST_FILE("scarceResourceFunctionFail.var.qml"));
+ QDeclarativeComponent varComponentTwelve(&engine, testFileUrl("scarceResourceFunctionFail.var.qml"));
object = varComponentTwelve.create();
QVERIFY(object != 0);
QVERIFY(!object->property("scarceResourceCopy").isValid()); // not yet assigned, so should not be valid
// test that if an Item which has JS ownership but has a scarce resource property is garbage collected,
// that the scarce resource is removed from the engine's list of scarce resources to clean up.
- QDeclarativeComponent varComponentThirteen(&engine, TEST_FILE("scarceResourceObjectGc.var.qml"));
+ QDeclarativeComponent varComponentThirteen(&engine, testFileUrl("scarceResourceObjectGc.var.qml"));
object = varComponentThirteen.create();
QVERIFY(object != 0);
QVERIFY(!object->property("varProperty").isValid()); // not assigned yet
/* property variant semantics */
// test that scarce resources are handled properly in signal invocation
- QDeclarativeComponent variantComponentTen(&engine, TEST_FILE("scarceResourceSignal.variant.qml"));
+ QDeclarativeComponent variantComponentTen(&engine, testFileUrl("scarceResourceSignal.variant.qml"));
object = variantComponentTen.create();
QVERIFY(object != 0);
srsc = object->findChild<QObject*>("srsc");
delete object;
// test that scarce resources are handled properly from js functions in qml files
- QDeclarativeComponent variantComponentEleven(&engine, TEST_FILE("scarceResourceFunction.variant.qml"));
+ QDeclarativeComponent variantComponentEleven(&engine, testFileUrl("scarceResourceFunction.variant.qml"));
object = variantComponentEleven.create();
QVERIFY(object != 0);
QVERIFY(!object->property("scarceResourceCopy").isValid()); // not yet assigned, so should not be valid
delete object;
// test that if an exception occurs while invoking js function from cpp, that the resources are released.
- QDeclarativeComponent variantComponentTwelve(&engine, TEST_FILE("scarceResourceFunctionFail.variant.qml"));
+ QDeclarativeComponent variantComponentTwelve(&engine, testFileUrl("scarceResourceFunctionFail.variant.qml"));
object = variantComponentTwelve.create();
QVERIFY(object != 0);
QVERIFY(!object->property("scarceResourceCopy").isValid()); // not yet assigned, so should not be valid
// resource should NOT be detached prior to deletion of the object instance,
// unless the resource is destroyed explicitly.
QTest::newRow("var: import scarce resource copy directly")
- << TEST_FILE("scarceResourceCopy.var.qml")
+ << testFileUrl("scarceResourceCopy.var.qml")
<< true
<< false // won't be detached, because assigned to property and not explicitly released
<< (QStringList() << QLatin1String("scarceResourceCopy"))
<< QStringList();
QTest::newRow("var: import scarce resource copy from JS")
- << TEST_FILE("scarceResourceCopyFromJs.var.qml")
+ << testFileUrl("scarceResourceCopyFromJs.var.qml")
<< true
<< false // won't be detached, because assigned to property and not explicitly released
<< (QStringList() << QLatin1String("scarceResourceCopy"))
<< QStringList();
QTest::newRow("var: import released scarce resource copy from JS")
- << TEST_FILE("scarceResourceDestroyedCopy.var.qml")
+ << testFileUrl("scarceResourceDestroyedCopy.var.qml")
<< true
<< true // explicitly released, so it will be detached
<< (QStringList() << QLatin1String("scarceResourceCopy"))
// in the following three cases, no other copy should exist in memory,
// and so it should be detached (unless explicitly preserved).
QTest::newRow("var: import auto-release SR from JS in binding side-effect")
- << TEST_FILE("scarceResourceTest.var.qml")
+ << testFileUrl("scarceResourceTest.var.qml")
<< true
<< true // auto released, so it will be detached
<< (QStringList() << QLatin1String("scarceResourceTest"))
<< (QList<QVariant>() << QVariant(100))
<< QStringList();
QTest::newRow("var: import explicit-preserve SR from JS in binding side-effect")
- << TEST_FILE("scarceResourceTestPreserve.var.qml")
+ << testFileUrl("scarceResourceTestPreserve.var.qml")
<< true
<< false // won't be detached because we explicitly preserve it
<< (QStringList() << QLatin1String("scarceResourceTest"))
<< (QList<QVariant>() << QVariant(100))
<< QStringList();
QTest::newRow("var: import explicit-preserve SR from JS in binding side-effect")
- << TEST_FILE("scarceResourceTestMultiple.var.qml")
+ << testFileUrl("scarceResourceTestMultiple.var.qml")
<< true
<< true // will be detached because all resources were released manually or automatically.
<< (QStringList() << QLatin1String("scarceResourceTest"))
// In the following three cases, test that scarce resources are handled
// correctly for imports.
QTest::newRow("var: import with no binding")
- << TEST_FILE("scarceResourceCopyImportNoBinding.var.qml")
+ << testFileUrl("scarceResourceCopyImportNoBinding.var.qml")
<< false // cannot check detach status.
<< false
<< QStringList()
<< QList<QVariant>()
<< QStringList();
QTest::newRow("var: import with binding without explicit preserve")
- << TEST_FILE("scarceResourceCopyImportNoBinding.var.qml")
+ << testFileUrl("scarceResourceCopyImportNoBinding.var.qml")
<< false
<< false
<< (QStringList() << QLatin1String("scarceResourceCopy"))
<< (QList<QVariant>() << QVariant())
<< QStringList();
QTest::newRow("var: import with explicit release after binding evaluation")
- << TEST_FILE("scarceResourceCopyImport.var.qml")
+ << testFileUrl("scarceResourceCopyImport.var.qml")
<< false
<< false
<< (QStringList() << QLatin1String("scarceResourceImportedCopy") << QLatin1String("scarceResourceAssignedCopyOne") << QLatin1String("scarceResourceAssignedCopyTwo") << QLatin1String("arePropertiesEqual"))
<< (QList<QVariant>() << QVariant() << QVariant() << QVariant() << QVariant(true))
<< QStringList();
QTest::newRow("var: import with different js objects")
- << TEST_FILE("scarceResourceCopyImportDifferent.var.qml")
+ << testFileUrl("scarceResourceCopyImportDifferent.var.qml")
<< false
<< false
<< (QStringList() << QLatin1String("scarceResourceAssignedCopyOne") << QLatin1String("scarceResourceAssignedCopyTwo") << QLatin1String("arePropertiesEqual"))
<< (QList<QVariant>() << QVariant() << QVariant(origPixmap) << QVariant(false))
<< QStringList();
QTest::newRow("var: import with different js objects and explicit release")
- << TEST_FILE("scarceResourceMultipleDifferentNoBinding.var.qml")
+ << testFileUrl("scarceResourceMultipleDifferentNoBinding.var.qml")
<< false
<< false
<< (QStringList() << QLatin1String("resourceOne") << QLatin1String("resourceTwo"))
<< (QList<QVariant>() << QVariant(origPixmap) << QVariant())
<< QStringList();
QTest::newRow("var: import with same js objects and explicit release")
- << TEST_FILE("scarceResourceMultipleSameNoBinding.var.qml")
+ << testFileUrl("scarceResourceMultipleSameNoBinding.var.qml")
<< false
<< false
<< (QStringList() << QLatin1String("resourceOne") << QLatin1String("resourceTwo"))
<< (QList<QVariant>() << QVariant() << QVariant())
<< QStringList();
QTest::newRow("var: binding with same js objects and explicit release")
- << TEST_FILE("scarceResourceMultipleSameWithBinding.var.qml")
+ << testFileUrl("scarceResourceMultipleSameWithBinding.var.qml")
<< false
<< false
<< (QStringList() << QLatin1String("resourceOne") << QLatin1String("resourceTwo"))
// resource should NOT be detached prior to deletion of the object instance,
// unless the resource is destroyed explicitly.
QTest::newRow("variant: import scarce resource copy directly")
- << TEST_FILE("scarceResourceCopy.variant.qml")
+ << testFileUrl("scarceResourceCopy.variant.qml")
<< true
<< false // won't be detached, because assigned to property and not explicitly released
<< (QStringList() << QLatin1String("scarceResourceCopy"))
<< QStringList();
QTest::newRow("variant: import scarce resource copy from JS")
- << TEST_FILE("scarceResourceCopyFromJs.variant.qml")
+ << testFileUrl("scarceResourceCopyFromJs.variant.qml")
<< true
<< false // won't be detached, because assigned to property and not explicitly released
<< (QStringList() << QLatin1String("scarceResourceCopy"))
<< QStringList();
QTest::newRow("variant: import released scarce resource copy from JS")
- << TEST_FILE("scarceResourceDestroyedCopy.variant.qml")
+ << testFileUrl("scarceResourceDestroyedCopy.variant.qml")
<< true
<< true // explicitly released, so it will be detached
<< (QStringList() << QLatin1String("scarceResourceCopy"))
// in the following three cases, no other copy should exist in memory,
// and so it should be detached (unless explicitly preserved).
QTest::newRow("variant: import auto-release SR from JS in binding side-effect")
- << TEST_FILE("scarceResourceTest.variant.qml")
+ << testFileUrl("scarceResourceTest.variant.qml")
<< true
<< true // auto released, so it will be detached
<< (QStringList() << QLatin1String("scarceResourceTest"))
<< (QList<QVariant>() << QVariant(100))
<< QStringList();
QTest::newRow("variant: import explicit-preserve SR from JS in binding side-effect")
- << TEST_FILE("scarceResourceTestPreserve.variant.qml")
+ << testFileUrl("scarceResourceTestPreserve.variant.qml")
<< true
<< false // won't be detached because we explicitly preserve it
<< (QStringList() << QLatin1String("scarceResourceTest"))
<< (QList<QVariant>() << QVariant(100))
<< QStringList();
QTest::newRow("variant: import multiple scarce resources")
- << TEST_FILE("scarceResourceTestMultiple.variant.qml")
+ << testFileUrl("scarceResourceTestMultiple.variant.qml")
<< true
<< true // will be detached because all resources were released manually or automatically.
<< (QStringList() << QLatin1String("scarceResourceTest"))
// In the following three cases, test that scarce resources are handled
// correctly for imports.
QTest::newRow("variant: import with no binding")
- << TEST_FILE("scarceResourceCopyImportNoBinding.variant.qml")
+ << testFileUrl("scarceResourceCopyImportNoBinding.variant.qml")
<< false // cannot check detach status.
<< false
<< QStringList()
<< QList<QVariant>()
<< QStringList();
QTest::newRow("variant: import with binding without explicit preserve")
- << TEST_FILE("scarceResourceCopyImportNoBinding.variant.qml")
+ << testFileUrl("scarceResourceCopyImportNoBinding.variant.qml")
<< false
<< false
<< (QStringList() << QLatin1String("scarceResourceCopy"))
<< (QList<QVariant>() << QVariant())
<< QStringList();
QTest::newRow("variant: import with explicit release after binding evaluation")
- << TEST_FILE("scarceResourceCopyImport.variant.qml")
+ << testFileUrl("scarceResourceCopyImport.variant.qml")
<< false
<< false
<< (QStringList() << QLatin1String("scarceResourceImportedCopy") << QLatin1String("scarceResourceAssignedCopyOne") << QLatin1String("scarceResourceAssignedCopyTwo"))
void tst_qdeclarativeecmascript::propertyChangeSlots()
{
// ensure that allowable property names are allowed and onPropertyNameChanged slots are generated correctly.
- QDeclarativeComponent component(&engine, TEST_FILE("changeslots/propertyChangeSlots.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("changeslots/propertyChangeSlots.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
delete object;
// ensure that invalid property names fail properly.
QTest::ignoreMessage(QtWarningMsg, "QDeclarativeComponent: Component is not ready");
- QDeclarativeComponent e1(&engine, TEST_FILE("changeslots/propertyChangeSlotErrors.1.qml"));
+ QDeclarativeComponent e1(&engine, testFileUrl("changeslots/propertyChangeSlotErrors.1.qml"));
QString expectedErrorString = e1.url().toString() + QLatin1String(":9:5: Cannot assign to non-existent property \"on_nameWithUnderscoreChanged\"");
QCOMPARE(e1.errors().at(0).toString(), expectedErrorString);
object = e1.create();
delete object;
QTest::ignoreMessage(QtWarningMsg, "QDeclarativeComponent: Component is not ready");
- QDeclarativeComponent e2(&engine, TEST_FILE("changeslots/propertyChangeSlotErrors.2.qml"));
+ QDeclarativeComponent e2(&engine, testFileUrl("changeslots/propertyChangeSlotErrors.2.qml"));
expectedErrorString = e2.url().toString() + QLatin1String(":9:5: Cannot assign to non-existent property \"on____nameWithUnderscoresChanged\"");
QCOMPARE(e2.errors().at(0).toString(), expectedErrorString);
object = e2.create();
delete object;
QTest::ignoreMessage(QtWarningMsg, "QDeclarativeComponent: Component is not ready");
- QDeclarativeComponent e3(&engine, TEST_FILE("changeslots/propertyChangeSlotErrors.3.qml"));
+ QDeclarativeComponent e3(&engine, testFileUrl("changeslots/propertyChangeSlotErrors.3.qml"));
expectedErrorString = e3.url().toString() + QLatin1String(":9:5: Cannot assign to non-existent property \"on$NameWithDollarsignChanged\"");
QCOMPARE(e3.errors().at(0).toString(), expectedErrorString);
object = e3.create();
delete object;
QTest::ignoreMessage(QtWarningMsg, "QDeclarativeComponent: Component is not ready");
- QDeclarativeComponent e4(&engine, TEST_FILE("changeslots/propertyChangeSlotErrors.4.qml"));
+ QDeclarativeComponent e4(&engine, testFileUrl("changeslots/propertyChangeSlotErrors.4.qml"));
expectedErrorString = e4.url().toString() + QLatin1String(":9:5: Cannot assign to non-existent property \"on_6NameWithUnderscoreNumberChanged\"");
QCOMPARE(e4.errors().at(0).toString(), expectedErrorString);
object = e4.create();
QTest::addColumn<QUrl>("qmlFile");
// valid
- QTest::newRow("non-bindable object subproperty changed") << TEST_FILE("propertyVar.1.qml");
- QTest::newRow("non-bindable object changed") << TEST_FILE("propertyVar.2.qml");
- QTest::newRow("primitive changed") << TEST_FILE("propertyVar.3.qml");
- QTest::newRow("javascript array modification") << TEST_FILE("propertyVar.4.qml");
- QTest::newRow("javascript map modification") << TEST_FILE("propertyVar.5.qml");
- QTest::newRow("javascript array assignment") << TEST_FILE("propertyVar.6.qml");
- QTest::newRow("javascript map assignment") << TEST_FILE("propertyVar.7.qml");
- QTest::newRow("literal property assignment") << TEST_FILE("propertyVar.8.qml");
- QTest::newRow("qobject property assignment") << TEST_FILE("propertyVar.9.qml");
+ QTest::newRow("non-bindable object subproperty changed") << testFileUrl("propertyVar.1.qml");
+ QTest::newRow("non-bindable object changed") << testFileUrl("propertyVar.2.qml");
+ QTest::newRow("primitive changed") << testFileUrl("propertyVar.3.qml");
+ QTest::newRow("javascript array modification") << testFileUrl("propertyVar.4.qml");
+ QTest::newRow("javascript map modification") << testFileUrl("propertyVar.5.qml");
+ QTest::newRow("javascript array assignment") << testFileUrl("propertyVar.6.qml");
+ QTest::newRow("javascript map assignment") << testFileUrl("propertyVar.7.qml");
+ QTest::newRow("literal property assignment") << testFileUrl("propertyVar.8.qml");
+ QTest::newRow("qobject property assignment") << testFileUrl("propertyVar.9.qml");
}
void tst_qdeclarativeecmascript::propertyVar()
// ensure that writing to and reading from a var property from cpp works as required.
// Literal values stored in var properties can be read and written as QVariants
// of a specific type, whereas object values are read as QVariantMaps.
- QDeclarativeComponent component(&engine, TEST_FILE("propertyVarCpp.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("propertyVarCpp.qml"));
object = component.create();
QVERIFY(object != 0);
// assign int to property var that currently has int assigned
{
// Referenced JS objects are not collected
{
- QDeclarativeComponent component(&engine, TEST_FILE("propertyVarOwnership.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("propertyVarOwnership.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
QCOMPARE(object->property("test").toBool(), false);
}
// Referenced JS objects are not collected
{
- QDeclarativeComponent component(&engine, TEST_FILE("propertyVarOwnership.2.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("propertyVarOwnership.2.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
QCOMPARE(object->property("test").toBool(), false);
}
// Qt objects are not collected until they've been dereferenced
{
- QDeclarativeComponent component(&engine, TEST_FILE("propertyVarOwnership.3.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("propertyVarOwnership.3.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
}
// Self reference does not prevent Qt object collection
{
- QDeclarativeComponent component(&engine, TEST_FILE("propertyVarOwnership.4.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("propertyVarOwnership.4.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
// The childObject has a reference to a different QObject. We want to ensure
// that the different item will not be cleaned up until required. IE, the childObject
// has implicit ownership of the constructed QObject.
- QDeclarativeComponent component(&engine, TEST_FILE("propertyVarImplicitOwnership.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("propertyVarImplicitOwnership.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
QMetaObject::invokeMethod(object, "assignCircular");
void tst_qdeclarativeecmascript::propertyVarReparent()
{
// ensure that nothing breaks if we re-parent objects
- QDeclarativeComponent component(&engine, TEST_FILE("propertyVar.reparent.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("propertyVar.reparent.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
QMetaObject::invokeMethod(object, "assignVarProp");
// sometimes reparenting can cause problems
// (eg, if the ctxt is collected, varproperties are no longer available)
// this test ensures that no crash occurs in that situation.
- QDeclarativeComponent component(&engine, TEST_FILE("propertyVar.reparent.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("propertyVar.reparent.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
QMetaObject::invokeMethod(object, "assignVarProp");
void tst_qdeclarativeecmascript::propertyVarCircular()
{
// enforce behaviour regarding circular references - ensure qdvmemo deletion.
- QDeclarativeComponent component(&engine, TEST_FILE("propertyVar.circular.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("propertyVar.circular.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
QMetaObject::invokeMethod(object, "assignCircular"); // cause assignment and gc
{
// track deletion of JS-owned parent item with Cpp-owned child
// where the child has a var property referencing its parent.
- QDeclarativeComponent component(&engine, TEST_FILE("propertyVar.circular.2.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("propertyVar.circular.2.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
QMetaObject::invokeMethod(object, "assignCircular");
// enforce behaviour regarding element inheritance - ensure handle disposal.
// The particular component under test here has a chain of references.
- QDeclarativeComponent component(&engine, TEST_FILE("propertyVar.inherit.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("propertyVar.inherit.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
QMetaObject::invokeMethod(object, "assignCircular"); // cause assignment and gc
// The particular component under test here does NOT have a chain of references; the
// only link between rootObject and childObject is that rootObject is the parent of childObject.
- QDeclarativeComponent component(&engine, TEST_FILE("propertyVar.circular.2.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("propertyVar.circular.2.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
QMetaObject::invokeMethod(object, "assignCircular");
// Ensure that QObject type conversion works on binding assignment
void tst_qdeclarativeecmascript::elementAssign()
{
- QDeclarativeComponent component(&engine, TEST_FILE("elementAssign.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("elementAssign.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
// QTBUG-12457
void tst_qdeclarativeecmascript::objectPassThroughSignals()
{
- QDeclarativeComponent component(&engine, TEST_FILE("objectsPassThroughSignals.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("objectsPassThroughSignals.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
// QTBUG-21626
void tst_qdeclarativeecmascript::objectConversion()
{
- QDeclarativeComponent component(&engine, TEST_FILE("objectConversion.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("objectConversion.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
// QTBUG-20242
void tst_qdeclarativeecmascript::booleanConversion()
{
- QDeclarativeComponent component(&engine, TEST_FILE("booleanConversion.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("booleanConversion.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
{
// Linear QObject reference
QDeclarativeEngine hrmEngine;
- QDeclarativeComponent component(&hrmEngine, TEST_FILE("handleReferenceManagement.object.1.qml"));
+ QDeclarativeComponent component(&hrmEngine, testFileUrl("handleReferenceManagement.object.1.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
CircularReferenceObject *cro = object->findChild<CircularReferenceObject*>("cro");
{
// Circular QObject reference
QDeclarativeEngine hrmEngine;
- QDeclarativeComponent component(&hrmEngine, TEST_FILE("handleReferenceManagement.object.2.qml"));
+ QDeclarativeComponent component(&hrmEngine, testFileUrl("handleReferenceManagement.object.2.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
CircularReferenceObject *cro = object->findChild<CircularReferenceObject*>("cro");
{
// Linear handle reference
QDeclarativeEngine hrmEngine;
- QDeclarativeComponent component(&hrmEngine, TEST_FILE("handleReferenceManagement.handle.1.qml"));
+ QDeclarativeComponent component(&hrmEngine, testFileUrl("handleReferenceManagement.handle.1.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
CircularReferenceHandle *crh = object->findChild<CircularReferenceHandle*>("crh");
{
// Circular handle reference
QDeclarativeEngine hrmEngine;
- QDeclarativeComponent component(&hrmEngine, TEST_FILE("handleReferenceManagement.handle.2.qml"));
+ QDeclarativeComponent component(&hrmEngine, testFileUrl("handleReferenceManagement.handle.2.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
CircularReferenceHandle *crh = object->findChild<CircularReferenceHandle*>("crh");
// multiple engine interaction - linear reference
QDeclarativeEngine hrmEngine1;
QDeclarativeEngine hrmEngine2;
- QDeclarativeComponent component1(&hrmEngine1, TEST_FILE("handleReferenceManagement.handle.1.qml"));
- QDeclarativeComponent component2(&hrmEngine2, TEST_FILE("handleReferenceManagement.handle.1.qml"));
+ QDeclarativeComponent component1(&hrmEngine1, testFileUrl("handleReferenceManagement.handle.1.qml"));
+ QDeclarativeComponent component2(&hrmEngine2, testFileUrl("handleReferenceManagement.handle.1.qml"));
QObject *object1 = component1.create();
QObject *object2 = component2.create();
QVERIFY(object1 != 0);
// multiple engine interaction - circular reference
QDeclarativeEngine hrmEngine1;
QDeclarativeEngine hrmEngine2;
- QDeclarativeComponent component1(&hrmEngine1, TEST_FILE("handleReferenceManagement.handle.1.qml"));
- QDeclarativeComponent component2(&hrmEngine2, TEST_FILE("handleReferenceManagement.handle.1.qml"));
+ QDeclarativeComponent component1(&hrmEngine1, testFileUrl("handleReferenceManagement.handle.1.qml"));
+ QDeclarativeComponent component2(&hrmEngine2, testFileUrl("handleReferenceManagement.handle.1.qml"));
QObject *object1 = component1.create();
QObject *object2 = component2.create();
QVERIFY(object1 != 0);
// multiple engine interaction - linear reference with engine deletion
QDeclarativeEngine *hrmEngine1 = new QDeclarativeEngine;
QDeclarativeEngine *hrmEngine2 = new QDeclarativeEngine;
- QDeclarativeComponent component1(hrmEngine1, TEST_FILE("handleReferenceManagement.handle.1.qml"));
- QDeclarativeComponent component2(hrmEngine2, TEST_FILE("handleReferenceManagement.handle.1.qml"));
+ QDeclarativeComponent component1(hrmEngine1, testFileUrl("handleReferenceManagement.handle.1.qml"));
+ QDeclarativeComponent component2(hrmEngine2, testFileUrl("handleReferenceManagement.handle.1.qml"));
QObject *object1 = component1.create();
QObject *object2 = component2.create();
QVERIFY(object1 != 0);
void tst_qdeclarativeecmascript::stringArg()
{
- QDeclarativeComponent component(&engine, TEST_FILE("stringArg.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("stringArg.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
QMetaObject::invokeMethod(object, "success");
QVERIFY(object->property("returnValue").toBool());
- QString w1 = TEST_FILE("stringArg.qml").toString() + QLatin1String(":45: Error: String.arg(): Invalid arguments");
+ QString w1 = testFileUrl("stringArg.qml").toString() + QLatin1String(":45: Error: String.arg(): Invalid arguments");
QTest::ignoreMessage(QtWarningMsg, w1.toAscii().constData());
QMetaObject::invokeMethod(object, "failure");
QVERIFY(object->property("returnValue").toBool());
void tst_qdeclarativeecmascript::readonlyDeclaration()
{
- QDeclarativeComponent component(&engine, TEST_FILE("readonlyDeclaration.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("readonlyDeclaration.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
void tst_qdeclarativeecmascript::sequenceConversionRead()
{
{
- QUrl qmlFile = TEST_FILE("sequenceConversion.read.qml");
+ QUrl qmlFile = testFileUrl("sequenceConversion.read.qml");
QDeclarativeComponent component(&engine, qmlFile);
QObject *object = component.create();
QVERIFY(object != 0);
}
{
- QUrl qmlFile = TEST_FILE("sequenceConversion.read.error.qml");
+ QUrl qmlFile = testFileUrl("sequenceConversion.read.error.qml");
QDeclarativeComponent component(&engine, qmlFile);
QObject *object = component.create();
QVERIFY(object != 0);
void tst_qdeclarativeecmascript::sequenceConversionWrite()
{
{
- QUrl qmlFile = TEST_FILE("sequenceConversion.write.qml");
+ QUrl qmlFile = testFileUrl("sequenceConversion.write.qml");
QDeclarativeComponent component(&engine, qmlFile);
QObject *object = component.create();
QVERIFY(object != 0);
}
{
- QUrl qmlFile = TEST_FILE("sequenceConversion.write.error.qml");
+ QUrl qmlFile = testFileUrl("sequenceConversion.write.error.qml");
QDeclarativeComponent component(&engine, qmlFile);
QObject *object = component.create();
QVERIFY(object != 0);
void tst_qdeclarativeecmascript::sequenceConversionArray()
{
// ensure that in JS the returned sequences act just like normal JS Arrays.
- QUrl qmlFile = TEST_FILE("sequenceConversion.array.qml");
+ QUrl qmlFile = testFileUrl("sequenceConversion.array.qml");
QDeclarativeComponent component(&engine, qmlFile);
QObject *object = component.create();
QVERIFY(object != 0);
{
// ensure that sequence conversion operations work correctly in a worker thread
// and that serialisation between the main and worker thread succeeds.
- QUrl qmlFile = TEST_FILE("sequenceConversion.threads.qml");
+ QUrl qmlFile = testFileUrl("sequenceConversion.threads.qml");
QDeclarativeComponent component(&engine, qmlFile);
QObject *object = component.create();
QVERIFY(object != 0);
void tst_qdeclarativeecmascript::sequenceConversionBindings()
{
{
- QUrl qmlFile = TEST_FILE("sequenceConversion.bindings.qml");
+ QUrl qmlFile = testFileUrl("sequenceConversion.bindings.qml");
QDeclarativeComponent component(&engine, qmlFile);
QObject *object = component.create();
QVERIFY(object != 0);
}
{
- QUrl qmlFile = TEST_FILE("sequenceConversion.bindings.error.qml");
+ QUrl qmlFile = testFileUrl("sequenceConversion.bindings.error.qml");
QString warning = QString(QLatin1String("%1:17: Unable to assign QList<int> to QList<bool>")).arg(qmlFile.toString());
QTest::ignoreMessage(QtWarningMsg, warning.toAscii().constData());
QDeclarativeComponent component(&engine, qmlFile);
void tst_qdeclarativeecmascript::sequenceConversionCopy()
{
- QUrl qmlFile = TEST_FILE("sequenceConversion.copy.qml");
+ QUrl qmlFile = testFileUrl("sequenceConversion.copy.qml");
QDeclarativeComponent component(&engine, qmlFile);
QObject *object = component.create();
QVERIFY(object != 0);
{
// test binding array to sequence type property
{
- QDeclarativeComponent component(&engine, TEST_FILE("assignSequenceTypes.1.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("assignSequenceTypes.1.qml"));
MySequenceConversionObject *object = qobject_cast<MySequenceConversionObject *>(component.create());
QVERIFY(object != 0);
QCOMPARE(object->intListProperty(), (QList<int>() << 1 << 2));
// test binding literal to sequence type property
{
- QDeclarativeComponent component(&engine, TEST_FILE("assignSequenceTypes.2.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("assignSequenceTypes.2.qml"));
MySequenceConversionObject *object = qobject_cast<MySequenceConversionObject *>(component.create());
QVERIFY(object != 0);
QCOMPARE(object->intListProperty(), (QList<int>() << 1));
// test binding single value to sequence type property
{
- QDeclarativeComponent component(&engine, TEST_FILE("assignSequenceTypes.3.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("assignSequenceTypes.3.qml"));
MySequenceConversionObject *object = qobject_cast<MySequenceConversionObject *>(component.create());
QVERIFY(object != 0);
QCOMPARE(object->intListProperty(), (QList<int>() << 1));
QCOMPARE(object->qrealListProperty(), (QList<qreal>() << 1.1));
QCOMPARE(object->boolListProperty(), (QList<bool>() << false));
- QCOMPARE(object->urlListProperty(), (QList<QUrl>() << QUrl(TEST_FILE("example.html"))));
+ QCOMPARE(object->urlListProperty(), (QList<QUrl>() << QUrl(testFileUrl("example.html"))));
delete object;
}
// test assigning array to sequence type property in js function
{
- QDeclarativeComponent component(&engine, TEST_FILE("assignSequenceTypes.4.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("assignSequenceTypes.4.qml"));
MySequenceConversionObject *object = qobject_cast<MySequenceConversionObject *>(component.create());
QVERIFY(object != 0);
QCOMPARE(object->intListProperty(), (QList<int>() << 1 << 2));
// test assigning literal to sequence type property in js function
{
- QDeclarativeComponent component(&engine, TEST_FILE("assignSequenceTypes.5.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("assignSequenceTypes.5.qml"));
MySequenceConversionObject *object = qobject_cast<MySequenceConversionObject *>(component.create());
QVERIFY(object != 0);
QCOMPARE(object->intListProperty(), (QList<int>() << 1));
// test assigning single value to sequence type property in js function
{
- QDeclarativeComponent component(&engine, TEST_FILE("assignSequenceTypes.6.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("assignSequenceTypes.6.qml"));
MySequenceConversionObject *object = qobject_cast<MySequenceConversionObject *>(component.create());
QVERIFY(object != 0);
QCOMPARE(object->intListProperty(), (QList<int>() << 1));
QCOMPARE(object->qrealListProperty(), (QList<qreal>() << 1.1));
QCOMPARE(object->boolListProperty(), (QList<bool>() << false));
- QCOMPARE(object->urlListProperty(), (QList<QUrl>() << QUrl(TEST_FILE("example.html"))));
+ QCOMPARE(object->urlListProperty(), (QList<QUrl>() << QUrl(testFileUrl("example.html"))));
delete object;
}
// test QList<QUrl> literal assignment and binding assignment causes url resolution when required
{
- QDeclarativeComponent component(&engine, TEST_FILE("assignSequenceTypes.7.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("assignSequenceTypes.7.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
MySequenceConversionObject *msco1 = object->findChild<MySequenceConversionObject *>(QLatin1String("msco1"));
MySequenceConversionObject *msco4 = object->findChild<MySequenceConversionObject *>(QLatin1String("msco4"));
MySequenceConversionObject *msco5 = object->findChild<MySequenceConversionObject *>(QLatin1String("msco5"));
QVERIFY(msco1 != 0 && msco2 != 0 && msco3 != 0 && msco4 != 0 && msco5 != 0);
- QCOMPARE(msco1->urlListProperty(), (QList<QUrl>() << QUrl(TEST_FILE("example.html"))));
- QCOMPARE(msco2->urlListProperty(), (QList<QUrl>() << QUrl(TEST_FILE("example.html"))));
- QCOMPARE(msco3->urlListProperty(), (QList<QUrl>() << QUrl(TEST_FILE("example.html")) << QUrl(TEST_FILE("example2.html"))));
- QCOMPARE(msco4->urlListProperty(), (QList<QUrl>() << QUrl(TEST_FILE("example.html")) << QUrl(TEST_FILE("example2.html"))));
- QCOMPARE(msco5->urlListProperty(), (QList<QUrl>() << QUrl(TEST_FILE("example.html")) << QUrl(TEST_FILE("example2.html"))));
+ QCOMPARE(msco1->urlListProperty(), (QList<QUrl>() << QUrl(testFileUrl("example.html"))));
+ QCOMPARE(msco2->urlListProperty(), (QList<QUrl>() << QUrl(testFileUrl("example.html"))));
+ QCOMPARE(msco3->urlListProperty(), (QList<QUrl>() << QUrl(testFileUrl("example.html")) << QUrl(testFileUrl("example2.html"))));
+ QCOMPARE(msco4->urlListProperty(), (QList<QUrl>() << QUrl(testFileUrl("example.html")) << QUrl(testFileUrl("example2.html"))));
+ QCOMPARE(msco5->urlListProperty(), (QList<QUrl>() << QUrl(testFileUrl("example.html")) << QUrl(testFileUrl("example2.html"))));
delete object;
}
}
// Regressed with: df1788b4dbbb2826ae63f26bdf166342595343f4
void tst_qdeclarativeecmascript::nullObjectBinding()
{
- QDeclarativeComponent component(&engine, TEST_FILE("nullObjectBinding.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("nullObjectBinding.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
void tst_qdeclarativeecmascript::deletedEngine()
{
QDeclarativeEngine *engine = new QDeclarativeEngine;
- QDeclarativeComponent component(engine, TEST_FILE("deletedEngine.qml"));
+ QDeclarativeComponent component(engine, testFileUrl("deletedEngine.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
// Test the crashing part of QTBUG-9705
void tst_qdeclarativeecmascript::libraryScriptAssert()
{
- QDeclarativeComponent component(&engine, TEST_FILE("libraryScriptAssert.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("libraryScriptAssert.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
void tst_qdeclarativeecmascript::variantsAssignedUndefined()
{
- QDeclarativeComponent component(&engine, TEST_FILE("variantsAssignedUndefined.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("variantsAssignedUndefined.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
void tst_qdeclarativeecmascript::qtbug_9792()
{
- QDeclarativeComponent component(&engine, TEST_FILE("qtbug_9792.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("qtbug_9792.qml"));
QDeclarativeContext *context = new QDeclarativeContext(engine.rootContext());
// Verifies that QDeclarativeGuard<>s used in the vmemetaobject are cleaned correctly
void tst_qdeclarativeecmascript::qtcreatorbug_1289()
{
- QDeclarativeComponent component(&engine, TEST_FILE("qtcreatorbug_1289.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("qtcreatorbug_1289.qml"));
QObject *o = component.create();
QVERIFY(o != 0);
void tst_qdeclarativeecmascript::noSpuriousWarningsAtShutdown()
{
{
- QDeclarativeComponent component(&engine, TEST_FILE("noSpuriousWarningsAtShutdown.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("noSpuriousWarningsAtShutdown.qml"));
QObject *o = component.create();
{
- QDeclarativeComponent component(&engine, TEST_FILE("noSpuriousWarningsAtShutdown.2.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("noSpuriousWarningsAtShutdown.2.qml"));
QObject *o = component.create();
void tst_qdeclarativeecmascript::canAssignNullToQObject()
{
{
- QDeclarativeComponent component(&engine, TEST_FILE("canAssignNullToQObject.1.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("canAssignNullToQObject.1.qml"));
MyQmlObject *o = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(o != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("canAssignNullToQObject.2.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("canAssignNullToQObject.2.qml"));
MyQmlObject *o = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(o != 0);
void tst_qdeclarativeecmascript::functionAssignment_fromBinding()
{
- QDeclarativeComponent component(&engine, TEST_FILE("functionAssignment.1.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("functionAssignment.1.qml"));
QString url = component.url().toString();
QString warning = url + ":4: Unable to assign a function to a property.";
{
QFETCH(QString, triggerProperty);
- QDeclarativeComponent component(&engine, TEST_FILE("functionAssignment.2.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("functionAssignment.2.qml"));
QVERIFY2(component.errorString().isEmpty(), qPrintable(component.errorString()));
MyQmlObject *o = qobject_cast<MyQmlObject *>(component.create());
void tst_qdeclarativeecmascript::functionAssignmentfromJS_invalid()
{
- QDeclarativeComponent component(&engine, TEST_FILE("functionAssignment.2.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("functionAssignment.2.qml"));
QVERIFY2(component.errorString().isEmpty(), qPrintable(component.errorString()));
MyQmlObject *o = qobject_cast<MyQmlObject *>(component.create());
void tst_qdeclarativeecmascript::eval()
{
- QDeclarativeComponent component(&engine, TEST_FILE("eval.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("eval.qml"));
QObject *o = component.create();
QVERIFY(o != 0);
void tst_qdeclarativeecmascript::function()
{
- QDeclarativeComponent component(&engine, TEST_FILE("function.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("function.qml"));
QObject *o = component.create();
QVERIFY(o != 0);
{
// Non-library relative include
{
- QDeclarativeComponent component(&engine, TEST_FILE("include.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("include.qml"));
QObject *o = component.create();
QVERIFY(o != 0);
// Library relative include
{
- QDeclarativeComponent component(&engine, TEST_FILE("include_shared.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("include_shared.qml"));
QObject *o = component.create();
QVERIFY(o != 0);
// Callback
{
- QDeclarativeComponent component(&engine, TEST_FILE("include_callback.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("include_callback.qml"));
QObject *o = component.create();
QVERIFY(o != 0);
// Including file with ".pragma library"
{
- QDeclarativeComponent component(&engine, TEST_FILE("include_pragma.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("include_pragma.qml"));
QObject *o = component.create();
QVERIFY(o != 0);
QCOMPARE(o->property("test1").toInt(), 100);
{
TestHTTPServer server(8111);
QVERIFY(server.isValid());
- server.serveDirectory(TESTDATA(""));
+ server.serveDirectory(dataDirectory());
- QDeclarativeComponent component(&engine, TEST_FILE("include_remote.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("include_remote.qml"));
QObject *o = component.create();
QVERIFY(o != 0);
{
TestHTTPServer server(8111);
QVERIFY(server.isValid());
- server.serveDirectory(TESTDATA(""));
+ server.serveDirectory(dataDirectory());
- QDeclarativeComponent component(&engine, TEST_FILE("include_remote_missing.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("include_remote_missing.qml"));
QObject *o = component.create();
QVERIFY(o != 0);
void tst_qdeclarativeecmascript::signalHandlers()
{
- QDeclarativeComponent component(&engine, TEST_FILE("signalHandlers.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("signalHandlers.qml"));
QObject *o = component.create();
QVERIFY(o != 0);
void tst_qdeclarativeecmascript::qtbug_10696()
{
- QDeclarativeComponent component(&engine, TEST_FILE("qtbug_10696.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("qtbug_10696.qml"));
QObject *o = component.create();
QVERIFY(o != 0);
delete o;
void tst_qdeclarativeecmascript::qtbug_11606()
{
- QDeclarativeComponent component(&engine, TEST_FILE("qtbug_11606.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("qtbug_11606.qml"));
QObject *o = component.create();
QVERIFY(o != 0);
QCOMPARE(o->property("test").toBool(), true);
void tst_qdeclarativeecmascript::qtbug_11600()
{
- QDeclarativeComponent component(&engine, TEST_FILE("qtbug_11600.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("qtbug_11600.qml"));
QObject *o = component.create();
QVERIFY(o != 0);
QCOMPARE(o->property("test").toBool(), true);
void tst_qdeclarativeecmascript::qtbug_21864()
{
- QDeclarativeComponent component(&engine, TEST_FILE("qtbug_21864.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("qtbug_21864.qml"));
QObject *o = component.create();
QVERIFY(o != 0);
QCOMPARE(o->property("test").toBool(), true);
// Reading and writing non-scriptable properties should fail
void tst_qdeclarativeecmascript::nonscriptable()
{
- QDeclarativeComponent component(&engine, TEST_FILE("nonscriptable.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("nonscriptable.qml"));
QObject *o = component.create();
QVERIFY(o != 0);
QCOMPARE(o->property("readOk").toBool(), true);
// deleteLater() should not be callable from QML
void tst_qdeclarativeecmascript::deleteLater()
{
- QDeclarativeComponent component(&engine, TEST_FILE("deleteLater.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("deleteLater.qml"));
QObject *o = component.create();
QVERIFY(o != 0);
QCOMPARE(o->property("test").toBool(), true);
void tst_qdeclarativeecmascript::in()
{
- QDeclarativeComponent component(&engine, TEST_FILE("in.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("in.qml"));
QObject *o = component.create();
QVERIFY(o != 0);
QCOMPARE(o->property("test1").toBool(), true);
void tst_qdeclarativeecmascript::typeOf()
{
- QDeclarativeComponent component(&engine, TEST_FILE("typeOf.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("typeOf.qml"));
// These warnings should not happen once QTBUG-21864 is fixed
QString warning1 = component.url().toString() + QLatin1String(":16: Error: Cannot assign [undefined] to QString");
void tst_qdeclarativeecmascript::sharedAttachedObject()
{
- QDeclarativeComponent component(&engine, TEST_FILE("sharedAttachedObject.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("sharedAttachedObject.qml"));
QObject *o = component.create();
QVERIFY(o != 0);
QCOMPARE(o->property("test1").toBool(), true);
// QTBUG-13999
void tst_qdeclarativeecmascript::objectName()
{
- QDeclarativeComponent component(&engine, TEST_FILE("objectName.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("objectName.qml"));
QObject *o = component.create();
QVERIFY(o != 0);
void tst_qdeclarativeecmascript::writeRemovesBinding()
{
- QDeclarativeComponent component(&engine, TEST_FILE("writeRemovesBinding.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("writeRemovesBinding.qml"));
QObject *o = component.create();
QVERIFY(o != 0);
// Test bindings assigned to alias properties actually assign to the alias' target
void tst_qdeclarativeecmascript::aliasBindingsAssignCorrectly()
{
- QDeclarativeComponent component(&engine, TEST_FILE("aliasBindingsAssignCorrectly.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("aliasBindingsAssignCorrectly.qml"));
QObject *o = component.create();
QVERIFY(o != 0);
void tst_qdeclarativeecmascript::aliasBindingsOverrideTarget()
{
{
- QDeclarativeComponent component(&engine, TEST_FILE("aliasBindingsOverrideTarget.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("aliasBindingsOverrideTarget.qml"));
QObject *o = component.create();
QVERIFY(o != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("aliasBindingsOverrideTarget.2.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("aliasBindingsOverrideTarget.2.qml"));
QObject *o = component.create();
QVERIFY(o != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("aliasBindingsOverrideTarget.3.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("aliasBindingsOverrideTarget.3.qml"));
QObject *o = component.create();
QVERIFY(o != 0);
void tst_qdeclarativeecmascript::aliasWritesOverrideBindings()
{
{
- QDeclarativeComponent component(&engine, TEST_FILE("aliasWritesOverrideBindings.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("aliasWritesOverrideBindings.qml"));
QObject *o = component.create();
QVERIFY(o != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("aliasWritesOverrideBindings.2.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("aliasWritesOverrideBindings.2.qml"));
QObject *o = component.create();
QVERIFY(o != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("aliasWritesOverrideBindings.3.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("aliasWritesOverrideBindings.3.qml"));
QObject *o = component.create();
QVERIFY(o != 0);
// QTBUG-20200
void tst_qdeclarativeecmascript::aliasToCompositeElement()
{
- QDeclarativeComponent component(&engine, TEST_FILE("aliasToCompositeElement.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("aliasToCompositeElement.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
void tst_qdeclarativeecmascript::qtbug_20344()
{
- QDeclarativeComponent component(&engine, TEST_FILE("qtbug_20344.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("qtbug_20344.qml"));
QString warning = component.url().toString() + ":5: Error: Exception thrown from within QObject slot";
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
void tst_qdeclarativeecmascript::revisionErrors()
{
{
- QDeclarativeComponent component(&engine, TEST_FILE("metaobjectRevisionErrors.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("metaobjectRevisionErrors.qml"));
QString url = component.url().toString();
QString warning1 = url + ":8: ReferenceError: Can't find variable: prop2";
delete object;
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("metaobjectRevisionErrors2.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("metaobjectRevisionErrors2.qml"));
QString url = component.url().toString();
// MyRevisionedSubclass 1.0 uses MyRevisionedClass revision 0
delete object;
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("metaobjectRevisionErrors3.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("metaobjectRevisionErrors3.qml"));
QString url = component.url().toString();
// MyRevisionedSubclass 1.1 uses MyRevisionedClass revision 1
void tst_qdeclarativeecmascript::revision()
{
{
- QDeclarativeComponent component(&engine, TEST_FILE("metaobjectRevision.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("metaobjectRevision.qml"));
QString url = component.url().toString();
MyRevisionedClass *object = qobject_cast<MyRevisionedClass *>(component.create());
delete object;
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("metaobjectRevision2.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("metaobjectRevision2.qml"));
QString url = component.url().toString();
MyRevisionedClass *object = qobject_cast<MyRevisionedClass *>(component.create());
delete object;
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("metaobjectRevision3.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("metaobjectRevision3.qml"));
QString url = component.url().toString();
MyRevisionedClass *object = qobject_cast<MyRevisionedClass *>(component.create());
}
// Test that non-root classes can resolve revisioned methods
{
- QDeclarativeComponent component(&engine, TEST_FILE("metaobjectRevision4.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("metaobjectRevision4.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
void tst_qdeclarativeecmascript::realToInt()
{
- QDeclarativeComponent component(&engine, TEST_FILE("realToInt.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("realToInt.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
QVERIFY(object != 0);
void tst_qdeclarativeecmascript::urlProperty()
{
{
- QDeclarativeComponent component(&engine, TEST_FILE("urlProperty.1.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("urlProperty.1.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject*>(component.create());
QVERIFY(object != 0);
object->setStringProperty("http://qt-project.org");
void tst_qdeclarativeecmascript::dynamicString()
{
- QDeclarativeComponent component(&engine, TEST_FILE("dynamicString.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("dynamicString.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
QCOMPARE(object->property("stringProperty").toString(),
void tst_qdeclarativeecmascript::automaticSemicolon()
{
- QDeclarativeComponent component(&engine, TEST_FILE("automaticSemicolon.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("automaticSemicolon.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
}
void tst_qdeclarativeecmascript::unaryExpression()
{
- QDeclarativeComponent component(&engine, TEST_FILE("unaryExpression.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("unaryExpression.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
}
// Makes sure that a binding isn't double re-evaluated when it depends on the same variable twice
void tst_qdeclarativeecmascript::doubleEvaluate()
{
- QDeclarativeComponent component(&engine, TEST_FILE("doubleEvaluate.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("doubleEvaluate.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
WriteCounter *wc = qobject_cast<WriteCounter *>(object);
void tst_qdeclarativeecmascript::nonNotifyable()
{
QV4Compiler::enableV4(false);
- QDeclarativeComponent component(&engine, TEST_FILE("nonNotifyable.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("nonNotifyable.qml"));
QV4Compiler::enableV4(true);
QtMsgHandler old = qInstallMsgHandler(captureMsgHandler);
void tst_qdeclarativeecmascript::forInLoop()
{
- QDeclarativeComponent component(&engine, TEST_FILE("forInLoop.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("forInLoop.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
// An object the binding depends on is deleted while the binding is still running
void tst_qdeclarativeecmascript::deleteWhileBindingRunning()
{
- QDeclarativeComponent component(&engine, TEST_FILE("deleteWhileBindingRunning.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("deleteWhileBindingRunning.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
delete object;
object.setStringProperty(QLatin1String("Please work correctly"));
engine.rootContext()->setContextProperty("contextProp", &object);
- QDeclarativeComponent component(&engine, TEST_FILE("qtbug_22679.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("qtbug_22679.qml"));
qRegisterMetaType<QList<QDeclarativeError> >("QList<QDeclarativeError>");
QSignalSpy warningsSpy(&engine, SIGNAL(warnings(QList<QDeclarativeError>)));
fileName += QLatin1String(".library");
fileName += QLatin1String(".qml");
- QDeclarativeComponent component(&engine, TEST_FILE(fileName));
+ QDeclarativeComponent component(&engine, testFileUrl(fileName));
QString url = component.url().toString();
QString warning1 = url.left(url.length()-3) + QLatin1String("js:4: SyntaxError: Unexpected token )");
QString warning2 = url + QLatin1String(":5: TypeError: Object [object Object] has no method 'func'");
void tst_qdeclarativeecmascript::switchStatement()
{
{
- QDeclarativeComponent component(&engine, TEST_FILE("switchStatement.1.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("switchStatement.1.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("switchStatement.2.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("switchStatement.2.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("switchStatement.3.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("switchStatement.3.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("switchStatement.4.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("switchStatement.4.qml"));
QString warning = component.url().toString() + ":4: Unable to assign [undefined] to int";
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("switchStatement.5.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("switchStatement.5.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("switchStatement.6.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("switchStatement.6.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
void tst_qdeclarativeecmascript::withStatement()
{
{
- QDeclarativeComponent component(&engine, TEST_FILE("withStatement.1.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("withStatement.1.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
void tst_qdeclarativeecmascript::tryStatement()
{
{
- QDeclarativeComponent component(&engine, TEST_FILE("tryStatement.1.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("tryStatement.1.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("tryStatement.2.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("tryStatement.2.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("tryStatement.3.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("tryStatement.3.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("tryStatement.4.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("tryStatement.4.qml"));
MyQmlObject *object = qobject_cast<MyQmlObject *>(component.create());
QVERIFY(object != 0);
CONFIG += testcase
TARGET = tst_qdeclarativeerror
-SOURCES += tst_qdeclarativeerror.cpp
+SOURCES += tst_qdeclarativeerror.cpp \
+ ../../shared/util.cpp
+HEADERS += ../../shared/util.h
macx:CONFIG -= app_bundle
CONFIG += parallel_test
#include <QDebug>
#include "../../shared/util.h"
-class tst_qdeclarativeerror : public QObject
+class tst_qdeclarativeerror : public QDeclarativeDataTest
{
Q_OBJECT
private slots:
}
{
- QUrl url(QUrl::fromLocalFile(TESTDATA("")).resolved(QUrl("test.txt")));
+ QUrl url(dataDirectoryUrl().resolved(QUrl("test.txt")));
QDeclarativeError error;
error.setUrl(url);
error.setDescription("An Error");
}
{
- QUrl url(QUrl::fromLocalFile(TESTDATA("")).resolved(QUrl("foo.txt")));
+ QUrl url(dataDirectoryUrl().resolved(QUrl("foo.txt")));
QDeclarativeError error;
error.setUrl(url);
error.setDescription("An Error");
TARGET = tst_qdeclarativeexpression
macx:CONFIG -= app_bundle
-SOURCES += tst_qdeclarativeexpression.cpp
+SOURCES += tst_qdeclarativeexpression.cpp \
+ ../../shared/util.cpp
+HEADERS += ../../shared/util.h
testDataFiles.files = data
testDataFiles.path = .
#include <QtDeclarative/qdeclarativescriptstring.h>
#include "../../shared/util.h"
-class tst_qdeclarativeexpression : public QObject
+class tst_qdeclarativeexpression : public QDeclarativeDataTest
{
Q_OBJECT
public:
qmlRegisterType<TestObject>("Test", 1, 0, "TestObject");
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("scriptString.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("scriptString.qml"));
TestObject *testObj = qobject_cast<TestObject*>(c.create());
QVERIFY(testObj != 0);
TARGET = tst_qdeclarativefolderlistmodel
macx:CONFIG -= app_bundle
-SOURCES += tst_qdeclarativefolderlistmodel.cpp
+SOURCES += tst_qdeclarativefolderlistmodel.cpp \
+ ../../shared/util.cpp
+HEADERS += ../../shared/util.h
testDataFiles.files = data
testDataFiles.path = .
const int FilePathRole = Qt::UserRole+2;
enum SortField { Unsorted, Name, Time, Size, Type };
-class tst_qdeclarativefolderlistmodel : public QObject
+class tst_qdeclarativefolderlistmodel : public QDeclarativeDataTest
{
Q_OBJECT
public:
void tst_qdeclarativefolderlistmodel::basicProperties()
{
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("basic.qml")));
+ QDeclarativeComponent component(&engine, testFileUrl("basic.qml"));
checkNoErrors(component);
QAbstractListModel *flm = qobject_cast<QAbstractListModel*>(component.create());
QVERIFY(flm != 0);
- flm->setProperty("folder",QUrl::fromLocalFile(TESTDATA("")));
+ flm->setProperty("folder", dataDirectoryUrl());
QTRY_COMPARE(flm->property("count").toInt(),4); // wait for refresh
- QCOMPARE(flm->property("folder").toUrl(), QUrl::fromLocalFile(TESTDATA("")));
- QCOMPARE(flm->property("parentFolder").toUrl(), QUrl::fromLocalFile(QDir(TESTDATA("..")).canonicalPath()));
+ QCOMPARE(flm->property("folder").toUrl(), dataDirectoryUrl());
+ QCOMPARE(flm->property("parentFolder").toUrl(), QUrl::fromLocalFile(QDir(directory()).canonicalPath()));
QCOMPARE(flm->property("sortField").toInt(), int(Name));
QCOMPARE(flm->property("nameFilters").toStringList(), QStringList() << "*.qml");
QCOMPARE(flm->property("sortReversed").toBool(), false);
void tst_qdeclarativefolderlistmodel::resetFiltering()
{
// see QTBUG-17837
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("resetFiltering.qml")));
+ QDeclarativeComponent component(&engine, testFileUrl("resetFiltering.qml"));
checkNoErrors(component);
QAbstractListModel *flm = qobject_cast<QAbstractListModel*>(component.create());
connect(flm, SIGNAL(rowsRemoved(const QModelIndex&,int,int)),
this, SLOT(removed(const QModelIndex&,int,int)));
- flm->setProperty("folder",QUrl::fromLocalFile(TESTDATA("resetfiltering")));
+ flm->setProperty("folder", testFileUrl("resetfiltering"));
QTRY_COMPARE(flm->property("count").toInt(),1); // should just be "test.txt" visible
int count = flm->rowCount();
QCOMPARE(removeStart, 0);
QCOMPARE(removeEnd, count-1);
- flm->setProperty("folder",QUrl::fromLocalFile(TESTDATA("resetfiltering/innerdir")));
+ flm->setProperty("folder", testFileUrl("resetfiltering/innerdir"));
QTRY_COMPARE(flm->property("count").toInt(),1); // should just be "test2.txt" visible
count = flm->rowCount();
QCOMPARE(removeStart, 0);
QCOMPARE(removeEnd, count-1);
- flm->setProperty("folder",QUrl::fromLocalFile(TESTDATA("resetfiltering")));
+ flm->setProperty("folder", testFileUrl("resetfiltering"));
QTRY_COMPARE(flm->property("count").toInt(),1); // should just be "test.txt" visible
count = flm->rowCount();
QCOMPARE(removeStart, 0);
void tst_qdeclarativefolderlistmodel::refresh()
{
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("basic.qml")));
+ QDeclarativeComponent component(&engine, testFileUrl("basic.qml"));
checkNoErrors(component);
QAbstractListModel *flm = qobject_cast<QAbstractListModel*>(component.create());
QVERIFY(flm != 0);
- flm->setProperty("folder",QUrl::fromLocalFile(TESTDATA("")));
+ flm->setProperty("folder", dataDirectoryUrl());
QTRY_COMPARE(flm->property("count").toInt(),4); // wait for refresh
int count = flm->rowCount();
macx:CONFIG -= app_bundle
SOURCES += tst_qdeclarativeincubator.cpp \
- testtypes.cpp
-HEADERS += testtypes.h
+ testtypes.cpp \
+ ../../shared/util.cpp
+
+HEADERS += testtypes.h \
+ ../../shared/util.h
testDataFiles.files = data
testDataFiles.path = .
#include <QDeclarativeIncubator>
#include "../../shared/util.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_qdeclarativeincubator : public QObject
+class tst_qdeclarativeincubator : public QDeclarativeDataTest
{
Q_OBJECT
public:
QVERIFY(!component.isError()); \
QVERIFY(component.errors().isEmpty()); \
} else { \
- QFile file(TESTDATA(errorfile)); \
+ QFile file(QDeclarativeDataTest::instance()->testFile(errorfile)); \
QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text)); \
QByteArray data = file.readAll(); \
file.close(); \
void tst_qdeclarativeincubator::initTestCase()
{
+ QDeclarativeDataTest::initTestCase();
registerTypes();
engine.setIncubationController(&controller);
}
{
SelfRegisteringType::clearMe();
- QDeclarativeComponent component(&engine, TEST_FILE("objectDeleted.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("objectDeleted.qml"));
QVERIFY(component.isReady());
QDeclarativeIncubator incubator;
{
SelfRegisteringType::clearMe();
- QDeclarativeComponent component(&engine, TEST_FILE("clear.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("clear.qml"));
QVERIFY(component.isReady());
// Clear in null state
// All incubators should behave synchronously when there is no controller
QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, TEST_FILE("noIncubationController.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("noIncubationController.qml"));
QVERIFY(component.isReady());
void tst_qdeclarativeincubator::forceCompletion()
{
- QDeclarativeComponent component(&engine, TEST_FILE("forceCompletion.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("forceCompletion.qml"));
QVERIFY(component.isReady());
{
void tst_qdeclarativeincubator::setInitialState()
{
- QDeclarativeComponent component(&engine, TEST_FILE("setInitialState.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("setInitialState.qml"));
QVERIFY(component.isReady());
struct MyIncubator : public QDeclarativeIncubator
CompletionRegisteringType::clearMe();
SelfRegisteringType::clearMe();
- QDeclarativeComponent component(&engine, TEST_FILE("clearDuringCompletion.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("clearDuringCompletion.qml"));
QVERIFY(component.isReady());
QDeclarativeIncubator incubator;
void tst_qdeclarativeincubator::objectDeletionAfterInit()
{
- QDeclarativeComponent component(&engine, TEST_FILE("clear.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("clear.qml"));
QVERIFY(component.isReady());
struct MyIncubator : public QDeclarativeIncubator
void start()
{
incubator = new MyIncubator(QDeclarativeIncubator::Synchronous, this);
- component = new QDeclarativeComponent(engine, TEST_FILE("recursiveClear.1.qml"));
+ component = new QDeclarativeComponent(engine, QDeclarativeDataTest::instance()->testFileUrl("recursiveClear.1.qml"));
component->create(*incubator);
}
void switchIt() {
component->deleteLater();
incubator->clear();
- component = new QDeclarativeComponent(engine, TEST_FILE("recursiveClear.2.qml"));
+ component = new QDeclarativeComponent(engine, QDeclarativeDataTest::instance()->testFileUrl("recursiveClear.2.qml"));
component->create(*incubator);
}
};
};
{
- QDeclarativeComponent component(&engine, TEST_FILE("statusChanged.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("statusChanged.qml"));
QVERIFY(component.isReady());
MyIncubator incubator(QDeclarativeIncubator::Synchronous);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("statusChanged.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("statusChanged.qml"));
QVERIFY(component.isReady());
MyIncubator incubator(QDeclarativeIncubator::Asynchronous);
}
{
- QDeclarativeComponent component2(&engine, TEST_FILE("statusChanged.nested.qml"));
+ QDeclarativeComponent component2(&engine, testFileUrl("statusChanged.nested.qml"));
QVERIFY(component2.isReady());
MyIncubator incubator(QDeclarativeIncubator::Asynchronous);
{
// Asynchronous if nested within a finalized context behaves synchronously
{
- QDeclarativeComponent component(&engine, TEST_FILE("asynchronousIfNested.1.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("asynchronousIfNested.1.qml"));
QVERIFY(component.isReady());
QObject *object = component.create();
{
SelfRegisteringType::clearMe();
- QDeclarativeComponent component(&engine, TEST_FILE("asynchronousIfNested.2.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("asynchronousIfNested.2.qml"));
QVERIFY(component.isReady());
QDeclarativeIncubator incubator;
{
SelfRegisteringType::clearMe();
- QDeclarativeComponent component(&engine, TEST_FILE("asynchronousIfNested.3.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("asynchronousIfNested.3.qml"));
QVERIFY(component.isReady());
struct CallbackData {
static void callback(CallbackRegisteringType *o, void *data) {
CallbackData *d = (CallbackData *)data;
- QDeclarativeComponent c(d->engine, TEST_FILE("asynchronousIfNested.1.qml"));
+ QDeclarativeComponent c(d->engine, QDeclarativeDataTest::instance()->testFileUrl("asynchronousIfNested.1.qml"));
if (!c.isReady()) return;
QDeclarativeIncubator incubator(QDeclarativeIncubator::AsynchronousIfNested);
void tst_qdeclarativeincubator::nestedComponent()
{
- QDeclarativeComponent component(&engine, TEST_FILE("nestedComponent.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("nestedComponent.qml"));
QVERIFY(component.isReady());
QObject *object = component.create();
{
SelfRegisteringType::clearMe();
- QDeclarativeComponent component(&engine, TEST_FILE("chainedAsynchronousIfNested.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("chainedAsynchronousIfNested.qml"));
QVERIFY(component.isReady());
QDeclarativeIncubator incubator(QDeclarativeIncubator::Asynchronous);
{
SelfRegisteringType::clearMe();
- QDeclarativeComponent component(&engine, TEST_FILE("chainInCompletion.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("chainInCompletion.qml"));
QVERIFY(component.isReady());
- QDeclarativeComponent c1(&engine, TEST_FILE("chainedAsynchronousIfNested.qml"));
+ QDeclarativeComponent c1(&engine, testFileUrl("chainedAsynchronousIfNested.qml"));
QVERIFY(c1.isReady());
struct MyIncubator : public QDeclarativeIncubator {
};
{
- QDeclarativeComponent component(&engine, TEST_FILE("selfDelete.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("selfDelete.qml"));
#define DELETE_TEST(status, mode) { \
bool done = false; \
{
SelfRegisteringType::clearMe();
- QDeclarativeComponent component(&engine, TEST_FILE("objectDeleted.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("objectDeleted.qml"));
QVERIFY(component.isReady());
bool done = false;
void tst_qdeclarativeincubator::contextDelete()
{
QDeclarativeContext *context = new QDeclarativeContext(engine.rootContext());
- QDeclarativeComponent component(&engine, TEST_FILE("contextDelete.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("contextDelete.qml"));
QDeclarativeIncubator incubator;
component.create(incubator, context);
TARGET = tst_qdeclarativeinfo
macx:CONFIG -= app_bundle
-SOURCES += tst_qdeclarativeinfo.cpp
+SOURCES += tst_qdeclarativeinfo.cpp \
+ ../../shared/util.cpp
+HEADERS += ../../shared/util.h
testDataFiles.files = data
testDataFiles.path = .
#include <qdeclarativeinfo.h>
#include "../../shared/util.h"
-class tst_qdeclarativeinfo : public QObject
+class tst_qdeclarativeinfo : public QDeclarativeDataTest
{
Q_OBJECT
public:
QDeclarativeEngine engine;
};
-inline QUrl TEST_FILE(const QString &filename)
-{
- return QUrl::fromLocalFile(TESTDATA(filename));
-}
-
void tst_qdeclarativeinfo::qmlObject()
{
- QDeclarativeComponent component(&engine, TEST_FILE("qmlObject.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("qmlObject.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
void tst_qdeclarativeinfo::nestedQmlObject()
{
- QDeclarativeComponent component(&engine, TEST_FILE("nestedQmlObject.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("nestedQmlObject.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
qmlInfo(nested) << "Outer Object";
- message = TEST_FILE("NestedObject.qml").toString() + ":6:14: QML QtObject: Inner Object";
+ message = testFileUrl("NestedObject.qml").toString() + ":6:14: QML QtObject: Inner Object";
QTest::ignoreMessage(QtWarningMsg, qPrintable(message));
qmlInfo(nested2) << "Inner Object";
}
void tst_qdeclarativeinfo::nestedComponent()
{
- QDeclarativeComponent component(&engine, TEST_FILE("NestedComponent.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("NestedComponent.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
TARGET = tst_qdeclarativelistmodel
macx:CONFIG -= app_bundle
-SOURCES += tst_qdeclarativelistmodel.cpp
+SOURCES += tst_qdeclarativelistmodel.cpp \
+ ../../shared/util.cpp
+HEADERS += ../../shared/util.h
testDataFiles.files = data
testDataFiles.path = .
return valid;
}
-class tst_qdeclarativelistmodel : public QObject
+class tst_qdeclarativelistmodel : public QDeclarativeDataTest
{
Q_OBJECT
public:
QDeclarativeListModel model;
model.setDynamicRoles(dynamicRoles);
QDeclarativeEngine eng;
- QDeclarativeComponent component(&eng, QUrl::fromLocalFile(TESTDATA("model.qml")));
+ QDeclarativeComponent component(&eng, testFileUrl("model.qml"));
QQuickItem *item = createWorkerTest(&eng, &component, &model);
QVERIFY(item != 0);
QDeclarativeListModel model;
model.setDynamicRoles(dynamicRoles);
QDeclarativeEngine eng;
- QDeclarativeComponent component(&eng, QUrl::fromLocalFile(TESTDATA("model.qml")));
+ QDeclarativeComponent component(&eng, testFileUrl("model.qml"));
QQuickItem *item = createWorkerTest(&eng, &component, &model);
QVERIFY(item != 0);
void tst_qdeclarativelistmodel::enumerate()
{
QDeclarativeEngine eng;
- QDeclarativeComponent component(&eng, QUrl::fromLocalFile(TESTDATA("enumerate.qml")));
+ QDeclarativeComponent component(&eng, testFileUrl("enumerate.qml"));
QVERIFY(!component.isError());
QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
QVERIFY(item != 0);
QDeclarativeListModel model;
model.setDynamicRoles(dynamicRoles);
QDeclarativeEngine eng;
- QDeclarativeComponent component(&eng, QUrl::fromLocalFile(TESTDATA("model.qml")));
+ QDeclarativeComponent component(&eng, testFileUrl("model.qml"));
QQuickItem *item = createWorkerTest(&eng, &component, &model);
QVERIFY(item != 0);
void tst_qdeclarativelistmodel::crash_model_with_multiple_roles()
{
QDeclarativeEngine eng;
- QDeclarativeComponent component(&eng, QUrl::fromLocalFile(TESTDATA("multipleroles.qml")));
+ QDeclarativeComponent component(&eng, testFileUrl("multipleroles.qml"));
QObject *rootItem = component.create();
QVERIFY(component.errorString().isEmpty());
QVERIFY(rootItem != 0);
void tst_qdeclarativelistmodel::set_model_cache()
{
QDeclarativeEngine eng;
- QDeclarativeComponent component(&eng, QUrl::fromLocalFile(TESTDATA("setmodelcachelist.qml")));
+ QDeclarativeComponent component(&eng, testFileUrl("setmodelcachelist.qml"));
QObject *model = component.create();
QVERIFY2(component.errorString().isEmpty(), QTest::toString(component.errorString()));
QVERIFY(model != 0);
QDeclarativeListModel model;
model.setDynamicRoles(dynamicRoles);
QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("model.qml")));
+ QDeclarativeComponent component(&engine, testFileUrl("model.qml"));
QVERIFY2(component.errorString().isEmpty(), component.errorString().toUtf8());
QQuickItem *item = createWorkerTest(&engine, &component, &model);
QVERIFY(item != 0);
QFETCH(bool, dynamicRoles);
QDeclarativeEngine eng;
- QDeclarativeComponent component(&eng, QUrl::fromLocalFile(TESTDATA("signalhandlers.qml")));
+ QDeclarativeComponent component(&eng, testFileUrl("signalhandlers.qml"));
QObject *model = component.create();
QDeclarativeListModel *lm = qobject_cast<QDeclarativeListModel *>(model);
QVERIFY(lm != 0);
QDeclarativeListModel model;
model.setDynamicRoles(dynamicRoles);
QDeclarativeEngine eng;
- QDeclarativeComponent component(&eng, QUrl::fromLocalFile(TESTDATA("workersync.qml")));
+ QDeclarativeComponent component(&eng, testFileUrl("workersync.qml"));
QQuickItem *item = createWorkerTest(&eng, &component, &model);
QVERIFY(item != 0);
QDeclarativeListModel model;
model.setDynamicRoles(dynamicRoles);
QDeclarativeEngine eng;
- QDeclarativeComponent component(&eng, QUrl::fromLocalFile(TESTDATA("workerremoveelement.qml")));
+ QDeclarativeComponent component(&eng, testFileUrl("workerremoveelement.qml"));
QQuickItem *item = createWorkerTest(&eng, &component, &model);
QVERIFY(item != 0);
QDeclarativeListModel model;
model.setDynamicRoles(dynamicRoles);
QDeclarativeEngine eng;
- QDeclarativeComponent component(&eng, QUrl::fromLocalFile(TESTDATA("workerremovelist.qml")));
+ QDeclarativeComponent component(&eng, testFileUrl("workerremovelist.qml"));
QQuickItem *item = createWorkerTest(&eng, &component, &model);
QVERIFY(item != 0);
QDeclarativeListModel model;
model.setDynamicRoles(true);
QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("model.qml")));
+ QDeclarativeComponent component(&engine, testFileUrl("model.qml"));
QQuickItem *item = createWorkerTest(&engine, &component, &model);
QVERIFY(item != 0);
TARGET = tst_qdeclarativelistreference
macx:CONFIG -= app_bundle
-SOURCES += tst_qdeclarativelistreference.cpp
+SOURCES += tst_qdeclarativelistreference.cpp \
+ ../../shared/util.cpp
+HEADERS += ../../shared/util.h
testDataFiles.files = data
testDataFiles.path = .
#include <QDebug>
#include "../../shared/util.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_qdeclarativelistreference : public QObject
+class tst_qdeclarativelistreference : public QDeclarativeDataTest
{
Q_OBJECT
public:
void tst_qdeclarativelistreference::initTestCase()
{
+ QDeclarativeDataTest::initTestCase();
qmlRegisterType<TestType>();
}
void tst_qdeclarativelistreference::engineTypes()
{
QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, TEST_FILE("engineTypes.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("engineTypes.qml"));
QObject *o = component.create();
QVERIFY(o);
void tst_qdeclarativelistreference::variantToList()
{
QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, TEST_FILE("variantToList.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("variantToList.qml"));
QObject *o = component.create();
QVERIFY(o);
TARGET = tst_qdeclarativelocale
macx:CONFIG -= app_bundle
-SOURCES += tst_qdeclarativelocale.cpp
+SOURCES += tst_qdeclarativelocale.cpp \
+ ../../shared/util.cpp
+HEADERS += ../../shared/util.h
testDataFiles.files = data
testDataFiles.path = .
#include <qcolor.h>
#include "../../shared/util.h"
-class tst_qdeclarativelocale : public QObject
+class tst_qdeclarativelocale : public QDeclarativeDataTest
{
Q_OBJECT
public:
void tst_qdeclarativelocale::defaultLocale()
{
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("properties.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("properties.qml"));
QObject *obj = c.create();
QVERIFY(obj);
QFETCH(QByteArray, property);
QFETCH(QVariant, value);
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("properties.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("properties.qml"));
QObject *obj = c.create();
QVERIFY(obj);
QFETCH(QString, locale);
QFETCH(int, param);
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("functions.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("functions.qml"));
QObject *obj = c.create();
QVERIFY(obj);
QFETCH(QString, locale);
QFETCH(int, param);
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("functions.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("functions.qml"));
QObject *obj = c.create();
QVERIFY(obj);
QFETCH(QString, locale);
QFETCH(int, param);
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("functions.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("functions.qml"));
QObject *obj = c.create();
QVERIFY(obj);
QFETCH(QString, locale);
QFETCH(int, param);
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("functions.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("functions.qml"));
QObject *obj = c.create();
QVERIFY(obj);
QFETCH(QString, locale);
QFETCH(int, param);
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("functions.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("functions.qml"));
QObject *obj = c.create();
QVERIFY(obj);
{
QFETCH(QString, locale);
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("properties.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("properties.qml"));
QObject *obj = c.create();
QVERIFY(obj);
QFETCH(QString, locale);
QFETCH(int, param);
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("functions.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("functions.qml"));
QObject *obj = c.create();
QVERIFY(obj);
QFETCH(QString, locale);
QFETCH(int, param);
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("functions.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("functions.qml"));
QObject *obj = c.create();
QVERIFY(obj);
QFETCH(QString, locale);
QFETCH(int, param);
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("functions.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("functions.qml"));
QObject *obj = c.create();
QVERIFY(obj);
QFETCH(QString, locale);
QFETCH(int, param);
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("date.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("date.qml"));
QObject *obj = c.create();
QVERIFY(obj);
QFETCH(QString, locale);
QFETCH(QString, format);
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("date.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("date.qml"));
QObject *obj = c.create();
QVERIFY(obj);
QFETCH(QString, locale);
QFETCH(int, param);
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("date.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("date.qml"));
QObject *obj = c.create();
QVERIFY(obj);
QFETCH(QString, locale);
QFETCH(QString, format);
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("date.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("date.qml"));
QObject *obj = c.create();
QVERIFY(obj);
QFETCH(QString, locale);
QFETCH(int, param);
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("date.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("date.qml"));
QObject *obj = c.create();
QVERIFY(obj);
QFETCH(QString, locale);
QFETCH(QString, format);
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("date.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("date.qml"));
QObject *obj = c.create();
QVERIFY(obj);
QFETCH(QString, locale);
QFETCH(QString, format);
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("date.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("date.qml"));
QObject *obj = c.create();
QVERIFY(obj);
QFETCH(QString, locale);
QFETCH(QString, format);
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("date.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("date.qml"));
QObject *obj = c.create();
QVERIFY(obj);
QFETCH(QString, locale);
QFETCH(QString, format);
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("date.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("date.qml"));
QObject *obj = c.create();
QVERIFY(obj);
QFETCH(char, format);
QFETCH(int, prec);
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("number.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("number.qml"));
QObject *obj = c.create();
QVERIFY(obj);
QFETCH(QString, locale);
QFETCH(QString, symbol);
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("number.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("number.qml"));
QObject *obj = c.create();
QVERIFY(obj);
QFETCH(QString, locale);
QFETCH(double, number);
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("number.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("number.qml"));
QObject *obj = c.create();
QVERIFY(obj);
void tst_qdeclarativelocale::numberConstToLocaleString()
{
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("number.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("number.qml"));
QObject *obj = c.create();
QVERIFY(obj);
#define SERVER_PORT 14450
-class tst_qdeclarativemoduleplugin : public QObject
+class tst_qdeclarativemoduleplugin : public QDeclarativeDataTest
{
Q_OBJECT
public:
- tst_qdeclarativemoduleplugin()
- {
- }
private slots:
+ virtual void initTestCase();
void importsPlugin();
void importsPlugin2();
void importsPlugin21();
void versionNotInstalled_data();
void implicitQmldir();
void implicitQmldir_data();
+
+private:
+ QString m_importsDirectory;
};
+void tst_qdeclarativemoduleplugin::initTestCase()
+{
+ QDeclarativeDataTest::initTestCase();
+ m_importsDirectory = directory() + QStringLiteral("/imports");
+ QVERIFY2(QFileInfo(m_importsDirectory).isDir(),
+ qPrintable(QString::fromLatin1("Imports directory '%1' does not exist.").arg(m_importsDirectory)));
+}
+
#define VERIFY_ERRORS(errorfile) \
if (!errorfile) { \
if (qgetenv("DEBUG") != "" && !component.errors().isEmpty()) \
QVERIFY(!component.isError()); \
QVERIFY(component.errors().isEmpty()); \
} else { \
- QString verify_errors_file_name = TESTDATA(errorfile); \
+ QString verify_errors_file_name = testFile(errorfile); \
QFile file(verify_errors_file_name); \
QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text)); \
QByteArray data = file.readAll(); \
qWarning() << "Expected:" << expected << "Actual:" << actual; \
} \
if (qgetenv("QDECLARATIVELANGUAGE_UPDATEERRORS") != "" && expected != actual) {\
- QFile file(TESTDATA(errorfile)); \
+ QFile file(testFile(errorfile)); \
QVERIFY(file.open(QIODevice::WriteOnly)); \
for (int ii = 0; ii < actual.count(); ++ii) { \
file.write(actual.at(ii)); file.write("\n"); \
} \
}
-inline QUrl TEST_FILE(const QString &filename)
-{
- return QUrl::fromLocalFile(TESTDATA(filename));
-}
-
-QString IMPORTSDIR()
-{
- // Try to find it relative to the binary.
- QDir appDir(QCoreApplication::applicationDirPath() + QDir::separator() + QLatin1String("imports"));
- if (appDir.exists()) {
- return appDir.absolutePath();
- }
-
- // Else try to find it in the source tree
- QDir sourceDir(QFileInfo(__FILE__).absoluteDir().filePath(QLatin1String("imports")));
- if (sourceDir.exists()) {
- return sourceDir.absolutePath();
- }
-
- qWarning("requested importsPath could not be found (looked at: %s, %s)",
- qPrintable(appDir.path()),
- qPrintable(sourceDir.path())
- );
-
- return QString();
-}
-
void tst_qdeclarativemoduleplugin::importsPlugin()
{
QDeclarativeEngine engine;
- engine.addImportPath(IMPORTSDIR());
+ engine.addImportPath(m_importsDirectory);
QTest::ignoreMessage(QtWarningMsg, "plugin created");
QTest::ignoreMessage(QtWarningMsg, "import worked");
- QDeclarativeComponent component(&engine, TEST_FILE("works.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl(QStringLiteral("works.qml")));
foreach (QDeclarativeError err, component.errors())
qWarning() << err;
VERIFY_ERRORS(0);
void tst_qdeclarativemoduleplugin::importsPlugin2()
{
QDeclarativeEngine engine;
- engine.addImportPath(IMPORTSDIR());
+ engine.addImportPath(m_importsDirectory);
QTest::ignoreMessage(QtWarningMsg, "plugin2 created");
QTest::ignoreMessage(QtWarningMsg, "import2 worked");
- QDeclarativeComponent component(&engine, TEST_FILE("works2.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl(QStringLiteral("works2.qml")));
foreach (QDeclarativeError err, component.errors())
qWarning() << err;
VERIFY_ERRORS(0);
void tst_qdeclarativemoduleplugin::importsPlugin21()
{
QDeclarativeEngine engine;
- engine.addImportPath(IMPORTSDIR());
+ engine.addImportPath(m_importsDirectory);
QTest::ignoreMessage(QtWarningMsg, "plugin2.1 created");
QTest::ignoreMessage(QtWarningMsg, "import2.1 worked");
- QDeclarativeComponent component(&engine, TEST_FILE("works21.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl(QStringLiteral("works21.qml")));
foreach (QDeclarativeError err, component.errors())
qWarning() << err;
VERIFY_ERRORS(0);
void tst_qdeclarativemoduleplugin::incorrectPluginCase()
{
QDeclarativeEngine engine;
- engine.addImportPath(IMPORTSDIR());
+ engine.addImportPath(m_importsDirectory);
- QDeclarativeComponent component(&engine, TEST_FILE("incorrectCase.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl(QStringLiteral("incorrectCase.qml")));
QList<QDeclarativeError> errors = component.errors();
QCOMPARE(errors.count(), 1);
#elif defined(Q_OS_WIN32)
QString libname = "PluGin.dll";
#endif
- QString expectedError = QLatin1String("plugin cannot be loaded for module \"com.nokia.WrongCase\": File name case mismatch for \"") + QDir(IMPORTSDIR()).filePath("com/nokia/WrongCase/" + libname) + QLatin1String("\"");
+ QString expectedError = QLatin1String("plugin cannot be loaded for module \"com.nokia.WrongCase\": File name case mismatch for \"") + QDir(m_importsDirectory).filePath("com/nokia/WrongCase/" + libname) + QLatin1String("\"");
#else
QString expectedError = QLatin1String("module \"com.nokia.WrongCase\" plugin \"PluGin\" not found");
#endif
void tst_qdeclarativemoduleplugin::importPluginWithQmlFile()
{
- QString path = IMPORTSDIR();
+ QString path = m_importsDirectory;
// QTBUG-16885: adding an import path with a lower-case "c:" causes assert failure
// (this only happens if the plugin includes pure QML files)
QDeclarativeEngine engine;
engine.addImportPath(path);
- QDeclarativeComponent component(&engine, TEST_FILE("pluginWithQmlFile.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl(QStringLiteral("pluginWithQmlFile.qml")));
foreach (QDeclarativeError err, component.errors())
qWarning() << err;
VERIFY_ERRORS(0);
{
TestHTTPServer server(SERVER_PORT);
QVERIFY(server.isValid());
- server.serveDirectory(IMPORTSDIR());
+ server.serveDirectory(m_importsDirectory);
QDeclarativeEngine engine;
QDeclarativeComponent component(&engine);
{
TestHTTPServer server(SERVER_PORT);
QVERIFY(server.isValid());
- server.serveDirectory(IMPORTSDIR());
+ server.serveDirectory(m_importsDirectory);
QDeclarativeEngine engine;
- engine.addImportPath(IMPORTSDIR());
+ engine.addImportPath(m_importsDirectory);
QDeclarativeComponent component(&engine);
component.setData("import com.nokia.PureQmlModule 1.0 \nComponentA { width: 300; ComponentB{} }", QUrl());
}
// QTBUG-17324
+
void tst_qdeclarativemoduleplugin::importsMixedQmlCppPlugin()
{
QDeclarativeEngine engine;
- engine.addImportPath(IMPORTSDIR());
+ engine.addImportPath(m_importsDirectory);
{
- QDeclarativeComponent component(&engine, TEST_FILE("importsMixedQmlCppPlugin.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl(QStringLiteral("importsMixedQmlCppPlugin.qml")));
QObject *o = component.create();
- QVERIFY(o != 0);
+ QVERIFY2(o != 0, QDeclarativeDataTest::msgComponentError(component, &engine));
QCOMPARE(o->property("test").toBool(), true);
delete o;
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("importsMixedQmlCppPlugin.2.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl(QStringLiteral("importsMixedQmlCppPlugin.2.qml")));
QObject *o = component.create();
- QVERIFY(o != 0);
+ QVERIFY2(o != 0, QDeclarativeDataTest::msgComponentError(component, &engine));
QCOMPARE(o->property("test").toBool(), true);
QCOMPARE(o->property("test2").toBool(), true);
delete o;
QFETCH(QString, errorFile);
QDeclarativeEngine engine;
- engine.addImportPath(IMPORTSDIR());
+ engine.addImportPath(m_importsDirectory);
- QDeclarativeComponent component(&engine, TEST_FILE(file));
+ QDeclarativeComponent component(&engine, testFileUrl(file));
VERIFY_ERRORS(errorFile.toLatin1().constData());
}
QFETCH(QString, file);
QFETCH(QString, errorFile);
- QString importPath = TESTDATA(directory);
+ QString importPath = testFile(directory);
QString fileName = directory + QDir::separator() + file;
QString errorFileName = directory + QDir::separator() + errorFile;
- QUrl testFileUrl = TEST_FILE(fileName);
+ QUrl testUrl = testFileUrl(fileName);
QDeclarativeEngine engine;
engine.addImportPath(importPath);
- QDeclarativeComponent component(&engine, testFileUrl);
+ QDeclarativeComponent component(&engine, testUrl);
QList<QDeclarativeError> errors = component.errors();
VERIFY_ERRORS(errorFileName.toLatin1().constData());
QTest::ignoreMessage(QtWarningMsg, "QDeclarativeComponent: Component is not ready");
CONFIG += testcase
TARGET = tst_qdeclarativemoduleplugin
-HEADERS = ../../shared/testhttpserver.h
+HEADERS = ../../shared/testhttpserver.h \
+ ../../shared/util.h
SOURCES = tst_qdeclarativemoduleplugin.cpp \
- ../../shared/testhttpserver.cpp
+ ../../shared/testhttpserver.cpp \
+ ../../shared/util.cpp
CONFIG -= app_bundle
testDataFiles.files = data
TARGET = tst_qdeclarativeproperty
macx:CONFIG -= app_bundle
-SOURCES += tst_qdeclarativeproperty.cpp
+SOURCES += tst_qdeclarativeproperty.cpp \
+ ../../shared/util.cpp
+HEADERS += ../../shared/util.h
testDataFiles.files = data
testDataFiles.path = .
#include <QtCore/qdir.h>
#include "../../shared/util.h"
-inline QUrl TEST_FILE(const QString &filename)
-{
- return QUrl::fromLocalFile(TESTDATA(filename));
-}
-
class MyQmlObject : public QObject
{
Q_OBJECT
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:
QVERIFY(qvariant_cast<QObject *>(v) == o.qmlObject());
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("readSynthesizedObject.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("readSynthesizedObject.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
QCOMPARE(qvariant_cast<QObject *>(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);
// 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);
void tst_qdeclarativeproperty::noContext()
{
- QDeclarativeComponent compA(&engine, TEST_FILE("NoContextTypeA.qml"));
- QDeclarativeComponent compB(&engine, TEST_FILE("NoContextTypeB.qml"));
+ QDeclarativeComponent compA(&engine, testFileUrl("NoContextTypeA.qml"));
+ QDeclarativeComponent compB(&engine, testFileUrl("NoContextTypeB.qml"));
QObject *a = compA.create();
QVERIFY(a != 0);
void tst_qdeclarativeproperty::initTestCase()
{
+ QDeclarativeDataTest::initTestCase();
qmlRegisterType<MyQmlObject>("Test",1,0,"MyQmlObject");
qmlRegisterType<PropertyObject>("Test",1,0,"PropertyObject");
qmlRegisterType<MyContainer>("Test",1,0,"MyContainer");
CONFIG += testcase
TARGET = tst_qdeclarativeqt
-SOURCES += tst_qdeclarativeqt.cpp
+SOURCES += tst_qdeclarativeqt.cpp \
+ ../../shared/util.cpp
+HEADERS += ../../shared/util.h
+
macx:CONFIG -= app_bundle
testDataFiles.files = data
#include <QSignalSpy>
#include "../../shared/util.h"
-class tst_qdeclarativeqt : public QObject
+class tst_qdeclarativeqt : public QDeclarativeDataTest
{
Q_OBJECT
public:
QDeclarativeEngine engine;
};
-inline QUrl TEST_FILE(const QString &filename)
-{
- return QUrl::fromLocalFile(TESTDATA(filename));
-}
-
void tst_qdeclarativeqt::enums()
{
- QDeclarativeComponent component(&engine, TEST_FILE("enums.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("enums.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
void tst_qdeclarativeqt::rgba()
{
- QDeclarativeComponent component(&engine, TEST_FILE("rgba.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("rgba.qml"));
QString warning1 = component.url().toString() + ":6: Error: Qt.rgba(): Invalid arguments";
QString warning2 = component.url().toString() + ":7: Error: Qt.rgba(): Invalid arguments";
void tst_qdeclarativeqt::hsla()
{
- QDeclarativeComponent component(&engine, TEST_FILE("hsla.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("hsla.qml"));
QString warning1 = component.url().toString() + ":6: Error: Qt.hsla(): Invalid arguments";
QString warning2 = component.url().toString() + ":7: Error: Qt.hsla(): Invalid arguments";
void tst_qdeclarativeqt::rect()
{
- QDeclarativeComponent component(&engine, TEST_FILE("rect.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("rect.qml"));
QString warning1 = component.url().toString() + ":6: Error: Qt.rect(): Invalid arguments";
QString warning2 = component.url().toString() + ":7: Error: Qt.rect(): Invalid arguments";
void tst_qdeclarativeqt::point()
{
- QDeclarativeComponent component(&engine, TEST_FILE("point.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("point.qml"));
QString warning1 = component.url().toString() + ":6: Error: Qt.point(): Invalid arguments";
QString warning2 = component.url().toString() + ":7: Error: Qt.point(): Invalid arguments";
void tst_qdeclarativeqt::size()
{
- QDeclarativeComponent component(&engine, TEST_FILE("size.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("size.qml"));
QString warning1 = component.url().toString() + ":7: Error: Qt.size(): Invalid arguments";
QString warning2 = component.url().toString() + ":8: Error: Qt.size(): Invalid arguments";
void tst_qdeclarativeqt::vector()
{
- QDeclarativeComponent component(&engine, TEST_FILE("vector.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("vector.qml"));
QString warning1 = component.url().toString() + ":6: Error: Qt.vector(): Invalid arguments";
QString warning2 = component.url().toString() + ":7: Error: Qt.vector(): Invalid arguments";
void tst_qdeclarativeqt::vector4d()
{
- QDeclarativeComponent component(&engine, TEST_FILE("vector4.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("vector4.qml"));
QString warning1 = component.url().toString() + ":6: Error: Qt.vector4d(): Invalid arguments";
QString warning2 = component.url().toString() + ":7: Error: Qt.vector4d(): Invalid arguments";
void tst_qdeclarativeqt::lighter()
{
- QDeclarativeComponent component(&engine, TEST_FILE("lighter.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("lighter.qml"));
QString warning1 = component.url().toString() + ":5: Error: Qt.lighter(): Invalid arguments";
QString warning2 = component.url().toString() + ":10: Error: Qt.lighter(): Invalid arguments";
void tst_qdeclarativeqt::darker()
{
- QDeclarativeComponent component(&engine, TEST_FILE("darker.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("darker.qml"));
QString warning1 = component.url().toString() + ":5: Error: Qt.darker(): Invalid arguments";
QString warning2 = component.url().toString() + ":10: Error: Qt.darker(): Invalid arguments";
void tst_qdeclarativeqt::tint()
{
- QDeclarativeComponent component(&engine, TEST_FILE("tint.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("tint.qml"));
QString warning1 = component.url().toString() + ":7: Error: Qt.tint(): Invalid arguments";
QString warning2 = component.url().toString() + ":8: Error: Qt.tint(): Invalid arguments";
QDesktopServices::setUrlHandler("test", &handler, "noteCall");
QDesktopServices::setUrlHandler("file", &handler, "noteCall");
- QDeclarativeComponent component(&engine, TEST_FILE("openUrlExternally.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("openUrlExternally.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
QCOMPARE(handler.called,1);
object->setProperty("testFile", true);
QCOMPARE(handler.called,2);
- QCOMPARE(handler.last, TEST_FILE("test.html"));
+ QCOMPARE(handler.last, testFileUrl("test.html"));
QDesktopServices::unsetUrlHandler("test");
QDesktopServices::unsetUrlHandler("file");
QDesktopServices::setUrlHandler("test", &handler, "noteCall");
QDesktopServices::setUrlHandler("file", &handler, "noteCall");
- QDeclarativeComponent component(&engine, TEST_FILE("openUrlExternally_lib.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("openUrlExternally_lib.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
QCOMPARE(handler.called,1);
object->setProperty("testFile", true);
QCOMPARE(handler.called,2);
- QCOMPARE(handler.last, TEST_FILE("test.html"));
+ QCOMPARE(handler.last, testFileUrl("test.html"));
QDesktopServices::unsetUrlHandler("test");
QDesktopServices::unsetUrlHandler("file");
void tst_qdeclarativeqt::md5()
{
- QDeclarativeComponent component(&engine, TEST_FILE("md5.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("md5.qml"));
QString warning1 = component.url().toString() + ":4: Error: Qt.md5(): Invalid arguments";
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
void tst_qdeclarativeqt::createComponent()
{
- QDeclarativeComponent component(&engine, TEST_FILE("createComponent.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("createComponent.qml"));
QString warning1 = component.url().toString() + ":9: Error: Qt.createComponent(): Invalid arguments";
QString warning2 = component.url().toString() + ":10: Error: Qt.createComponent(): Invalid arguments";
QVERIFY(object != 0);
QCOMPARE(object->property("absoluteUrl").toString(), QString("http://www.example.com/test.qml"));
- QCOMPARE(object->property("relativeUrl").toString(), TEST_FILE("createComponentData.qml").toString());
+ QCOMPARE(object->property("relativeUrl").toString(), testFileUrl("createComponentData.qml").toString());
delete object;
}
void tst_qdeclarativeqt::createComponent_pragmaLibrary()
{
// Currently, just loading createComponent_lib.qml causes crash on some platforms
- QDeclarativeComponent component(&engine, TEST_FILE("createComponent_lib.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("createComponent_lib.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
QCOMPARE(object->property("status").toInt(), int(QDeclarativeComponent::Ready));
void tst_qdeclarativeqt::createQmlObject()
{
- QDeclarativeComponent component(&engine, TEST_FILE("createQmlObject.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("createQmlObject.qml"));
QString warning1 = component.url().toString() + ":7: Error: Qt.createQmlObject(): Invalid arguments";
- QString warning2 = component.url().toString()+ ":10: Error: Qt.createQmlObject(): failed to create object: \n " + TEST_FILE("inline").toString() + ":2:10: Blah is not a type";
- QString warning3 = component.url().toString()+ ":11: Error: Qt.createQmlObject(): failed to create object: \n " + TEST_FILE("main.qml").toString() + ":4:1: Duplicate property name";
+ QString warning2 = component.url().toString()+ ":10: Error: Qt.createQmlObject(): failed to create object: \n " + testFileUrl("inline").toString() + ":2:10: Blah is not a type";
+ QString warning3 = component.url().toString()+ ":11: Error: Qt.createQmlObject(): failed to create object: \n " + testFileUrl("main.qml").toString() + ":4:1: Duplicate property name";
QString warning4 = component.url().toString()+ ":9: Error: Qt.createQmlObject(): Missing parent object";
QString warning5 = component.url().toString()+ ":8: Error: Qt.createQmlObject(): Invalid arguments";
- QString warning6 = "RunTimeError: Qt.createQmlObject(): failed to create object: \n " + TEST_FILE("inline").toString() + ":3: Cannot assign object type QObject with no default method";
+ QString warning6 = "RunTimeError: Qt.createQmlObject(): failed to create object: \n " + testFileUrl("inline").toString() + ":3: Cannot assign object type QObject with no default method";
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning3));
void tst_qdeclarativeqt::console()
{
- QUrl testFileUrl = TEST_FILE("console.qml");
- QString testException = QString(QLatin1String("%1:%2: ReferenceError: Can't find variable: exception")).arg(testFileUrl.toString()).arg(34);
- QString testTrace = QString(QLatin1String("onCompleted (%1:%2:%3)\n")).arg(testFileUrl.toString()).arg(31).arg(17);
+ QUrl testUrl = testFileUrl("console.qml");
+ QString testException = QString(QLatin1String("%1:%2: ReferenceError: Can't find variable: exception")).arg(testUrl.toString()).arg(34);
+ QString testTrace = QString(QLatin1String("onCompleted (%1:%2:%3)\n")).arg(testUrl.toString()).arg(31).arg(17);
QTest::ignoreMessage(QtDebugMsg, qPrintable(testTrace));
QTest::ignoreMessage(QtDebugMsg, "Profiling started.");
QTest::ignoreMessage(QtDebugMsg, "Profiling ended.");
QTest::ignoreMessage(QtWarningMsg, qPrintable(testException));
- QDeclarativeComponent component(&engine, testFileUrl);
+ QDeclarativeComponent component(&engine, testUrl);
QObject *object = component.create();
QVERIFY(object != 0);
delete object;
QDateTime dateTime6(QDate(2008,2,24), QTime(14,15,38,200));
QDeclarativeEngine eng;
- QDeclarativeComponent component(&eng, TEST_FILE("dateTimeConversion.qml"));
+ QDeclarativeComponent component(&eng, testFileUrl("dateTimeConversion.qml"));
QObject *obj = component.create();
QCOMPARE(obj->property("qdate").toDate(), date);
eng.rootContext()->setContextProperty("qtime", time);
eng.rootContext()->setContextProperty("qdatetime", dateTime);
- QDeclarativeComponent component(&eng, TEST_FILE("formatting.qml"));
+ QDeclarativeComponent component(&eng, testFileUrl("formatting.qml"));
QStringList warnings;
warnings << component.url().toString() + ":37: Error: Qt.formatDate(): Invalid date format"
QDeclarativeEngine eng;
eng.rootContext()->setContextProperty("qvariant", variant);
- QDeclarativeComponent component(&eng, TEST_FILE("formatting.qml"));
+ QDeclarativeComponent component(&eng, testFileUrl("formatting.qml"));
QStringList warnings;
warnings << component.url().toString() + ":37: Error: Qt.formatDate(): Invalid date format"
void tst_qdeclarativeqt::isQtObject()
{
- QDeclarativeComponent component(&engine, TEST_FILE("isQtObject.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("isQtObject.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
void tst_qdeclarativeqt::btoa()
{
- QDeclarativeComponent component(&engine, TEST_FILE("btoa.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("btoa.qml"));
QString warning1 = component.url().toString() + ":4: Error: Qt.btoa(): Invalid arguments";
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
void tst_qdeclarativeqt::atob()
{
- QDeclarativeComponent component(&engine, TEST_FILE("atob.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("atob.qml"));
QString warning1 = component.url().toString() + ":4: Error: Qt.atob(): Invalid arguments";
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
void tst_qdeclarativeqt::fontFamilies()
{
- QDeclarativeComponent component(&engine, TEST_FILE("fontFamilies.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("fontFamilies.qml"));
QString warning1 = component.url().toString() + ":4: Error: Qt.fontFamilies(): Invalid arguments";
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
void tst_qdeclarativeqt::quit()
{
- QDeclarativeComponent component(&engine, TEST_FILE("quit.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("quit.qml"));
QSignalSpy spy(&engine, SIGNAL(quit()));
QObject *object = component.create();
void tst_qdeclarativeqt::resolvedUrl()
{
- QDeclarativeComponent component(&engine, TEST_FILE("resolvedUrl.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("resolvedUrl.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
TARGET = tst_qdeclarativesqldatabase
macx:CONFIG -= app_bundle
-SOURCES += tst_qdeclarativesqldatabase.cpp
+SOURCES += tst_qdeclarativesqldatabase.cpp \
+ ../../shared/util.cpp
+HEADERS += ../../shared/util.h
CONFIG += parallel_test
#include <QtCore/qfile.h>
#include "../../shared/util.h"
-class tst_qdeclarativesqldatabase : public QObject
+class tst_qdeclarativesqldatabase : public QDeclarativeDataTest
{
Q_OBJECT
public:
void tst_qdeclarativesqldatabase::initTestCase()
{
+ QDeclarativeDataTest::initTestCase();
removeRecursive(dbDir());
QDir().mkpath(dbDir());
}
engine->setOfflineStoragePath(dbDir());
QDeclarativeComponent component(engine);
- component.setData(qml.toUtf8(), QUrl::fromLocalFile(TESTDATA("empty.qml"))); // just a file for relative local imports
+ component.setData(qml.toUtf8(), testFileUrl("empty.qml")); // just a file for relative local imports
QVERIFY(!component.isError());
QQuickText *text = qobject_cast<QQuickText*>(component.create());
QVERIFY(text != 0);
TARGET = tst_qdeclarativetranslation
macx:CONFIG -= app_bundle
-SOURCES += tst_qdeclarativetranslation.cpp
+SOURCES += tst_qdeclarativetranslation.cpp \
+ ../../shared/util.cpp
+HEADERS += ../../shared/util.h
RESOURCES += data/translation.qrc
testDataFiles.files = data
#include <QTranslator>
#include "../../shared/util.h"
-class tst_qdeclarativetranslation : public QObject
+class tst_qdeclarativetranslation : public QDeclarativeDataTest
{
Q_OBJECT
public:
void translationInQrc();
};
-inline QUrl TEST_FILE(const QString &filename)
-{
- return QUrl::fromLocalFile(TESTDATA(filename));
-}
-
void tst_qdeclarativetranslation::translation()
{
QTranslator translator;
- translator.load(QLatin1String("qml_fr"), TESTDATA(""));
+ translator.load(QLatin1String("qml_fr"), dataDirectory());
QCoreApplication::installTranslator(&translator);
QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, TEST_FILE("translation.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("translation.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
void tst_qdeclarativetranslation::idTranslation()
{
QTranslator translator;
- translator.load(QLatin1String("qmlid_fr"),TESTDATA(""));
+ translator.load(QLatin1String("qmlid_fr"), dataDirectory());
QCoreApplication::installTranslator(&translator);
QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, TEST_FILE("idtranslation.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("idtranslation.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
TARGET = tst_qdeclarativevaluetypes
macx:CONFIG -= app_bundle
-HEADERS += testtypes.h
+HEADERS += testtypes.h \
+ ../../shared/util.h
SOURCES += tst_qdeclarativevaluetypes.cpp \
- testtypes.cpp
+ testtypes.cpp \
+ ../../shared/util.cpp
testDataFiles.files = data
testDataFiles.path = .
extern int qt_defaultDpi();
QT_END_NAMESPACE
-class tst_qdeclarativevaluetypes : public QObject
+class tst_qdeclarativevaluetypes : public QDeclarativeDataTest
{
Q_OBJECT
public:
void tst_qdeclarativevaluetypes::initTestCase()
{
+ QDeclarativeDataTest::initTestCase();
registerTypes();
}
-inline QUrl TEST_FILE(const QString &filename)
-{
- return QUrl::fromLocalFile(TESTDATA(filename));
-}
-
void tst_qdeclarativevaluetypes::point()
{
{
- QDeclarativeComponent component(&engine, TEST_FILE("point_read.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("point_read.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("point_write.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("point_write.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("point_compare.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("point_compare.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
void tst_qdeclarativevaluetypes::pointf()
{
{
- QDeclarativeComponent component(&engine, TEST_FILE("pointf_read.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("pointf_read.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("pointf_write.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("pointf_write.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("pointf_compare.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("pointf_compare.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
void tst_qdeclarativevaluetypes::size()
{
{
- QDeclarativeComponent component(&engine, TEST_FILE("size_read.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("size_read.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("size_write.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("size_write.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("size_compare.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("size_compare.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
void tst_qdeclarativevaluetypes::sizef()
{
{
- QDeclarativeComponent component(&engine, TEST_FILE("sizef_read.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("sizef_read.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("sizef_write.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("sizef_write.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("sizef_compare.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("sizef_compare.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
void tst_qdeclarativevaluetypes::variant()
{
- QDeclarativeComponent component(&engine, TEST_FILE("variant_read.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("variant_read.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
void tst_qdeclarativevaluetypes::sizereadonly()
{
{
- QDeclarativeComponent component(&engine, TEST_FILE("sizereadonly_read.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("sizereadonly_read.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("sizereadonly_writeerror.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("sizereadonly_writeerror.qml"));
QVERIFY(component.isError());
QCOMPARE(component.errors().at(0).description(), QLatin1String("Invalid property assignment: \"sizereadonly\" is a read-only property"));
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("sizereadonly_writeerror2.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("sizereadonly_writeerror2.qml"));
QVERIFY(component.isError());
QCOMPARE(component.errors().at(0).description(), QLatin1String("Invalid property assignment: \"sizereadonly\" is a read-only property"));
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("sizereadonly_writeerror3.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("sizereadonly_writeerror3.qml"));
QVERIFY(component.isError());
QCOMPARE(component.errors().at(0).description(), QLatin1String("Invalid property assignment: \"sizereadonly\" is a read-only property"));
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("sizereadonly_writeerror4.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("sizereadonly_writeerror4.qml"));
QObject *object = component.create();
QVERIFY(object);
void tst_qdeclarativevaluetypes::rect()
{
{
- QDeclarativeComponent component(&engine, TEST_FILE("rect_read.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("rect_read.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("rect_write.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("rect_write.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("rect_compare.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("rect_compare.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
void tst_qdeclarativevaluetypes::rectf()
{
{
- QDeclarativeComponent component(&engine, TEST_FILE("rectf_read.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("rectf_read.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("rectf_write.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("rectf_write.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("rectf_compare.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("rectf_compare.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
void tst_qdeclarativevaluetypes::vector2d()
{
{
- QDeclarativeComponent component(&engine, TEST_FILE("vector2d_read.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("vector2d_read.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("vector2d_write.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("vector2d_write.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("vector2d_compare.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("vector2d_compare.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
void tst_qdeclarativevaluetypes::vector3d()
{
{
- QDeclarativeComponent component(&engine, TEST_FILE("vector3d_read.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("vector3d_read.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("vector3d_write.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("vector3d_write.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("vector3d_compare.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("vector3d_compare.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
void tst_qdeclarativevaluetypes::vector4d()
{
{
- QDeclarativeComponent component(&engine, TEST_FILE("vector4d_read.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("vector4d_read.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("vector4d_write.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("vector4d_write.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("vector4d_compare.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("vector4d_compare.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
void tst_qdeclarativevaluetypes::quaternion()
{
{
- QDeclarativeComponent component(&engine, TEST_FILE("quaternion_read.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("quaternion_read.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("quaternion_write.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("quaternion_write.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("quaternion_compare.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("quaternion_compare.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
void tst_qdeclarativevaluetypes::matrix4x4()
{
{
- QDeclarativeComponent component(&engine, TEST_FILE("matrix4x4_read.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("matrix4x4_read.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("matrix4x4_write.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("matrix4x4_write.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("matrix4x4_compare.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("matrix4x4_compare.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
void tst_qdeclarativevaluetypes::font()
{
{
- QDeclarativeComponent component(&engine, TEST_FILE("font_read.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("font_read.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("font_write.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("font_write.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
// Test pixelSize
{
- QDeclarativeComponent component(&engine, TEST_FILE("font_write.2.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("font_write.2.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
// Test pixelSize and pointSize
{
- QDeclarativeComponent component(&engine, TEST_FILE("font_write.3.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("font_write.3.qml"));
QTest::ignoreMessage(QtWarningMsg, "Both point size and pixel size set. Using pixel size. ");
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
delete object;
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("font_write.4.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("font_write.4.qml"));
QTest::ignoreMessage(QtWarningMsg, "Both point size and pixel size set. Using pixel size. ");
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
delete object;
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("font_write.5.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("font_write.5.qml"));
QObject *object = qobject_cast<QObject *>(component.create());
QVERIFY(object != 0);
MyTypeObject *object1 = object->findChild<MyTypeObject *>("object1");
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("font_compare.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("font_compare.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
void tst_qdeclarativevaluetypes::color()
{
{
- QDeclarativeComponent component(&engine, TEST_FILE("color_read.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("color_read.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("color_write.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("color_write.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("color_compare.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("color_compare.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
QString colorString("#33e199");
// Test bindings can write to value types
void tst_qdeclarativevaluetypes::bindingAssignment()
{
- QDeclarativeComponent component(&engine, TEST_FILE("bindingAssignment.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("bindingAssignment.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
// Test bindings can read from value types
void tst_qdeclarativevaluetypes::bindingRead()
{
- QDeclarativeComponent component(&engine, TEST_FILE("bindingRead.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("bindingRead.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
// Test static values can assign to value types
void tst_qdeclarativevaluetypes::staticAssignment()
{
- QDeclarativeComponent component(&engine, TEST_FILE("staticAssignment.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("staticAssignment.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
// Test scripts can read/write value types
void tst_qdeclarativevaluetypes::scriptAccess()
{
- QDeclarativeComponent component(&engine, TEST_FILE("scriptAccess.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("scriptAccess.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
void tst_qdeclarativevaluetypes::autoBindingRemoval()
{
{
- QDeclarativeComponent component(&engine, TEST_FILE("autoBindingRemoval.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("autoBindingRemoval.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
/*
{
- QDeclarativeComponent component(&engine, TEST_FILE("autoBindingRemoval.2.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("autoBindingRemoval.2.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("autoBindingRemoval.3.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("autoBindingRemoval.3.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
// Test that property value sources assign to value types
void tst_qdeclarativevaluetypes::valueSources()
{
- QDeclarativeComponent component(&engine, TEST_FILE("valueSources.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("valueSources.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
// Test that property value interceptors can be applied to value types
void tst_qdeclarativevaluetypes::valueInterceptors()
{
- QDeclarativeComponent component(&engine, TEST_FILE("valueInterceptors.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("valueInterceptors.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
checkNoErrors(component);
QVERIFY(object != 0);
// Test that you can't assign a binding to the "root" value type, and a sub-property
void tst_qdeclarativevaluetypes::bindingConflict()
{
- QDeclarativeComponent component(&engine, TEST_FILE("bindingConflict.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("bindingConflict.qml"));
QCOMPARE(component.isError(), true);
}
// doesn't crash
void tst_qdeclarativevaluetypes::deletedObject()
{
- QDeclarativeComponent component(&engine, TEST_FILE("deletedObject.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("deletedObject.qml"));
QTest::ignoreMessage(QtDebugMsg, "Test: 2");
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
// Test that value types can be assigned to another value type property in a binding
void tst_qdeclarativevaluetypes::bindingVariantCopy()
{
- QDeclarativeComponent component(&engine, TEST_FILE("bindingVariantCopy.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("bindingVariantCopy.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
// Test that value types can be assigned to another value type property in script
void tst_qdeclarativevaluetypes::scriptVariantCopy()
{
- QDeclarativeComponent component(&engine, TEST_FILE("scriptVariantCopy.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("scriptVariantCopy.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
void tst_qdeclarativevaluetypes::enums()
{
{
- QDeclarativeComponent component(&engine, TEST_FILE("enums.1.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("enums.1.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
QVERIFY(object->font().capitalization() == QFont::AllUppercase);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("enums.2.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("enums.2.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
QVERIFY(object->font().capitalization() == QFont::AllUppercase);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("enums.3.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("enums.3.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
QVERIFY(object->font().capitalization() == QFont::AllUppercase);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("enums.4.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("enums.4.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
QVERIFY(object->font().capitalization() == QFont::AllUppercase);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("enums.5.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("enums.5.qml"));
MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create());
QVERIFY(object != 0);
QVERIFY(object->font().capitalization() == QFont::AllUppercase);
void tst_qdeclarativevaluetypes::conflictingBindings()
{
{
- QDeclarativeComponent component(&engine, TEST_FILE("conflicting.1.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("conflicting.1.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("conflicting.2.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("conflicting.2.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("conflicting.3.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("conflicting.3.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
void tst_qdeclarativevaluetypes::returnValues()
{
- QDeclarativeComponent component(&engine, TEST_FILE("returnValues.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("returnValues.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
void tst_qdeclarativevaluetypes::varAssignment()
{
- QDeclarativeComponent component(&engine, TEST_FILE("varAssignment.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("varAssignment.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
void tst_qdeclarativevaluetypes::bindingsSpliceCorrectly()
{
{
- QDeclarativeComponent component(&engine, TEST_FILE("bindingsSpliceCorrectly.1.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("bindingsSpliceCorrectly.1.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("bindingsSpliceCorrectly.2.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("bindingsSpliceCorrectly.2.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
{
- QDeclarativeComponent component(&engine, TEST_FILE("bindingsSpliceCorrectly.3.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("bindingsSpliceCorrectly.3.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("bindingsSpliceCorrectly.4.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("bindingsSpliceCorrectly.4.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("bindingsSpliceCorrectly.5.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("bindingsSpliceCorrectly.5.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
TARGET = tst_qdeclarativeworkerscript
macx:CONFIG -= app_bundle
-SOURCES += tst_qdeclarativeworkerscript.cpp
+SOURCES += tst_qdeclarativeworkerscript.cpp \
+ ../../shared/util.cpp
+HEADERS += ../../shared/util.h
testDataFiles.files = data
testDataFiles.path = .
#include <private/qdeclarativeengine_p.h>
#include "../../shared/util.h"
-inline QUrl TEST_FILE(const QString &filename)
-{
- return QUrl::fromLocalFile(TESTDATA(filename));
-}
-
-
-class tst_QDeclarativeWorkerScript : public QObject
+class tst_QDeclarativeWorkerScript : public QDeclarativeDataTest
{
Q_OBJECT
public:
void tst_QDeclarativeWorkerScript::source()
{
- QDeclarativeComponent component(&m_engine, TESTDATA("worker.qml"));
+ QDeclarativeComponent component(&m_engine, testFileUrl("worker.qml"));
QDeclarativeWorkerScript *worker = qobject_cast<QDeclarativeWorkerScript*>(component.create());
QVERIFY(worker != 0);
const QMetaObject *mo = worker->metaObject();
waitForEchoMessage(worker);
QCOMPARE(mo->property(mo->indexOfProperty("response")).read(worker).value<QVariant>(), value);
- QUrl source = QUrl::fromLocalFile(TESTDATA("script_fixed_return.js"));
+ QUrl source = testFileUrl("script_fixed_return.js");
worker->setSource(source);
QCOMPARE(worker->source(), source);
QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value)));
{
QFETCH(QVariant, value);
- QDeclarativeComponent component(&m_engine, TESTDATA("worker.qml"));
+ QDeclarativeComponent component(&m_engine, testFileUrl("worker.qml"));
QDeclarativeWorkerScript *worker = qobject_cast<QDeclarativeWorkerScript*>(component.create());
QVERIFY(worker != 0);
// instances. If objects are sent in a list, they will be sent as 'undefined'
// js values.
- QDeclarativeComponent component(&m_engine, TESTDATA("worker.qml"));
+ QDeclarativeComponent component(&m_engine, testFileUrl("worker.qml"));
QDeclarativeWorkerScript *worker = qobject_cast<QDeclarativeWorkerScript*>(component.create());
QVERIFY(worker != 0);
void tst_QDeclarativeWorkerScript::messaging_sendJsObject()
{
- QDeclarativeComponent component(&m_engine, TESTDATA("worker.qml"));
+ QDeclarativeComponent component(&m_engine, testFileUrl("worker.qml"));
QDeclarativeWorkerScript *worker = qobject_cast<QDeclarativeWorkerScript*>(component.create());
QVERIFY(worker != 0);
void tst_QDeclarativeWorkerScript::messaging_sendExternalObject()
{
- QDeclarativeComponent component(&m_engine, TESTDATA("externalObjectWorker.qml"));
+ QDeclarativeComponent component(&m_engine, testFileUrl("externalObjectWorker.qml"));
QObject *obj = component.create();
QVERIFY(obj);
QMetaObject::invokeMethod(obj, "testExternalObject");
{
QVariant value(100);
- QDeclarativeComponent component(&m_engine, TESTDATA("worker_pragma.qml"));
+ QDeclarativeComponent component(&m_engine, testFileUrl("worker_pragma.qml"));
QDeclarativeWorkerScript *worker = qobject_cast<QDeclarativeWorkerScript*>(component.create());
QVERIFY(worker != 0);
void tst_QDeclarativeWorkerScript::script_included()
{
- QDeclarativeComponent component(&m_engine, TESTDATA("worker_include.qml"));
+ QDeclarativeComponent component(&m_engine, testFileUrl("worker_include.qml"));
QDeclarativeWorkerScript *worker = qobject_cast<QDeclarativeWorkerScript*>(component.create());
QVERIFY(worker != 0);
void tst_QDeclarativeWorkerScript::scriptError_onLoad()
{
- QDeclarativeComponent component(&m_engine, TESTDATA("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("script_error_onLoad.js").toString() + QLatin1String(":3: SyntaxError: Unexpected identifier"));
+ testFileUrl("script_error_onLoad.js").toString() + QLatin1String(":3: SyntaxError: Unexpected identifier"));
qInstallMsgHandler(previousMsgHandler);
qApp->processEvents();
void tst_QDeclarativeWorkerScript::scriptError_onCall()
{
- QDeclarativeComponent component(&m_engine, TESTDATA("worker_error_onCall.qml"));
+ QDeclarativeComponent component(&m_engine, testFileUrl("worker_error_onCall.qml"));
QDeclarativeWorkerScript *worker = qobject_cast<QDeclarativeWorkerScript*>(component.create());
QVERIFY(worker != 0);
QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value)));
QTRY_COMPARE(qdeclarativeworkerscript_lastWarning,
- TEST_FILE("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();
{
for (int ii = 0; ii < 100; ++ii) {
QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, TESTDATA("stressDispose.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("stressDispose.qml"));
QObject *o = component.create();
QVERIFY(o);
delete o;
macx:CONFIG -= app_bundle
INCLUDEPATH += ../../shared/
-HEADERS += ../../shared/testhttpserver.h
+HEADERS += ../../shared/testhttpserver.h \
+ ../../shared/util.h
SOURCES += tst_qdeclarativexmlhttprequest.cpp \
- ../../shared/testhttpserver.cpp
+ ../../shared/testhttpserver.cpp \
+ ../../shared/util.cpp
testDataFiles.files = data
testDataFiles.path = .
#define SERVER_PORT 14445
-class tst_qdeclarativexmlhttprequest : public QObject
+class tst_qdeclarativexmlhttprequest : public QDeclarativeDataTest
{
Q_OBJECT
public:
QDeclarativeEngine engine;
};
-inline QUrl TEST_FILE(const QString &filename)
-{
- return QUrl::fromLocalFile(TESTDATA(filename));
-}
-
// Test that the dom exception codes are correct
void tst_qdeclarativexmlhttprequest::domExceptionCodes()
{
- QDeclarativeComponent component(&engine, TEST_FILE("domExceptionCodes.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("domExceptionCodes.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
QFETCH(QString, which);
QFETCH(int, line);
- QString expect = TEST_FILE("callbackException.qml").toString() + ":"+QString::number(line)+": Error: Exception from Callback";
+ QString expect = testFileUrl("callbackException.qml").toString() + ":"+QString::number(line)+": Error: Exception from Callback";
QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
- QDeclarativeComponent component(&engine, TEST_FILE("callbackException.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("callbackException.qml"));
QObject *object = component.beginCreate(engine.rootContext());
QVERIFY(object != 0);
object->setProperty("url", "testdocument.html");
// ### WebKit does not do this, but it seems to fit the standard and QML better
void tst_qdeclarativexmlhttprequest::staticStateValues()
{
- QDeclarativeComponent component(&engine, TEST_FILE("staticStateValues.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("staticStateValues.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
// Test that the state value properties on instances have the correct values.
void tst_qdeclarativexmlhttprequest::instanceStateValues()
{
- QDeclarativeComponent component(&engine, TEST_FILE("instanceStateValues.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("instanceStateValues.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
// Test calling constructor
void tst_qdeclarativexmlhttprequest::constructor()
{
- QDeclarativeComponent component(&engine, TEST_FILE("constructor.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("constructor.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
// Test that all the properties are set correctly before any request is sent
void tst_qdeclarativexmlhttprequest::defaultState()
{
- QDeclarativeComponent component(&engine, TEST_FILE("defaultState.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("defaultState.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
if (remote) {
server.reset(new TestHTTPServer(SERVER_PORT));
QVERIFY(server->isValid());
- QVERIFY(server->wait(TEST_FILE("open_network.expect"),
- TEST_FILE("open_network.reply"),
- TEST_FILE("testdocument.html")));
+ QVERIFY(server->wait(testFileUrl("open_network.expect"),
+ testFileUrl("open_network.reply"),
+ testFileUrl("testdocument.html")));
}
QDeclarativeComponent component(&engine, qmlFile);
QTest::addColumn<QString>("url");
QTest::addColumn<bool>("remote");
- QTest::newRow("Relative url)") << TEST_FILE("open.qml") << "testdocument.html" << false;
- QTest::newRow("Absolute url)") << TEST_FILE("open.qml") << TEST_FILE("testdocument.html").toString() << false;
- QTest::newRow("Absolute network url)") << TEST_FILE("open.qml") << "http://127.0.0.1:14445/testdocument.html" << true;
+ QTest::newRow("Relative url)") << testFileUrl("open.qml") << "testdocument.html" << false;
+ QTest::newRow("Absolute url)") << testFileUrl("open.qml") << testFileUrl("testdocument.html").toString() << false;
+ QTest::newRow("Absolute network url)") << testFileUrl("open.qml") << "http://127.0.0.1:14445/testdocument.html" << true;
// ### Check that the username/password were sent to the server
- QTest::newRow("User/pass") << TEST_FILE("open_user.qml") << "http://127.0.0.1:14445/testdocument.html" << true;
+ QTest::newRow("User/pass") << testFileUrl("open_user.qml") << "http://127.0.0.1:14445/testdocument.html" << true;
}
// Test that calling XMLHttpRequest.open() with an invalid method raises an exception
void tst_qdeclarativexmlhttprequest::open_invalid_method()
{
- QDeclarativeComponent component(&engine, TEST_FILE("open_invalid_method.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("open_invalid_method.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
// Test that calling XMLHttpRequest.open() with sync raises an exception
void tst_qdeclarativexmlhttprequest::open_sync()
{
- QDeclarativeComponent component(&engine, TEST_FILE("open_sync.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("open_sync.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
void tst_qdeclarativexmlhttprequest::open_arg_count()
{
{
- QDeclarativeComponent component(&engine, TEST_FILE("open_arg_count.1.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("open_arg_count.1.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("open_arg_count.2.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("open_arg_count.2.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
{
TestHTTPServer server(SERVER_PORT);
QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("setRequestHeader.expect"),
- TEST_FILE("setRequestHeader.reply"),
- TEST_FILE("testdocument.html")));
+ QVERIFY(server.wait(testFileUrl("setRequestHeader.expect"),
+ testFileUrl("setRequestHeader.reply"),
+ testFileUrl("testdocument.html")));
- QDeclarativeComponent component(&engine, TEST_FILE("setRequestHeader.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("setRequestHeader.qml"));
QObject *object = component.beginCreate(engine.rootContext());
QVERIFY(object != 0);
object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
{
TestHTTPServer server(SERVER_PORT);
QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("setRequestHeader.expect"),
- TEST_FILE("setRequestHeader.reply"),
- TEST_FILE("testdocument.html")));
+ QVERIFY(server.wait(testFileUrl("setRequestHeader.expect"),
+ testFileUrl("setRequestHeader.reply"),
+ testFileUrl("testdocument.html")));
- QDeclarativeComponent component(&engine, TEST_FILE("setRequestHeader_caseInsensitive.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("setRequestHeader_caseInsensitive.qml"));
QObject *object = component.beginCreate(engine.rootContext());
QVERIFY(object != 0);
object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
// Test setting headers before open() throws exception
void tst_qdeclarativexmlhttprequest::setRequestHeader_unsent()
{
- QDeclarativeComponent component(&engine, TEST_FILE("setRequestHeader_unsent.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("setRequestHeader_unsent.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
TestHTTPServer server(SERVER_PORT);
QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("open_network.expect"),
- TEST_FILE("open_network.reply"),
- TEST_FILE("testdocument.html")));
+ QVERIFY(server.wait(testFileUrl("open_network.expect"),
+ testFileUrl("open_network.reply"),
+ testFileUrl("testdocument.html")));
- QDeclarativeComponent component(&engine, TEST_FILE("setRequestHeader_illegalName.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("setRequestHeader_illegalName.qml"));
QObject *object = component.beginCreate(engine.rootContext());
QVERIFY(object != 0);
object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
{
TestHTTPServer server(SERVER_PORT);
QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("open_network.expect"),
- TEST_FILE("open_network.reply"),
- TEST_FILE("testdocument.html")));
+ QVERIFY(server.wait(testFileUrl("open_network.expect"),
+ testFileUrl("open_network.reply"),
+ testFileUrl("testdocument.html")));
- QDeclarativeComponent component(&engine, TEST_FILE("setRequestHeader_sent.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("setRequestHeader_sent.qml"));
QObject *object = component.beginCreate(engine.rootContext());
QVERIFY(object != 0);
object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
// Invalid arg count throws exception
void tst_qdeclarativexmlhttprequest::setRequestHeader_args()
{
- QDeclarativeComponent component(&engine, TEST_FILE("setRequestHeader_args.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("setRequestHeader_args.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
// Test that calling send() in UNSENT state throws an exception
void tst_qdeclarativexmlhttprequest::send_unsent()
{
- QDeclarativeComponent component(&engine, TEST_FILE("send_unsent.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("send_unsent.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
// Test attempting to resend a sent request throws an exception
void tst_qdeclarativexmlhttprequest::send_alreadySent()
{
- QDeclarativeComponent component(&engine, TEST_FILE("send_alreadySent.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("send_alreadySent.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
{
TestHTTPServer server(SERVER_PORT);
QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("send_ignoreData_GET.expect"),
- TEST_FILE("send_ignoreData.reply"),
- TEST_FILE("testdocument.html")));
+ QVERIFY(server.wait(testFileUrl("send_ignoreData_GET.expect"),
+ testFileUrl("send_ignoreData.reply"),
+ testFileUrl("testdocument.html")));
- QDeclarativeComponent component(&engine, TEST_FILE("send_ignoreData.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("send_ignoreData.qml"));
QObject *object = component.beginCreate(engine.rootContext());
QVERIFY(object != 0);
object->setProperty("reqType", "GET");
{
TestHTTPServer server(SERVER_PORT);
QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("send_ignoreData_HEAD.expect"),
- TEST_FILE("send_ignoreData.reply"),
+ QVERIFY(server.wait(testFileUrl("send_ignoreData_HEAD.expect"),
+ testFileUrl("send_ignoreData.reply"),
QUrl()));
- QDeclarativeComponent component(&engine, TEST_FILE("send_ignoreData.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("send_ignoreData.qml"));
QObject *object = component.beginCreate(engine.rootContext());
QVERIFY(object != 0);
object->setProperty("reqType", "HEAD");
{
TestHTTPServer server(SERVER_PORT);
QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("send_ignoreData_DELETE.expect"),
- TEST_FILE("send_ignoreData.reply"),
+ QVERIFY(server.wait(testFileUrl("send_ignoreData_DELETE.expect"),
+ testFileUrl("send_ignoreData.reply"),
QUrl()));
- QDeclarativeComponent component(&engine, TEST_FILE("send_ignoreData.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("send_ignoreData.qml"));
QObject *object = component.beginCreate(engine.rootContext());
QVERIFY(object != 0);
object->setProperty("reqType", "DELETE");
TestHTTPServer server(SERVER_PORT);
QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE(file_expected),
- TEST_FILE("send_data.reply"),
- TEST_FILE("testdocument.html")));
+ QVERIFY(server.wait(testFileUrl(file_expected),
+ testFileUrl("send_data.reply"),
+ testFileUrl("testdocument.html")));
- QDeclarativeComponent component(&engine, TEST_FILE(file_qml));
+ QDeclarativeComponent component(&engine, testFileUrl(file_qml));
QObject *object = component.beginCreate(engine.rootContext());
QVERIFY(object != 0);
object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
// Test abort() has no effect in unsent state
void tst_qdeclarativexmlhttprequest::abort_unsent()
{
- QDeclarativeComponent component(&engine, TEST_FILE("abort_unsent.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("abort_unsent.qml"));
QObject *object = component.beginCreate(engine.rootContext());
QVERIFY(object != 0);
object->setProperty("url", "testdocument.html");
// Test abort() cancels an open (but unsent) request
void tst_qdeclarativexmlhttprequest::abort_opened()
{
- QDeclarativeComponent component(&engine, TEST_FILE("abort_opened.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("abort_opened.qml"));
QObject *object = component.beginCreate(engine.rootContext());
QVERIFY(object != 0);
object->setProperty("url", "testdocument.html");
{
TestHTTPServer server(SERVER_PORT);
QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("abort.expect"),
- TEST_FILE("abort.reply"),
- TEST_FILE("testdocument.html")));
+ QVERIFY(server.wait(testFileUrl("abort.expect"),
+ testFileUrl("abort.reply"),
+ testFileUrl("testdocument.html")));
- QDeclarativeComponent component(&engine, TEST_FILE("abort.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("abort.qml"));
QObject *object = component.beginCreate(engine.rootContext());
QVERIFY(object != 0);
object->setProperty("urlDummy", "http://127.0.0.1:14449/testdocument.html");
TestHTTPServer server(SERVER_PORT);
QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("getResponseHeader.expect"),
- TEST_FILE("getResponseHeader.reply"),
- TEST_FILE("testdocument.html")));
+ QVERIFY(server.wait(testFileUrl("getResponseHeader.expect"),
+ testFileUrl("getResponseHeader.reply"),
+ testFileUrl("testdocument.html")));
- QDeclarativeComponent component(&engine, TEST_FILE("getResponseHeader.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("getResponseHeader.qml"));
QObject *object = component.beginCreate(engine.rootContext());
QVERIFY(object != 0);
object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
// Test getResponseHeader throws an exception in an invalid state
void tst_qdeclarativexmlhttprequest::getResponseHeader_unsent()
{
- QDeclarativeComponent component(&engine, TEST_FILE("getResponseHeader_unsent.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("getResponseHeader_unsent.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
// Test getResponseHeader throws an exception in an invalid state
void tst_qdeclarativexmlhttprequest::getResponseHeader_sent()
{
- QDeclarativeComponent component(&engine, TEST_FILE("getResponseHeader_sent.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("getResponseHeader_sent.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
// Invalid arg count throws exception
void tst_qdeclarativexmlhttprequest::getResponseHeader_args()
{
- QDeclarativeComponent component(&engine, TEST_FILE("getResponseHeader_args.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("getResponseHeader_args.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
TestHTTPServer server(SERVER_PORT);
QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("getResponseHeader.expect"),
- TEST_FILE("getResponseHeader.reply"),
- TEST_FILE("testdocument.html")));
+ QVERIFY(server.wait(testFileUrl("getResponseHeader.expect"),
+ testFileUrl("getResponseHeader.reply"),
+ testFileUrl("testdocument.html")));
- QDeclarativeComponent component(&engine, TEST_FILE("getAllResponseHeaders.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("getAllResponseHeaders.qml"));
QObject *object = component.beginCreate(engine.rootContext());
QVERIFY(object != 0);
object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
// Test getAllResponseHeaders throws an exception in an invalid state
void tst_qdeclarativexmlhttprequest::getAllResponseHeaders_unsent()
{
- QDeclarativeComponent component(&engine, TEST_FILE("getAllResponseHeaders_unsent.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("getAllResponseHeaders_unsent.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
// Test getAllResponseHeaders throws an exception in an invalid state
void tst_qdeclarativexmlhttprequest::getAllResponseHeaders_sent()
{
- QDeclarativeComponent component(&engine, TEST_FILE("getAllResponseHeaders_sent.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("getAllResponseHeaders_sent.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
// Invalid arg count throws exception
void tst_qdeclarativexmlhttprequest::getAllResponseHeaders_args()
{
- QDeclarativeComponent component(&engine, TEST_FILE("getAllResponseHeaders_args.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("getAllResponseHeaders_args.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
TestHTTPServer server(SERVER_PORT);
QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("status.expect"),
+ QVERIFY(server.wait(testFileUrl("status.expect"),
replyUrl,
- TEST_FILE("testdocument.html")));
+ testFileUrl("testdocument.html")));
- QDeclarativeComponent component(&engine, TEST_FILE("status.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("status.qml"));
QObject *object = component.beginCreate(engine.rootContext());
QVERIFY(object != 0);
object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
QTest::addColumn<QUrl>("replyUrl");
QTest::addColumn<int>("status");
- QTest::newRow("OK") << TEST_FILE("status.200.reply") << 200;
- QTest::newRow("Not Found") << TEST_FILE("status.404.reply") << 404;
- QTest::newRow("Bad Request") << TEST_FILE("status.400.reply") << 400;
+ QTest::newRow("OK") << testFileUrl("status.200.reply") << 200;
+ QTest::newRow("Not Found") << testFileUrl("status.404.reply") << 404;
+ QTest::newRow("Bad Request") << testFileUrl("status.400.reply") << 400;
}
void tst_qdeclarativexmlhttprequest::statusText()
TestHTTPServer server(SERVER_PORT);
QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("status.expect"),
+ QVERIFY(server.wait(testFileUrl("status.expect"),
replyUrl,
- TEST_FILE("testdocument.html")));
+ testFileUrl("testdocument.html")));
- QDeclarativeComponent component(&engine, TEST_FILE("statusText.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("statusText.qml"));
QObject *object = component.beginCreate(engine.rootContext());
QVERIFY(object != 0);
object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
QTest::addColumn<QUrl>("replyUrl");
QTest::addColumn<QString>("statusText");
- QTest::newRow("OK") << TEST_FILE("status.200.reply") << "OK";
- QTest::newRow("Not Found") << TEST_FILE("status.404.reply") << "Document not found";
- QTest::newRow("Bad Request") << TEST_FILE("status.400.reply") << "Bad request";
+ QTest::newRow("OK") << testFileUrl("status.200.reply") << "OK";
+ QTest::newRow("Not Found") << testFileUrl("status.404.reply") << "Document not found";
+ QTest::newRow("Bad Request") << testFileUrl("status.400.reply") << "Bad request";
}
void tst_qdeclarativexmlhttprequest::responseText()
TestHTTPServer server(SERVER_PORT);
QVERIFY(server.isValid());
- QVERIFY(server.wait(TEST_FILE("status.expect"),
+ QVERIFY(server.wait(testFileUrl("status.expect"),
replyUrl,
bodyUrl));
- QDeclarativeComponent component(&engine, TEST_FILE("responseText.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("responseText.qml"));
QObject *object = component.beginCreate(engine.rootContext());
QVERIFY(object != 0);
object->setProperty("url", "http://127.0.0.1:14445/testdocument.html");
QTest::addColumn<QUrl>("bodyUrl");
QTest::addColumn<QString>("responseText");
- QTest::newRow("OK") << TEST_FILE("status.200.reply") << TEST_FILE("testdocument.html") << "QML Rocks!\n";
- QTest::newRow("empty body") << TEST_FILE("status.200.reply") << QUrl() << "";
- QTest::newRow("Not Found") << TEST_FILE("status.404.reply") << TEST_FILE("testdocument.html") << "";
- QTest::newRow("Bad Request") << TEST_FILE("status.404.reply") << TEST_FILE("testdocument.html") << "";
+ QTest::newRow("OK") << testFileUrl("status.200.reply") << testFileUrl("testdocument.html") << "QML Rocks!\n";
+ QTest::newRow("empty body") << testFileUrl("status.200.reply") << QUrl() << "";
+ QTest::newRow("Not Found") << testFileUrl("status.404.reply") << testFileUrl("testdocument.html") << "";
+ QTest::newRow("Bad Request") << testFileUrl("status.404.reply") << testFileUrl("testdocument.html") << "";
}
void tst_qdeclarativexmlhttprequest::nonUtf8()
QFETCH(QString, responseText);
QFETCH(QString, xmlRootNodeValue);
- QDeclarativeComponent component(&engine, TEST_FILE("utf16.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("utf16.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
// throws an exception
void tst_qdeclarativexmlhttprequest::invalidMethodUsage()
{
- QDeclarativeComponent component(&engine, TEST_FILE("invalidMethodUsage.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("invalidMethodUsage.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
TestHTTPServer server(SERVER_PORT);
QVERIFY(server.isValid());
server.addRedirect("redirect.html", "http://127.0.0.1:14445/redirecttarget.html");
- server.serveDirectory(TESTDATA(""));
+ server.serveDirectory(dataDirectory());
- QDeclarativeComponent component(&engine, TEST_FILE("redirects.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("redirects.qml"));
QObject *object = component.beginCreate(engine.rootContext());
QVERIFY(object != 0);
object->setProperty("url", "http://127.0.0.1:14445/redirect.html");
TestHTTPServer server(SERVER_PORT);
QVERIFY(server.isValid());
server.addRedirect("redirect.html", "http://127.0.0.1:14445/redirectmissing.html");
- server.serveDirectory(TESTDATA(""));
+ server.serveDirectory(dataDirectory());
- QDeclarativeComponent component(&engine, TEST_FILE("redirectError.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("redirectError.qml"));
QObject *object = component.beginCreate(engine.rootContext());
QVERIFY(object != 0);
object->setProperty("url", "http://127.0.0.1:14445/redirect.html");
TestHTTPServer server(SERVER_PORT);
QVERIFY(server.isValid());
server.addRedirect("redirect.html", "http://127.0.0.1:14445/redirect.html");
- server.serveDirectory(TESTDATA(""));
+ server.serveDirectory(dataDirectory());
- QDeclarativeComponent component(&engine, TEST_FILE("redirectRecur.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("redirectRecur.qml"));
QObject *object = component.beginCreate(engine.rootContext());
QVERIFY(object != 0);
object->setProperty("url", "http://127.0.0.1:14445/redirect.html");
void tst_qdeclarativexmlhttprequest::responseXML_invalid()
{
- QDeclarativeComponent component(&engine, TEST_FILE("responseXML_invalid.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("responseXML_invalid.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
// Test the Document DOM element
void tst_qdeclarativexmlhttprequest::document()
{
- QDeclarativeComponent component(&engine, TEST_FILE("document.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("document.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
// Test the Element DOM element
void tst_qdeclarativexmlhttprequest::element()
{
- QDeclarativeComponent component(&engine, TEST_FILE("element.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("element.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
// Test the Attr DOM element
void tst_qdeclarativexmlhttprequest::attr()
{
- QDeclarativeComponent component(&engine, TEST_FILE("attr.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("attr.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
// Test the Text DOM element
void tst_qdeclarativexmlhttprequest::text()
{
- QDeclarativeComponent component(&engine, TEST_FILE("text.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("text.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
// Test the CDataSection DOM element
void tst_qdeclarativexmlhttprequest::cdata()
{
- QDeclarativeComponent component(&engine, TEST_FILE("cdata.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("cdata.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
#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:
void tst_v4::initTestCase()
{
+ QDeclarativeDataTest::initTestCase();
registerTypes();
}
QFETCH(QString, file);
QV4Compiler::enableBindingsTest(true);
- QDeclarativeComponent component(&engine, TEST_FILE(file));
+ QDeclarativeComponent component(&engine, testFileUrl(file));
v4ErrorsMsgCount = 0;
QtMsgHandler old = qInstallMsgHandler(v4ErrorsMsgHandler);
void tst_v4::unnecessaryReeval()
{
- QDeclarativeComponent component(&engine, TEST_FILE("unnecessaryReeval.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("unnecessaryReeval.qml"));
QObject *o = component.create();
QVERIFY(o != 0);
void tst_v4::logicalOr()
{
{
- QDeclarativeComponent component(&engine, TEST_FILE("logicalOr.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("logicalOr.qml"));
QObject *o = component.create();
QVERIFY(o != 0);
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("logicalOr.2.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("logicalOr.2.qml"));
QObject *o = component.create();
QVERIFY(o != 0);
void tst_v4::conditionalExpr()
{
{
- QDeclarativeComponent component(&engine, TEST_FILE("conditionalExpr.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("conditionalExpr.qml"));
QObject *o = component.create();
QVERIFY(o != 0);
// 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);
void tst_v4::subscriptionsInConditionalExpressions()
{
- QDeclarativeComponent component(&engine, TEST_FILE("subscriptionsInConditionalExpressions.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("subscriptionsInConditionalExpressions.qml"));
QObject *o = component.create();
QVERIFY(o != 0);
// 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());
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);
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 = .
CONFIG += testcase
TARGET = tst_qdeclarativeanimations
-SOURCES += tst_qdeclarativeanimations.cpp
+SOURCES += tst_qdeclarativeanimations.cpp \
+ ../../shared/util.cpp
+HEADERS += ../../shared/util.h
+
macx:CONFIG -= app_bundle
testDataFiles.files = data
#include "../../shared/util.h"
-class tst_qdeclarativeanimations : public QObject
+class tst_qdeclarativeanimations : public QDeclarativeDataTest
{
Q_OBJECT
public:
tst_qdeclarativeanimations() {}
private slots:
- void initTestCase() { QDeclarativeEngine engine; } // ensure types are registered
+ void initTestCase()
+ {
+ QDeclarativeEngine engine; // ensure types are registered
+ QDeclarativeDataTest::initTestCase();
+ }
void simpleProperty();
void simpleNumber();
{
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("pathAnimation.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("pathAnimation.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("pathAnimation2.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("pathAnimation2.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
void tst_qdeclarativeanimations::pathInterpolator()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("pathInterpolator.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("pathInterpolator.qml"));
QDeclarativePathInterpolator *interpolator = qobject_cast<QDeclarativePathInterpolator*>(c.create());
QVERIFY(interpolator);
void tst_qdeclarativeanimations::pathInterpolatorBackwardJump()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("pathInterpolatorBack.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("pathInterpolatorBack.qml"));
QDeclarativePathInterpolator *interpolator = qobject_cast<QDeclarativePathInterpolator*>(c.create());
QVERIFY(interpolator);
void tst_qdeclarativeanimations::pathWithNoStart()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("pathAnimationNoStart.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("pathAnimationNoStart.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
//don't crash
{
QQuickView *view = new QQuickView;
- view->setSource(QUrl::fromLocalFile(TESTDATA("badtype1.qml")));
+ view->setSource(testFileUrl("badtype1.qml"));
qApp->processEvents();
//make sure we get a compiler error
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("badtype2.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("badtype2.qml"));
QTest::ignoreMessage(QtWarningMsg, "QDeclarativeComponent: Component is not ready");
c.create();
//make sure we get a compiler error
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("badtype3.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("badtype3.qml"));
QTest::ignoreMessage(QtWarningMsg, "QDeclarativeComponent: Component is not ready");
c.create();
//don't crash
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("badtype4.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("badtype4.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c1(&engine, QUrl::fromLocalFile(TESTDATA("badproperty1.qml")));
- QByteArray message = QUrl::fromLocalFile(TESTDATA("badproperty1.qml")).toString().toUtf8() + ":18:9: QML ColorAnimation: Cannot animate non-existent property \"border.colr\"";
+ QDeclarativeComponent c1(&engine, testFileUrl("badproperty1.qml"));
+ QByteArray message = testFileUrl("badproperty1.qml").toString().toUtf8() + ":18:9: QML ColorAnimation: Cannot animate non-existent property \"border.colr\"";
QTest::ignoreMessage(QtWarningMsg, message);
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c1.create());
QVERIFY(rect);
- QDeclarativeComponent c2(&engine, QUrl::fromLocalFile(TESTDATA("badproperty2.qml")));
- message = QUrl::fromLocalFile(TESTDATA("badproperty2.qml")).toString().toUtf8() + ":18:9: QML ColorAnimation: Cannot animate read-only property \"border\"";
+ QDeclarativeComponent c2(&engine, testFileUrl("badproperty2.qml"));
+ message = testFileUrl("badproperty2.qml").toString().toUtf8() + ":18:9: QML ColorAnimation: Cannot animate read-only property \"border\"";
QTest::ignoreMessage(QtWarningMsg, message);
rect = qobject_cast<QQuickRectangle*>(c2.create());
QVERIFY(rect);
//assumes border.width stays a real -- not real robust
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("mixedtype1.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("mixedtype1.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("mixedtype2.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("mixedtype2.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
const int waitDuration = 300;
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("properties.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("properties.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("properties2.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("properties2.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("properties3.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("properties3.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("properties4.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("properties4.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("properties5.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("properties5.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
const int waitDuration = 300;
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("propertiesTransition.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("propertiesTransition.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("propertiesTransition2.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("propertiesTransition2.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("propertiesTransition3.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("propertiesTransition3.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("propertiesTransition4.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("propertiesTransition4.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("propertiesTransition5.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("propertiesTransition5.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
/*{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("propertiesTransition6.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("propertiesTransition6.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("propertiesTransition7.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("propertiesTransition7.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
void tst_qdeclarativeanimations::pathTransition()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("pathTransition.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("pathTransition.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
void tst_qdeclarativeanimations::disabledTransition()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("disabledTransition.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("disabledTransition.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("attached.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("attached.qml"));
QTest::ignoreMessage(QtDebugMsg, "off");
QTest::ignoreMessage(QtDebugMsg, "on");
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("valuesource.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("valuesource.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("valuesource2.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("valuesource2.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("dontAutoStart.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("dontAutoStart.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("dontStart.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("dontStart.qml"));
QString warning = c.url().toString() + ":14:13: QML NumberAnimation: setRunning() cannot be used on non-root animation nodes.";
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("dontStart2.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("dontStart2.qml"));
QString warning = c.url().toString() + ":15:17: QML NumberAnimation: setRunning() cannot be used on non-root animation nodes.";
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
void tst_qdeclarativeanimations::rotation()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("rotation.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("rotation.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
{
//ensure we start correctly when "running: true" is explicitly set
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("runningTrueBug.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("runningTrueBug.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
//in the case where an animation in the transition doesn't match anything (but previously did)
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("nonTransitionBug.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("nonTransitionBug.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect != 0);
QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("registrationBug.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("registrationBug.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect != 0);
QTRY_COMPARE(rect->property("value"), QVariant(int(100)));
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("doubleRegistrationBug.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("doubleRegistrationBug.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect != 0);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("transitionAssignmentBug.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("transitionAssignmentBug.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect != 0);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("pauseBindingBug.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("pauseBindingBug.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect != 0);
QDeclarativeAbstractAnimation *anim = rect->findChild<QDeclarativeAbstractAnimation*>("animation");
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("pauseBug.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("pauseBug.qml"));
QDeclarativeAbstractAnimation *anim = qobject_cast<QDeclarativeAbstractAnimation*>(c.create());
QVERIFY(anim != 0);
QCOMPARE(anim->qtAnimation()->state(), QAbstractAnimation::Paused);
CONFIG += testcase
TARGET = tst_qdeclarativebehaviors
-SOURCES += tst_qdeclarativebehaviors.cpp
+SOURCES += tst_qdeclarativebehaviors.cpp \
+ ../../shared/util.cpp
+HEADERS += ../../shared/util.h
+
macx:CONFIG -= app_bundle
testDataFiles.files = data
#include <private/qquickitem_p.h>
#include "../../shared/util.h"
-class tst_qdeclarativebehaviors : public QObject
+class tst_qdeclarativebehaviors : public QDeclarativeDataTest
{
Q_OBJECT
public:
void tst_qdeclarativebehaviors::simpleBehavior()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("simple.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("simple.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QTRY_VERIFY(rect);
QTRY_VERIFY(qobject_cast<QDeclarativeBehavior*>(rect->findChild<QDeclarativeBehavior*>("MyBehavior"))->animation());
void tst_qdeclarativebehaviors::scriptTriggered()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("scripttrigger.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("scripttrigger.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QTRY_VERIFY(rect);
void tst_qdeclarativebehaviors::cppTriggered()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("cpptrigger.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("cpptrigger.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QTRY_VERIFY(rect);
void tst_qdeclarativebehaviors::loop()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("loop.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("loop.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QTRY_VERIFY(rect);
void tst_qdeclarativebehaviors::colorBehavior()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("color.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("color.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QTRY_VERIFY(rect);
void tst_qdeclarativebehaviors::parentBehavior()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("parent.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("parent.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QTRY_VERIFY(rect);
void tst_qdeclarativebehaviors::replaceBinding()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("binding.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("binding.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QTRY_VERIFY(rect);
/* XXX TODO Create a test element for this case.
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("groupProperty.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("groupProperty.qml")));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
qDebug() << c.errorString();
QTRY_VERIFY(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("groupProperty2.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("groupProperty2.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QTRY_VERIFY(rect);
void tst_qdeclarativebehaviors::valueType()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("valueType.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("valueType.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
void tst_qdeclarativebehaviors::emptyBehavior()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("empty.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("empty.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
void tst_qdeclarativebehaviors::explicitSelection()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("explicit.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("explicit.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
void tst_qdeclarativebehaviors::nonSelectingBehavior()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("nonSelecting2.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("nonSelecting2.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
void tst_qdeclarativebehaviors::reassignedAnimation()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("reassignedAnimation.qml")));
- QString warning = QUrl::fromLocalFile(TESTDATA("reassignedAnimation.qml")).toString() + ":9:9: QML Behavior: Cannot change the animation assigned to a Behavior.";
+ QDeclarativeComponent c(&engine, testFileUrl("reassignedAnimation.qml"));
+ QString warning = testFileUrl("reassignedAnimation.qml").toString() + ":9:9: QML Behavior: Cannot change the animation assigned to a Behavior.";
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
void tst_qdeclarativebehaviors::disabled()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("disabled.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("disabled.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
QCOMPARE(rect->findChild<QDeclarativeBehavior*>("MyBehavior")->enabled(), false);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("dontStart.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("dontStart.qml"));
QString warning = c.url().toString() + ":13:13: QML NumberAnimation: setRunning() cannot be used on non-root animation nodes.";
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
{
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("startup.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("startup.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("startup2.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("startup2.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
void tst_qdeclarativebehaviors::groupedPropertyCrash()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("groupedPropertyCrash.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("groupedPropertyCrash.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect); //don't crash
void tst_qdeclarativebehaviors::runningTrue()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("runningTrue.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("runningTrue.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
void tst_qdeclarativebehaviors::sameValue()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("qtbug12295.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("qtbug12295.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("delayedRegistration.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("delayedRegistration.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect != 0);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("startOnCompleted.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("startOnCompleted.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect != 0);
TARGET = tst_qdeclarativefontloader
macx:CONFIG -= app_bundle
-HEADERS += ../../shared/testhttpserver.h
-SOURCES += tst_qdeclarativefontloader.cpp ../../shared/testhttpserver.cpp
+HEADERS += ../../shared/testhttpserver.h \
+ ../../shared/util.h
+SOURCES += tst_qdeclarativefontloader.cpp \
+ ../../shared/testhttpserver.cpp \
+ ../../shared/util.cpp
testDataFiles.files = data
testDataFiles.path = .
#define SERVER_PORT 14448
-class tst_qdeclarativefontloader : public QObject
+class tst_qdeclarativefontloader : public QDeclarativeDataTest
{
Q_OBJECT
public:
tst_qdeclarativefontloader();
private slots:
- void init();
+ void initTestCase();
void noFont();
void namedFont();
void localFont();
tst_qdeclarativefontloader::tst_qdeclarativefontloader() :
server(SERVER_PORT)
{
- server.serveDirectory(TESTDATA(""));
}
-void tst_qdeclarativefontloader::init()
+void tst_qdeclarativefontloader::initTestCase()
{
+ QDeclarativeDataTest::initTestCase();
+ server.serveDirectory(dataDirectory());
QVERIFY(server.isValid());
}
void tst_qdeclarativefontloader::localFont()
{
- QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"" + TESTDATA("tarzeau_ocr_a.ttf") + "\" }";
+ QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"" + testFile("tarzeau_ocr_a.ttf") + "\" }";
QDeclarativeComponent component(&engine);
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
QDeclarativeFontLoader *fontObject = qobject_cast<QDeclarativeFontLoader*>(component.create());
void tst_qdeclarativefontloader::failLocalFont()
{
- QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"" + QUrl::fromLocalFile(TESTDATA("dummy.ttf")).toString() + "\" }";
- QTest::ignoreMessage(QtWarningMsg, QString("file::2:1: QML FontLoader: Cannot load font: \"" + QUrl::fromLocalFile(TESTDATA("dummy.ttf")).toString() + "\"").toUtf8().constData());
+ QString componentStr = "import QtQuick 2.0\nFontLoader { source: \"" + testFileUrl("dummy.ttf").toString() + "\" }";
+ QTest::ignoreMessage(QtWarningMsg, QString("file::2:1: QML FontLoader: Cannot load font: \"" + testFileUrl("dummy.ttf").toString() + "\"").toUtf8().constData());
QDeclarativeComponent component(&engine);
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
QDeclarativeFontLoader *fontObject = qobject_cast<QDeclarativeFontLoader*>(component.create());
{
QString componentStr = "import QtQuick 2.0\nFontLoader { source: font }";
QDeclarativeContext *ctxt = engine.rootContext();
- ctxt->setContextProperty("font", QUrl::fromLocalFile(TESTDATA("tarzeau_ocr_a.ttf")));
+ ctxt->setContextProperty("font", testFileUrl("tarzeau_ocr_a.ttf"));
QDeclarativeComponent component(&engine);
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
QDeclarativeFontLoader *fontObject = qobject_cast<QDeclarativeFontLoader*>(component.create());
QCOMPARE(statusSpy.count(), 2);
QTRY_COMPARE(fontObject->name(), QString("Daniel"));
- ctxt->setContextProperty("font", QUrl::fromLocalFile(TESTDATA("tarzeau_ocr_a.ttf")));
+ ctxt->setContextProperty("font", testFileUrl("tarzeau_ocr_a.ttf"));
QTRY_VERIFY(fontObject->status() == QDeclarativeFontLoader::Ready);
QCOMPARE(nameSpy.count(), 2);
QCOMPARE(statusSpy.count(), 2);
void tst_qdeclarativefontloader::changeFontSourceViaState()
{
- QQuickView canvas(QUrl::fromLocalFile(TESTDATA("qtbug-20268.qml")));
+ QQuickView canvas(testFileUrl("qtbug-20268.qml"));
canvas.show();
canvas.requestActivateWindow();
QTest::qWaitForWindowShown(&canvas);
canvas.rootObject()->setProperty("usename", true);
// This warning should probably not be printed once QTBUG-20268 is fixed
- QString warning = QString(QUrl::fromLocalFile(TESTDATA("qtbug-20268.qml")).toString()) +
+ QString warning = QString(testFileUrl("qtbug-20268.qml").toString()) +
QLatin1String(":13:5: QML FontLoader: Cannot load font: \"\"");
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
TARGET = tst_qdeclarativepath
macx:CONFIG -= app_bundle
-SOURCES += tst_qdeclarativepath.cpp
+SOURCES += tst_qdeclarativepath.cpp \
+ ../../shared/util.cpp
+HEADERS += ../../shared/util.h
testDataFiles.files = data
testDataFiles.path = .
#include "../../shared/util.h"
-class tst_QDeclarativePath : public QObject
+class tst_QDeclarativePath : public QDeclarativeDataTest
{
Q_OBJECT
public:
void tst_QDeclarativePath::arc()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("arc.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("arc.qml"));
QDeclarativePath *obj = qobject_cast<QDeclarativePath*>(c.create());
QVERIFY(obj != 0);
void tst_QDeclarativePath::catmullromCurve()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("curve.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("curve.qml"));
QDeclarativePath *obj = qobject_cast<QDeclarativePath*>(c.create());
QVERIFY(obj != 0);
void tst_QDeclarativePath::svg()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("svg.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("svg.qml"));
QDeclarativePath *obj = qobject_cast<QDeclarativePath*>(c.create());
QVERIFY(obj != 0);
TARGET = tst_qdeclarativepixmapcache
macx:CONFIG -= app_bundle
-SOURCES += tst_qdeclarativepixmapcache.cpp
-
+SOURCES += tst_qdeclarativepixmapcache.cpp \
+ ../../shared/testhttpserver.cpp \
+ ../../shared/util.cpp
+HEADERS += ../../shared/testhttpserver.h \
+ ../../shared/util.h
INCLUDEPATH += ../../shared/
-HEADERS += ../../shared/testhttpserver.h
-SOURCES += ../../shared/testhttpserver.cpp
importFiles.files = data
importFiles.path = .
#define PIXMAP_DATA_LEAK_TEST 0
-inline QUrl TEST_FILE(const QString &filename)
-{
- return QUrl::fromLocalFile(TESTDATA(filename));
-}
-
-class tst_qdeclarativepixmapcache : public QObject
+class tst_qdeclarativepixmapcache : public QDeclarativeDataTest
{
Q_OBJECT
public:
- tst_qdeclarativepixmapcache() :
- server(14452)
- {
- server.serveDirectory(TESTDATA("http"));
- }
+ tst_qdeclarativepixmapcache() : server(14452) {}
private slots:
+ void initTestCase();
void single();
void single_data();
void parallel();
static const bool localfile_optimized = false;
#endif
+
+void tst_qdeclarativepixmapcache::initTestCase()
+{
+ QDeclarativeDataTest::initTestCase();
+ server.serveDirectory(testFile("http"));
+}
+
void tst_qdeclarativepixmapcache::single_data()
{
// Note, since QDeclarativePixmapCache is shared, tests affect each other!
QTest::addColumn<bool>("neterror");
// File URLs are optimized
- QTest::newRow("local") << TEST_FILE("exists.png") << localfile_optimized << true << false;
- QTest::newRow("local") << TEST_FILE("notexists.png") << localfile_optimized << false << false;
+ QTest::newRow("local") << testFileUrl("exists.png") << localfile_optimized << true << false;
+ QTest::newRow("local") << testFileUrl("notexists.png") << localfile_optimized << false << false;
QTest::newRow("remote") << QUrl("http://127.0.0.1:14452/exists.png") << false << true << false;
QTest::newRow("remote") << QUrl("http://127.0.0.1:14452/notexists.png") << false << false << true;
}
QTest::addColumn<int>("cancel"); // which one to cancel
QTest::newRow("local")
- << TEST_FILE("exists1.png")
- << TEST_FILE("exists2.png")
+ << testFileUrl("exists1.png")
+ << testFileUrl("exists2.png")
<< (localfile_optimized ? 2 : 0)
<< -1;
void tst_qdeclarativepixmapcache::massive()
{
QDeclarativeEngine engine;
- QUrl url = TEST_FILE("massive.png");
+ QUrl url = testFileUrl("massive.png");
// Confirm that massive images remain in the cache while they are
// in use by the application.
{
QEventLoop eventLoop;
TestHTTPServer server(14453);
- server.serveDirectory(TESTDATA("http"));
+ server.serveDirectory(QDeclarativeDataTest::instance()->testFile("http"));
QTimer::singleShot(100, &eventLoop, SLOT(quit()));
eventLoop.exec();
}
void tst_qdeclarativepixmapcache::lockingCrash()
{
TestHTTPServer server(14453);
- server.serveDirectory(TESTDATA("http"), TestHTTPServer::Delay);
+ server.serveDirectory(testFile("http"), TestHTTPServer::Delay);
{
QDeclarativePixmap* p = new QDeclarativePixmap;
public:
explicit DataLeakView() : QQuickView()
{
- setSource(TEST_FILE("dataLeak.qml"));
+ setSource(testFileUrl("dataLeak.qml"));
}
void showFor2Seconds()
{
QScopedPointer<DataLeakView> test(new DataLeakView);
test->showFor2Seconds();
- dataLeakPixmap()->load(test->engine(), TEST_FILE("exists.png"));
- p1->load(test->engine(), TEST_FILE("exists.png"));
- p2->load(test->engine(), TEST_FILE("exists2.png"));
+ dataLeakPixmap()->load(test->engine(), testFileUrl("exists.png"));
+ p1->load(test->engine(), testFileUrl("exists.png"));
+ p2->load(test->engine(), testFileUrl("exists2.png"));
QTest::qWait(2005); // 2 seconds + a few more millis.
}
TARGET = tst_qdeclarativesmoothedanimation
macx:CONFIG -= app_bundle
-SOURCES += tst_qdeclarativesmoothedanimation.cpp
+SOURCES += tst_qdeclarativesmoothedanimation.cpp \
+ ../../shared/util.cpp
+HEADERS += ../../shared/util.h
testDataFiles.files = data
testDataFiles.path = .
#include <private/qdeclarativevaluetype_p.h>
#include "../../shared/util.h"
-class tst_qdeclarativesmoothedanimation : public QObject
+class tst_qdeclarativesmoothedanimation : public QDeclarativeDataTest
{
Q_OBJECT
public:
void tst_qdeclarativesmoothedanimation::defaultValues()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("smoothedanimation1.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("smoothedanimation1.qml"));
QDeclarativeSmoothedAnimation *obj = qobject_cast<QDeclarativeSmoothedAnimation*>(c.create());
QVERIFY(obj != 0);
void tst_qdeclarativesmoothedanimation::values()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("smoothedanimation2.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("smoothedanimation2.qml"));
QDeclarativeSmoothedAnimation *obj = qobject_cast<QDeclarativeSmoothedAnimation*>(c.create());
QVERIFY(obj != 0);
void tst_qdeclarativesmoothedanimation::disabled()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("smoothedanimation3.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("smoothedanimation3.qml"));
QDeclarativeSmoothedAnimation *obj = qobject_cast<QDeclarativeSmoothedAnimation*>(c.create());
QVERIFY(obj != 0);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("smoothedanimationValueSource.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("smoothedanimationValueSource.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("smoothedanimationBehavior.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("smoothedanimationBehavior.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect);
TARGET = tst_qdeclarativespringanimation
macx:CONFIG -= app_bundle
-SOURCES += tst_qdeclarativespringanimation.cpp
+SOURCES += tst_qdeclarativespringanimation.cpp \
+ ../../shared/util.cpp
+HEADERS += ../../shared/util.h
testDataFiles.files = data
testDataFiles.path = .
#include <private/qdeclarativevaluetype_p.h>
#include "../../shared/util.h"
-class tst_qdeclarativespringanimation : public QObject
+class tst_qdeclarativespringanimation : public QDeclarativeDataTest
{
Q_OBJECT
public:
void tst_qdeclarativespringanimation::defaultValues()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("springanimation1.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("springanimation1.qml"));
QDeclarativeSpringAnimation *obj = qobject_cast<QDeclarativeSpringAnimation*>(c.create());
QVERIFY(obj != 0);
void tst_qdeclarativespringanimation::values()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("springanimation2.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("springanimation2.qml"));
QDeclarativeSpringAnimation *obj = qobject_cast<QDeclarativeSpringAnimation*>(c.create());
QVERIFY(obj != 0);
void tst_qdeclarativespringanimation::disabled()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("springanimation3.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("springanimation3.qml"));
QDeclarativeSpringAnimation *obj = qobject_cast<QDeclarativeSpringAnimation*>(c.create());
QVERIFY(obj != 0);
TARGET = tst_qdeclarativestates
macx:CONFIG -= app_bundle
-SOURCES += tst_qdeclarativestates.cpp
+SOURCES += tst_qdeclarativestates.cpp \
+ ../../shared/util.cpp
+HEADERS += ../../shared/util.h
testDataFiles.files = data
testDataFiles.path = .
QML_DECLARE_TYPE(MyRect)
QML_DECLARE_TYPEINFO(MyRect, QML_HAS_ATTACHED_PROPERTIES)
-class tst_qdeclarativestates : public QObject
+class tst_qdeclarativestates : public QDeclarativeDataTest
{
Q_OBJECT
public:
tst_qdeclarativestates() {}
private:
- static QByteArray fullDataPath(const QString &path);
+ QByteArray fullDataPath(const QString &path) const;
private slots:
void initTestCase();
void tst_qdeclarativestates::initTestCase()
{
+ QDeclarativeDataTest::initTestCase();
qmlRegisterType<MyRect>("Qt.test", 1, 0, "MyRectangle");
}
-QByteArray tst_qdeclarativestates::fullDataPath(const QString &path)
+QByteArray tst_qdeclarativestates::fullDataPath(const QString &path) const
{
- return QUrl::fromLocalFile(TESTDATA(path)).toString().toUtf8();
+ return testFileUrl(path).toString().toUtf8();
}
void tst_qdeclarativestates::basicChanges()
QDeclarativeEngine engine;
{
- QDeclarativeComponent rectComponent(&engine, TESTDATA("basicChanges.qml"));
+ QDeclarativeComponent rectComponent(&engine, testFileUrl("basicChanges.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
QVERIFY(rect != 0);
}
{
- QDeclarativeComponent rectComponent(&engine, TESTDATA("basicChanges2.qml"));
+ QDeclarativeComponent rectComponent(&engine, testFileUrl("basicChanges2.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
QVERIFY(rect != 0);
}
{
- QDeclarativeComponent rectComponent(&engine, TESTDATA("basicChanges3.qml"));
+ QDeclarativeComponent rectComponent(&engine, testFileUrl("basicChanges3.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
QVERIFY(rect != 0);
// signal using 'onPropertyWithNotifyChanged' even though the signal name is
// actually 'oddlyNamedNotifySignal'
- QDeclarativeComponent component(&engine, TESTDATA("basicChanges4.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("basicChanges4.qml"));
QVERIFY(component.isReady());
MyRect *rect = qobject_cast<MyRect*>(component.create());
{
QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, TESTDATA("attachedPropertyChanges.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("attachedPropertyChanges.qml"));
QVERIFY(component.isReady());
QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
QDeclarativeEngine engine;
{
- QDeclarativeComponent rectComponent(&engine, TESTDATA("basicExtension.qml"));
+ QDeclarativeComponent rectComponent(&engine, testFileUrl("basicExtension.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
QVERIFY(rect != 0);
}
{
- QDeclarativeComponent rectComponent(&engine, TESTDATA("fakeExtension.qml"));
+ QDeclarativeComponent rectComponent(&engine, testFileUrl("fakeExtension.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
QVERIFY(rect != 0);
QDeclarativeEngine engine;
{
- QDeclarativeComponent rectComponent(&engine, TESTDATA("basicBinding.qml"));
+ QDeclarativeComponent rectComponent(&engine, testFileUrl("basicBinding.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
QVERIFY(rect != 0);
}
{
- QDeclarativeComponent rectComponent(&engine, TESTDATA("basicBinding2.qml"));
+ QDeclarativeComponent rectComponent(&engine, testFileUrl("basicBinding2.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
QVERIFY(rect != 0);
}
{
- QDeclarativeComponent rectComponent(&engine, TESTDATA("basicBinding3.qml"));
+ QDeclarativeComponent rectComponent(&engine, testFileUrl("basicBinding3.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
QVERIFY(rect != 0);
}
{
- QDeclarativeComponent rectComponent(&engine, TESTDATA("basicBinding4.qml"));
+ QDeclarativeComponent rectComponent(&engine, testFileUrl("basicBinding4.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
QVERIFY(rect != 0);
QDeclarativeEngine engine;
{
- QDeclarativeComponent rectComponent(&engine, TESTDATA("signalOverride.qml"));
+ QDeclarativeComponent rectComponent(&engine, testFileUrl("signalOverride.qml"));
MyRect *rect = qobject_cast<MyRect*>(rectComponent.create());
QVERIFY(rect != 0);
}
{
- QDeclarativeComponent rectComponent(&engine, TESTDATA("signalOverride2.qml"));
+ QDeclarativeComponent rectComponent(&engine, testFileUrl("signalOverride2.qml"));
MyRect *rect = qobject_cast<MyRect*>(rectComponent.create());
QVERIFY(rect != 0);
{
QDeclarativeEngine engine;
- QDeclarativeComponent rectComponent(&engine, TESTDATA("signalOverrideCrash.qml"));
+ QDeclarativeComponent rectComponent(&engine, testFileUrl("signalOverrideCrash.qml"));
MyRect *rect = qobject_cast<MyRect*>(rectComponent.create());
QVERIFY(rect != 0);
{
QDeclarativeEngine engine;
- QDeclarativeComponent rectComponent(&engine, TESTDATA("signalOverrideCrash2.qml"));
+ QDeclarativeComponent rectComponent(&engine, testFileUrl("signalOverrideCrash2.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
QVERIFY(rect != 0);
{
QDeclarativeEngine engine;
- QDeclarativeComponent rectComponent(&engine, TESTDATA("signalOverrideCrash3.qml"));
+ QDeclarativeComponent rectComponent(&engine, testFileUrl("signalOverrideCrash3.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
QVERIFY(rect != 0);
QDeclarativeEngine engine;
{
- QDeclarativeComponent rectComponent(&engine, TESTDATA("parentChange1.qml"));
+ QDeclarativeComponent rectComponent(&engine, testFileUrl("parentChange1.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
QVERIFY(rect != 0);
}
{
- QDeclarativeComponent rectComponent(&engine, TESTDATA("parentChange2.qml"));
+ QDeclarativeComponent rectComponent(&engine, testFileUrl("parentChange2.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
QVERIFY(rect != 0);
QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
}
{
- QDeclarativeComponent rectComponent(&engine, TESTDATA("parentChange3.qml"));
+ QDeclarativeComponent rectComponent(&engine, testFileUrl("parentChange3.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
QVERIFY(rect != 0);
QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
}
{
- QDeclarativeComponent rectComponent(&engine, TESTDATA("parentChange6.qml"));
+ QDeclarativeComponent rectComponent(&engine, testFileUrl("parentChange6.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
QVERIFY(rect != 0);
QDeclarativeEngine engine;
{
- QDeclarativeComponent rectComponent(&engine, TESTDATA("parentChange4.qml"));
+ QDeclarativeComponent rectComponent(&engine, testFileUrl("parentChange4.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
QVERIFY(rect != 0);
}
{
- QDeclarativeComponent rectComponent(&engine, TESTDATA("parentChange5.qml"));
+ QDeclarativeComponent rectComponent(&engine, testFileUrl("parentChange5.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
QVERIFY(rect != 0);
{
QDeclarativeEngine engine;
- QDeclarativeComponent rectComponent(&engine, TESTDATA("anchorChanges1.qml"));
+ QDeclarativeComponent rectComponent(&engine, testFileUrl("anchorChanges1.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
QVERIFY(rect != 0);
QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent rectComponent(&engine, TESTDATA("anchorChanges2.qml"));
+ QDeclarativeComponent rectComponent(&engine, testFileUrl("anchorChanges2.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
QVERIFY(rect != 0);
QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent rectComponent(&engine, TESTDATA("anchorChanges3.qml"));
+ QDeclarativeComponent rectComponent(&engine, testFileUrl("anchorChanges3.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
QVERIFY(rect != 0);
QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent rectComponent(&engine, TESTDATA("anchorChanges4.qml"));
+ QDeclarativeComponent rectComponent(&engine, testFileUrl("anchorChanges4.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
QVERIFY(rect != 0);
{
QDeclarativeEngine engine;
- QDeclarativeComponent rectComponent(&engine, TESTDATA("anchorChanges5.qml"));
+ QDeclarativeComponent rectComponent(&engine, testFileUrl("anchorChanges5.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
QVERIFY(rect != 0);
{
QDeclarativeEngine engine;
- QDeclarativeComponent rectComponent(&engine, TESTDATA("anchorChanges1.qml"));
+ QDeclarativeComponent rectComponent(&engine, testFileUrl("anchorChanges1.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
QVERIFY(rect != 0);
QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent rectComponent(&engine, TESTDATA("anchorChanges2.qml"));
+ QDeclarativeComponent rectComponent(&engine, testFileUrl("anchorChanges2.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
QVERIFY(rect != 0);
QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent rectComponent(&engine, TESTDATA("anchorChanges3.qml"));
+ QDeclarativeComponent rectComponent(&engine, testFileUrl("anchorChanges3.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
QVERIFY(rect != 0);
QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent rectComponent(&engine, TESTDATA("anchorChangesCrash.qml"));
+ QDeclarativeComponent rectComponent(&engine, testFileUrl("anchorChangesCrash.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
QVERIFY(rect != 0);
void tst_qdeclarativestates::anchorRewindBug()
{
QQuickView *view = new QQuickView;
- view->setSource(QUrl::fromLocalFile(TESTDATA("anchorRewindBug.qml")));
+ view->setSource(testFileUrl("anchorRewindBug.qml"));
view->show();
view->requestActivateWindow();
{
QDeclarativeEngine engine;
- QDeclarativeComponent rectComponent(&engine, TESTDATA("anchorRewindBug2.qml"));
+ QDeclarativeComponent rectComponent(&engine, testFileUrl("anchorRewindBug2.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
QVERIFY(rect != 0);
QDeclarativeEngine engine;
{
- QDeclarativeComponent rectComponent(&engine, TESTDATA("script.qml"));
+ QDeclarativeComponent rectComponent(&engine, testFileUrl("script.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
QVERIFY(rect != 0);
QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent rectComponent(&engine, TESTDATA("restoreEntryValues.qml"));
+ QDeclarativeComponent rectComponent(&engine, testFileUrl("restoreEntryValues.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
QVERIFY(rect != 0);
QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent rectComponent(&engine, TESTDATA("explicit.qml"));
+ QDeclarativeComponent rectComponent(&engine, testFileUrl("explicit.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
QVERIFY(rect != 0);
QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
void tst_qdeclarativestates::propertyErrors()
{
QDeclarativeEngine engine;
- QDeclarativeComponent rectComponent(&engine, TESTDATA("propertyErrors.qml"));
+ QDeclarativeComponent rectComponent(&engine, testFileUrl("propertyErrors.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
QVERIFY(rect != 0);
{
QDeclarativeEngine engine;
- QDeclarativeComponent rectComponent(&engine, TESTDATA("basicChanges.qml"));
+ QDeclarativeComponent rectComponent(&engine, testFileUrl("basicChanges.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
QVERIFY(rect != 0);
QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, TESTDATA("autoStateAtStartupRestoreBug.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("autoStateAtStartupRestoreBug.qml"));
QObject *obj = component.create();
QVERIFY(obj != 0);
{
QDeclarativeEngine engine;
- QDeclarativeComponent rectComponent(&engine, TESTDATA("deleting.qml"));
+ QDeclarativeComponent rectComponent(&engine, testFileUrl("deleting.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
QVERIFY(rect != 0);
QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent rectComponent(&engine, TESTDATA("deletingState.qml"));
+ QDeclarativeComponent rectComponent(&engine, testFileUrl("deletingState.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
QVERIFY(rect != 0);
{
QDeclarativeEngine engine;
- QDeclarativeComponent rectComponent(&engine, TESTDATA("legalTempState.qml"));
+ QDeclarativeComponent rectComponent(&engine, testFileUrl("legalTempState.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
QVERIFY(rect != 0);
QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent rectComponent(&engine, TESTDATA("illegalTempState.qml"));
+ QDeclarativeComponent rectComponent(&engine, testFileUrl("illegalTempState.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
QVERIFY(rect != 0);
QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent rectComponent(&engine, TESTDATA("nonExistantProp.qml"));
+ QDeclarativeComponent rectComponent(&engine, testFileUrl("nonExistantProp.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(rectComponent.create());
QVERIFY(rect != 0);
QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, TESTDATA("reset.qml"));
+ QDeclarativeComponent c(&engine, testFileUrl("reset.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect != 0);
{
QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, TESTDATA("illegalObj.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("illegalObj.qml"));
QList<QDeclarativeError> errors = component.errors();
QVERIFY(errors.count() == 1);
const QDeclarativeError &error = errors.at(0);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, TESTDATA("whenOrdering.qml"));
+ QDeclarativeComponent c(&engine, testFileUrl("whenOrdering.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect != 0);
QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, TESTDATA("urlResolution.qml"));
+ QDeclarativeComponent c(&engine, testFileUrl("urlResolution.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect != 0);
QVERIFY(myType != 0 && image1 != 0 && image2 != 0 && image3 != 0);
QQuickItemPrivate::get(myType)->setState("SetImageState");
- QUrl resolved = QUrl::fromLocalFile(TESTDATA("Implementation/images/qt-logo.png"));
+ QUrl resolved = testFileUrl("Implementation/images/qt-logo.png");
QCOMPARE(image1->source(), resolved);
QCOMPARE(image2->source(), resolved);
QCOMPARE(image3->source(), resolved);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, TESTDATA("unnamedWhen.qml"));
+ QDeclarativeComponent c(&engine, testFileUrl("unnamedWhen.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect != 0);
QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, TESTDATA("returnToBase.qml"));
+ QDeclarativeComponent c(&engine, testFileUrl("returnToBase.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect != 0);
QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, TESTDATA("extendsBug.qml"));
+ QDeclarativeComponent c(&engine, testFileUrl("extendsBug.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect != 0);
QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, TESTDATA("editProperties.qml"));
+ QDeclarativeComponent c(&engine, testFileUrl("editProperties.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect != 0);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, TESTDATA("QTBUG-14830.qml"));
+ QDeclarativeComponent c(&engine, testFileUrl("QTBUG-14830.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect != 0);
QQuickItem *item = rect->findChild<QQuickItem*>("area");
QDeclarativeEngine engine;
//shouldn't fast forward if there isn't a transition
- QDeclarativeComponent c(&engine, TESTDATA("avoidFastForward.qml"));
+ QDeclarativeComponent c(&engine, testFileUrl("avoidFastForward.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect != 0);
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, TESTDATA("revertListBug.qml"));
+ QDeclarativeComponent c(&engine, testFileUrl("revertListBug.qml"));
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(c.create());
QVERIFY(rect != 0);
TARGET = tst_qdeclarativexmllistmodel
macx:CONFIG -= app_bundle
-SOURCES += tst_qdeclarativexmllistmodel.cpp
+SOURCES += tst_qdeclarativexmllistmodel.cpp \
+ ../../shared/util.cpp
+HEADERS += ../../shared/util.h
+
testDataFiles.files = data
testDataFiles.path = .
DEPLOYMENT += testDataFiles
Q_DECLARE_METATYPE(QDeclarativeXmlModelData)
Q_DECLARE_METATYPE(QDeclarativeXmlListModel::Status)
-class tst_qdeclarativexmllistmodel : public QObject
+class tst_qdeclarativexmllistmodel : public QDeclarativeDataTest
{
Q_OBJECT
private slots:
void initTestCase() {
+ QDeclarativeDataTest::initTestCase();
qRegisterMetaType<QDeclarativeXmlListModel::Status>();
}
void tst_qdeclarativexmllistmodel::buildModel()
{
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("model.qml")));
+ QDeclarativeComponent component(&engine, testFileUrl("model.qml"));
QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
QVERIFY(model != 0);
QTRY_COMPARE(model->count(), 9);
QFETCH(QString, roleName);
QFETCH(QVariant, expectedValue);
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("testtypes.qml")));
+ QDeclarativeComponent component(&engine, testFileUrl("testtypes.qml"));
QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
QVERIFY(model != 0);
model->setProperty("xml",xml.toUtf8());
void tst_qdeclarativexmllistmodel::cdata()
{
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("recipes.qml")));
+ QDeclarativeComponent component(&engine, testFileUrl("recipes.qml"));
QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
QVERIFY(model != 0);
QTRY_COMPARE(model->count(), 5);
void tst_qdeclarativexmllistmodel::attributes()
{
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("recipes.qml")));
+ QDeclarativeComponent component(&engine, testFileUrl("recipes.qml"));
QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
QVERIFY(model != 0);
QTRY_COMPARE(model->count(), 5);
void tst_qdeclarativexmllistmodel::roles()
{
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("model.qml")));
+ QDeclarativeComponent component(&engine, testFileUrl("model.qml"));
QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
QVERIFY(model != 0);
QTRY_COMPARE(model->count(), 9);
void tst_qdeclarativexmllistmodel::roleErrors()
{
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("roleErrors.qml")));
- QTest::ignoreMessage(QtWarningMsg, (QUrl::fromLocalFile(TESTDATA("roleErrors.qml")).toString() + ":7:5: QML XmlRole: An XmlRole query must not start with '/'").toUtf8().constData());
- QTest::ignoreMessage(QtWarningMsg, (QUrl::fromLocalFile(TESTDATA("roleErrors.qml")).toString() + ":10:5: QML XmlRole: invalid query: \"age/\"").toUtf8().constData());
+ QDeclarativeComponent component(&engine, testFileUrl("roleErrors.qml"));
+ QTest::ignoreMessage(QtWarningMsg, (testFileUrl("roleErrors.qml").toString() + ":7:5: QML XmlRole: An XmlRole query must not start with '/'").toUtf8().constData());
+ QTest::ignoreMessage(QtWarningMsg, (testFileUrl("roleErrors.qml").toString() + ":10:5: QML XmlRole: invalid query: \"age/\"").toUtf8().constData());
//### make sure we receive all expected warning messages.
QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
void tst_qdeclarativexmllistmodel::uniqueRoleNames()
{
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("unique.qml")));
- QTest::ignoreMessage(QtWarningMsg, (QUrl::fromLocalFile(TESTDATA("unique.qml")).toString() + ":8:5: QML XmlRole: \"name\" duplicates a previous role name and will be disabled.").toUtf8().constData());
+ QDeclarativeComponent component(&engine, testFileUrl("unique.qml"));
+ QTest::ignoreMessage(QtWarningMsg, (testFileUrl("unique.qml").toString() + ":8:5: QML XmlRole: \"name\" duplicates a previous role name and will be disabled.").toUtf8().constData());
QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
QVERIFY(model != 0);
QTRY_COMPARE(model->count(), 9);
QFETCH(QString, xml);
QFETCH(int, count);
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("model.qml")));
+ QDeclarativeComponent component(&engine, testFileUrl("model.qml"));
QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
QSignalSpy spy(model, SIGNAL(statusChanged(QDeclarativeXmlListModel::Status)));
CustomNetworkAccessManagerFactory factory;
qmlEng.setNetworkAccessManagerFactory(&factory);
- QDeclarativeComponent component(&qmlEng, QUrl::fromLocalFile(TESTDATA("model.qml")));
+ QDeclarativeComponent component(&qmlEng, testFileUrl("model.qml"));
QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
QVERIFY(model != 0);
QTRY_COMPARE(qvariant_cast<QDeclarativeXmlListModel::Status>(model->property("status")),
QFETCH(int, count);
QFETCH(QDeclarativeXmlListModel::Status, status);
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("model.qml")));
+ QDeclarativeComponent component(&engine, testFileUrl("model.qml"));
QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
QSignalSpy spy(model, SIGNAL(statusChanged(QDeclarativeXmlListModel::Status)));
QTest::addColumn<int>("count");
QTest::addColumn<QDeclarativeXmlListModel::Status>("status");
- QTest::newRow("valid") << QUrl::fromLocalFile(TESTDATA("model2.xml")) << 2
+ QTest::newRow("valid") << testFileUrl("model2.xml") << 2
<< QDeclarativeXmlListModel::Ready;
QTest::newRow("invalid") << QUrl("http://blah.blah/blah.xml") << 0
<< QDeclarativeXmlListModel::Error;
void tst_qdeclarativexmllistmodel::data()
{
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("model.qml")));
+ QDeclarativeComponent component(&engine, testFileUrl("model.qml"));
QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
QVERIFY(model != 0);
void tst_qdeclarativexmllistmodel::get()
{
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("get.qml")));
+ QDeclarativeComponent component(&engine, testFileUrl("get.qml"));
QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
QVERIFY(model != 0);
// If no keys are used, the model should be rebuilt from scratch when
// reload() is called.
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("model.qml")));
+ QDeclarativeComponent component(&engine, testFileUrl("model.qml"));
QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
QVERIFY(model != 0);
QTRY_COMPARE(model->count(), 9);
QFETCH(QList<QDeclarativeXmlListRange>, insertRanges);
QFETCH(QList<QDeclarativeXmlListRange>, removeRanges);
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("roleKeys.qml")));
+ QDeclarativeComponent component(&engine, testFileUrl("roleKeys.qml"));
QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
QVERIFY(model != 0);
// If a 'sport' value is changed, the model should not be reloaded,
// since 'sport' is not marked as a key.
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("roleKeys.qml")));
+ QDeclarativeComponent component(&engine, testFileUrl("roleKeys.qml"));
QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
QVERIFY(model != 0);
// delete all its data and build a clean model (i.e. same behaviour as
// if no keys are set).
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("roleKeys.qml")));
+ QDeclarativeComponent component(&engine, testFileUrl("roleKeys.qml"));
QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
QVERIFY(model != 0);
{
QFETCH(int, xmlDataCount);
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("roleKeys.qml")));
+ QDeclarativeComponent component(&engine, testFileUrl("roleKeys.qml"));
QListModelInterface *m1 = qobject_cast<QListModelInterface*>(component.create());
QVERIFY(m1 != 0);
void tst_qdeclarativexmllistmodel::propertyChanges()
{
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("propertychanges.qml")));
+ QDeclarativeComponent component(&engine, testFileUrl("propertychanges.qml"));
QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
QVERIFY(model != 0);
QTRY_COMPARE(model->count(), 9);
void tst_qdeclarativexmllistmodel::roleCrash()
{
// don't crash
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("roleCrash.qml")));
+ QDeclarativeComponent component(&engine, testFileUrl("roleCrash.qml"));
QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
QVERIFY(model != 0);
delete model;
TARGET = tst_qquickanchors
CONFIG += testcase
-SOURCES += tst_qquickanchors.cpp
+SOURCES += tst_qquickanchors.cpp \
+ ../../shared/util.cpp
+HEADERS += ../../shared/util.h
+
macx:CONFIG -= app_bundle
testDataFiles.files = data
Q_DECLARE_METATYPE(QQuickAnchors::Anchor)
Q_DECLARE_METATYPE(QQuickAnchorLine::AnchorLine)
-class tst_qquickanchors : public QObject
+class tst_qquickanchors : public QDeclarativeDataTest
{
Q_OBJECT
public:
void tst_qquickanchors::basicAnchors()
{
QQuickView *view = new QQuickView;
- view->setSource(QUrl::fromLocalFile(TESTDATA("anchors.qml")));
+ view->setSource(testFileUrl("anchors.qml"));
qApp->processEvents();
void tst_qquickanchors::basicAnchorsRTL()
{
QQuickView *view = new QQuickView;
- view->setSource(QUrl::fromLocalFile(TESTDATA("anchors.qml")));
+ view->setSource(testFileUrl("anchors.qml"));
qApp->processEvents();
void tst_qquickanchors::loops()
{
{
- QUrl source(QUrl::fromLocalFile(TESTDATA("loop1.qml")));
+ QUrl source(testFileUrl("loop1.qml"));
QString expect = source.toString() + ":6:5: QML Text: Possible anchor loop detected on horizontal anchor.";
QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
}
{
- QUrl source(QUrl::fromLocalFile(TESTDATA("loop2.qml")));
+ QUrl source(testFileUrl("loop2.qml"));
QString expect = source.toString() + ":8:3: QML Image: Possible anchor loop detected on horizontal anchor.";
QTest::ignoreMessage(QtWarningMsg, expect.toLatin1());
//QTBUG-5428
void tst_qquickanchors::crash1()
{
- QUrl source(QUrl::fromLocalFile(TESTDATA("crash1.qml")));
+ QUrl source(testFileUrl("crash1.qml"));
QString expect = source.toString() + ":3:1: QML Column: Cannot specify top, bottom, verticalCenter, fill or centerIn anchors for items inside Column";
void tst_qquickanchors::fill()
{
- QQuickView *view = new QQuickView(QUrl::fromLocalFile(TESTDATA("fill.qml")));
+ QQuickView *view = new QQuickView(testFileUrl("fill.qml"));
qApp->processEvents();
QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("filler"));
void tst_qquickanchors::fillRTL()
{
- QQuickView *view = new QQuickView(QUrl::fromLocalFile(TESTDATA("fill.qml")));
+ QQuickView *view = new QQuickView(testFileUrl("fill.qml"));
qApp->processEvents();
QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("filler"));
void tst_qquickanchors::centerIn()
{
- QQuickView *view = new QQuickView(QUrl::fromLocalFile(TESTDATA("centerin.qml")));
+ QQuickView *view = new QQuickView(testFileUrl("centerin.qml"));
qApp->processEvents();
QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("centered"));
void tst_qquickanchors::centerInRTL()
{
- QQuickView *view = new QQuickView(QUrl::fromLocalFile(TESTDATA("centerin.qml")));
+ QQuickView *view = new QQuickView(testFileUrl("centerin.qml"));
qApp->processEvents();
QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("centered"));
//QTBUG-12441
void tst_qquickanchors::centerInRotation()
{
- QQuickView *view = new QQuickView(QUrl::fromLocalFile(TESTDATA("centerinRotation.qml")));
+ QQuickView *view = new QQuickView(testFileUrl("centerinRotation.qml"));
qApp->processEvents();
QQuickRectangle* outer = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("outer"));
void tst_qquickanchors::hvCenter()
{
- QQuickView *view = new QQuickView(QUrl::fromLocalFile(TESTDATA("hvCenter.qml")));
+ QQuickView *view = new QQuickView(testFileUrl("hvCenter.qml"));
qApp->processEvents();
QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("centered"));
void tst_qquickanchors::hvCenterRTL()
{
- QQuickView *view = new QQuickView(QUrl::fromLocalFile(TESTDATA("hvCenter.qml")));
+ QQuickView *view = new QQuickView(testFileUrl("hvCenter.qml"));
qApp->processEvents();
QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("centered"));
}
void tst_qquickanchors::margins()
{
- QQuickView *view = new QQuickView(QUrl::fromLocalFile(TESTDATA("margins.qml")));
+ QQuickView *view = new QQuickView(testFileUrl("margins.qml"));
qApp->processEvents();
QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("filler"));
void tst_qquickanchors::marginsRTL()
{
- QQuickView *view = new QQuickView(QUrl::fromLocalFile(TESTDATA("margins.qml")));
+ QQuickView *view = new QQuickView(testFileUrl("margins.qml"));
QQuickRectangle* rect = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("filler"));
QQuickItemPrivate *rectPrivate = QQuickItemPrivate::get(rect);
CONFIG += testcase
TARGET = tst_qquickanimatedimage
-HEADERS += ../../shared/testhttpserver.h
-SOURCES += tst_qquickanimatedimage.cpp ../../shared/testhttpserver.cpp
+HEADERS += ../../shared/testhttpserver.h \
+ ../../shared/util.h
+SOURCES += tst_qquickanimatedimage.cpp \
+ ../../shared/testhttpserver.cpp \
+ ../../shared/util.cpp
+
macx:CONFIG -= app_bundle
testDataFiles.files = data
Q_DECLARE_METATYPE(QQuickImageBase::Status)
-class tst_qquickanimatedimage : public QObject
+class tst_qquickanimatedimage : public QDeclarativeDataTest
{
Q_OBJECT
public:
void tst_qquickanimatedimage::play()
{
QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("stickman.qml")));
+ QDeclarativeComponent component(&engine, testFileUrl("stickman.qml"));
QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create());
QVERIFY(anim);
QVERIFY(anim->isPlaying());
void tst_qquickanimatedimage::pause()
{
QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("stickmanpause.qml")));
+ QDeclarativeComponent component(&engine, testFileUrl("stickmanpause.qml"));
QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create());
QVERIFY(anim);
QVERIFY(anim->isPlaying());
void tst_qquickanimatedimage::stopped()
{
QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("stickmanstopped.qml")));
+ QDeclarativeComponent component(&engine, testFileUrl("stickmanstopped.qml"));
QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create());
QVERIFY(anim);
QVERIFY(!anim->isPlaying());
void tst_qquickanimatedimage::setFrame()
{
QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("stickmanpause.qml")));
+ QDeclarativeComponent component(&engine, testFileUrl("stickmanpause.qml"));
QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create());
QVERIFY(anim);
QVERIFY(anim->isPlaying());
void tst_qquickanimatedimage::frameCount()
{
QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("colors.qml")));
+ QDeclarativeComponent component(&engine, testFileUrl("colors.qml"));
QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create());
QVERIFY(anim);
QVERIFY(anim->isPlaying());
QQuickView *canvas = new QQuickView;
canvas->show();
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("hearts.qml")));
+ canvas->setSource(testFileUrl("hearts.qml"));
QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(canvas->rootObject());
QVERIFY(anim);
{
QTest::addColumn<QUrl>("fileUrl");
- QTest::newRow("paused") << QUrl::fromLocalFile(TESTDATA("stickmanpause.qml"));
- QTest::newRow("stopped") << QUrl::fromLocalFile(TESTDATA("stickmanstopped.qml"));
+ QTest::newRow("paused") << testFileUrl("stickmanpause.qml");
+ QTest::newRow("stopped") << testFileUrl("stickmanstopped.qml");
}
void tst_qquickanimatedimage::remote()
TestHTTPServer server(14449);
QVERIFY(server.isValid());
- server.serveDirectory(TESTDATA(""));
+ server.serveDirectory(dataDirectory());
QDeclarativeEngine engine;
QDeclarativeComponent component(&engine, QUrl("http://127.0.0.1:14449/" + fileName));
void tst_qquickanimatedimage::sourceSize()
{
QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("stickmanscaled.qml")));
+ QDeclarativeComponent component(&engine, testFileUrl("stickmanscaled.qml"));
QQuickAnimatedImage *anim = qobject_cast<QQuickAnimatedImage *>(component.create());
QVERIFY(anim);
QCOMPARE(anim->width(),240.0);
void tst_qquickanimatedimage::sourceSizeReadOnly()
{
QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("stickmanerror1.qml")));
+ QDeclarativeComponent component(&engine, testFileUrl("stickmanerror1.qml"));
QVERIFY(component.isError());
QCOMPARE(component.errors().at(0).description(), QString("Invalid property assignment: \"sourceSize\" is a read-only property"));
}
{
TestHTTPServer server(14449);
QVERIFY(server.isValid());
- server.serveDirectory(TESTDATA(""));
+ server.serveDirectory(dataDirectory());
QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("qtbug-16520.qml")));
+ QDeclarativeComponent component(&engine, testFileUrl("qtbug-16520.qml"));
QTRY_VERIFY(component.isReady());
QQuickRectangle *root = qobject_cast<QQuickRectangle *>(component.create());
{
TestHTTPServer server(14449);
QVERIFY(server.isValid());
- server.serveDirectory(TESTDATA(""));
+ server.serveDirectory(dataDirectory());
QDeclarativeEngine engine;
QString componentStr = "import QtQuick 2.0\nAnimatedImage { source: srcImage }";
QDeclarativeContext *ctxt = engine.rootContext();
- ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(TESTDATA("stickman.gif")));
+ ctxt->setContextProperty("srcImage", testFileUrl("stickman.gif"));
QDeclarativeComponent component(&engine);
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
QSignalSpy statusSpy(obj, SIGNAL(statusChanged(QQuickImageBase::Status)));
// Loading local file
- ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(TESTDATA("colors.gif")));
+ ctxt->setContextProperty("srcImage", testFileUrl("colors.gif"));
QTRY_VERIFY(obj->status() == QQuickImage::Ready);
QTRY_VERIFY(obj->progress() == 1.0);
QTRY_COMPARE(sourceSpy.count(), 1);
TARGET = tst_qquickborderimage
macx:CONFIG -= app_bundle
-HEADERS += ../../shared/testhttpserver.h
-SOURCES += tst_qquickborderimage.cpp ../../shared/testhttpserver.cpp
+HEADERS += ../../shared/testhttpserver.h \
+ ../../shared/util.h
+SOURCES += tst_qquickborderimage.cpp \
+ ../../shared/testhttpserver.cpp \
+ ../../shared/util.cpp
testDataFiles.files = data
testDataFiles.path = .
#define SERVER_PORT 14446
#define SERVER_ADDR "http://127.0.0.1:14446"
-class tst_qquickborderimage : public QObject
+class tst_qquickborderimage : public QDeclarativeDataTest
{
Q_OBJECT
QTest::addColumn<bool>("remote");
QTest::addColumn<QString>("error");
- QTest::newRow("local") << QUrl::fromLocalFile(TESTDATA("colors.png")).toString() << false << "";
- QTest::newRow("local not found") << QUrl::fromLocalFile(TESTDATA("no-such-file.png")).toString() << false
- << "file::2:1: QML BorderImage: Cannot open: " + QUrl::fromLocalFile(TESTDATA("no-such-file.png")).toString();
+ QTest::newRow("local") << testFileUrl("colors.png").toString() << false << "";
+ QTest::newRow("local not found") << testFileUrl("no-such-file.png").toString() << false
+ << "file::2:1: QML BorderImage: Cannot open: " + testFileUrl("no-such-file.png").toString();
QTest::newRow("remote") << SERVER_ADDR "/colors.png" << true << "";
QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << true
<< "file::2:1: QML BorderImage: Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found";
if (remote) {
server = new TestHTTPServer(SERVER_PORT);
QVERIFY(server->isValid());
- server->serveDirectory(TESTDATA(""));
+ server->serveDirectory(dataDirectory());
}
if (!error.isEmpty())
{
QString componentStr = "import QtQuick 2.0\nBorderImage { source: srcImage }";
QDeclarativeContext *ctxt = engine.rootContext();
- ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(TESTDATA("colors.png")));
+ ctxt->setContextProperty("srcImage", testFileUrl("colors.png"));
QDeclarativeComponent component(&engine);
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create());
void tst_qquickborderimage::resized()
{
- QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + QUrl::fromLocalFile(TESTDATA("colors.png")).toString() + "\"; width: 300; height: 300 }";
+ QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + testFileUrl("colors.png").toString() + "\"; width: 300; height: 300 }";
QDeclarativeComponent component(&engine);
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create());
void tst_qquickborderimage::smooth()
{
- QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + TESTDATA("colors.png") + "\"; smooth: true; width: 300; height: 300 }";
+ QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + testFile("colors.png") + "\"; smooth: true; width: 300; height: 300 }";
QDeclarativeComponent component(&engine);
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create());
QQuickView *canvas = new QQuickView;
canvas->show();
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("mirror.qml")));
+ canvas->setSource(testFileUrl("mirror.qml"));
QQuickBorderImage *image = qobject_cast<QQuickBorderImage*>(canvas->rootObject());
QVERIFY(image != 0);
canvas->show();
void tst_qquickborderimage::tileModes()
{
{
- QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + TESTDATA("colors.png") + "\"; width: 100; height: 300; horizontalTileMode: BorderImage.Repeat; verticalTileMode: BorderImage.Repeat }";
+ QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + testFile("colors.png") + "\"; width: 100; height: 300; horizontalTileMode: BorderImage.Repeat; verticalTileMode: BorderImage.Repeat }";
QDeclarativeComponent component(&engine);
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create());
delete obj;
}
{
- QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + TESTDATA("colors.png") + "\"; width: 300; height: 150; horizontalTileMode: BorderImage.Round; verticalTileMode: BorderImage.Round }";
+ QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + testFile("colors.png") + "\"; width: 300; height: 150; horizontalTileMode: BorderImage.Round; verticalTileMode: BorderImage.Round }";
QDeclarativeComponent component(&engine);
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create());
if (remote) {
server = new TestHTTPServer(SERVER_PORT);
QVERIFY(server->isValid());
- server->serveDirectory(TESTDATA(""));
+ server->serveDirectory(dataDirectory());
}
QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + source + "\"; width: 300; height: 300 }";
QTest::addColumn<QString>("source");
QTest::addColumn<bool>("valid");
- QTest::newRow("local") << QUrl::fromLocalFile(TESTDATA("colors-round.sci")).toString() << true;
- QTest::newRow("local quoted filename") << QUrl::fromLocalFile(TESTDATA("colors-round-quotes.sci")).toString() << true;
- QTest::newRow("local not found") << QUrl::fromLocalFile(TESTDATA("no-such-file.sci")).toString() << false;
+ QTest::newRow("local") << testFileUrl("colors-round.sci").toString() << true;
+ QTest::newRow("local quoted filename") << testFileUrl("colors-round-quotes.sci").toString() << true;
+ QTest::newRow("local not found") << testFileUrl("no-such-file.sci").toString() << false;
QTest::newRow("remote") << SERVER_ADDR "/colors-round.sci" << true;
QTest::newRow("remote filename quoted") << SERVER_ADDR "/colors-round-quotes.sci" << true;
QTest::newRow("remote image") << SERVER_ADDR "/colors-round-remote.sci" << true;
QTest::ignoreMessage(QtWarningMsg, "QQuickGridScaledImage: Invalid tile rule specified. Using Stretch."); // for "Roun"
QTest::ignoreMessage(QtWarningMsg, "QQuickGridScaledImage: Invalid tile rule specified. Using Stretch."); // for "Repea"
- QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + QUrl::fromLocalFile(TESTDATA("invalid.sci")).toString() +"\"; width: 300; height: 300 }";
+ QString componentStr = "import QtQuick 2.0\nBorderImage { source: \"" + testFileUrl("invalid.sci").toString() +"\"; width: 300; height: 300 }";
QDeclarativeComponent component(&engine);
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
QQuickBorderImage *obj = qobject_cast<QQuickBorderImage*>(component.create());
CONFIG += testcase
TARGET = tst_qquickcanvas
-SOURCES += tst_qquickcanvas.cpp
+SOURCES += tst_qquickcanvas.cpp \
+ ../../shared/util.cpp
+HEADERS += ../../shared/util.h
macx:CONFIG -= app_bundle
}
};
-class tst_qquickcanvas : public QObject
+class tst_qquickcanvas : public QDeclarativeDataTest
{
Q_OBJECT
public:
- tst_qquickcanvas();
private slots:
- void initTestCase();
- void cleanupTestCase();
-
void constantUpdates();
void touchEvent_basic();
void headless();
};
-tst_qquickcanvas::tst_qquickcanvas()
-{
-}
-
-void tst_qquickcanvas::initTestCase()
-{
-}
-
-void tst_qquickcanvas::cleanupTestCase()
-{
-}
-
//If the item calls update inside updatePaintNode, it should schedule another update
void tst_qquickcanvas::constantUpdates()
{
{
QDeclarativeEngine engine;
QDeclarativeComponent component(&engine);
- component.loadUrl(TESTDATA("window.qml"));
+ component.loadUrl(testFileUrl("window.qml"));
QObject* created = component.create();
QVERIFY(created);
{
QDeclarativeEngine engine;
QDeclarativeComponent component(&engine);
- component.loadUrl(TESTDATA("AnimationsWhileHidden.qml"));
+ component.loadUrl(testFileUrl("AnimationsWhileHidden.qml"));
QObject* created = component.create();
QQuickCanvas* canvas = qobject_cast<QQuickCanvas*>(created);
{
QDeclarativeEngine engine;
QDeclarativeComponent component(&engine);
- component.loadUrl(TESTDATA("Headless.qml"));
+ component.loadUrl(testFileUrl("Headless.qml"));
QObject* created = component.create();
QQuickCanvas* canvas = qobject_cast<QQuickCanvas*>(created);
TARGET = tst_qquickflickable
macx:CONFIG -= app_bundle
-SOURCES += tst_qquickflickable.cpp
+SOURCES += tst_qquickflickable.cpp \
+ ../../shared/util.cpp
+HEADERS += ../../shared/util.h
testDataFiles.files = data
testDataFiles.path = .
#include "../../shared/util.h"
#include <QtOpenGL/QGLShaderProgram>
-class tst_qquickflickable : public QObject
+class tst_qquickflickable : public QDeclarativeDataTest
{
Q_OBJECT
public:
- tst_qquickflickable();
private slots:
- void initTestCase();
- void cleanupTestCase();
-
void create();
void horizontalViewportSize();
void verticalViewportSize();
T *findItem(QQuickItem *parent, const QString &objectName);
};
-tst_qquickflickable::tst_qquickflickable()
-{
-}
-
-void tst_qquickflickable::initTestCase()
-{
-
-}
-
-void tst_qquickflickable::cleanupTestCase()
-{
-
-}
-
void tst_qquickflickable::create()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("flickable01.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("flickable01.qml"));
QQuickFlickable *obj = qobject_cast<QQuickFlickable*>(c.create());
QVERIFY(obj != 0);
void tst_qquickflickable::horizontalViewportSize()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("flickable02.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("flickable02.qml"));
QQuickFlickable *obj = qobject_cast<QQuickFlickable*>(c.create());
QVERIFY(obj != 0);
void tst_qquickflickable::verticalViewportSize()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("flickable03.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("flickable03.qml"));
QQuickFlickable *obj = qobject_cast<QQuickFlickable*>(c.create());
QVERIFY(obj != 0);
void tst_qquickflickable::properties()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("flickable04.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("flickable04.qml"));
QQuickFlickable *obj = qobject_cast<QQuickFlickable*>(c.create());
QVERIFY(obj != 0);
void tst_qquickflickable::nestedPressDelay()
{
QQuickView *canvas = new QQuickView;
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("nestedPressDelay.qml")));
+ canvas->setSource(testFileUrl("nestedPressDelay.qml"));
canvas->show();
canvas->requestActivateWindow();
QVERIFY(canvas->rootObject() != 0);
void tst_qquickflickable::resizeContent()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("resize.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("resize.qml"));
QQuickItem *root = qobject_cast<QQuickItem*>(c.create());
QQuickFlickable *obj = findItem<QQuickFlickable>(root, "flick");
void tst_qquickflickable::returnToBounds()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("resize.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("resize.qml"));
QQuickItem *root = qobject_cast<QQuickItem*>(c.create());
QQuickFlickable *obj = findItem<QQuickFlickable>(root, "flick");
void tst_qquickflickable::wheel()
{
QQuickView *canvas = new QQuickView;
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("wheel.qml")));
+ canvas->setSource(testFileUrl("wheel.qml"));
canvas->show();
canvas->requestActivateWindow();
QVERIFY(canvas->rootObject() != 0);
void tst_qquickflickable::movingAndDragging()
{
QQuickView *canvas = new QQuickView;
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("flickable03.qml")));
+ canvas->setSource(testFileUrl("flickable03.qml"));
canvas->show();
canvas->requestActivateWindow();
QTest::qWaitForWindowShown(canvas);
void tst_qquickflickable::disabled()
{
QQuickView *canvas = new QQuickView;
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("disabled.qml")));
+ canvas->setSource(testFileUrl("disabled.qml"));
canvas->show();
canvas->requestActivateWindow();
QVERIFY(canvas->rootObject() != 0);
#endif
QQuickView *canvas = new QQuickView;
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("flickable03.qml")));
+ canvas->setSource(testFileUrl("flickable03.qml"));
canvas->show();
canvas->requestActivateWindow();
QVERIFY(canvas->rootObject() != 0);
void tst_qquickflickable::margins()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("margins.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("margins.qml"));
QQuickItem *root = qobject_cast<QQuickItem*>(c.create());
QQuickFlickable *obj = qobject_cast<QQuickFlickable*>(root);
QVERIFY(obj != 0);
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 = .
#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();
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);
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);
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);
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();
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();
CONFIG += testcase
TARGET = tst_qquickfocusscope
-SOURCES += tst_qquickfocusscope.cpp
+SOURCES += tst_qquickfocusscope.cpp \
+ ../../shared/util.cpp
+HEADERS += ../../shared/util.h
+
macx:CONFIG -= app_bundle
testDataFiles.files = data
#include <QtQuick/private/qquickfocusscope_p.h>
#include "../../shared/util.h"
-class tst_qquickfocusscope : public QObject
+class tst_qquickfocusscope : public QDeclarativeDataTest
{
Q_OBJECT
public:
T *findItem(QQuickItem *parent, const QString &id);
private slots:
- void initTestCase();
- void cleanupTestCase();
void basic();
void nested();
void noFocus();
void forceActiveFocus();
void canvasFocus();
};
-void tst_qquickfocusscope::initTestCase()
-{
-}
-
-void tst_qquickfocusscope::cleanupTestCase()
-{
-
-}
/*
Find an item with the specified id.
void tst_qquickfocusscope::basic()
{
QQuickView *view = new QQuickView;
- view->setSource(QUrl::fromLocalFile(TESTDATA("test.qml")));
+ view->setSource(testFileUrl("test.qml"));
QQuickFocusScope *item0 = findItem<QQuickFocusScope>(view->rootObject(), QLatin1String("item0"));
QQuickRectangle *item1 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item1"));
void tst_qquickfocusscope::nested()
{
QQuickView *view = new QQuickView;
- view->setSource(QUrl::fromLocalFile(TESTDATA("test2.qml")));
+ view->setSource(testFileUrl("test2.qml"));
QQuickFocusScope *item1 = findItem<QQuickFocusScope>(view->rootObject(), QLatin1String("item1"));
QQuickFocusScope *item2 = findItem<QQuickFocusScope>(view->rootObject(), QLatin1String("item2"));
void tst_qquickfocusscope::noFocus()
{
QQuickView *view = new QQuickView;
- view->setSource(QUrl::fromLocalFile(TESTDATA("test4.qml")));
+ view->setSource(testFileUrl("test4.qml"));
QQuickRectangle *item0 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item0"));
QQuickRectangle *item1 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item1"));
void tst_qquickfocusscope::textEdit()
{
QQuickView *view = new QQuickView;
- view->setSource(QUrl::fromLocalFile(TESTDATA("test5.qml")));
+ view->setSource(testFileUrl("test5.qml"));
QQuickFocusScope *item0 = findItem<QQuickFocusScope>(view->rootObject(), QLatin1String("item0"));
QQuickTextEdit *item1 = findItem<QQuickTextEdit>(view->rootObject(), QLatin1String("item1"));
void tst_qquickfocusscope::forceFocus()
{
QQuickView *view = new QQuickView;
- view->setSource(QUrl::fromLocalFile(TESTDATA("forcefocus.qml")));
+ view->setSource(testFileUrl("forcefocus.qml"));
QQuickFocusScope *item0 = findItem<QQuickFocusScope>(view->rootObject(), QLatin1String("item0"));
QQuickRectangle *item1 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item1"));
void tst_qquickfocusscope::noParentFocus()
{
QQuickView *view = new QQuickView;
- view->setSource(QUrl::fromLocalFile(TESTDATA("chain.qml")));
+ view->setSource(testFileUrl("chain.qml"));
QVERIFY(view->rootObject());
view->show();
void tst_qquickfocusscope::signalEmission()
{
QQuickView *view = new QQuickView;
- view->setSource(QUrl::fromLocalFile(TESTDATA("signalEmission.qml")));
+ view->setSource(testFileUrl("signalEmission.qml"));
QQuickRectangle *item1 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item1"));
QQuickRectangle *item2 = findItem<QQuickRectangle>(view->rootObject(), QLatin1String("item2"));
void tst_qquickfocusscope::qtBug13380()
{
QQuickView *view = new QQuickView;
- view->setSource(QUrl::fromLocalFile(TESTDATA("qtBug13380.qml")));
+ view->setSource(testFileUrl("qtBug13380.qml"));
view->show();
QVERIFY(view->rootObject());
void tst_qquickfocusscope::forceActiveFocus()
{
QQuickView *view = new QQuickView;
- view->setSource(QUrl::fromLocalFile(TESTDATA("forceActiveFocus.qml")));
+ view->setSource(testFileUrl("forceActiveFocus.qml"));
view->show();
view->requestActivateWindow();
void tst_qquickfocusscope::canvasFocus()
{
QQuickView *view = new QQuickView;
- view->setSource(QUrl::fromLocalFile(TESTDATA("canvasFocus.qml")));
+ view->setSource(testFileUrl("canvasFocus.qml"));
QQuickView alternateView;
TARGET = tst_qquickgridview
macx:CONFIG -= app_bundle
-SOURCES += tst_qquickgridview.cpp
+SOURCES += tst_qquickgridview.cpp \
+ ../../shared/util.cpp
+HEADERS += ../../shared/util.h
testDataFiles.files = data
testDataFiles.path = .
Q_DECLARE_METATYPE(Qt::LayoutDirection)
Q_DECLARE_METATYPE(QQuickGridView::Flow)
-class tst_QQuickGridView : public QObject
+class tst_QQuickGridView : public QDeclarativeDataTest
{
Q_OBJECT
public:
tst_QQuickGridView();
private slots:
- void initTestCase();
- void cleanupTestCase();
void items();
void changed();
void inserted();
*t = *f;
}
-void tst_QQuickGridView::initTestCase()
-{
-}
-
-void tst_QQuickGridView::cleanupTestCase()
-{
-
-}
-
-
class TestModel : public QAbstractListModel
{
public:
ctxt->setContextProperty("testRightToLeft", QVariant(false));
ctxt->setContextProperty("testTopToBottom", QVariant(false));
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("gridview1.qml")));
+ canvas->setSource(testFileUrl("gridview1.qml"));
qApp->processEvents();
QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
ctxt->setContextProperty("testRightToLeft", QVariant(false));
ctxt->setContextProperty("testTopToBottom", QVariant(false));
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("gridview1.qml")));
+ canvas->setSource(testFileUrl("gridview1.qml"));
qApp->processEvents();
QQuickFlickable *gridview = findItem<QQuickFlickable>(canvas->rootObject(), "grid");
ctxt->setContextProperty("testRightToLeft", QVariant(false));
ctxt->setContextProperty("testTopToBottom", QVariant(false));
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("gridview1.qml")));
+ canvas->setSource(testFileUrl("gridview1.qml"));
qApp->processEvents();
QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
ctxt->setContextProperty("testRightToLeft", QVariant(false));
ctxt->setContextProperty("testTopToBottom", QVariant(false));
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("gridview1.qml")));
+ canvas->setSource(testFileUrl("gridview1.qml"));
qApp->processEvents();
QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
ctxt->setContextProperty("testModel", &model);
ctxt->setContextProperty("testRightToLeft", QVariant(false));
ctxt->setContextProperty("testTopToBottom", QVariant(false));
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("gridview1.qml")));
+ canvas->setSource(testFileUrl("gridview1.qml"));
qApp->processEvents();
QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
ctxt->setContextProperty("testRightToLeft", QVariant(false));
ctxt->setContextProperty("testTopToBottom", QVariant(false));
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("gridview1.qml")));
+ canvas->setSource(testFileUrl("gridview1.qml"));
qApp->processEvents();
QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
ctxt->setContextProperty("testModel", &model);
ctxt->setContextProperty("testRightToLeft", QVariant(false));
ctxt->setContextProperty("testTopToBottom", QVariant(false));
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("gridview1.qml")));
+ canvas->setSource(testFileUrl("gridview1.qml"));
QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
QTRY_VERIFY(gridview != 0);
ctxt->setContextProperty("testRightToLeft", QVariant(false));
ctxt->setContextProperty("testTopToBottom", QVariant(false));
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("gridview1.qml")));
+ canvas->setSource(testFileUrl("gridview1.qml"));
qApp->processEvents();
QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
ctxt->setContextProperty("testRightToLeft", QVariant(false));
ctxt->setContextProperty("testTopToBottom", QVariant(false));
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("gridview1.qml")));
+ canvas->setSource(testFileUrl("gridview1.qml"));
qApp->processEvents();
QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
ctxt->setContextProperty("testRightToLeft", QVariant(false));
ctxt->setContextProperty("testTopToBottom", QVariant(false));
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("gridview1.qml")));
+ canvas->setSource(testFileUrl("gridview1.qml"));
qApp->processEvents();
QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
ctxt->setContextProperty("testRightToLeft", QVariant(false));
ctxt->setContextProperty("testTopToBottom", QVariant(false));
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("gridview1.qml")));
+ canvas->setSource(testFileUrl("gridview1.qml"));
qApp->processEvents();
QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
QDeclarativeContext *ctxt = canvas->rootContext();
ctxt->setContextProperty("testModel", &model);
- QString filename(TESTDATA("gridview-initCurrent.qml"));
+ QString filename(testFile("gridview-initCurrent.qml"));
canvas->setSource(QUrl::fromLocalFile(filename));
qApp->processEvents();
QDeclarativeContext *ctxt = canvas->rootContext();
ctxt->setContextProperty("testModel", &model);
- QString filename(TESTDATA("gridview-noCurrent.qml"));
+ QString filename(testFile("gridview-noCurrent.qml"));
canvas->setSource(QUrl::fromLocalFile(filename));
qApp->processEvents();
ctxt->setContextProperty("testRightToLeft", QVariant(false));
ctxt->setContextProperty("testTopToBottom", QVariant(false));
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("gridview1.qml")));
+ canvas->setSource(testFileUrl("gridview1.qml"));
qApp->processEvents();
QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
void tst_QQuickGridView::defaultValues()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("gridview3.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("gridview3.qml"));
QQuickGridView *obj = qobject_cast<QQuickGridView*>(c.create());
QTRY_VERIFY(obj != 0);
void tst_QQuickGridView::properties()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("gridview2.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("gridview2.qml"));
QQuickGridView *obj = qobject_cast<QQuickGridView*>(c.create());
QTRY_VERIFY(obj != 0);
{
QQuickView *canvas = createView();
QTRY_VERIFY(canvas);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("propertychangestest.qml")));
+ canvas->setSource(testFileUrl("propertychangestest.qml"));
QQuickGridView *gridView = canvas->rootObject()->findChild<QQuickGridView*>("gridView");
QTRY_VERIFY(gridView);
{
QQuickView *canvas = createView();
QTRY_VERIFY(canvas);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("propertychangestest.qml")));
+ canvas->setSource(testFileUrl("propertychangestest.qml"));
QQuickGridView *gridView = canvas->rootObject()->findChild<QQuickGridView*>("gridView");
QTRY_VERIFY(gridView);
{
QQuickView *canvas = createView();
QTRY_VERIFY(canvas);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("propertychangestest.qml")));
+ canvas->setSource(testFileUrl("propertychangestest.qml"));
QQuickGridView *gridView = canvas->rootObject()->findChild<QQuickGridView*>("gridView");
QTRY_VERIFY(gridView);
ctxt->setContextProperty("testRightToLeft", QVariant(false));
ctxt->setContextProperty("testTopToBottom", QVariant(false));
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("gridview1.qml")));
+ canvas->setSource(testFileUrl("gridview1.qml"));
qApp->processEvents();
QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
ctxt->setContextProperty("testTopToBottom", QVariant(false));
ctxt->setContextProperty("testRightToLeft", QVariant(false));
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("gridview1.qml")));
+ canvas->setSource(testFileUrl("gridview1.qml"));
qApp->processEvents();
QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
void tst_QQuickGridView::mirroring()
{
QQuickView *canvasA = createView();
- canvasA->setSource(QUrl::fromLocalFile(TESTDATA("mirroring.qml")));
+ canvasA->setSource(testFileUrl("mirroring.qml"));
QQuickGridView *gridviewA = findItem<QQuickGridView>(canvasA->rootObject(), "view");
QTRY_VERIFY(gridviewA != 0);
QQuickView *canvasB = createView();
- canvasB->setSource(QUrl::fromLocalFile(TESTDATA("mirroring.qml")));
+ canvasB->setSource(testFileUrl("mirroring.qml"));
QQuickGridView *gridviewB = findItem<QQuickGridView>(canvasB->rootObject(), "view");
QTRY_VERIFY(gridviewA != 0);
qApp->processEvents();
ctxt->setContextProperty("testTopToBottom", QVariant(true));
ctxt->setContextProperty("testRightToLeft", QVariant(true));
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("gridview1.qml")));
+ canvas->setSource(testFileUrl("gridview1.qml"));
qApp->processEvents();
QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
QDeclarativeContext *ctxt = canvas->rootContext();
ctxt->setContextProperty("testModel", &model);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("displaygrid.qml")));
+ canvas->setSource(testFileUrl("displaygrid.qml"));
qApp->processEvents();
QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
ctxt->setContextProperty("testRightToLeft", QVariant(false));
ctxt->setContextProperty("testTopToBottom", QVariant(false));
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("gridview-enforcerange.qml")));
+ canvas->setSource(testFileUrl("gridview-enforcerange.qml"));
qApp->processEvents();
QVERIFY(canvas->rootObject() != 0);
ctxt->setContextProperty("testRightToLeft", QVariant(true));
ctxt->setContextProperty("testTopToBottom", QVariant(true));
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("gridview-enforcerange.qml")));
+ canvas->setSource(testFileUrl("gridview-enforcerange.qml"));
qApp->processEvents();
QVERIFY(canvas->rootObject() != 0);
{
QQuickView *canvas = createView();
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("setindex.qml")));
+ canvas->setSource(testFileUrl("setindex.qml"));
qApp->processEvents();
QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
{
QQuickView *canvas = createView();
- QString filename(TESTDATA("manual-highlight.qml"));
+ QString filename(testFile("manual-highlight.qml"));
canvas->setSource(QUrl::fromLocalFile(filename));
qApp->processEvents();
QDeclarativeContext *ctxt = canvas->rootContext();
ctxt->setContextProperty("testModel", &model);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("footer.qml")));
+ canvas->setSource(testFileUrl("footer.qml"));
qApp->processEvents();
QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
canvas->rootContext()->setContextProperty("testModel", &model);
canvas->rootContext()->setContextProperty("initialViewWidth", 240);
canvas->rootContext()->setContextProperty("initialViewHeight", 320);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("header.qml")));
+ canvas->setSource(testFileUrl("header.qml"));
QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
QTRY_VERIFY(gridview != 0);
canvas->rootContext()->setContextProperty("testModel", &model);
canvas->rootContext()->setContextProperty("initialViewWidth", 240);
canvas->rootContext()->setContextProperty("initialViewHeight", 320);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("header.qml")));
+ canvas->setSource(testFileUrl("header.qml"));
gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
QTRY_VERIFY(gridview != 0);
ctxt->setContextProperty("testModel", &model);
ctxt->setContextProperty("initialHeight", 100);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("resizeview.qml")));
+ canvas->setSource(testFileUrl("resizeview.qml"));
qApp->processEvents();
QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
ctxt->setContextProperty("testRightToLeft", QVariant(false));
ctxt->setContextProperty("testTopToBottom", QVariant(false));
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("gridview1.qml")));
+ canvas->setSource(testFileUrl("gridview1.qml"));
qApp->processEvents();
QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
ctxt->setContextProperty("testModel", &model);
ctxt->setContextProperty("delegateWidth", delegateWidth);
ctxt->setContextProperty("delegateHeight", delegateHeight);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("attachedSignals.qml")));
+ canvas->setSource(testFileUrl("attachedSignals.qml"));
QObject *object = canvas->rootObject();
object->setProperty("width", canvas->width());
ctxt->setContextProperty("testModel", &model);
ctxt->setContextProperty("delegateWidth", delegateWidth);
ctxt->setContextProperty("delegateHeight", delegateHeight);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("attachedSignals.qml")));
+ canvas->setSource(testFileUrl("attachedSignals.qml"));
QObject *object = canvas->rootObject();
model.removeItems(indexToRemove, removeCount);
void tst_QQuickGridView::columnCount()
{
QQuickView canvas;
- canvas.setSource(QUrl::fromLocalFile(TESTDATA("gridview4.qml")));
+ canvas.setSource(testFileUrl("gridview4.qml"));
canvas.show();
canvas.requestActivateWindow();
QTest::qWaitForWindowShown(&canvas);
ctxt->setContextProperty("testModel", &model);
ctxt->setContextProperty("testRightToLeft", QVariant(false));
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("margins.qml")));
+ canvas->setSource(testFileUrl("margins.qml"));
qApp->processEvents();
QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
ctxt->setContextProperty("testModel", &model);
ctxt->setContextProperty("testRightToLeft", QVariant(true));
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("margins.qml")));
+ canvas->setSource(testFileUrl("margins.qml"));
qApp->processEvents();
QQuickGridView *gridview = findItem<QQuickGridView>(canvas->rootObject(), "grid");
{
QQuickView canvas;
canvas.setGeometry(0,0,240,320);
- canvas.setSource(QUrl::fromLocalFile(TESTDATA("creationContext.qml")));
+ canvas.setSource(testFileUrl("creationContext.qml"));
qApp->processEvents();
QQuickItem *rootItem = qobject_cast<QQuickItem *>(canvas.rootObject());
QQuickView *canvas = createView();
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("snapToRow.qml")));
+ canvas->setSource(testFileUrl("snapToRow.qml"));
canvas->show();
qApp->processEvents();
QQuickView *canvas = createView();
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("snapOneRow.qml")));
+ canvas->setSource(testFileUrl("snapOneRow.qml"));
canvas->show();
qApp->processEvents();
QDeclarativeContext *ctxt = canvas->rootContext();
ctxt->setContextProperty("testModel", &model);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("unaligned.qml")));
+ canvas->setSource(testFileUrl("unaligned.qml"));
qApp->processEvents();
QQuickGridView *gridview = qobject_cast<QQuickGridView*>(canvas->rootObject());
ctxt->setContextProperty("testRightToLeft", QVariant(false));
ctxt->setContextProperty("testTopToBottom", QVariant(false));
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("gridview1.qml")));
+ canvas->setSource(testFileUrl("gridview1.qml"));
canvas->show();
qApp->processEvents();
QDeclarativeIncubationController controller;
canvas->engine()->setIncubationController(&controller);
- canvas->setSource(TESTDATA("asyncloader.qml"));
+ canvas->setSource(testFile("asyncloader.qml"));
QQuickItem *rootObject = qobject_cast<QQuickItem*>(canvas->rootObject());
QVERIFY(rootObject);
ctxt->setContextProperty("testModel", &model);
ctxt->setContextProperty("testWrap", QVariant(false));
- QString filename(TESTDATA("unrequestedItems.qml"));
- canvas->setSource(QUrl::fromLocalFile(filename));
+ canvas->setSource(testFileUrl("unrequestedItems.qml"));
canvas->show();
TARGET = tst_qquickimage
macx:CONFIG -= app_bundle
-HEADERS += ../../shared/testhttpserver.h
-SOURCES += tst_qquickimage.cpp ../../shared/testhttpserver.cpp
+HEADERS += ../../shared/testhttpserver.h \
+ ../../shared/util.h
+SOURCES += tst_qquickimage.cpp \
+ ../../shared/testhttpserver.cpp \
+ ../../shared/util.cpp
testDataFiles.files = data
testDataFiles.path = .
Q_DECLARE_METATYPE(QQuickImageBase::Status)
-class tst_qquickimage : public QObject
+class tst_qquickimage : public QDeclarativeDataTest
{
Q_OBJECT
public:
QTest::addColumn<bool>("cache");
QTest::addColumn<QString>("error");
- QTest::newRow("local") << QUrl::fromLocalFile(TESTDATA("colors.png")).toString() << 120.0 << 120.0 << false << false << true << "";
- QTest::newRow("local no cache") << QUrl::fromLocalFile(TESTDATA("colors.png")).toString() << 120.0 << 120.0 << false << false << false << "";
- QTest::newRow("local async") << QUrl::fromLocalFile(TESTDATA("colors1.png")).toString() << 120.0 << 120.0 << false << true << true << "";
- QTest::newRow("local not found") << QUrl::fromLocalFile(TESTDATA("no-such-file.png")).toString() << 0.0 << 0.0 << false
- << false << true << "file::2:1: QML Image: Cannot open: " + QUrl::fromLocalFile(TESTDATA("no-such-file.png")).toString();
- QTest::newRow("local async not found") << QUrl::fromLocalFile(TESTDATA("no-such-file-1.png")).toString() << 0.0 << 0.0 << false
- << true << true << "file::2:1: QML Image: Cannot open: " + QUrl::fromLocalFile(TESTDATA("no-such-file-1.png")).toString();
+ QTest::newRow("local") << testFileUrl("colors.png").toString() << 120.0 << 120.0 << false << false << true << "";
+ QTest::newRow("local no cache") << testFileUrl("colors.png").toString() << 120.0 << 120.0 << false << false << false << "";
+ QTest::newRow("local async") << testFileUrl("colors1.png").toString() << 120.0 << 120.0 << false << true << true << "";
+ QTest::newRow("local not found") << testFileUrl("no-such-file.png").toString() << 0.0 << 0.0 << false
+ << false << true << "file::2:1: QML Image: Cannot open: " + testFileUrl("no-such-file.png").toString();
+ QTest::newRow("local async not found") << testFileUrl("no-such-file-1.png").toString() << 0.0 << 0.0 << false
+ << true << true << "file::2:1: QML Image: Cannot open: " + testFileUrl("no-such-file-1.png").toString();
QTest::newRow("remote") << SERVER_ADDR "/colors.png" << 120.0 << 120.0 << true << false << true << "";
QTest::newRow("remote redirected") << SERVER_ADDR "/oldcolors.png" << 120.0 << 120.0 << true << false << false << "";
if (QImageReader::supportedImageFormats().contains("svg"))
TestHTTPServer server(SERVER_PORT);
if (remote) {
QVERIFY(server.isValid());
- server.serveDirectory(TESTDATA(""));
+ server.serveDirectory(dataDirectory());
server.addRedirect("oldcolors.png", SERVER_ADDR "/colors.png");
}
{
QString componentStr = "import QtQuick 2.0\nImage { source: srcImage }";
QDeclarativeContext *ctxt = engine.rootContext();
- ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(TESTDATA("colors.png")));
+ ctxt->setContextProperty("srcImage", testFileUrl("colors.png"));
QDeclarativeComponent component(&engine);
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
void tst_qquickimage::resized()
{
- QString componentStr = "import QtQuick 2.0\nImage { source: \"" + TESTDATA("colors.png") + "\"; width: 300; height: 300 }";
+ QString componentStr = "import QtQuick 2.0\nImage { source: \"" + testFile("colors.png") + "\"; width: 300; height: 300 }";
QDeclarativeComponent component(&engine);
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
QQuickView *canvas = new QQuickView(0);
canvas->show();
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("aspectratio.qml")));
+ canvas->setSource(testFileUrl("aspectratio.qml"));
QQuickImage *image = qobject_cast<QQuickImage*>(canvas->rootObject());
QVERIFY(image != 0);
image->setWidth(80.0);
QCOMPARE(image->width(), 80.);
QCOMPARE(image->height(), 80.);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("aspectratio.qml")));
+ canvas->setSource(testFileUrl("aspectratio.qml"));
image = qobject_cast<QQuickImage*>(canvas->rootObject());
image->setHeight(60.0);
QVERIFY(image != 0);
void tst_qquickimage::smooth()
{
- QString componentStr = "import QtQuick 2.0\nImage { source: \"" + TESTDATA("colors.png") + "\"; smooth: true; width: 300; height: 300 }";
+ QString componentStr = "import QtQuick 2.0\nImage { source: \"" + testFile("colors.png") + "\"; smooth: true; width: 300; height: 300 }";
QDeclarativeComponent component(&engine);
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
foreach (QQuickImage::FillMode fillMode, fillModes) {
QQuickView *canvas = new QQuickView;
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("mirror.qml")));
+ canvas->setSource(testFileUrl("mirror.qml"));
QQuickImage *obj = canvas->rootObject()->findChild<QQuickImage*>("image");
QVERIFY(obj != 0);
foreach (QQuickImage::FillMode fillMode, fillModes) {
QPixmap srcPixmap;
- QVERIFY(srcPixmap.load(TESTDATA("pattern.png")));
+ QVERIFY(srcPixmap.load(testFile("pattern.png")));
QPixmap expected(width, height);
expected.fill();
if (!QImageReader::supportedImageFormats().contains("svg"))
QSKIP("svg support not available");
- QString src = QUrl::fromLocalFile(TESTDATA("heart.svg")).toString();
+ QString src = testFileUrl("heart.svg").toString();
QString componentStr = "import QtQuick 2.0\nImage { source: \"" + src + "\"; sourceSize.width: 300; sourceSize.height: 300 }";
QDeclarativeComponent component(&engine);
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
QFETCH(double, boundingWidth);
QFETCH(double, boundingHeight);
- QString src = QUrl::fromLocalFile(TESTDATA("rect.png")).toString();
+ QString src = testFileUrl("rect.png").toString();
QString componentStr = "import QtQuick 2.0\nImage { source: \"" + src + "\"; fillMode: Image." + fillMode + "; ";
if (explicitWidth)
// If the JPEG loader does not implement scaling efficiently, it would
// have to build a 400 MB image. That would be a bug in the JPEG loader.
- QString src = QUrl::fromLocalFile(TESTDATA("big.jpeg")).toString();
+ QString src = testFileUrl("big.jpeg").toString();
QString componentStr = "import QtQuick 2.0\nImage { source: \"" + src + "\"; width: 100; sourceSize.height: 256 }";
QDeclarativeComponent component(&engine);
QQuickView *canvas = new QQuickView(0);
AutoDelete<QQuickView> del(canvas);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA(source)));
+ canvas->setSource(testFileUrl(source));
canvas->show();
qApp->processEvents();
TestHTTPServer server(SERVER_PORT);
QVERIFY(server.isValid());
- server.serveDirectory(TESTDATA(""));
+ server.serveDirectory(dataDirectory());
server.addRedirect("oldcolors.png", SERVER_ADDR "/colors.png");
QString componentStr = "import QtQuick 2.0\nImage { source: srcImage; cache: true }";
QDeclarativeContext *ctxt = engine.rootContext();
- ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(TESTDATA("heart.png")));
+ ctxt->setContextProperty("srcImage", testFileUrl("heart.png"));
QDeclarativeComponent component(&engine);
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
QSignalSpy statusSpy(obj, SIGNAL(statusChanged(QQuickImageBase::Status)));
// Loading local file
- ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(TESTDATA("green.png")));
+ ctxt->setContextProperty("srcImage", testFileUrl("green.png"));
QTRY_VERIFY(obj->status() == QQuickImage::Ready);
QTRY_VERIFY(obj->progress() == 1.0);
QTRY_COMPARE(sourceSpy.count(), 1);
QTRY_COMPARE(statusSpy.count(), 2);
// Loading remote file again - should not go through 'Loading' state.
- ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(TESTDATA("green.png")));
+ ctxt->setContextProperty("srcImage", testFileUrl("green.png"));
ctxt->setContextProperty("srcImage", QString(SERVER_ADDR) + "/rect.png");
QTRY_VERIFY(obj->status() == QQuickImage::Ready);
QTRY_VERIFY(obj->progress() == 1.0);
void tst_qquickimage::paintedWidthHeight()
{
{
- QString src = QUrl::fromLocalFile(TESTDATA("heart.png")).toString();
+ QString src = testFileUrl("heart.png").toString();
QString componentStr = "import QtQuick 2.0\nImage { source: \"" + src + "\"; width: 200; height: 25; fillMode: Image.PreserveAspectFit }";
QDeclarativeComponent component(&engine);
}
{
- QString src = QUrl::fromLocalFile(TESTDATA("heart.png")).toString();
+ QString src = testFileUrl("heart.png").toString();
QString componentStr = "import QtQuick 2.0\nImage { source: \"" + src + "\"; width: 26; height: 175; fillMode: Image.PreserveAspectFit }";
QDeclarativeComponent component(&engine);
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
{
QString componentStr = "import QtQuick 2.0\nImage { source: srcImage }";
QDeclarativeContext *ctxt = engine.rootContext();
- ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(TESTDATA("heart200.png")));
+ ctxt->setContextProperty("srcImage", testFileUrl("heart200.png"));
QDeclarativeComponent component(&engine);
component.setData(componentStr.toLatin1(), QUrl::fromLocalFile(""));
QQuickImage *obj = qobject_cast<QQuickImage*>(component.create());
QTRY_COMPARE(obj->sourceSize().height(), 200);
QTRY_COMPARE(sourceSizeSpy.count(), 0);
- ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(TESTDATA("colors.png")));
+ ctxt->setContextProperty("srcImage", testFileUrl("colors.png"));
QTRY_COMPARE(obj->sourceSize().width(), 120);
QTRY_COMPARE(obj->sourceSize().height(), 120);
QTRY_COMPARE(sourceSizeSpy.count(), 1);
- ctxt->setContextProperty("srcImage", QUrl::fromLocalFile(TESTDATA("heart200.png")));
+ ctxt->setContextProperty("srcImage", testFileUrl("heart200.png"));
QTRY_COMPARE(obj->sourceSize().width(), 200);
QTRY_COMPARE(obj->sourceSize().height(), 200);
QTRY_COMPARE(sourceSizeSpy.count(), 2);
void tst_qquickimage::sourceSize_QTBUG_16389()
{
QQuickView *canvas = new QQuickView(0);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("qtbug_16389.qml")));
+ canvas->setSource(testFileUrl("qtbug_16389.qml"));
canvas->show();
qApp->processEvents();
void tst_qquickimage::nullPixmapPaint()
{
QQuickView *canvas = new QQuickView(0);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("nullpixmap.qml")));
+ canvas->setSource(testFileUrl("nullpixmap.qml"));
canvas->show();
QQuickImage *image = qobject_cast<QQuickImage*>(canvas->rootObject());
{
TestHTTPServer server(SERVER_PORT);
QVERIFY(server.isValid());
- server.serveDirectory(TESTDATA(""), TestHTTPServer::Delay);
+ server.serveDirectory(dataDirectory(), TestHTTPServer::Delay);
{
- QQuickView view(QUrl::fromLocalFile(TESTDATA("qtbug_22125.qml")));
+ QQuickView view(testFileUrl("qtbug_22125.qml"));
view.show();
qApp->processEvents();
qApp->processEvents();
CONFIG += testcase
TARGET = tst_qquickitem
-SOURCES += tst_qquickitem.cpp
+SOURCES += tst_qquickitem.cpp \
+ ../../shared/util.cpp
+HEADERS += ../../shared/util.h
macx:CONFIG -= app_bundle
virtual void focusOutEvent(QFocusEvent *) { Q_ASSERT(focused); focused = false; }
};
-class tst_qquickitem : public QObject
+class tst_qquickitem : public QDeclarativeDataTest
{
Q_OBJECT
public:
- tst_qquickitem();
private slots:
- void initTestCase();
- void cleanupTestCase();
-
void noCanvas();
void simpleFocus();
void scopedFocus();
}
};
-tst_qquickitem::tst_qquickitem()
-{
-}
-
-void tst_qquickitem::initTestCase()
-{
-}
-
-void tst_qquickitem::cleanupTestCase()
-{
-}
-
// Focus has no effect when outside a canvas
void tst_qquickitem::noCanvas()
{
void tst_qquickitem::paintOrder_data()
{
+ const QUrl order1Url = testFileUrl("order.1.qml");
+ const QUrl order2Url = testFileUrl("order.2.qml");
+
QTest::addColumn<QUrl>("source");
QTest::addColumn<int>("op");
QTest::addColumn<QVariant>("param1");
QTest::addColumn<QVariant>("param2");
QTest::addColumn<QStringList>("expected");
- QTest::newRow("test 1 noop") << QUrl::fromLocalFile(TESTDATA("order.1.qml"))
+ QTest::newRow("test 1 noop") << order1Url
<< int(NoOp) << QVariant() << QVariant()
<< (QStringList() << "1" << "2" << "3");
- QTest::newRow("test 1 add") << QUrl::fromLocalFile(TESTDATA("order.1.qml"))
+ QTest::newRow("test 1 add") << order1Url
<< int(Append) << QVariant("new") << QVariant()
<< (QStringList() << "1" << "2" << "3" << "new");
- QTest::newRow("test 1 remove") << QUrl::fromLocalFile(TESTDATA("order.1.qml"))
+ QTest::newRow("test 1 remove") << order1Url
<< int(Remove) << QVariant(1) << QVariant()
<< (QStringList() << "1" << "3");
- QTest::newRow("test 1 stack before") << QUrl::fromLocalFile(TESTDATA("order.1.qml"))
+ QTest::newRow("test 1 stack before") << order1Url
<< int(StackBefore) << QVariant(2) << QVariant(1)
<< (QStringList() << "1" << "3" << "2");
- QTest::newRow("test 1 stack after") << QUrl::fromLocalFile(TESTDATA("order.1.qml"))
+ QTest::newRow("test 1 stack after") << order1Url
<< int(StackAfter) << QVariant(0) << QVariant(1)
<< (QStringList() << "2" << "1" << "3");
- QTest::newRow("test 1 set z") << QUrl::fromLocalFile(TESTDATA("order.1.qml"))
+ QTest::newRow("test 1 set z") << order1Url
<< int(SetZ) << QVariant(1) << QVariant(qreal(1.))
<< (QStringList() << "1" << "3" << "2");
- QTest::newRow("test 2 noop") << QUrl::fromLocalFile(TESTDATA("order.2.qml"))
+ QTest::newRow("test 2 noop") << order2Url
<< int(NoOp) << QVariant() << QVariant()
<< (QStringList() << "1" << "3" << "2");
- QTest::newRow("test 2 add") << QUrl::fromLocalFile(TESTDATA("order.2.qml"))
+ QTest::newRow("test 2 add") << order2Url
<< int(Append) << QVariant("new") << QVariant()
<< (QStringList() << "1" << "3" << "new" << "2");
- QTest::newRow("test 2 remove 1") << QUrl::fromLocalFile(TESTDATA("order.2.qml"))
+ QTest::newRow("test 2 remove 1") << order2Url
<< int(Remove) << QVariant(1) << QVariant()
<< (QStringList() << "1" << "3");
- QTest::newRow("test 2 remove 2") << QUrl::fromLocalFile(TESTDATA("order.2.qml"))
+ QTest::newRow("test 2 remove 2") << order2Url
<< int(Remove) << QVariant(2) << QVariant()
<< (QStringList() << "1" << "2");
- QTest::newRow("test 2 stack before 1") << QUrl::fromLocalFile(TESTDATA("order.2.qml"))
+ QTest::newRow("test 2 stack before 1") << order2Url
<< int(StackBefore) << QVariant(1) << QVariant(0)
<< (QStringList() << "1" << "3" << "2");
- QTest::newRow("test 2 stack before 2") << QUrl::fromLocalFile(TESTDATA("order.2.qml"))
+ QTest::newRow("test 2 stack before 2") << order2Url
<< int(StackBefore) << QVariant(2) << QVariant(0)
<< (QStringList() << "3" << "1" << "2");
- QTest::newRow("test 2 stack after 1") << QUrl::fromLocalFile(TESTDATA("order.2.qml"))
+ QTest::newRow("test 2 stack after 1") << order2Url
<< int(StackAfter) << QVariant(0) << QVariant(1)
<< (QStringList() << "1" << "3" << "2");
- QTest::newRow("test 2 stack after 2") << QUrl::fromLocalFile(TESTDATA("order.2.qml"))
+ QTest::newRow("test 2 stack after 2") << order2Url
<< int(StackAfter) << QVariant(0) << QVariant(2)
<< (QStringList() << "3" << "1" << "2");
- QTest::newRow("test 1 set z") << QUrl::fromLocalFile(TESTDATA("order.1.qml"))
+ QTest::newRow("test 1 set z") << order1Url
<< int(SetZ) << QVariant(2) << QVariant(qreal(2.))
<< (QStringList() << "1" << "2" << "3");
}
TARGET = tst_qquickitem2
macx:CONFIG -= app_bundle
-SOURCES += tst_qquickitem.cpp
+SOURCES += tst_qquickitem.cpp \
+ ../../shared/util.cpp
+HEADERS += ../../shared/util.h
testDataFiles.files = data
testDataFiles.path = .
#include <private/qquickitem_p.h>
#include "../../shared/util.h"
-class tst_QQuickItem : public QObject
+class tst_QQuickItem : public QDeclarativeDataTest
{
Q_OBJECT
public:
void tst_QQuickItem::initTestCase()
{
+ QDeclarativeDataTest::initTestCase();
qmlRegisterType<KeyTestItem>("Test",1,0,"KeyTestItem");
}
canvas->rootContext()->setContextProperty("enableKeyHanding", QVariant(true));
canvas->rootContext()->setContextProperty("forwardeeVisible", QVariant(true));
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("keystest.qml")));
+ canvas->setSource(testFileUrl("keystest.qml"));
canvas->show();
canvas->requestActivateWindow();
QTest::qWaitForWindowShown(canvas);
KeysTestObject *testObject = new KeysTestObject;
canvas->rootContext()->setContextProperty("keysTestObject", testObject);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("keyspriority.qml")));
+ canvas->setSource(testFileUrl("keyspriority.qml"));
canvas->show();
canvas->requestActivateWindow();
QTest::qWaitForWindowShown(canvas);
void tst_QQuickItem::layoutMirroring()
{
QQuickView *canvas = new QQuickView(0);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("layoutmirroring.qml")));
+ canvas->setSource(testFileUrl("layoutmirroring.qml"));
canvas->show();
QQuickItem *rootItem = qobject_cast<QQuickItem*>(canvas->rootObject());
QQuickView *canvas = new QQuickView(0);
canvas->setBaseSize(QSize(240,320));
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("keynavigationtest.qml")));
+ canvas->setSource(testFileUrl("keynavigationtest.qml"));
canvas->show();
canvas->requestActivateWindow();
QTest::qWaitForWindowShown(canvas);
QQuickView *canvas = new QQuickView(0);
canvas->setBaseSize(QSize(240,320));
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("keynavigationtest.qml")));
+ canvas->setSource(testFileUrl("keynavigationtest.qml"));
canvas->show();
canvas->requestActivateWindow();
QTest::qWaitForWindowShown(canvas);
QQuickView *canvas = new QQuickView(0);
canvas->setBaseSize(QSize(240,320));
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("keynavigationtest.qml")));
+ canvas->setSource(testFileUrl("keynavigationtest.qml"));
canvas->show();
canvas->requestActivateWindow();
QTest::qWaitForWindowShown(canvas);
QQuickView *canvas = new QQuickView(0);
canvas->setBaseSize(QSize(240,320));
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("keynavigationtest_implicit.qml")));
+ canvas->setSource(testFileUrl("keynavigationtest_implicit.qml"));
canvas->show();
canvas->requestActivateWindow();
QTest::qWaitForWindowShown(canvas);
QQuickView *canvas = new QQuickView(0);
canvas->setBaseSize(QSize(300, 300));
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("mapCoordinates.qml")));
+ canvas->setSource(testFileUrl("mapCoordinates.qml"));
canvas->show();
qApp->processEvents();
Q_RETURN_ARG(QVariant, result), Q_ARG(QVariant, x), Q_ARG(QVariant, y)));
QCOMPARE(result.value<QPointF>(), qobject_cast<QQuickItem*>(a)->mapFromScene(QPointF(x, y)));
- QString warning1 = QUrl::fromLocalFile(TESTDATA("mapCoordinates.qml")).toString() + ":48:5: QML Item: mapToItem() given argument \"1122\" which is neither null nor an Item";
- QString warning2 = QUrl::fromLocalFile(TESTDATA("mapCoordinates.qml")).toString() + ":48:5: QML Item: mapFromItem() given argument \"1122\" which is neither null nor an Item";
+ QString warning1 = testFileUrl("mapCoordinates.qml").toString() + ":48:5: QML Item: mapToItem() given argument \"1122\" which is neither null nor an Item";
+ QString warning2 = testFileUrl("mapCoordinates.qml").toString() + ":48:5: QML Item: mapFromItem() given argument \"1122\" which is neither null nor an Item";
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
QVERIFY(QMetaObject::invokeMethod(root, "checkMapAToInvalid",
void tst_QQuickItem::childrenProperty()
{
- QDeclarativeComponent component(&engine, TESTDATA("childrenProperty.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("childrenProperty.qml"));
QObject *o = component.create();
QVERIFY(o != 0);
void tst_QQuickItem::resourcesProperty()
{
- QDeclarativeComponent component(&engine, TESTDATA("resourcesProperty.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("resourcesProperty.qml"));
QObject *o = component.create();
QVERIFY(o != 0);
{
QQuickView *canvas = new QQuickView(0);
canvas->setBaseSize(QSize(300, 300));
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("propertychanges.qml")));
+ canvas->setSource(testFileUrl("propertychanges.qml"));
canvas->show();
canvas->requestActivateWindow();
QTest::qWaitForWindowShown(canvas);
void tst_QQuickItem::childrenRect()
{
QQuickView *canvas = new QQuickView(0);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("childrenRect.qml")));
+ canvas->setSource(testFileUrl("childrenRect.qml"));
canvas->setBaseSize(QSize(240,320));
canvas->show();
{
QQuickView *canvas = new QQuickView(0);
- QString warning = QUrl::fromLocalFile(TESTDATA("childrenRectBug.qml")).toString() + ":7:5: QML Item: Binding loop detected for property \"height\"";
+ QString warning = testFileUrl("childrenRectBug.qml").toString() + ":7:5: QML Item: Binding loop detected for property \"height\"";
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("childrenRectBug.qml")));
+ canvas->setSource(testFileUrl("childrenRectBug.qml"));
canvas->show();
QQuickItem *o = canvas->rootObject();
{
QQuickView *canvas = new QQuickView(0);
- QString warning1 = QUrl::fromLocalFile(TESTDATA("childrenRectBug2.qml")).toString() + ":7:5: QML Item: Binding loop detected for property \"width\"";
+ QString warning1 = testFileUrl("childrenRectBug2.qml").toString() + ":7:5: QML Item: Binding loop detected for property \"width\"";
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning1));
- QString warning2 = QUrl::fromLocalFile(TESTDATA("childrenRectBug2.qml")).toString() + ":7:5: QML Item: Binding loop detected for property \"height\"";
+ QString warning2 = testFileUrl("childrenRectBug2.qml").toString() + ":7:5: QML Item: Binding loop detected for property \"height\"";
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning2));
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("childrenRectBug2.qml")));
+ canvas->setSource(testFileUrl("childrenRectBug2.qml"));
canvas->show();
QQuickRectangle *rect = qobject_cast<QQuickRectangle*>(canvas->rootObject());
void tst_QQuickItem::childrenRectBug3()
{
QQuickView *canvas = new QQuickView(0);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("childrenRectBug3.qml")));
+ canvas->setSource(testFileUrl("childrenRectBug3.qml"));
canvas->show();
//don't crash on delete
void tst_QQuickItem::transformCrash()
{
QQuickView *canvas = new QQuickView(0);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("transformCrash.qml")));
+ canvas->setSource(testFileUrl("transformCrash.qml"));
canvas->show();
delete canvas;
void tst_QQuickItem::implicitSize()
{
QQuickView *canvas = new QQuickView(0);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("implicitsize.qml")));
+ canvas->setSource(testFileUrl("implicitsize.qml"));
canvas->show();
QQuickItem *item = qobject_cast<QQuickItem*>(canvas->rootObject());
void tst_QQuickItem::qtbug_16871()
{
- QDeclarativeComponent component(&engine, TESTDATA("qtbug_16871.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("qtbug_16871.qml"));
QObject *o = component.create();
QVERIFY(o != 0);
delete o;
TARGET = tst_qquicklistview
macx:CONFIG -= app_bundle
-HEADERS += incrementalmodel.h
-SOURCES += tst_qquicklistview.cpp incrementalmodel.cpp
+HEADERS += incrementalmodel.h \
+ ../../shared/util.h
+SOURCES += tst_qquicklistview.cpp \
+ incrementalmodel.cpp \
+ ../../shared/util.cpp
testDataFiles.files = data
testDataFiles.path = .
Q_DECLARE_METATYPE(Qt::LayoutDirection)
Q_DECLARE_METATYPE(QQuickListView::Orientation)
-class tst_QQuickListView : public QObject
+class tst_QQuickListView : public QDeclarativeDataTest
{
Q_OBJECT
public:
tst_QQuickListView();
private slots:
- void initTestCase();
- void cleanupTestCase();
// Test both QListModelInterface and QAbstractItemModel model types
void qListModelInterface_items();
void qListModelInterface_package_items();
void moved_data();
};
-void tst_QQuickListView::initTestCase()
-{
-}
-
-void tst_QQuickListView::cleanupTestCase()
-{
-
-}
class TestObject : public QObject
{
Q_OBJECT
ctxt->setContextProperty("testObject", testObject);
canvas->setSource(source);
- //canvas->setSource(QUrl::fromLocalFile(TESTDATA("listviewtest.qml")));
+ //canvas->setSource(testFileUrl("listviewtest.qml")));
qApp->processEvents();
QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
TestObject *testObject = new TestObject;
ctxt->setContextProperty("testObject", testObject);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("listviewtest.qml")));
+ canvas->setSource(testFileUrl("listviewtest.qml"));
qApp->processEvents();
QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
TestObject *testObject = new TestObject;
ctxt->setContextProperty("testObject", testObject);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("listviewtest.qml")));
+ canvas->setSource(testFileUrl("listviewtest.qml"));
qApp->processEvents();
QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
TestObject *testObject = new TestObject;
ctxt->setContextProperty("testObject", testObject);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("listviewtest.qml")));
+ canvas->setSource(testFileUrl("listviewtest.qml"));
qApp->processEvents();
QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
TestObject *testObject = new TestObject;
ctxt->setContextProperty("testObject", testObject);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("listviewtest.qml")));
+ canvas->setSource(testFileUrl("listviewtest.qml"));
qApp->processEvents();
QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
QDeclarativeContext *ctxt = canvas->rootContext();
ctxt->setContextProperty("testModel", &model);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("listview-enforcerange.qml")));
+ canvas->setSource(testFileUrl("listview-enforcerange.qml"));
qApp->processEvents();
QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
QDeclarativeContext *ctxt = canvas->rootContext();
ctxt->setContextProperty("testModel", &model);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("listview-enforcerange-nohighlight.qml")));
+ canvas->setSource(testFileUrl("listview-enforcerange-nohighlight.qml"));
qApp->processEvents();
QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
TestObject *testObject = new TestObject;
ctxt->setContextProperty("testObject", testObject);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("listviewtest.qml")));
+ canvas->setSource(testFileUrl("listviewtest.qml"));
qApp->processEvents();
QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
QDeclarativeContext *ctxt = canvas->rootContext();
ctxt->setContextProperty("testModel", &model);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("listview-sections_delegate.qml")));
+ canvas->setSource(testFileUrl("listview-sections_delegate.qml"));
qApp->processEvents();
QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
QDeclarativeContext *ctxt = canvas->rootContext();
ctxt->setContextProperty("testModel", &model);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("listview-sections_delegate.qml")));
+ canvas->setSource(testFileUrl("listview-sections_delegate.qml"));
qApp->processEvents();
canvas->rootObject()->setProperty("sectionPositioning", QVariant(int(QQuickViewSection::InlineLabels | QQuickViewSection::CurrentLabelAtStart | QQuickViewSection::NextLabelAtEnd)));
// (since the currentItem will have changed and that shares the same index)
canvas->rootContext()->setContextProperty("setCurrentToZero", setCurrentToZero);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("fillModelOnComponentCompleted.qml")));
+ canvas->setSource(testFileUrl("fillModelOnComponentCompleted.qml"));
qApp->processEvents();
QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
ctxt->setContextProperty("testModel", &model);
ctxt->setContextProperty("testWrap", QVariant(false));
- QString filename(TESTDATA("listview-initCurrent.qml"));
+ QString filename(testFile("listview-initCurrent.qml"));
canvas->setSource(QUrl::fromLocalFile(filename));
qApp->processEvents();
QDeclarativeContext *ctxt = canvas->rootContext();
ctxt->setContextProperty("testModel", &model);
- QString filename(TESTDATA("listview-noCurrent.qml"));
+ QString filename(testFile("listview-noCurrent.qml"));
canvas->setSource(QUrl::fromLocalFile(filename));
qApp->processEvents();
{
QQuickView *canvas = createView();
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("itemlist.qml")));
+ canvas->setSource(testFileUrl("itemlist.qml"));
qApp->processEvents();
QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "view");
TestObject *testObject = new TestObject;
ctxt->setContextProperty("testObject", testObject);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("listviewtest.qml")));
+ canvas->setSource(testFileUrl("listviewtest.qml"));
canvas->show();
qApp->processEvents();
TestObject *testObject = new TestObject;
ctxt->setContextProperty("testObject", testObject);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("listviewtest.qml")));
+ canvas->setSource(testFileUrl("listviewtest.qml"));
qApp->processEvents();
QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
QDeclarativeContext *ctxt = canvas->rootContext();
ctxt->setContextProperty("testModel", &model);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("displaylist.qml")));
+ canvas->setSource(testFileUrl("displaylist.qml"));
qApp->processEvents();
QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
{
QQuickView *canvas = createView();
QTRY_VERIFY(canvas);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("propertychangestest.qml")));
+ canvas->setSource(testFileUrl("propertychangestest.qml"));
QQuickListView *listView = canvas->rootObject()->findChild<QQuickListView*>("listView");
QTRY_VERIFY(listView);
{
QQuickView *canvas = createView();
QTRY_VERIFY(canvas);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("propertychangestest.qml")));
+ canvas->setSource(testFileUrl("propertychangestest.qml"));
QQuickListView *listView = canvas->rootObject()->findChild<QQuickListView*>("listView");
QTRY_VERIFY(listView);
{
QQuickView *canvas = createView();
QTRY_VERIFY(canvas);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("propertychangestest.qml")));
+ canvas->setSource(testFileUrl("propertychangestest.qml"));
QQuickListView *listView = canvas->rootObject()->findChild<QQuickListView*>("listView");
QTRY_VERIFY(listView);
{
QQuickView *canvas = createView();
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("strictlyenforcerange.qml")));
+ canvas->setSource(testFileUrl("strictlyenforcerange.qml"));
qApp->processEvents();
QQuickListView *listview = qobject_cast<QQuickListView*>(canvas->rootObject());
QQuickView *canvas = new QQuickView(0);
canvas->setGeometry(0,0,240,320);
- QString filename(TESTDATA("manual-highlight.qml"));
+ QString filename(testFile("manual-highlight.qml"));
canvas->setSource(QUrl::fromLocalFile(filename));
qApp->processEvents();
TestObject *testObject = new TestObject;
ctxt->setContextProperty("testObject", testObject);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("listviewtest.qml")));
+ canvas->setSource(testFileUrl("listviewtest.qml"));
qApp->processEvents();
QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
canvas->rootContext()->setContextProperty("testModel", &model);
canvas->rootContext()->setContextProperty("initialViewWidth", 240);
canvas->rootContext()->setContextProperty("initialViewHeight", 320);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("header.qml")));
+ canvas->setSource(testFileUrl("header.qml"));
QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
QTRY_VERIFY(listview != 0);
canvas->rootContext()->setContextProperty("testModel", &model);
canvas->rootContext()->setContextProperty("initialViewWidth", 0.0);
canvas->rootContext()->setContextProperty("initialViewHeight", 0.0);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("header.qml")));
+ canvas->setSource(testFileUrl("header.qml"));
listview = findItem<QQuickListView>(canvas->rootObject(), "list");
QTRY_VERIFY(listview != 0);
TestModel model;
canvas->rootContext()->setContextProperty("setCurrentToZero", QVariant(false));
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("fillModelOnComponentCompleted.qml")));
+ canvas->setSource(testFileUrl("fillModelOnComponentCompleted.qml"));
qApp->processEvents();
QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
QDeclarativeContext *ctxt = canvas->rootContext();
ctxt->setContextProperty("testModel", &model);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("footer.qml")));
+ canvas->setSource(testFileUrl("footer.qml"));
canvas->show();
qApp->processEvents();
QDeclarativeContext *ctxt = canvas->rootContext();
ctxt->setContextProperty("testModel", &model);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("headerfooter.qml")));
+ canvas->setSource(testFileUrl("headerfooter.qml"));
qApp->processEvents();
QQuickListView *listview = qobject_cast<QQuickListView*>(canvas->rootObject());
QDeclarativeContext *ctxt = canvas->rootContext();
ctxt->setContextProperty("testModel", &model);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("headerfooter.qml")));
+ canvas->setSource(testFileUrl("headerfooter.qml"));
canvas->rootObject()->setProperty("horizontal", true);
qApp->processEvents();
QDeclarativeContext *ctxt = canvas->rootContext();
ctxt->setContextProperty("testModel", &model);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("headerfooter.qml")));
+ canvas->setSource(testFileUrl("headerfooter.qml"));
canvas->rootObject()->setProperty("horizontal", true);
canvas->rootObject()->setProperty("rtl", true);
qApp->processEvents();
TestObject *testObject = new TestObject;
ctxt->setContextProperty("testObject", testObject);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("listviewtest.qml")));
+ canvas->setSource(testFileUrl("listviewtest.qml"));
qApp->processEvents();
QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
ctxt->setContextProperty("testModel", &model);
ctxt->setContextProperty("initialHeight", 100);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("resizeview.qml")));
+ canvas->setSource(testFileUrl("resizeview.qml"));
qApp->processEvents();
QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
TestObject *testObject = new TestObject;
ctxt->setContextProperty("testObject", testObject);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("sizelessthan1.qml")));
+ canvas->setSource(testFileUrl("sizelessthan1.qml"));
qApp->processEvents();
QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
{
QQuickView *canvas = createView();
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("qtbug14821.qml")));
+ canvas->setSource(testFileUrl("qtbug14821.qml"));
qApp->processEvents();
QQuickListView *listview = qobject_cast<QQuickListView*>(canvas->rootObject());
QDeclarativeContext *ctxt = canvas->rootContext();
ctxt->setContextProperty("testModel", &model);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("displaylist.qml")));
+ canvas->setSource(testFileUrl("displaylist.qml"));
qApp->processEvents();
QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
TestObject *testObject = new TestObject;
ctxt->setContextProperty("testObject", testObject);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("listviewtest.qml")));
+ canvas->setSource(testFileUrl("listviewtest.qml"));
qApp->processEvents();
QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
QQuickView *canvas = createView();
canvas->show();
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("qtbug16037.qml")));
+ canvas->setSource(testFileUrl("qtbug16037.qml"));
qApp->processEvents();
QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "listview");
TestObject *testObject = new TestObject;
ctxt->setContextProperty("testObject", testObject);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("listviewtest.qml")));
+ canvas->setSource(testFileUrl("listviewtest.qml"));
qApp->processEvents();
QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
QDeclarativeContext *ctxt = canvas->rootContext();
ctxt->setContextProperty("testModel", &model);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("displaylist.qml")));
+ canvas->setSource(testFileUrl("displaylist.qml"));
qApp->processEvents();
QQuickListView *listview = findItem<QQuickListView>(canvas->rootObject(), "list");
QDeclarativeContext *ctxt = canvas->rootContext();
ctxt->setContextProperty("testModel", &model);
ctxt->setContextProperty("delegateHeight", delegateHeight);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("attachedSignals.qml")));
+ canvas->setSource(testFileUrl("attachedSignals.qml"));
QObject *object = canvas->rootObject();
object->setProperty("width", canvas->width());
QDeclarativeContext *ctxt = canvas->rootContext();
ctxt->setContextProperty("testModel", &model);
ctxt->setContextProperty("delegateHeight", delegateHeight);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("attachedSignals.qml")));
+ canvas->setSource(testFileUrl("attachedSignals.qml"));
QObject *object = canvas->rootObject();
model.removeItems(indexToRemove, removeCount);
{
QQuickView *canvas = createView();
canvas->setGeometry(0,0,640,320);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("rightToLeft.qml")));
+ canvas->setSource(testFileUrl("rightToLeft.qml"));
qApp->processEvents();
QVERIFY(canvas->rootObject() != 0);
void tst_QQuickListView::test_mirroring()
{
QQuickView *canvasA = createView();
- canvasA->setSource(QUrl::fromLocalFile(TESTDATA("rightToLeft.qml")));
+ canvasA->setSource(testFileUrl("rightToLeft.qml"));
QQuickListView *listviewA = findItem<QQuickListView>(canvasA->rootObject(), "view");
QTRY_VERIFY(listviewA != 0);
QQuickView *canvasB = createView();
- canvasB->setSource(QUrl::fromLocalFile(TESTDATA("rightToLeft.qml")));
+ canvasB->setSource(testFileUrl("rightToLeft.qml"));
QQuickListView *listviewB = findItem<QQuickListView>(canvasB->rootObject(), "view");
QTRY_VERIFY(listviewA != 0);
qApp->processEvents();
QDeclarativeContext *ctxt = canvas->rootContext();
ctxt->setContextProperty("testModel", &model);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("margins.qml")));
+ canvas->setSource(testFileUrl("margins.qml"));
canvas->show();
qApp->processEvents();
QQuickView *canvas = createView();
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("snapToItem.qml")));
+ canvas->setSource(testFileUrl("snapToItem.qml"));
canvas->show();
qApp->processEvents();
void tst_QQuickListView::qListModelInterface_items()
{
- items<TestModel>(QUrl::fromLocalFile(TESTDATA("listviewtest.qml")), false);
+ items<TestModel>(testFileUrl("listviewtest.qml"), false);
}
void tst_QQuickListView::qListModelInterface_package_items()
{
- items<TestModel>(QUrl::fromLocalFile(TESTDATA("listviewtest-package.qml")), true);
+ items<TestModel>(testFileUrl("listviewtest-package.qml"), true);
}
void tst_QQuickListView::qAbstractItemModel_items()
{
- items<TestModel2>(QUrl::fromLocalFile(TESTDATA("listviewtest.qml")), false);
+ items<TestModel2>(testFileUrl("listviewtest.qml"), false);
}
void tst_QQuickListView::qListModelInterface_changed()
{
- changed<TestModel>(QUrl::fromLocalFile(TESTDATA("listviewtest.qml")), false);
+ changed<TestModel>(testFileUrl("listviewtest.qml"), false);
}
void tst_QQuickListView::qListModelInterface_package_changed()
{
- changed<TestModel>(QUrl::fromLocalFile(TESTDATA("listviewtest-package.qml")), true);
+ changed<TestModel>(testFileUrl("listviewtest-package.qml"), true);
}
void tst_QQuickListView::qAbstractItemModel_changed()
{
- changed<TestModel2>(QUrl::fromLocalFile(TESTDATA("listviewtest.qml")), false);
+ changed<TestModel2>(testFileUrl("listviewtest.qml"), false);
}
void tst_QQuickListView::qListModelInterface_inserted()
{
- inserted<TestModel>(QUrl::fromLocalFile(TESTDATA("listviewtest.qml")));
+ inserted<TestModel>(testFileUrl("listviewtest.qml"));
}
void tst_QQuickListView::qListModelInterface_package_inserted()
{
- inserted<TestModel>(QUrl::fromLocalFile(TESTDATA("listviewtest-package.qml")));
+ inserted<TestModel>(testFileUrl("listviewtest-package.qml"));
}
void tst_QQuickListView::qListModelInterface_inserted_more()
void tst_QQuickListView::qAbstractItemModel_inserted()
{
- inserted<TestModel2>(QUrl::fromLocalFile(TESTDATA("listviewtest.qml")));
+ inserted<TestModel2>(testFileUrl("listviewtest.qml"));
}
void tst_QQuickListView::qAbstractItemModel_inserted_more()
void tst_QQuickListView::qListModelInterface_removed()
{
- removed<TestModel>(QUrl::fromLocalFile(TESTDATA("listviewtest.qml")), false);
- removed<TestModel>(QUrl::fromLocalFile(TESTDATA("listviewtest.qml")), true);
+ removed<TestModel>(testFileUrl("listviewtest.qml"), false);
+ removed<TestModel>(testFileUrl("listviewtest.qml"), true);
}
void tst_QQuickListView::qListModelInterface_package_removed()
{
- removed<TestModel>(QUrl::fromLocalFile(TESTDATA("listviewtest-package.qml")), false);
- removed<TestModel>(QUrl::fromLocalFile(TESTDATA("listviewtest-package.qml")), true);
+ removed<TestModel>(testFileUrl("listviewtest-package.qml"), false);
+ removed<TestModel>(testFileUrl("listviewtest-package.qml"), true);
}
void tst_QQuickListView::qAbstractItemModel_removed()
{
- removed<TestModel2>(QUrl::fromLocalFile(TESTDATA("listviewtest.qml")), false);
- removed<TestModel2>(QUrl::fromLocalFile(TESTDATA("listviewtest.qml")), true);
+ removed<TestModel2>(testFileUrl("listviewtest.qml"), false);
+ removed<TestModel2>(testFileUrl("listviewtest.qml"), true);
}
void tst_QQuickListView::qListModelInterface_moved()
{
- moved<TestModel>(QUrl::fromLocalFile(TESTDATA("listviewtest.qml")));
+ moved<TestModel>(testFileUrl("listviewtest.qml"));
}
void tst_QQuickListView::qListModelInterface_moved_data()
void tst_QQuickListView::qListModelInterface_package_moved()
{
- moved<TestModel>(QUrl::fromLocalFile(TESTDATA("listviewtest-package.qml")));
+ moved<TestModel>(testFileUrl("listviewtest-package.qml"));
}
void tst_QQuickListView::qListModelInterface_package_moved_data()
void tst_QQuickListView::qAbstractItemModel_moved()
{
- moved<TestModel2>(QUrl::fromLocalFile(TESTDATA("listviewtest.qml")));
+ moved<TestModel2>(testFileUrl("listviewtest.qml"));
}
void tst_QQuickListView::qAbstractItemModel_moved_data()
void tst_QQuickListView::qListModelInterface_clear()
{
- clear<TestModel>(QUrl::fromLocalFile(TESTDATA("listviewtest.qml")));
+ clear<TestModel>(testFileUrl("listviewtest.qml"));
}
void tst_QQuickListView::qListModelInterface_package_clear()
{
- clear<TestModel>(QUrl::fromLocalFile(TESTDATA("listviewtest-package.qml")));
+ clear<TestModel>(testFileUrl("listviewtest-package.qml"));
}
void tst_QQuickListView::qAbstractItemModel_clear()
{
- clear<TestModel2>(QUrl::fromLocalFile(TESTDATA("listviewtest.qml")));
+ clear<TestModel2>(testFileUrl("listviewtest.qml"));
}
void tst_QQuickListView::qListModelInterface_sections()
{
- sections<TestModel>(QUrl::fromLocalFile(TESTDATA("listview-sections.qml")));
+ sections<TestModel>(testFileUrl("listview-sections.qml"));
}
void tst_QQuickListView::qListModelInterface_package_sections()
{
- sections<TestModel>(QUrl::fromLocalFile(TESTDATA("listview-sections-package.qml")));
+ sections<TestModel>(testFileUrl("listview-sections-package.qml"));
}
void tst_QQuickListView::qAbstractItemModel_sections()
{
- sections<TestModel2>(QUrl::fromLocalFile(TESTDATA("listview-sections.qml")));
+ sections<TestModel2>(testFileUrl("listview-sections.qml"));
}
void tst_QQuickListView::creationContext()
{
QQuickView canvas;
canvas.setGeometry(0,0,240,320);
- canvas.setSource(QUrl::fromLocalFile(TESTDATA("creationContext.qml")));
+ canvas.setSource(testFileUrl("creationContext.qml"));
qApp->processEvents();
QQuickItem *rootItem = qobject_cast<QQuickItem *>(canvas.rootObject());
{
QQuickView canvas;
canvas.setGeometry(0,0,200,200);
- canvas.setSource(QUrl::fromLocalFile(TESTDATA("qtbug-21742.qml")));
+ canvas.setSource(testFileUrl("qtbug-21742.qml"));
qApp->processEvents();
QQuickItem *rootItem = qobject_cast<QQuickItem *>(canvas.rootObject());
QDeclarativeIncubationController controller;
canvas->engine()->setIncubationController(&controller);
- canvas->setSource(TESTDATA("asyncloader.qml"));
+ canvas->setSource(testFileUrl("asyncloader.qml"));
QQuickItem *rootObject = qobject_cast<QQuickItem*>(canvas->rootObject());
QVERIFY(rootObject);
QQuickView *canvas = createView();
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("snapOneItem.qml")));
+ canvas->setSource(testFileUrl("snapOneItem.qml"));
canvas->show();
qApp->processEvents();
ctxt->setContextProperty("testModel", &model);
ctxt->setContextProperty("testWrap", QVariant(false));
- QString filename(TESTDATA("unrequestedItems.qml"));
- canvas->setSource(QUrl::fromLocalFile(filename));
+ canvas->setSource(testFileUrl("unrequestedItems.qml"));
canvas->show();
macx:CONFIG -= app_bundle
INCLUDEPATH += ../../shared/
-HEADERS += ../../shared/testhttpserver.h
+HEADERS += ../../shared/testhttpserver.h \
+ ../../shared/util.h
+
SOURCES += tst_qquickloader.cpp \
- ../../shared/testhttpserver.cpp
+ ../../shared/testhttpserver.cpp \
+ ../../shared/util.cpp
testDataFiles.files = data
testDataFiles.path = .
#define SERVER_PORT 14450
-inline QUrl TEST_FILE(const QString &filename)
-{
- return QUrl::fromLocalFile(TESTDATA(filename));
-}
-
class PeriodicIncubationController : public QObject,
public QDeclarativeIncubationController
{
}
};
-class tst_QQuickLoader : public QObject
+class tst_QQuickLoader : public QDeclarativeDataTest
{
Q_OBJECT
" onProgressChanged: onProgressChangedCount += 1\n"
" onLoaded: onLoadedCount += 1\n"
"}")
- , TEST_FILE(""));
+ , dataDirectoryUrl());
QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create());
QVERIFY(loader != 0);
QTest::addColumn<QUrl>("sourceUrl");
QTest::addColumn<QString>("errorString");
- QTest::newRow("source") << "source" << "source: 'Rect120x60.qml'\n" << QUrl::fromLocalFile(TESTDATA("Rect120x60.qml")) << "";
+ QTest::newRow("source") << "source" << "source: 'Rect120x60.qml'\n" << testFileUrl("Rect120x60.qml") << "";
QTest::newRow("sourceComponent") << "component" << "Component { id: comp; Rectangle { width: 100; height: 50 } }\n sourceComponent: comp\n" << QUrl() << "";
- QTest::newRow("invalid source") << "source" << "source: 'IDontExist.qml'\n" << QUrl::fromLocalFile(TESTDATA("IDontExist.qml"))
- << QString(QUrl::fromLocalFile(TESTDATA("IDontExist.qml")).toString() + ": File not found");
+ QTest::newRow("invalid source") << "source" << "source: 'IDontExist.qml'\n" << testFileUrl("IDontExist.qml")
+ << QString(testFileUrl("IDontExist.qml").toString() + ": File not found");
}
void tst_QQuickLoader::clear()
" source: 'Rect120x60.qml'\n"
" Timer { interval: 200; running: true; onTriggered: loader.source = '' }\n"
" }")
- , TEST_FILE(""));
+ , dataDirectoryUrl());
QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create());
QVERIFY(loader != 0);
QVERIFY(loader->item());
delete loader;
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("/SetSourceComponent.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("/SetSourceComponent.qml"));
QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
QVERIFY(item);
delete item;
}
{
- QDeclarativeComponent component(&engine, TEST_FILE("/SetSourceComponent.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("/SetSourceComponent.qml"));
QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
QVERIFY(item);
" source: \"Rect120x60.qml\"\n"
" Timer { interval: 100; running: true; onTriggered: loader.sourceComponent = myComp }\n"
"}" )
- , TEST_FILE(""));
+ , dataDirectoryUrl());
QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create());
QTest::qWait(200);
QTRY_VERIFY(loader != 0);
void tst_QQuickLoader::componentToUrl()
{
- QDeclarativeComponent component(&engine, TEST_FILE("/SetSourceComponent.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("/SetSourceComponent.qml"));
QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
QVERIFY(item);
QCOMPARE(loader->progress(), 1.0);
QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1);
- loader->setSource(TEST_FILE("/Rect120x60.qml"));
+ loader->setSource(testFileUrl("/Rect120x60.qml"));
QVERIFY(loader->item());
QCOMPARE(loader->progress(), 1.0);
QCOMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1);
void tst_QQuickLoader::anchoredLoader()
{
- QDeclarativeComponent component(&engine, TEST_FILE("/AnchoredLoader.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("/AnchoredLoader.qml"));
QQuickItem *rootItem = qobject_cast<QQuickItem*>(component.create());
QVERIFY(rootItem != 0);
QQuickItem *loader = rootItem->findChild<QQuickItem*>("loader");
void tst_QQuickLoader::sizeLoaderToItem()
{
- QDeclarativeComponent component(&engine, TEST_FILE("/SizeToItem.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("/SizeToItem.qml"));
QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create());
QVERIFY(loader != 0);
QCOMPARE(loader->width(), 120.0);
void tst_QQuickLoader::sizeItemToLoader()
{
- QDeclarativeComponent component(&engine, TEST_FILE("/SizeToLoader.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("/SizeToLoader.qml"));
QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create());
QVERIFY(loader != 0);
QCOMPARE(loader->width(), 200.0);
void tst_QQuickLoader::noResize()
{
- QDeclarativeComponent component(&engine, TEST_FILE("/NoResize.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("/NoResize.qml"));
QQuickItem* item = qobject_cast<QQuickItem*>(component.create());
QVERIFY(item != 0);
QCOMPARE(item->width(), 200.0);
{
TestHTTPServer server(SERVER_PORT);
QVERIFY(server.isValid());
- server.serveDirectory(TESTDATA(""));
+ server.serveDirectory(dataDirectory());
QDeclarativeComponent component(&engine);
- component.setData(QByteArray("import QtQuick 2.0\nLoader { property int signalCount : 0; source: \"http://127.0.0.1:14450/Rect120x60.qml\"; onLoaded: signalCount += 1 }"), QUrl::fromLocalFile(TESTDATA("../dummy.qml")));
+ component.setData(QByteArray("import QtQuick 2.0\nLoader { property int signalCount : 0; source: \"http://127.0.0.1:14450/Rect120x60.qml\"; onLoaded: signalCount += 1 }"), testFileUrl("../dummy.qml"));
if (component.isError())
qDebug() << component.errors();
QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create());
"Item {\n"
" Component { id: comp; NW.SlowRect {} }\n"
" Loader { sourceComponent: comp } }")
- , TEST_FILE(""));
+ , dataDirectoryUrl());
QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
QVERIFY(item);
{
TestHTTPServer server(SERVER_PORT);
QVERIFY(server.isValid());
- server.serveDirectory(TESTDATA(""));
+ server.serveDirectory(dataDirectory());
QTest::ignoreMessage(QtWarningMsg, "http://127.0.0.1:14450/IDontExist.qml: File not found");
{
// check that the item isn't instantiated until active is set to true
{
- QDeclarativeComponent component(&engine, TEST_FILE("active.1.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("active.1.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
QQuickLoader *loader = object->findChild<QQuickLoader*>("loader");
// check that the status is Null if active is set to false
{
- QDeclarativeComponent component(&engine, TEST_FILE("active.2.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("active.2.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
QQuickLoader *loader = object->findChild<QQuickLoader*>("loader");
// check that the source is not cleared if active is set to false
{
- QDeclarativeComponent component(&engine, TEST_FILE("active.3.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("active.3.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
QQuickLoader *loader = object->findChild<QQuickLoader*>("loader");
// check that the sourceComponent is not cleared if active is set to false
{
- QDeclarativeComponent component(&engine, TEST_FILE("active.4.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("active.4.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
QQuickLoader *loader = object->findChild<QQuickLoader*>("loader");
// check that the item is released if active is set to false
{
- QDeclarativeComponent component(&engine, TEST_FILE("active.5.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("active.5.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
QQuickLoader *loader = object->findChild<QQuickLoader*>("loader");
// check that the activeChanged signal is emitted correctly
{
- QDeclarativeComponent component(&engine, TEST_FILE("active.6.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("active.6.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
QQuickLoader *loader = object->findChild<QQuickLoader*>("loader");
// check that the component isn't loaded until active is set to true
{
- QDeclarativeComponent component(&engine, TEST_FILE("active.7.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("active.7.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
QCOMPARE(object->property("success").toBool(), true);
// check that the component is loaded if active is not set (true by default)
{
- QDeclarativeComponent component(&engine, TEST_FILE("active.8.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("active.8.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
QCOMPARE(object->property("success").toBool(), true);
QTest::addColumn<QStringList>("propertyNames");
QTest::addColumn<QVariantList>("propertyValues");
- QTest::newRow("source url with value set in onLoaded, initially active = true") << TEST_FILE("initialPropertyValues.1.qml")
+ QTest::newRow("source url with value set in onLoaded, initially active = true") << testFileUrl("initialPropertyValues.1.qml")
<< QStringList()
<< (QStringList() << "initialValue" << "behaviorCount")
<< (QVariantList() << 1 << 1);
- QTest::newRow("set source with initial property values specified, active = true") << TEST_FILE("initialPropertyValues.2.qml")
+ QTest::newRow("set source with initial property values specified, active = true") << testFileUrl("initialPropertyValues.2.qml")
<< QStringList()
<< (QStringList() << "initialValue" << "behaviorCount")
<< (QVariantList() << 2 << 0);
- QTest::newRow("set source with initial property values specified, active = false") << TEST_FILE("initialPropertyValues.3.qml")
- << (QStringList() << QString(QLatin1String("file://") + TEST_FILE("initialPropertyValues.3.qml").toLocalFile() + QLatin1String(":16: TypeError: Cannot read property 'canary' of null")))
+ QTest::newRow("set source with initial property values specified, active = false") << testFileUrl("initialPropertyValues.3.qml")
+ << (QStringList() << QString(QLatin1String("file://") + testFileUrl("initialPropertyValues.3.qml").toLocalFile() + QLatin1String(":16: TypeError: Cannot read property 'canary' of null")))
<< (QStringList())
<< (QVariantList());
- QTest::newRow("set source with initial property values specified, active = false, with active set true later") << TEST_FILE("initialPropertyValues.4.qml")
+ QTest::newRow("set source with initial property values specified, active = false, with active set true later") << testFileUrl("initialPropertyValues.4.qml")
<< QStringList()
<< (QStringList() << "initialValue" << "behaviorCount")
<< (QVariantList() << 4 << 0);
- QTest::newRow("set source without initial property values specified, active = true") << TEST_FILE("initialPropertyValues.5.qml")
+ QTest::newRow("set source without initial property values specified, active = true") << testFileUrl("initialPropertyValues.5.qml")
<< QStringList()
<< (QStringList() << "initialValue" << "behaviorCount")
<< (QVariantList() << 0 << 0);
- QTest::newRow("set source with initial property values specified with binding, active = true") << TEST_FILE("initialPropertyValues.6.qml")
+ QTest::newRow("set source with initial property values specified with binding, active = true") << testFileUrl("initialPropertyValues.6.qml")
<< QStringList()
<< (QStringList() << "initialValue" << "behaviorCount")
<< (QVariantList() << 6 << 0);
- QTest::newRow("ensure initial property value semantics mimic createObject") << TEST_FILE("initialPropertyValues.7.qml")
+ QTest::newRow("ensure initial property value semantics mimic createObject") << testFileUrl("initialPropertyValues.7.qml")
<< QStringList()
<< (QStringList() << "loaderValue" << "createObjectValue")
<< (QVariantList() << 1 << 1);
- QTest::newRow("ensure initial property values aren't disposed prior to component completion") << TEST_FILE("initialPropertyValues.8.qml")
+ QTest::newRow("ensure initial property values aren't disposed prior to component completion") << testFileUrl("initialPropertyValues.8.qml")
<< QStringList()
<< (QStringList() << "initialValue")
<< (QVariantList() << 6);
TestHTTPServer server(SERVER_PORT);
QVERIFY(server.isValid());
- server.serveDirectory(TESTDATA(""));
+ server.serveDirectory(dataDirectory());
foreach (const QString &warning, expectedWarnings)
QTest::ignoreMessage(QtWarningMsg, warning.toAscii().constData());
void tst_QQuickLoader::initialPropertyValuesBinding()
{
- QDeclarativeComponent component(&engine, TEST_FILE("initialPropertyValues.binding.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("initialPropertyValues.binding.qml"));
QObject *object = component.create();
QVERIFY(object != 0);
QTest::addColumn<QUrl>("qmlFile");
QTest::addColumn<QStringList>("expectedWarnings");
- QTest::newRow("invalid initial property values object") << TEST_FILE("initialPropertyValues.error.1.qml")
- << (QStringList() << QString(TEST_FILE("initialPropertyValues.error.1.qml").toString() + ":6:5: QML Loader: setSource: value is not an object"));
+ QTest::newRow("invalid initial property values object") << testFileUrl("initialPropertyValues.error.1.qml")
+ << (QStringList() << QString(testFileUrl("initialPropertyValues.error.1.qml").toString() + ":6:5: QML Loader: setSource: value is not an object"));
- QTest::newRow("nonexistent source url") << TEST_FILE("initialPropertyValues.error.2.qml")
- << (QStringList() << QString(TEST_FILE("NonexistentSourceComponent.qml").toString() + ": File not found"));
+ QTest::newRow("nonexistent source url") << testFileUrl("initialPropertyValues.error.2.qml")
+ << (QStringList() << QString(testFileUrl("NonexistentSourceComponent.qml").toString() + ": File not found"));
- QTest::newRow("invalid source url") << TEST_FILE("initialPropertyValues.error.3.qml")
- << (QStringList() << QString(TEST_FILE("InvalidSourceComponent.qml").toString() + ":5:1: Syntax error"));
+ QTest::newRow("invalid source url") << testFileUrl("initialPropertyValues.error.3.qml")
+ << (QStringList() << QString(testFileUrl("InvalidSourceComponent.qml").toString() + ":5:1: Syntax error"));
- QTest::newRow("invalid initial property values object with invalid property access") << TEST_FILE("initialPropertyValues.error.4.qml")
- << (QStringList() << QString(TEST_FILE("initialPropertyValues.error.4.qml").toString() + ":7:5: QML Loader: setSource: value is not an object")
- << QString(TEST_FILE("initialPropertyValues.error.4.qml").toString() + ":5: TypeError: Cannot read property 'canary' of null"));
+ QTest::newRow("invalid initial property values object with invalid property access") << testFileUrl("initialPropertyValues.error.4.qml")
+ << (QStringList() << QString(testFileUrl("initialPropertyValues.error.4.qml").toString() + ":7:5: QML Loader: setSource: value is not an object")
+ << QString(testFileUrl("initialPropertyValues.error.4.qml").toString() + ":5: TypeError: Cannot read property 'canary' of null"));
}
void tst_QQuickLoader::initialPropertyValuesError()
// QTBUG-9241
void tst_QQuickLoader::deleteComponentCrash()
{
- QDeclarativeComponent component(&engine, TEST_FILE("crash.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("crash.qml"));
QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
QVERIFY(item);
QCOMPARE(loader->status(), QQuickLoader::Ready);
qApp->processEvents(QEventLoop::DeferredDeletion);
QTRY_COMPARE(static_cast<QQuickItem*>(loader)->childItems().count(), 1);
- QVERIFY(loader->source() == QUrl::fromLocalFile(TESTDATA("BlueRect.qml")));
+ QVERIFY(loader->source() == testFileUrl("BlueRect.qml"));
delete item;
}
void tst_QQuickLoader::nonItem()
{
- QDeclarativeComponent component(&engine, TEST_FILE("nonItem.qml"));
- QString err = QUrl::fromLocalFile(TESTDATA("nonItem.qml")).toString() + ":3:1: QML Loader: Loader does not support loading non-visual elements.";
+ QDeclarativeComponent component(&engine, testFileUrl("nonItem.qml"));
+ QString err = testFileUrl("nonItem.qml").toString() + ":3:1: QML Loader: Loader does not support loading non-visual elements.";
QTest::ignoreMessage(QtWarningMsg, err.toLatin1().constData());
QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create());
void tst_QQuickLoader::vmeErrors()
{
- QDeclarativeComponent component(&engine, TEST_FILE("vmeErrors.qml"));
- QString err = QUrl::fromLocalFile(TESTDATA("VmeError.qml")).toString() + ":6: Cannot assign object type QObject with no default method";
+ QDeclarativeComponent component(&engine, testFileUrl("vmeErrors.qml"));
+ QString err = testFileUrl("VmeError.qml").toString() + ":6: Cannot assign object type QObject with no default method";
QTest::ignoreMessage(QtWarningMsg, err.toLatin1().constData());
QQuickLoader *loader = qobject_cast<QQuickLoader*>(component.create());
QVERIFY(loader);
// QTBUG-13481
void tst_QQuickLoader::creationContext()
{
- QDeclarativeComponent component(&engine, TEST_FILE("creationContext.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("creationContext.qml"));
QObject *o = component.create();
QVERIFY(o != 0);
void tst_QQuickLoader::QTBUG_16928()
{
- QDeclarativeComponent component(&engine, TEST_FILE("QTBUG_16928.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("QTBUG_16928.qml"));
QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
QVERIFY(item);
void tst_QQuickLoader::implicitSize()
{
- QDeclarativeComponent component(&engine, TEST_FILE("implicitSize.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("implicitSize.qml"));
QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
QVERIFY(item);
void tst_QQuickLoader::QTBUG_17114()
{
- QDeclarativeComponent component(&engine, TEST_FILE("QTBUG_17114.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("QTBUG_17114.qml"));
QQuickItem *item = qobject_cast<QQuickItem*>(component.create());
QVERIFY(item);
QTest::addColumn<QUrl>("qmlFile");
QTest::addColumn<QStringList>("expectedWarnings");
- QTest::newRow("Valid component") << TEST_FILE("BigComponent.qml")
+ QTest::newRow("Valid component") << testFileUrl("BigComponent.qml")
<< QStringList();
- QTest::newRow("Non-existant component") << TEST_FILE("IDoNotExist.qml")
- << (QStringList() << QString(TEST_FILE("IDoNotExist.qml").toString() + ": File not found"));
+ QTest::newRow("Non-existant component") << testFileUrl("IDoNotExist.qml")
+ << (QStringList() << QString(testFileUrl("IDoNotExist.qml").toString() + ": File not found"));
- QTest::newRow("Invalid component") << TEST_FILE("InvalidSourceComponent.qml")
- << (QStringList() << QString(TEST_FILE("InvalidSourceComponent.qml").toString() + ":5:1: Syntax error"));
+ QTest::newRow("Invalid component") << testFileUrl("InvalidSourceComponent.qml")
+ << (QStringList() << QString(testFileUrl("InvalidSourceComponent.qml").toString() + ":5:1: Syntax error"));
}
void tst_QQuickLoader::asynchronous()
if (!engine.incubationController())
engine.setIncubationController(new PeriodicIncubationController);
- QDeclarativeComponent component(&engine, TEST_FILE("asynchronous.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("asynchronous.qml"));
QQuickItem *root = qobject_cast<QQuickItem*>(component.create());
QVERIFY(root);
{
if (!engine.incubationController())
engine.setIncubationController(new PeriodicIncubationController);
- QDeclarativeComponent component(&engine, TEST_FILE("asynchronous.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("asynchronous.qml"));
QQuickItem *root = qobject_cast<QQuickItem*>(component.create());
QVERIFY(root);
void tst_QQuickLoader::parented()
{
- QDeclarativeComponent component(&engine, TEST_FILE("parented.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("parented.qml"));
QQuickItem *root = qobject_cast<QQuickItem*>(component.create());
QVERIFY(root);
TARGET = tst_qquickmousearea
macx:CONFIG -= app_bundle
-HEADERS += ../../shared/testhttpserver.h
-SOURCES += tst_qquickmousearea.cpp ../../shared/testhttpserver.cpp
+HEADERS += ../../shared/testhttpserver.h \
+ ../../shared/util.h
+SOURCES += tst_qquickmousearea.cpp \
+ ../../shared/testhttpserver.cpp \
+ ../../shared/util.cpp
testDataFiles.files = data
testDataFiles.path = .
//#define OLDWAY
-class tst_QQuickMouseArea: public QObject
+class tst_QQuickMouseArea: public QDeclarativeDataTest
{
Q_OBJECT
private slots:
- void initTestCase();
- void cleanupTestCase();
void dragProperties();
void resetDrag();
void dragging();
QQuickView *createView();
};
-void tst_QQuickMouseArea::initTestCase()
-{
-
-}
-
-void tst_QQuickMouseArea::cleanupTestCase()
-{
-
-}
-
void tst_QQuickMouseArea::dragProperties()
{
QQuickView *canvas = createView();
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("dragproperties.qml")));
+ canvas->setSource(testFileUrl("dragproperties.qml"));
canvas->show();
canvas->requestActivateWindow();
QVERIFY(canvas->rootObject() != 0);
QQuickView *canvas = createView();
canvas->rootContext()->setContextProperty("haveTarget", QVariant(true));
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("dragreset.qml")));
+ canvas->setSource(testFileUrl("dragreset.qml"));
canvas->show();
canvas->requestActivateWindow();
QVERIFY(canvas->rootObject() != 0);
{
QQuickView *canvas = createView();
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("dragging.qml")));
+ canvas->setSource(testFileUrl("dragging.qml"));
canvas->show();
canvas->requestActivateWindow();
QTest::qWait(20);
void tst_QQuickMouseArea::updateMouseAreaPosOnClick()
{
QQuickView *canvas = createView();
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("updateMousePosOnClick.qml")));
+ canvas->setSource(testFileUrl("updateMousePosOnClick.qml"));
canvas->show();
canvas->requestActivateWindow();
QVERIFY(canvas->rootObject() != 0);
void tst_QQuickMouseArea::updateMouseAreaPosOnResize()
{
QQuickView *canvas = createView();
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("updateMousePosOnResize.qml")));
+ canvas->setSource(testFileUrl("updateMousePosOnResize.qml"));
canvas->show();
canvas->requestActivateWindow();
QVERIFY(canvas->rootObject() != 0);
{
// We handle onPressAndHold, therefore no onClicked
QQuickView *canvas = createView();
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("clickandhold.qml")));
+ canvas->setSource(testFileUrl("clickandhold.qml"));
canvas->show();
canvas->requestActivateWindow();
QVERIFY(canvas->rootObject() != 0);
{
// We do not handle onPressAndHold, therefore we get onClicked
QQuickView *canvas = createView();
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("noclickandhold.qml")));
+ canvas->setSource(testFileUrl("noclickandhold.qml"));
canvas->show();
canvas->requestActivateWindow();
QVERIFY(canvas->rootObject() != 0);
void tst_QQuickMouseArea::onMousePressRejected()
{
QQuickView *canvas = createView();
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("rejectEvent.qml")));
+ canvas->setSource(testFileUrl("rejectEvent.qml"));
canvas->show();
canvas->requestActivateWindow();
QVERIFY(canvas->rootObject() != 0);
void tst_QQuickMouseArea::pressedCanceledOnWindowDeactivate()
{
QQuickView *canvas = createView();
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("pressedCanceled.qml")));
+ canvas->setSource(testFileUrl("pressedCanceled.qml"));
canvas->show();
canvas->requestActivateWindow();
QVERIFY(canvas->rootObject() != 0);
void tst_QQuickMouseArea::doubleClick()
{
QQuickView *canvas = createView();
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("doubleclick.qml")));
+ canvas->setSource(testFileUrl("doubleclick.qml"));
canvas->show();
canvas->requestActivateWindow();
QVERIFY(canvas->rootObject() != 0);
void tst_QQuickMouseArea::clickTwice()
{
QQuickView *canvas = createView();
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("clicktwice.qml")));
+ canvas->setSource(testFileUrl("clicktwice.qml"));
canvas->show();
canvas->requestActivateWindow();
QVERIFY(canvas->rootObject() != 0);
void tst_QQuickMouseArea::pressedOrdering()
{
QQuickView *canvas = createView();
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("pressedOrdering.qml")));
+ canvas->setSource(testFileUrl("pressedOrdering.qml"));
canvas->show();
canvas->requestActivateWindow();
QVERIFY(canvas->rootObject() != 0);
{
QQuickView *canvas = createView();
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("preventstealing.qml")));
+ canvas->setSource(testFileUrl("preventstealing.qml"));
canvas->show();
canvas->requestActivateWindow();
QVERIFY(canvas->rootObject() != 0);
{
//With no handlers defined click, doubleClick and PressAndHold should propagate to those with handlers
QQuickView *canvas = createView();
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("clickThrough.qml")));
+ canvas->setSource(testFileUrl("clickThrough.qml"));
canvas->show();
canvas->requestActivateWindow();
QVERIFY(canvas->rootObject() != 0);
//With handlers defined click, doubleClick and PressAndHold should propagate only when explicitly ignored
canvas = createView();
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("clickThrough2.qml")));
+ canvas->setSource(testFileUrl("clickThrough2.qml"));
canvas->show();
canvas->requestActivateWindow();
QVERIFY(canvas->rootObject() != 0);
void tst_QQuickMouseArea::hoverPosition()
{
QQuickView *canvas = createView();
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("hoverPosition.qml")));
+ canvas->setSource(testFileUrl("hoverPosition.qml"));
QQuickItem *root = canvas->rootObject();
QVERIFY(root != 0);
{
//QTBUG-18175, to behave like GV did.
QQuickView *canvas = createView();
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("hoverPropagation.qml")));
+ canvas->setSource(testFileUrl("hoverPropagation.qml"));
QQuickItem *root = canvas->rootObject();
QVERIFY(root != 0);
TARGET = tst_qquickpathview
macx:CONFIG -= app_bundle
-SOURCES += tst_qquickpathview.cpp
+SOURCES += tst_qquickpathview.cpp \
+ ../../shared/util.cpp
+HEADERS += ../../shared/util.h
testDataFiles.files = data
testDataFiles.path = .
}
-class tst_QQuickPathView : public QObject
+class tst_QQuickPathView : public QDeclarativeDataTest
{
Q_OBJECT
public:
tst_QQuickPathView();
private slots:
- void initTestCase();
- void cleanupTestCase();
void initValues();
void items();
void dataModel();
QList<T*> findItems(QQuickItem *parent, const QString &objectName);
};
-void tst_QQuickPathView::initTestCase()
-{
-}
-
-void tst_QQuickPathView::cleanupTestCase()
-{
-
-}
-
class TestObject : public QObject
{
Q_OBJECT
void tst_QQuickPathView::initValues()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("pathview1.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("pathview1.qml"));
QQuickPathView *obj = qobject_cast<QQuickPathView*>(c.create());
QVERIFY(obj != 0);
QDeclarativeContext *ctxt = canvas->rootContext();
ctxt->setContextProperty("testModel", &model);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("pathview0.qml")));
+ canvas->setSource(testFileUrl("pathview0.qml"));
qApp->processEvents();
QQuickPathView *pathview = findItem<QQuickPathView>(canvas->rootObject(), "view");
void tst_QQuickPathView::pathview2()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("pathview2.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("pathview2.qml"));
QQuickPathView *obj = qobject_cast<QQuickPathView*>(c.create());
QVERIFY(obj != 0);
void tst_QQuickPathView::pathview3()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("pathview3.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("pathview3.qml"));
QQuickPathView *obj = qobject_cast<QQuickPathView*>(c.create());
QVERIFY(obj != 0);
QDeclarativeContext *ctxt = canvas->rootContext();
ctxt->setContextProperty("testModel", &model);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("pathview0.qml")));
+ canvas->setSource(testFileUrl("pathview0.qml"));
qApp->processEvents();
QQuickPathView *pathview = findItem<QQuickPathView>(canvas->rootObject(), "view");
QDeclarativeContext *ctxt = canvas->rootContext();
ctxt->setContextProperty("testModel", &model);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("pathview0.qml")));
+ canvas->setSource(testFileUrl("pathview0.qml"));
qApp->processEvents();
QQuickPathView *pathview = findItem<QQuickPathView>(canvas->rootObject(), "view");
QDeclarativeContext *ctxt = canvas->rootContext();
ctxt->setContextProperty("testModel", &model);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("pathview0.qml")));
+ canvas->setSource(testFileUrl("pathview0.qml"));
qApp->processEvents();
QQuickPathView *pathview = findItem<QQuickPathView>(canvas->rootObject(), "view");
void tst_QQuickPathView::path()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("pathtest.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("pathtest.qml"));
QDeclarativePath *obj = qobject_cast<QDeclarativePath*>(c.create());
QVERIFY(obj != 0);
ctxt->setContextProperty("testData", &model);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("datamodel.qml")));
+ canvas->setSource(testFileUrl("datamodel.qml"));
qApp->processEvents();
QQuickPathView *pathview = qobject_cast<QQuickPathView*>(canvas->rootObject());
QDeclarativeContext *ctxt = canvas->rootContext();
ctxt->setContextProperty("testModel", &model);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("pathview0.qml")));
+ canvas->setSource(testFileUrl("pathview0.qml"));
qApp->processEvents();
QQuickPathView *pathview = findItem<QQuickPathView>(canvas->rootObject(), "view");
QDeclarativeContext *ctxt = canvas->rootContext();
ctxt->setContextProperty("testModel", &model);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("pathview0.qml")));
+ canvas->setSource(testFileUrl("pathview0.qml"));
qApp->processEvents();
QQuickPathView *pathview = findItem<QQuickPathView>(canvas->rootObject(), "view");
QDeclarativeContext *ctxt = canvas->rootContext();
ctxt->setContextProperty("testModel", &model);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("displaypath.qml")));
+ canvas->setSource(testFileUrl("displaypath.qml"));
qApp->processEvents();
QQuickPathView *pathview = findItem<QQuickPathView>(canvas->rootObject(), "view");
{
QQuickView *canvas = createView();
QVERIFY(canvas);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("propertychanges.qml")));
+ canvas->setSource(testFileUrl("propertychanges.qml"));
QQuickPathView *pathView = canvas->rootObject()->findChild<QQuickPathView*>("pathView");
QVERIFY(pathView);
{
QQuickView *canvas = createView();
QVERIFY(canvas);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("propertychanges.qml")));
+ canvas->setSource(testFileUrl("propertychanges.qml"));
QQuickPathView *pathView = canvas->rootObject()->findChild<QQuickPathView*>("pathView");
QVERIFY(pathView);
{
QQuickView *canvas = createView();
QVERIFY(canvas);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("propertychanges.qml")));
+ canvas->setSource(testFileUrl("propertychanges.qml"));
QQuickPathView *pathView = canvas->rootObject()->findChild<QQuickPathView*>("pathView");
QVERIFY(pathView);
{
QQuickView *canvas = createView();
QVERIFY(canvas);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("propertychanges.qml")));
+ canvas->setSource(testFileUrl("propertychanges.qml"));
QQuickPathView *pathView = canvas->rootObject()->findChild<QQuickPathView*>("pathView");
QVERIFY(pathView);
{
QQuickView *canvas = createView();
QVERIFY(canvas);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("pathUpdateOnStartChanged.qml")));
+ canvas->setSource(testFileUrl("pathUpdateOnStartChanged.qml"));
QQuickPathView *pathView = canvas->rootObject()->findChild<QQuickPathView*>("pathView");
QVERIFY(pathView);
{
QQuickView *canvas = createView();
QVERIFY(canvas);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("pathview_package.qml")));
+ canvas->setSource(testFileUrl("pathview_package.qml"));
canvas->show();
QTest::qWaitForWindowShown(canvas);
QDeclarativeContext *ctxt = canvas->rootContext();
ctxt->setContextProperty("emptyModel", &model);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("emptymodel.qml")));
+ canvas->setSource(testFileUrl("emptymodel.qml"));
qApp->processEvents();
QQuickPathView *pathview = qobject_cast<QQuickPathView*>(canvas->rootObject());
QDeclarativeEngine engine;
{
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("openPath.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("openPath.qml"));
QDeclarativePath *obj = qobject_cast<QDeclarativePath*>(c.create());
QVERIFY(obj);
QCOMPARE(obj->isClosed(), false);
}
{
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("closedPath.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("closedPath.qml"));
QDeclarativePath *obj = qobject_cast<QDeclarativePath*>(c.create());
QVERIFY(obj);
QCOMPARE(obj->isClosed(), true);
{
QQuickView *canvas = createView();
QVERIFY(canvas);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("pathUpdate.qml")));
+ canvas->setSource(testFileUrl("pathUpdate.qml"));
QQuickPathView *pathView = canvas->rootObject()->findChild<QQuickPathView*>("pathView");
QVERIFY(pathView);
void tst_QQuickPathView::visualDataModel()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("vdm.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("vdm.qml"));
QQuickPathView *obj = qobject_cast<QQuickPathView*>(c.create());
QVERIFY(obj != 0);
QString warning2("QPainterPath::lineTo: Adding point where x or y is NaN or Inf, ignoring call");
QTest::ignoreMessage(QtWarningMsg,qPrintable(warning2));
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("undefinedpath.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("undefinedpath.qml"));
QQuickPathView *obj = qobject_cast<QQuickPathView*>(c.create());
QVERIFY(obj != 0);
void tst_QQuickPathView::mouseDrag()
{
QQuickView *canvas = createView();
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("dragpath.qml")));
+ canvas->setSource(testFileUrl("dragpath.qml"));
canvas->show();
canvas->requestActivateWindow();
QTest::qWaitForWindowShown(canvas);
initStandardTreeModel(&model);
canvas->engine()->rootContext()->setContextProperty("myModel", &model);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("treemodel.qml")));
+ canvas->setSource(testFileUrl("treemodel.qml"));
QQuickPathView *pathview = qobject_cast<QQuickPathView*>(canvas->rootObject());
QVERIFY(pathview != 0);
{
QQuickView *canvas = createView();
canvas->setGeometry(0,0,400,200);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("dragpath.qml")));
+ canvas->setSource(testFileUrl("dragpath.qml"));
canvas->show();
canvas->requestActivateWindow();
QTest::qWaitForWindowShown(canvas);
{
QQuickView canvas;
canvas.setGeometry(0,0,240,320);
- canvas.setSource(QUrl::fromLocalFile(TESTDATA("creationContext.qml")));
+ canvas.setSource(testFileUrl("creationContext.qml"));
QQuickItem *rootItem = qobject_cast<QQuickItem *>(canvas.rootObject());
QVERIFY(rootItem);
QDeclarativeContext *ctxt = canvas->rootContext();
ctxt->setContextProperty("testModel", &model);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("pathline.qml")));
+ canvas->setSource(testFileUrl("pathline.qml"));
qApp->processEvents();
QQuickPathView *pathview = findItem<QQuickPathView>(canvas->rootObject(), "view");
QDeclarativeIncubationController controller;
canvas->engine()->setIncubationController(&controller);
- canvas->setSource(TESTDATA("asyncloader.qml"));
+ canvas->setSource(testFileUrl("asyncloader.qml"));
QQuickItem *rootObject = qobject_cast<QQuickItem*>(canvas->rootObject());
QVERIFY(rootObject);
void tst_QQuickPathView::missingPercent()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("missingPercent.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("missingPercent.qml"));
QDeclarativePath *obj = qobject_cast<QDeclarativePath*>(c.create());
QVERIFY(obj);
QCOMPARE(obj->attributeAt("_qfx_percent", 1.0), qreal(1.0));
TARGET = tst_qquickpincharea
macx:CONFIG -= app_bundle
-SOURCES += tst_qquickpincharea.cpp
+SOURCES += tst_qquickpincharea.cpp \
+ ../../shared/util.cpp
+HEADERS += ../../shared/util.h
testDataFiles.files = data
testDataFiles.path = .
#include <QtDeclarative/qdeclarativecontext.h>
#include "../../shared/util.h"
-class tst_QQuickPinchArea: public QObject
+class tst_QQuickPinchArea: public QDeclarativeDataTest
{
Q_OBJECT
public:
};
void tst_QQuickPinchArea::initTestCase()
{
+ QDeclarativeDataTest::initTestCase();
if (!device) {
device = new QTouchDevice;
device->setType(QTouchDevice::TouchScreen);
void tst_QQuickPinchArea::pinchProperties()
{
QQuickView *canvas = createView();
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("pinchproperties.qml")));
+ canvas->setSource(testFileUrl("pinchproperties.qml"));
canvas->show();
canvas->requestActivateWindow();
QVERIFY(canvas->rootObject() != 0);
void tst_QQuickPinchArea::scale()
{
QQuickView *canvas = createView();
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("pinchproperties.qml")));
+ canvas->setSource(testFileUrl("pinchproperties.qml"));
canvas->show();
canvas->requestActivateWindow();
QTest::qWaitForWindowShown(canvas);
void tst_QQuickPinchArea::pan()
{
QQuickView *canvas = createView();
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("pinchproperties.qml")));
+ canvas->setSource(testFileUrl("pinchproperties.qml"));
canvas->show();
canvas->requestActivateWindow();
QTest::qWaitForWindowShown(canvas);
void tst_QQuickPinchArea::retouch()
{
QQuickView *canvas = createView();
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("pinchproperties.qml")));
+ canvas->setSource(testFileUrl("pinchproperties.qml"));
canvas->show();
canvas->requestActivateWindow();
QTest::qWaitForWindowShown(canvas);
CONFIG += testcase
TARGET = tst_qquickpositioners
-SOURCES += tst_qquickpositioners.cpp
+SOURCES += tst_qquickpositioners.cpp \
+ ../../shared/util.cpp
+HEADERS += ../../shared/util.h
+
macx:CONFIG -= app_bundle
testDataFiles.files = data
#include <qdeclarativeexpression.h>
#include "../../shared/util.h"
-class tst_qquickpositioners : public QObject
+class tst_qquickpositioners : public QDeclarativeDataTest
{
Q_OBJECT
public:
void tst_qquickpositioners::test_horizontal()
{
- QQuickView *canvas = createView(TESTDATA("horizontal.qml"));
+ QQuickView *canvas = createView(testFile("horizontal.qml"));
canvas->rootObject()->setProperty("testRightToLeft", false);
void tst_qquickpositioners::test_horizontal_rtl()
{
- QQuickView *canvas = createView(TESTDATA("horizontal.qml"));
+ QQuickView *canvas = createView(testFile("horizontal.qml"));
canvas->rootObject()->setProperty("testRightToLeft", true);
void tst_qquickpositioners::test_horizontal_spacing()
{
- QQuickView *canvas = createView(TESTDATA("horizontal-spacing.qml"));
+ QQuickView *canvas = createView(testFile("horizontal-spacing.qml"));
canvas->rootObject()->setProperty("testRightToLeft", false);
void tst_qquickpositioners::test_horizontal_spacing_rightToLeft()
{
- QQuickView *canvas = createView(TESTDATA("horizontal-spacing.qml"));
+ QQuickView *canvas = createView(testFile("horizontal-spacing.qml"));
canvas->rootObject()->setProperty("testRightToLeft", true);
void tst_qquickpositioners::test_horizontal_animated()
{
- QQuickView *canvas = createView(TESTDATA("horizontal-animated.qml"), false);
+ QQuickView *canvas = createView(testFile("horizontal-animated.qml"), false);
canvas->rootObject()->setProperty("testRightToLeft", false);
void tst_qquickpositioners::test_horizontal_animated_rightToLeft()
{
- QQuickView *canvas = createView(TESTDATA("horizontal-animated.qml"), false);
+ QQuickView *canvas = createView(testFile("horizontal-animated.qml"), false);
canvas->rootObject()->setProperty("testRightToLeft", true);
void tst_qquickpositioners::test_horizontal_animated_disabled()
{
- QQuickView *canvas = createView(TESTDATA("horizontal-animated-disabled.qml"));
+ QQuickView *canvas = createView(testFile("horizontal-animated-disabled.qml"));
QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
QVERIFY(one != 0);
void tst_qquickpositioners::test_vertical()
{
- QQuickView *canvas = createView(TESTDATA("vertical.qml"));
+ QQuickView *canvas = createView(testFile("vertical.qml"));
QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
QVERIFY(one != 0);
void tst_qquickpositioners::test_vertical_spacing()
{
- QQuickView *canvas = createView(TESTDATA("vertical-spacing.qml"));
+ QQuickView *canvas = createView(testFile("vertical-spacing.qml"));
QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
QVERIFY(one != 0);
void tst_qquickpositioners::test_vertical_animated()
{
- QQuickView *canvas = createView(TESTDATA("vertical-animated.qml"), false);
+ QQuickView *canvas = createView(testFile("vertical-animated.qml"), false);
//Note that they animate in
QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
void tst_qquickpositioners::test_grid()
{
- QQuickView *canvas = createView(TESTDATA("gridtest.qml"));
+ QQuickView *canvas = createView(testFile("gridtest.qml"));
QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
QVERIFY(one != 0);
void tst_qquickpositioners::test_grid_topToBottom()
{
- QQuickView *canvas = createView(TESTDATA("grid-toptobottom.qml"));
+ QQuickView *canvas = createView(testFile("grid-toptobottom.qml"));
QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
QVERIFY(one != 0);
void tst_qquickpositioners::test_grid_rightToLeft()
{
- QQuickView *canvas = createView(TESTDATA("gridtest.qml"));
+ QQuickView *canvas = createView(testFile("gridtest.qml"));
canvas->rootObject()->setProperty("testRightToLeft", true);
void tst_qquickpositioners::test_grid_spacing()
{
- QQuickView *canvas = createView(TESTDATA("grid-spacing.qml"));
+ QQuickView *canvas = createView(testFile("grid-spacing.qml"));
QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
QVERIFY(one != 0);
void tst_qquickpositioners::test_grid_row_column_spacing()
{
- QQuickView *canvas = createView(TESTDATA("grid-row-column-spacing.qml"));
+ QQuickView *canvas = createView(testFile("grid-row-column-spacing.qml"));
QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
QVERIFY(one != 0);
void tst_qquickpositioners::test_grid_animated()
{
- QQuickView *canvas = createView(TESTDATA("grid-animated.qml"), false);
+ QQuickView *canvas = createView(testFile("grid-animated.qml"), false);
canvas->rootObject()->setProperty("testRightToLeft", false);
void tst_qquickpositioners::test_grid_animated_rightToLeft()
{
- QQuickView *canvas = createView(TESTDATA("grid-animated.qml"), false);
+ QQuickView *canvas = createView(testFile("grid-animated.qml"), false);
canvas->rootObject()->setProperty("testRightToLeft", true);
void tst_qquickpositioners::test_grid_zero_columns()
{
- QQuickView *canvas = createView(TESTDATA("gridzerocolumns.qml"));
+ QQuickView *canvas = createView(testFile("gridzerocolumns.qml"));
QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
QVERIFY(one != 0);
void tst_qquickpositioners::test_propertychanges()
{
- QQuickView *canvas = createView(TESTDATA("propertychangestest.qml"));
+ QQuickView *canvas = createView(testFile("propertychangestest.qml"));
QQuickGrid *grid = qobject_cast<QQuickGrid*>(canvas->rootObject());
QVERIFY(grid != 0);
void tst_qquickpositioners::test_repeater()
{
- QQuickView *canvas = createView(TESTDATA("repeatertest.qml"));
+ QQuickView *canvas = createView(testFile("repeatertest.qml"));
QQuickRectangle *one = canvas->rootObject()->findChild<QQuickRectangle*>("one");
QVERIFY(one != 0);
void tst_qquickpositioners::test_flow()
{
- QQuickView *canvas = createView(TESTDATA("flowtest.qml"));
+ QQuickView *canvas = createView(testFile("flowtest.qml"));
canvas->rootObject()->setProperty("testRightToLeft", false);
void tst_qquickpositioners::test_flow_rightToLeft()
{
- QQuickView *canvas = createView(TESTDATA("flowtest.qml"));
+ QQuickView *canvas = createView(testFile("flowtest.qml"));
canvas->rootObject()->setProperty("testRightToLeft", true);
void tst_qquickpositioners::test_flow_topToBottom()
{
- QQuickView *canvas = createView(TESTDATA("flowtest-toptobottom.qml"));
+ QQuickView *canvas = createView(testFile("flowtest-toptobottom.qml"));
canvas->rootObject()->setProperty("testRightToLeft", false);
void tst_qquickpositioners::test_flow_resize()
{
- QQuickView *canvas = createView(TESTDATA("flowtest.qml"));
+ QQuickView *canvas = createView(testFile("flowtest.qml"));
QQuickItem *root = qobject_cast<QQuickItem*>(canvas->rootObject());
QVERIFY(root);
void tst_qquickpositioners::test_flow_resize_rightToLeft()
{
- QQuickView *canvas = createView(TESTDATA("flowtest.qml"));
+ QQuickView *canvas = createView(testFile("flowtest.qml"));
QQuickItem *root = qobject_cast<QQuickItem*>(canvas->rootObject());
QVERIFY(root);
void tst_qquickpositioners::test_flow_implicit_resize()
{
- QQuickView *canvas = createView(TESTDATA("flow-testimplicitsize.qml"));
+ QQuickView *canvas = createView(testFile("flow-testimplicitsize.qml"));
QVERIFY(canvas->rootObject() != 0);
QQuickFlow *flow = canvas->rootObject()->findChild<QQuickFlow*>("flow");
objectNames << "one" << "two" << "three" << "four" << "five";
foreach (const QString qmlFile, qmlFiles) {
- QQuickView *canvasA = createView(TESTDATA(qmlFile));
+ QQuickView *canvasA = createView(testFile(qmlFile));
QQuickItem *rootA = qobject_cast<QQuickItem*>(canvasA->rootObject());
- QQuickView *canvasB = createView(TESTDATA(qmlFile));
+ QQuickView *canvasB = createView(testFile(qmlFile));
QQuickItem *rootB = qobject_cast<QQuickItem*>(canvasB->rootObject());
rootA->setProperty("testRightToLeft", true); // layoutDirection: Qt.RightToLeft
void tst_qquickpositioners::test_allInvisible()
{
//QTBUG-19361
- QQuickView *canvas = createView(TESTDATA("allInvisible.qml"));
+ QQuickView *canvas = createView(testFile("allInvisible.qml"));
QQuickItem *root = qobject_cast<QQuickItem*>(canvas->rootObject());
QVERIFY(root);
{
QTest::addColumn<QString>("filename");
- QTest::newRow("column") << TESTDATA("attachedproperties-column.qml");
- QTest::newRow("row") << TESTDATA("attachedproperties-row.qml");
- QTest::newRow("grid") << TESTDATA("attachedproperties-grid.qml");
- QTest::newRow("flow") << TESTDATA("attachedproperties-flow.qml");
+ QTest::newRow("column") << testFile("attachedproperties-column.qml");
+ QTest::newRow("row") << testFile("attachedproperties-row.qml");
+ QTest::newRow("grid") << testFile("attachedproperties-grid.qml");
+ QTest::newRow("flow") << testFile("attachedproperties-flow.qml");
}
void tst_qquickpositioners::test_attachedproperties_dynamic()
{
- QQuickView *canvas = createView(TESTDATA("attachedproperties-dynamic.qml"));
+ QQuickView *canvas = createView(testFile("attachedproperties-dynamic.qml"));
QVERIFY(canvas->rootObject() != 0);
QQuickRow *row = canvas->rootObject()->findChild<QQuickRow *>("pos");
TARGET = tst_qquickrepeater
macx:CONFIG -= app_bundle
-SOURCES += tst_qquickrepeater.cpp
+SOURCES += tst_qquickrepeater.cpp \
+ ../../shared/util.cpp
+HEADERS += ../../shared/util.h
testFiles.files = data
testFiles.path = .
#include "../../shared/util.h"
-inline QUrl TEST_FILE(const QString &filename)
-{
- return QUrl::fromLocalFile(TESTDATA(filename));
-}
-
-class tst_QQuickRepeater : public QObject
+class tst_QQuickRepeater : public QDeclarativeDataTest
{
Q_OBJECT
public:
TestObject *testObject = new TestObject;
ctxt->setContextProperty("testObject", testObject);
- canvas->setSource(TEST_FILE("intmodel.qml"));
+ canvas->setSource(testFileUrl("intmodel.qml"));
qApp->processEvents();
QQuickRepeater *repeater = findItem<QQuickRepeater>(canvas->rootObject(), "repeater");
QDeclarativeContext *ctxt = canvas->rootContext();
ctxt->setContextProperty("testData", QVariant::fromValue(data));
- canvas->setSource(TEST_FILE("objlist.qml"));
+ canvas->setSource(testFileUrl("objlist.qml"));
qApp->processEvents();
QQuickRepeater *repeater = findItem<QQuickRepeater>(canvas->rootObject(), "repeater");
QDeclarativeContext *ctxt = canvas->rootContext();
ctxt->setContextProperty("testData", data);
- canvas->setSource(TEST_FILE("repeater1.qml"));
+ canvas->setSource(testFileUrl("repeater1.qml"));
qApp->processEvents();
QQuickRepeater *repeater = findItem<QQuickRepeater>(canvas->rootObject(), "repeater");
TestModel testModel;
ctxt->setContextProperty("testData", &testModel);
- canvas->setSource(TEST_FILE("repeater2.qml"));
+ canvas->setSource(testFileUrl("repeater2.qml"));
qApp->processEvents();
QQuickRepeater *repeater = findItem<QQuickRepeater>(canvas->rootObject(), "repeater");
testModel.addItem("five", "5");
ctxt->setContextProperty("testData", &testModel);
- canvas->setSource(TEST_FILE("repeater2.qml"));
+ canvas->setSource(testFileUrl("repeater2.qml"));
qApp->processEvents();
QQuickRepeater *repeater = findItem<QQuickRepeater>(canvas->rootObject(), "repeater");
testModel.addItem("three", "3");
ctxt->setContextProperty("testData", &testModel);
- canvas->setSource(TEST_FILE("repeater2.qml"));
+ canvas->setSource(testFileUrl("repeater2.qml"));
qApp->processEvents();
QQuickRepeater *repeater = findItem<QQuickRepeater>(canvas->rootObject(), "repeater");
TestObject *testObject = new TestObject;
ctxt->setContextProperty("testObject", testObject);
- canvas->setSource(TEST_FILE("itemlist.qml"));
+ canvas->setSource(testFileUrl("itemlist.qml"));
qApp->processEvents();
QQuickRepeater *repeater = findItem<QQuickRepeater>(canvas->rootObject(), "repeater");
QDeclarativeContext *ctxt = canvas->rootContext();
ctxt->setContextProperty("testData", dataA);
- canvas->setSource(TEST_FILE("repeater1.qml"));
+ canvas->setSource(testFileUrl("repeater1.qml"));
qApp->processEvents();
QQuickRepeater *repeater = findItem<QQuickRepeater>(canvas->rootObject(), "repeater");
QVERIFY(repeater != 0);
void tst_QQuickRepeater::modelChanged()
{
QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, TEST_FILE("modelChanged.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("modelChanged.qml"));
QQuickItem *rootObject = qobject_cast<QQuickItem*>(component.create());
QVERIFY(rootObject);
void tst_QQuickRepeater::properties()
{
QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, TEST_FILE("properties.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("properties.qml"));
QQuickItem *rootObject = qobject_cast<QQuickItem*>(component.create());
QVERIFY(rootObject);
QDeclarativeIncubationController controller;
canvas->engine()->setIncubationController(&controller);
- canvas->setSource(TEST_FILE("asyncloader.qml"));
+ canvas->setSource(testFileUrl("asyncloader.qml"));
QQuickItem *rootObject = qobject_cast<QQuickItem*>(canvas->rootObject());
QVERIFY(rootObject);
void tst_QQuickRepeater::initParent()
{
QDeclarativeEngine engine;
- QDeclarativeComponent component(&engine, TEST_FILE("initparent.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("initparent.qml"));
QQuickItem *rootObject = qobject_cast<QQuickItem*>(component.create());
QVERIFY(rootObject);
CONFIG += testcase
TARGET = tst_qquickscreen
-SOURCES += tst_qquickscreen.cpp
+SOURCES += tst_qquickscreen.cpp \
+ ../../shared/util.cpp
+HEADERS += ../../shared/util.h
macx:CONFIG -= app_bundle
#include <QtGui/QScreen>
#include "../../shared/util.h"
-class tst_qquickscreen : public QObject
+class tst_qquickscreen : public QDeclarativeDataTest
{
Q_OBJECT
-public:
- tst_qquickscreen ();
-
private slots:
- void initTestCase();
- void cleanupTestCase();
-
void basicProperties();
};
-tst_qquickscreen::tst_qquickscreen()
-{
-}
-
-void tst_qquickscreen::initTestCase()
-{
-}
-
-void tst_qquickscreen::cleanupTestCase()
-{
-}
-
void tst_qquickscreen::basicProperties()
{
QQuickView view;
- view.setSource(TESTDATA("screen.qml"));
+ view.setSource(testFileUrl("screen.qml"));
view.show();
QTest::qWaitForWindowShown(&view);
CONFIG += testcase
TARGET = tst_qquickspriteimage
-SOURCES += tst_qquickspriteimage.cpp
+SOURCES += tst_qquickspriteimage.cpp \
+ ../../shared/util.cpp
+HEADERS += ../../shared/util.h
+
macx:CONFIG -= app_bundle
testDataFiles.files = data
#include <QtQuick/qquickview.h>
#include <private/qquickspriteimage_p.h>
-class tst_qquickspriteimage : public QObject
+class tst_qquickspriteimage : public QDeclarativeDataTest
{
Q_OBJECT
public:
{
QQuickView *canvas = new QQuickView(0);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("basic.qml")));
+ canvas->setSource(testFileUrl("basic.qml"));
canvas->show();
QTest::qWaitForWindowShown(canvas);
SOURCES += tst_qquicktext.cpp
INCLUDEPATH += ../../shared/
-HEADERS += ../../shared/testhttpserver.h
-SOURCES += ../../shared/testhttpserver.cpp
+HEADERS += ../../shared/testhttpserver.h \
+ ../../shared/util.h
+SOURCES += ../../shared/testhttpserver.cpp \
+ ../../shared/util.cpp
testDataFiles.files = data
testDataFiles.path = .
DEFINE_BOOL_CONFIG_OPTION(qmlDisableDistanceField, QML_DISABLE_DISTANCEFIELD)
-class tst_qquicktext : public QObject
+class tst_qquicktext : public QDeclarativeDataTest
{
Q_OBJECT
public:
tst_qquicktext();
private slots:
- void initTestCase();
- void cleanupTestCase();
void text();
void width();
void wrap();
QQuickView *createView(const QString &filename);
};
-void tst_qquicktext::initTestCase()
-{
-}
-void tst_qquicktext::cleanupTestCase()
-{
-
-}
tst_qquicktext::tst_qquicktext()
{
standard << "the quick brown fox jumped over the lazy dog"
void tst_qquicktext::multilineElide()
{
- QQuickView *canvas = createView(TESTDATA("multilineelide.qml"));
+ QQuickView *canvas = createView(testFile("multilineelide.qml"));
QQuickText *myText = qobject_cast<QQuickText*>(canvas->rootObject());
QVERIFY(myText != 0);
QTest::addColumn<int>("vAlign");
QTest::addColumn<QString>("expectfile");
- QTest::newRow("LT") << int(Qt::AlignLeft) << int(Qt::AlignTop) << TESTDATA("alignments_lt.png");
- QTest::newRow("RT") << int(Qt::AlignRight) << int(Qt::AlignTop) << TESTDATA("alignments_rt.png");
- QTest::newRow("CT") << int(Qt::AlignHCenter) << int(Qt::AlignTop) << TESTDATA("alignments_ct.png");
+ QTest::newRow("LT") << int(Qt::AlignLeft) << int(Qt::AlignTop) << testFile("alignments_lt.png");
+ QTest::newRow("RT") << int(Qt::AlignRight) << int(Qt::AlignTop) << testFile("alignments_rt.png");
+ QTest::newRow("CT") << int(Qt::AlignHCenter) << int(Qt::AlignTop) << testFile("alignments_ct.png");
- QTest::newRow("LB") << int(Qt::AlignLeft) << int(Qt::AlignBottom) << TESTDATA("alignments_lb.png");
- QTest::newRow("RB") << int(Qt::AlignRight) << int(Qt::AlignBottom) << TESTDATA("alignments_rb.png");
- QTest::newRow("CB") << int(Qt::AlignHCenter) << int(Qt::AlignBottom) << TESTDATA("alignments_cb.png");
+ QTest::newRow("LB") << int(Qt::AlignLeft) << int(Qt::AlignBottom) << testFile("alignments_lb.png");
+ QTest::newRow("RB") << int(Qt::AlignRight) << int(Qt::AlignBottom) << testFile("alignments_rb.png");
+ QTest::newRow("CB") << int(Qt::AlignHCenter) << int(Qt::AlignBottom) << testFile("alignments_cb.png");
- QTest::newRow("LC") << int(Qt::AlignLeft) << int(Qt::AlignVCenter) << TESTDATA("alignments_lc.png");
- QTest::newRow("RC") << int(Qt::AlignRight) << int(Qt::AlignVCenter) << TESTDATA("alignments_rc.png");
- QTest::newRow("CC") << int(Qt::AlignHCenter) << int(Qt::AlignVCenter) << TESTDATA("alignments_cc.png");
+ QTest::newRow("LC") << int(Qt::AlignLeft) << int(Qt::AlignVCenter) << testFile("alignments_lc.png");
+ QTest::newRow("RC") << int(Qt::AlignRight) << int(Qt::AlignVCenter) << testFile("alignments_rc.png");
+ QTest::newRow("CC") << int(Qt::AlignHCenter) << int(Qt::AlignVCenter) << testFile("alignments_cc.png");
}
QFETCH(int, vAlign);
QFETCH(QString, expectfile);
- QQuickView *canvas = createView(TESTDATA("alignments.qml"));
+ QQuickView *canvas = createView(testFile("alignments.qml"));
canvas->show();
canvas->requestActivateWindow();
QTest::qWait(50);
void tst_qquicktext::horizontalAlignment_RightToLeft()
{
- QQuickView *canvas = createView(TESTDATA("horizontalAlignment_RightToLeft.qml"));
+ QQuickView *canvas = createView(testFile("horizontalAlignment_RightToLeft.qml"));
QQuickText *text = canvas->rootObject()->findChild<QQuickText*>("text");
QVERIFY(text != 0);
canvas->show();
{
QTest::addColumn<QUrl>("qmlfile");
QTest::addColumn<QString>("error");
- QTest::newRow("local") << QUrl::fromLocalFile(TESTDATA("embeddedImagesLocal.qml")) << "";
- QTest::newRow("local-error") << QUrl::fromLocalFile(TESTDATA("embeddedImagesLocalError.qml"))
- << QUrl::fromLocalFile(TESTDATA("embeddedImagesLocalError.qml")).toString()+":3:1: QML Text: Cannot open: " + QUrl::fromLocalFile(TESTDATA("http/notexists.png")).toString();
- QTest::newRow("remote") << QUrl::fromLocalFile(TESTDATA("embeddedImagesRemote.qml")) << "";
- QTest::newRow("remote-error") << QUrl::fromLocalFile(TESTDATA("embeddedImagesRemoteError.qml"))
- << QUrl::fromLocalFile(TESTDATA("embeddedImagesRemoteError.qml")).toString()+":3:1: QML Text: Error downloading http://127.0.0.1:14453/notexists.png - server replied: Not found";
+ QTest::newRow("local") << testFileUrl("embeddedImagesLocal.qml") << "";
+ QTest::newRow("local-error") << testFileUrl("embeddedImagesLocalError.qml")
+ << testFileUrl("embeddedImagesLocalError.qml").toString()+":3:1: QML Text: Cannot open: " + testFileUrl("http/notexists.png").toString();
+ QTest::newRow("remote") << testFileUrl("embeddedImagesRemote.qml") << "";
+ QTest::newRow("remote-error") << testFileUrl("embeddedImagesRemoteError.qml")
+ << testFileUrl("embeddedImagesRemoteError.qml").toString()+":3:1: QML Text: Error downloading http://127.0.0.1:14453/notexists.png - server replied: Not found";
}
void tst_qquicktext::embeddedImages()
QFETCH(QString, error);
TestHTTPServer server(14453);
- server.serveDirectory(TESTDATA("http"));
+ server.serveDirectory(testFile("http"));
if (!error.isEmpty())
QTest::ignoreMessage(QtWarningMsg, error.toLatin1());
QTRY_COMPARE(textObject->resourcesLoading(), 0);
- QPixmap pm(TESTDATA("http/exists.png"));
+ QPixmap pm(testFile("http/exists.png"));
if (error.isEmpty()) {
QCOMPARE(textObject->width(), double(pm.width()));
QCOMPARE(textObject->height(), double(pm.height()));
void tst_qquicktext::lineCount()
{
- QQuickView *canvas = createView(TESTDATA("lineCount.qml"));
+ QQuickView *canvas = createView(testFile("lineCount.qml"));
QQuickText *myText = canvas->rootObject()->findChild<QQuickText*>("myText");
QVERIFY(myText != 0);
void tst_qquicktext::lineHeight()
{
- QQuickView *canvas = createView(TESTDATA("lineHeight.qml"));
+ QQuickView *canvas = createView(testFile("lineHeight.qml"));
QQuickText *myText = canvas->rootObject()->findChild<QQuickText*>("myText");
QVERIFY(myText != 0);
void tst_qquicktext::lineLaidOut()
{
- QQuickView *canvas = createView(TESTDATA("lineLayout.qml"));
+ QQuickView *canvas = createView(testFile("lineLayout.qml"));
QQuickText *myText = canvas->rootObject()->findChild<QQuickText*>("myText");
QVERIFY(myText != 0);
TARGET = tst_qquicktextedit
macx:CONFIG -= app_bundle
-SOURCES += tst_qquicktextedit.cpp ../../shared/testhttpserver.cpp
-HEADERS += ../../shared/testhttpserver.h
+SOURCES += tst_qquicktextedit.cpp \
+ ../../shared/testhttpserver.cpp \
+ ../../shared/util.cpp
+
+HEADERS += ../../shared/testhttpserver.h \
+ ../../shared/util.h
testDataFiles.files = data
testDataFiles.path = .
QString createExpectedFileIfNotFound(const QString& filebasename, const QImage& actual)
{
// XXX This will be replaced by some clever persistent platform image store.
- QString persistent_dir = TESTDATA("");
+ QString persistent_dir = QDeclarativeDataTest::instance()->dataDirectory();
QString arch = "unknown-architecture"; // QTest needs to help with this.
QString expectfile = persistent_dir + QDir::separator() + filebasename + "-" + arch + ".png";
typedef QPair<int, QChar> Key;
-class tst_qquicktextedit : public QObject
+class tst_qquicktextedit : public QDeclarativeDataTest
{
Q_OBJECT
tst_qquicktextedit();
private slots:
- void initTestCase();
- void cleanupTestCase();
void text();
void width();
void wrap();
return keys;
}
-
-void tst_qquicktextedit::initTestCase()
-{
-}
-
-void tst_qquicktextedit::cleanupTestCase()
-{
-
-}
tst_qquicktextedit::tst_qquicktextedit()
{
standard << "the quick brown fox jumped over the lazy dog"
QFETCH(int, vAlign);
QFETCH(QString, expectfile);
- QQuickView canvas(QUrl::fromLocalFile(TESTDATA("alignments.qml")));
+ QQuickView canvas(testFileUrl("alignments.qml"));
canvas.show();
canvas.requestActivateWindow();
void tst_qquicktextedit::hAlign_RightToLeft()
{
- QQuickView canvas(QUrl::fromLocalFile(TESTDATA("horizontalAlignment_RightToLeft.qml")));
+ QQuickView canvas(testFileUrl("horizontalAlignment_RightToLeft.qml"));
QQuickTextEdit *textEdit = canvas.rootObject()->findChild<QQuickTextEdit*>("text");
QVERIFY(textEdit != 0);
canvas.show();
void tst_qquicktextedit::keySelection()
{
- QQuickView canvas(QUrl::fromLocalFile(TESTDATA("navigation.qml")));
+ QQuickView canvas(testFileUrl("navigation.qml"));
canvas.show();
canvas.requestActivateWindow();
QTest::qWaitForWindowShown(&canvas);
QTest::addColumn<QString>("selectedText");
// import installed
- QTest::newRow("on") << TESTDATA("mouseselection_true.qml") << 4 << 9 << "45678";
- QTest::newRow("off") << TESTDATA("mouseselection_false.qml") << 4 << 9 << QString();
- QTest::newRow("default") << TESTDATA("mouseselection_default.qml") << 4 << 9 << QString();
- QTest::newRow("off word selection") << TESTDATA("mouseselection_false_words.qml") << 4 << 9 << QString();
- QTest::newRow("on word selection (4,9)") << TESTDATA("mouseselection_true_words.qml") << 4 << 9 << "0123456789";
- QTest::newRow("on word selection (2,13)") << TESTDATA("mouseselection_true_words.qml") << 2 << 13 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- QTest::newRow("on word selection (2,30)") << TESTDATA("mouseselection_true_words.qml") << 2 << 30 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- QTest::newRow("on word selection (9,13)") << TESTDATA("mouseselection_true_words.qml") << 9 << 13 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- QTest::newRow("on word selection (9,30)") << TESTDATA("mouseselection_true_words.qml") << 9 << 30 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- QTest::newRow("on word selection (13,2)") << TESTDATA("mouseselection_true_words.qml") << 13 << 2 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- QTest::newRow("on word selection (20,2)") << TESTDATA("mouseselection_true_words.qml") << 20 << 2 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- QTest::newRow("on word selection (12,9)") << TESTDATA("mouseselection_true_words.qml") << 12 << 9 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- QTest::newRow("on word selection (30,9)") << TESTDATA("mouseselection_true_words.qml") << 30 << 9 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ QTest::newRow("on") << testFile("mouseselection_true.qml") << 4 << 9 << "45678";
+ QTest::newRow("off") << testFile("mouseselection_false.qml") << 4 << 9 << QString();
+ QTest::newRow("default") << testFile("mouseselection_default.qml") << 4 << 9 << QString();
+ QTest::newRow("off word selection") << testFile("mouseselection_false_words.qml") << 4 << 9 << QString();
+ QTest::newRow("on word selection (4,9)") << testFile("mouseselection_true_words.qml") << 4 << 9 << "0123456789";
+ QTest::newRow("on word selection (2,13)") << testFile("mouseselection_true_words.qml") << 2 << 13 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ QTest::newRow("on word selection (2,30)") << testFile("mouseselection_true_words.qml") << 2 << 30 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ QTest::newRow("on word selection (9,13)") << testFile("mouseselection_true_words.qml") << 9 << 13 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ QTest::newRow("on word selection (9,30)") << testFile("mouseselection_true_words.qml") << 9 << 30 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ QTest::newRow("on word selection (13,2)") << testFile("mouseselection_true_words.qml") << 13 << 2 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ QTest::newRow("on word selection (20,2)") << testFile("mouseselection_true_words.qml") << 20 << 2 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ QTest::newRow("on word selection (12,9)") << testFile("mouseselection_true_words.qml") << 12 << 9 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ QTest::newRow("on word selection (30,9)") << testFile("mouseselection_true_words.qml") << 30 << 9 << "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
}
void tst_qquicktextedit::mouseSelection()
void tst_qquicktextedit::dragMouseSelection()
{
- QString qmlfile = TESTDATA("mouseselection_true.qml");
+ QString qmlfile = testFile("mouseselection_true.qml");
QQuickView canvas(QUrl::fromLocalFile(qmlfile));
QTest::addColumn<bool>("selectWords");
// import installed
- QTest::newRow("SelectWords") << TESTDATA("mouseselectionmode_words.qml") << true;
- QTest::newRow("SelectCharacters") << TESTDATA("mouseselectionmode_characters.qml") << false;
- QTest::newRow("default") << TESTDATA("mouseselectionmode_default.qml") << false;
+ QTest::newRow("SelectWords") << testFile("mouseselectionmode_words.qml") << true;
+ QTest::newRow("SelectCharacters") << testFile("mouseselectionmode_characters.qml") << false;
+ QTest::newRow("default") << testFile("mouseselectionmode_default.qml") << false;
}
void tst_qquicktextedit::mouseSelectionMode()
void tst_qquicktextedit::inputMethodHints()
{
- QQuickView canvas(QUrl::fromLocalFile(TESTDATA("inputmethodhints.qml")));
+ QQuickView canvas(testFileUrl("inputmethodhints.qml"));
canvas.show();
canvas.requestActivateWindow();
void tst_qquicktextedit::positionAt()
{
- QQuickView canvas(QUrl::fromLocalFile(TESTDATA("positionAt.qml")));
+ QQuickView canvas(testFileUrl("positionAt.qml"));
QVERIFY(canvas.rootObject() != 0);
canvas.show();
canvas.requestActivateWindow();
void tst_qquicktextedit::linkActivated()
{
- QQuickView canvas(QUrl::fromLocalFile(TESTDATA("linkActivated.qml")));
+ QQuickView canvas(testFileUrl("linkActivated.qml"));
QVERIFY(canvas.rootObject() != 0);
canvas.show();
canvas.requestActivateWindow();
void tst_qquicktextedit::cursorDelegate()
{
- QQuickView view(QUrl::fromLocalFile(TESTDATA("cursorTest.qml")));
+ QQuickView view(testFileUrl("cursorTest.qml"));
view.show();
view.requestActivateWindow();
QQuickTextEdit *textEditObject = view.rootObject()->findChild<QQuickTextEdit*>("textEditObject");
void tst_qquicktextedit::cursorVisible()
{
- QQuickView view(QUrl::fromLocalFile(TESTDATA("cursorVisible.qml")));
+ QQuickView view(testFileUrl("cursorVisible.qml"));
view.show();
view.requestActivateWindow();
QTest::qWaitForWindowShown(&view);
QFETCH(QString, error);
TestHTTPServer server(42332);
- server.serveDirectory(TESTDATA("httpfail"), TestHTTPServer::Disconnect);
- server.serveDirectory(TESTDATA("httpslow"), TestHTTPServer::Delay);
- server.serveDirectory(TESTDATA("http"));
+ server.serveDirectory(testFile("httpfail"), TestHTTPServer::Disconnect);
+ server.serveDirectory(testFile("httpslow"), TestHTTPServer::Delay);
+ server.serveDirectory(testFile("http"));
QQuickView view(QUrl(QLatin1String("http://localhost:42332/") + qmlfile));
view.show();
*/
void tst_qquicktextedit::navigation()
{
- QQuickView canvas(QUrl::fromLocalFile(TESTDATA("navigation.qml")));
+ QQuickView canvas(testFileUrl("navigation.qml"));
canvas.show();
canvas.requestActivateWindow();
void tst_qquicktextedit::readOnly()
{
- QQuickView canvas(QUrl::fromLocalFile(TESTDATA("readOnly.qml")));
+ QQuickView canvas(testFileUrl("readOnly.qml"));
canvas.show();
canvas.requestActivateWindow();
void tst_qquicktextedit::textInput()
{
- QQuickView view(QUrl::fromLocalFile(TESTDATA("inputMethodEvent.qml")));
+ QQuickView view(testFileUrl("inputMethodEvent.qml"));
view.show();
view.requestActivateWindow();
QTest::qWaitForWindowShown(&view);
QInputPanelPrivate *inputPanelPrivate = QInputPanelPrivate::get(qApp->inputPanel());
inputPanelPrivate->testContext = &platformInputContext;
- QQuickView view(QUrl::fromLocalFile(TESTDATA("openInputPanel.qml")));
+ QQuickView view(testFileUrl("openInputPanel.qml"));
view.show();
view.requestActivateWindow();
QTest::qWaitForWindowShown(&view);
void tst_qquicktextedit::geometrySignals()
{
- QDeclarativeComponent component(&engine, TESTDATA("geometrySignals.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("geometrySignals.qml"));
QObject *o = component.create();
QVERIFY(o);
QCOMPARE(o->property("bindingWidth").toInt(), 400);
{
QString preeditText = "super";
- QQuickView view(QUrl::fromLocalFile(TESTDATA("inputMethodEvent.qml")));
+ QQuickView view(testFileUrl("inputMethodEvent.qml"));
view.show();
view.requestActivateWindow();
QTest::qWaitForWindowShown(&view);
{
QString text = "supercalifragisiticexpialidocious!";
- QQuickView view(QUrl::fromLocalFile(TESTDATA("inputContext.qml")));
+ QQuickView view(testFileUrl("inputContext.qml"));
view.show();
view.requestActivateWindow();
QTest::qWaitForWindowShown(&view);
void tst_qquicktextedit::cursorRectangleSize()
{
- QQuickView *canvas = new QQuickView(QUrl::fromLocalFile(TESTDATA("positionAt.qml")));
+ QQuickView *canvas = new QQuickView(testFileUrl("positionAt.qml"));
QVERIFY(canvas->rootObject() != 0);
QQuickTextEdit *textEdit = qobject_cast<QQuickTextEdit *>(canvas->rootObject());
void tst_qquicktextedit::emptytags_QTBUG_22058()
{
- QQuickView canvas(QUrl::fromLocalFile(TESTDATA("qtbug-22058.qml")));
+ QQuickView canvas(testFileUrl("qtbug-22058.qml"));
QVERIFY(canvas.rootObject() != 0);
canvas.show();
TARGET = tst_qquicktextinput
macx:CONFIG -= app_bundle
-SOURCES += tst_qquicktextinput.cpp
+SOURCES += tst_qquicktextinput.cpp \
+ ../../shared/util.cpp
+HEADERS += ../../shared/util.h
testDataFiles.files = data
testDataFiles.path = .
QString createExpectedFileIfNotFound(const QString& filebasename, const QImage& actual)
{
// XXX This will be replaced by some clever persistent platform image store.
- QString persistent_dir = TESTDATA("");
+ QString persistent_dir = QDeclarativeDataTest::instance()->dataDirectory();
QString arch = "unknown-architecture"; // QTest needs to help with this.
QString expectfile = persistent_dir + QDir::separator() + filebasename + "-" + arch + ".png";
typedef QPair<int, QChar> Key;
-class tst_qquicktextinput : public QObject
+class tst_qquicktextinput : public QDeclarativeDataTest
{
Q_OBJECT
tst_qquicktextinput();
private slots:
- void initTestCase();
- void cleanupTestCase();
void cleanup();
void text();
void width();
return keys;
}
-void tst_qquicktextinput::initTestCase()
-{
-}
-
-void tst_qquicktextinput::cleanupTestCase()
-{
-}
-
void tst_qquicktextinput::cleanup()
{
// ensure not even skipped tests with custom input context leave it dangling
void tst_qquicktextinput::dragMouseSelection()
{
- QString qmlfile = TESTDATA("mouseselection_true.qml");
+ QString qmlfile = testFile("mouseselection_true.qml");
QQuickView canvas(QUrl::fromLocalFile(qmlfile));
QTest::addColumn<bool>("selectWords");
// import installed
- QTest::newRow("SelectWords") << TESTDATA("mouseselectionmode_words.qml") << true;
- QTest::newRow("SelectCharacters") << TESTDATA("mouseselectionmode_characters.qml") << false;
- QTest::newRow("default") << TESTDATA("mouseselectionmode_default.qml") << false;
+ QTest::newRow("SelectWords") << testFile("mouseselectionmode_words.qml") << true;
+ QTest::newRow("SelectCharacters") << testFile("mouseselectionmode_characters.qml") << false;
+ QTest::newRow("default") << testFile("mouseselectionmode_default.qml") << false;
}
void tst_qquicktextinput::mouseSelectionMode()
QFETCH(int, hAlign);
QFETCH(QString, expectfile);
- QQuickView canvas(QUrl::fromLocalFile(TESTDATA("horizontalAlignment.qml")));
+ QQuickView canvas(testFileUrl("horizontalAlignment.qml"));
canvas.show();
canvas.requestActivateWindow();
void tst_qquicktextinput::horizontalAlignment_RightToLeft()
{
- QQuickView canvas(QUrl::fromLocalFile(TESTDATA("horizontalAlignment_RightToLeft.qml")));
+ QQuickView canvas(testFileUrl("horizontalAlignment_RightToLeft.qml"));
QQuickTextInput *textInput = canvas.rootObject()->findChild<QQuickTextInput*>("text");
QVERIFY(textInput != 0);
canvas.show();
void tst_qquicktextinput::verticalAlignment()
{
- QQuickView canvas(QUrl::fromLocalFile(TESTDATA("horizontalAlignment.qml")));
+ QQuickView canvas(testFileUrl("horizontalAlignment.qml"));
QQuickTextInput *textInput = canvas.rootObject()->findChild<QQuickTextInput*>("text");
QVERIFY(textInput != 0);
canvas.show();
void tst_qquicktextinput::positionAt()
{
- QQuickView canvas(QUrl::fromLocalFile(TESTDATA("positionAt.qml")));
+ QQuickView canvas(testFileUrl("positionAt.qml"));
QVERIFY(canvas.rootObject() != 0);
canvas.show();
canvas.requestActivateWindow();
void tst_qquicktextinput::maxLength()
{
- QQuickView canvas(QUrl::fromLocalFile(TESTDATA("maxLength.qml")));
+ QQuickView canvas(testFileUrl("maxLength.qml"));
QVERIFY(canvas.rootObject() != 0);
canvas.show();
canvas.requestActivateWindow();
{
//Not a comprehensive test of the possible masks, that's done elsewhere (QLineEdit)
//QString componentStr = "import QtQuick 2.0\nTextInput { inputMask: 'HHHHhhhh'; }";
- QQuickView canvas(QUrl::fromLocalFile(TESTDATA("masks.qml")));
+ QQuickView canvas(testFileUrl("masks.qml"));
canvas.show();
canvas.requestActivateWindow();
QVERIFY(canvas.rootObject() != 0);
// so you may need to run their tests first. All validators are checked
// here to ensure that their exposure to QML is working.
- QQuickView canvas(QUrl::fromLocalFile(TESTDATA("validators.qml")));
+ QQuickView canvas(testFileUrl("validators.qml"));
canvas.show();
canvas.requestActivateWindow();
void tst_qquicktextinput::inputMethods()
{
- QQuickView canvas(QUrl::fromLocalFile(TESTDATA("inputmethods.qml")));
+ QQuickView canvas(testFileUrl("inputmethods.qml"));
canvas.show();
canvas.requestActivateWindow();
QTest::qWaitForWindowShown(&canvas);
*/
void tst_qquicktextinput::navigation()
{
- QQuickView canvas(QUrl::fromLocalFile(TESTDATA("navigation.qml")));
+ QQuickView canvas(testFileUrl("navigation.qml"));
canvas.show();
canvas.requestActivateWindow();
void tst_qquicktextinput::navigation_RTL()
{
- QQuickView canvas(QUrl::fromLocalFile(TESTDATA("navigation.qml")));
+ QQuickView canvas(testFileUrl("navigation.qml"));
canvas.show();
canvas.requestActivateWindow();
void tst_qquicktextinput::cursorDelegate()
{
- QQuickView view(QUrl::fromLocalFile(TESTDATA("cursorTest.qml")));
+ QQuickView view(testFileUrl("cursorTest.qml"));
view.show();
view.requestActivateWindow();
QQuickTextInput *textInputObject = view.rootObject()->findChild<QQuickTextInput*>("textInputObject");
void tst_qquicktextinput::cursorVisible()
{
- QQuickView view(QUrl::fromLocalFile(TESTDATA("cursorVisible.qml")));
+ QQuickView view(testFileUrl("cursorVisible.qml"));
view.show();
view.requestActivateWindow();
QTest::qWaitForWindowShown(&view);
void tst_qquicktextinput::readOnly()
{
- QQuickView canvas(QUrl::fromLocalFile(TESTDATA("readOnly.qml")));
+ QQuickView canvas(testFileUrl("readOnly.qml"));
canvas.show();
canvas.requestActivateWindow();
void tst_qquicktextinput::echoMode()
{
- QQuickView canvas(QUrl::fromLocalFile(TESTDATA("echoMode.qml")));
+ QQuickView canvas(testFileUrl("echoMode.qml"));
canvas.show();
canvas.requestActivateWindow();
QTest::qWaitForWindowShown(&canvas);
#ifdef QT_GUI_PASSWORD_ECHO_DELAY
void tst_qquicktextinput::passwordEchoDelay()
{
- QQuickView canvas(QUrl::fromLocalFile(TESTDATA("echoMode.qml")));
+ QQuickView canvas(testFileUrl("echoMode.qml"));
canvas.show();
canvas.requestActivateWindow();
QTest::qWaitForWindowShown(&canvas);
QInputPanelPrivate *inputPanelPrivate = QInputPanelPrivate::get(qApp->inputPanel());
inputPanelPrivate->testContext = &platformInputContext;
- QQuickView view(QUrl::fromLocalFile(TESTDATA("openInputPanel.qml")));
+ QQuickView view(testFileUrl("openInputPanel.qml"));
view.show();
view.requestActivateWindow();
QTest::qWaitForWindowShown(&view);
void tst_qquicktextinput::geometrySignals()
{
- QDeclarativeComponent component(&engine, TESTDATA("geometrySignals.qml"));
+ QDeclarativeComponent component(&engine, testFileUrl("geometrySignals.qml"));
QObject *o = component.create();
QVERIFY(o);
QCOMPARE(o->property("bindingWidth").toInt(), 400);
{
QString preeditText = "califragisiticexpialidocious!";
- QQuickView view(QUrl::fromLocalFile(TESTDATA("preeditAutoScroll.qml")));
+ QQuickView view(testFileUrl("preeditAutoScroll.qml"));
view.show();
view.requestActivateWindow();
QTest::qWaitForWindowShown(&view);
{
QString preeditText = "super";
- QQuickView view(QUrl::fromLocalFile(TESTDATA("inputMethodEvent.qml")));
+ QQuickView view(testFileUrl("inputMethodEvent.qml"));
view.show();
view.requestActivateWindow();
QTest::qWaitForWindowShown(&view);
inputPanelPrivate->testContext = &platformInputContext;
QString text = "supercalifragisiticexpialidocious!";
- QQuickView view(QUrl::fromLocalFile(TESTDATA("inputContext.qml")));
+ QQuickView view(testFileUrl("inputContext.qml"));
QQuickTextInput *input = qobject_cast<QQuickTextInput *>(view.rootObject());
QVERIFY(input);
{
QString text = "supercalifragisiticexpialidocious!";
- QQuickView view(QUrl::fromLocalFile(TESTDATA("inputContext.qml")));
+ QQuickView view(testFileUrl("inputContext.qml"));
view.show();
view.requestActivateWindow();
QTest::qWaitForWindowShown(&view);
void tst_qquicktextinput::cursorRectangleSize()
{
- QQuickView *canvas = new QQuickView(QUrl::fromLocalFile(TESTDATA("positionAt.qml")));
+ QQuickView *canvas = new QQuickView(testFileUrl("positionAt.qml"));
QVERIFY(canvas->rootObject() != 0);
QQuickTextInput *textInput = qobject_cast<QQuickTextInput *>(canvas->rootObject());
void tst_qquicktextinput::tripleClickSelectsAll()
{
- QString qmlfile = TESTDATA("positionAt.qml");
+ QString qmlfile = testFile("positionAt.qml");
QQuickView view(QUrl::fromLocalFile(qmlfile));
view.show();
view.requestActivateWindow();
{
QFETCH(QString, url);
- QQuickView canvas(QUrl::fromLocalFile(TESTDATA(url)));
+ QQuickView canvas(testFileUrl(url));
canvas.show();
canvas.requestActivateWindow();
QTest::qWaitForWindowShown(&canvas);
void tst_qquicktextinput::QTBUG_19956_regexp()
{
- QUrl url = QUrl::fromLocalFile(TESTDATA("qtbug-19956regexp.qml"));
+ QUrl url = testFileUrl("qtbug-19956regexp.qml");
QString warning = url.toString() + ":11: Unable to assign [undefined] to QRegExp";
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
TARGET = tst_qquickview
macx:CONFIG -= app_bundle
-SOURCES += tst_qquickview.cpp
+SOURCES += tst_qquickview.cpp \
+ ../../shared/util.cpp
+HEADERS += ../../shared/util.h
testDataFiles.files = data
testDataFiles.path = .
#include <QtGui/QWindow>
#include <QtCore/QDebug>
-class tst_QQuickView : public QObject
+class tst_QQuickView : public QDeclarativeDataTest
{
Q_OBJECT
public:
QVERIFY(canvas);
canvas->setResizeMode(QQuickView::SizeRootObjectToView);
QCOMPARE(QSize(0,0), canvas->initialSize());
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("resizemodeitem.qml")));
+ canvas->setSource(testFileUrl("resizemodeitem.qml"));
QQuickItem* item = qobject_cast<QQuickItem*>(canvas->rootObject());
QVERIFY(item);
window.show();
canvas = new QQuickView(&window);
QVERIFY(canvas);
canvas->setResizeMode(QQuickView::SizeViewToRootObject);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("resizemodeitem.qml")));
+ canvas->setSource(testFileUrl("resizemodeitem.qml"));
item = qobject_cast<QQuickItem*>(canvas->rootObject());
QVERIFY(item);
window.show();
canvas->resize(300, 300);
canvas->setResizeMode(QQuickView::SizeRootObjectToView);
QCOMPARE(QSize(0,0), canvas->initialSize());
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("resizemodeitem.qml")));
+ canvas->setSource(testFileUrl("resizemodeitem.qml"));
canvas->resize(300, 300);
item = qobject_cast<QQuickItem*>(canvas->rootObject());
QVERIFY(item);
QQuickView *canvas = new QQuickView;
QVERIFY(canvas);
QtMsgHandler old = qInstallMsgHandler(silentErrorsMsgHandler);
- canvas->setSource(QUrl::fromLocalFile(TESTDATA("error1.qml")));
+ canvas->setSource(testFileUrl("error1.qml"));
qInstallMsgHandler(old);
QVERIFY(canvas->status() == QQuickView::Error);
QVERIFY(canvas->errors().count() == 1);
TARGET = tst_qquickvisualdatamodel
macx:CONFIG -= app_bundle
-SOURCES += tst_qquickvisualdatamodel.cpp
+SOURCES += tst_qquickvisualdatamodel.cpp \
+ ../../shared/util.cpp
+HEADERS += ../../shared/util.h
testDataFiles.files = data
testDataFiles.path = .
};
-class tst_qquickvisualdatamodel : public QObject
+class tst_qquickvisualdatamodel : public QDeclarativeDataTest
{
Q_OBJECT
public:
void tst_qquickvisualdatamodel::initTestCase()
{
+ QDeclarativeDataTest::initTestCase();
qRegisterMetaType<QDeclarativeChangeSet>();
}
void tst_qquickvisualdatamodel::rootIndex()
{
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("visualdatamodel.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("visualdatamodel.qml"));
QStandardItemModel model;
initStandardTreeModel(&model);
{
QTest::addColumn<QUrl>("source");
- QTest::newRow("item delegate") << QUrl::fromLocalFile(TESTDATA("datalist.qml"));
- QTest::newRow("package delegate") << QUrl::fromLocalFile(TESTDATA("datalist-package.qml"));
+ QTest::newRow("item delegate") << testFileUrl("datalist.qml");
+ QTest::newRow("package delegate") << testFileUrl("datalist-package.qml");
}
void tst_qquickvisualdatamodel::updateLayout()
{
QTest::addColumn<QUrl>("source");
- QTest::newRow("item delegate") << QUrl::fromLocalFile(TESTDATA("datalist.qml"));
- QTest::newRow("package delegate") << QUrl::fromLocalFile(TESTDATA("datalist-package.qml"));
+ QTest::newRow("item delegate") << testFileUrl("datalist.qml");
+ QTest::newRow("package delegate") << testFileUrl("datalist-package.qml");
}
void tst_qquickvisualdatamodel::childChanged()
QDeclarativeContext *ctxt = view.rootContext();
ctxt->setContextProperty("myModel", QVariant::fromValue(dataList));
- view.setSource(QUrl::fromLocalFile(TESTDATA("objectlist.qml")));
+ view.setSource(testFileUrl("objectlist.qml"));
QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
QVERIFY(listview != 0);
QDeclarativeContext *ctxt = view.rootContext();
ctxt->setContextProperty("myModel", &model);
- view.setSource(QUrl::fromLocalFile(TESTDATA("singlerole1.qml")));
+ view.setSource(testFileUrl("singlerole1.qml"));
QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
QVERIFY(listview != 0);
QDeclarativeContext *ctxt = view.rootContext();
ctxt->setContextProperty("myModel", &model);
- view.setSource(QUrl::fromLocalFile(TESTDATA("singlerole2.qml")));
+ view.setSource(testFileUrl("singlerole2.qml"));
QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
QVERIFY(listview != 0);
QDeclarativeContext *ctxt = view.rootContext();
ctxt->setContextProperty("myModel", &model);
- view.setSource(QUrl::fromLocalFile(TESTDATA("singlerole2.qml")));
+ view.setSource(testFileUrl("singlerole2.qml"));
QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
QVERIFY(listview != 0);
QDeclarativeContext *ctxt = view.rootContext();
ctxt->setContextProperty("myModel", &model);
- view.setSource(QUrl::fromLocalFile(TESTDATA("modelproperties.qml")));
+ view.setSource(testFileUrl("modelproperties.qml"));
QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
QVERIFY(listview != 0);
QDeclarativeContext *ctxt = view.rootContext();
ctxt->setContextProperty("myModel", QVariant::fromValue(dataList));
- view.setSource(QUrl::fromLocalFile(TESTDATA("modelproperties.qml")));
+ view.setSource(testFileUrl("modelproperties.qml"));
QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
QVERIFY(listview != 0);
view.rootContext()->setContextProperty("myModel", &model);
- QUrl source(QUrl::fromLocalFile(TESTDATA("modelproperties2.qml")));
+ QUrl source(testFileUrl("modelproperties2.qml"));
//3 items, 3 i each
QTest::ignoreMessage(QtWarningMsg, source.toString().toLatin1() + ":13: ReferenceError: Can't find variable: modelData");
{
QTest::addColumn<QUrl>("source");
- QTest::newRow("item delegate") << QUrl::fromLocalFile(TESTDATA("datalist.qml"));
- QTest::newRow("package delegate") << QUrl::fromLocalFile(TESTDATA("datalist-package.qml"));
+ QTest::newRow("item delegate") << testFileUrl("datalist.qml");
+ QTest::newRow("package delegate") << testFileUrl("datalist-package.qml");
}
void tst_qquickvisualdatamodel::noDelegate()
{
QTest::addColumn<QUrl>("source");
- QTest::newRow("listView") << QUrl::fromLocalFile(TESTDATA("itemsDestroyed_listView.qml"));
- QTest::newRow("package") << QUrl::fromLocalFile(TESTDATA("itemsDestroyed_package.qml"));
- QTest::newRow("pathView") << QUrl::fromLocalFile(TESTDATA("itemsDestroyed_pathView.qml"));
- QTest::newRow("repeater") << QUrl::fromLocalFile(TESTDATA("itemsDestroyed_repeater.qml"));
+ QTest::newRow("listView") << testFileUrl("itemsDestroyed_listView.qml");
+ QTest::newRow("package") << testFileUrl("itemsDestroyed_package.qml");
+ QTest::newRow("pathView") << testFileUrl("itemsDestroyed_pathView.qml");
+ QTest::newRow("repeater") << testFileUrl("itemsDestroyed_repeater.qml");
}
void tst_qquickvisualdatamodel::itemsDestroyed()
QQuickView view;
view.rootContext()->setContextProperty("testModel", &model);
- QString filename(TESTDATA("packageView.qml"));
+ QString filename(testFile("packageView.qml"));
view.setSource(QUrl::fromLocalFile(filename));
qApp->processEvents();
QFETCH(int, expectCount);
QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(TESTDATA("visualdatamodel.qml")));
+ QDeclarativeComponent c(&engine, testFileUrl("visualdatamodel.qml"));
SingleRoleModel model;
model.list.clear();
QTest::addColumn<QString>("package delegate");
QTest::newRow("item delegate")
- << QUrl::fromLocalFile(TESTDATA("groups.qml"))
+ << testFileUrl("groups.qml")
<< QString();
QTest::newRow("package")
- << QUrl::fromLocalFile(TESTDATA("groups-package.qml"))
+ << testFileUrl("groups-package.qml")
<< QString("package.");
}
QDeclarativeContext *ctxt = view.rootContext();
ctxt->setContextProperty("myModel", &model);
- view.setSource(QUrl::fromLocalFile(TESTDATA("groups.qml")));
+ view.setSource(testFileUrl("groups.qml"));
QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
QVERIFY(listview != 0);
QTest::addColumn<QString>("package delegate");
QTest::newRow("item delegate")
- << QUrl::fromLocalFile(TESTDATA("groups.qml"))
+ << testFileUrl("groups.qml")
<< QString();
QTest::newRow("package")
- << QUrl::fromLocalFile(TESTDATA("groups-package.qml"))
+ << testFileUrl("groups-package.qml")
<< QString("package.");
}
QDeclarativeContext *ctxt = view.rootContext();
ctxt->setContextProperty("myModel", &model);
- view.setSource(QUrl::fromLocalFile(TESTDATA("groups.qml")));
+ view.setSource(testFileUrl("groups.qml"));
QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
QVERIFY(listview != 0);
QTest::addColumn<QString>("part");
QTest::newRow("item delegate")
- << QUrl::fromLocalFile(TESTDATA("groups.qml"))
+ << testFileUrl("groups.qml")
<< QString();
QTest::newRow("package")
- << QUrl::fromLocalFile(TESTDATA("groups-package.qml"))
+ << testFileUrl("groups-package.qml")
<< QString("visualModel.parts.package.");
}
QDeclarativeContext *ctxt = view.rootContext();
ctxt->setContextProperty("myModel", &model);
- view.setSource(QUrl::fromLocalFile(TESTDATA("groups.qml")));
+ view.setSource(testFileUrl("groups.qml"));
QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
QVERIFY(listview != 0);
void tst_qquickvisualdatamodel::invalidGroups()
{
- QUrl source = QUrl::fromLocalFile(TESTDATA("groups-invalid.qml"));
+ QUrl source = testFileUrl("groups-invalid.qml");
QTest::ignoreMessage(QtWarningMsg, (source.toString() + ":12:9: QML VisualDataGroup: " + QQuickVisualDataGroup::tr("Group names must start with a lower case letter")).toUtf8());
QDeclarativeComponent component(&engine, source);
QFETCH(QString, expression);
QFETCH(QStringList, tests);
- QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("onChanged.qml")));
+ QDeclarativeComponent component(&engine, testFileUrl("onChanged.qml"));
QScopedPointer<QObject> object(component.create());
QVERIFY(object);
QDeclarativeContext *ctxt = view.rootContext();
ctxt->setContextProperty("myModel", &model);
- view.setSource(QUrl::fromLocalFile(TESTDATA("create.qml")));
+ view.setSource(testFileUrl("create.qml"));
QQuickListView *listview = qobject_cast<QQuickListView*>(view.rootObject());
QVERIFY(listview != 0);
// harmlessly ignored until then.
QDeclarativeComponent component(&engine);
- component.setData("import QtQuick 2.0\n VisualDataModel {}", QUrl::fromLocalFile(TESTDATA("")));
+ component.setData("import QtQuick 2.0\n VisualDataModel {}", testFileUrl(""));
QScopedPointer<QObject> object(component.beginCreate(engine.rootContext()));
--- /dev/null
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "util.h"
+
+#include <QtDeclarative/QDeclarativeComponent>
+#include <QtDeclarative/QDeclarativeError>
+#include <QtDeclarative/QDeclarativeContext>
+#include <QtDeclarative/QDeclarativeEngine>
+#include <QtCore/QTextStream>
+
+QDeclarativeDataTest *QDeclarativeDataTest::m_instance = 0;
+
+QDeclarativeDataTest::QDeclarativeDataTest() :
+ m_dataDirectory(QFINDTESTDATA("data")),
+ m_dataDirectoryUrl(QUrl::fromLocalFile(m_dataDirectory + QLatin1Char('/')))
+{
+ m_instance = this;
+}
+
+QDeclarativeDataTest::~QDeclarativeDataTest()
+{
+ m_instance = 0;
+}
+
+void QDeclarativeDataTest::initTestCase()
+{
+ QVERIFY2(!m_dataDirectory.isEmpty(), "'data' directory not found");
+ m_directory = QFileInfo(m_dataDirectory).absolutePath();
+ QVERIFY2(QDir::setCurrent(m_directory), qPrintable(QLatin1String("Could not chdir to ") + m_directory));
+}
+
+QString QDeclarativeDataTest::testFile(const QString &fileName) const
+{
+ if (m_directory.isEmpty())
+ qFatal("QDeclarativeDataTest::initTestCase() not called.");
+ QString result = m_dataDirectory;
+ result += QLatin1Char('/');
+ result += fileName;
+ return result;
+}
+
+QByteArray QDeclarativeDataTest::msgComponentError(const QDeclarativeComponent &c,
+ const QDeclarativeEngine *engine /* = 0 */)
+{
+ QString result;
+ const QList<QDeclarativeError> errors = c.errors();
+ QTextStream str(&result);
+ str << "Component '" << c.url().toString() << "' has " << errors.size()
+ << " errors: '";
+ for (int i = 0; i < errors.size(); ++i) {
+ if (i)
+ str << ", '";
+ str << errors.at(i).toString() << '\'';
+
+ }
+ if (!engine)
+ if (QDeclarativeContext *context = c.creationContext())
+ engine = context->engine();
+ if (engine) {
+ str << " Import paths: (" << engine->importPathList().join(QStringLiteral(", "))
+ << ") Plugin paths: (" << engine->pluginPathList().join(QStringLiteral(", "))
+ << ')';
+ }
+ return result.toLocal8Bit();
+}
#ifndef QDECLARATIVETESTUTILS_H
#define QDECLARATIVETESTUTILS_H
-#include <QtCore/qdir.h>
-#include <QtCore/qcoreapplication.h>
+#include <QtCore/QDir>
+#include <QtCore/QUrl>
+#include <QtCore/QCoreApplication>
+#include <QtTest/QTest>
-namespace QDeclarativeTestUtils
+QT_FORWARD_DECLARE_CLASS(QDeclarativeComponent)
+QT_FORWARD_DECLARE_CLASS(QDeclarativeEngine)
+
+/* Base class for tests with data that are located in a "data" subfolder. */
+
+class QDeclarativeDataTest : public QObject
{
- /*
- Returns the path to some testdata file.
+ Q_OBJECT
+public:
+ QDeclarativeDataTest();
+ virtual ~QDeclarativeDataTest();
+
+ QString testFile(const QString &fileName) const;
+ inline QString testFile(const char *fileName) const
+ { return testFile(QLatin1String(fileName)); }
+ inline QUrl testFileUrl(const QString &fileName) const
+ { return QUrl::fromLocalFile(testFile(fileName)); }
+ inline QUrl testFileUrl(const char *fileName) const
+ { return testFileUrl(QLatin1String(fileName)); }
- We first check relative to the binary, and then look in the source tree.
+ inline QString dataDirectory() const { return m_dataDirectory; }
+ inline QUrl dataDirectoryUrl() const { return m_dataDirectoryUrl; }
+ inline QString directory() const { return m_directory; }
- Note we are looking for a _directory_ which exists, but the _file_ itself need not exist,
- to support the case of finding a path to a testdata file which doesn't exist yet (i.e.
- a file we are about to create).
- */
- QString testdata(QString const& name, const char *sourceFile)
- {
- // Try to find it relative to the binary.
- QFileInfo relative = QDir(QCoreApplication::applicationDirPath()).filePath(QLatin1String("data/") + name);
- if (relative.dir().exists()) {
- return relative.absoluteFilePath();
- }
+ static inline QDeclarativeDataTest *instance() { return m_instance; }
- // Else try to find it in the source tree
- QFileInfo from_source = QFileInfo(sourceFile).absoluteDir().filePath(QLatin1String("data/") + name);
- if (from_source.dir().exists()) {
- return from_source.absoluteFilePath();
- }
+ static QByteArray msgComponentError(const QDeclarativeComponent &,
+ const QDeclarativeEngine *engine = 0);
- qWarning("requested testdata %s could not be found (looked at: %s, %s)",
- qPrintable(name),
- qPrintable(relative.filePath()),
- qPrintable(from_source.filePath())
- );
+public slots:
+ virtual void initTestCase();
- return QString();
- }
-}
+private:
+ static QDeclarativeDataTest *m_instance;
-#define TESTDATA(name) QDeclarativeTestUtils::testdata(name, __FILE__)
+ const QString m_dataDirectory;
+ const QUrl m_dataDirectoryUrl;
+ QString m_directory;
+};
#endif // QDECLARATIVETESTUTILS_H