diff options
author | Andrew den Exter <andrew.den-exter@nokia.com> | 2011-07-25 15:48:01 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-07-26 01:35:59 +0200 |
commit | ac22379a75b2e252ae0fe6fe2585e3beb2096be9 (patch) | |
tree | d2d99c3e2ec7e55e0e1e794629638a7d232e384a /tests/auto/qtextedit/tst_qtextedit.cpp | |
parent | ef2384ad57c7e7ea40937cced6e6210fd371a978 (diff) |
Emit selectionChanged signals when input method alters the selection.
Check if the input method removes the selection and force emit
selectionChanged if it sets a new selection.
Task-number: QTBUG-19727
Reviewed-by: Martin Jones
Change-Id: Ic8ea1044d0917aac4e52368f431ac9e5c7db7c56
Reviewed-on: http://codereview.qt.nokia.com/2076
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Andrew den Exter <andrew.den-exter@nokia.com>
Diffstat (limited to 'tests/auto/qtextedit/tst_qtextedit.cpp')
-rw-r--r-- | tests/auto/qtextedit/tst_qtextedit.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/auto/qtextedit/tst_qtextedit.cpp b/tests/auto/qtextedit/tst_qtextedit.cpp index 65158d3d7a..7208861394 100644 --- a/tests/auto/qtextedit/tst_qtextedit.cpp +++ b/tests/auto/qtextedit/tst_qtextedit.cpp @@ -207,6 +207,8 @@ private slots: void bidiLogicalMovement_data(); void bidiLogicalMovement(); + void inputMethodSelection(); + private: void createSelection(); int blockCount() const; @@ -2365,5 +2367,30 @@ void tst_QTextEdit::bidiLogicalMovement() } while (moved && i >= 0); } +void tst_QTextEdit::inputMethodSelection() +{ + ed->setText("Lorem ipsum dolor sit amet, consectetur adipiscing elit."); + + QSignalSpy selectionSpy(ed, SIGNAL(selectionChanged())); + QTextCursor cursor = ed->textCursor(); + cursor.setPosition(0); + cursor.setPosition(5, QTextCursor::KeepAnchor); + ed->setTextCursor(cursor); + + QCOMPARE(selectionSpy.count(), 1); + QCOMPARE(ed->textCursor().selectionStart(), 0); + QCOMPARE(ed->textCursor().selectionEnd(), 5); + + QList<QInputMethodEvent::Attribute> attributes; + attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 12, 5, QVariant()); + QInputMethodEvent event("", attributes); + QApplication::sendEvent(ed, &event); + + QCOMPARE(selectionSpy.count(), 2); + QCOMPARE(ed->textCursor().selectionStart(), 12); + QCOMPARE(ed->textCursor().selectionEnd(), 17); +} + + QTEST_MAIN(tst_QTextEdit) #include "tst_qtextedit.moc" |