diff options
author | Ariya Hidayat <ariya.hidayat@trolltech.com> | 2009-03-17 13:56:04 (GMT) |
---|---|---|
committer | Alexis Menard <alexis.menard@trolltech.com> | 2009-04-07 18:18:06 (GMT) |
commit | 8e13ebc41ccbf4d1ec6ba552f8865007db5af875 (patch) | |
tree | a84aee77ccf37c1f3f93da42554c36f0917f4134 /tests/auto | |
parent | 6df288191c5b6de8c6d1f00fd931401dc9f0c342 (diff) | |
download | Qt-8e13ebc41ccbf4d1ec6ba552f8865007db5af875.zip Qt-8e13ebc41ccbf4d1ec6ba552f8865007db5af875.tar.gz Qt-8e13ebc41ccbf4d1ec6ba552f8865007db5af875.tar.bz2 |
Fixes: Add autotest for overlapped rectangles
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qgraphicssceneindex/tst_qgraphicssceneindex.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/auto/qgraphicssceneindex/tst_qgraphicssceneindex.cpp b/tests/auto/qgraphicssceneindex/tst_qgraphicssceneindex.cpp index d199351..f03404e 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" |