From eba3b567d639ab40c939e27900029f93e351d77a Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Mon, 6 May 2019 13:02:57 +0200 Subject: Accessibility: Improve handling of read-only state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- tests/auto/other/qaccessibility/tst_qaccessibility.cpp | 15 +++++++++++++++ .../other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp | 8 ++++++++ 2 files changed, 23 insertions(+) (limited to 'tests/auto/other') 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 > 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; -- cgit v1.2.3 From 490ee4c5e6d296d975980c8be65d9b6f661d2603 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Thu, 18 Oct 2018 15:25:14 +0200 Subject: Fix compilation of tst_qaccessibilitylinux MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Note that the test is still disabled, but this is needed in any case. Change-Id: Ib7523ba800b94c32690c1bd09b23fc2078c71d4e Reviewed-by: Jan Arve Sæther --- tests/auto/other/qaccessibilitylinux/qaccessibilitylinux.pro | 1 + tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp | 7 +++---- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'tests/auto/other') diff --git a/tests/auto/other/qaccessibilitylinux/qaccessibilitylinux.pro b/tests/auto/other/qaccessibilitylinux/qaccessibilitylinux.pro index 5cb3f5902a..a964df0e24 100644 --- a/tests/auto/other/qaccessibilitylinux/qaccessibilitylinux.pro +++ b/tests/auto/other/qaccessibilitylinux/qaccessibilitylinux.pro @@ -5,3 +5,4 @@ SOURCES += tst_qaccessibilitylinux.cpp QT += gui-private widgets dbus testlib accessibility_support-private linuxaccessibility_support-private +DBUS_INTERFACES = $$PWD/../../../../src/platformsupport/linuxaccessibility/dbusxml/Bus.xml diff --git a/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp b/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp index 2b82b03998..7ba3715e13 100644 --- a/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp +++ b/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp @@ -42,12 +42,11 @@ #include #include -#include "atspi/atspi-constants.h" +#include +#include +#include #include "bus_interface.h" -#include "dbusconnection_p.h" -#include "struct_marshallers_p.h" - #define COMPARE3(v1, v2, v3) QCOMPARE(v1, v3); QCOMPARE(v2, v3); class AccessibleTestWindow : public QWidget -- cgit v1.2.3