diff options
Diffstat (limited to 'tests')
8 files changed, 149 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp index 7ebe0bac52..a15c00ad62 100644 --- a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp +++ b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp @@ -41,6 +41,7 @@ #include <QtCore/private/qobject_p.h> #include "../../shared/util.h" #include "qobject.h" +#include <QtQml/QQmlPropertyMap> #include <QDebug> class MyQmlObject : public QObject @@ -155,6 +156,8 @@ private slots: void floatToStringPrecision(); void copy(); + + void nestedQQmlPropertyMap(); private: QQmlEngine engine; }; @@ -2209,6 +2212,24 @@ void tst_qqmlproperty::initTestCase() qmlRegisterType<MyContainer>("Test",1,0,"MyContainer"); } +void tst_qqmlproperty::nestedQQmlPropertyMap() +{ + QQmlPropertyMap mainPropertyMap; + QQmlPropertyMap nestedPropertyMap; + QQmlPropertyMap deeplyNestedPropertyMap; + + mainPropertyMap.insert("nesting1", QVariant::fromValue(&nestedPropertyMap)); + nestedPropertyMap.insert("value", 42); + nestedPropertyMap.insert("nesting2", QVariant::fromValue(&deeplyNestedPropertyMap)); + deeplyNestedPropertyMap.insert("value", "success"); + + QQmlProperty value{&mainPropertyMap, "nesting1.value"}; + QCOMPARE(value.read().toInt(), 42); + + QQmlProperty success{&mainPropertyMap, "nesting1.nesting2.value"}; + QCOMPARE(success.read().toString(), QLatin1String("success")); +} + QTEST_MAIN(tst_qqmlproperty) #include "tst_qqmlproperty.moc" diff --git a/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp b/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp index ee43e5e06a..f1288c2dbe 100644 --- a/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp +++ b/tests/auto/quick/qquickdrag/tst_qquickdrag.cpp @@ -143,6 +143,7 @@ private slots: void source(); void recursion_data(); void recursion(); + void noCrashWithImageProvider(); private: QQmlEngine engine; @@ -1279,6 +1280,30 @@ void tst_QQuickDrag::recursion() } } +void tst_QQuickDrag::noCrashWithImageProvider() +{ + // QTBUG-72045 + QQmlComponent component(&engine); + component.setData( + R"( + import QtQuick 2.9 + Item { + Rectangle { + id: item + width: 50 + height: 50 + anchors.centerIn: parent + color: "orange" + Component.onCompleted: { + item.Drag.imageSource = "image://kill/me" + } + } + })", QUrl()); + QScopedPointer<QObject> object(component.create()); + QQuickItem *item = qobject_cast<QQuickItem *>(object.data()); + QVERIFY(item); +} + QTEST_MAIN(tst_QQuickDrag) diff --git a/tests/auto/quick/qquickitem/data/setParentInWindowChange.qml b/tests/auto/quick/qquickitem/data/setParentInWindowChange.qml new file mode 100644 index 0000000000..d68b7adb72 --- /dev/null +++ b/tests/auto/quick/qquickitem/data/setParentInWindowChange.qml @@ -0,0 +1,12 @@ +import QtQuick 2.12 + +Rectangle { + width: 800 + height: 600 + Item { + id: it + onWindowChanged: () => it.parent = newParent + } + + Item { id: newParent } +} diff --git a/tests/auto/quick/qquickitem/tst_qquickitem.cpp b/tests/auto/quick/qquickitem/tst_qquickitem.cpp index b6e40d5117..8aab13e095 100644 --- a/tests/auto/quick/qquickitem/tst_qquickitem.cpp +++ b/tests/auto/quick/qquickitem/tst_qquickitem.cpp @@ -197,6 +197,8 @@ private slots: void qtBug60123(); #endif + void setParentCalledInOnWindowChanged(); + private: enum PaintOrderOp { @@ -2146,6 +2148,12 @@ void tst_qquickitem::qtBug60123() activateWindowAndTestPress(&window); } #endif +void tst_qquickitem::setParentCalledInOnWindowChanged() +{ + QQuickView view; + view.setSource(testFileUrl("setParentInWindowChange.qml")); + QVERIFY(ensureFocus(&view)); // should not crash +} QTEST_MAIN(tst_qquickitem) diff --git a/tests/auto/quick/qquicklayouts/data/tst_gridlayout.qml b/tests/auto/quick/qquicklayouts/data/tst_gridlayout.qml index 49838c4fd5..e8b3960486 100644 --- a/tests/auto/quick/qquicklayouts/data/tst_gridlayout.qml +++ b/tests/auto/quick/qquicklayouts/data/tst_gridlayout.qml @@ -1019,5 +1019,59 @@ Item { waitForRendering(layout); verify(layout.children[1].visible == false); } + + + + Component { + id: gridlayout_propertyChanges_Component + GridLayout { + columns: 1 + property alias spy : signalSpy + SignalSpy { + id: signalSpy + target: parent + } + } + } + + Component { + id: rowlayout_propertyChanges_Component + RowLayout { + property alias spy : signalSpy + SignalSpy { + id: signalSpy + target: parent + } + } + } + + function test_propertyChanges_data() + { + let data = [ + { tag: "columnSpacing", value: 9 }, + { tag: "rowSpacing", value: 9 }, + { tag: "columns", value: 2 }, + { tag: "rows", value: 2 }, + { tag: "flow", value: GridLayout.TopToBottom}, + { tag: "layoutDirection", value: Qt.RightToLeft }, + { tag: "spacing", value: 9 } + ] + return data + } + + function test_propertyChanges(data) + { + var propName = data.tag + var layout = createTemporaryObject(propName === "spacing" + ? rowlayout_propertyChanges_Component + : gridlayout_propertyChanges_Component + , container) + + layout.spy.signalName = propName + "Changed" + verify(layout.spy.valid) + + layout[propName] = data.value + compare(layout.spy.count, 1) + } } } diff --git a/tests/auto/quick/qquickloader/data/CacheClearTest.qml b/tests/auto/quick/qquickloader/data/CacheClearTest.qml new file mode 100644 index 0000000000..acab79f96e --- /dev/null +++ b/tests/auto/quick/qquickloader/data/CacheClearTest.qml @@ -0,0 +1,4 @@ +import QtQml 2.12 +QtObject { + property int i: 42 +} diff --git a/tests/auto/quick/qquickloader/data/initialPropertyValues.11.qml b/tests/auto/quick/qquickloader/data/initialPropertyValues.11.qml new file mode 100644 index 0000000000..ddc874d14c --- /dev/null +++ b/tests/auto/quick/qquickloader/data/initialPropertyValues.11.qml @@ -0,0 +1,20 @@ +import QtQuick 2.0 + +Item { + id: root + property int oldi: 0 + property int i: 0 + + Loader { + id: loader + objectName: "loader" + active: true + } + + Component.onCompleted: { + loader.setSource("CacheClearTest.qml", {i: 12}) + root.oldi = loader.item.i + loader.setSource("CacheClearTest.qml") + root.i = loader.item.i // should be 42 + } +} diff --git a/tests/auto/quick/qquickloader/tst_qquickloader.cpp b/tests/auto/quick/qquickloader/tst_qquickloader.cpp index fbdd87905b..d0a1a8a45b 100644 --- a/tests/auto/quick/qquickloader/tst_qquickloader.cpp +++ b/tests/auto/quick/qquickloader/tst_qquickloader.cpp @@ -681,6 +681,11 @@ void tst_QQuickLoader::initialPropertyValues_data() << QStringList() << (QStringList() << "initialValue") << (QVariantList() << 6); + + QTest::newRow("source url changed, previously initial properties are discared") << testFileUrl("initialPropertyValues.11.qml") + << QStringList() + << (QStringList() << "oldi" << "i") + << (QVariantList() << 12 << 42); } void tst_QQuickLoader::initialPropertyValues() |