Remove QInputContext based test from QGraphicsItem tests

Was basically checking that a method call is a method call and
QApplication::setInputContext() sets the input context.

Change-Id: Ia8723fe245f2480d503f0140f61078dc074161fc
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Joona Petrell <joona.t.petrell@nokia.com>
This commit is contained in:
Pekka Vuorela 2011-12-15 16:06:27 +02:00 committed by Qt by Nokia
parent db55b6aee7
commit a32df45bec

View File

@ -61,7 +61,6 @@
#include <QScrollBar>
#include <QVBoxLayout>
#include <QGraphicsEffect>
#include <QInputContext>
#include <QPushButton>
#include <QLineEdit>
#include <QGraphicsLinearLayout>
@ -440,7 +439,6 @@ private slots:
void modality_keyEvents();
void itemIsInFront();
void scenePosChange();
void updateMicroFocus();
void textItem_shortcuts();
void scroll();
void focusHandling_data();
@ -10436,86 +10434,6 @@ void tst_QGraphicsItem::scenePosChange()
QCOMPARE(child2->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 0);
}
class MyInputContext : public QInputContext
{
public:
MyInputContext() : nbUpdates(0) {}
~MyInputContext() {}
QString identifierName() { return QString(); }
QString language() { return QString(); }
void reset() {}
bool isComposing() const { return false; }
void update() { nbUpdates++; }
bool nbUpdates;
};
class MyInputWidget : public QGraphicsWidget
{
public:
MyInputWidget()
{
setFlag(QGraphicsItem::ItemIsFocusable, true);
setFlag(QGraphicsItem::ItemAcceptsInputMethod, true);
}
void mousePressEvent(QGraphicsSceneMouseEvent *event)
{
event->accept();
}
void doUpdateMicroFocus()
{
if (QWidget *fw = QApplication::focusWidget()) {
if (scene()) {
for (int i = 0 ; i < scene()->views().count() ; ++i) {
if (scene()->views().at(i) == fw) {
if (QInputContext *inputContext = fw->inputContext()) {
inputContext->update();
}
}
}
}
}
}
};
void tst_QGraphicsItem::updateMicroFocus()
{
#if defined Q_OS_WIN || defined Q_OS_MAC
QSKIP("QTBUG-9578");
#endif
QGraphicsScene scene;
QWidget parent;
QGridLayout layout;
parent.setLayout(&layout);
QGraphicsView view(&scene);
QGraphicsView view2(&scene);
layout.addWidget(&view, 0, 0);
layout.addWidget(&view2, 0, 1);
MyInputContext *ic = new MyInputContext;
qApp->setInputContext(ic);
MyInputWidget input;
input.setPos(0, 0);
input.resize(150, 150);
scene.addItem(&input);
input.setFocus();
parent.show();
view.setFocus();
qApp->setAutoSipEnabled(true);
QApplication::setActiveWindow(&parent);
QTest::qWaitForWindowShown(&parent);
QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(&parent));
//We reset the number of updates that happened previously (initialisation)
ic->nbUpdates = 0;
input.doUpdateMicroFocus();
QApplication::processEvents();
QTRY_COMPARE(ic->nbUpdates, 1);
}
void tst_QGraphicsItem::textItem_shortcuts()
{
QWidget w;