summaryrefslogtreecommitdiffstats
path: root/tests/auto/qgraphicssceneindex
diff options
context:
space:
mode:
authorAriya Hidayat <ariya.hidayat@trolltech.com>2009-03-17 15:04:52 +0100
committerAlexis Menard <alexis.menard@trolltech.com>2009-04-07 20:18:40 +0200
commit72f34ea254d2ad93e11f740bf2ed2523f1975ee9 (patch)
treeb7c7de48f2c151f8efb419f35cce1667e2d39d86 /tests/auto/qgraphicssceneindex
parent8e13ebc41ccbf4d1ec6ba552f8865007db5af875 (diff)
Fixes: Add autotest for moving rectangle between items.
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 f03404e70d..9a01cb882e 100644
--- a/tests/auto/qgraphicssceneindex/tst_qgraphicssceneindex.cpp
+++ b/tests/auto/qgraphicssceneindex/tst_qgraphicssceneindex.cpp
@@ -65,6 +65,8 @@ private slots:
void scatteredItems();
void overlappedItems_data();
void overlappedItems();
+ void movingItems_data();
+ void movingItems();
private:
void common_data();
@@ -171,6 +173,33 @@ void tst_QGraphicsSceneIndex::overlappedItems()
QCOMPARE(scene.items(QRectF(0, 0, 1, 1000)).count(), 10);
}
+void tst_QGraphicsSceneIndex::movingItems_data()
+{
+ common_data();
+}
+
+void tst_QGraphicsSceneIndex::movingItems()
+{
+ QFETCH(QString, indexMethod);
+ QGraphicsSceneIndex *index = createIndex(indexMethod);
+
+ QGraphicsScene scene;
+ scene.setSceneIndex(index);
+
+ for (int i = 0; i < 10; ++i)
+ scene.addRect(i*50, i*50, 40, 35);
+
+ QGraphicsRectItem *box = scene.addRect(0, 0, 10, 10);
+ QCOMPARE(scene.items(QRectF(0, 0, 5, 5)).count(), 2);
+
+ box->setPos(10, 10);
+ QCOMPARE(scene.items(QRectF(0, 0, 1, 1)).count(), 1);
+
+ box->setPos(-5, -5);
+ QCOMPARE(scene.items(QRectF(0, 0, 1, 1)).count(), 2);
+
+ QCOMPARE(scene.items(QRectF(0, 0, 1000, 1000)).count(), 11);
+}
QTEST_MAIN(tst_QGraphicsSceneIndex)