diff options
Diffstat (limited to 'tests')
4 files changed, 38 insertions, 5 deletions
diff --git a/tests/auto/qml/qqmlobjectmodel/tst_qqmlobjectmodel.cpp b/tests/auto/qml/qqmlobjectmodel/tst_qqmlobjectmodel.cpp index 6ac0412ae5..fb63d811a8 100644 --- a/tests/auto/qml/qqmlobjectmodel/tst_qqmlobjectmodel.cpp +++ b/tests/auto/qml/qqmlobjectmodel/tst_qqmlobjectmodel.cpp @@ -47,18 +47,18 @@ static bool compareItems(QQmlObjectModel *model, const QObjectList &items) return true; } -static bool verifyChangeSet(const QQmlChangeSet &changeSet, int expectedInserts, int expectedRemoves, bool isMove) +static bool verifyChangeSet(const QQmlChangeSet &changeSet, int expectedInserts, int expectedRemoves, bool isMove, int moveId = -1) { int actualRemoves = 0; for (const QQmlChangeSet::Change &r : changeSet.removes()) { - if (r.isMove() != isMove) + if (r.isMove() != isMove && (!isMove || moveId == r.moveId)) return false; actualRemoves += r.count; } int actualInserts = 0; for (const QQmlChangeSet::Change &i : changeSet.inserts()) { - if (i.isMove() != isMove) + if (i.isMove() != isMove && (!isMove || moveId == i.moveId)) return false; actualInserts += i.count; } @@ -129,7 +129,7 @@ void tst_QQmlObjectModel::changes() QCOMPARE(countSpy.count(), countSignals); QCOMPARE(childrenSpy.count(), ++childrenSignals); QCOMPARE(modelUpdateSpy.count(), ++modelUpdateSignals); - QVERIFY(verifyChangeSet(modelUpdateSpy.last().first().value<QQmlChangeSet>(), 1, 1, true)); + QVERIFY(verifyChangeSet(modelUpdateSpy.last().first().value<QQmlChangeSet>(), 1, 1, true, 1)); // move(3, 2) -> [item0, item1, item2, item3] model.move(3, 2); items.move(3, 2); @@ -138,7 +138,7 @@ void tst_QQmlObjectModel::changes() QCOMPARE(countSpy.count(), countSignals); QCOMPARE(childrenSpy.count(), ++childrenSignals); QCOMPARE(modelUpdateSpy.count(), ++modelUpdateSignals); - QVERIFY(verifyChangeSet(modelUpdateSpy.last().first().value<QQmlChangeSet>(), 1, 1, true)); + QVERIFY(verifyChangeSet(modelUpdateSpy.last().first().value<QQmlChangeSet>(), 1, 1, true, 2)); // remove(0) -> [item1, item2, item3] model.remove(0); items.removeAt(0); diff --git a/tests/auto/quick/qquickbehaviors/data/ItemWithInnerBehavior.qml b/tests/auto/quick/qquickbehaviors/data/ItemWithInnerBehavior.qml new file mode 100644 index 0000000000..09983645ef --- /dev/null +++ b/tests/auto/quick/qquickbehaviors/data/ItemWithInnerBehavior.qml @@ -0,0 +1,10 @@ +import QtQuick 2.4 + +Item { + id: root + + property bool someValue + Behavior on someValue { + ScriptAction { script: { parent.behaviorTriggered = true }} + } +} diff --git a/tests/auto/quick/qquickbehaviors/data/overwrittenbehavior.qml b/tests/auto/quick/qquickbehaviors/data/overwrittenbehavior.qml new file mode 100644 index 0000000000..e627c45782 --- /dev/null +++ b/tests/auto/quick/qquickbehaviors/data/overwrittenbehavior.qml @@ -0,0 +1,14 @@ +import QtQuick 2.4 + +Item { + property bool behaviorTriggered + property bool someProperty + + ItemWithInnerBehavior { + //the existence of this property triggers the bug + property bool iDoAbsolutelyNothing + + Component.onCompleted: parent.someProperty = true + someValue: parent.someProperty + } +} diff --git a/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp b/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp index 80c76a377b..bdd53702e5 100644 --- a/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp +++ b/tests/auto/quick/qquickbehaviors/tst_qquickbehaviors.cpp @@ -72,6 +72,7 @@ private slots: void currentValue(); void disabledWriteWhileRunning(); void aliasedProperty(); + void innerBehaviorOverwritten(); }; void tst_qquickbehaviors::simpleBehavior() @@ -589,6 +590,14 @@ void tst_qquickbehaviors::aliasedProperty() //i.e. the behavior has been triggered } +void tst_qquickbehaviors::innerBehaviorOverwritten() +{ + QQmlEngine engine; + QQmlComponent c(&engine, testFileUrl("overwrittenbehavior.qml")); + QScopedPointer<QQuickItem> item(qobject_cast<QQuickItem*>(c.create())); + QVERIFY(item->property("behaviorTriggered").toBool()); +} + QTEST_MAIN(tst_qquickbehaviors) #include "tst_qquickbehaviors.moc" |