diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2019-10-04 13:49:18 +0200 |
---|---|---|
committer | Fabian Kosmale <fabian.kosmale@qt.io> | 2019-10-07 07:51:31 +0200 |
commit | 56d218d72dfa60893404254900d6c18aad35cc50 (patch) | |
tree | dec0d5875e3e9a2ed2f2f15d7cbb30ebf26c6a52 /tests/auto/qml/qqmlengine | |
parent | 0bbd52ac6f98e7020208faa2dbd774824ed212c7 (diff) |
Clean up tst_qqmlengine.cpp
- avoid setContextProperty in multiple places
- ignore expected warning
Change-Id: I0d7ed77ef58f5b7bb40bd633811498f107f4c700
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'tests/auto/qml/qqmlengine')
40 files changed, 53 insertions, 11 deletions
diff --git a/tests/auto/qml/qqmlengine/data/testEmptyAggregateEmptyComponent.1.qml b/tests/auto/qml/qqmlengine/data/testEmptyAggregateEmptyComponent.1.qml index 812242f146..a37461a173 100644 --- a/tests/auto/qml/qqmlengine/data/testEmptyAggregateEmptyComponent.1.qml +++ b/tests/auto/qml/qqmlengine/data/testEmptyAggregateEmptyComponent.1.qml @@ -2,6 +2,7 @@ import QtQuick 2.0 Item { property bool success: false + required property QtObject componentCache function reportError(s) { console.warn(s) } diff --git a/tests/auto/qml/qqmlengine/data/testEmptyAggregateEmptyComponent.2.qml b/tests/auto/qml/qqmlengine/data/testEmptyAggregateEmptyComponent.2.qml index a171ee6b28..1dc06ee6ae 100644 --- a/tests/auto/qml/qqmlengine/data/testEmptyAggregateEmptyComponent.2.qml +++ b/tests/auto/qml/qqmlengine/data/testEmptyAggregateEmptyComponent.2.qml @@ -2,6 +2,7 @@ import QtQuick 2.0 Item { property bool success: false + required property QtObject componentCache function reportError(s) { console.warn(s) } diff --git a/tests/auto/qml/qqmlengine/data/testEmptyAggregateVMEComponent.1.qml b/tests/auto/qml/qqmlengine/data/testEmptyAggregateVMEComponent.1.qml index de40284452..ea945eebb0 100644 --- a/tests/auto/qml/qqmlengine/data/testEmptyAggregateVMEComponent.1.qml +++ b/tests/auto/qml/qqmlengine/data/testEmptyAggregateVMEComponent.1.qml @@ -2,6 +2,7 @@ import QtQuick 2.0 Item { property bool success: false + required property QtObject componentCache function reportError(s) { console.warn(s) } diff --git a/tests/auto/qml/qqmlengine/data/testEmptyAggregateVMEComponent.2.qml b/tests/auto/qml/qqmlengine/data/testEmptyAggregateVMEComponent.2.qml index 4939087b31..9a4fc53833 100644 --- a/tests/auto/qml/qqmlengine/data/testEmptyAggregateVMEComponent.2.qml +++ b/tests/auto/qml/qqmlengine/data/testEmptyAggregateVMEComponent.2.qml @@ -2,6 +2,7 @@ import QtQuick 2.0 Item { property bool success: false + required property QtObject componentCache function reportError(s) { console.warn(s) } diff --git a/tests/auto/qml/qqmlengine/data/testEmptyComponent.1.qml b/tests/auto/qml/qqmlengine/data/testEmptyComponent.1.qml index 5cee0341fe..155dbdcb91 100644 --- a/tests/auto/qml/qqmlengine/data/testEmptyComponent.1.qml +++ b/tests/auto/qml/qqmlengine/data/testEmptyComponent.1.qml @@ -2,6 +2,7 @@ import QtQuick 2.0 Item { property bool success: false + required property QtObject componentCache function reportError(s) { console.warn(s) } diff --git a/tests/auto/qml/qqmlengine/data/testEmptyComponent.2.qml b/tests/auto/qml/qqmlengine/data/testEmptyComponent.2.qml index 2a13822fab..940d54be90 100644 --- a/tests/auto/qml/qqmlengine/data/testEmptyComponent.2.qml +++ b/tests/auto/qml/qqmlengine/data/testEmptyComponent.2.qml @@ -2,6 +2,7 @@ import QtQuick 2.0 Item { property bool success: false + required property QtObject componentCache function reportError(s) { console.warn(s) } diff --git a/tests/auto/qml/qqmlengine/data/testEmptyExtendEmptyComponent.1.qml b/tests/auto/qml/qqmlengine/data/testEmptyExtendEmptyComponent.1.qml index 2f238175fa..46d20e38bb 100644 --- a/tests/auto/qml/qqmlengine/data/testEmptyExtendEmptyComponent.1.qml +++ b/tests/auto/qml/qqmlengine/data/testEmptyExtendEmptyComponent.1.qml @@ -2,6 +2,7 @@ import QtQuick 2.0 Item { property bool success: false + required property QtObject componentCache function reportError(s) { console.warn(s) } diff --git a/tests/auto/qml/qqmlengine/data/testEmptyExtendEmptyComponent.2.qml b/tests/auto/qml/qqmlengine/data/testEmptyExtendEmptyComponent.2.qml index d36e95fec3..ffdb30f072 100644 --- a/tests/auto/qml/qqmlengine/data/testEmptyExtendEmptyComponent.2.qml +++ b/tests/auto/qml/qqmlengine/data/testEmptyExtendEmptyComponent.2.qml @@ -2,6 +2,7 @@ import QtQuick 2.0 Item { property bool success: false + required property QtObject componentCache function reportError(s) { console.warn(s) } diff --git a/tests/auto/qml/qqmlengine/data/testEmptyExtendVMEComponent.1.qml b/tests/auto/qml/qqmlengine/data/testEmptyExtendVMEComponent.1.qml index 53dd5a17e9..ca669a9708 100644 --- a/tests/auto/qml/qqmlengine/data/testEmptyExtendVMEComponent.1.qml +++ b/tests/auto/qml/qqmlengine/data/testEmptyExtendVMEComponent.1.qml @@ -2,6 +2,7 @@ import QtQuick 2.0 Item { property bool success: false + required property QtObject componentCache function reportError(s) { console.warn(s) } diff --git a/tests/auto/qml/qqmlengine/data/testEmptyExtendVMEComponent.2.qml b/tests/auto/qml/qqmlengine/data/testEmptyExtendVMEComponent.2.qml index e5cd7d60de..a93c3b302c 100644 --- a/tests/auto/qml/qqmlengine/data/testEmptyExtendVMEComponent.2.qml +++ b/tests/auto/qml/qqmlengine/data/testEmptyExtendVMEComponent.2.qml @@ -2,6 +2,7 @@ import QtQuick 2.0 Item { property bool success: false + required property QtObject componentCache function reportError(s) { console.warn(s) } diff --git a/tests/auto/qml/qqmlengine/data/testEmptyPropertyEmptyComponent.1.qml b/tests/auto/qml/qqmlengine/data/testEmptyPropertyEmptyComponent.1.qml index d98aef2932..5930e12df6 100644 --- a/tests/auto/qml/qqmlengine/data/testEmptyPropertyEmptyComponent.1.qml +++ b/tests/auto/qml/qqmlengine/data/testEmptyPropertyEmptyComponent.1.qml @@ -2,6 +2,7 @@ import QtQuick 2.0 Item { property bool success: false + required property QtObject componentCache function reportError(s) { console.warn(s) } diff --git a/tests/auto/qml/qqmlengine/data/testEmptyPropertyEmptyComponent.2.qml b/tests/auto/qml/qqmlengine/data/testEmptyPropertyEmptyComponent.2.qml index 7f438aa995..8f929c20b2 100644 --- a/tests/auto/qml/qqmlengine/data/testEmptyPropertyEmptyComponent.2.qml +++ b/tests/auto/qml/qqmlengine/data/testEmptyPropertyEmptyComponent.2.qml @@ -2,6 +2,7 @@ import QtQuick 2.0 Item { property bool success: false + required property QtObject componentCache function reportError(s) { console.warn(s) } diff --git a/tests/auto/qml/qqmlengine/data/testEmptyPropertyVMEComponent.1.qml b/tests/auto/qml/qqmlengine/data/testEmptyPropertyVMEComponent.1.qml index 83d6226e83..20bde6d0af 100644 --- a/tests/auto/qml/qqmlengine/data/testEmptyPropertyVMEComponent.1.qml +++ b/tests/auto/qml/qqmlengine/data/testEmptyPropertyVMEComponent.1.qml @@ -2,6 +2,7 @@ import QtQuick 2.0 Item { property bool success: false + required property QtObject componentCache function reportError(s) { console.warn(s) } diff --git a/tests/auto/qml/qqmlengine/data/testEmptyPropertyVMEComponent.2.qml b/tests/auto/qml/qqmlengine/data/testEmptyPropertyVMEComponent.2.qml index 98dfb7241b..10ae369459 100644 --- a/tests/auto/qml/qqmlengine/data/testEmptyPropertyVMEComponent.2.qml +++ b/tests/auto/qml/qqmlengine/data/testEmptyPropertyVMEComponent.2.qml @@ -2,6 +2,7 @@ import QtQuick 2.0 Item { property bool success: false + required property QtObject componentCache function reportError(s) { console.warn(s) } diff --git a/tests/auto/qml/qqmlengine/data/testIncubatedComponent.qml b/tests/auto/qml/qqmlengine/data/testIncubatedComponent.qml index 50af9c4f16..422637fe31 100644 --- a/tests/auto/qml/qqmlengine/data/testIncubatedComponent.qml +++ b/tests/auto/qml/qqmlengine/data/testIncubatedComponent.qml @@ -2,6 +2,7 @@ import QtQuick 2.0 Item { property bool success: false + required property QtObject componentCache function reportError(s) { console.warn(s) } diff --git a/tests/auto/qml/qqmlengine/data/testLoaderComponent.qml b/tests/auto/qml/qqmlengine/data/testLoaderComponent.qml index a04ca41c26..67d7ddd1c9 100644 --- a/tests/auto/qml/qqmlengine/data/testLoaderComponent.qml +++ b/tests/auto/qml/qqmlengine/data/testLoaderComponent.qml @@ -2,6 +2,7 @@ import QtQuick 2.0 Item { property bool success: false + required property QtObject componentCache function reportError(s) { console.warn(s) } diff --git a/tests/auto/qml/qqmlengine/data/testReloadComponent.qml b/tests/auto/qml/qqmlengine/data/testReloadComponent.qml index 74442108cd..79d4f29db0 100644 --- a/tests/auto/qml/qqmlengine/data/testReloadComponent.qml +++ b/tests/auto/qml/qqmlengine/data/testReloadComponent.qml @@ -2,6 +2,7 @@ import QtQuick 2.0 Item { property bool success: false + required property QtObject componentCache function reportError(s) { console.warn(s) } diff --git a/tests/auto/qml/qqmlengine/data/testScriptComponent.qml b/tests/auto/qml/qqmlengine/data/testScriptComponent.qml index b33eb48461..4952a08a6c 100644 --- a/tests/auto/qml/qqmlengine/data/testScriptComponent.qml +++ b/tests/auto/qml/qqmlengine/data/testScriptComponent.qml @@ -2,6 +2,7 @@ import QtQuick 2.0 Item { property bool success: false + required property QtObject componentCache function reportError(s) { console.warn(s) } diff --git a/tests/auto/qml/qqmlengine/data/testTopLevelComponent.qml b/tests/auto/qml/qqmlengine/data/testTopLevelComponent.qml index 6cf8ec4203..a6a1f4d4d3 100644 --- a/tests/auto/qml/qqmlengine/data/testTopLevelComponent.qml +++ b/tests/auto/qml/qqmlengine/data/testTopLevelComponent.qml @@ -2,6 +2,7 @@ import QtQuick 2.0 Item { property bool success: false + required property QtObject componentCache function reportError(s) { console.warn(s) } diff --git a/tests/auto/qml/qqmlengine/data/testTransientComponent.1.qml b/tests/auto/qml/qqmlengine/data/testTransientComponent.1.qml index d3e6ffd7cf..c661cb6fe4 100644 --- a/tests/auto/qml/qqmlengine/data/testTransientComponent.1.qml +++ b/tests/auto/qml/qqmlengine/data/testTransientComponent.1.qml @@ -2,6 +2,7 @@ import QtQuick 2.0 Item { property bool success: false + required property QtObject componentCache function reportError(s) { console.warn(s) } diff --git a/tests/auto/qml/qqmlengine/data/testTransientComponent.2.qml b/tests/auto/qml/qqmlengine/data/testTransientComponent.2.qml index acb0113e61..8b6c7eda4d 100644 --- a/tests/auto/qml/qqmlengine/data/testTransientComponent.2.qml +++ b/tests/auto/qml/qqmlengine/data/testTransientComponent.2.qml @@ -2,6 +2,7 @@ import QtQuick 2.0 Item { property bool success: false + required property QtObject componentCache function reportError(s) { console.warn(s) } diff --git a/tests/auto/qml/qqmlengine/data/testVMEAggregateEmptyComponent.1.qml b/tests/auto/qml/qqmlengine/data/testVMEAggregateEmptyComponent.1.qml index a5beede469..8c0596eae4 100644 --- a/tests/auto/qml/qqmlengine/data/testVMEAggregateEmptyComponent.1.qml +++ b/tests/auto/qml/qqmlengine/data/testVMEAggregateEmptyComponent.1.qml @@ -2,6 +2,7 @@ import QtQuick 2.0 Item { property bool success: false + required property QtObject componentCache function reportError(s) { console.warn(s) } diff --git a/tests/auto/qml/qqmlengine/data/testVMEAggregateEmptyComponent.2.qml b/tests/auto/qml/qqmlengine/data/testVMEAggregateEmptyComponent.2.qml index 4c8e52f251..39b604d42f 100644 --- a/tests/auto/qml/qqmlengine/data/testVMEAggregateEmptyComponent.2.qml +++ b/tests/auto/qml/qqmlengine/data/testVMEAggregateEmptyComponent.2.qml @@ -2,6 +2,7 @@ import QtQuick 2.0 Item { property bool success: false + required property QtObject componentCache function reportError(s) { console.warn(s) } diff --git a/tests/auto/qml/qqmlengine/data/testVMEAggregateVMEComponent.1.qml b/tests/auto/qml/qqmlengine/data/testVMEAggregateVMEComponent.1.qml index 983d6e824c..807203b6c7 100644 --- a/tests/auto/qml/qqmlengine/data/testVMEAggregateVMEComponent.1.qml +++ b/tests/auto/qml/qqmlengine/data/testVMEAggregateVMEComponent.1.qml @@ -2,6 +2,7 @@ import QtQuick 2.0 Item { property bool success: false + required property QtObject componentCache function reportError(s) { console.warn(s) } diff --git a/tests/auto/qml/qqmlengine/data/testVMEAggregateVMEComponent.2.qml b/tests/auto/qml/qqmlengine/data/testVMEAggregateVMEComponent.2.qml index fc8e5a0cd4..100b287cfd 100644 --- a/tests/auto/qml/qqmlengine/data/testVMEAggregateVMEComponent.2.qml +++ b/tests/auto/qml/qqmlengine/data/testVMEAggregateVMEComponent.2.qml @@ -2,6 +2,7 @@ import QtQuick 2.0 Item { property bool success: false + required property QtObject componentCache function reportError(s) { console.warn(s) } diff --git a/tests/auto/qml/qqmlengine/data/testVMEComponent.1.qml b/tests/auto/qml/qqmlengine/data/testVMEComponent.1.qml index fcfd05c51f..dddf51b926 100644 --- a/tests/auto/qml/qqmlengine/data/testVMEComponent.1.qml +++ b/tests/auto/qml/qqmlengine/data/testVMEComponent.1.qml @@ -2,6 +2,7 @@ import QtQuick 2.0 Item { property bool success: false + required property QtObject componentCache function reportError(s) { console.warn(s) } diff --git a/tests/auto/qml/qqmlengine/data/testVMEComponent.2.qml b/tests/auto/qml/qqmlengine/data/testVMEComponent.2.qml index f434406eec..fa508f16ac 100644 --- a/tests/auto/qml/qqmlengine/data/testVMEComponent.2.qml +++ b/tests/auto/qml/qqmlengine/data/testVMEComponent.2.qml @@ -2,6 +2,7 @@ import QtQuick 2.0 Item { property bool success: false + required property QtObject componentCache function reportError(s) { console.warn(s) } diff --git a/tests/auto/qml/qqmlengine/data/testVMEExtendEmptyComponent.1.qml b/tests/auto/qml/qqmlengine/data/testVMEExtendEmptyComponent.1.qml index 1dcaec90e6..b36d6ebf14 100644 --- a/tests/auto/qml/qqmlengine/data/testVMEExtendEmptyComponent.1.qml +++ b/tests/auto/qml/qqmlengine/data/testVMEExtendEmptyComponent.1.qml @@ -2,6 +2,7 @@ import QtQuick 2.0 Item { property bool success: false + required property QtObject componentCache function reportError(s) { console.warn(s) } diff --git a/tests/auto/qml/qqmlengine/data/testVMEExtendEmptyComponent.2.qml b/tests/auto/qml/qqmlengine/data/testVMEExtendEmptyComponent.2.qml index fd7d7e454c..fce617046b 100644 --- a/tests/auto/qml/qqmlengine/data/testVMEExtendEmptyComponent.2.qml +++ b/tests/auto/qml/qqmlengine/data/testVMEExtendEmptyComponent.2.qml @@ -2,6 +2,7 @@ import QtQuick 2.0 Item { property bool success: false + required property QtObject componentCache function reportError(s) { console.warn(s) } diff --git a/tests/auto/qml/qqmlengine/data/testVMEExtendVMEComponent.1.qml b/tests/auto/qml/qqmlengine/data/testVMEExtendVMEComponent.1.qml index d2dab32fc9..39629d47df 100644 --- a/tests/auto/qml/qqmlengine/data/testVMEExtendVMEComponent.1.qml +++ b/tests/auto/qml/qqmlengine/data/testVMEExtendVMEComponent.1.qml @@ -2,6 +2,7 @@ import QtQuick 2.0 Item { property bool success: false + required property QtObject componentCache function reportError(s) { console.warn(s) } diff --git a/tests/auto/qml/qqmlengine/data/testVMEExtendVMEComponent.2.qml b/tests/auto/qml/qqmlengine/data/testVMEExtendVMEComponent.2.qml index 813e43896c..a4c947cc17 100644 --- a/tests/auto/qml/qqmlengine/data/testVMEExtendVMEComponent.2.qml +++ b/tests/auto/qml/qqmlengine/data/testVMEExtendVMEComponent.2.qml @@ -2,6 +2,7 @@ import QtQuick 2.0 Item { property bool success: false + required property QtObject componentCache function reportError(s) { console.warn(s) } diff --git a/tests/auto/qml/qqmlengine/data/testVMEPropertyEmptyComponent.1.qml b/tests/auto/qml/qqmlengine/data/testVMEPropertyEmptyComponent.1.qml index c6f0b7928b..a87372cd27 100644 --- a/tests/auto/qml/qqmlengine/data/testVMEPropertyEmptyComponent.1.qml +++ b/tests/auto/qml/qqmlengine/data/testVMEPropertyEmptyComponent.1.qml @@ -2,6 +2,7 @@ import QtQuick 2.0 Item { property bool success: false + required property QtObject componentCache function reportError(s) { console.warn(s) } diff --git a/tests/auto/qml/qqmlengine/data/testVMEPropertyEmptyComponent.2.qml b/tests/auto/qml/qqmlengine/data/testVMEPropertyEmptyComponent.2.qml index 255138520c..c4b16d8ec9 100644 --- a/tests/auto/qml/qqmlengine/data/testVMEPropertyEmptyComponent.2.qml +++ b/tests/auto/qml/qqmlengine/data/testVMEPropertyEmptyComponent.2.qml @@ -2,6 +2,7 @@ import QtQuick 2.0 Item { property bool success: false + required property QtObject componentCache function reportError(s) { console.warn(s) } diff --git a/tests/auto/qml/qqmlengine/data/testVMEPropertyVMEComponent.1.qml b/tests/auto/qml/qqmlengine/data/testVMEPropertyVMEComponent.1.qml index 0ad59b32d3..a18a88884c 100644 --- a/tests/auto/qml/qqmlengine/data/testVMEPropertyVMEComponent.1.qml +++ b/tests/auto/qml/qqmlengine/data/testVMEPropertyVMEComponent.1.qml @@ -2,6 +2,7 @@ import QtQuick 2.0 Item { property bool success: false + required property QtObject componentCache function reportError(s) { console.warn(s) } diff --git a/tests/auto/qml/qqmlengine/data/testVMEPropertyVMEComponent.2.qml b/tests/auto/qml/qqmlengine/data/testVMEPropertyVMEComponent.2.qml index 60f72a92fe..eb042e82f8 100644 --- a/tests/auto/qml/qqmlengine/data/testVMEPropertyVMEComponent.2.qml +++ b/tests/auto/qml/qqmlengine/data/testVMEPropertyVMEComponent.2.qml @@ -2,6 +2,7 @@ import QtQuick 2.0 Item { property bool success: false + required property QtObject componentCache function reportError(s) { console.warn(s) } diff --git a/tests/auto/qml/qqmlengine/data/testVMETransientEmptyComponent.1.qml b/tests/auto/qml/qqmlengine/data/testVMETransientEmptyComponent.1.qml index 6c7f959f49..1f97e587e0 100644 --- a/tests/auto/qml/qqmlengine/data/testVMETransientEmptyComponent.1.qml +++ b/tests/auto/qml/qqmlengine/data/testVMETransientEmptyComponent.1.qml @@ -2,6 +2,7 @@ import QtQuick 2.0 Item { property bool success: false + required property QtObject componentCache function reportError(s) { console.warn(s) } diff --git a/tests/auto/qml/qqmlengine/data/testVMETransientEmptyComponent.2.qml b/tests/auto/qml/qqmlengine/data/testVMETransientEmptyComponent.2.qml index 86060c3998..794686494b 100644 --- a/tests/auto/qml/qqmlengine/data/testVMETransientEmptyComponent.2.qml +++ b/tests/auto/qml/qqmlengine/data/testVMETransientEmptyComponent.2.qml @@ -2,6 +2,7 @@ import QtQuick 2.0 Item { property bool success: false + required property QtObject componentCache function reportError(s) { console.warn(s) } diff --git a/tests/auto/qml/qqmlengine/data/testVMETransientVMEComponent.1.qml b/tests/auto/qml/qqmlengine/data/testVMETransientVMEComponent.1.qml index c50fd70dec..f442500c7f 100644 --- a/tests/auto/qml/qqmlengine/data/testVMETransientVMEComponent.1.qml +++ b/tests/auto/qml/qqmlengine/data/testVMETransientVMEComponent.1.qml @@ -2,6 +2,7 @@ import QtQuick 2.0 Item { property bool success: false + required property QtObject componentCache function reportError(s) { console.warn(s) } diff --git a/tests/auto/qml/qqmlengine/data/testVMETransientVMEComponent.2.qml b/tests/auto/qml/qqmlengine/data/testVMETransientVMEComponent.2.qml index 120d249bc0..d57cd8a739 100644 --- a/tests/auto/qml/qqmlengine/data/testVMETransientVMEComponent.2.qml +++ b/tests/auto/qml/qqmlengine/data/testVMETransientVMEComponent.2.qml @@ -2,6 +2,7 @@ import QtQuick 2.0 Item { property bool success: false + required property QtObject componentCache function reportError(s) { console.warn(s) } diff --git a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp index aae42e9ebb..de99e8c37d 100644 --- a/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp +++ b/tests/auto/qml/qqmlengine/tst_qqmlengine.cpp @@ -424,12 +424,13 @@ void tst_qqmlengine::trimComponentCache() QQmlEngine engine; ComponentCacheFunctions componentCache(engine); - engine.rootContext()->setContextProperty("componentCache", &componentCache); engine.setIncubationController(&componentCache); QQmlComponent component(&engine, testFileUrl(file)); QVERIFY2(component.isReady(), qPrintable(component.errorString())); - QScopedPointer<QObject> object(component.create()); + QScopedPointer<QObject> object(component.createWithInitialProperties({ + {"componentCache", QVariant::fromValue(&componentCache)} + })); QVERIFY(object != nullptr); QCOMPARE(object->property("success").toBool(), true); } @@ -511,6 +512,7 @@ void tst_qqmlengine::failedCompilation() QQmlEngine engine; QQmlComponent component(&engine, testFileUrl(file)); + QTest::ignoreMessage(QtMsgType::QtWarningMsg, "QQmlComponent: Component is not ready"); QVERIFY(!component.isReady()); QScopedPointer<QObject> object(component.create()); QVERIFY(object.isNull()); @@ -601,11 +603,10 @@ void tst_qqmlengine::objectOwnership() { QQmlEngine engine; QQmlComponent c(&engine); - engine.rootContext()->setContextProperty("test", this); QQmlEngine::setObjectOwnership(ptr, QQmlEngine::JavaScriptOwnership); - c.setData("import QtQuick 2.0; Item { property int data: test.createAQObjectForOwnershipTest() ? 0 : 1 }", QUrl()); + c.setData("import QtQuick 2.0; Item { required property QtObject test; property int data: test.createAQObjectForOwnershipTest() ? 0 : 1 }", QUrl()); QVERIFY(c.isReady()); - QObject *o = c.create(); + QObject *o = c.createWithInitialProperties( {{"test", QVariant::fromValue(this)}} ); QVERIFY(o != nullptr); } QTRY_VERIFY(spy.count()); @@ -616,13 +617,13 @@ void tst_qqmlengine::objectOwnership() { QQmlEngine engine; QQmlComponent c(&engine); - engine.rootContext()->setContextProperty("test", ptr); QQmlEngine::setObjectOwnership(ptr, QQmlEngine::JavaScriptOwnership); - c.setData("import QtQuick 2.0; QtObject { property var object: { var i = test; test ? 0 : 1 } }", QUrl()); + c.setData("import QtQuick 2.0; QtObject { required property QtObject test; property var object: { var i = test; test ? 0 : 1 } }", QUrl()); QVERIFY(c.isReady()); - QObject *o = c.create(); + QObject *o = c.createWithInitialProperties({{"test", QVariant::fromValue(ptr)}}); QVERIFY(o != nullptr); - engine.rootContext()->setContextProperty("test", nullptr); + QQmlProperty testProp(o, "test"); + testProp.write(QVariant::fromValue<QObject*>(nullptr)); } QTRY_VERIFY(spy.count()); } @@ -772,6 +773,7 @@ public: }; Q_DECLARE_METATYPE(QList<QQmlAbstractUrlInterceptor::DataType>); + void tst_qqmlengine::urlInterceptor_data() { QTest::addColumn<QUrl>("testFile"); @@ -940,14 +942,15 @@ void tst_qqmlengine::cppSignalAndEval() { ObjectCaller objectCaller; QQmlEngine engine; - engine.rootContext()->setContextProperty(QLatin1String("CallerCpp"), &objectCaller); + qmlRegisterSingletonInstance("Test", 1, 0, "CallerCpp", &objectCaller); QQmlComponent c(&engine); c.setData("import QtQuick 2.9\n" + "import Test 1.0\n" "Item {\n" " property var r: 0\n" " Connections {\n" " target: CallerCpp;\n" - " onDoubleReply: {\n" + " function onDoubleReply() {\n" " eval('var z = 1');\n" " r = a;\n" " }\n" |