diff options
author | axis <qt-info@nokia.com> | 2009-05-29 13:49:38 (GMT) |
---|---|---|
committer | axis <qt-info@nokia.com> | 2009-06-03 11:16:48 (GMT) |
commit | c651bff5e560dc495896002ce773b418a05b69a1 (patch) | |
tree | 843e5453c4fef0cf8ba7958d10e881f729751e65 /tests/auto/qinputcontext | |
parent | d9bdb8bf50de5ee3fcd8d9de62f41ad52aacebb3 (diff) | |
download | Qt-c651bff5e560dc495896002ce773b418a05b69a1.zip Qt-c651bff5e560dc495896002ce773b418a05b69a1.tar.gz Qt-c651bff5e560dc495896002ce773b418a05b69a1.tar.bz2 |
Added an autotest for the new selection API in input methods.
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" |