summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorOliver Wolff <oliver.wolff@digia.com>2012-10-04 15:02:48 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-10-13 05:51:19 +0200
commit57fac2e83a27c9a2da1932991692586c42d97ddc (patch)
tree1cc60300d966acbf34cd8886b528a8685e1a2284 /tests
parent9ab8c0ae98f2e488f362484c2c2d1dc6a5ae1d1e (diff)
Do not accept key events if a widget is disabled
The disabled state was handled in qapplication_xxx.cpp before. As the platform integration only knows about windows and not widgets the state check is now done in qwidget. This commit just adds key events to the list of events which are ignored if the widget is disabled. This list also contains mouse events for example. Task-number: QTBUG-27417 Change-Id: I55949e1c1aaa992ba71df51c5b5e8177ec6f1e86 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index 167bf28fc3..07ed38fa61 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -174,6 +174,8 @@ private slots:
void palettePropagation();
void palettePropagation2();
void enabledPropagation();
+ void ignoreKeyEventsWhenDisabled_QTBUG27417();
+ void properTabHandlingWhenDisabled_QTBUG27417();
void popupEnterLeave();
#ifndef QT_NO_DRAGANDDROP
void acceptDropsPropagation();
@@ -1053,6 +1055,43 @@ void tst_QWidget::enabledPropagation()
QVERIFY( !grandChildWidget->isEnabled() );
}
+void tst_QWidget::ignoreKeyEventsWhenDisabled_QTBUG27417()
+{
+ QLineEdit lineEdit;
+ lineEdit.setDisabled(true);
+ lineEdit.show();
+ QTest::keyClick(&lineEdit, Qt::Key_A);
+ QTRY_VERIFY(lineEdit.text().isEmpty());
+}
+
+void tst_QWidget::properTabHandlingWhenDisabled_QTBUG27417()
+{
+ QWidget widget;
+ QVBoxLayout *layout = new QVBoxLayout();
+ QLineEdit *lineEdit = new QLineEdit();
+ layout->addWidget(lineEdit);
+ QLineEdit *lineEdit2 = new QLineEdit();
+ layout->addWidget(lineEdit2);
+ QLineEdit *lineEdit3 = new QLineEdit();
+ layout->addWidget(lineEdit3);
+ widget.setLayout(layout);
+ widget.show();
+
+ lineEdit->setFocus();
+ QTRY_VERIFY(lineEdit->hasFocus());
+ QTest::keyClick(&widget, Qt::Key_Tab);
+ QTRY_VERIFY(lineEdit2->hasFocus());
+ QTest::keyClick(&widget, Qt::Key_Tab);
+ QTRY_VERIFY(lineEdit3->hasFocus());
+
+ lineEdit2->setDisabled(true);
+ lineEdit->setFocus();
+ QTRY_VERIFY(lineEdit->hasFocus());
+ QTest::keyClick(&widget, Qt::Key_Tab);
+ QTRY_VERIFY(!lineEdit2->hasFocus());
+ QVERIFY(lineEdit3->hasFocus());
+}
+
// Drag'n drop disabled in this build.
#ifndef QT_NO_DRAGANDDROP
void tst_QWidget::acceptDropsPropagation()