Re-enable TextEdit pre-edit cursor rectangle test.
Formerly known as micro focus. Change-Id: I4a860e1da488b38b8cf17e79ac922a39ff017dbc Reviewed-by: Martin Jones <martin.jones@nokia.com>
This commit is contained in:
parent
cc8f0227a4
commit
2290062a7d
|
@ -151,7 +151,7 @@ private slots:
|
||||||
void testQtQuick11Attributes();
|
void testQtQuick11Attributes();
|
||||||
void testQtQuick11Attributes_data();
|
void testQtQuick11Attributes_data();
|
||||||
|
|
||||||
void preeditMicroFocus();
|
void preeditCursorRectangle();
|
||||||
void inputContextMouseHandler();
|
void inputContextMouseHandler();
|
||||||
void inputMethodComposing();
|
void inputMethodComposing();
|
||||||
void cursorRectangleSize();
|
void cursorRectangleSize();
|
||||||
|
@ -2179,12 +2179,8 @@ void tst_qquicktextedit::testQtQuick11Attributes_data()
|
||||||
<< ":1 \"TextEdit.onLinkActivated\" is not available in QtQuick 1.0.\n";
|
<< ":1 \"TextEdit.onLinkActivated\" is not available in QtQuick 1.0.\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_qquicktextedit::preeditMicroFocus()
|
void tst_qquicktextedit::preeditCursorRectangle()
|
||||||
{
|
{
|
||||||
#ifdef QTBUG_21691
|
|
||||||
QEXPECT_FAIL("", QTBUG_21691_MESSAGE, Abort);
|
|
||||||
QVERIFY(false);
|
|
||||||
#else
|
|
||||||
QString preeditText = "super";
|
QString preeditText = "super";
|
||||||
|
|
||||||
QQuickView view(QUrl::fromLocalFile(TESTDATA("inputMethodEvent.qml")));
|
QQuickView view(QUrl::fromLocalFile(TESTDATA("inputMethodEvent.qml")));
|
||||||
|
@ -2196,43 +2192,52 @@ void tst_qquicktextedit::preeditMicroFocus()
|
||||||
QQuickTextEdit *edit = qobject_cast<QQuickTextEdit *>(view.rootObject());
|
QQuickTextEdit *edit = qobject_cast<QQuickTextEdit *>(view.rootObject());
|
||||||
QVERIFY(edit);
|
QVERIFY(edit);
|
||||||
|
|
||||||
QSignalSpy cursorRectangleSpy(edit, SIGNAL(cursorRectangleChanged()));
|
QSignalSpy editSpy(edit, SIGNAL(cursorRectangleChanged()));
|
||||||
|
QSignalSpy panelSpy(qGuiApp->inputPanel(), SIGNAL(cursorRectangleChanged()));
|
||||||
|
|
||||||
QRect currentRect;
|
QRect currentRect;
|
||||||
QRect previousRect = edit->inputMethodQuery(Qt::ImCursorRectangle).toRect();
|
|
||||||
|
QInputMethodQueryEvent query(Qt::ImCursorRectangle);
|
||||||
|
QCoreApplication::sendEvent(qGuiApp->inputPanel()->inputItem(), &query);
|
||||||
|
QRect previousRect = query.value(Qt::ImCursorRectangle).toRect();
|
||||||
|
|
||||||
// Verify that the micro focus rect is positioned the same for position 0 as
|
// Verify that the micro focus rect is positioned the same for position 0 as
|
||||||
// it would be if there was no preedit text.
|
// it would be if there was no preedit text.
|
||||||
ic.updateReceived = false;
|
QInputMethodEvent imEvent(preeditText, QList<QInputMethodEvent::Attribute>()
|
||||||
ic.sendPreeditText(preeditText, 0);
|
<< QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, preeditText.length(), QVariant()));
|
||||||
currentRect = edit->inputMethodQuery(Qt::ImCursorRectangle).toRect();
|
QCoreApplication::sendEvent(qGuiApp->inputPanel()->inputItem(), &imEvent);
|
||||||
|
QCoreApplication::sendEvent(qGuiApp->inputPanel()->inputItem(), &query);
|
||||||
|
currentRect = query.value(Qt::ImCursorRectangle).toRect();
|
||||||
QCOMPARE(currentRect, previousRect);
|
QCOMPARE(currentRect, previousRect);
|
||||||
QCOMPARE(ic.updateReceived, false); // The cursor position hasn't changed.
|
QCOMPARE(editSpy.count(), 0);
|
||||||
QCOMPARE(cursorRectangleSpy.count(), 0);
|
QCOMPARE(panelSpy.count(), 0);
|
||||||
|
|
||||||
// Verify that the micro focus rect moves to the left as the cursor position
|
// Verify that the micro focus rect moves to the left as the cursor position
|
||||||
// is incremented.
|
// is incremented.
|
||||||
for (int i = 1; i <= 5; ++i) {
|
for (int i = 1; i <= 5; ++i) {
|
||||||
ic.updateReceived = false;
|
QInputMethodEvent imEvent(preeditText, QList<QInputMethodEvent::Attribute>()
|
||||||
ic.sendPreeditText(preeditText, i);
|
<< QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, i, preeditText.length(), QVariant()));
|
||||||
currentRect = edit->inputMethodQuery(Qt::ImCursorRectangle).toRect();
|
QCoreApplication::sendEvent(qGuiApp->inputPanel()->inputItem(), &imEvent);
|
||||||
|
QCoreApplication::sendEvent(qGuiApp->inputPanel()->inputItem(), &query);
|
||||||
|
currentRect = query.value(Qt::ImCursorRectangle).toRect();
|
||||||
QVERIFY(previousRect.left() < currentRect.left());
|
QVERIFY(previousRect.left() < currentRect.left());
|
||||||
QCOMPARE(ic.updateReceived, true);
|
QVERIFY(editSpy.count() > 0); editSpy.clear();
|
||||||
QVERIFY(cursorRectangleSpy.count() > 0);
|
QVERIFY(panelSpy.count() > 0); panelSpy.clear();
|
||||||
cursorRectangleSpy.clear();
|
|
||||||
previousRect = currentRect;
|
previousRect = currentRect;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify that if there is no preedit cursor then the micro focus rect is the
|
// Verify that if there is no preedit cursor then the micro focus rect is the
|
||||||
// same as it would be if it were positioned at the end of the preedit text.
|
// same as it would be if it were positioned at the end of the preedit text.
|
||||||
ic.sendPreeditText(preeditText, 0);
|
QCoreApplication::sendEvent(qGuiApp->inputPanel()->inputItem(), &imEvent);
|
||||||
ic.updateReceived = false;
|
editSpy.clear();
|
||||||
ic.sendEvent(QInputMethodEvent(preeditText, QList<QInputMethodEvent::Attribute>()));
|
panelSpy.clear();
|
||||||
currentRect = edit->inputMethodQuery(Qt::ImCursorRectangle).toRect();
|
{ QInputMethodEvent imEvent(preeditText, QList<QInputMethodEvent::Attribute>());
|
||||||
|
QCoreApplication::sendEvent(qGuiApp->inputPanel()->inputItem(), &imEvent); }
|
||||||
|
QCoreApplication::sendEvent(qGuiApp->inputPanel()->inputItem(), &query);
|
||||||
|
currentRect = query.value(Qt::ImCursorRectangle).toRect();
|
||||||
QCOMPARE(currentRect, previousRect);
|
QCOMPARE(currentRect, previousRect);
|
||||||
QCOMPARE(ic.updateReceived, true);
|
QVERIFY(editSpy.count() > 0);
|
||||||
QVERIFY(cursorRectangleSpy.count() > 0);
|
QVERIFY(panelSpy.count() > 0);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_qquicktextedit::inputContextMouseHandler()
|
void tst_qquicktextedit::inputContextMouseHandler()
|
||||||
|
|
Loading…
Reference in New Issue