summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorJan-Arve Sæther <jan-arve.saether@nokia.com>2009-08-27 07:30:32 (GMT)
committerJan-Arve Sæther <jan-arve.saether@nokia.com>2009-08-27 08:24:08 (GMT)
commit574fcf93bd5420a7e668466259de5c89b485fef2 (patch)
treeefc70f16e85fe94e3618818f64ab90c1700d5884 /tests/auto
parent35dbf37c70cd27494e9463b7b75c83ad7a671f1e (diff)
downloadQt-574fcf93bd5420a7e668466259de5c89b485fef2.zip
Qt-574fcf93bd5420a7e668466259de5c89b485fef2.tar.gz
Qt-574fcf93bd5420a7e668466259de5c89b485fef2.tar.bz2
Make sure itemAt() reflects the visual order.
This means it should respect the order that was defined with insertItem() and addItem(). Note that this is not strictly necessary (as now explicitly written in the docs for QGraphicsLayout::itemAt()), but commit 2ec56d158dc140f68efb45e2e0613f0e4026ddf6 broke the order and for people that relied on this that commit caused a regression. In addition, after commit 2ec56d158dc140f68efb45e2e0613f0e4026ddf6 it was not longer possible to query the "item at visual index". Thus, instead of adding another function (like QGGL::itemAt(int,int)) we make sure that itemAt() also returns the "item at visual index".
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp25
1 files changed, 24 insertions, 1 deletions
diff --git a/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp b/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
index 1d81ac8..51c96b1 100644
--- a/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
+++ b/tests/auto/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
@@ -76,6 +76,7 @@ private slots:
void invalidate();
void itemAt_data();
void itemAt();
+ void itemAt_visualOrder();
void orientation_data();
void orientation();
void removeAt_data();
@@ -537,7 +538,7 @@ void tst_QGraphicsLinearLayout::insertItem()
QCOMPARE(layout.count(), itemCount + layoutCount + 1);
if (insertItemAt >= 0 && (itemCount + layoutCount >= 0)) {
- QCOMPARE(layout.itemAt(itemCount + layoutCount), item);
+ QCOMPARE(layout.itemAt(insertItemAt), item);
}
layout.activate();
@@ -686,6 +687,28 @@ void tst_QGraphicsLinearLayout::itemAt()
QVERIFY(layout.itemAt(index) != 0);
}
+void tst_QGraphicsLinearLayout::itemAt_visualOrder()
+{
+ QGraphicsLinearLayout *l = new QGraphicsLinearLayout;
+
+ QGraphicsWidget *w1 = new QGraphicsWidget;
+ l->addItem(w1);
+
+ QGraphicsWidget *w3 = new QGraphicsWidget;
+ l->addItem(w3);
+
+ QGraphicsWidget *w0 = new QGraphicsWidget;
+ l->insertItem(0, w0);
+
+ QGraphicsWidget *w2 = new QGraphicsWidget;
+ l->insertItem(2, w2);
+
+ QCOMPARE(l->itemAt(0), w0);
+ QCOMPARE(l->itemAt(1), w1);
+ QCOMPARE(l->itemAt(2), w2);
+ QCOMPARE(l->itemAt(3), w3);
+}
+
void tst_QGraphicsLinearLayout::orientation_data()
{
QTest::addColumn<Qt::Orientation>("orientation");