diff options
author | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2023-10-11 16:01:30 +0300 |
---|---|---|
committer | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2023-10-11 16:01:30 +0300 |
commit | 105e610548a62d943301153afb337a49f14e9e25 (patch) | |
tree | 34d8e322f1161f4a8eafabdbc721af42ea960075 /tests | |
parent | 960a980dc885622cb84990c4da75d5060318302d (diff) | |
parent | 94fd52dbb83a4982e4a70e621f431b0bd0945b5d (diff) |
Merge remote-tracking branch 'origin/tqtc/lts-5.15.12' into tqtc/lts-5.15-opensourcev5.15.12-lts-lgpl
Change-Id: Ia60d01835108b0a461791e56388eb3dfe90649e2
Diffstat (limited to 'tests')
12 files changed, 580 insertions, 0 deletions
diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp index c66e2dccf3..363070d7f8 100644 --- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp +++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp @@ -260,6 +260,7 @@ private slots: void sortNonStringArray(); void iterateInvalidProxy(); void applyOnHugeArray(); + void reflectApplyOnHugeArray(); void tostringRecursionCheck(); void arrayIncludesWithLargeArray(); @@ -5174,6 +5175,22 @@ void tst_QJSEngine::applyOnHugeArray() QCOMPARE(value.toString(), "RangeError: Array too large for apply()."); } + +void tst_QJSEngine::reflectApplyOnHugeArray() +{ + QQmlEngine engine; + const QJSValue value = engine.evaluate(R"( +(function(){ +const v1 = []; +const v3 = []; +v3.length = 3900000000; +Reflect.apply(v1.reverse,v1,v3); +})() + )"); + QVERIFY(value.isError()); + QCOMPARE(value.toString(), QLatin1String("RangeError: Invalid array length.")); +} + void tst_QJSEngine::typedArraySet() { QJSEngine engine; diff --git a/tests/auto/qml/qqmllanguage/data/alias.15a.qml b/tests/auto/qml/qqmllanguage/data/alias.15a.qml index ba8097c997..b5f96e15c1 100644 --- a/tests/auto/qml/qqmllanguage/data/alias.15a.qml +++ b/tests/auto/qml/qqmllanguage/data/alias.15a.qml @@ -9,4 +9,25 @@ Item { Item { id: symbol } + + Rectangle { + id: txtElevationValue + + property Rectangle background: Rectangle { } + + state: "ValidatorInvalid" + + states: [ + State { + name: "ValidatorInvalid" + PropertyChanges { + target: txtElevationValue + background.border.color: "red" // this line caused the segfault in qtbug107795 + } + }, + State { + name: "ValidatorAcceptable" + } + ] + } } diff --git a/tests/auto/qml/qqmllanguage/data/badGroupedProperty.qml b/tests/auto/qml/qqmllanguage/data/badGroupedProperty.qml new file mode 100644 index 0000000000..34dcbf96fa --- /dev/null +++ b/tests/auto/qml/qqmllanguage/data/badGroupedProperty.qml @@ -0,0 +1,10 @@ +import QtQml 2.15 + +QtObject { + id: testItem + property rect rect + onComplete { + rect.x: 2 + rect.width: 22 + } +} diff --git a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp index 1be1533b63..ac6634290a 100644 --- a/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp +++ b/tests/auto/qml/qqmllanguage/tst_qqmllanguage.cpp @@ -341,6 +341,7 @@ private slots: void ambiguousContainingType(); void staticConstexprMembers(); void bindingAliasToComponentUrl(); + void badGroupedProperty(); private: QQmlEngine engine; @@ -5939,6 +5940,17 @@ void tst_qqmllanguage::bindingAliasToComponentUrl() } } +void tst_qqmllanguage::badGroupedProperty() +{ + QQmlEngine engine; + const QUrl url = testFileUrl("badGroupedProperty.qml"); + QQmlComponent c(&engine, url); + QVERIFY(c.isError()); + QCOMPARE(c.errorString(), + QStringLiteral("%1:6 Cannot assign to non-existent property \"onComplete\"\n") + .arg(url.toString())); +} + QTEST_MAIN(tst_qqmllanguage) #include "tst_qqmllanguage.moc" diff --git a/tests/auto/quick/qquickanimations/BLACKLIST b/tests/auto/quick/qquickanimations/BLACKLIST new file mode 100644 index 0000000000..6c1bec6520 --- /dev/null +++ b/tests/auto/quick/qquickanimations/BLACKLIST @@ -0,0 +1,3 @@ +# See qtbase/src/testlib/qtestblacklist.cpp for format +[reparent] +ci macos # QTBUG-108880 diff --git a/tests/auto/quick/qquickbehaviors/BLACKLIST b/tests/auto/quick/qquickbehaviors/BLACKLIST new file mode 100644 index 0000000000..d2a11a6a32 --- /dev/null +++ b/tests/auto/quick/qquickbehaviors/BLACKLIST @@ -0,0 +1,3 @@ +# See qtbase/src/testlib/qtestblacklist.cpp for format +[currentValue] +ci macos # QTBUG-108258 diff --git a/tests/auto/quick/qquicklayouts/data/tst_stacklayout.qml b/tests/auto/quick/qquicklayouts/data/tst_stacklayout.qml index de335386cf..2536b9789f 100644 --- a/tests/auto/quick/qquicklayouts/data/tst_stacklayout.qml +++ b/tests/auto/quick/qquicklayouts/data/tst_stacklayout.qml @@ -51,6 +51,7 @@ import QtQuick 2.2 import QtTest 1.0 import QtQuick.Layouts 1.3 +import QtQuick.Window 2.1 Item { id: container @@ -153,5 +154,417 @@ Item { compare(layout.secondItem.width, 200) // width should not be -1 layout.destroy() } + + function geometry(item) { + return [item.x, item.y, item.width, item.height] + } + + Component { + id: countGeometryChanges_Component + StackLayout { + id: stack + property alias col: _col + property alias row: _row + width: 100 + ColumnLayout { + id: _col + property alias r1: _r1 + property alias r2: _r2 + property alias r3: _r3 + spacing: 0 + property int counter : 0 + onWidthChanged: { ++counter; } + Rectangle { + id: _r1 + implicitWidth: 20 + implicitHeight: 20 + Layout.fillWidth: true + property int counter : 0 + onWidthChanged: { ++counter; } + } + Rectangle { + id: _r2 + implicitWidth: 50 + implicitHeight: 50 + Layout.fillWidth: true + property int counter : 0 + onWidthChanged: { ++counter; } + } + Rectangle { + id: _r3 + implicitWidth: 40 + implicitHeight: 40 + Layout.fillWidth: true + property int counter : 0 + onWidthChanged: { ++counter; } + } + } + RowLayout { + id: _row + property alias r5: _r5 + spacing: 0 + property int counter : 0 + onWidthChanged: { ++counter; } + Rectangle { + id: _r5 + implicitWidth: 100 + implicitHeight: 100 + Layout.fillWidth: true + property int counter : 0 + onWidthChanged: { ++counter; } + } + } + } + } + + function test_countGeometryChanges() { + + var stack = countGeometryChanges_Component.createObject(container) + compare(stack.currentIndex, 0) + compare(stack.col.width, 100) + compare(stack.col.height, 110) + compare(stack.row.width, 100) + compare(stack.row.height, 100) + verify(stack.col.r1.counter <= 2) + compare(stack.col.r2.counter, 1) + verify(stack.col.r3.counter <= 2) + verify(stack.col.counter <= 2) + compare(stack.row.counter, 1) // not visible, will only receive the initial geometry change + compare(stack.row.r5.counter, 0) + stack.destroy() + } + + + Component { + id: layoutItem_Component + Rectangle { + implicitWidth: 20 + implicitHeight: 20 + } + } + + Component { + id: emtpy_StackLayout_Component + StackLayout { + property int num_onCountChanged: 0 + property int num_onCurrentIndexChanged: 0 + onCountChanged: { ++num_onCountChanged; } + onCurrentIndexChanged: { ++num_onCurrentIndexChanged; } + } + } + + function test_addAndRemoveItems() + { + var stack = emtpy_StackLayout_Component.createObject(container) + stack.currentIndex = 2 + compare(stack.implicitWidth, 0) + compare(stack.implicitHeight, 0) + + var rect0 = layoutItem_Component.createObject(stack) + verify(waitForItemPolished(stack)) + compare(stack.implicitWidth, 20) + compare(stack.implicitHeight, 20) + compare(rect0.visible, false) + + var rect1 = layoutItem_Component.createObject(stack) + rect1.Layout.preferredWidth = 30 + rect1.Layout.preferredHeight = 10 + verify(waitForItemPolished(stack)) + compare(stack.implicitWidth, 30) + compare(stack.implicitHeight, 20) + compare(rect0.visible, false) + compare(rect1.visible, false) + + var rect2 = layoutItem_Component.createObject(stack) + rect2.x = 42 // ### items in a stacklayout will have their x and y positions discarded. + rect2.y = 42 + rect2.Layout.preferredWidth = 80 + rect2.Layout.preferredHeight = 30 + rect2.Layout.fillWidth = true + verify(waitForItemPolished(stack)) + compare(stack.implicitWidth, 80) + compare(stack.implicitHeight, 30) + compare(rect0.visible, false) + compare(rect1.visible, false) + compare(rect2.visible, true) + compare(geometry(rect2), geometry(stack)) + + rect2.destroy() + wait(0) + verify(waitForItemPolished(stack)) + compare(stack.implicitWidth, 30) + compare(stack.implicitHeight, 20) + + rect0.destroy() + wait(0) + verify(waitForItemPolished(stack)) + compare(stack.implicitWidth, 30) + compare(stack.implicitHeight, 10) + + rect1.destroy() + wait(0) + verify(waitForItemPolished(stack)) + compare(stack.implicitWidth, 0) + compare(stack.implicitHeight, 0) + + stack.destroy() + } + + function test_sizeHint_data() { + return [ + { tag: "propagateNone", layoutHints: [10, 20, 30], childHints: [11, 21, 31], expected:[10, 20, Number.POSITIVE_INFINITY]}, + { tag: "propagateMinimumWidth", layoutHints: [-1, 20, 30], childHints: [10, 21, 31], expected:[10, 20, Number.POSITIVE_INFINITY]}, + { tag: "propagatePreferredWidth", layoutHints: [10, -1, 30], childHints: [11, 20, 31], expected:[10, 20, Number.POSITIVE_INFINITY]}, + { tag: "propagateMaximumWidth", layoutHints: [10, 20, -1], childHints: [11, 21, 30], expected:[10, 20, Number.POSITIVE_INFINITY]}, + { tag: "propagateAll", layoutHints: [-1, -1, -1], childHints: [10, 20, 30], expected:[10, 20, Number.POSITIVE_INFINITY]}, + { tag: "propagateCrazy", layoutHints: [-1, -1, -1], childHints: [40, 21, 30], expected:[30, 30, Number.POSITIVE_INFINITY]}, + { tag: "expandMinToExplicitPref", layoutHints: [-1, 1, -1], childHints: [11, 21, 31], expected:[ 1, 1, Number.POSITIVE_INFINITY]}, + { tag: "expandMaxToExplicitPref", layoutHints: [-1, 99, -1], childHints: [11, 21, 31], expected:[11, 99, Number.POSITIVE_INFINITY]}, + { tag: "expandAllToExplicitMin", layoutHints: [99, -1, -1], childHints: [11, 21, 31], expected:[99, 99, Number.POSITIVE_INFINITY]}, + { tag: "expandPrefToExplicitMin", layoutHints: [24, -1, -1], childHints: [11, 21, 31], expected:[24, 24, Number.POSITIVE_INFINITY]}, + { tag: "boundPrefToExplicitMax", layoutHints: [-1, -1, 19], childHints: [11, 21, 31], expected:[11, 19, Number.POSITIVE_INFINITY]}, + { tag: "boundAllToExplicitMax", layoutHints: [-1, -1, 9], childHints: [11, 21, 31], expected:[ 9, 9, Number.POSITIVE_INFINITY]}, + ]; + } + + function itemSizeHints(item) { + return [item.Layout.minimumWidth, item.implicitWidth, item.Layout.maximumWidth] + } + Component { + id: stacklayout_sizeHint_Component + StackLayout { + property int implicitWidthChangedCount : 0 + onImplicitWidthChanged: { ++implicitWidthChangedCount } + ColumnLayout { + Rectangle { + id: r1 + color: "red" + Layout.minimumWidth: 1 + Layout.preferredWidth: 2 + Layout.maximumWidth: 3 + + Layout.minimumHeight: 20 + Layout.preferredHeight: 20 + Layout.maximumHeight: 20 + Layout.fillWidth: true + } + } + } + } + + function test_sizeHint(data) { + var layout = stacklayout_sizeHint_Component.createObject(container) + + var col = layout.children[0] + col.Layout.minimumWidth = data.layoutHints[0] + col.Layout.preferredWidth = data.layoutHints[1] + col.Layout.maximumWidth = data.layoutHints[2] + + var child = col.children[0] + if (data.implicitWidth !== undefined) { + child.implicitWidth = data.implicitWidth + } + child.Layout.minimumWidth = data.childHints[0] + child.Layout.preferredWidth = data.childHints[1] + child.Layout.maximumWidth = data.childHints[2] + + verify(waitForItemPolished(layout)) + var effectiveSizeHintResult = [layout.Layout.minimumWidth, layout.implicitWidth, layout.Layout.maximumWidth] + compare(effectiveSizeHintResult, data.expected) + layout.destroy() + } + + Component { + id: stacklayout_addIgnoredItem_Component + StackLayout { + Repeater { + id: rep + model: 1 + Rectangle { + id: r + } + } + } + } + + // Items with no size information is ignored. + function test_addIgnoredItem() + { + var stack = stacklayout_addIgnoredItem_Component.createObject(container) + compare(stack.count, 1) + compare(stack.implicitWidth, 0) + compare(stack.implicitHeight, 0) + var r = stack.children[0] + r.Layout.preferredWidth = 20 + r.Layout.preferredHeight = 30 + verify(waitForItemPolished(stack)) + compare(stack.count, 1) + compare(stack.implicitWidth, 20) + compare(stack.implicitHeight, 30) + stack.destroy(); + } + + function test_dontCrashWhenAnchoredToAWindow() { + var test_layoutStr = + 'import QtQuick 2.2; \ + import QtQuick.Window 2.1; \ + import QtQuick.Layouts 1.3; \ + Window { \ + visible: true; \ + width: stack.implicitWidth; \ + height: stack.implicitHeight; \ + StackLayout { \ + id: stack; \ + currentIndex: 0; \ + anchors.fill: parent; \ + Rectangle { \ + color: "red"; \ + implicitWidth: 300; \ + implicitHeight: 200; \ + } \ + } \ + } ' + + var win = Qt.createQmlObject(test_layoutStr, container, ''); + if (win.visibility === Window.Windowed) { + // on single-window systems (such as Android), the window geometry will be + // fullscreen, and most likely it will be set to screen size. Avoid this test for + // those systems, as the size of the window will not be determined by the layout + tryCompare(win, 'width', 300); + } + win.destroy() + } + + Component { + id: test_dontCrashWhenChildIsResizedToNull_Component + StackLayout { + property alias rect : _rect + Rectangle { + id: _rect; + color: "red" + implicitWidth: 200 + implicitHeight: 200 + } + } + } + + function test_dontCrashWhenChildIsResizedToNull() { + var layout = test_dontCrashWhenChildIsResizedToNull_Component.createObject(container) + layout.rect.width = 0 + layout.width = 222 // trigger a rearrange with a valid size + layout.height = 222 + } + + Component { + id: test_currentIndex_Component + StackLayout { + currentIndex: 1 + Text { + text: "0" + } + Text { + text: "1" + } + } + } + + function test_currentIndex() { + var layout = test_currentIndex_Component.createObject(container) + var c0 = layout.children[0] + var c1 = layout.children[1] + compare(layout.currentIndex, 1) + tryCompare(layout, 'visible', true) + compare(c0.visible, false) + compare(c1.visible, true) + layout.currentIndex = 0 + compare(c0.visible, true) + compare(c1.visible, false) + var c2 = layoutItem_Component.createObject(layout) + compare(c2.visible, false) + + /* + * destroy the current item and check if visibility advances to next + */ + c0.destroy() + tryCompare(c1, 'visible', true) + compare(c2.visible, false) + c1.destroy() + tryCompare(c2, 'visible', true) + c2.destroy() + tryCompare(layout, 'currentIndex', 0) + + layout.destroy() + + /* + * Test the default/implicit value of currentIndex, either -1 (if empty) or 0: + */ + layout = emtpy_StackLayout_Component.createObject(container) + tryCompare(layout, 'visible', true) + compare(layout.currentIndex, -1) + compare(layout.num_onCurrentIndexChanged, 0) + // make it non-empty + c0 = layoutItem_Component.createObject(layout) + compare(layout.currentIndex, 0) + compare(layout.num_onCurrentIndexChanged, 1) + compare(c0.visible, true) + // make it empty again + c0.destroy() + wait(0) + compare(layout.currentIndex, -1) + //tryCompare(layout, 'currentIndex', -1) + compare(layout.num_onCurrentIndexChanged, 2) + + /* + * Check that explicit value doesn't change, + * and that no items are visible if the index is invalid/out of range + */ + layout.currentIndex = 2 + compare(layout.currentIndex, 2) + compare(layout.num_onCurrentIndexChanged, 3) + c0 = layoutItem_Component.createObject(layout) + compare(layout.currentIndex, 2) + compare(c0.visible, false) + + c1 = layoutItem_Component.createObject(layout) + compare(layout.currentIndex, 2) + compare(c0.visible, false) + compare(c1.visible, false) + + c2 = layoutItem_Component.createObject(layout) + compare(layout.currentIndex, 2) + compare(c0.visible, false) + compare(c1.visible, false) + compare(c2.visible, true) + + c2.destroy() + wait(0) + compare(layout.currentIndex, 2) + compare(c0.visible, false) + compare(c1.visible, false) + c1.destroy() + wait(0) + compare(layout.currentIndex, 2) + compare(c0.visible, false) + c0.destroy() + wait(0) + compare(layout.currentIndex, 2) + compare(layout.num_onCurrentIndexChanged, 3) + } + + function test_count() { + var layout = emtpy_StackLayout_Component.createObject(container) + tryCompare(layout, 'visible', true) + compare(layout.count, 0) + compare(layout.currentIndex, -1) + compare(layout.num_onCountChanged, 0) + compare(layout.num_onCurrentIndexChanged, 0) + var c0 = layoutItem_Component.createObject(layout) + compare(layout.count, 1) + compare(layout.currentIndex, 0) + compare(layout.num_onCurrentIndexChanged, 1) + compare(layout.num_onCountChanged, 1) + } + + } } diff --git a/tests/auto/quick/qquickloader/data/overflow.qml b/tests/auto/quick/qquickloader/data/overflow.qml new file mode 100644 index 0000000000..8ca196e2ed --- /dev/null +++ b/tests/auto/quick/qquickloader/data/overflow.qml @@ -0,0 +1,5 @@ +import QtQuick 2.15 + +Loader { + source: "overflow.qml" +} diff --git a/tests/auto/quick/qquickloader/tst_qquickloader.cpp b/tests/auto/quick/qquickloader/tst_qquickloader.cpp index db678ae5a1..4539a89cb3 100644 --- a/tests/auto/quick/qquickloader/tst_qquickloader.cpp +++ b/tests/auto/quick/qquickloader/tst_qquickloader.cpp @@ -134,6 +134,8 @@ private slots: void setSourceAndCheckStatus(); void asyncLoaderRace(); void noEngine(); + + void stackOverflow(); }; Q_DECLARE_METATYPE(QList<QQmlError>) @@ -1530,6 +1532,17 @@ void tst_QQuickLoader::noEngine() QTRY_COMPARE(o->property("changes").toInt(), 1); } +void tst_QQuickLoader::stackOverflow() +{ + QQmlEngine engine; + const QUrl url = testFileUrl("overflow.qml"); + QQmlComponent component(&engine, url); + QVERIFY2(component.isReady(), qPrintable(component.errorString())); + const QString message = url.toString() + QStringLiteral(": Maximum call stack size exceeded."); + QTest::ignoreMessage(QtCriticalMsg, qPrintable(message)); + QScopedPointer<QObject> o(component.create()); +} + QTEST_MAIN(tst_QQuickLoader) #include "tst_qquickloader.moc" diff --git a/tests/auto/quick/qquickvisualdatamodel/data/setDelegateNoDoubleChange.qml b/tests/auto/quick/qquickvisualdatamodel/data/setDelegateNoDoubleChange.qml new file mode 100644 index 0000000000..05623fbc5b --- /dev/null +++ b/tests/auto/quick/qquickvisualdatamodel/data/setDelegateNoDoubleChange.qml @@ -0,0 +1,43 @@ +import QtQuick 2.0 + +Item { + width: 200 + height: 200 + id: root + property int creationCount: 0 + property bool testStarted: false + + ListModel { + id: mymodel + ListElement {message: "This is my alarm"} + } + + Component { + id: aDelegate + Rectangle { + color: "blue" + width: 100 + height: 100 + } + } + + Component { + id: bDelegate + Rectangle { + color: "red" + width: 100 + height: 100 + Text {text: model.message } + Component.onCompleted: root.creationCount++ + } + } + + + ListView { + width: 200 + height: 200 + id: myListView + model: mymodel + delegate: testStarted ? bDelegate : aDelegate + } +} diff --git a/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp b/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp index 27bd8aae49..83bdb1a5f8 100644 --- a/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp +++ b/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp @@ -434,6 +434,7 @@ private slots: void invalidContext(); void externalManagedModel(); void delegateModelChangeDelegate(); + void noDoubleDelegateUpdate(); void checkFilterGroupForDelegate(); void readFromProxyObject(); @@ -4345,6 +4346,20 @@ void tst_qquickvisualdatamodel::delegateModelChangeDelegate() QCOMPARE(visualModel->count(), 3); } +void tst_qquickvisualdatamodel::noDoubleDelegateUpdate() +{ + // changing a delegate only refreshes its instances once + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("setDelegateNoDoubleChange.qml")); + + QScopedPointer<QObject> root(component.create()); + QVERIFY(root); + + bool ok = root->setProperty("testStarted", true); + QVERIFY(ok); + QCOMPARE(root->property("creationCount").toInt(), 1); +} + void tst_qquickvisualdatamodel::checkFilterGroupForDelegate() { QQuickView view; diff --git a/tests/baseline/scenegraph/data/text/text_nativerendering_no_antialiasing.qml b/tests/baseline/scenegraph/data/text/text_nativerendering_no_antialiasing.qml new file mode 100644 index 0000000000..92598eb490 --- /dev/null +++ b/tests/baseline/scenegraph/data/text/text_nativerendering_no_antialiasing.qml @@ -0,0 +1,25 @@ +import QtQuick 2.0 + +//vary font style, native rendering without antialiasing + +Item { + id: topLevel + width: 320 + height: 580 + + Repeater { + model: [Text.Normal, Text.Outline, Text.Raised, Text.Sunken] + Text { + y: 20 * index + clip: true + renderType: Text.NativeRendering + width: parent.width + wrapMode: Text.Wrap + font.pointSize: 10 + style: modelData + styleColor: "green" + antialiasing: false + text: "The quick fox jumps in style " + modelData + } + } +} |