summaryrefslogtreecommitdiffstats
path: root/tests/auto/qaccessibility/tst_qaccessibility.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qaccessibility/tst_qaccessibility.cpp')
-rw-r--r--tests/auto/qaccessibility/tst_qaccessibility.cpp490
1 files changed, 483 insertions, 7 deletions
diff --git a/tests/auto/qaccessibility/tst_qaccessibility.cpp b/tests/auto/qaccessibility/tst_qaccessibility.cpp
index 1ab630d020..d8aa382548 100644
--- a/tests/auto/qaccessibility/tst_qaccessibility.cpp
+++ b/tests/auto/qaccessibility/tst_qaccessibility.cpp
@@ -187,7 +187,8 @@ static int verifyHierarchy(QAccessibleInterface *iface)
if (middleChild) {
entry = if2->navigate(QAccessible::Sibling, middle, &if3);
EXPECT(entry == 0 && if3->object() == middleChild->object());
- delete if3;
+ if (entry == 0)
+ delete if3;
EXPECT(iface->indexOfChild(middleChild) == middle);
}
@@ -229,6 +230,7 @@ private slots:
void navigateHierarchy();
void navigateSlider();
void navigateCovered();
+ void textAttributes();
void hideShowTest();
void userActionCount();
@@ -258,6 +260,9 @@ private slots:
void scrollAreaTest();
void tableWidgetTest();
void tableViewTest();
+ void table2ListTest();
+ void table2TreeTest();
+ void table2TableTest();
void calendarWidgetTest();
void dockWidgetTest();
void comboBoxTest();
@@ -288,6 +293,10 @@ QString eventName(const int ev)
case 0x0012: return "ScrollingStart";
case 0x0013: return "ScrollingEnd";
case 0x0018: return "MenuCommand";
+
+ case 0x0116: return "TableModelChanged";
+ case 0x011B: return "TextCaretMoved";
+
case 0x8000: return "ObjectCreated";
case 0x8001: return "ObjectDestroyed";
case 0x8002: return "ObjectShow";
@@ -854,6 +863,60 @@ void tst_QAccessibility::accessibleName()
QTestAccessibility::clearEvents();
}
+void tst_QAccessibility::textAttributes()
+{
+ QTextEdit textEdit;
+ int startOffset;
+ int endOffset;
+ QString attributes;
+ QString text("<html><head></head><body>"
+ "Hello, <b>this</b> is an <i><b>example</b> text</i>."
+ "<span style=\"font-family: monospace\">Multiple fonts are used.</span>"
+ "Multiple <span style=\"font-size: 8pt\">text sizes</span> are used."
+ "Let's give some color to <span style=\"color:#f0f1f2; background-color:#14f01e\">Qt</span>."
+ "</body></html>");
+
+ textEdit.setText(text);
+ QAccessibleInterface *interface = QAccessible::queryAccessibleInterface(&textEdit);
+
+ QAccessibleTextInterface *textInterface=interface->textInterface();
+
+ QVERIFY(textInterface);
+ QCOMPARE(textInterface->characterCount(), 112);
+
+ attributes = textInterface->attributes(10, &startOffset, &endOffset);
+ QCOMPARE(startOffset, 7);
+ QCOMPARE(endOffset, 11);
+ attributes.prepend(';');
+ QVERIFY(attributes.contains(QLatin1String(";font-weight:bold;")));
+
+ attributes = textInterface->attributes(18, &startOffset, &endOffset);
+ QCOMPARE(startOffset, 18);
+ QCOMPARE(endOffset, 25);
+ attributes.prepend(';');
+ QVERIFY(attributes.contains(QLatin1String(";font-weight:bold;")));
+ QVERIFY(attributes.contains(QLatin1String(";font-style:italic;")));
+
+ attributes = textInterface->attributes(34, &startOffset, &endOffset);
+ QCOMPARE(startOffset, 31);
+ QCOMPARE(endOffset, 55);
+ attributes.prepend(';');
+ QVERIFY(attributes.contains(QLatin1String(";font-family:\"monospace\";")));
+
+ attributes = textInterface->attributes(65, &startOffset, &endOffset);
+ QCOMPARE(startOffset, 64);
+ QCOMPARE(endOffset, 74);
+ attributes.prepend(';');
+ QVERIFY(attributes.contains(QLatin1String(";font-size:8pt;")));
+
+ attributes = textInterface->attributes(110, &startOffset, &endOffset);
+ QCOMPARE(startOffset, 109);
+ QCOMPARE(endOffset, 111);
+ attributes.prepend(';');
+ QVERIFY(attributes.contains(QLatin1String(";background-color:rgb(20,240,30);")));
+ QVERIFY(attributes.contains(QLatin1String(";color:rgb(240,241,242);")));
+}
+
void tst_QAccessibility::hideShowTest()
{
QWidget * const window = new QWidget();
@@ -957,18 +1020,21 @@ void tst_QAccessibility::applicationTest()
void tst_QAccessibility::mainWindowTest()
{
- QMainWindow mw;
- mw.resize(300, 200);
- mw.show(); // triggers layout
+ QMainWindow *mw = new QMainWindow;
+ mw->resize(300, 200);
+ mw->show(); // triggers layout
QLatin1String name = QLatin1String("I am the main window");
- mw.setWindowTitle(name);
- QTest::qWaitForWindowShown(&mw);
+ mw->setWindowTitle(name);
+ QTest::qWaitForWindowShown(mw);
+ QVERIFY_EVENT(mw, 0, QAccessible::ObjectShow);
- QAccessibleInterface *interface = QAccessible::queryAccessibleInterface(&mw);
+ QAccessibleInterface *interface = QAccessible::queryAccessibleInterface(mw);
QCOMPARE(interface->text(QAccessible::Name, 0), name);
QCOMPARE(interface->role(0), QAccessible::Window);
delete interface;
+ delete mw;
+ QTestAccessibility::clearEvents();
}
class CounterButton : public QPushButton {
@@ -1679,6 +1745,8 @@ void tst_QAccessibility::textEditTest()
{
{
QTextEdit edit;
+ int startOffset;
+ int endOffset;
QString text = "hello world\nhow are you today?\n";
edit.setText(text);
edit.show();
@@ -1688,6 +1756,12 @@ void tst_QAccessibility::textEditTest()
QCOMPARE(iface->childCount(), 6);
QCOMPARE(iface->text(QAccessible::Value, 4), QString("hello world"));
QCOMPARE(iface->text(QAccessible::Value, 5), QString("how are you today?"));
+ QCOMPARE(iface->textInterface()->textAtOffset(8, QAccessible2::WordBoundary, &startOffset, &endOffset), QString("world"));
+ QCOMPARE(startOffset, 6);
+ QCOMPARE(endOffset, 11);
+ QCOMPARE(iface->textInterface()->textAtOffset(14, QAccessible2::LineBoundary, &startOffset, &endOffset), QString("how are you today?"));
+ QCOMPARE(startOffset, 12);
+ QCOMPARE(endOffset, 30);
QCOMPARE(iface->text(QAccessible::Value, 6), QString());
QCOMPARE(iface->textInterface()->characterCount(), 31);
QFontMetrics fm(edit.font());
@@ -1720,6 +1794,9 @@ void tst_QAccessibility::textBrowserTest()
void tst_QAccessibility::listViewTest()
{
+#if defined(Q_WS_X11)
+ QSKIP( "Accessible table1 interface is no longer supported on X11.", SkipAll);
+#else
{
QListView listView;
QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(&listView);
@@ -1785,6 +1862,7 @@ void tst_QAccessibility::listViewTest()
}
QTestAccessibility::clearEvents();
+#endif
}
@@ -2020,9 +2098,71 @@ void tst_QAccessibility::lineEditTest()
QTestAccessibility::clearEvents();
le2->setFocus(Qt::TabFocusReason);
QTRY_VERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(le2, 0, QAccessible::Focus)));
+
+ le->setText(QLatin1String("500"));
+ le->setValidator(new QIntValidator());
+ iface->setText(QAccessible::Value, 0, QLatin1String("This text is not a number"));
+ QCOMPARE(le->text(), QLatin1String("500"));
+
delete iface;
delete le;
delete le2;
+ QTestAccessibility::clearEvents();
+
+ // IA2
+ QString cite = "I always pass on good advice. It is the only thing to do with it. It is never of any use to oneself. --Oscar Wilde";
+ QLineEdit *le3 = new QLineEdit(cite, toplevel);
+ iface = QAccessible::queryAccessibleInterface(le3);
+ QAccessibleTextInterface* textIface = iface->textInterface();
+ le3->deselect();
+ le3->setCursorPosition(3);
+ QCOMPARE(textIface->cursorPosition(), 3);
+ QTRY_VERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(le3, 0, QAccessible::TextCaretMoved)));
+ QCOMPARE(textIface->selectionCount(), 0);
+ QTestAccessibility::clearEvents();
+
+ int start, end;
+ QCOMPARE(textIface->text(0, 8), QString::fromLatin1("I always"));
+ QCOMPARE(textIface->textAtOffset(0, QAccessible2::CharBoundary,&start,&end), QString::fromLatin1("I"));
+ QCOMPARE(start, 0);
+ QCOMPARE(end, 1);
+ QCOMPARE(textIface->textBeforeOffset(0, QAccessible2::CharBoundary,&start,&end), QString());
+ QCOMPARE(textIface->textAfterOffset(0, QAccessible2::CharBoundary,&start,&end), QString::fromLatin1(" "));
+ QCOMPARE(start, 1);
+ QCOMPARE(end, 2);
+
+ QCOMPARE(textIface->textAtOffset(5, QAccessible2::CharBoundary,&start,&end), QString::fromLatin1("a"));
+ QCOMPARE(start, 5);
+ QCOMPARE(end, 6);
+ QCOMPARE(textIface->textBeforeOffset(5, QAccessible2::CharBoundary,&start,&end), QString::fromLatin1("w"));
+ QCOMPARE(textIface->textAfterOffset(5, QAccessible2::CharBoundary,&start,&end), QString::fromLatin1("y"));
+
+ QCOMPARE(textIface->textAtOffset(5, QAccessible2::WordBoundary,&start,&end), QString::fromLatin1("always"));
+ QCOMPARE(start, 2);
+ QCOMPARE(end, 8);
+
+ QCOMPARE(textIface->textAtOffset(2, QAccessible2::WordBoundary,&start,&end), QString::fromLatin1("always"));
+ QCOMPARE(textIface->textAtOffset(7, QAccessible2::WordBoundary,&start,&end), QString::fromLatin1("always"));
+ QCOMPARE(textIface->textAtOffset(8, QAccessible2::WordBoundary,&start,&end), QString::fromLatin1(" "));
+ QCOMPARE(textIface->textAtOffset(25, QAccessible2::WordBoundary,&start,&end), QString::fromLatin1("advice"));
+ QCOMPARE(textIface->textAtOffset(92, QAccessible2::WordBoundary,&start,&end), QString::fromLatin1("oneself"));
+
+ QCOMPARE(textIface->textBeforeOffset(5, QAccessible2::WordBoundary,&start,&end), QString::fromLatin1(" "));
+ QCOMPARE(textIface->textAfterOffset(5, QAccessible2::WordBoundary,&start,&end), QString::fromLatin1(" "));
+ QCOMPARE(textIface->textAtOffset(5, QAccessible2::SentenceBoundary,&start,&end), QString::fromLatin1("I always pass on good advice. "));
+ QCOMPARE(start, 0);
+ QCOMPARE(end, 30);
+
+ QCOMPARE(textIface->textBeforeOffset(40, QAccessible2::SentenceBoundary,&start,&end), QString::fromLatin1("I always pass on good advice. "));
+ QCOMPARE(textIface->textAfterOffset(5, QAccessible2::SentenceBoundary,&start,&end), QString::fromLatin1("It is the only thing to do with it. "));
+
+ QCOMPARE(textIface->textAtOffset(5, QAccessible2::ParagraphBoundary,&start,&end), cite);
+ QCOMPARE(start, 0);
+ QCOMPARE(end, cite.length());
+ QCOMPARE(textIface->textAtOffset(5, QAccessible2::LineBoundary,&start,&end), cite);
+ QCOMPARE(textIface->textAtOffset(5, QAccessible2::NoBoundary,&start,&end), cite);
+
+ delete iface;
delete toplevel;
QTestAccessibility::clearEvents();
}
@@ -2435,6 +2575,9 @@ void tst_QAccessibility::scrollAreaTest()
void tst_QAccessibility::tableWidgetTest()
{
+#if defined(Q_WS_X11)
+ QSKIP( "Accessible table1 interface is no longer supported on X11.", SkipAll);
+#else
{
QWidget *topLevel = new QWidget;
QTableWidget *w = new QTableWidget(8,4,topLevel);
@@ -2474,6 +2617,7 @@ void tst_QAccessibility::tableWidgetTest()
delete topLevel;
}
QTestAccessibility::clearEvents();
+#endif
}
class QtTestTableModel: public QAbstractTableModel
@@ -2556,6 +2700,9 @@ public:
void tst_QAccessibility::tableViewTest()
{
+#if defined(Q_WS_X11)
+ QSKIP( "Accessible table1 interface is no longer supported on X11.", SkipAll);
+#else
{
QtTestTableModel *model = new QtTestTableModel(3, 4);
QTableView *w = new QTableView();
@@ -2635,6 +2782,331 @@ void tst_QAccessibility::tableViewTest()
delete model;
}
QTestAccessibility::clearEvents();
+#endif
+}
+
+void tst_QAccessibility::table2ListTest()
+{
+#if !defined(Q_WS_X11)
+ QSKIP( "Accessible table2 interface is currently only supported on X11.", SkipAll);
+#else
+ QListWidget *listView = new QListWidget;
+ listView->addItem("Oslo");
+ listView->addItem("Berlin");
+ listView->addItem("Brisbane");
+ listView->resize(400,400);
+ listView->show();
+ QTest::qWait(1); // Need this for indexOfchild to work.
+#if defined(Q_WS_X11)
+ qt_x11_wait_for_window_manager(listView);
+ QTest::qWait(100);
+#endif
+
+ QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(listView);
+ QCOMPARE(verifyHierarchy(iface), 0);
+
+ QCOMPARE((int)iface->role(0), (int)QAccessible::List);
+ QCOMPARE(iface->childCount(), 3);
+
+ QAccessibleInterface *child1 = 0;
+ QCOMPARE(iface->navigate(QAccessible::Child, 1, &child1), 0);
+ QVERIFY(child1);
+ QCOMPARE(iface->indexOfChild(child1), 1);
+ QCOMPARE(child1->text(QAccessible::Name, 0), QString("Oslo"));
+ QCOMPARE(child1->role(0), QAccessible::ListItem);
+ delete child1;
+
+ QAccessibleInterface *child2 = 0;
+ QCOMPARE(iface->navigate(QAccessible::Child, 2, &child2), 0);
+ QVERIFY(child2);
+ QCOMPARE(iface->indexOfChild(child2), 2);
+ QCOMPARE(child2->text(QAccessible::Name, 0), QString("Berlin"));
+ delete child2;
+
+ QAccessibleInterface *child3 = 0;
+ QCOMPARE(iface->navigate(QAccessible::Child, 3, &child3), 0);
+ QVERIFY(child3);
+ QCOMPARE(iface->indexOfChild(child3), 3);
+ QCOMPARE(child3->text(QAccessible::Name, 0), QString("Brisbane"));
+ delete child3;
+ QTestAccessibility::clearEvents();
+
+ // Check for events
+ QTest::mouseClick(listView->viewport(), Qt::LeftButton, 0, listView->visualItemRect(listView->item(1)).center());
+ QVERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(listView, 2, QAccessible::Selection)));
+ QVERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(listView, 2, QAccessible::Focus)));
+ QTest::mouseClick(listView->viewport(), Qt::LeftButton, 0, listView->visualItemRect(listView->item(2)).center());
+ QVERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(listView, 3, QAccessible::Selection)));
+ QVERIFY(QTestAccessibility::events().contains(QTestAccessibilityEvent(listView, 3, QAccessible::Focus)));
+
+ listView->addItem("Munich");
+ QCOMPARE(iface->childCount(), 4);
+
+ // table 2
+ QAccessibleTable2Interface *table2 = iface->table2Interface();
+ QVERIFY(table2);
+ QCOMPARE(table2->columnCount(), 1);
+ QCOMPARE(table2->rowCount(), 4);
+ QAccessibleTable2CellInterface *cell1;
+ QVERIFY(cell1 = table2->cellAt(0,0));
+ QCOMPARE(cell1->text(QAccessible::Name, 0), QString("Oslo"));
+ QAccessibleTable2CellInterface *cell4;
+ QVERIFY(cell4 = table2->cellAt(3,0));
+ QCOMPARE(cell4->text(QAccessible::Name, 0), QString("Munich"));
+ QCOMPARE(cell4->role(0), QAccessible::ListItem);
+ QCOMPARE(cell4->rowIndex(), 3);
+ QCOMPARE(cell4->columnIndex(), 0);
+ QVERIFY(!cell4->isExpandable());
+
+ delete cell4;
+ delete cell1;
+ delete iface;
+ delete listView;
+ QTestAccessibility::clearEvents();
+#endif
+}
+
+void tst_QAccessibility::table2TreeTest()
+{
+#if !defined(Q_WS_X11)
+ QSKIP( "Accessible table2 interface is currently only supported on X11.", SkipAll);
+#else
+ QTreeWidget *treeView = new QTreeWidget;
+ treeView->setColumnCount(2);
+ QTreeWidgetItem *header = new QTreeWidgetItem;
+ header->setText(0, "Artist");
+ header->setText(1, "Work");
+ treeView->setHeaderItem(header);
+
+ QTreeWidgetItem *root1 = new QTreeWidgetItem;
+ root1->setText(0, "Spain");
+ treeView->addTopLevelItem(root1);
+
+ QTreeWidgetItem *item1 = new QTreeWidgetItem;
+ item1->setText(0, "Picasso");
+ item1->setText(1, "Guernica");
+ root1->addChild(item1);
+
+ QTreeWidgetItem *item2 = new QTreeWidgetItem;
+ item2->setText(0, "Tapies");
+ item2->setText(1, "Ambrosia");
+ root1->addChild(item2);
+
+ QTreeWidgetItem *root2 = new QTreeWidgetItem;
+ root2->setText(0, "Austria");
+ treeView->addTopLevelItem(root2);
+
+ QTreeWidgetItem *item3 = new QTreeWidgetItem;
+ item3->setText(0, "Klimt");
+ item3->setText(1, "The Kiss");
+ root2->addChild(item3);
+
+ treeView->resize(400,400);
+ treeView->show();
+ QTest::qWait(1); // Need this for indexOfchild to work.
+#if defined(Q_WS_X11)
+ qt_x11_wait_for_window_manager(treeView);
+ QTest::qWait(100);
+#endif
+
+ QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(treeView);
+ QEXPECT_FAIL("", "Implement Sibling navigation for table2 cells.", Continue);
+ QCOMPARE(verifyHierarchy(iface), 0);
+
+ QCOMPARE((int)iface->role(0), (int)QAccessible::Tree);
+ // header and 2 rows (the others are not expanded, thus not visible)
+ QCOMPARE(iface->childCount(), 6);
+
+ QAccessibleInterface *header1 = 0;
+ QCOMPARE(iface->navigate(QAccessible::Child, 1, &header1), 0);
+ QVERIFY(header1);
+ QCOMPARE(iface->indexOfChild(header1), 1);
+ QCOMPARE(header1->text(QAccessible::Name, 0), QString("Artist"));
+ QCOMPARE(header1->role(0), QAccessible::ColumnHeader);
+ delete header1;
+
+ QAccessibleInterface *child1 = 0;
+ QCOMPARE(iface->navigate(QAccessible::Child, 3, &child1), 0);
+ QVERIFY(child1);
+ QCOMPARE(iface->indexOfChild(child1), 3);
+ QCOMPARE(child1->text(QAccessible::Name, 0), QString("Spain"));
+ QCOMPARE(child1->role(0), QAccessible::TreeItem);
+ QVERIFY(!(child1->state(0) & QAccessible::Expanded));
+ delete child1;
+
+ QAccessibleInterface *child2 = 0;
+ QCOMPARE(iface->navigate(QAccessible::Child, 5, &child2), 0);
+ QVERIFY(child2);
+ QCOMPARE(iface->indexOfChild(child2), 5);
+ QCOMPARE(child2->text(QAccessible::Name, 0), QString("Austria"));
+ delete child2;
+
+ QTestAccessibility::clearEvents();
+
+ // table 2
+ QAccessibleTable2Interface *table2 = iface->table2Interface();
+ QVERIFY(table2);
+ QCOMPARE(table2->columnCount(), 2);
+ QCOMPARE(table2->rowCount(), 2);
+ QAccessibleTable2CellInterface *cell1;
+ QVERIFY(cell1 = table2->cellAt(0,0));
+ QCOMPARE(cell1->text(QAccessible::Name, 0), QString("Spain"));
+ QAccessibleTable2CellInterface *cell2;
+ QVERIFY(cell2 = table2->cellAt(1,0));
+ QCOMPARE(cell2->text(QAccessible::Name, 0), QString("Austria"));
+ QCOMPARE(cell2->role(0), QAccessible::TreeItem);
+ QCOMPARE(cell2->rowIndex(), 1);
+ QCOMPARE(cell2->columnIndex(), 0);
+ QVERIFY(cell2->isExpandable());
+ QCOMPARE(iface->indexOfChild(cell2), 5);
+ QVERIFY(!(cell2->state(0) & QAccessible::Expanded));
+ QCOMPARE(table2->columnDescription(1), QString("Work"));
+ delete cell2;
+ delete cell1;
+
+ treeView->expandAll();
+
+ QTest::qWait(1); // Need this for indexOfchild to work.
+#if defined(Q_WS_X11)
+ qt_x11_wait_for_window_manager(treeView);
+ QTest::qWait(100);
+#endif
+
+ QCOMPARE(table2->columnCount(), 2);
+ QCOMPARE(table2->rowCount(), 5);
+ cell1 = table2->cellAt(1,0);
+ QCOMPARE(cell1->text(QAccessible::Name, 0), QString("Picasso"));
+ QCOMPARE(iface->indexOfChild(cell1), 5); // 1 based + 2 header + 2 for root item
+
+ cell2 = table2->cellAt(4,0);
+ QCOMPARE(cell2->text(QAccessible::Name, 0), QString("Klimt"));
+ QCOMPARE(cell2->role(0), QAccessible::TreeItem);
+ QCOMPARE(cell2->rowIndex(), 4);
+ QCOMPARE(cell2->columnIndex(), 0);
+ QVERIFY(!cell2->isExpandable());
+ QCOMPARE(iface->indexOfChild(cell2), 11);
+
+ QCOMPARE(table2->columnDescription(0), QString("Artist"));
+ QCOMPARE(table2->columnDescription(1), QString("Work"));
+
+ delete iface;
+ QTestAccessibility::clearEvents();
+#endif
+}
+
+
+void tst_QAccessibility::table2TableTest()
+{
+#if !defined(Q_WS_X11)
+ QSKIP( "Accessible table2 interface is currently only supported on X11.", SkipAll);
+#else
+ QTableWidget *tableView = new QTableWidget(3, 3);
+ tableView->setColumnCount(3);
+ QStringList hHeader;
+ hHeader << "h1" << "h2" << "h3";
+ tableView->setHorizontalHeaderLabels(hHeader);
+
+ QStringList vHeader;
+ vHeader << "v1" << "v2" << "v3";
+ tableView->setVerticalHeaderLabels(vHeader);
+
+ for (int i = 0; i<9; ++i) {
+ QTableWidgetItem *item = new QTableWidgetItem;
+ item->setText(QString::number(i/3) + QString(".") + QString::number(i%3));
+ tableView->setItem(i/3, i%3, item);
+ }
+
+ tableView->resize(600,600);
+ tableView->show();
+ QTest::qWait(1); // Need this for indexOfchild to work.
+#if defined(Q_WS_X11)
+ qt_x11_wait_for_window_manager(tableView);
+ QTest::qWait(100);
+#endif
+
+ QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(tableView);
+ QEXPECT_FAIL("", "Implement Sibling navigation for table2 cells.", Continue);
+ QCOMPARE(verifyHierarchy(iface), 0);
+
+ QCOMPARE((int)iface->role(0), (int)QAccessible::Table);
+ // header and 2 rows (the others are not expanded, thus not visible)
+ QCOMPARE(iface->childCount(), 9+3+3+1); // cell+headers+topleft button
+
+ QAccessibleInterface *cornerButton = 0;
+ QCOMPARE(iface->navigate(QAccessible::Child, 1, &cornerButton), 0);
+ QVERIFY(cornerButton);
+ QCOMPARE(iface->indexOfChild(cornerButton), 1);
+ QCOMPARE(cornerButton->role(0), QAccessible::Pane);
+ delete cornerButton;
+
+ QAccessibleInterface *child1 = 0;
+ QCOMPARE(iface->navigate(QAccessible::Child, 3, &child1), 0);
+ QVERIFY(child1);
+ QCOMPARE(iface->indexOfChild(child1), 3);
+ QCOMPARE(child1->text(QAccessible::Name, 0), QString("h2"));
+ QCOMPARE(child1->role(0), QAccessible::ColumnHeader);
+ QVERIFY(!(child1->state(0) & QAccessible::Expanded));
+ delete child1;
+
+ QAccessibleInterface *child2 = 0;
+ QCOMPARE(iface->navigate(QAccessible::Child, 11, &child2), 0);
+ QVERIFY(child2);
+ QCOMPARE(iface->indexOfChild(child2), 11);
+ QCOMPARE(child2->text(QAccessible::Name, 0), QString("1.1"));
+ QAccessibleTable2CellInterface *cell2Iface = static_cast<QAccessibleTable2CellInterface*>(child2);
+ QCOMPARE(cell2Iface->rowIndex(), 1);
+ QCOMPARE(cell2Iface->columnIndex(), 1);
+ delete child2;
+
+ QAccessibleInterface *child3 = 0;
+ QCOMPARE(iface->navigate(QAccessible::Child, 12, &child3), 0);
+ QCOMPARE(iface->indexOfChild(child3), 12);
+ QCOMPARE(child3->text(QAccessible::Name, 0), QString("1.2"));
+ delete child3;
+
+ QTestAccessibility::clearEvents();
+
+ // table 2
+ QAccessibleTable2Interface *table2 = iface->table2Interface();
+ QVERIFY(table2);
+ QCOMPARE(table2->columnCount(), 3);
+ QCOMPARE(table2->rowCount(), 3);
+ QAccessibleTable2CellInterface *cell1;
+ QVERIFY(cell1 = table2->cellAt(0,0));
+ QCOMPARE(cell1->text(QAccessible::Name, 0), QString("0.0"));
+ QCOMPARE(iface->indexOfChild(cell1), 6);
+
+ QAccessibleTable2CellInterface *cell2;
+ QVERIFY(cell2 = table2->cellAt(0,1));
+ QCOMPARE(cell2->text(QAccessible::Name, 0), QString("0.1"));
+ QCOMPARE(cell2->role(0), QAccessible::Cell);
+ QCOMPARE(cell2->rowIndex(), 0);
+ QCOMPARE(cell2->columnIndex(), 1);
+ QCOMPARE(iface->indexOfChild(cell2), 7);
+ delete cell2;
+
+ QAccessibleTable2CellInterface *cell3;
+ QVERIFY(cell3 = table2->cellAt(1,2));
+ QCOMPARE(cell3->text(QAccessible::Name, 0), QString("1.2"));
+ QCOMPARE(cell3->role(0), QAccessible::Cell);
+ QCOMPARE(cell3->rowIndex(), 1);
+ QCOMPARE(cell3->columnIndex(), 2);
+ QCOMPARE(iface->indexOfChild(cell3), 12);
+ delete cell3;
+
+ QCOMPARE(table2->columnDescription(0), QString("h1"));
+ QCOMPARE(table2->columnDescription(1), QString("h2"));
+ QCOMPARE(table2->columnDescription(2), QString("h3"));
+ QCOMPARE(table2->rowDescription(0), QString("v1"));
+ QCOMPARE(table2->rowDescription(1), QString("v2"));
+ QCOMPARE(table2->rowDescription(2), QString("v3"));
+
+ delete iface;
+
+ delete tableView;
+
+ QTestAccessibility::clearEvents();
+#endif
}
void tst_QAccessibility::calendarWidgetTest()
@@ -2851,6 +3323,9 @@ void tst_QAccessibility::comboBoxTest()
void tst_QAccessibility::treeWidgetTest()
{
+#if defined(Q_WS_X11)
+ QSKIP( "Accessible table1 interface is no longer supported on X11.", SkipAll);
+#else
QWidget *w = new QWidget;
QTreeWidget *tree = new QTreeWidget(w);
QHBoxLayout *l = new QHBoxLayout(w);
@@ -2908,6 +3383,7 @@ void tst_QAccessibility::treeWidgetTest()
delete w;
QTestAccessibility::clearEvents();
+#endif
}
void tst_QAccessibility::labelTest()