summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/graphicsview/qgraphicsscene
diff options
context:
space:
mode:
authorPekka Vuorela <pekka.ta.vuorela@nokia.com>2011-12-15 16:22:52 +0200
committerQt by Nokia <qt-info@nokia.com>2011-12-30 11:28:20 +0100
commitb83e98d22c667ae36be5ed85b863c7086482afa4 (patch)
treef4adc468f5834972254684aafa9cfd6f19f07e02 /tests/auto/widgets/graphicsview/qgraphicsscene
parent14e139f39187a6e87d6eed332b11b8a3f8521906 (diff)
Adapt QGraphicsScene test to use QPlatformInputContext
Change-Id: Iaf61798cc78e57563fee088711d39090b722a946 Reviewed-by: Joona Petrell <joona.t.petrell@nokia.com>
Diffstat (limited to 'tests/auto/widgets/graphicsview/qgraphicsscene')
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp41
1 files changed, 17 insertions, 24 deletions
diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
index eebea90a61..d359581f1a 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
@@ -51,6 +51,8 @@
#include <private/qgraphicssceneindex_p.h>
#include <math.h>
#include "../../../gui/painting/qpathclipper/pathcompare.h"
+#include "../../shared/platforminputcontext.h"
+#include <private/qinputpanel_p.h>
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
#include <windows.h>
@@ -186,6 +188,7 @@ class tst_QGraphicsScene : public QObject
Q_OBJECT
public slots:
void initTestCase();
+ void cleanup();
private slots:
void construction();
@@ -289,6 +292,13 @@ void tst_QGraphicsScene::initTestCase()
#endif
}
+void tst_QGraphicsScene::cleanup()
+{
+ // ensure not even skipped tests with custom input context leave it dangling
+ QInputPanelPrivate *inputPanelPrivate = QInputPanelPrivate::get(qApp->inputPanel());
+ inputPanelPrivate->testContext = 0;
+}
+
void tst_QGraphicsScene::construction()
{
QGraphicsScene scene;
@@ -3753,25 +3763,12 @@ 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()
{
+ PlatformInputContext inputContext;
+ QInputPanelPrivate *inputPanelPrivate = QInputPanelPrivate::get(qApp->inputPanel());
+ inputPanelPrivate->testContext = &inputContext;
+
QFETCH(int, flags);
QFETCH(bool, callFocusItem);
@@ -3780,21 +3777,19 @@ void tst_QGraphicsScene::inputMethod()
QGraphicsScene scene;
QGraphicsView view(&scene);
- TestInputContext *inputContext = new TestInputContext;
- qApp->setInputContext(inputContext);
view.show();
QApplication::setActiveWindow(&view);
view.setFocus();
QTest::qWaitForWindowShown(&view);
QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&view));
- inputContext->resetCalls = 0;
+ inputContext.m_resetCallCount = 0;
scene.addItem(item);
QInputMethodEvent event;
scene.setFocusItem(item);
QCOMPARE(!!(item->flags() & QGraphicsItem::ItemIsFocusable), scene.focusItem() == item);
- QCOMPARE(inputContext->resetCalls, 0);
+ QCOMPARE(inputContext.m_resetCallCount, 0);
item->eventCalls = 0;
qApp->sendEvent(&scene, &event);
@@ -3807,9 +3802,7 @@ void tst_QGraphicsScene::inputMethod()
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.
- QEXPECT_FAIL("3", "QTBUG-22456", Abort);
- QCOMPARE(inputContext->resetCalls, callFocusItem ? 2 : 0);
- QCOMPARE(item->eventCalls, callFocusItem ? 2 : 0); // verify correct delivery of "reset" event
+ QCOMPARE(inputContext.m_resetCallCount, callFocusItem ? 2 : 0);
QCOMPARE(item->queryCalls, callFocusItem ? 1 : 0); // verify that value is unaffected
item->eventCalls = 0;