diff options
author | Andrew den Exter <andrew.den-exter@nokia.com> | 2011-02-09 06:34:57 (GMT) |
---|---|---|
committer | Andrew den Exter <andrew.den-exter@nokia.com> | 2011-02-09 07:01:15 (GMT) |
commit | 1759f7d688903210a142d7f93a6d173c52995d2f (patch) | |
tree | 9af3b637f86cc586d202e932f63af3c96d7146c1 /tests | |
parent | eb1db74fb59ecb40d541644ce31ce7ec7b2620d2 (diff) | |
download | Qt-1759f7d688903210a142d7f93a6d173c52995d2f.zip Qt-1759f7d688903210a142d7f93a6d173c52995d2f.tar.gz Qt-1759f7d688903210a142d7f93a6d173c52995d2f.tar.bz2 |
Fix auto test failure.
Allow the input context to be reset twice. The context is reset
because of two events, the first is because an item lost focus and that
reset needs to occur before the focus moves away from the item or events
won't be delivered to it. The second redundant reset is because the
Qt::WA_InputMethodEnabled flag was cleared on the view widget because
no item has focus and it has no way to know the context doesn't need
to be reset.
Change-Id: Ie3b3fc6898d144ed3f8b3822e49ea0eee7e029f4
Reviewed-by: Martin Jones
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qgraphicsview/tst_qgraphicsview.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp index dcd679f..3c4984e 100644 --- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp @@ -4141,11 +4141,14 @@ void tst_QGraphicsView::inputContextReset() inputContext.resets = 0; scene.setFocusItem(0); - QCOMPARE(inputContext.resets, 1); + // the input context is reset twice, once because an item has lost focus and again because + // the Qt::WA_InputMethodEnabled flag is cleared because no item has focus. + QCOMPARE(inputContext.resets, 2); // introduce another item that is focusable but does not accept input methods QGraphicsItem *item2 = new QGraphicsRectItem; - item1->setFlags(QGraphicsItem::ItemIsFocusable); + item2->setFlags(QGraphicsItem::ItemIsFocusable); + scene.addItem(item2); inputContext.resets = 0; scene.setFocusItem(item2); @@ -4154,6 +4157,11 @@ void tst_QGraphicsView::inputContextReset() inputContext.resets = 0; scene.setFocusItem(item1); QCOMPARE(inputContext.resets, 0); + + // test changing between between items that accept input methods. + item2->setFlags(QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemAcceptsInputMethod); + scene.setFocusItem(item2); + QCOMPARE(inputContext.resets, 1); } void tst_QGraphicsView::indirectPainting() |