summaryrefslogtreecommitdiffstats
path: root/tests/auto/qgraphicslinearlayout
diff options
context:
space:
mode:
authorOlivier Goffart <olivier.goffart@nokia.com>2010-11-25 13:32:37 (GMT)
committerOlivier Goffart <olivier.goffart@nokia.com>2010-11-25 13:32:37 (GMT)
commit850ebb63dfe5fbfdb2107d33a1af4460da59b97c (patch)
tree5e0350e3180de97b561be16072ff1444499048d3 /tests/auto/qgraphicslinearlayout
parente868e896054061f35b38dd3e7b688d932be40a55 (diff)
parent5200f708c46d4bc737d6706691965c726c063292 (diff)
downloadQt-850ebb63dfe5fbfdb2107d33a1af4460da59b97c.zip
Qt-850ebb63dfe5fbfdb2107d33a1af4460da59b97c.tar.gz
Qt-850ebb63dfe5fbfdb2107d33a1af4460da59b97c.tar.bz2
Merge remote branch 'origin/4.7' into qt-master-from-4.7
Conflicts: qmake/generators/symbian/symmake.cpp src/corelib/global/qglobal.h src/gui/kernel/qwidget_p.h src/gui/painting/qtextureglyphcache.cpp src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp src/opengl/gl2paintengineex/qtextureglyphcache_gl.cpp src/opengl/gl2paintengineex/qtextureglyphcache_gl_p.h src/plugins/qpluginbase.pri src/qbase.pri tests/auto/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp tests/auto/qthread/tst_qthread.cpp tests/auto/selftests/expected_cmptest.txt tests/auto/selftests/expected_crashes_3.txt tests/auto/selftests/expected_longstring.txt tests/auto/selftests/expected_maxwarnings.txt tests/auto/selftests/expected_skip.txt tools/assistant/tools/assistant/doc/assistant.qdocconf tools/qdoc3/test/assistant.qdocconf tools/qdoc3/test/designer.qdocconf tools/qdoc3/test/linguist.qdocconf tools/qdoc3/test/qdeclarative.qdocconf tools/qdoc3/test/qmake.qdocconf tools/qdoc3/test/qt-build-docs.qdocconf tools/qdoc3/test/qt-build-docs_ja_JP.qdocconf tools/qdoc3/test/qt-build-docs_zh_CN.qdocconf tools/qdoc3/test/qt.qdocconf tools/qdoc3/test/qt_ja_JP.qdocconf tools/qdoc3/test/qt_zh_CN.qdocconf
Diffstat (limited to 'tests/auto/qgraphicslinearlayout')
-rw-r--r--tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp118
1 files changed, 118 insertions, 0 deletions
diff --git a/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp b/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
index 6107fa1..965e340 100644
--- a/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
+++ b/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
@@ -103,6 +103,9 @@ private slots:
void removeLayout();
void avoidRecursionInInsertItem();
void styleInfoLeak();
+ void testAlignmentInLargerLayout();
+ void testOffByOneInLargerLayout();
+ void testDefaultAlignment();
// Task specific tests
void task218400_insertStretchCrash();
@@ -1465,6 +1468,121 @@ void tst_QGraphicsLinearLayout::task218400_insertStretchCrash()
form->setLayout(layout); // crash
}
+void tst_QGraphicsLinearLayout::testAlignmentInLargerLayout()
+{
+ QGraphicsScene *scene = new QGraphicsScene;
+ QGraphicsWidget *form = new QGraphicsWidget;
+ scene->addItem(form);
+ QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical, form);
+ layout->setSpacing(0);
+ layout->setContentsMargins(0,0,0,0);
+
+ QGraphicsWidget *a = new QGraphicsWidget;
+ a->setMaximumSize(100,100);
+ layout->addItem(a);
+
+ QCOMPARE(form->maximumSize(), QSizeF(100,100));
+ QCOMPARE(layout->maximumSize(), QSizeF(100,100));
+ layout->setMinimumSize(QSizeF(200,200));
+ layout->setMaximumSize(QSizeF(200,200));
+
+ layout->setAlignment(a, Qt::AlignCenter);
+ layout->activate();
+ QCOMPARE(a->geometry(), QRectF(50,50,100,100));
+
+ layout->setAlignment(a, Qt::AlignRight | Qt::AlignBottom);
+ layout->activate();
+ QCOMPARE(a->geometry(), QRectF(100,100,100,100));
+
+ layout->setAlignment(a, Qt::AlignHCenter | Qt::AlignTop);
+ layout->activate();
+ QCOMPARE(a->geometry(), QRectF(50,0,100,100));
+
+ QGraphicsWidget *b = new QGraphicsWidget;
+ b->setMaximumSize(100,100);
+ layout->addItem(b);
+
+ layout->setAlignment(a, Qt::AlignCenter);
+ layout->setAlignment(b, Qt::AlignCenter);
+ layout->activate();
+ QCOMPARE(a->geometry(), QRectF(50,0,100,100));
+ QCOMPARE(b->geometry(), QRectF(50,100,100,100));
+
+ layout->setAlignment(a, Qt::AlignRight | Qt::AlignBottom);
+ layout->setAlignment(b, Qt::AlignLeft | Qt::AlignTop);
+ layout->activate();
+ QCOMPARE(a->geometry(), QRectF(100,0,100,100));
+ QCOMPARE(b->geometry(), QRectF(0,100,100,100));
+}
+
+void tst_QGraphicsLinearLayout::testOffByOneInLargerLayout() {
+ QGraphicsScene *scene = new QGraphicsScene;
+ QGraphicsWidget *form = new QGraphicsWidget;
+ scene->addItem(form);
+ QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical, form);
+ layout->setSpacing(0);
+ layout->setContentsMargins(0,0,0,0);
+
+ QGraphicsWidget *a = new QGraphicsWidget;
+ QGraphicsWidget *b = new QGraphicsWidget;
+ a->setMaximumSize(100,100);
+ b->setMaximumSize(100,100);
+ layout->addItem(a);
+ layout->addItem(b);
+
+ layout->setAlignment(a, Qt::AlignRight | Qt::AlignBottom);
+ layout->setAlignment(b, Qt::AlignLeft | Qt::AlignTop);
+ layout->setMinimumSize(QSizeF(101,201));
+ layout->setMaximumSize(QSizeF(101,201));
+ layout->activate();
+ QCOMPARE(a->geometry(), QRectF(1,0.5,100,100));
+ QCOMPARE(b->geometry(), QRectF(0,100.5,100,100));
+
+ layout->setMinimumSize(QSizeF(100,200));
+ layout->setMaximumSize(QSizeF(100,200));
+ layout->activate();
+ QCOMPARE(a->geometry(), QRectF(0,0,100,100));
+ QCOMPARE(b->geometry(), QRectF(0,100,100,100));
+
+ layout->setMinimumSize(QSizeF(99,199));
+ layout->setMaximumSize(QSizeF(99,199));
+ layout->activate();
+ 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"