diff options
author | Yoann Lopes <yoann.lopes@nokia.com> | 2010-04-26 10:31:41 (GMT) |
---|---|---|
committer | Yoann Lopes <yoann.lopes@nokia.com> | 2010-04-26 10:54:24 (GMT) |
commit | 27668f4df1756225cfa07fe4195024b501d66d25 (patch) | |
tree | 13a0d209bed7df90c708ac63b95a6a82bf36e7a8 /tests/auto | |
parent | 8daa3ee6591f0ec5f65552a8a9290228d6e9f0ab (diff) | |
download | Qt-27668f4df1756225cfa07fe4195024b501d66d25.zip Qt-27668f4df1756225cfa07fe4195024b501d66d25.tar.gz Qt-27668f4df1756225cfa07fe4195024b501d66d25.tar.bz2 |
Fixes selection being cleared when right clicking on a selected item.
Autotest included.
Task-number: QTBUG-10138
Reviewed-by: bnilsen
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 03ce45a..6e7c83c 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -294,6 +294,7 @@ private slots: void explicitlyEnabled(); void selected(); void selected2(); + void selected3(); void selected_group(); void selected_textItem(); void selected_multi(); @@ -1453,6 +1454,43 @@ void tst_QGraphicsItem::selected2() } } +void tst_QGraphicsItem::selected3() +{ + QGraphicsScene scene; + QGraphicsItem *item1 = scene.addRect(QRectF(0, 0, 100, 100)); + item1->setFlag(QGraphicsItem::ItemIsSelectable); + + QGraphicsItem *item2 = scene.addRect(QRectF(100, 100, 100, 100)); + item2->setFlag(QGraphicsItem::ItemIsSelectable); + + item1->setSelected(true); + QGraphicsView view(&scene); + view.show(); + QTest::qWaitForWindowShown(&view); + + QVERIFY(item1->isSelected()); + QVERIFY(!item2->isSelected()); + + // Right click on a selected item should not clear the selection + QTest::mouseClick(view.viewport(), Qt::RightButton, 0, view.mapFromScene(item1->boundingRect().center())); + QVERIFY(item1->isSelected()); + QCOMPARE(scene.selectedItems().count(), 1); + + // Right click on an unselected item should clear the selection + QTest::mouseClick(view.viewport(), Qt::RightButton, 0, view.mapFromScene(item2->boundingRect().center())); + QVERIFY(!item1->isSelected()); + QCOMPARE(scene.selectedItems().count(), 0); + + item2->setSelected(true); + QVERIFY(item2->isSelected()); + QCOMPARE(scene.selectedItems().count(), 1); + + // Right click on the scene background should clear the selection + QTest::mouseClick(view.viewport(), Qt::RightButton, 0, view.mapFromScene(QPointF(0, 110))); + QVERIFY(!item2->isSelected()); + QCOMPARE(scene.selectedItems().count(), 0); +} + void tst_QGraphicsItem::selected_group() { QGraphicsScene scene; |