summaryrefslogtreecommitdiffstats
path: root/tests/auto/qgraphicslinearlayout
diff options
context:
space:
mode:
authorJohn Tapsell <john.tapsell.ext@basyskom.de>2010-11-15 11:55:13 (GMT)
committerJan-Arve Sæther <jan-arve.saether@nokia.com>2010-11-15 11:55:13 (GMT)
commit1781b3c876b4e1025b2a85f4e7975c171b1a1404 (patch)
tree4b15aa0cac8d0c379fd3ce1f11e1c832f2559ca3 /tests/auto/qgraphicslinearlayout
parent604c51f1fc5c79b7fad12cda911b06b9e6e5005f (diff)
downloadQt-1781b3c876b4e1025b2a85f4e7975c171b1a1404.zip
Qt-1781b3c876b4e1025b2a85f4e7975c171b1a1404.tar.gz
Qt-1781b3c876b4e1025b2a85f4e7975c171b1a1404.tar.bz2
Change the QGraphics*Layout documentation to match the code - that the default alignment is top-left.
This includes unit tests to confirm that the alignment is top-left in a variety of different cases. Merge-request: 894 Reviewed-by: Jan-Arve Sæther <jan-arve.saether@nokia.com>
Diffstat (limited to 'tests/auto/qgraphicslinearlayout')
-rw-r--r--tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp b/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
index e271aee..cbc90be 100644
--- a/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
+++ b/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
@@ -105,6 +105,7 @@ private slots:
void styleInfoLeak();
void testAlignmentInLargerLayout();
void testOffByOneInLargerLayout();
+ void testDefaultAlignment();
// Task specific tests
void task218400_insertStretchCrash();
@@ -1549,6 +1550,38 @@ void tst_QGraphicsLinearLayout::testOffByOneInLargerLayout() {
QCOMPARE(a->geometry(), QRectF(0,0,99,99.5));
QCOMPARE(b->geometry(), QRectF(0,99.5,99,99.5));
}
+void tst_QGraphicsLinearLayout::testDefaultAlignment()
+{
+ QGraphicsWidget *widget = new QGraphicsWidget;
+ QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical, widget);
+ layout->setContentsMargins(0, 0, 0, 0);
+ layout->setSpacing(0);
+
+ QGraphicsWidget *w = new QGraphicsWidget;
+ w->setMinimumSize(50,50);
+ w->setMaximumSize(50,50);
+ layout->addItem(w);
+
+ //Default alignment should be to the top-left
+ QCOMPARE(layout->alignment(w), 0);
+
+ //First, check by forcing the layout to be bigger
+ layout->setMinimumSize(100,100);
+ layout->activate();
+ QCOMPARE(layout->geometry(), QRectF(0,0,100,100));
+ QCOMPARE(w->geometry(), QRectF(0,0,50,50));
+ layout->setMinimumSize(-1,-1);
+
+ //Second, check by adding a larger item in the column
+ QGraphicsWidget *w2 = new QGraphicsWidget;
+ w2->setMinimumSize(100,100);
+ w2->setMaximumSize(100,100);
+ layout->addItem(w2);
+ layout->activate();
+ QCOMPARE(layout->geometry(), QRectF(0,0,100,150));
+ QCOMPARE(w->geometry(), QRectF(0,0,50,50));
+ QCOMPARE(w2->geometry(), QRectF(0,50,100,100));
+}
QTEST_MAIN(tst_QGraphicsLinearLayout)
#include "tst_qgraphicslinearlayout.moc"