aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2022-03-02 13:36:05 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-03-03 07:33:04 +0000
commitcf3534147f55ec5f3e5af1f206122c1a5b96ddd4 (patch)
tree00fe2700cf4ff54ba0a7957b1012d2f5f1b56622 /tests
parentd9a492469abb9bf6e3621e7a0630b5978e52de38 (diff)
QQuickAnchorChanges: Keep geometry bindings on reverse() and rewind()
This is in line with what we do in other reverse() and rewind() methods. Unfortunately we need to dig deep into the QQuickItem internals in order to get all the flags and callbacks right. Fixes: QTBUG-101186 Change-Id: Icde1a1b2dab1b9cab5adcbc28485a7526a8ac2b7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 247efb9a343a14bb12805e56e4950919071d9395) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/quick/qquickstates/data/anchorRewind.qml31
-rw-r--r--tests/auto/quick/qquickstates/tst_qquickstates.cpp24
2 files changed, 55 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickstates/data/anchorRewind.qml b/tests/auto/quick/qquickstates/data/anchorRewind.qml
new file mode 100644
index 0000000000..740c94cf42
--- /dev/null
+++ b/tests/auto/quick/qquickstates/data/anchorRewind.qml
@@ -0,0 +1,31 @@
+import QtQuick
+
+Item {
+ width: 400
+ height: 400
+ Item {
+ id: outer
+ anchors.fill: parent
+ Item {
+ id: inner
+ width: parent.width / 2
+ height: parent.height / 2
+ anchors.left: parent.right
+ anchors.top: parent.bottom
+ }
+ states: [
+ State {
+ when: true
+ AnchorChanges {
+ target: inner
+ anchors.left: outer.left
+ anchors.top: outer.top
+ }
+ }
+ ]
+ transitions: Transition {
+ AnchorAnimation {}
+ }
+ }
+}
+
diff --git a/tests/auto/quick/qquickstates/tst_qquickstates.cpp b/tests/auto/quick/qquickstates/tst_qquickstates.cpp
index 788b9c68ec..d6814bd057 100644
--- a/tests/auto/quick/qquickstates/tst_qquickstates.cpp
+++ b/tests/auto/quick/qquickstates/tst_qquickstates.cpp
@@ -206,6 +206,7 @@ private slots:
void bindableProperties();
void parentChangeInvolvingBindings();
void deferredProperties();
+ void rewindAnchorChange();
};
void tst_qquickstates::initTestCase()
@@ -1954,6 +1955,29 @@ void tst_qquickstates::deferredProperties()
QCOMPARE(root->height(), 100.0);
}
+void tst_qquickstates::rewindAnchorChange()
+{
+ QQmlEngine engine;
+ QQmlComponent c(&engine, testFileUrl("anchorRewind.qml"));
+ QVERIFY2(c.isReady(), qPrintable(c.errorString()));
+ QScopedPointer<QObject> root(c.create());
+ QVERIFY(root);
+
+ QQmlContext *context = qmlContext(root.data());
+ QVERIFY(context);
+
+ QObject *inner = context->objectForName(QStringLiteral("inner"));
+ QVERIFY(inner);
+
+ QQuickItem *innerRect = qobject_cast<QQuickItem *>(inner);
+ QVERIFY(innerRect);
+
+ QTRY_COMPARE(innerRect->x(), 0);
+ QTRY_COMPARE(innerRect->y(), 0);
+ QTRY_COMPARE(innerRect->width(), 200);
+ QTRY_COMPARE(innerRect->height(), 200);
+}
+
QTEST_MAIN(tst_qquickstates)
#include "tst_qquickstates.moc"