summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJan-Arve Sæther <jan-arve.saether@nokia.com>2010-04-29 07:11:02 (GMT)
committerJan-Arve Sæther <jan-arve.saether@nokia.com>2010-04-29 08:58:53 (GMT)
commitb7ea50145c6dc443e15d9f3f1e1dd1737a5135cc (patch)
tree6aa0990060d5f3c7f9a00bee913da8a668e4d92d /tests
parentcc1d15dc46ecdc661e9eb96e0a6c2bd3832d5c83 (diff)
downloadQt-b7ea50145c6dc443e15d9f3f1e1dd1737a5135cc.zip
Qt-b7ea50145c6dc443e15d9f3f1e1dd1737a5135cc.tar.gz
Qt-b7ea50145c6dc443e15d9f3f1e1dd1737a5135cc.tar.bz2
Ensured that WA_InputMethodEnabled was set before FocusInEvent was sent.
When focusInEvent is called we need to ensure that WA_InputMethodEnabled is set, since FocusInEvent might lead to that QInputContext::setFocusWidget is called (with the QGraphicsView as the widget parameter). However, if the widget still does not have WA_InputMethodEnabled set yet it will assert in QInputContext::setFocusWidget (it requires that the widget has the flag set). This was a problem for the morbit bridge, where Dui requires the attribute to be set (while Orbit actually does not require) Task-number: QTBUG-10276 Reviewed-by: jasplin Reviewed-by: Alexis Menard
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qgraphicsview/tst_qgraphicsview.cpp26
1 files changed, 24 insertions, 2 deletions
diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
index 1c19fab..e3c699b 100644
--- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
+++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
@@ -3664,6 +3664,22 @@ void tst_QGraphicsView::update()
#endif
}
+class FocusItem : public QGraphicsRectItem
+{
+public:
+ FocusItem() : QGraphicsRectItem(0, 0, 20, 20) {
+ m_viewHasIMEnabledInFocusInEvent = false;
+ }
+
+ void focusInEvent(QFocusEvent *event)
+ {
+ QGraphicsView *view = scene()->views().first();
+ m_viewHasIMEnabledInFocusInEvent = view->testAttribute(Qt::WA_InputMethodEnabled);
+ }
+
+ bool m_viewHasIMEnabledInFocusInEvent;
+};
+
void tst_QGraphicsView::inputMethodSensitivity()
{
QGraphicsScene scene;
@@ -3673,7 +3689,7 @@ void tst_QGraphicsView::inputMethodSensitivity()
QApplication::setActiveWindow(&view);
QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view));
- QGraphicsRectItem *item = new QGraphicsRectItem;
+ FocusItem *item = new FocusItem;
view.setAttribute(Qt::WA_InputMethodEnabled, true);
@@ -3702,6 +3718,7 @@ void tst_QGraphicsView::inputMethodSensitivity()
scene.setFocusItem(item);
QCOMPARE(scene.focusItem(), static_cast<QGraphicsItem *>(item));
QCOMPARE(view.testAttribute(Qt::WA_InputMethodEnabled), true);
+ QCOMPARE(item->m_viewHasIMEnabledInFocusInEvent, true);
item->setFlag(QGraphicsItem::ItemAcceptsInputMethod, false);
QCOMPARE(view.testAttribute(Qt::WA_InputMethodEnabled), false);
@@ -3710,15 +3727,17 @@ void tst_QGraphicsView::inputMethodSensitivity()
QCOMPARE(view.testAttribute(Qt::WA_InputMethodEnabled), true);
// introduce another item that is focusable but does not accept input methods
- QGraphicsRectItem *item2 = new QGraphicsRectItem;
+ FocusItem *item2 = new FocusItem;
item2->setFlag(QGraphicsItem::ItemIsFocusable);
scene.addItem(item2);
scene.setFocusItem(item2);
QCOMPARE(view.testAttribute(Qt::WA_InputMethodEnabled), false);
+ QCOMPARE(item2->m_viewHasIMEnabledInFocusInEvent, false);
QCOMPARE(scene.focusItem(), static_cast<QGraphicsItem *>(item2));
scene.setFocusItem(item);
QCOMPARE(view.testAttribute(Qt::WA_InputMethodEnabled), true);
+ QCOMPARE(item->m_viewHasIMEnabledInFocusInEvent, true);
QCOMPARE(scene.focusItem(), static_cast<QGraphicsItem *>(item));
view.setScene(0);
@@ -3727,10 +3746,12 @@ void tst_QGraphicsView::inputMethodSensitivity()
view.setScene(&scene);
QCOMPARE(view.testAttribute(Qt::WA_InputMethodEnabled), true);
+ QCOMPARE(item->m_viewHasIMEnabledInFocusInEvent, true);
QCOMPARE(scene.focusItem(), static_cast<QGraphicsItem *>(item));
scene.setFocusItem(item2);
QCOMPARE(view.testAttribute(Qt::WA_InputMethodEnabled), false);
+ QCOMPARE(item2->m_viewHasIMEnabledInFocusInEvent, false);
QCOMPARE(scene.focusItem(), static_cast<QGraphicsItem *>(item2));
view.setScene(0);
@@ -3743,6 +3764,7 @@ void tst_QGraphicsView::inputMethodSensitivity()
view.setScene(&scene);
QCOMPARE(view.testAttribute(Qt::WA_InputMethodEnabled), true);
+ QCOMPARE(item->m_viewHasIMEnabledInFocusInEvent, true);
QCOMPARE(scene.focusItem(), static_cast<QGraphicsItem *>(item));
}