summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/anchors
diff options
context:
space:
mode:
authorAlan Alpert <alan.alpert@nokia.com>2009-12-10 10:33:50 (GMT)
committerAlan Alpert <alan.alpert@nokia.com>2009-12-10 10:58:24 (GMT)
commit8d3596fefc882a4194c665bcde4e8309dbdcc85f (patch)
treef8957887296695990d2c4bf6f2512deb91881d1e /tests/auto/declarative/anchors
parentd1fa2391bf53e43e1952c6722e2525cc947557f2 (diff)
downloadQt-8d3596fefc882a4194c665bcde4e8309dbdcc85f.zip
Qt-8d3596fefc882a4194c665bcde4e8309dbdcc85f.tar.gz
Qt-8d3596fefc882a4194c665bcde4e8309dbdcc85f.tar.bz2
Update centerIn when center offsets change
Also adds functionality to update fill when margins change. Task-number: QTBUG-6631
Diffstat (limited to 'tests/auto/declarative/anchors')
-rw-r--r--tests/auto/declarative/anchors/data/fill.qml14
-rw-r--r--tests/auto/declarative/anchors/tst_anchors.cpp38
2 files changed, 49 insertions, 3 deletions
diff --git a/tests/auto/declarative/anchors/data/fill.qml b/tests/auto/declarative/anchors/data/fill.qml
new file mode 100644
index 0000000..902465c
--- /dev/null
+++ b/tests/auto/declarative/anchors/data/fill.qml
@@ -0,0 +1,14 @@
+import Qt 4.6
+
+Rectangle {
+ width: 200; height: 200
+ Rectangle {
+ objectName: "filler"
+ width: 50; height: 50; color: "blue"
+ anchors.fill: parent;
+ anchors.leftMargin: 10;
+ anchors.rightMargin: 20;
+ anchors.topMargin: 30;
+ anchors.bottomMargin: 40;
+ }
+}
diff --git a/tests/auto/declarative/anchors/tst_anchors.cpp b/tests/auto/declarative/anchors/tst_anchors.cpp
index bbe5ef1..8967725 100644
--- a/tests/auto/declarative/anchors/tst_anchors.cpp
+++ b/tests/auto/declarative/anchors/tst_anchors.cpp
@@ -72,6 +72,7 @@ private slots:
void nullItem_data();
void crash1();
void centerIn();
+ void fill();
};
/*
@@ -379,6 +380,32 @@ void tst_anchors::crash1()
delete view;
}
+void tst_anchors::fill()
+{
+ QmlView *view = new QmlView;
+
+ view->setUrl(QUrl("file://" SRCDIR "/data/fill.qml"));
+
+ view->execute();
+ qApp->processEvents();
+ QmlGraphicsRectangle* rect = findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("filler"));
+ QCOMPARE(rect->x(), 0.0 + 10);
+ QCOMPARE(rect->y(), 0.0 + 30);
+ QCOMPARE(rect->width(), 200.0 - 10.0 - 20.0);
+ QCOMPARE(rect->height(), 200.0 - 30.0 - 40.0);
+ //Alter Offsets (QTBUG-6631)
+ rect->anchors()->setLeftMargin(20.0);
+ rect->anchors()->setRightMargin(0.0);
+ rect->anchors()->setBottomMargin(0.0);
+ rect->anchors()->setTopMargin(10.0);
+ QCOMPARE(rect->x(), 0.0 + 20.0);
+ QCOMPARE(rect->y(), 0.0 + 10.0);
+ QCOMPARE(rect->width(), 200.0 - 20.0);
+ QCOMPARE(rect->height(), 200.0 - 10.0);
+
+ delete view;
+}
+
void tst_anchors::centerIn()
{
QmlView *view = new QmlView;
@@ -387,9 +414,14 @@ void tst_anchors::centerIn()
view->execute();
qApp->processEvents();
-
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("centered"))->x(), 85.0);
- QCOMPARE(findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("centered"))->y(), 105.0);
+ QmlGraphicsRectangle* rect = findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("centered"));
+ QCOMPARE(rect->x(), 75.0 + 10);
+ QCOMPARE(rect->y(), 75.0 + 30);
+ //Alter Offsets (QTBUG-6631)
+ rect->anchors()->setHorizontalCenterOffset(-20.0);
+ rect->anchors()->setVerticalCenterOffset(-10.0);
+ QCOMPARE(rect->x(), 75.0 - 20.0);
+ QCOMPARE(rect->y(), 75.0 - 10.0);
delete view;
}