summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/auto/declarative/states/data/anchorChanges3.qml29
-rw-r--r--tests/auto/declarative/states/tst_states.cpp28
2 files changed, 57 insertions, 0 deletions
diff --git a/tests/auto/declarative/states/data/anchorChanges3.qml b/tests/auto/declarative/states/data/anchorChanges3.qml
new file mode 100644
index 0000000..8a74595
--- /dev/null
+++ b/tests/auto/declarative/states/data/anchorChanges3.qml
@@ -0,0 +1,29 @@
+import Qt 4.6
+
+Rectangle {
+ id: container
+ width: 200; height: 200
+ Rectangle {
+ id: myRect
+ objectName: "MyRect"
+ color: "green";
+ anchors.left: parent.left
+ anchors.right: rightGuideline.left
+ anchors.top: topGuideline.top
+ anchors.bottom: container.bottom
+ }
+ Item { id: leftGuideline; x: 10 }
+ Item { id: rightGuideline; x: 150 }
+ Item { id: topGuideline; y: 10 }
+ Item { id: bottomGuideline; y: 150 }
+ states: State {
+ name: "reanchored"
+ AnchorChanges {
+ target: myRect;
+ left: leftGuideline.left
+ right: container.right
+ top: container.top
+ bottom: bottomGuideline.bottom
+ }
+ }
+}
diff --git a/tests/auto/declarative/states/tst_states.cpp b/tests/auto/declarative/states/tst_states.cpp
index fe90191..4f8b9c2 100644
--- a/tests/auto/declarative/states/tst_states.cpp
+++ b/tests/auto/declarative/states/tst_states.cpp
@@ -484,6 +484,8 @@ void tst_states::anchorChanges()
rect->setState("");
QCOMPARE(innerRect->x(), qreal(5));
+
+ delete rect;
}
{
@@ -495,10 +497,36 @@ void tst_states::anchorChanges()
QVERIFY(innerRect != 0);
rect->setState("right");
+ QEXPECT_FAIL("", "QTBUG-5338", Continue);
QCOMPARE(innerRect->x(), qreal(150));
rect->setState("");
QCOMPARE(innerRect->x(), qreal(5));
+
+ delete rect;
+ }
+
+ {
+ QmlComponent rectComponent(&engine, SRCDIR "/data/anchorChanges3.qml");
+ QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QmlGraphicsRectangle *innerRect = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ rect->setState("reanchored");
+ QCOMPARE(innerRect->x(), qreal(10));
+ QCOMPARE(innerRect->y(), qreal(0));
+ QCOMPARE(innerRect->width(), qreal(190));
+ QCOMPARE(innerRect->height(), qreal(150));
+
+ rect->setState("");
+ QCOMPARE(innerRect->x(), qreal(0));
+ QCOMPARE(innerRect->y(), qreal(10));
+ QCOMPARE(innerRect->width(), qreal(150));
+ QCOMPARE(innerRect->height(), qreal(190));
+
+ delete rect;
}
}