summaryrefslogtreecommitdiffstats
path: root/tests/auto/qlineedit/tst_qlineedit.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qlineedit/tst_qlineedit.cpp')
-rw-r--r--tests/auto/qlineedit/tst_qlineedit.cpp63
1 files changed, 53 insertions, 10 deletions
diff --git a/tests/auto/qlineedit/tst_qlineedit.cpp b/tests/auto/qlineedit/tst_qlineedit.cpp
index 4122436..47f0730 100644
--- a/tests/auto/qlineedit/tst_qlineedit.cpp
+++ b/tests/auto/qlineedit/tst_qlineedit.cpp
@@ -1,7 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the test suite of the Qt Toolkit.
@@ -21,9 +20,10 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.1, included in the file LGPL_EXCEPTION.txt in this
+** package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
@@ -190,6 +190,7 @@ private slots:
void selectedText();
void hasSelectedText();
+ void deleteSelectedText();
void textChangedAndTextEdited();
void returnPressed();
@@ -220,10 +221,11 @@ private slots:
void setSelection_data();
void setSelection();
+#ifndef QT_NO_CLIPBOARD
void cut();
void copy();
void paste();
-
+#endif
void maxLengthAndInputMask();
void returnPressedKeyEvent();
@@ -257,6 +259,7 @@ private slots:
void task233101_cursorPosAfterInputMethod_data();
void task233101_cursorPosAfterInputMethod();
void task241436_passwordEchoOnEditRestoreEchoMode();
+ void task248948_redoRemovedSelection();
protected slots:
#ifdef QT3_SUPPORT
@@ -340,6 +343,7 @@ void tst_QLineEdit::initTestCase()
// to be safe and avoid failing setFocus with window managers
qt_x11_wait_for_window_manager(testWidget);
#endif
+ QTRY_VERIFY(testWidget->hasFocus());
changed_count = 0;
edited_count = 0;
@@ -1598,8 +1602,7 @@ void tst_QLineEdit::passwordEchoOnEdit()
testWidget->setEchoMode(QLineEdit::PasswordEchoOnEdit);
testWidget->setFocus();
testWidget->raise();
- QTest::qWait(250);
- QVERIFY(testWidget->hasFocus());
+ QTRY_VERIFY(testWidget->hasFocus());
QTest::keyPress(testWidget, '0');
QTest::keyPress(testWidget, '1');
@@ -1611,6 +1614,7 @@ void tst_QLineEdit::passwordEchoOnEdit()
QVERIFY(!testWidget->hasFocus());
QCOMPARE(testWidget->displayText(), QString(5, fillChar));
testWidget->setFocus();
+ QTRY_VERIFY(testWidget->hasFocus());
QCOMPARE(testWidget->displayText(), QString(5, fillChar));
QTest::keyPress(testWidget, '0');
@@ -2052,6 +2056,32 @@ void tst_QLineEdit::hasSelectedText()
DEPENDS_ON("selectedText");
}
+void tst_QLineEdit::deleteSelectedText()
+{
+ const QString text = QString::fromLatin1("bar");
+ QLineEdit edit( text );
+ QCOMPARE(edit.text(), text);
+
+ edit.selectAll();
+
+ QTest::keyClick(&edit, Qt::Key_Delete, 0);
+ QVERIFY(edit.text().isEmpty());
+
+ edit.setText(text);
+ edit.selectAll();
+
+ QMenu *menu = edit.createStandardContextMenu();
+ for (int i = 0; i < menu->actions().count(); ++i) {
+ QAction *current = menu->actions().at(i);
+ if (current->text() == QLineEdit::tr("Delete")) {
+ current->trigger(); //this will delete the whole text selected
+ QVERIFY(edit.text().isEmpty());
+ }
+ }
+
+}
+
+
void tst_QLineEdit::textChangedAndTextEdited()
{
changed_count = 0;
@@ -2749,6 +2779,7 @@ void tst_QLineEdit::setSelection()
QCOMPARE(testWidget->cursorPosition(), expectedCursor);
}
+#ifndef QT_NO_CLIPBOARD
void tst_QLineEdit::cut()
{
#ifdef Q_WS_MAC
@@ -2829,7 +2860,7 @@ void tst_QLineEdit::paste()
{
DEPENDS_ON("cut");
}
-
+#endif
class InputMaskValidator : public QValidator
{
public:
@@ -3367,7 +3398,7 @@ void tst_QLineEdit::task210502_caseInsensitiveInlineCompletion()
qt_x11_wait_for_window_manager(&lineEdit);
#endif
lineEdit.setFocus();
- QTest::qWait(200);
+ QTRY_VERIFY(lineEdit.hasFocus());
QTest::keyPress(&lineEdit, 'a');
QTest::keyPress(&lineEdit, Qt::Key_Return);
QCOMPARE(lineEdit.text(), completion);
@@ -3461,7 +3492,7 @@ void tst_QLineEdit::task241436_passwordEchoOnEditRestoreEchoMode()
testWidget->setEchoMode(QLineEdit::PasswordEchoOnEdit);
testWidget->setFocus();
- QTest::qWait(250);
+ QTRY_VERIFY(testWidget->hasFocus());
QTest::keyPress(testWidget, '0');
QCOMPARE(testWidget->displayText(), QString("0"));
@@ -3483,5 +3514,17 @@ void tst_QLineEdit::task241436_passwordEchoOnEditRestoreEchoMode()
testWidget->setEchoMode(QLineEdit::Normal);
}
+void tst_QLineEdit::task248948_redoRemovedSelection()
+{
+ testWidget->setText("a");
+ testWidget->selectAll();
+ QTest::keyPress(testWidget, Qt::Key_Delete);
+ testWidget->undo();
+ testWidget->redo();
+ QTest::keyPress(testWidget, 'a');
+ QTest::keyPress(testWidget, 'b');
+ QCOMPARE(testWidget->text(), QLatin1String("ab"));
+}
+
QTEST_MAIN(tst_QLineEdit)
#include "tst_qlineedit.moc"