Testability for password mask delay
Unit test to override mask delay value so running it is not dependent on platform style hint. Change-Id: Ic5cc12d32cf97e64729b3af54250bdc05c0c95ad Reviewed-by: Joona Petrell <joona.t.petrell@nokia.com>bb10
parent
d5bc8ab811
commit
1f5e058f79
|
|
@ -70,7 +70,7 @@
|
|||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QLineEditPrivate : public QWidgetPrivate
|
||||
class Q_AUTOTEST_EXPORT QLineEditPrivate : public QWidgetPrivate
|
||||
{
|
||||
Q_DECLARE_PUBLIC(QLineEdit)
|
||||
public:
|
||||
|
|
@ -109,6 +109,10 @@ public:
|
|||
return !control->isReadOnly();
|
||||
}
|
||||
|
||||
static inline QLineEditPrivate *get(QLineEdit *lineEdit) {
|
||||
return lineEdit->d_func();
|
||||
}
|
||||
|
||||
QPoint tripleClick;
|
||||
QBasicTimer tripleClickTimer;
|
||||
uint frame : 1;
|
||||
|
|
|
|||
|
|
@ -785,6 +785,11 @@ void QWidgetLineControl::internalInsert(const QString &s)
|
|||
if (m_passwordEchoTimer != 0)
|
||||
killTimer(m_passwordEchoTimer);
|
||||
int delay = qGuiApp->styleHints()->passwordMaskDelay();
|
||||
#ifdef QT_BUILD_INTERNAL
|
||||
if (m_passwordMaskDelayOverride >= 0)
|
||||
delay = m_passwordMaskDelayOverride;
|
||||
#endif
|
||||
|
||||
if (delay > 0)
|
||||
m_passwordEchoTimer = startTimer(delay);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,6 +98,9 @@ public:
|
|||
, m_threadChecks(false)
|
||||
, m_textLayoutThread(0)
|
||||
#endif
|
||||
#if defined(QT_BUILD_INTERNAL)
|
||||
, m_passwordMaskDelayOverride(-1)
|
||||
#endif
|
||||
, m_keyboardScheme(0)
|
||||
{
|
||||
init(txt);
|
||||
|
|
@ -496,6 +499,11 @@ private:
|
|||
mutable QThread *m_textLayoutThread;
|
||||
#endif
|
||||
|
||||
public:
|
||||
#if defined(QT_BUILD_INTERNAL)
|
||||
int m_passwordMaskDelayOverride;
|
||||
#endif
|
||||
|
||||
Q_SIGNALS:
|
||||
void cursorPositionChanged(int, int);
|
||||
void selectionChanged();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
CONFIG += testcase
|
||||
TARGET = tst_qlineedit
|
||||
QT += gui-private core-private widgets testlib
|
||||
QT += gui-private core-private widgets widgets-private testlib
|
||||
SOURCES += tst_qlineedit.cpp
|
||||
|
||||
# QTBUG-24518 - unstable test
|
||||
|
|
|
|||
|
|
@ -62,6 +62,8 @@
|
|||
#endif
|
||||
|
||||
#include <qlineedit.h>
|
||||
#include <private/qlineedit_p.h>
|
||||
#include <private/qwidgetlinecontrol_p.h>
|
||||
#include <qmenu.h>
|
||||
#include <qlayout.h>
|
||||
#include <qspinbox.h>
|
||||
|
|
@ -1670,8 +1672,16 @@ void tst_QLineEdit::passwordEchoOnEdit()
|
|||
|
||||
void tst_QLineEdit::passwordEchoDelay()
|
||||
{
|
||||
if (qGuiApp->styleHints()->passwordMaskDelay() <= 0)
|
||||
QSKIP("No mask delay in use");
|
||||
int delay = qGuiApp->styleHints()->passwordMaskDelay();
|
||||
#if defined QT_BUILD_INTERNAL
|
||||
QLineEditPrivate *priv = QLineEditPrivate::get(testWidget);
|
||||
QWidgetLineControl *control = priv->control;
|
||||
control->m_passwordMaskDelayOverride = 200;
|
||||
delay = 200;
|
||||
#endif
|
||||
if (delay <= 0)
|
||||
QSKIP("Platform not defining echo delay and overriding only possible in internal build");
|
||||
|
||||
QStyleOptionFrameV2 opt;
|
||||
QChar fillChar = testWidget->style()->styleHint(QStyle::SH_LineEdit_PasswordCharacter, &opt, testWidget);
|
||||
|
||||
|
|
@ -1691,7 +1701,7 @@ void tst_QLineEdit::passwordEchoDelay()
|
|||
QCOMPARE(testWidget->displayText(), QString(4, fillChar));
|
||||
QTest::keyPress(testWidget, '4');
|
||||
QCOMPARE(testWidget->displayText(), QString(4, fillChar) + QLatin1Char('4'));
|
||||
QTest::qWait(qGuiApp->styleHints()->passwordMaskDelay());
|
||||
QTest::qWait(delay);
|
||||
QTRY_COMPARE(testWidget->displayText(), QString(5, fillChar));
|
||||
QTest::keyPress(testWidget, '5');
|
||||
QCOMPARE(testWidget->displayText(), QString(5, fillChar) + QLatin1Char('5'));
|
||||
|
|
|
|||
Loading…
Reference in New Issue