aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qquickworkerscript/tst_qquickworkerscript.cpp
diff options
context:
space:
mode:
authorMaximilian Goldstein <max.goldstein@qt.io>2019-12-06 10:56:22 +0100
committerUlf Hermann <ulf.hermann@qt.io>2019-12-06 14:32:16 +0000
commit3c4247e1e021b6bcc480afc0716e0231575d0501 (patch)
tree8f1f72b91e150b88e53e5b4ccac6a551e096220b /tests/auto/qml/qquickworkerscript/tst_qquickworkerscript.cpp
parent8fadf5d374936e50b8bce5adb1f10da2f66eac2b (diff)
src/qmlworkerscript: Add ready property to WorkerScript
Previously it was impossible to determine whether a WorkerScript has been fully initialized. This commit introduces a ready property that allows outside Components to determine whether it is safe to send signals. Fixes: QTBUG-80413 Change-Id: I2a1892b5e759e317de791e71d79fbb0cbd320dd3 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tests/auto/qml/qquickworkerscript/tst_qquickworkerscript.cpp')
-rw-r--r--tests/auto/qml/qquickworkerscript/tst_qquickworkerscript.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/auto/qml/qquickworkerscript/tst_qquickworkerscript.cpp b/tests/auto/qml/qquickworkerscript/tst_qquickworkerscript.cpp
index bea9978f0b..1ace13a3fa 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();
@@ -104,6 +105,25 @@ 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();
+
+ // Give the component some time to become ready
+ QTest::qSleep(1000);
+
+ QVERIFY(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);