diff options
Diffstat (limited to 'tests/auto/qinputcontext')
-rw-r--r-- | tests/auto/qinputcontext/tst_qinputcontext.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/auto/qinputcontext/tst_qinputcontext.cpp b/tests/auto/qinputcontext/tst_qinputcontext.cpp index 90ab071..444672e 100644 --- a/tests/auto/qinputcontext/tst_qinputcontext.cpp +++ b/tests/auto/qinputcontext/tst_qinputcontext.cpp @@ -66,6 +66,7 @@ private slots: void filterMouseEvents(); void requestSoftwareInputPanel(); void closeSoftwareInputPanel(); + void selections(); }; void tst_QInputContext::maximumTextLength() @@ -191,5 +192,23 @@ void tst_QInputContext::closeSoftwareInputPanel() QCOMPARE(ic2->lastType, QEvent::CloseSoftwareInputPanel); } +void tst_QInputContext::selections() +{ + QLineEdit le; + le.setText("Test text"); + le.setSelection(2, 2); + QCOMPARE(le.inputMethodQuery(Qt::ImCursorPosition).toInt(), 4); + QCOMPARE(le.inputMethodQuery(Qt::ImAnchorPosition).toInt(), 2); + + QList<QInputMethodEvent::Attribute> attributes; + attributes.append(QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 5, 3, QVariant())); + QInputMethodEvent event("", attributes); + QApplication::sendEvent(&le, &event); + QCOMPARE(le.cursorPosition(), 8); + QCOMPARE(le.selectionStart(), 5); + QCOMPARE(le.inputMethodQuery(Qt::ImCursorPosition).toInt(), 8); + QCOMPARE(le.inputMethodQuery(Qt::ImAnchorPosition).toInt(), 5); +} + QTEST_MAIN(tst_QInputContext) #include "tst_qinputcontext.moc" |