diff options
Diffstat (limited to 'tests/auto/qml/qquickworkerscript')
-rw-r--r-- | tests/auto/qml/qquickworkerscript/data/BaseWorker.qml | 5 | ||||
-rw-r--r-- | tests/auto/qml/qquickworkerscript/tst_qquickworkerscript.cpp | 18 |
2 files changed, 23 insertions, 0 deletions
diff --git a/tests/auto/qml/qquickworkerscript/data/BaseWorker.qml b/tests/auto/qml/qquickworkerscript/data/BaseWorker.qml index 0ac56d9b66..1d3420e186 100644 --- a/tests/auto/qml/qquickworkerscript/data/BaseWorker.qml +++ b/tests/auto/qml/qquickworkerscript/data/BaseWorker.qml @@ -1,11 +1,14 @@ import QtQuick 2.0 +import QtQml.WorkerScript 2.15 WorkerScript { id: worker property variant response + property bool readyChangedCalled : false signal done() + signal ready() function testSend(value) { worker.sendMessage(value) @@ -20,5 +23,7 @@ WorkerScript { worker.response = messageObject worker.done() } + + onReadyChanged: worker.readyChangedCalled = true } diff --git a/tests/auto/qml/qquickworkerscript/tst_qquickworkerscript.cpp b/tests/auto/qml/qquickworkerscript/tst_qquickworkerscript.cpp index d11e7bde4b..2f79f7157f 100644 --- a/tests/auto/qml/qquickworkerscript/tst_qquickworkerscript.cpp +++ b/tests/auto/qml/qquickworkerscript/tst_qquickworkerscript.cpp @@ -47,6 +47,7 @@ public: tst_QQuickWorkerScript() {} private slots: void source(); + void ready(); void messaging(); void messaging_data(); void messaging_sendQObjectList(); @@ -105,6 +106,22 @@ void tst_QQuickWorkerScript::source() qApp->processEvents(); } +void tst_QQuickWorkerScript::ready() +{ + QQmlComponent component(&m_engine, testFileUrl("worker.qml")); + QScopedPointer<QQuickWorkerScript>worker(qobject_cast<QQuickWorkerScript*>(component.create())); + QVERIFY(worker != nullptr); + + const QMetaObject *mo = worker->metaObject(); + + QTRY_VERIFY(worker->ready()); + + QVariant readyChangedCalled = mo->property(mo->indexOfProperty("readyChangedCalled")).read(worker.data()).value<QVariant>(); + + QVERIFY(!readyChangedCalled.isNull()); + QVERIFY(readyChangedCalled.toBool()); +} + void tst_QQuickWorkerScript::messaging() { QFETCH(QVariant, value); @@ -152,6 +169,7 @@ void tst_QQuickWorkerScript::messaging_data() QRegExp::RegExp2)); QTest::newRow("regularexpression") << QVariant::fromValue(QRegularExpression( "^\\d\\d?$", QRegularExpression::CaseInsensitiveOption)); + QTest::newRow("url") << QVariant::fromValue(QUrl("http://example.com/foo/bar")); } void tst_QQuickWorkerScript::messaging_sendQObjectList() |