diff options
author | Yoann Lopes <yoann.lopes@nokia.com> | 2011-03-10 16:24:46 (GMT) |
---|---|---|
committer | Yoann Lopes <yoann.lopes@nokia.com> | 2011-03-10 16:35:18 (GMT) |
commit | 1b3514e4b2d9a41f73bf5b87caf73ce409eadf2a (patch) | |
tree | ab226734b91c8286bf2963fdc8faca682b440ae6 /tests/auto/qgraphicsscene | |
parent | 1b326932d48c0e584f9d5173fa5f892c5086fee8 (diff) | |
download | Qt-1b3514e4b2d9a41f73bf5b87caf73ce409eadf2a.zip Qt-1b3514e4b2d9a41f73bf5b87caf73ce409eadf2a.tar.gz Qt-1b3514e4b2d9a41f73bf5b87caf73ce409eadf2a.tar.bz2 |
Fix QGraphicsScene returning incorrect focus item.
When the scene was losing and regaining focus, it was incorrectly
setting the focus on any item that had its focus previously explicitly
cleared.
Autotest included.
Task-number: QTBUG-16401
Reviewed-by: TrustMe
Diffstat (limited to 'tests/auto/qgraphicsscene')
-rw-r--r-- | tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp index b221cd9..5a5c9b7 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() @@ -4652,5 +4653,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" |