diff --git a/autotests/klineedit_unittest.cpp b/autotests/klineedit_unittest.cpp --- a/autotests/klineedit_unittest.cpp +++ b/autotests/klineedit_unittest.cpp @@ -68,7 +68,7 @@ #endif QCOMPARE(textChangedSpy.count(), 1); QCOMPARE(textChangedSpy[0][0].toString(), w.text()); - QCOMPARE(textEditedSpy.count(), 1); + QCOMPARE(textEditedSpy.count(), 0); QVERIFY(!w.isModified()); #ifndef KCOMPLETION_NO_DEPRECATED userTextChangedSpy.clear(); @@ -76,6 +76,32 @@ textChangedSpy.clear(); textEditedSpy.clear(); + // calling clear should emit textChanged and userTextChanged, but not textEdited + w.clear(); + QCOMPARE(textChangedSpy.count(),1); + QCOMPARE(textEditedSpy.count(),0); +#ifndef KCOMPLETION_NO_DEPRECATED + QCOMPARE(userTextChangedSpy.count(),1); +#endif + + //if text box is already empty, calling clear() shouldn't emit + // any more signals + w.clear(); + QCOMPARE(textChangedSpy.count(),1); + QCOMPARE(textEditedSpy.count(),0); +#ifndef KCOMPLETION_NO_DEPRECATED + QCOMPARE(userTextChangedSpy.count(),1); +#endif + + + //set the text back for further tests below + w.setText("Hello worl"); +#ifndef KCOMPLETION_NO_DEPRECATED + userTextChangedSpy.clear(); +#endif + textChangedSpy.clear(); + textEditedSpy.clear(); + // typing emits all three signals QTest::keyClick(&w, Qt::Key_D); QCOMPARE(w.text(), QString::fromLatin1("Hello world")); @@ -85,7 +111,7 @@ #endif QCOMPARE(textChangedSpy.count(), 1); QCOMPARE(textChangedSpy[0][0].toString(), w.text()); - QCOMPARE(textEditedSpy.count(), 2); + QCOMPARE(textEditedSpy.count(), 1); QCOMPARE(textEditedSpy[0][0].toString(), w.text()); QVERIFY(w.isModified()); @@ -169,7 +195,7 @@ QCOMPARE(userTextChangedSpy.count(), 2); #endif QCOMPARE(textChangedSpy.count(), 2); - QCOMPARE(textEditedSpy.count(), 2); + QCOMPARE(textEditedSpy.count(), 0); #ifndef KCOMPLETION_NO_DEPRECATED userTextChangedSpy.clear(); #endif diff --git a/src/klineedit.cpp b/src/klineedit.cpp --- a/src/klineedit.cpp +++ b/src/klineedit.cpp @@ -60,7 +60,6 @@ #ifndef KCOMPLETION_NO_DEPRECATED emit q->userTextChanged(text); #endif - emit q->textEdited(text); } }