diff options
| author | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2025-12-15 16:14:22 +0200 |
|---|---|---|
| committer | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2025-12-15 16:14:22 +0200 |
| commit | b58ec3b086518da5aa573f99426235854c23e35f (patch) | |
| tree | 861a9935d8f1cdba2fdca546836a351736dbddbf /tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp | |
| parent | 4826f86e274f1b29bd769e6790824f9e62a40f62 (diff) | |
| parent | 22032227d16c39211e2ebceef97d21f4d89c7c87 (diff) | |
Merge tag 'v6.5.8-lts-lgpl' into 6.56.5
Qt 6.5.8-lts-lgpl release
Diffstat (limited to 'tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp')
| -rw-r--r-- | tests/auto/qml/qqmlcomponent/tst_qqmlcomponent.cpp | 50 |
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 |
