summaryrefslogtreecommitdiffstats
path: root/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp')
-rw-r--r--tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
index d446ca7..9ff086c 100644
--- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
+++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
@@ -289,6 +289,7 @@ private slots:
void taskQTBUG_7863_paintIntoCacheWithTransparentParts();
void taskQT_3674_doNotCrash();
void taskQTBUG_15977_renderWithDeviceCoordinateCache();
+ void taskQTBUG_16401_focusItem();
};
void tst_QGraphicsScene::initTestCase()
@@ -4680,5 +4681,35 @@ void tst_QGraphicsScene::taskQTBUG_15977_renderWithDeviceCoordinateCache()
QCOMPARE(image, expected);
}
+void tst_QGraphicsScene::taskQTBUG_16401_focusItem()
+{
+ QGraphicsScene scene;
+ QGraphicsView view(&scene);
+ QGraphicsRectItem *rect = scene.addRect(0, 0, 100, 100);
+ rect->setFlag(QGraphicsItem::ItemIsFocusable);
+
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+ QApplication::setActiveWindow(&view);
+
+ QVERIFY(!scene.focusItem());
+
+ rect->setFocus();
+ QCOMPARE(scene.focusItem(), rect);
+ QFocusEvent focusOut(QEvent::FocusOut);
+ QApplication::sendEvent(&view, &focusOut);
+ QVERIFY(!scene.focusItem());
+ QFocusEvent focusIn(QEvent::FocusIn);
+ QApplication::sendEvent(&view, &focusIn);
+ QCOMPARE(scene.focusItem(), rect);
+
+ rect->clearFocus();
+ QVERIFY(!scene.focusItem());
+ QApplication::sendEvent(&view, &focusOut);
+ QVERIFY(!scene.focusItem());
+ QApplication::sendEvent(&view, &focusIn);
+ QVERIFY(!scene.focusItem());
+}
+
QTEST_MAIN(tst_QGraphicsScene)
#include "tst_qgraphicsscene.moc"