diff options
author | Ariya Hidayat <ariya.hidayat@trolltech.com> | 2009-03-17 14:04:52 (GMT) |
---|---|---|
committer | Alexis Menard <alexis.menard@trolltech.com> | 2009-04-07 18:18:40 (GMT) |
commit | 72f34ea254d2ad93e11f740bf2ed2523f1975ee9 (patch) | |
tree | b7c7de48f2c151f8efb419f35cce1667e2d39d86 /tests/auto/qgraphicssceneindex | |
parent | 8e13ebc41ccbf4d1ec6ba552f8865007db5af875 (diff) | |
download | Qt-72f34ea254d2ad93e11f740bf2ed2523f1975ee9.zip Qt-72f34ea254d2ad93e11f740bf2ed2523f1975ee9.tar.gz Qt-72f34ea254d2ad93e11f740bf2ed2523f1975ee9.tar.bz2 |
Fixes: Add autotest for moving rectangle between items.
Diffstat (limited to 'tests/auto/qgraphicssceneindex')
-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 f03404e..9a01cb8 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) |