summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorJan-Arve Sæther <jan-arve.saether@nokia.com>2009-11-08 22:43:25 +0100
committerJan-Arve Sæther <jan-arve.saether@nokia.com>2009-11-08 22:43:25 +0100
commited899a8de07327d488d69af7e57a13e446cf6c32 (patch)
treeb3923e70b1cebd2946635769b3b1fe1673f57749 /tests/auto
parent360a51d64c607f5efae7a4f25a9a519424399b69 (diff)
parent0000d60b8bf38c9869b5f3ca43828f97af5488c7 (diff)
Merge file://t:/dev/qt-46-wt into widgetteam
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp65
-rw-r--r--tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp21
2 files changed, 73 insertions, 13 deletions
diff --git a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
index cc96edbee3..c7ed309a2b 100644
--- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
+++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
@@ -83,6 +83,8 @@ private slots:
void infiniteMaxSizes();
void simplifiableUnfeasible();
void simplificationVsOrder();
+ void parallelSimplificationOfCenter();
+ void simplificationVsRedundance();
};
class RectWidget : public QGraphicsWidget
@@ -1801,5 +1803,68 @@ void tst_QGraphicsAnchorLayout::simplificationVsOrder()
}
}
+void tst_QGraphicsAnchorLayout::parallelSimplificationOfCenter()
+{
+ QSizeF min(10, 10);
+ QSizeF pref(20, 10);
+ QSizeF max(50, 10);
+
+ QGraphicsWidget *a = createItem(min, pref, max, "A");
+ QGraphicsWidget *b = createItem(min, pref, max, "B");
+
+ QGraphicsWidget parent;
+ QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout(&parent);
+ l->setContentsMargins(0, 0, 0, 0);
+
+ l->addAnchor(l, Qt::AnchorLeft, a, Qt::AnchorLeft);
+ l->addAnchor(l, Qt::AnchorRight, a, Qt::AnchorRight);
+
+ l->addAnchor(a, Qt::AnchorHorizontalCenter, b, Qt::AnchorLeft);
+ l->addAnchor(b, Qt::AnchorRight, a, Qt::AnchorRight);
+
+ parent.resize(l->effectiveSizeHint(Qt::PreferredSize));
+
+ QCOMPARE(a->geometry(), QRectF(0, 0, 40, 10));
+ QCOMPARE(b->geometry(), QRectF(20, 0, 20, 10));
+}
+
+/*
+ Test whether redundance of anchors (in this case by using addCornerAnchors), will
+ prevent simplification to take place when it should.
+*/
+void tst_QGraphicsAnchorLayout::simplificationVsRedundance()
+{
+ QSizeF min(10, 10);
+ QSizeF pref(20, 10);
+ QSizeF max(50, 30);
+
+ QGraphicsWidget *a = createItem(min, pref, max, "A");
+ QGraphicsWidget *b = createItem(min, pref, max, "B");
+ QGraphicsWidget *c = createItem(min, pref, max, "C");
+
+ QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout;
+
+ l->addCornerAnchors(a, Qt::TopLeftCorner, l, Qt::TopLeftCorner);
+ l->addCornerAnchors(a, Qt::BottomLeftCorner, l, Qt::BottomLeftCorner);
+
+ l->addCornerAnchors(b, Qt::TopLeftCorner, a, Qt::TopRightCorner);
+ l->addCornerAnchors(b, Qt::TopRightCorner, l, Qt::TopRightCorner);
+
+ l->addCornerAnchors(c, Qt::TopLeftCorner, b, Qt::BottomLeftCorner);
+ l->addCornerAnchors(c, Qt::BottomLeftCorner, a, Qt::BottomRightCorner);
+ l->addCornerAnchors(c, Qt::TopRightCorner, b, Qt::BottomRightCorner);
+ l->addCornerAnchors(c, Qt::BottomRightCorner, l, Qt::BottomRightCorner);
+
+ l->effectiveSizeHint(Qt::MinimumSize);
+
+ QCOMPARE(layoutHasConflict(l), false);
+
+ if (!hasSimplification)
+ QEXPECT_FAIL("", "Test depends on simplification.", Abort);
+
+ QCOMPARE(usedSimplex(l, Qt::Horizontal), false);
+ QCOMPARE(usedSimplex(l, Qt::Vertical), false);
+}
+
QTEST_MAIN(tst_QGraphicsAnchorLayout)
#include "tst_qgraphicsanchorlayout.moc"
diff --git a/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp b/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp
index 4f8a4780ac..0fbd0692ce 100644
--- a/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp
+++ b/tests/auto/qgraphicsanchorlayout1/tst_qgraphicsanchorlayout1.cpp
@@ -423,7 +423,6 @@ void tst_QGraphicsAnchorLayout1::testAddAndRemoveAnchor()
layout->setAnchor(layout, Qt::AnchorLeft, widget5, Qt::AnchorTop, 10);
QCOMPARE( layout->count(), 4 );
- // ###: NOT SUPPORTED
// anchor two edges of a widget (to define width / height)
QTest::ignoreMessage(QtWarningMsg, "QGraphicsAnchorLayout::addAnchor(): Cannot anchor the item to itself");
layout->setAnchor(widget5, Qt::AnchorLeft, widget5, Qt::AnchorRight, 10);
@@ -520,8 +519,6 @@ void tst_QGraphicsAnchorLayout1::testIsValid()
widget->setLayout(layout);
widget->setGeometry(QRectF(0,0,100,100));
- // ###: this shall change once isValid() is ready
- // QCOMPARE(layout->isValid(), false);
QCOMPARE(layout->isValid(), true);
delete widget;
}
@@ -698,9 +695,8 @@ void tst_QGraphicsAnchorLayout1::testSpecialCases()
layout2->setAnchor(widget1, Qt::AnchorRight, layout2, Qt::AnchorRight, 1);
layout2->setAnchor(widget1, Qt::AnchorBottom, layout2, Qt::AnchorBottom, 1);
- // ###: uncomment when simplification bug is solved
- //widget->setGeometry(QRectF(0,0,100,100));
- //QCOMPARE(widget1->geometry(), QRectF(51,2,47,96));
+ widget->setGeometry(QRectF(0,0,100,100));
+ QCOMPARE(widget1->geometry(), QRectF(51,2,47,96));
delete widget;
}
@@ -900,9 +896,6 @@ void tst_QGraphicsAnchorLayout1::testBasicLayout_data()
<< BasicData(-1, Qt::AnchorLeft, 1, Qt::AnchorRight, 20)
;
- // ### SIMPLIFICATION BUG FOR ITEM 1
- // ### remove this when bug is solved
-
theResult
<< BasicResult(0, QRectF(10, 10, 180, 80) )
<< BasicResult(1, QRectF(10, 80, 10, 10) )
@@ -1743,7 +1736,10 @@ void tst_QGraphicsAnchorLayout1::testBasicLayout()
if (mirroredRect.isValid()){
mirroredRect.moveLeft(size.width()-item.rect.width()-item.rect.left());
}
- QCOMPARE(widgets[item.index]->geometry(), mirroredRect);
+ QRectF expected = truncate(mirroredRect);
+ QRectF actual = truncate(widgets[item.index]->geometry());
+
+ QCOMPARE(expected, actual);
delete widgets[item.index];
}
@@ -2445,6 +2441,8 @@ void tst_QGraphicsAnchorLayout1::testDoubleSizePolicy_data()
QTest::newRow("double size policy: expanding-preferred") << sizePolicy1 << sizePolicy2 << width1 << width2;
}
+ // QGAL handling of ignored flag is different
+ if (0)
{
QSizePolicy sizePolicy1( QSizePolicy::Ignored, QSizePolicy::Ignored );
QSizePolicy sizePolicy2( QSizePolicy::Preferred, QSizePolicy::Preferred );
@@ -2512,9 +2510,6 @@ void tst_QGraphicsAnchorLayout1::testDoubleSizePolicy_data()
void tst_QGraphicsAnchorLayout1::testDoubleSizePolicy()
{
- // ### Size policy is not yet supported
- return;
-
QFETCH(QSizePolicy, policy1);
QFETCH(QSizePolicy, policy2);
QFETCH(qreal, width1);