aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qml')
-rw-r--r--tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp28
-rw-r--r--tests/auto/qml/debugger/shared/qqmlenginedebugclient.cpp4
-rw-r--r--tests/auto/qml/debugger/shared/qqmlenginedebugclient.h2
-rw-r--r--tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp58
-rw-r--r--tests/auto/qml/qqmlecmascript/data/signalParameterTypes.qml2
-rw-r--r--tests/auto/qml/qqmlecmascript/testtypes.h1
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp1
7 files changed, 89 insertions, 7 deletions
diff --git a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp
index 40e19d375d..8c30a82317 100644
--- a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp
+++ b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp
@@ -45,6 +45,7 @@
#include <QtQml/qqmlcomponent.h>
#include <QtQml/qqmlexpression.h>
#include <QtQml/qqmlproperty.h>
+#include <QtQml/qqmlincubator.h>
#include <QtQuick/qquickitem.h>
#include <QtNetwork/qhostaddress.h>
@@ -136,6 +137,7 @@ private slots:
void regression_QTCREATORBUG_7451();
void queryObjectWithNonStreamableTypes();
+ void asynchronousCreate();
};
QmlDebugObjectReference tst_QQmlEngineDebugService::findRootObject(
@@ -1220,6 +1222,32 @@ void tst_QQmlEngineDebugService::queryObjectTree()
QCOMPARE(findProperty(animation.properties,"duration").value.toInt(), 100);
}
+void tst_QQmlEngineDebugService::asynchronousCreate() {
+ QmlDebugObjectReference object;
+ auto connection = connect(m_dbg, &QQmlEngineDebugClient::newObject, this, [&](int objectId) {
+ object.debugId = objectId;
+ });
+
+ QByteArray asynchronousComponent = "import QtQuick 2.5\n"
+ "Rectangle { id: asyncRect }";
+ QQmlComponent component(m_engine);
+ component.setData(asynchronousComponent, QUrl::fromLocalFile(""));
+ QVERIFY(component.isReady()); // fails if bad syntax
+ QQmlIncubator incubator(QQmlIncubator::Asynchronous);
+ component.create(incubator);
+
+ QVERIFY(m_dbg->object().idString != QLatin1String("asyncRect"));
+
+ QTRY_VERIFY(object.debugId != -1);
+ disconnect(connection);
+
+ bool success = false;
+ m_dbg->queryObject(object, &success);
+ QVERIFY(success);
+
+ QTRY_COMPARE(m_dbg->object().idString, QLatin1String("asyncRect"));
+}
+
int main(int argc, char *argv[])
{
int _argc = argc + 1;
diff --git a/tests/auto/qml/debugger/shared/qqmlenginedebugclient.cpp b/tests/auto/qml/debugger/shared/qqmlenginedebugclient.cpp
index 3ad7beb7ff..3e27951d78 100644
--- a/tests/auto/qml/debugger/shared/qqmlenginedebugclient.cpp
+++ b/tests/auto/qml/debugger/shared/qqmlenginedebugclient.cpp
@@ -489,7 +489,9 @@ void QQmlEngineDebugClient::messageReceived(const QByteArray &data)
return;
} else if (type == "OBJECT_CREATED") {
- emit newObjects();
+ int engineId, objectId, parentId;
+ ds >> engineId >> objectId >> parentId;
+ emit newObject(objectId);
return;
} else if (type == "SET_BINDING_R") {
ds >> m_valid;
diff --git a/tests/auto/qml/debugger/shared/qqmlenginedebugclient.h b/tests/auto/qml/debugger/shared/qqmlenginedebugclient.h
index a64a77e13e..5d74f2d43c 100644
--- a/tests/auto/qml/debugger/shared/qqmlenginedebugclient.h
+++ b/tests/auto/qml/debugger/shared/qqmlenginedebugclient.h
@@ -213,7 +213,7 @@ public:
bool valid() { return m_valid; }
signals:
- void newObjects();
+ void newObject(int objectId);
void valueChanged(QByteArray,QVariant);
void result();
diff --git a/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp b/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp
index 8af446173d..b265607fd1 100644
--- a/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp
+++ b/tests/auto/qml/qmldiskcache/tst_qmldiskcache.cpp
@@ -53,6 +53,7 @@ private slots:
void registerImportForImplicitComponent();
void basicVersionChecks();
void recompileAfterChange();
+ void recompileAfterDirectoryChange();
void fileSelectors();
void localAliases();
void cacheResources();
@@ -95,11 +96,17 @@ struct TestCompiler
TestCompiler(QQmlEngine *engine)
: engine(engine)
, tempDir()
- , testFilePath(tempDir.path() + QStringLiteral("/test.qml"))
- , cacheFilePath(tempDir.path() + QStringLiteral("/test.qmlc"))
- , mappedFile(cacheFilePath)
, currentMapping(nullptr)
{
+ init(tempDir.path());
+ }
+
+ void init(const QString &baseDirectory)
+ {
+ closeMapping();
+ testFilePath = baseDirectory + QStringLiteral("/test.qml");
+ cacheFilePath = baseDirectory + QStringLiteral("/test.qmlc");
+ mappedFile.setFileName(cacheFilePath);
}
bool compile(const QByteArray &contents)
@@ -187,8 +194,8 @@ struct TestCompiler
QQmlEngine *engine;
const QTemporaryDir tempDir;
- const QString testFilePath;
- const QString cacheFilePath;
+ QString testFilePath;
+ QString cacheFilePath;
QString lastErrorString;
QFile mappedFile;
uchar *currentMapping;
@@ -441,6 +448,47 @@ void tst_qmldiskcache::recompileAfterChange()
}
}
+void tst_qmldiskcache::recompileAfterDirectoryChange()
+{
+ QQmlEngine engine;
+ TestCompiler testCompiler(&engine);
+
+ QVERIFY(testCompiler.tempDir.isValid());
+
+ QVERIFY(QDir(testCompiler.tempDir.path()).mkdir("source1"));
+ testCompiler.init(testCompiler.tempDir.path() + QLatin1String("/source1"));
+
+ {
+ const QByteArray contents = QByteArrayLiteral("import QtQml 2.0\n"
+ "QtObject {\n"
+ " property int blah: 42;\n"
+ "}");
+
+ testCompiler.clearCache();
+ QVERIFY2(testCompiler.compile(contents), qPrintable(testCompiler.lastErrorString));
+ QVERIFY2(testCompiler.verify(), qPrintable(testCompiler.lastErrorString));
+ testCompiler.closeMapping();
+ }
+
+ const QDateTime initialCacheTimeStamp = QFileInfo(testCompiler.cacheFilePath).lastModified();
+
+ QDir(testCompiler.tempDir.path()).rename(QStringLiteral("source1"), QStringLiteral("source2"));
+ waitForFileSystem();
+
+ testCompiler.init(testCompiler.tempDir.path() + QLatin1String("/source2"));
+
+ {
+ CleanlyLoadingComponent component(&engine, testCompiler.testFilePath);
+ QScopedPointer<QObject> obj(component.create());
+ QVERIFY(!obj.isNull());
+ QCOMPARE(obj->property("blah").toInt(), 42);
+ }
+
+ QFile cacheFile(testCompiler.cacheFilePath);
+ QVERIFY2(cacheFile.exists(), qPrintable(cacheFile.fileName()));
+ QVERIFY(QFileInfo(testCompiler.cacheFilePath).lastModified() > initialCacheTimeStamp);
+}
+
void tst_qmldiskcache::fileSelectors()
{
QQmlEngine engine;
diff --git a/tests/auto/qml/qqmlecmascript/data/signalParameterTypes.qml b/tests/auto/qml/qqmlecmascript/data/signalParameterTypes.qml
index 4fc2dab943..676593096c 100644
--- a/tests/auto/qml/qqmlecmascript/data/signalParameterTypes.qml
+++ b/tests/auto/qml/qqmlecmascript/data/signalParameterTypes.qml
@@ -15,4 +15,6 @@ MyQmlObject
onMySignal: { intProperty = a; realProperty = b; colorProperty = c; variantProperty = d; enumProperty = e; qtEnumProperty = f; }
onBasicSignal: root.mySignal(10, 19.2, Qt.rgba(1, 1, 0, 1), Qt.rgba(1, 0, 1, 1), MyQmlObject.EnumValue3, Qt.LeftButton)
+
+ onQjsValueEmittingSignal: {}
}
diff --git a/tests/auto/qml/qqmlecmascript/testtypes.h b/tests/auto/qml/qqmlecmascript/testtypes.h
index 47fb2a56e7..1f7f3344ef 100644
--- a/tests/auto/qml/qqmlecmascript/testtypes.h
+++ b/tests/auto/qml/qqmlecmascript/testtypes.h
@@ -244,6 +244,7 @@ signals:
void signalWithGlobalName(int parseInt);
void intChanged();
void qjsvalueChanged();
+ void qjsValueEmittingSignal(QJSValue value);
public slots:
void deleteMe() { delete this; }
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index 88a8886ecb..b8f12e772d 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -1410,6 +1410,7 @@ void tst_qqmlecmascript::signalParameterTypes()
QVERIFY(object != 0);
emit object->basicSignal();
+ emit object->qjsValueEmittingSignal(QJSValue());
QCOMPARE(object->property("intProperty").toInt(), 10);
QCOMPARE(object->property("realProperty").toReal(), 19.2);