From f195a8e2b69eba0e3c44f2dece222b0da9e06026 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Mon, 13 Feb 2012 14:05:51 +0100 Subject: Added QAccessibleGroupBox MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added a new accessible interface for QGroupBox, as QAccessibleDisplay is not good enough when the QGroupBox is checkable. AccessibleFactory was modified to return a QAccessibleGroupBox when the accessible interface of a QGroupBox is requested. Created tst_QAccessibility::groupBoxTest Port to Qt5 of the patch by José Millán Soto Change-Id: I6c23dcf5562b3ea269b04102e78463b65827188a Reviewed-by: Jan-Arve Sæther (cherry picked from commit c03ceb203c65d9e3485fad848bfc0c4b6ee3e9aa) --- .../other/qaccessibility/tst_qaccessibility.cpp | 67 ++++++++++++++++++++++ 1 file changed, 67 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index 4d46ae43cf..be7cb7dd15 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -252,6 +252,7 @@ private slots: void mdiAreaTest(); void mdiSubWindowTest(); void lineEditTest(); + void groupBoxTest(); void workspaceTest(); void dialogButtonBoxTest(); void dialTest(); @@ -1894,6 +1895,72 @@ void tst_QAccessibility::lineEditTest() QTestAccessibility::clearEvents(); } +void tst_QAccessibility::groupBoxTest() +{ + { + QGroupBox *groupBox = new QGroupBox(); + QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(groupBox); + + groupBox->setTitle(QLatin1String("Test QGroupBox")); + + QAccessibleEvent ev(groupBox, QAccessible::NameChanged); + QVERIFY_EVENT(&ev); + + groupBox->setToolTip(QLatin1String("This group box will be used to test accessibility")); + QVBoxLayout *layout = new QVBoxLayout(); + QRadioButton *rbutton = new QRadioButton(); + layout->addWidget(rbutton); + groupBox->setLayout(layout); + QAccessibleInterface *rButtonIface = QAccessible::queryAccessibleInterface(rbutton); + + QCOMPARE(iface->childCount(), 1); + QCOMPARE(iface->role(), QAccessible::Grouping); + QCOMPARE(iface->text(QAccessible::Name), QLatin1String("Test QGroupBox")); + QCOMPARE(iface->text(QAccessible::Description), QLatin1String("This group box will be used to test accessibility")); + QVector > relations = rButtonIface->relations(); + QVERIFY(relations.size() == 1); + QPair relation = relations.first(); + QCOMPARE(relation.first->object(), groupBox); + QCOMPARE(relation.second, QAccessible::Label); + + delete relation.first; + + delete rButtonIface; + delete iface; + delete groupBox; + } + + { + QGroupBox *groupBox = new QGroupBox(); + QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(groupBox); + QVERIFY(!iface->state().checkable); + groupBox->setCheckable(true); + + groupBox->setChecked(false); + QAccessible::State st; + st.checked = true; + QAccessibleStateChangeEvent ev(groupBox, st); + QVERIFY_EVENT(&ev); + + QCOMPARE(iface->role(), QAccessible::CheckBox); + QAccessibleActionInterface *actionIface = iface->actionInterface(); + QVERIFY(actionIface); + QAccessible::State state = iface->state(); + QVERIFY(state.checkable); + QVERIFY(!state.checked); + QVERIFY(actionIface->actionNames().contains(QAccessibleActionInterface::checkAction())); + actionIface->doAction(QAccessibleActionInterface::checkAction()); + QVERIFY(groupBox->isChecked()); + state = iface->state(); + QVERIFY(state.checked); + QAccessibleStateChangeEvent ev2(groupBox, st); + QVERIFY_EVENT(&ev2); + + delete iface; + delete groupBox; + } +} + void tst_QAccessibility::workspaceTest() { { -- cgit v1.2.3