summaryrefslogtreecommitdiffstats
path: root/tests/auto/qlineedit
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2009-11-24 14:29:37 (GMT)
committerThierry Bastian <thierry.bastian@nokia.com>2009-11-24 14:31:53 (GMT)
commit1e36e3917cae1e6b55cce46dc7e0e8a0b336cd01 (patch)
treef8491ca132c987fcf79ae265a1d0be56232cddbe /tests/auto/qlineedit
parent6bf1037df75d8d6f697f9f49d8d7fbe9b2cabc98 (diff)
downloadQt-1e36e3917cae1e6b55cce46dc7e0e8a0b336cd01.zip
Qt-1e36e3917cae1e6b55cce46dc7e0e8a0b336cd01.tar.gz
Qt-1e36e3917cae1e6b55cce46dc7e0e8a0b336cd01.tar.bz2
Make paste + undo behave in QLineEdit as it does in QTextEdit
On the undo/redo stack, it needs to be treated as a separate command Task-number: QTBUG-5786 Reviewed-by: ogoffart
Diffstat (limited to 'tests/auto/qlineedit')
-rw-r--r--tests/auto/qlineedit/tst_qlineedit.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/auto/qlineedit/tst_qlineedit.cpp b/tests/auto/qlineedit/tst_qlineedit.cpp
index b4dfbba..dd5bb29 100644
--- a/tests/auto/qlineedit/tst_qlineedit.cpp
+++ b/tests/auto/qlineedit/tst_qlineedit.cpp
@@ -51,6 +51,10 @@
#include "qcompleter.h"
#include "qstandarditemmodel.h"
+#ifndef QT_NO_CLIPBOARD
+#include "qclipboard.h"
+#endif
+
#ifdef Q_WS_MAC
#include <Carbon/Carbon.h> // For the random function.
#include <cstdlib> // For the random function.
@@ -157,6 +161,10 @@ private slots:
void undo_keypressevents_data();
void undo_keypressevents();
+#ifndef QT_NO_CLIPBOARD
+ void QTBUG5786_undoPaste();
+#endif
+
void clear();
void text_data();
@@ -1406,6 +1414,36 @@ void tst_QLineEdit::undo_keypressevents()
QVERIFY(testWidget->text().isEmpty());
}
+#ifndef QT_NO_CLIPBOARD
+void tst_QLineEdit::QTBUG5786_undoPaste()
+{
+ QString initial("initial");
+ QString string("test");
+ QString additional("add");
+ QApplication::clipboard()->setText(string);
+ QLineEdit edit(initial);
+ QCOMPARE(edit.text(), initial);
+ edit.paste();
+ QCOMPARE(edit.text(), initial + string);
+ edit.paste();
+ QCOMPARE(edit.text(), initial + string + string);
+ edit.insert(additional);
+ QCOMPARE(edit.text(), initial + string + string + additional);
+ edit.undo();
+ QCOMPARE(edit.text(), initial + string + string);
+ edit.undo();
+ QCOMPARE(edit.text(), initial + string);
+ edit.undo();
+ QCOMPARE(edit.text(), initial);
+ edit.selectAll();
+ QApplication::clipboard()->setText(QString());
+ edit.paste();
+ QVERIFY(edit.text().isEmpty());
+
+}
+#endif
+
+
void tst_QLineEdit::clear()
{
// checking that clear of empty/nullstring doesn't add to undo history