summaryrefslogtreecommitdiffstats
path: root/tests/auto/qgraphicssceneindex
diff options
context:
space:
mode:
authorAriya Hidayat <ariya.hidayat@trolltech.com>2009-03-17 14:56:04 +0100
committerAlexis Menard <alexis.menard@trolltech.com>2009-04-07 20:18:06 +0200
commit8e13ebc41ccbf4d1ec6ba552f8865007db5af875 (patch)
treea84aee77ccf37c1f3f93da42554c36f0917f4134 /tests/auto/qgraphicssceneindex
parent6df288191c5b6de8c6d1f00fd931401dc9f0c342 (diff)
Fixes: Add autotest for overlapped rectangles
Diffstat (limited to 'tests/auto/qgraphicssceneindex')
-rw-r--r--tests/auto/qgraphicssceneindex/tst_qgraphicssceneindex.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/auto/qgraphicssceneindex/tst_qgraphicssceneindex.cpp b/tests/auto/qgraphicssceneindex/tst_qgraphicssceneindex.cpp
index d199351150..f03404e70d 100644
--- a/tests/auto/qgraphicssceneindex/tst_qgraphicssceneindex.cpp
+++ b/tests/auto/qgraphicssceneindex/tst_qgraphicssceneindex.cpp
@@ -63,6 +63,8 @@ private slots:
void customIndex();
void scatteredItems_data();
void scatteredItems();
+ void overlappedItems_data();
+ void overlappedItems();
private:
void common_data();
@@ -144,5 +146,32 @@ void tst_QGraphicsSceneIndex::scatteredItems()
QCOMPARE(scene.items(QRectF(-100, -1000, 0, 0)).count(), 0);
}
+void tst_QGraphicsSceneIndex::overlappedItems_data()
+{
+ common_data();
+}
+
+void tst_QGraphicsSceneIndex::overlappedItems()
+{
+ QFETCH(QString, indexMethod);
+ QGraphicsSceneIndex *index = createIndex(indexMethod);
+
+ QGraphicsScene scene;
+ scene.setSceneIndex(index);
+
+ for (int i = 0; i < 10; ++i)
+ for (int j = 0; j < 10; ++j)
+ scene.addRect(i*50, j*50, 200, 200);
+
+ QCOMPARE(scene.items(QRectF(0, 0, 1000, 1000)).count(), 100);
+ QCOMPARE(scene.items(QRectF(-100, -1000, 0, 0)).count(), 0);
+ QCOMPARE(scene.items(QRectF(0, 0, 200, 200)).count(), 16);
+ QCOMPARE(scene.items(QRectF(0, 0, 100, 100)).count(), 4);
+ QCOMPARE(scene.items(QRectF(0, 0, 1, 100)).count(), 2);
+ QCOMPARE(scene.items(QRectF(0, 0, 1, 1000)).count(), 10);
+}
+
+
+
QTEST_MAIN(tst_QGraphicsSceneIndex)
#include "tst_qgraphicssceneindex.moc"