diff options
author | Leonardo Sobral Cunha <leo.cunha@nokia.com> | 2009-10-20 13:33:29 (GMT) |
---|---|---|
committer | Leonardo Sobral Cunha <leo.cunha@nokia.com> | 2009-10-20 15:12:06 (GMT) |
commit | a6b0316c2418a90cb754132a678c38027009e875 (patch) | |
tree | 152be5f5faae16fbc40a6ba513a7e33be9f374ee /tests | |
parent | 70dacb37c85941d5c9fa9d4e37661378d91aa339 (diff) | |
download | Qt-a6b0316c2418a90cb754132a678c38027009e875.zip Qt-a6b0316c2418a90cb754132a678c38027009e875.tar.gz Qt-a6b0316c2418a90cb754132a678c38027009e875.tar.bz2 |
Moved private function to test which graphic items is in front of the other
This function is moved to graphicsitem private because it is needed by
multi-touch event handling and is not specific to bsptreeindex.
Reviewed-by: bnilsen
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 0a6f60e..dcad8e1 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -398,6 +398,7 @@ private slots: void modality_mouseGrabber(); void modality_clickFocus(); void modality_keyEvents(); + void itemIsInFront(); // task specific tests below me void task141694_textItemEnsureVisible(); @@ -9541,5 +9542,47 @@ void tst_QGraphicsItem::modality_keyEvents() QCOMPARE(rect1Spy.counts[QEvent::KeyRelease], 0); } +void tst_QGraphicsItem::itemIsInFront() +{ + QGraphicsScene scene; + QGraphicsRectItem *rect1 = new QGraphicsRectItem; + rect1->setData(0, "rect1"); + scene.addItem(rect1); + + QGraphicsRectItem *rect1child1 = new QGraphicsRectItem(rect1); + rect1child1->setZValue(1); + rect1child1->setData(0, "rect1child1"); + + QGraphicsRectItem *rect1child2 = new QGraphicsRectItem(rect1); + rect1child2->setParentItem(rect1); + rect1child2->setData(0, "rect1child2"); + + QGraphicsRectItem *rect1child1_1 = new QGraphicsRectItem(rect1child1); + rect1child1_1->setData(0, "rect1child1_1"); + + QGraphicsRectItem *rect1child1_2 = new QGraphicsRectItem(rect1child1); + rect1child1_2->setFlag(QGraphicsItem::ItemStacksBehindParent); + rect1child1_2->setData(0, "rect1child1_2"); + + QGraphicsRectItem *rect2 = new QGraphicsRectItem; + rect2->setData(0, "rect2"); + scene.addItem(rect2); + + QGraphicsRectItem *rect2child1 = new QGraphicsRectItem(rect2); + rect2child1->setData(0, "rect2child1"); + + QCOMPARE(qt_closestItemFirst(rect1, rect1), false); + QCOMPARE(qt_closestItemFirst(rect1, rect2), false); + QCOMPARE(qt_closestItemFirst(rect1child1, rect2child1), false); + QCOMPARE(qt_closestItemFirst(rect1child1, rect1child2), true); + QCOMPARE(qt_closestItemFirst(rect1child1_1, rect1child2), true); + QCOMPARE(qt_closestItemFirst(rect1child1_1, rect1child1), true); + QCOMPARE(qt_closestItemFirst(rect1child1_2, rect1child2), true); + QCOMPARE(qt_closestItemFirst(rect1child1_2, rect1child1), false); + QCOMPARE(qt_closestItemFirst(rect1child1_2, rect1), true); + QCOMPARE(qt_closestItemFirst(rect1child1_2, rect2), false); + QCOMPARE(qt_closestItemFirst(rect1child1_2, rect2child1), false); +} + QTEST_MAIN(tst_QGraphicsItem) #include "tst_qgraphicsitem.moc" |