summaryrefslogtreecommitdiffstats
path: root/tests/auto/qgraphicsanchorlayout
diff options
context:
space:
mode:
authorCaio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>2009-08-13 19:32:18 -0300
committerCaio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>2009-08-13 19:55:04 -0300
commit23441f49a23cbf936b60140c5c8a6d5cb3ca00a7 (patch)
tree28ebda80192b274c59b8a7ec236e158f66ebb621 /tests/auto/qgraphicsanchorlayout
parentac4239eb5eb68ee18864378f643b5f38a3d07af1 (diff)
QGraphicsAnchorLayout: fix expected values for parallel test
We changed the parallel example because the expected values for preferred size are wrong. Before we had a parallel anchor ("d|e") that should have the maximum preferred of the both children, so this end up being 170. This parallel is in a sequence with another item ("b") with a preferred of 150 ending up with 320. This group is in parallel with "c" that has a maximum of 300. So in the preferred size of the layout, the group was constraint to 300, which would be proportionally distributed between "b" and "d|e", and 50%/50% as the test expected. The proportional distribution is a feature and we changed the test to illustrate that more. We gave a bump in "c" maximum to 350 and "b" maximum to 300, so the preferred is 100% for both "b" and "d|e", and the proportional feature shows up in the maximum allocation, which is not 100% for the group (b and d|e). In the group, the maximum possible is 500 but the layout only allows 350, so the sizes need to be proportionally, but in relation not to zero, but to the preferred which is 320 (this is the same logic used for setGeometry()). So the growth is 30 / (500 - 320) = 30 / 180 = 1/6. This 1/6 should be the factor given to the children (b and d|e), taking their preferred sizes as starting points. Note that the test still fails, but serve as a milestone to see when the feature is correct implemented. Signed-off-by: Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org> Reviewed-by: Artur Duque de Souza <artur.souza@openbossa.org>
Diffstat (limited to 'tests/auto/qgraphicsanchorlayout')
-rw-r--r--tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp82
1 files changed, 42 insertions, 40 deletions
diff --git a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
index cacb3a68b8..530e51e523 100644
--- a/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
+++ b/tests/auto/qgraphicsanchorlayout/tst_qgraphicsanchorlayout.cpp
@@ -37,12 +37,14 @@ public:
static QGraphicsWidget *createItem(const QSizeF &minimum = QSizeF(100.0, 100.0),
const QSizeF &preferred = QSize(150.0, 100.0),
- const QSizeF &maximum = QSizeF(200.0, 100.0))
+ const QSizeF &maximum = QSizeF(200.0, 100.0),
+ const QString &name = QString())
{
QGraphicsWidget *w = new RectWidget;
w->setMinimumSize(minimum);
w->setPreferredSize(preferred);
w->setMaximumSize(maximum);
+ w->setData(0, name);
return w;
}
@@ -149,29 +151,29 @@ void tst_QGraphicsAnchorLayout::diagonal()
void tst_QGraphicsAnchorLayout::parallel()
{
- QGraphicsWidget *a = createItem(QSizeF(100.0, 100.0),
- QSizeF(150.0, 100.0),
- QSizeF(200.0, 100.0));
+ QGraphicsWidget *a = createItem(QSizeF(100, 100),
+ QSizeF(150, 100),
+ QSizeF(200, 100), "A");
- QGraphicsWidget *b = createItem(QSizeF(100.0, 100.0),
- QSizeF(150.0, 100.0),
- QSizeF(200.0, 100.0));
+ QGraphicsWidget *b = createItem(QSizeF(100, 100),
+ QSizeF(150, 100),
+ QSizeF(300, 100), "B");
- QGraphicsWidget *c = createItem(QSizeF(100.0, 100.0),
- QSizeF(200.0, 100.0),
- QSizeF(300.0, 100.0));
+ QGraphicsWidget *c = createItem(QSizeF(100, 100),
+ QSizeF(200, 100),
+ QSizeF(350, 100), "C");
- QGraphicsWidget *d = createItem(QSizeF(100.0, 100.0),
- QSizeF(170.0, 100.0),
- QSizeF(200.0, 100.0));
+ QGraphicsWidget *d = createItem(QSizeF(100, 100),
+ QSizeF(170, 100),
+ QSizeF(200, 100), "D");
- QGraphicsWidget *e = createItem(QSizeF(150.0, 100.0),
- QSizeF(150.0, 100.0),
- QSizeF(200.0, 100.0));
+ QGraphicsWidget *e = createItem(QSizeF(150, 100),
+ QSizeF(150, 100),
+ QSizeF(200, 100), "E");
- QGraphicsWidget *f = createItem(QSizeF(100.0, 100.0),
- QSizeF(150.0, 100.0),
- QSizeF(200.0, 100.0));
+ QGraphicsWidget *f = createItem(QSizeF(100, 100),
+ QSizeF(150, 100),
+ QSizeF(200, 100), "F");
QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout;
l->setContentsMargins(0, 0, 0, 0);
@@ -203,38 +205,38 @@ void tst_QGraphicsAnchorLayout::parallel()
QSizeF layoutPreferredSize = l->effectiveSizeHint(Qt::PreferredSize);
QSizeF layoutMaximumSize = l->effectiveSizeHint(Qt::MaximumSize);
- QCOMPARE(layoutMinimumSize, QSizeF(450.0, 600.0));
- QCOMPARE(layoutPreferredSize, QSizeF(600.0, 600.0));
- QCOMPARE(layoutMaximumSize, QSizeF(700.0, 600.0));
+ QCOMPARE(layoutMinimumSize, QSizeF(450, 600));
+ QCOMPARE(layoutPreferredSize, QSizeF(620, 600));
+ QCOMPARE(layoutMaximumSize, QSizeF(750, 600));
p.resize(layoutMinimumSize);
- QCOMPARE(a->geometry(), QRectF(0.0, 0.0, 100.0, 100.0));
- QCOMPARE(b->geometry(), QRectF(100.0, 100.0, 100.0, 100.0));
- QCOMPARE(c->geometry(), QRectF(100.0, 200.0, 250.0, 100.0));
- QCOMPARE(d->geometry(), QRectF(200.0, 300.0, 150.0, 100.0));
- QCOMPARE(e->geometry(), QRectF(200.0, 400.0, 150.0, 100.0));
- QCOMPARE(f->geometry(), QRectF(350.0, 500.0, 100.0, 100.0));
+ QCOMPARE(a->geometry(), QRectF(0, 0, 100, 100));
+ QCOMPARE(b->geometry(), QRectF(100, 100, 100, 100));
+ QCOMPARE(c->geometry(), QRectF(100, 200, 250, 100));
+ QCOMPARE(d->geometry(), QRectF(200, 300, 150, 100));
+ QCOMPARE(e->geometry(), QRectF(200, 400, 150, 100));
+ QCOMPARE(f->geometry(), QRectF(350, 500, 100, 100));
QCOMPARE(p.size(), layoutMinimumSize);
p.resize(layoutPreferredSize);
- QCOMPARE(a->geometry(), QRectF(0.0, 0.0, 150.0, 100.0));
- QCOMPARE(b->geometry(), QRectF(150.0, 100.0, 150.0, 100.0));
- QCOMPARE(c->geometry(), QRectF(150.0, 200.0, 300.0, 100.0));
- QCOMPARE(d->geometry(), QRectF(300.0, 300.0, 150.0, 100.0));
- QCOMPARE(e->geometry(), QRectF(300.0, 400.0, 150.0, 100.0));
- QCOMPARE(f->geometry(), QRectF(450.0, 500.0, 150.0, 100.0));
+ QCOMPARE(a->geometry(), QRectF(0, 0, 150, 100));
+ QCOMPARE(b->geometry(), QRectF(150, 100, 150, 100));
+ QCOMPARE(c->geometry(), QRectF(150, 200, 320, 100));
+ QCOMPARE(d->geometry(), QRectF(300, 300, 170, 100));
+ QCOMPARE(e->geometry(), QRectF(300, 400, 170, 100));
+ QCOMPARE(f->geometry(), QRectF(470, 500, 150, 100));
QCOMPARE(p.size(), layoutPreferredSize);
// Maximum size depends on simplification / fair distribution
// Without that, test may or may not pass, depending on the
// solution found by the solver at runtime.
p.resize(layoutMaximumSize);
- QCOMPARE(a->geometry(), QRectF(0.0, 0.0, 200.0, 100.0));
- QCOMPARE(b->geometry(), QRectF(200.0, 100.0, 150.0, 100.0));
- QCOMPARE(c->geometry(), QRectF(200.0, 200.0, 300.0, 100.0));
- QCOMPARE(d->geometry(), QRectF(350.0, 300.0, 150.0, 100.0));
- QCOMPARE(e->geometry(), QRectF(350.0, 400.0, 150.0, 100.0));
- QCOMPARE(f->geometry(), QRectF(500.0, 500.0, 200.0, 100.0));
+ QCOMPARE(a->geometry(), QRectF(0, 0, 200, 100));
+ QCOMPARE(b->geometry(), QRectF(200, 100, 175, 100));
+ QCOMPARE(c->geometry(), QRectF(200, 200, 350, 100));
+ QCOMPARE(d->geometry(), QRectF(375, 300, 175, 100));
+ QCOMPARE(e->geometry(), QRectF(375, 400, 175, 100));
+ QCOMPARE(f->geometry(), QRectF(550, 500, 200, 100));
QCOMPARE(p.size(), layoutMaximumSize);
}