summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp27
-rw-r--r--tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp20
2 files changed, 47 insertions, 0 deletions
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index 1ae3ecf..3634ce9 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -463,6 +463,7 @@ private slots:
void sortItemsWhileAdding();
void doNotMarkFullUpdateIfNotInScene();
void itemDiesDuringDraggingOperation();
+ void QTBUG_12112_focusItem();
private:
QList<QGraphicsItem *> paintedItems;
@@ -10724,5 +10725,31 @@ void tst_QGraphicsItem::itemDiesDuringDraggingOperation()
delete item;
QVERIFY(QGraphicsScenePrivate::get(&scene)->dragDropItem == 0);
}
+
+void tst_QGraphicsItem::QTBUG_12112_focusItem()
+{
+ QGraphicsScene scene;
+ QGraphicsView view(&scene);
+ QGraphicsRectItem *item1 = new QGraphicsRectItem(0, 0, 20, 20);
+ item1->setFlag(QGraphicsItem::ItemIsFocusable);
+ QGraphicsRectItem *item2 = new QGraphicsRectItem(20, 20, 20, 20);
+ item2->setFlag(QGraphicsItem::ItemIsFocusable);
+ item1->setFocus();
+ scene.addItem(item2);
+ scene.addItem(item1);
+
+ view.show();
+ QApplication::setActiveWindow(&view);
+ QTest::qWaitForWindowShown(&view);
+ QTRY_COMPARE(QApplication::activeWindow(), (QWidget *)&view);
+
+ QVERIFY(item1->focusItem());
+ QVERIFY(!item2->focusItem());
+
+ item2->setFocus();
+ QVERIFY(!item1->focusItem());
+ QVERIFY(item2->focusItem());
+}
+
QTEST_MAIN(tst_QGraphicsItem)
#include "tst_qgraphicsitem.moc"
diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
index ed8ff04..a771332 100644
--- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
+++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
@@ -176,6 +176,7 @@ private slots:
void task243004_setStyleCrash();
void task250119_shortcutContext();
void QT_BUG_6544_tabFocusFirstUnsetWhenRemovingItems();
+ void QT_BUG_12056_tabFocusFirstUnsetWhenRemovingItems();
};
@@ -3089,6 +3090,25 @@ void tst_QGraphicsWidget::QT_BUG_6544_tabFocusFirstUnsetWhenRemovingItems()
//This should not crash
}
+void tst_QGraphicsWidget::QT_BUG_12056_tabFocusFirstUnsetWhenRemovingItems()
+{
+ QGraphicsScene scene;
+ QGraphicsWidget* item1 = new QGraphicsWidget;
+ QGraphicsWidget* item2 = new QGraphicsWidget;
+ QGraphicsWidget* item3 = new QGraphicsWidget;
+
+ scene.addItem(item1);
+ scene.addItem(item2);
+
+ scene.removeItem(item2);
+ scene.removeItem(item1);
+ delete item2;
+ delete item1;
+
+ scene.addItem(item3);
+
+ //This should not crash
+}
QTEST_MAIN(tst_QGraphicsWidget)
#include "tst_qgraphicswidget.moc"