summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJoona Petrell <joona.t.petrell@nokia.com>2010-07-20 15:14:11 +1000
committerToby Tomkins <toby.tomkins@nokia.com>2010-07-26 14:10:01 +1000
commitfb065bb1ca4c49194e8a936ec0babba04f8471a1 (patch)
treedb81336dd844ec5b30277d1c29f2c25dabe393cf /tests
parentd28dcae97d2244906d1e2c21f38dc1d33396004a (diff)
Rewinding AnchorChanges should not make target item's implicit width and height explicit
Task-number: QTBUG-12273 Reviewed-by: Michael Brasser (cherry picked from commit 164b2b54922d87a44a60efe6dbbe2fa3b7716820)
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qdeclarativestates/data/anchorRewindBug.qml37
-rw-r--r--tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp35
2 files changed, 72 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativestates/data/anchorRewindBug.qml b/tests/auto/declarative/qdeclarativestates/data/anchorRewindBug.qml
new file mode 100644
index 0000000000..e6b602013e
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativestates/data/anchorRewindBug.qml
@@ -0,0 +1,37 @@
+import Qt 4.7
+Rectangle {
+ id: container
+ color: "red"
+ height: 200
+ width: 200
+ Column {
+ id: column
+ objectName: "column"
+ anchors.left: container.right
+ anchors.bottom: container.bottom
+
+ Rectangle {
+ id: rectangle
+ color: "blue"
+ height: 100
+ width: 200
+ }
+ Rectangle {
+ color: "blue"
+ height: 100
+ width: 200
+ }
+ }
+ states: State {
+ name: "reanchored"
+ AnchorChanges {
+ target: column
+ anchors.left: undefined
+ anchors.right: container.right
+ }
+ PropertyChanges {
+ target: rectangle
+ opacity: 0
+ }
+ }
+} \ No newline at end of file
diff --git a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp
index 639b2f38c3..7bc4fd4b5d 100644
--- a/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp
+++ b/tests/auto/declarative/qdeclarativestates/tst_qdeclarativestates.cpp
@@ -121,6 +121,7 @@ private slots:
void anchorChanges4();
void anchorChanges5();
void anchorChangesCrash();
+ void anchorRewindBug();
void script();
void restoreEntryValues();
void explicitChanges();
@@ -807,6 +808,40 @@ void tst_qdeclarativestates::anchorChangesCrash()
delete rect;
}
+// QTBUG-12273
+void tst_qdeclarativestates::anchorRewindBug()
+{
+ QDeclarativeEngine engine;
+
+ QDeclarativeComponent rectComponent(&engine, SRCDIR "/data/anchorRewindBug.qml");
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QDeclarativeItem * column = rect->findChild<QDeclarativeItem*>("column");
+
+ QVERIFY(column != 0);
+ QVERIFY(!QDeclarativeItemPrivate::get(column)->heightValid);
+ QVERIFY(!QDeclarativeItemPrivate::get(column)->widthValid);
+ QCOMPARE(column->height(), 200.0);
+ QDeclarativeItemPrivate::get(rect)->setState("reanchored");
+
+ // column height and width should stay implicit
+ // and column's implicit resizing should still work
+ QVERIFY(!QDeclarativeItemPrivate::get(column)->heightValid);
+ QVERIFY(!QDeclarativeItemPrivate::get(column)->widthValid);
+ QCOMPARE(column->height(), 100.0);
+
+ QDeclarativeItemPrivate::get(rect)->setState("");
+
+ // column height and width should stay implicit
+ // and column's implicit resizing should still work
+ QVERIFY(!QDeclarativeItemPrivate::get(column)->heightValid);
+ QVERIFY(!QDeclarativeItemPrivate::get(column)->widthValid);
+ QCOMPARE(column->height(), 200.0);
+
+ delete rect;
+}
+
void tst_qdeclarativestates::script()
{
QDeclarativeEngine engine;