summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2011-07-19 08:31:38 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2011-07-19 08:31:38 (GMT)
commit4c5a7f63305b3faeebfa522898e6f9a711f62251 (patch)
treef8135bd71132104d7bfd79c87b7f7822a0520a51 /tests
parent53da0d9862784493cee4861e50481d461b670f9b (diff)
parentf9e7aee2019d321edd655bfde7de43f20a106971 (diff)
downloadQt-4c5a7f63305b3faeebfa522898e6f9a711f62251.zip
Qt-4c5a7f63305b3faeebfa522898e6f9a711f62251.tar.gz
Qt-4c5a7f63305b3faeebfa522898e6f9a711f62251.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-qml: Delay masking the last character in Password echo mode.
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp61
-rw-r--r--tests/auto/qlineedit/tst_qlineedit.cpp51
2 files changed, 112 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
index 19b7a76..280f952 100644
--- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
+++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp
@@ -52,6 +52,8 @@
#include <QInputContext>
#include <private/qapplication_p.h>
+#include "qplatformdefs.h"
+
#ifdef Q_OS_SYMBIAN
// In Symbian OS test data is located in applications private dir
#define SRCDIR "."
@@ -133,6 +135,9 @@ private slots:
void focusOutClearSelection();
void echoMode();
+#ifdef QT_GUI_PASSWORD_ECHO_DELAY
+ void passwordEchoDelay();
+#endif
void geometrySignals();
void testQtQuick11Attributes();
void testQtQuick11Attributes_data();
@@ -2051,6 +2056,62 @@ void tst_qdeclarativetextinput::echoMode()
delete canvas;
}
+
+#ifdef QT_GUI_PASSWORD_ECHO_DELAY
+void tst_qdeclarativetextinput::passwordEchoDelay()
+{
+ QDeclarativeView *canvas = createView(SRCDIR "/data/echoMode.qml");
+ canvas->show();
+ canvas->setFocus();
+ QApplication::setActiveWindow(canvas);
+ QTest::qWaitForWindowShown(canvas);
+ QTRY_COMPARE(QApplication::activeWindow(), static_cast<QWidget *>(canvas));
+
+ QVERIFY(canvas->rootObject() != 0);
+
+ QDeclarativeTextInput *input = qobject_cast<QDeclarativeTextInput *>(qvariant_cast<QObject *>(canvas->rootObject()->property("myInput")));
+
+ QChar fillChar = QLatin1Char('*');
+
+ input->setEchoMode(QDeclarativeTextInput::Password);
+ QCOMPARE(input->displayText(), QString(8, fillChar));
+ input->setText(QString());
+ QCOMPARE(input->displayText(), QString());
+
+ QTest::keyPress(canvas, '0');
+ QTest::keyPress(canvas, '1');
+ QTest::keyPress(canvas, '2');
+ QCOMPARE(input->displayText(), QString(2, fillChar) + QLatin1Char('2'));
+ QTest::keyPress(canvas, '3');
+ QTest::keyPress(canvas, '4');
+ QCOMPARE(input->displayText(), QString(4, fillChar) + QLatin1Char('4'));
+ QTest::keyPress(canvas, Qt::Key_Backspace);
+ QCOMPARE(input->displayText(), QString(4, fillChar));
+ QTest::keyPress(canvas, '4');
+ QCOMPARE(input->displayText(), QString(4, fillChar) + QLatin1Char('4'));
+ QTest::qWait(QT_GUI_PASSWORD_ECHO_DELAY);
+ QTRY_COMPARE(input->displayText(), QString(5, fillChar));
+ QTest::keyPress(canvas, '5');
+ QCOMPARE(input->displayText(), QString(5, fillChar) + QLatin1Char('5'));
+ input->setFocus(false);
+ QVERIFY(!input->hasFocus());
+ QCOMPARE(input->displayText(), QString(6, fillChar));
+ input->setFocus(true);
+ QTRY_VERIFY(input->hasFocus());
+ QCOMPARE(input->displayText(), QString(6, fillChar));
+ QTest::keyPress(canvas, '6');
+ QCOMPARE(input->displayText(), QString(6, fillChar) + QLatin1Char('6'));
+
+ QInputMethodEvent ev;
+ ev.setCommitString(QLatin1String("7"));
+ QApplication::sendEvent(canvas, &ev);
+ QCOMPARE(input->displayText(), QString(7, fillChar) + QLatin1Char('7'));
+
+ delete canvas;
+}
+#endif
+
+
void tst_qdeclarativetextinput::simulateKey(QDeclarativeView *view, int key)
{
QKeyEvent press(QKeyEvent::KeyPress, key, 0);
diff --git a/tests/auto/qlineedit/tst_qlineedit.cpp b/tests/auto/qlineedit/tst_qlineedit.cpp
index 9f4d158..1f33458 100644
--- a/tests/auto/qlineedit/tst_qlineedit.cpp
+++ b/tests/auto/qlineedit/tst_qlineedit.cpp
@@ -72,6 +72,8 @@
#include "qcommonstyle.h"
#include "qstyleoption.h"
+#include "qplatformdefs.h"
+
QT_BEGIN_NAMESPACE
class QPainter;
QT_END_NAMESPACE
@@ -180,6 +182,10 @@ private slots:
void echoMode();
void passwordEchoOnEdit();
+#ifdef QT_GUI_PASSWORD_ECHO_DELAY
+ void passwordEchoDelay();
+#endif
+
void maxLength_mask_data();
void maxLength_mask();
@@ -1718,6 +1724,51 @@ void tst_QLineEdit::passwordEchoOnEdit()
testWidget->setEchoMode(QLineEdit::Normal);
}
+#ifdef QT_GUI_PASSWORD_ECHO_DELAY
+void tst_QLineEdit::passwordEchoDelay()
+{
+ QStyleOptionFrameV2 opt;
+ QChar fillChar = testWidget->style()->styleHint(QStyle::SH_LineEdit_PasswordCharacter, &opt, testWidget);
+
+ testWidget->setEchoMode(QLineEdit::Password);
+ testWidget->setFocus();
+ testWidget->raise();
+ QTRY_VERIFY(testWidget->hasFocus());
+
+ QTest::keyPress(testWidget, '0');
+ QTest::keyPress(testWidget, '1');
+ QTest::keyPress(testWidget, '2');
+ QCOMPARE(testWidget->displayText(), QString(2, fillChar) + QLatin1Char('2'));
+ QTest::keyPress(testWidget, '3');
+ QTest::keyPress(testWidget, '4');
+ QCOMPARE(testWidget->displayText(), QString(4, fillChar) + QLatin1Char('4'));
+ QTest::keyPress(testWidget, Qt::Key_Backspace);
+ QCOMPARE(testWidget->displayText(), QString(4, fillChar));
+ QTest::keyPress(testWidget, '4');
+ QCOMPARE(testWidget->displayText(), QString(4, fillChar) + QLatin1Char('4'));
+ QTest::qWait(QT_GUI_PASSWORD_ECHO_DELAY);
+ QTRY_COMPARE(testWidget->displayText(), QString(5, fillChar));
+ QTest::keyPress(testWidget, '5');
+ QCOMPARE(testWidget->displayText(), QString(5, fillChar) + QLatin1Char('5'));
+ testWidget->clearFocus();
+ QVERIFY(!testWidget->hasFocus());
+ QCOMPARE(testWidget->displayText(), QString(6, fillChar));
+ testWidget->setFocus();
+ QTRY_VERIFY(testWidget->hasFocus());
+ QCOMPARE(testWidget->displayText(), QString(6, fillChar));
+ QTest::keyPress(testWidget, '6');
+ QCOMPARE(testWidget->displayText(), QString(6, fillChar) + QLatin1Char('6'));
+
+ QInputMethodEvent ev;
+ ev.setCommitString(QLatin1String("7"));
+ QApplication::sendEvent(testWidget, &ev);
+ QCOMPARE(testWidget->displayText(), QString(7, fillChar) + QLatin1Char('7'));
+
+ // restore clean state
+ testWidget->setEchoMode(QLineEdit::Normal);
+}
+#endif
+
void tst_QLineEdit::maxLength_mask_data()
{
QTest::addColumn<QString>("mask");