From 782700705a1a2625509b73910b667ee91f23a74a Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Mon, 9 Nov 2009 18:48:13 +1000 Subject: Fix layouts test Turns out I misinterpreted QGraphicsLinearLayout's behaviour. Task-number: QT-2472 --- tests/auto/declarative/layouts/data/layouts.qml | 3 +-- tests/auto/declarative/layouts/tst_layouts.cpp | 20 ++++++++++++-------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/tests/auto/declarative/layouts/data/layouts.qml b/tests/auto/declarative/layouts/data/layouts.qml index ccc8cfe..b0ee63b 100644 --- a/tests/auto/declarative/layouts/data/layouts.qml +++ b/tests/auto/declarative/layouts/data/layouts.qml @@ -7,10 +7,9 @@ Item { GraphicsObjectContainer { anchors.fill:parent + synchronizedResizing: true QGraphicsWidget { - size.width:parent.width - size.height:parent.height layout: QGraphicsLinearLayout { spacing: 0 diff --git a/tests/auto/declarative/layouts/tst_layouts.cpp b/tests/auto/declarative/layouts/tst_layouts.cpp index f619b57..1c2330d 100644 --- a/tests/auto/declarative/layouts/tst_layouts.cpp +++ b/tests/auto/declarative/layouts/tst_layouts.cpp @@ -68,10 +68,10 @@ void tst_QmlGraphicsLayouts::test_qml() canvas->execute(); qApp->processEvents(); - QmlGraphicsLayoutItem *left = qobject_cast(canvas->root()->findChild("left")); + QmlGraphicsLayoutItem *left = static_cast(canvas->root()->findChild("left")); QVERIFY(left != 0); - QmlGraphicsLayoutItem *right = qobject_cast(canvas->root()->findChild("right")); + QmlGraphicsLayoutItem *right = static_cast(canvas->root()->findChild("right")); QVERIFY(right != 0); qreal gvMargin = 9.0; @@ -101,17 +101,21 @@ void tst_QmlGraphicsLayouts::test_qml() QCOMPARE(right->width(), 100.0); QCOMPARE(right->height(), 100.0); - //Maximum Size - canvas->root()->setWidth(1000 + 2*gvMargin); - canvas->root()->setHeight(1000 + 2*gvMargin); + //Between preferred and Maximum Size + /*Note that if set to maximum size (or above) GraphicsLinearLayout behavior + is to shrink them down to preferred size. So the exact maximum size can't + be used*/ + canvas->root()->setWidth(670 + 2*gvMargin); + canvas->root()->setHeight(300 + 2*gvMargin); QCOMPARE(left->x(), gvMargin); - QCOMPARE(left->width(), 300.0); + QCOMPARE(left->width(), 270.0); QCOMPARE(left->height(), 300.0); - QCOMPARE(right->x(), 300.0 + gvMargin); + QCOMPARE(right->x(), 270.0 + gvMargin); QCOMPARE(right->width(), 400.0); - QCOMPARE(right->height(), 400.0); + QCOMPARE(right->height(), 300.0); + } void tst_QmlGraphicsLayouts::test_cpp() -- cgit v0.12