From 337eedb316e94217d6d8b4bb6dc664d26ef3a741 Mon Sep 17 00:00:00 2001 From: Pekka Vuorela Date: Wed, 21 Mar 2012 16:23:33 +0200 Subject: Fixed QLineEdit to emit selectionChanged Was not emitted when removed by input method event. Change-Id: Ia2c0dcb09d42826188d4612f4c1705a41874a31d Reviewed-by: Andrew den Exter --- .../widgets/widgets/qlineedit/tst_qlineedit.cpp | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'tests/auto/widgets/widgets/qlineedit') diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp index 81dc940c00..f67f7ce1e8 100644 --- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp @@ -3846,13 +3846,26 @@ void tst_QLineEdit::inputMethodSelection() QCOMPARE(selectionSpy.count(), 1); QCOMPARE(testWidget->selectionStart(), 0); - QList attributes; - attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 12, 5, QVariant()); - QInputMethodEvent event("", attributes); - QApplication::sendEvent(testWidget, &event); + // selection gained + { + QList attributes; + attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 12, 5, QVariant()); + QInputMethodEvent event("", attributes); + QApplication::sendEvent(testWidget, &event); + } QCOMPARE(selectionSpy.count(), 2); QCOMPARE(testWidget->selectionStart(), 12); + + // selection removed + { + QList attributes; + attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 0, 0, QVariant()); + QInputMethodEvent event("", attributes); + QApplication::sendEvent(testWidget, &event); + } + + QCOMPARE(selectionSpy.count(), 3); } void tst_QLineEdit::inputMethodTentativeCommit() -- cgit v1.2.3