summaryrefslogtreecommitdiffstats
path: root/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
diff options
context:
space:
mode:
authorJan-Arve Sæther <jan-arve.saether@nokia.com>2009-09-29 07:46:06 (GMT)
committerJan-Arve Sæther <jan-arve.saether@nokia.com>2009-09-29 11:01:45 (GMT)
commitcdfcdbacc543bc0b67e615adf7bb8d885285b425 (patch)
treebc80d175ba08948fbb3e46ea957608b827e543bd /tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
parent02989fc21d15dcbf5ceb6a55fc124b5eaf191169 (diff)
downloadQt-cdfcdbacc543bc0b67e615adf7bb8d885285b425.zip
Qt-cdfcdbacc543bc0b67e615adf7bb8d885285b425.tar.gz
Qt-cdfcdbacc543bc0b67e615adf7bb8d885285b425.tar.bz2
After some discussion we decided to remove hasConflicts() from the API.
hasConflicts() does only make sense for a tool/editor of the layout, and how this function would help the tool is only guesswork at the moment. We keep the private API though, in order to let the autotests we inherited from Orbit pass.
Diffstat (limited to 'tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp')
-rw-r--r--tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp52
1 files changed, 19 insertions, 33 deletions
diff --git a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
index 2fee98d..9f13aca 100644
--- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
+++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
@@ -40,9 +40,10 @@
****************************************************************************/
#include <QtTest/QtTest>
-#include <qgraphicsanchorlayout.h>
-#include <qgraphicswidget.h>
-#include <qgraphicsproxywidget.h>
+#include <QtGui/qgraphicsanchorlayout.h>
+#include <private/qgraphicsanchorlayout_p.h>
+#include <QtGui/qgraphicswidget.h>
+#include <QtGui/qgraphicsproxywidget.h>
#include <QtGui/qgraphicsview.h>
class tst_QGraphicsAnchorLayout : public QObject {
@@ -142,6 +143,11 @@ static bool checkReverseDirection(QGraphicsWidget *w)
return true;
}
+static bool layoutHasConflict(QGraphicsAnchorLayout *l)
+{
+ return QGraphicsAnchorLayoutPrivate::get(l)->hasConflicts();
+}
+
void tst_QGraphicsAnchorLayout::simple()
{
QGraphicsWidget *w1 = createItem();
@@ -154,8 +160,6 @@ void tst_QGraphicsAnchorLayout::simple()
QGraphicsWidget p;
p.setLayout(l);
- QVERIFY(l->hasConflicts() == false);
-
QCOMPARE(l->count(), 2);
}
@@ -185,8 +189,6 @@ void tst_QGraphicsAnchorLayout::simple_center()
setAnchor(l, b, Qt::AnchorBottom, c, Qt::AnchorTop, 0);
setAnchor(l, c, Qt::AnchorBottom, l, Qt::AnchorBottom, 0);
- QVERIFY(l->hasConflicts() == false);
-
QCOMPARE(l->count(), 3);
QGraphicsWidget *p = new QGraphicsWidget(0, Qt::Window);
@@ -234,8 +236,6 @@ void tst_QGraphicsAnchorLayout::simple_semifloat()
setAnchor(l, a, Qt::AnchorBottom, l, Qt::AnchorBottom, 0);
setAnchor(l, b, Qt::AnchorBottom, l, Qt::AnchorBottom, 0);
- QVERIFY(l->hasConflicts() == false);
-
QCOMPARE(l->count(), 4);
QGraphicsWidget *p = new QGraphicsWidget(0, Qt::Window);
@@ -296,7 +296,6 @@ void tst_QGraphicsAnchorLayout::layoutDirection()
view->show();
QCOMPARE(checkReverseDirection(p), true);
- QVERIFY(l->hasConflicts() == false);
delete p;
delete view;
@@ -340,8 +339,6 @@ void tst_QGraphicsAnchorLayout::diagonal()
l->addAnchor(e, Qt::AnchorRight, l, Qt::AnchorRight);
l->addAnchor(d, Qt::AnchorRight, e, Qt::AnchorLeft);
- QVERIFY(l->hasConflicts() == false);
-
QCOMPARE(l->count(), 5);
QGraphicsWidget p;
@@ -391,7 +388,7 @@ void tst_QGraphicsAnchorLayout::diagonal()
QCOMPARE(checkReverseDirection(&p), true);
c->setMinimumWidth(300);
- QVERIFY(l->hasConflicts());
+ QVERIFY(layoutHasConflict(l));
}
void tst_QGraphicsAnchorLayout::parallel()
@@ -484,8 +481,6 @@ void tst_QGraphicsAnchorLayout::parallel()
QCOMPARE(e->geometry(), QRectF(375, 400, 175, 100));
QCOMPARE(f->geometry(), QRectF(550, 500, 200, 100));
QCOMPARE(p.size(), layoutMaximumSize);
-
- QVERIFY(l->hasConflicts() == false);
}
void tst_QGraphicsAnchorLayout::parallel2()
@@ -510,7 +505,6 @@ void tst_QGraphicsAnchorLayout::parallel2()
l->addAnchor(l, Qt::AnchorLeft, b, Qt::AnchorLeft);
l->addAnchor(b, Qt::AnchorRight, a, Qt::AnchorRight);
- QVERIFY(l->hasConflicts() == false);
QCOMPARE(l->count(), 2);
QGraphicsWidget p;
@@ -592,8 +586,6 @@ void tst_QGraphicsAnchorLayout::snake()
QCOMPARE(b->geometry(), QRectF(90.0, 100.0, 10.0, 100.0));
QCOMPARE(c->geometry(), QRectF(90.0, 200.0, 100.0, 100.0));
QCOMPARE(p.size(), layoutMaximumSize);
-
- QVERIFY(l->hasConflicts() == false);
}
void tst_QGraphicsAnchorLayout::snakeOppositeDirections()
@@ -627,7 +619,6 @@ void tst_QGraphicsAnchorLayout::snakeOppositeDirections()
l->addAnchor(c, Qt::AnchorRight, l, Qt::AnchorRight);
- QVERIFY(l->hasConflicts() == false);
QCOMPARE(l->count(), 3);
QGraphicsWidget p;
@@ -731,8 +722,6 @@ void tst_QGraphicsAnchorLayout::fairDistribution()
QCOMPARE(c->geometry(), QRectF(200.0, 200.0, 100.0, 100.0));
QCOMPARE(d->geometry(), QRectF(0.0, 300.0, 300.0, 100.0));
QCOMPARE(p.size(), layoutMaximumSize);
-
- QVERIFY(l->hasConflicts() == false);
}
void tst_QGraphicsAnchorLayout::fairDistributionOppositeDirections()
@@ -809,8 +798,6 @@ void tst_QGraphicsAnchorLayout::fairDistributionOppositeDirections()
QCOMPARE(a->size(), d->size());
QCOMPARE(e->size().width(), 4 * a->size().width());
QCOMPARE(p.size(), layoutMaximumSize);
-
- QVERIFY(l->hasConflicts() == false);
}
void tst_QGraphicsAnchorLayout::proportionalPreferred()
@@ -873,8 +860,6 @@ void tst_QGraphicsAnchorLayout::proportionalPreferred()
QCOMPARE(a->size().width(), 10 * factor);
QCOMPARE(c->size().width(), 14 * factor);
QCOMPARE(p.size(), QSizeF(12, 400));
-
- QVERIFY(l->hasConflicts() == false);
}
void tst_QGraphicsAnchorLayout::example()
@@ -928,7 +913,6 @@ void tst_QGraphicsAnchorLayout::example()
l->addAnchor(l, Qt::AnchorLeft, g, Qt::AnchorLeft);
l->addAnchor(f, Qt::AnchorRight, g, Qt::AnchorRight);
- QVERIFY(l->hasConflicts() == false);
QCOMPARE(l->count(), 7);
QGraphicsWidget p;
@@ -1017,8 +1001,6 @@ void tst_QGraphicsAnchorLayout::setSpacing()
QCOMPARE(b->geometry(), QRectF(24, 0, 20, 20));
QCOMPARE(c->geometry(), QRectF(0, 20, 44, 20));
- QVERIFY(l->hasConflicts() == false);
-
delete p;
delete view;
}
@@ -1103,7 +1085,6 @@ void tst_QGraphicsAnchorLayout::hardComplexS60()
QSizeF layoutMaximumSize = l->effectiveSizeHint(Qt::MaximumSize);
QCOMPARE(layoutMaximumSize, QSizeF(240, 40));
- QVERIFY(l->hasConflicts() == false);
delete p;
}
@@ -1166,7 +1147,6 @@ void tst_QGraphicsAnchorLayout::delete_anchor()
QGraphicsWidget *p = new QGraphicsWidget;
p->setLayout(l);
- QVERIFY(l->hasConflicts() == false);
QCOMPARE(l->count(), 3);
scene.addItem(p);
@@ -1281,6 +1261,12 @@ void tst_QGraphicsAnchorLayout::sizePolicy()
delete view;
}
+/*!
+ \internal
+
+ Uses private API. (We have decided to pull hasConflicts() out of the API). However, it also
+ tests some tight conditions (almost-in-conflict) that we really want to test.
+*/
void tst_QGraphicsAnchorLayout::conflicts()
{
QGraphicsWidget *a = createItem(QSizeF(80,10), QSizeF(90,10), QSizeF(100,10), "a");
@@ -1311,13 +1297,13 @@ void tst_QGraphicsAnchorLayout::conflicts()
p->setLayout(l);
- QCOMPARE(l->hasConflicts(), true);
+ QCOMPARE(layoutHasConflict(l), true);
a->setMinimumSize(QSizeF(29,10));
- QCOMPARE(l->hasConflicts(), false);
+ QCOMPARE(layoutHasConflict(l), false);
a->setMinimumSize(QSizeF(30,10));
- QCOMPARE(l->hasConflicts(), false);
+ QCOMPARE(layoutHasConflict(l), false);
delete p;
}