summaryrefslogtreecommitdiffstats
path: root/tests/auto/other
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@nokia.com>2012-02-13 14:05:51 +0100
committerQt by Nokia <qt-info@nokia.com>2012-03-24 15:10:00 +0100
commitf195a8e2b69eba0e3c44f2dece222b0da9e06026 (patch)
tree8912eb662a2af13b07d3cff155df7a9b37002521 /tests/auto/other
parentf49f94434e082657f2227292c15cad20493f112c (diff)
Added QAccessibleGroupBox
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 <fid@gpul.org> Change-Id: I6c23dcf5562b3ea269b04102e78463b65827188a Reviewed-by: Jan-Arve Sæther <jan-arve.saether@nokia.com> (cherry picked from commit c03ceb203c65d9e3485fad848bfc0c4b6ee3e9aa)
Diffstat (limited to 'tests/auto/other')
-rw-r--r--tests/auto/other/qaccessibility/tst_qaccessibility.cpp67
1 files changed, 67 insertions, 0 deletions
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<QPair<QAccessibleInterface*, QAccessible::Relation> > relations = rButtonIface->relations();
+ QVERIFY(relations.size() == 1);
+ QPair<QAccessibleInterface*, QAccessible::Relation> 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()
{
{