diff options
author | J-P Nurmi <jpnurmi@theqtcompany.com> | 2016-02-24 13:59:19 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@theqtcompany.com> | 2016-02-25 08:21:32 +0000 |
commit | 609a658da0b9a73bbdcd9cfab8acd8f2b7329daf (patch) | |
tree | 51635f9ad91ede08c9168b8fbb6186617fcf6eb4 /tests/auto/accessibility/tst_accessibility.cpp | |
parent | 22624517ccbe780937ec2ba0b4264b71e38484bb (diff) |
Implement accessibility support for Popup and Menu
Change-Id: I55067bb1cb9888be8e0e991fb73c9365d93d04f4
Task-number: QTBUG-51316
Reviewed-by: Liang Qi <liang.qi@theqtcompany.com>
Diffstat (limited to 'tests/auto/accessibility/tst_accessibility.cpp')
-rw-r--r-- | tests/auto/accessibility/tst_accessibility.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/tests/auto/accessibility/tst_accessibility.cpp b/tests/auto/accessibility/tst_accessibility.cpp index 16a138b5..8c05e2f2 100644 --- a/tests/auto/accessibility/tst_accessibility.cpp +++ b/tests/auto/accessibility/tst_accessibility.cpp @@ -41,6 +41,7 @@ #include <QtQml/qqmlcontext.h> #include <QtQuick/qquickview.h> #include <QtQuick/private/qquickitem_p.h> +#include <QtLabsTemplates/private/qquickpopup_p.h> #include "../shared/util.h" #include "../shared/visualtestutil.h" @@ -75,7 +76,9 @@ void tst_accessibility::a11y_data() // Frame // GroupBox QTest::newRow("Label") << "label" << 0x00000029 << "Label"; //QAccessible::StaticText + QTest::newRow("Menu") << "menu" << 0x0000000B << ""; //QAccessible::PopupMenu QTest::newRow("PageIndicator") << "pageindicator" << 0x00000027 << ""; //QAccessible::Indicator + QTest::newRow("Popup") << "popup" << 0x00000080 << ""; //QAccessible::LayeredPane QTest::newRow("ProgressBar") << "progressbar" << 0x00000030 << ""; //QAccessible::ProgressBar QTest::newRow("RadioButton") << "radiobutton" << 0x0000002D << "RadioButton"; //QAccessible::RadioButton QTest::newRow("RangeSlider") << "rangeslider" << 0x00000033 << ""; //QAccessible::Slider @@ -102,6 +105,14 @@ void tst_accessibility::a11y_data() QTest::newRow("WeekNumberColumn") << "weeknumbercolumn" << 0x0 << "WeekNumberColumn"; //QAccessible::NoRole } +static QQuickAccessibleAttached *accessibleAttached(QQuickItem *item) +{ + QQuickAccessibleAttached *acc = qobject_cast<QQuickAccessibleAttached *>(qmlAttachedPropertiesObject<QQuickAccessibleAttached>(item, false)); + if (!acc) + acc = item->findChild<QQuickAccessibleAttached *>(); + return acc; +} + void tst_accessibility::a11y() { QFETCH(QString, name); @@ -128,10 +139,15 @@ void tst_accessibility::a11y() QVERIFY(QTest::qWaitForWindowActive(window)); QQuickItem *item = findItem<QQuickItem>(window->contentItem(), name); + if (!item) { + QQuickPopup *popup = window->contentItem()->findChild<QQuickPopup *>(name); + if (popup) + item = popup->popupItem(); + } QVERIFY(item); #ifndef QT_NO_ACCESSIBILITY - QQuickAccessibleAttached *acc = qobject_cast<QQuickAccessibleAttached *>(qmlAttachedPropertiesObject<QQuickAccessibleAttached>(item, false)); + QQuickAccessibleAttached *acc = accessibleAttached(item); if (name != QLatin1Literal("dayofweekrow") && name != QLatin1Literal("monthgrid") && name != QLatin1Literal("weeknumbercolumn")) { @@ -140,7 +156,7 @@ void tst_accessibility::a11y() } else { QVERIFY(!acc); QAccessible::setActive(true); - acc = qobject_cast<QQuickAccessibleAttached *>(qmlAttachedPropertiesObject<QQuickAccessibleAttached>(item, false)); + acc = accessibleAttached(item); } } QVERIFY(acc); |