diff options
author | Jan Arve Sæther <jan-arve.saether@qt.io> | 2021-01-14 18:46:17 +0100 |
---|---|---|
committer | Jan Arve Sæther <jan-arve.saether@qt.io> | 2021-02-02 09:45:11 +0100 |
commit | 180dbd050173d20c99f730eeacf2b0376fcb895e (patch) | |
tree | 30829dd47722419ec96bce940d5da382252349c8 /tests | |
parent | 950f8bff7cbbdbd472234fd32ef659c9d0e8ba7c (diff) |
a11y: Fix ordering on header, content item and footer in Page
Because of the previous behavior, the footer could be read aloud by
the screen reader before the content item. And even worse, the footer
could be read aloud even before the header in some cases. This made
it hard for visually impaired people to use the application.
The Page type was used by the Dialog type, so it also affected that.
Fixes: QTBUG-75042
Change-Id: Ic3e8ec3f7dcf18af9262b1d35c986835c8da6900
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 4b1acb290dc8869d0d2d1250dc1ed415d6b6e202)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/accessibility/accessibility.pro | 4 | ||||
-rw-r--r-- | tests/auto/accessibility/data/ordering/page.qml | 23 | ||||
-rw-r--r-- | tests/auto/accessibility/tst_accessibility.cpp | 30 |
3 files changed, 56 insertions, 1 deletions
diff --git a/tests/auto/accessibility/accessibility.pro b/tests/auto/accessibility/accessibility.pro index d8d5bb95..4cc101fb 100644 --- a/tests/auto/accessibility/accessibility.pro +++ b/tests/auto/accessibility/accessibility.pro @@ -12,5 +12,7 @@ include (../shared/util.pri) TESTDATA = data/* OTHER_FILES += \ - data/*.qml + data/defaults\*.qml \ + data/ordering\*.qml \ + data/override*.qml diff --git a/tests/auto/accessibility/data/ordering/page.qml b/tests/auto/accessibility/data/ordering/page.qml new file mode 100644 index 00000000..5eeb1530 --- /dev/null +++ b/tests/auto/accessibility/data/ordering/page.qml @@ -0,0 +1,23 @@ +import QtQuick 2.15 +import QtQuick.Controls 2.15 + +Page { + title: "Page" + Accessible.role: Accessible.Pane + + header: Label { + text: "Header" + } + + footer: Label { + text: "Footer" + } + + Label { + text: "Content item 1" + } + + Label { + text: "Content item 2" + } +} diff --git a/tests/auto/accessibility/tst_accessibility.cpp b/tests/auto/accessibility/tst_accessibility.cpp index 6e5a37df..30bd4757 100644 --- a/tests/auto/accessibility/tst_accessibility.cpp +++ b/tests/auto/accessibility/tst_accessibility.cpp @@ -60,6 +60,7 @@ private slots: void override_data(); void override(); + void ordering(); private: QQmlEngine engine; }; @@ -284,6 +285,35 @@ void tst_accessibility::override() Q_UNUSED(text) #endif } +template <typename Predicate> +void a11yDescendants(QAccessibleInterface *iface, Predicate pred) +{ + for (int i = 0; i < iface->childCount(); ++i) { + if (QAccessibleInterface *child = iface->child(i)) { + pred(child); + a11yDescendants(child, pred); + } + } +} + +void tst_accessibility::ordering() +{ + QQmlComponent component(&engine); + component.loadUrl(testFileUrl("ordering/page.qml")); + + QScopedPointer<QObject> object(component.create()); + QVERIFY2(!object.isNull(), qPrintable(component.errorString())); + +#if QT_CONFIG(accessibility) + QQuickItem *item = findItem(object.data()); + QVERIFY(item); + QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(item); + QVERIFY(iface); + QStringList strings; + a11yDescendants(iface, [&](QAccessibleInterface *iface) {strings << iface->text(QAccessible::Name);}); + QCOMPARE(strings.join(QLatin1String(", ")), "Header, Content item 1, Content item 2, Footer"); +#endif +} QTEST_MAIN(tst_accessibility) |