diff options
author | Jan Arve Saether <jan-arve.saether@digia.com> | 2012-11-01 14:32:46 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-11-02 10:28:34 +0100 |
commit | 12e92ff8072b06f5f9b68a071223a94e7460a383 (patch) | |
tree | eab4e1ebc8e2793c3e05f88e82c81e8ddaf5de83 | |
parent | 5b19228c2af24629dfffb40673f05a3500a66533 (diff) |
Expose IAccessibleTable2 to non-conformant screen readers
This seems to be the established practice.
Change-Id: I75a65d722a026ab0eb1805688743f46aba406e6c
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com>
-rw-r--r-- | src/plugins/platforms/windows/accessible/iaccessible2.cpp | 27 | ||||
-rw-r--r-- | tests/auto/other/qaccessibility/tst_qaccessibility.cpp | 82 |
2 files changed, 101 insertions, 8 deletions
diff --git a/src/plugins/platforms/windows/accessible/iaccessible2.cpp b/src/plugins/platforms/windows/accessible/iaccessible2.cpp index 6acfd6e602..03bb94db8f 100644 --- a/src/plugins/platforms/windows/accessible/iaccessible2.cpp +++ b/src/plugins/platforms/windows/accessible/iaccessible2.cpp @@ -1493,13 +1493,26 @@ HRESULT STDMETHODCALLTYPE QWindowsIA2Accessible::QueryService(REFGUID guidServic *iface = 0; accessibleDebug("QWindowsIA2Accessible::QS(): %s", IIDToString(riid).constData()); - if (guidService == IID_IAccessible && riid == IID_IAccessible2) { - // The conditions for entering here should be ok (from _dicoveringInterfaces in IAccessible2.idl) - *iface = static_cast<IAccessible2*>(this); - } else if (guidService == IID_IAccessible && (riid == IID_IAccessible || riid == IID_IUnknown || riid == IID_IDispatch)) { - // The above conditions works with AccProbe and NVDA. - *iface = static_cast<IAccessible*>(this); - } else if (riid == IID_IAccessibleApplication) { + + if (guidService == IID_IAccessible) { + if (riid == IID_IServiceProvider) { + // do not end up calling QueryInterface for IID_IServiceProvider + *iface = 0; + } else if (riid == IID_IAccessible || riid == IID_IUnknown || riid == IID_IDispatch) { + // The above conditions works with AccProbe and NVDA. + *iface = static_cast<IAccessible*>(this); + } else { + // According to _dicoveringInterfaces Discovery of Interfaces, we should really only + // enter here if riid == IID_IAccessible2, but some screen readers does not like that, + // and other servers seems to have realized that. (Chrome and Mozilla for instance, + // calls QueryInterface more or less in the same way) + + // For instance, accProbe discovers IID_IAccessibleTable2 by a QueryService only. + return QueryInterface(riid, iface); + } + } + + if (riid == IID_IAccessibleApplication) { *iface = new AccessibleApplication; return S_OK; } diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index 1b8ac101bc..7d0914b791 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -52,6 +52,8 @@ # include <AccessibleComponent.h> # include <AccessibleEditableText.h> # include <AccessibleText.h> +# include <AccessibleTable2.h> +# include <AccessibleTableCell.h> # endif #endif #include <QtTest/QtTest> @@ -3033,8 +3035,29 @@ void tst_QAccessibility::bridgeTest() QPushButton *button = new QPushButton(tr("Push me"), window); QTextEdit *te = new QTextEdit(window); te->setText(QLatin1String("hello world\nhow are you today?\n")); + + // Add QTableWidget + QTableWidget *tableWidget = new QTableWidget(3, 3, window); + tableWidget->setColumnCount(3); + QStringList hHeader; + hHeader << "h1" << "h2" << "h3"; + tableWidget->setHorizontalHeaderLabels(hHeader); + + QStringList vHeader; + vHeader << "v1" << "v2" << "v3"; + tableWidget->setVerticalHeaderLabels(vHeader); + + for (int i = 0; i<9; ++i) { + QTableWidgetItem *item = new QTableWidgetItem; + item->setText(QString::number(i/3) + QString(".") + QString::number(i%3)); + tableWidget->setItem(i/3, i%3, item); + } + + tableWidget->setFixedSize(600, 600); + lay->addWidget(button); lay->addWidget(te); + lay->addWidget(tableWidget); window->show(); QVERIFY(QTest::qWaitForWindowExposed(window)); @@ -3130,7 +3153,7 @@ void tst_QAccessibility::bridgeTest() long nChildren; hr = iaccWindow->get_accChildCount(&nChildren); QVERIFY(SUCCEEDED(hr)); - QCOMPARE(nChildren, (long)2); + QCOMPARE(nChildren, (long)3); /************************************************** * QTextEdit @@ -3170,6 +3193,63 @@ void tst_QAccessibility::bridgeTest() iaccTextEdit->Release(); + /************************************************** + * QTableWidget + **************************************************/ + { + // Get the second child (the accessible interface for the table widget) + varChild.vt = VT_I4; + varChild.lVal = 3; + QVERIFY(iaccWindow); + IAccessible *iaccTable = 0; + hr = iaccWindow->get_accChild(varChild, (IDispatch**)&iaccTable); + QVERIFY(SUCCEEDED(hr)); + QVERIFY(iaccTable); + hr = iaccTable->get_accRole(varSELF, &varRole); + QVERIFY(SUCCEEDED(hr)); + + QCOMPARE(varRole.vt, (VARTYPE)VT_I4); + QCOMPARE(varRole.lVal, (LONG)ROLE_SYSTEM_TABLE); + + +#ifdef QT_SUPPORTS_IACCESSIBLE2 + IAccessibleTable2 *ia2Table = (IAccessibleTable2*)queryIA2(iaccTable, IID_IAccessibleTable2); + QVERIFY(ia2Table); + BSTR bstrDescription; + hr = ia2Table->get_columnDescription(0, &bstrDescription); + QVERIFY(SUCCEEDED(hr)); + const QString description((QChar*)bstrDescription); + QCOMPARE(description, QLatin1String("h1")); + + IAccessible *accTableCell = 0; + hr = ia2Table->get_cellAt(1, 2, (IUnknown**)&accTableCell); + IAccessibleTableCell *ia2TableCell = (IAccessibleTableCell *)queryIA2(accTableCell, IID_IAccessibleTableCell); + QVERIFY(SUCCEEDED(hr)); + QVERIFY(ia2TableCell); + LONG index; + ia2TableCell->get_rowIndex(&index); + QCOMPARE(index, (LONG)1); + ia2TableCell->get_columnIndex(&index); + QCOMPARE(index, (LONG)2); + + IAccessible *iaccTableCell = 0; + hr = ia2TableCell->QueryInterface(IID_IAccessible, (void**)&iaccTableCell); + QVERIFY(SUCCEEDED(hr)); + QVERIFY(iaccTableCell); + BSTR bstrCellName; + hr = iaccTableCell->get_accName(varSELF, &bstrCellName); + QVERIFY(SUCCEEDED(hr)); + QString cellName((QChar*)bstrCellName); + QCOMPARE(cellName, QLatin1String("1.2")); + + accTableCell->Release(); + iaccTableCell->Release(); + ia2TableCell->Release(); + ia2Table->Release(); +#endif + iaccTextEdit->Release(); + } + iaccWindow->Release(); QTestAccessibility::clearEvents(); #endif |