From e39d629ebe9044b505ac35eaae3ab9c214d452a2 Mon Sep 17 00:00:00 2001 From: Jan Arve Saether Date: Wed, 11 Sep 2013 11:09:40 +0200 Subject: Include hidden headers in trees and tables consistently There was a disagreement between the a11y plugin and QTreeView whether the horizontal header should have been exposed or not. When the header was hidden, this resulted in that we sent an event with a child id that was wrong, or in worst case higher than QAI::childrenCount(). This was the reason we got the warning output as described in the task. With this commit, we consistently *expose* hidden headers both for QTreeView and QTableView, but ensure that their state().invisible is set to true instead. This makes it consistent with how hidden cells are exposed. This also fixes a bug in QTableViewPrivate::accessibleTable2Index where we always added 1 to the index, which was spotted while writing the test. Task-number: QTBUG-33247 Change-Id: Ifd1f83d56296dd071424fdb81fce7628bc24fe0a Reviewed-by: Frederik Gladhorn --- .../other/qaccessibility/tst_qaccessibility.cpp | 41 ++++++++++++++++++---- 1 file changed, 35 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index 557189f4e2..4186572be3 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -2600,11 +2600,23 @@ void tst_QAccessibility::treeTest() QCOMPARE(iface->indexOfChild(child2), 4); QCOMPARE(child2->text(QAccessible::Name), QString("Austria")); - treeView->setHeaderHidden(true); - QAccessibleInterface *accSpain = iface->child(0); - QCOMPARE(accSpain->role(), QAccessible::TreeItem); - QCOMPARE(iface->indexOfChild(accSpain), 0); - treeView->setHeaderHidden(false); + bool headerHidden = true; + do { + treeView->setHeaderHidden(headerHidden); + header1 = iface->child(0); + QCOMPARE(header1->role(), QAccessible::ColumnHeader); + QCOMPARE(!!header1->state().invisible, headerHidden); + QCOMPARE(header1->text(QAccessible::Name), QStringLiteral("Artist")); + header1 = iface->child(1); + QCOMPARE(header1->role(), QAccessible::ColumnHeader); + QCOMPARE(!!header1->state().invisible, headerHidden); + QCOMPARE(header1->text(QAccessible::Name), QStringLiteral("Work")); + + QAccessibleInterface *accSpain = iface->child(2); + QCOMPARE(accSpain->role(), QAccessible::TreeItem); + QCOMPARE(iface->indexOfChild(accSpain), 2); + headerHidden = !headerHidden; + } while (!headerHidden); QTestAccessibility::clearEvents(); @@ -2931,8 +2943,25 @@ void tst_QAccessibility::tableTest() cell30_new = table2->cellAt(3, 0); QCOMPARE(cell30_new, cell20); QCOMPARE(iface->indexOfChild(cell30_new), 21); - delete tableView; + + { + QTestAccessibility::clearEvents(); + QModelIndex index00 = tableView->model()->index(1, 1, tableView->rootIndex()); + tableView->setSelectionBehavior(QAbstractItemView::SelectItems); + tableView->setSelectionMode(QAbstractItemView::SingleSelection); + tableView->selectionModel()->select(index00, QItemSelectionModel::ClearAndSelect); + QAccessibleEvent event(tableView, QAccessible::Selection); + event.setChild(12); + QCOMPARE(QTestAccessibility::containsEvent(&event), true); + QTestAccessibility::clearEvents(); + tableView->setSelectionBehavior(QAbstractItemView::SelectItems); + tableView->setSelectionMode(QAbstractItemView::SingleSelection); + tableView->selectionModel()->select(index00, QItemSelectionModel::ClearAndSelect); + tableView->horizontalHeader()->setVisible(false); + + } + delete tableView; QVERIFY(!QAccessible::accessibleInterface(id00)); QTestAccessibility::clearEvents(); } -- cgit v1.2.3