diff options
author | Alan Alpert <alan.alpert@nokia.com> | 2009-12-10 11:22:29 (GMT) |
---|---|---|
committer | Alan Alpert <alan.alpert@nokia.com> | 2009-12-10 11:22:29 (GMT) |
commit | 57d6bf52074761a0c6e9a79829ec845a7b0061fa (patch) | |
tree | baee7b86f5acd238689bb65591351f87dd0bb70e /tests | |
parent | 8d3596fefc882a4194c665bcde4e8309dbdcc85f (diff) | |
download | Qt-57d6bf52074761a0c6e9a79829ec845a7b0061fa.zip Qt-57d6bf52074761a0c6e9a79829ec845a7b0061fa.tar.gz Qt-57d6bf52074761a0c6e9a79829ec845a7b0061fa.tar.bz2 |
Add anchors.margins
Task-number: QTBUG-6676
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/declarative/anchors/data/margins.qml | 13 | ||||
-rw-r--r-- | tests/auto/declarative/anchors/tst_anchors.cpp | 30 |
2 files changed, 41 insertions, 2 deletions
diff --git a/tests/auto/declarative/anchors/data/margins.qml b/tests/auto/declarative/anchors/data/margins.qml new file mode 100644 index 0000000..4a29e77 --- /dev/null +++ b/tests/auto/declarative/anchors/data/margins.qml @@ -0,0 +1,13 @@ +import Qt 4.6 + +Rectangle { + width: 200; height: 200 + Rectangle { + objectName: "filler" + width: 50; height: 50; color: "blue" + anchors.fill: parent; + anchors.margins: 10 + anchors.leftMargin: 5 + anchors.topMargin: 6 + } +} diff --git a/tests/auto/declarative/anchors/tst_anchors.cpp b/tests/auto/declarative/anchors/tst_anchors.cpp index 8967725..defc841 100644 --- a/tests/auto/declarative/anchors/tst_anchors.cpp +++ b/tests/auto/declarative/anchors/tst_anchors.cpp @@ -73,6 +73,7 @@ private slots: void crash1(); void centerIn(); void fill(); + void margins(); }; /* @@ -389,8 +390,8 @@ void tst_anchors::fill() 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->x(), 0.0 + 10.0); + QCOMPARE(rect->y(), 0.0 + 30.0); QCOMPARE(rect->width(), 200.0 - 10.0 - 20.0); QCOMPARE(rect->height(), 200.0 - 30.0 - 40.0); //Alter Offsets (QTBUG-6631) @@ -426,6 +427,31 @@ void tst_anchors::centerIn() delete view; } +void tst_anchors::margins() +{ + QmlView *view = new QmlView; + + view->setUrl(QUrl("file://" SRCDIR "/data/margins.qml")); + + view->execute(); + qApp->processEvents(); + QmlGraphicsRectangle* rect = findItem<QmlGraphicsRectangle>(view->root(), QLatin1String("filler")); + QCOMPARE(rect->x(), 5.0); + QCOMPARE(rect->y(), 6.0); + QCOMPARE(rect->width(), 200.0 - 5.0 - 10.0); + QCOMPARE(rect->height(), 200.0 - 6.0 - 10.0); + + rect->anchors()->setTopMargin(0.0); + rect->anchors()->setMargins(20.0); + + QCOMPARE(rect->x(), 5.0); + QCOMPARE(rect->y(), 20.0); + QCOMPARE(rect->width(), 200.0 - 5.0 - 20.0); + QCOMPARE(rect->height(), 200.0 - 20.0 - 20.0); + + delete view; +} + QTEST_MAIN(tst_anchors) #include "tst_anchors.moc" |