aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp')
-rw-r--r--tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp50
1 files changed, 44 insertions, 6 deletions
diff --git a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp
index 1ccf7a6f23..59703d5c36 100644
--- a/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp
+++ b/tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp
@@ -1361,8 +1361,7 @@ void tst_qqmlcomponent::loadFromModule()
void tst_qqmlcomponent::loadFromModuleLifecycle()
{
QQmlEngine engine;
- QList<int> loadFromModuleOrder;
- QList<int> plainLoadOrder;
+ const QString text = "text"_L1;
const QList<int> expected {1, 2, 3};
{
QQmlComponent component(&engine);
@@ -1371,19 +1370,58 @@ void tst_qqmlcomponent::loadFromModuleLifecycle()
std::unique_ptr<QObject> root{ component.create() };
LifeCycleWatcher *watcher = qobject_cast<LifeCycleWatcher *>(root.get());
QVERIFY(watcher);
- loadFromModuleOrder = watcher->states;
- QCOMPARE(loadFromModuleOrder, expected);
+ QCOMPARE(watcher->states, expected);
+ QCOMPARE(watcher->observedTexts, QStringList(3));
+
+ const QString loaded = "load from module"_L1;
+ root.reset(component.createWithInitialProperties(QVariantMap{{text, loaded}}));
+ watcher = qobject_cast<LifeCycleWatcher *>(root.get());
+ QVERIFY(watcher);
+ QCOMPARE(watcher->states, expected);
+ QCOMPARE(watcher->observedTexts, QStringList({QString(), loaded, loaded}));
}
+
{
QQmlComponent component(&engine);
component.setData("import test; LifeCycleWatcher {}", {});
QVERIFY2(component.isReady(), qPrintable(component.errorString()));
+
std::unique_ptr<QObject> root{ component.create() };
LifeCycleWatcher *watcher = qobject_cast<LifeCycleWatcher *>(root.get());
QVERIFY(watcher);
- plainLoadOrder = watcher->states;
+ QCOMPARE(watcher->states, expected);
+ QCOMPARE(watcher->observedTexts, QStringList(3));
+
+ const QString loaded = "load from data"_L1;
+ root.reset(component.createWithInitialProperties(QVariantMap{{text, loaded}}));
+ watcher = qobject_cast<LifeCycleWatcher *>(root.get());
+ QVERIFY(watcher);
+ QCOMPARE(watcher->states, expected);
+ QCOMPARE(watcher->observedTexts, QStringList({QString(), loaded, loaded}));
}
- QCOMPARE(loadFromModuleOrder, plainLoadOrder);
+
+ {
+ QQmlComponent component(&engine);
+ const QString compiled = "inline"_L1;
+ component.setData("import test; LifeCycleWatcher { text: 'inline' }", {});
+ QVERIFY2(component.isReady(), qPrintable(component.errorString()));
+
+ std::unique_ptr<QObject> root{ component.create() };
+ LifeCycleWatcher *watcher = qobject_cast<LifeCycleWatcher *>(root.get());
+ QVERIFY(watcher);
+ QCOMPARE(watcher->states, expected);
+ QCOMPARE(watcher->observedTexts, QStringList({QString(), compiled, compiled}));
+
+ const QString loaded = "overridden"_L1;
+ std::unique_ptr<QObject> withProperties(
+ component.createWithInitialProperties(QVariantMap{{text, loaded}}));
+ watcher = qobject_cast<LifeCycleWatcher *>(withProperties.get());
+ QVERIFY(watcher);
+ QCOMPARE(watcher->states, expected);
+ QCOMPARE(watcher->observedTexts, QStringList({QString(), loaded, loaded}));
+ }
+
+
}
struct CallVerifyingIncubtor : QQmlIncubator