summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorYann Bodson <yann.bodson@nokia.com>2009-11-17 06:40:29 (GMT)
committerYann Bodson <yann.bodson@nokia.com>2009-11-17 06:40:29 (GMT)
commit00ba769bd417ff005a5e9854bfcc5dbd0acd9848 (patch)
treeac0d7116d50c0251f8d2551401bb16c6001b8e2d /tests
parentd4f2c30ba3ab70a3f40fb7699a6924c1155c83d3 (diff)
downloadQt-00ba769bd417ff005a5e9854bfcc5dbd0acd9848.zip
Qt-00ba769bd417ff005a5e9854bfcc5dbd0acd9848.tar.gz
Qt-00ba769bd417ff005a5e9854bfcc5dbd0acd9848.tar.bz2
AnchorChanges autotests
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/states/data/anchorChanges.qml4
-rw-r--r--tests/auto/declarative/states/data/anchorChanges2.qml4
-rw-r--r--tests/auto/declarative/states/data/anchorChanges3.qml28
-rw-r--r--tests/auto/declarative/states/data/anchorChanges4.qml22
-rw-r--r--tests/auto/declarative/states/data/anchorChanges5.qml22
-rw-r--r--tests/auto/declarative/states/tst_states.cpp183
6 files changed, 199 insertions, 64 deletions
diff --git a/tests/auto/declarative/states/data/anchorChanges.qml b/tests/auto/declarative/states/data/anchorChanges.qml
index 4afdee3..3d94f36 100644
--- a/tests/auto/declarative/states/data/anchorChanges.qml
+++ b/tests/auto/declarative/states/data/anchorChanges.qml
@@ -1,7 +1,7 @@
import Qt 4.6
Rectangle {
- id: container
+ id: Container
width: 200; height: 200
Rectangle {
id: myRect
@@ -17,7 +17,7 @@ Rectangle {
id: AncCh
target: myRect;
reset: "left"
- right: container.right
+ right: Container.right
}
}
}
diff --git a/tests/auto/declarative/states/data/anchorChanges2.qml b/tests/auto/declarative/states/data/anchorChanges2.qml
index 545345e..2e13628 100644
--- a/tests/auto/declarative/states/data/anchorChanges2.qml
+++ b/tests/auto/declarative/states/data/anchorChanges2.qml
@@ -3,7 +3,7 @@ import Qt 4.6
Rectangle {
width: 200; height: 200
Rectangle {
- id: myRect
+ id: MyRect
objectName: "MyRect"
width: 50; height: 50
color: "green";
@@ -13,7 +13,7 @@ Rectangle {
states: State {
name: "right"
AnchorChanges {
- target: myRect;
+ target: MyRect;
reset: "left"
right: parent.right
}
diff --git a/tests/auto/declarative/states/data/anchorChanges3.qml b/tests/auto/declarative/states/data/anchorChanges3.qml
index 8a74595..cf85472 100644
--- a/tests/auto/declarative/states/data/anchorChanges3.qml
+++ b/tests/auto/declarative/states/data/anchorChanges3.qml
@@ -1,29 +1,29 @@
import Qt 4.6
Rectangle {
- id: container
+ id: Container
width: 200; height: 200
Rectangle {
- id: myRect
+ id: MyRect
objectName: "MyRect"
color: "green";
anchors.left: parent.left
- anchors.right: rightGuideline.left
- anchors.top: topGuideline.top
- anchors.bottom: container.bottom
+ 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 }
+ Item { objectName: "LeftGuideline"; id: LeftGuideline; x: 10 }
+ Item { id: RightGuideline; x: 150 }
+ Item { id: TopGuideline; y: 10 }
+ Item { objectName: "BottomGuideline"; id: BottomGuideline; y: 150 }
states: State {
name: "reanchored"
AnchorChanges {
- target: myRect;
- left: leftGuideline.left
- right: container.right
- top: container.top
- bottom: bottomGuideline.bottom
+ target: MyRect;
+ left: LeftGuideline.left
+ right: Container.right
+ top: Container.top
+ bottom: BottomGuideline.bottom
}
}
}
diff --git a/tests/auto/declarative/states/data/anchorChanges4.qml b/tests/auto/declarative/states/data/anchorChanges4.qml
new file mode 100644
index 0000000..717f506
--- /dev/null
+++ b/tests/auto/declarative/states/data/anchorChanges4.qml
@@ -0,0 +1,22 @@
+import Qt 4.6
+
+Rectangle {
+ width: 200; height: 200
+ Rectangle {
+ id: MyRect
+ objectName: "MyRect"
+ color: "green";
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.verticalCenter: parent.verticalCenter
+ }
+ Item { objectName: "LeftGuideline"; id: LeftGuideline; x: 10 }
+ Item { objectName: "BottomGuideline"; id: BottomGuideline; y: 150 }
+ states: State {
+ name: "reanchored"
+ AnchorChanges {
+ target: MyRect;
+ horizontalCenter: BottomGuideline.horizontalCenter
+ verticalCenter: LeftGuideline.verticalCenter
+ }
+ }
+}
diff --git a/tests/auto/declarative/states/data/anchorChanges5.qml b/tests/auto/declarative/states/data/anchorChanges5.qml
new file mode 100644
index 0000000..ef5f041
--- /dev/null
+++ b/tests/auto/declarative/states/data/anchorChanges5.qml
@@ -0,0 +1,22 @@
+import Qt 4.6
+
+Rectangle {
+ width: 200; height: 200
+ Rectangle {
+ id: MyRect
+ objectName: "MyRect"
+ color: "green";
+ anchors.horizontalCenter: parent.horizontalCenter
+ anchors.baseline: parent.baseline
+ }
+ Item { objectName: "LeftGuideline"; id: LeftGuideline; x: 10 }
+ Item { objectName: "BottomGuideline"; id: BottomGuideline; y: 150 }
+ states: State {
+ name: "reanchored"
+ AnchorChanges {
+ target: MyRect;
+ horizontalCenter: BottomGuideline.horizontalCenter
+ baseline: LeftGuideline.baseline
+ }
+ }
+}
diff --git a/tests/auto/declarative/states/tst_states.cpp b/tests/auto/declarative/states/tst_states.cpp
index 1588d4c..671ca33 100644
--- a/tests/auto/declarative/states/tst_states.cpp
+++ b/tests/auto/declarative/states/tst_states.cpp
@@ -41,6 +41,7 @@
#include <qtest.h>
#include <QtDeclarative/qmlengine.h>
#include <QtDeclarative/qmlcomponent.h>
+#include <private/qmlgraphicsanchors_p_p.h>
#include <private/qmlgraphicsrectangle_p.h>
#include <private/qmlpropertychanges_p.h>
@@ -59,6 +60,10 @@ private slots:
void parentChange();
void parentChangeErrors();
void anchorChanges();
+ void anchorChanges2();
+ void anchorChanges3();
+ void anchorChanges4();
+ void anchorChanges5();
void script();
void restoreEntryValues();
void explicitChanges();
@@ -471,67 +476,153 @@ void tst_states::anchorChanges()
{
QmlEngine engine;
- {
- QmlComponent rectComponent(&engine, SRCDIR "/data/anchorChanges.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
+ QmlComponent rectComponent(&engine, SRCDIR "/data/anchorChanges.qml");
+ QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
- QmlGraphicsRectangle *innerRect = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
+ QmlGraphicsRectangle *innerRect = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
- QmlAnchorChanges *aChanges = qobject_cast<QmlAnchorChanges*>(rect->states()->at(0)->changes()->at(0));
- QVERIFY(aChanges != 0);
+ QmlAnchorChanges *aChanges = qobject_cast<QmlAnchorChanges*>(rect->states()->at(0)->changes()->at(0));
+ QVERIFY(aChanges != 0);
- rect->setState("right");
- QCOMPARE(innerRect->x(), qreal(150));
- QCOMPARE(aChanges->reset(), QString("left"));
+ rect->setState("right");
+ QCOMPARE(innerRect->x(), qreal(150));
+ QCOMPARE(aChanges->reset(), QString("left"));
+ QCOMPARE(aChanges->object(), innerRect);
+ QCOMPARE(aChanges->right().item, rect->right().item);
+ QCOMPARE(aChanges->right().anchorLine, rect->right().anchorLine);
- rect->setState("");
- QCOMPARE(innerRect->x(), qreal(5));
+ rect->setState("");
+ QCOMPARE(innerRect->x(), qreal(5));
- delete rect;
- }
+ delete rect;
+}
- {
- QmlComponent rectComponent(&engine, SRCDIR "/data/anchorChanges2.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
+void tst_states::anchorChanges2()
+{
+ QmlEngine engine;
- QmlGraphicsRectangle *innerRect = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
+ QmlComponent rectComponent(&engine, SRCDIR "/data/anchorChanges2.qml");
+ QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
- rect->setState("right");
- QEXPECT_FAIL("", "QTBUG-5338", Continue);
- QCOMPARE(innerRect->x(), qreal(150));
+ QmlGraphicsRectangle *innerRect = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
- rect->setState("");
- QCOMPARE(innerRect->x(), qreal(5));
+ rect->setState("right");
+ QEXPECT_FAIL("", "QTBUG-5338", Continue);
+ QCOMPARE(innerRect->x(), qreal(150));
- delete rect;
- }
+ rect->setState("");
+ QCOMPARE(innerRect->x(), qreal(5));
- {
- QmlComponent rectComponent(&engine, SRCDIR "/data/anchorChanges3.qml");
- QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
- QVERIFY(rect != 0);
+ delete rect;
+}
- QmlGraphicsRectangle *innerRect = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"));
- QVERIFY(innerRect != 0);
+void tst_states::anchorChanges3()
+{
+ QmlEngine engine;
- rect->setState("reanchored");
- QCOMPARE(innerRect->x(), qreal(10));
- QCOMPARE(innerRect->y(), qreal(0));
- QCOMPARE(innerRect->width(), qreal(190));
- QCOMPARE(innerRect->height(), qreal(150));
+ QmlComponent rectComponent(&engine, SRCDIR "/data/anchorChanges3.qml");
+ QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
- rect->setState("");
- QCOMPARE(innerRect->x(), qreal(0));
- QCOMPARE(innerRect->y(), qreal(10));
- QCOMPARE(innerRect->width(), qreal(150));
- QCOMPARE(innerRect->height(), qreal(190));
+ QmlGraphicsRectangle *innerRect = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
- delete rect;
- }
+ QmlGraphicsItem *leftGuideline = qobject_cast<QmlGraphicsItem*>(rect->findChild<QmlGraphicsItem*>("LeftGuideline"));
+ QVERIFY(leftGuideline != 0);
+
+ QmlGraphicsItem *bottomGuideline = qobject_cast<QmlGraphicsItem*>(rect->findChild<QmlGraphicsItem*>("BottomGuideline"));
+ QVERIFY(bottomGuideline != 0);
+
+ QmlAnchorChanges *aChanges = qobject_cast<QmlAnchorChanges*>(rect->states()->at(0)->changes()->at(0));
+ QVERIFY(aChanges != 0);
+
+ rect->setState("reanchored");
+ QCOMPARE(aChanges->object(), innerRect);
+ QCOMPARE(aChanges->left().item, leftGuideline->left().item);
+ QCOMPARE(aChanges->left().anchorLine, leftGuideline->left().anchorLine);
+ QCOMPARE(aChanges->right().item, rect->right().item);
+ QCOMPARE(aChanges->right().anchorLine, rect->right().anchorLine);
+ QCOMPARE(aChanges->top().item, rect->top().item);
+ QCOMPARE(aChanges->top().anchorLine, rect->top().anchorLine);
+ QCOMPARE(aChanges->bottom().item, bottomGuideline->bottom().item);
+ QCOMPARE(aChanges->bottom().anchorLine, bottomGuideline->bottom().anchorLine);
+
+ 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;
+}
+
+void tst_states::anchorChanges4()
+{
+ QmlEngine engine;
+
+ QmlComponent rectComponent(&engine, SRCDIR "/data/anchorChanges4.qml");
+ QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QmlGraphicsRectangle *innerRect = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ QmlGraphicsItem *leftGuideline = qobject_cast<QmlGraphicsItem*>(rect->findChild<QmlGraphicsItem*>("LeftGuideline"));
+ QVERIFY(leftGuideline != 0);
+
+ QmlGraphicsItem *bottomGuideline = qobject_cast<QmlGraphicsItem*>(rect->findChild<QmlGraphicsItem*>("BottomGuideline"));
+ QVERIFY(bottomGuideline != 0);
+
+ QmlAnchorChanges *aChanges = qobject_cast<QmlAnchorChanges*>(rect->states()->at(0)->changes()->at(0));
+ QVERIFY(aChanges != 0);
+
+ rect->setState("reanchored");
+ QCOMPARE(aChanges->object(), innerRect);
+ QCOMPARE(aChanges->horizontalCenter().item, bottomGuideline->horizontalCenter().item);
+ QCOMPARE(aChanges->horizontalCenter().anchorLine, bottomGuideline->horizontalCenter().anchorLine);
+ QCOMPARE(aChanges->verticalCenter().item, leftGuideline->verticalCenter().item);
+ QCOMPARE(aChanges->verticalCenter().anchorLine, leftGuideline->verticalCenter().anchorLine);
+
+ delete rect;
+}
+
+void tst_states::anchorChanges5()
+{
+ QmlEngine engine;
+
+ QmlComponent rectComponent(&engine, SRCDIR "/data/anchorChanges5.qml");
+ QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create());
+ QVERIFY(rect != 0);
+
+ QmlGraphicsRectangle *innerRect = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect"));
+ QVERIFY(innerRect != 0);
+
+ QmlGraphicsItem *leftGuideline = qobject_cast<QmlGraphicsItem*>(rect->findChild<QmlGraphicsItem*>("LeftGuideline"));
+ QVERIFY(leftGuideline != 0);
+
+ QmlGraphicsItem *bottomGuideline = qobject_cast<QmlGraphicsItem*>(rect->findChild<QmlGraphicsItem*>("BottomGuideline"));
+ QVERIFY(bottomGuideline != 0);
+
+ QmlAnchorChanges *aChanges = qobject_cast<QmlAnchorChanges*>(rect->states()->at(0)->changes()->at(0));
+ QVERIFY(aChanges != 0);
+
+ rect->setState("reanchored");
+ QCOMPARE(aChanges->object(), innerRect);
+ QCOMPARE(aChanges->horizontalCenter().item, bottomGuideline->horizontalCenter().item);
+ QCOMPARE(aChanges->horizontalCenter().anchorLine, bottomGuideline->horizontalCenter().anchorLine);
+ QCOMPARE(aChanges->baseline().item, leftGuideline->baseline().item);
+ QCOMPARE(aChanges->baseline().anchorLine, leftGuideline->baseline().anchorLine);
+
+ delete rect;
}
void tst_states::script()