summaryrefslogtreecommitdiffstats
path: root/tests/auto/other
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@qt.io>2019-05-06 13:02:57 +0200
committerFrederik Gladhorn <frederik.gladhorn@qt.io>2019-05-07 10:05:30 +0000
commiteba3b567d639ab40c939e27900029f93e351d77a (patch)
tree3525615959eef0513a2c01b716c83b7eae0142cd /tests/auto/other
parent48a12735d813c88bb4015ac762d12c79f863ffb6 (diff)
Accessibility: Improve handling of read-only state
We have been rather sloppy in how read-only versus editable is handled. According to the definition, editable signifies that in principle a widget allows the user to change its text. Read-only means that this ability is (currently) disabled. Task-number: QTBUG-75002 Change-Id: I5d71843abcdaac52f4a60a1abcac2604341f6c96 Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Diffstat (limited to 'tests/auto/other')
-rw-r--r--tests/auto/other/qaccessibility/tst_qaccessibility.cpp15
-rw-r--r--tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp8
2 files changed, 23 insertions, 0 deletions
diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
index 8b24937079..bc45487599 100644
--- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
+++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
@@ -2045,6 +2045,15 @@ void tst_QAccessibility::lineEditTest()
QVERIFY(!iface->state().selectable);
QVERIFY(iface->state().selectableText);
QVERIFY(!iface->state().hasPopup);
+ QVERIFY(!iface->state().readOnly);
+ QVERIFY(iface->state().editable);
+
+ le->setReadOnly(true);
+ QVERIFY(iface->state().editable);
+ QVERIFY(iface->state().readOnly);
+ le->setReadOnly(false);
+ QVERIFY(!iface->state().readOnly);
+
QCOMPARE(bool(iface->state().focused), le->hasFocus());
QString secret(QLatin1String("secret"));
@@ -3640,6 +3649,12 @@ void tst_QAccessibility::labelTest()
QVERIFY(acc_label);
QCOMPARE(acc_label->text(QAccessible::Name), text);
+ QCOMPARE(acc_label->state().editable, false);
+ QCOMPARE(acc_label->state().passwordEdit, false);
+ QCOMPARE(acc_label->state().disabled, false);
+ QCOMPARE(acc_label->state().focused, false);
+ QCOMPARE(acc_label->state().focusable, false);
+ QCOMPARE(acc_label->state().readOnly, true);
QVector<QPair<QAccessibleInterface *, QAccessible::Relation> > rels = acc_label->relations();
QCOMPARE(rels.count(), 1);
diff --git a/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp b/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
index 48594b2fa1..2b82b03998 100644
--- a/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+++ b/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
@@ -251,6 +251,8 @@ void tst_QAccessibilityLinux::testLabel()
QCOMPARE(labelInterface->call(QDBus::Block, "GetRoleName").arguments().first().toString(), QLatin1String("label"));
QCOMPARE(labelInterface->call(QDBus::Block, "GetRole").arguments().first().toUInt(), 29u);
QCOMPARE(getParent(labelInterface), mainWindow->path());
+ QVERIFY(!hasState(labelInterface, ATSPI_STATE_EDITABLE));
+ QVERIFY(hasState(labelInterface, ATSPI_STATE_READ_ONLY));
l->setText("New text");
QCOMPARE(labelInterface->property("Name").toString(), l->text());
@@ -303,6 +305,12 @@ void tst_QAccessibilityLinux::testLineEdit()
QCOMPARE(lineEdit->selectionStart(), -1);
QCOMPARE(textInterface->call(QDBus::Block, "GetNSelections").arguments().first().toInt(), 0);
+ QVERIFY(hasState(accessibleInterface, ATSPI_STATE_EDITABLE));
+ QVERIFY(!hasState(accessibleInterface, ATSPI_STATE_READ_ONLY));
+ lineEdit->setReadOnly(true);
+ QVERIFY(hasState(accessibleInterface, ATSPI_STATE_EDITABLE));
+ QVERIFY(hasState(accessibleInterface, ATSPI_STATE_READ_ONLY));
+
m_window->clearChildren();
delete accessibleInterface;
delete textInterface;