diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2010-09-15 00:53:29 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2010-09-15 00:57:34 (GMT) |
commit | 8ab760b70e13318749bcc83e33b9a9b9a849a892 (patch) | |
tree | 890b756a675c5beab16a5233c58a7404182fe895 /tests/auto/declarative/qdeclarativestates | |
parent | 3f1b772d7ff2ccb216cc05ec08b82a9b8729802a (diff) | |
download | Qt-8ab760b70e13318749bcc83e33b9a9b9a849a892.zip Qt-8ab760b70e13318749bcc83e33b9a9b9a849a892.tar.gz Qt-8ab760b70e13318749bcc83e33b9a9b9a849a892.tar.bz2 |
Restore any absolute geometry changed by AnchorChanges when returning
to the base state.
Task-number: QTBUG-11834
Diffstat (limited to 'tests/auto/declarative/qdeclarativestates')
-rw-r--r-- | tests/auto/declarative/qdeclarativestates/data/anchorRewindBug2.qml | 25 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp | 27 |
2 files changed, 52 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativestates/data/anchorRewindBug2.qml b/tests/auto/declarative/qdeclarativestates/data/anchorRewindBug2.qml new file mode 100644 index 0000000..4ed2815 --- /dev/null +++ b/tests/auto/declarative/qdeclarativestates/data/anchorRewindBug2.qml @@ -0,0 +1,25 @@ +import Qt 4.7 + +Rectangle { + id: root + width:200; height:300 + + Rectangle { + id: rectangle + objectName: "mover" + color: "green" + width:50; height:50 + } + + states: [ + State { + name: "anchored" + AnchorChanges { + target: rectangle + anchors.left: root.left + anchors.right: root.right + anchors.bottom: root.bottom + } + } + ] +} diff --git a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp index 4a0ae30..f61ecf5 100644 --- a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp +++ b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp @@ -123,6 +123,7 @@ private slots: void anchorChanges5(); void anchorChangesCrash(); void anchorRewindBug(); + void anchorRewindBug2(); void script(); void restoreEntryValues(); void explicitChanges(); @@ -860,6 +861,32 @@ void tst_qdeclarativestates::anchorRewindBug() delete rect; } +// QTBUG-11834 +void tst_qdeclarativestates::anchorRewindBug2() +{ + QDeclarativeEngine engine; + + QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorRewindBug2.qml"); + QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create()); + QVERIFY(rect != 0); + + QDeclarativeRectangle *mover = rect->findChild<QDeclarativeRectangle*>("mover"); + + QVERIFY(mover != 0); + QCOMPARE(mover->y(), qreal(0.0)); + QCOMPARE(mover->width(), qreal(50.0)); + + QDeclarativeItemPrivate::get(rect)->setState("anchored"); + QCOMPARE(mover->y(), qreal(250.0)); + QCOMPARE(mover->width(), qreal(200.0)); + + QDeclarativeItemPrivate::get(rect)->setState(""); + QCOMPARE(mover->y(), qreal(0.0)); + QCOMPARE(mover->width(), qreal(50.0)); + + delete rect; +} + void tst_qdeclarativestates::script() { QDeclarativeEngine engine; |