Check validator when changing text using accessibility functions.
Reviewed-by: Frederik Gladhorn (cherry picked from commit 731d843b52b0a0bc387c50c2af37a71f87804f4d) Change-Id: Ieef71cea5b44f288f2f95a0765ec0b3f6d47c042 Reviewed-on: http://codereview.qt.nokia.com/3037 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Frederik Gladhorn <frederik.gladhorn@nokia.com>
This commit is contained in:
parent
b8cd3fe7b6
commit
983941da65
@ -710,7 +710,14 @@ void QAccessibleLineEdit::setText(Text t, int control, const QString &text)
|
||||
QAccessibleWidgetEx::setText(t, control, text);
|
||||
return;
|
||||
}
|
||||
lineEdit()->setText(text);
|
||||
|
||||
QString newText = text;
|
||||
if (lineEdit()->validator()) {
|
||||
int pos = 0;
|
||||
if (lineEdit()->validator()->validate(newText, pos) != QValidator::Acceptable)
|
||||
return;
|
||||
}
|
||||
lineEdit()->setText(newText);
|
||||
}
|
||||
|
||||
/*! \reimp */
|
||||
|
@ -2098,6 +2098,12 @@ void tst_QAccessibility::lineEditTest()
|
||||
QTestAccessibility::clearEvents();
|
||||
le2->setFocus(Qt::TabFocusReason);
|
||||
QTRY_VERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(le2, 0, QAccessible::Focus)));
|
||||
|
||||
le->setText(QLatin1String("500"));
|
||||
le->setValidator(new QIntValidator());
|
||||
iface->setText(QAccessible::Value, 0, QLatin1String("This text is not a number"));
|
||||
QCOMPARE(le->text(), QLatin1String("500"));
|
||||
|
||||
delete iface;
|
||||
delete le;
|
||||
delete le2;
|
||||
|
Loading…
Reference in New Issue
Block a user