From 18291af42caf18165f99dd0300738576b96379a6 Mon Sep 17 00:00:00 2001 From: Dongmei Wang Date: Fri, 22 Jan 2016 20:19:28 -0800 Subject: QTabBar: Add setAccessibleTabName() and accessibleTabName() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently, a tab's text is used as its accessibleName. When a tab's text is empty, there is no API to set the tab's accessibleName. The two APIs are added to set and return the accessibleName property of a tab. Task-number: QTBUG-46530 Change-Id: Idf88b5f905fe66c6365ea0eeb650e74211db90e1 Reviewed-by: Jan Arve Sæther --- .../auto/other/qaccessibility/tst_qaccessibility.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'tests/auto/other') diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index 046c77d6c3..2f5936f1ad 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -1301,6 +1301,16 @@ void tst_QAccessibility::tabTest() child2->actionInterface()->doAction(QAccessibleActionInterface::pressAction()); QCOMPARE(tabBar->currentIndex(), 1); + // Test that setAccessibleTabName changes a tab's accessible name + tabBar->setAccessibleTabName(0, "AccFoo"); + tabBar->setAccessibleTabName(1, "AccBar"); + QCOMPARE(child1->text(QAccessible::Name), QLatin1String("AccFoo")); + QCOMPARE(child2->text(QAccessible::Name), QLatin1String("AccBar")); + tabBar->setCurrentIndex(0); + QCOMPARE(interface->text(QAccessible::Name), QLatin1String("AccFoo")); + tabBar->setCurrentIndex(1); + QCOMPARE(interface->text(QAccessible::Name), QLatin1String("AccBar")); + delete tabBar; QTestAccessibility::clearEvents(); } @@ -1338,10 +1348,17 @@ void tst_QAccessibility::tabWidgetTest() QCOMPARE(tabButton1Interface->text(QAccessible::Name), QLatin1String("Tab 1")); QAccessibleInterface* tabButton2Interface = tabBarInterface->child(1); - QVERIFY(tabButton1Interface); + QVERIFY(tabButton2Interface); QCOMPARE(tabButton2Interface->role(), QAccessible::PageTab); QCOMPARE(tabButton2Interface->text(QAccessible::Name), QLatin1String("Tab 2")); + // Test that setAccessibleTabName changes a tab's accessible name + tabWidget->setCurrentIndex(0); + tabWidget->tabBar()->setAccessibleTabName(0, "Acc Tab"); + QCOMPARE(tabButton1Interface->role(), QAccessible::PageTab); + QCOMPARE(tabButton1Interface->text(QAccessible::Name), QLatin1String("Acc Tab")); + QCOMPARE(tabBarInterface->text(QAccessible::Name), QLatin1String("Acc Tab")); + QAccessibleInterface* tabButtonLeft = tabBarInterface->child(2); QVERIFY(tabButtonLeft); QCOMPARE(tabButtonLeft->role(), QAccessible::PushButton); -- cgit v1.2.3