summaryrefslogtreecommitdiffstats
path: root/tests/auto/qgraphicsscene
diff options
context:
space:
mode:
authoraxis <qt-info@nokia.com>2011-02-24 16:07:22 (GMT)
committeraxis <qt-info@nokia.com>2011-02-24 16:07:22 (GMT)
commit2b768ad7d4de4862584762a7d106d9cfcc3416df (patch)
tree0ddfe84f345d7e61ce71daa51fbbfb373c3e3106 /tests/auto/qgraphicsscene
parentbb7d9bcc8e0c617091e91f7a40f3d33f8c1cdec1 (diff)
parentca7be48b7a150952a9657d1000941fb986e5bb2b (diff)
downloadQt-2b768ad7d4de4862584762a7d106d9cfcc3416df.zip
Qt-2b768ad7d4de4862584762a7d106d9cfcc3416df.tar.gz
Qt-2b768ad7d4de4862584762a7d106d9cfcc3416df.tar.bz2
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt into earth-master
Conflicts: src/network/access/qnetworkreplyimpl.cpp tests/auto/moc/tst_moc.cpp
Diffstat (limited to 'tests/auto/qgraphicsscene')
-rw-r--r--tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp32
1 files changed, 30 insertions, 2 deletions
diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
index b221cd9..d446ca7 100644
--- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
+++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
@@ -3838,6 +3838,23 @@ public:
mutable int queryCalls;
};
+class TestInputContext : public QInputContext
+{
+public:
+ TestInputContext() {}
+
+ QString identifierName() { return QString(); }
+ QString language() { return QString(); }
+
+ void reset() {
+ ++resetCalls;
+ sendEvent(QInputMethodEvent()); }
+
+ bool isComposing() const { return false; }
+
+ int resetCalls;
+};
+
void tst_QGraphicsScene::inputMethod()
{
QFETCH(int, flags);
@@ -3847,14 +3864,22 @@ void tst_QGraphicsScene::inputMethod()
item->setFlags((QGraphicsItem::GraphicsItemFlags)flags);
QGraphicsScene scene;
- QEvent activate(QEvent::WindowActivate);
- QApplication::sendEvent(&scene, &activate);
+ QGraphicsView view(&scene);
+ TestInputContext inputContext;
+ view.setInputContext(&inputContext);
+ view.show();
+ QApplication::setActiveWindow(&view);
+ view.setFocus();
+ QTest::qWaitForWindowShown(&view);
+ QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view));
+ inputContext.resetCalls = 0;
scene.addItem(item);
QInputMethodEvent event;
scene.setFocusItem(item);
QCOMPARE(!!(item->flags() & QGraphicsItem::ItemIsFocusable), scene.focusItem() == item);
+ QCOMPARE(inputContext.resetCalls, 0);
item->eventCalls = 0;
qApp->sendEvent(&scene, &event);
@@ -3865,6 +3890,9 @@ void tst_QGraphicsScene::inputMethod()
QCOMPARE(item->queryCalls, callFocusItem ? 1 : 0);
scene.setFocusItem(0);
+ // 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.resetCalls, callFocusItem ? 2 : 0);
QCOMPARE(item->eventCalls, callFocusItem ? 2 : 0); // verify correct delivery of "reset" event
QCOMPARE(item->queryCalls, callFocusItem ? 1 : 0); // verify that value is unaffected