diff options
author | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2009-07-10 14:42:08 (GMT) |
---|---|---|
committer | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2009-07-10 15:02:23 (GMT) |
commit | 3384aea1357a0f2e7c633701f467d5f8b0855c50 (patch) | |
tree | 51017d746f571f65833c2fd70ca4a6a1aab49b1e /tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | |
parent | c1cf0eb65e87386d1875ed309e5c13cdc0f33e3d (diff) | |
download | Qt-3384aea1357a0f2e7c633701f467d5f8b0855c50.zip Qt-3384aea1357a0f2e7c633701f467d5f8b0855c50.tar.gz Qt-3384aea1357a0f2e7c633701f467d5f8b0855c50.tar.bz2 |
Fixes broken item-lookup for untransformable items.
Found during manual testing (manualtests/graphicsview/untransformable).
At some point it was not possible to click on an untransformable item.
The problem was that none of the untransformable items were top-levels,
and none of the transformable top-level items were in the same area,
resulting in an empty list of estimated top-level items.
Auto-test included.
Diffstat (limited to 'tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp')
-rw-r--r-- | tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 2dbd5f1..4e669ae 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -231,6 +231,7 @@ private slots: void sorting_data(); void sorting(); void itemHasNoContents(); + void hitTestUntransformableItem(); // task specific tests below me void task141694_textItemEnsureVisible(); @@ -7131,5 +7132,55 @@ void tst_QGraphicsItem::itemHasNoContents() QCOMPARE(_paintedItems, QList<QGraphicsItem *>() << item2); } +void tst_QGraphicsItem::hitTestUntransformableItem() +{ + QGraphicsScene scene; + scene.setSceneRect(-100, -100, 200, 200); + + QGraphicsView view(&scene); + view.show(); +#ifdef Q_WS_X11 + qt_x11_wait_for_window_manager(&view); +#endif + QTest::qWait(100); + + // Confuse the BSP with dummy items. + QGraphicsRectItem *dummy = new QGraphicsRectItem(0, 0, 20, 20); + dummy->setPos(-100, -100); + scene.addItem(dummy); + for (int i = 0; i < 100; ++i) { + QGraphicsItem *parent = dummy; + dummy = new QGraphicsRectItem(0, 0, 20, 20); + dummy->setPos(-100 + i, -100 + i); + dummy->setParentItem(parent); + } + + QGraphicsRectItem *item1 = new QGraphicsRectItem(0, 0, 20, 20); + item1->setPos(-200, -200); + + QGraphicsRectItem *item2 = new QGraphicsRectItem(0, 0, 20, 20); + item2->setFlag(QGraphicsItem::ItemIgnoresTransformations); + item2->setParentItem(item1); + item2->setPos(200, 200); + + QGraphicsRectItem *item3 = new QGraphicsRectItem(0, 0, 20, 20); + item3->setParentItem(item2); + item3->setPos(80, 80); + + scene.addItem(item1); + QTest::qWait(100); + + QList<QGraphicsItem *> items = scene.items(QPointF(80, 80)); + QCOMPARE(items.size(), 1); + QCOMPARE(items.at(0), static_cast<QGraphicsItem*>(item3)); + + scene.setItemIndexMethod(QGraphicsScene::NoIndex); + QTest::qWait(100); + + items = scene.items(QPointF(80, 80)); + QCOMPARE(items.size(), 1); + QCOMPARE(items.at(0), static_cast<QGraphicsItem*>(item3)); +} + QTEST_MAIN(tst_QGraphicsItem) #include "tst_qgraphicsitem.moc" |