Window and Application fixes for accessibility.
Return app name instead of window title for root accessibility object. Return Window as accessible type for the main window. Reviewed-by: Jan-Arve (cherry picked from commit 9a5b0d7a579572cd7e7faf869ab1a6684800f592)
This commit is contained in:
parent
8f5b2faaac
commit
a5e191de57
@ -322,9 +322,7 @@ QString QAccessibleApplication::text(Text t, int) const
|
||||
{
|
||||
switch (t) {
|
||||
case Name:
|
||||
if (QApplication::activeWindow())
|
||||
return QApplication::activeWindow()->windowTitle();
|
||||
break;
|
||||
return QApplication::applicationName();
|
||||
case Description:
|
||||
return QApplication::applicationFilePath();
|
||||
default:
|
||||
|
@ -1603,7 +1603,7 @@ void QAccessibleTextEdit::setAttributes(int startOffset, int endOffset, const QS
|
||||
|
||||
#ifndef QT_NO_MAINWINDOW
|
||||
QAccessibleMainWindow::QAccessibleMainWindow(QWidget *widget)
|
||||
: QAccessibleWidgetEx(widget, Application) { }
|
||||
: QAccessibleWidgetEx(widget, Window) { }
|
||||
|
||||
QVariant QAccessibleMainWindow::invokeMethodEx(QAccessible::Method /*method*/, int /*child*/, const QVariantList & /*params*/)
|
||||
{
|
||||
|
@ -245,6 +245,8 @@ private slots:
|
||||
void actionText();
|
||||
void doAction();
|
||||
|
||||
void applicationTest();
|
||||
void mainWindowTest();
|
||||
void buttonTest();
|
||||
void sliderTest();
|
||||
void scrollBarTest();
|
||||
@ -1826,6 +1828,41 @@ void tst_QAccessibility::doAction()
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QAccessibility::applicationTest()
|
||||
{
|
||||
#ifdef QTEST_ACCESSIBILITY
|
||||
QLatin1String name = QLatin1String("My Name");
|
||||
qApp->setApplicationName(name);
|
||||
QAccessibleInterface *interface = QAccessible::queryAccessibleInterface(qApp);
|
||||
QCOMPARE(interface->text(QAccessible::Name, 0), name);
|
||||
QCOMPARE(interface->role(0), QAccessible::Application);
|
||||
delete interface;
|
||||
#else
|
||||
QSKIP("Test needs accessibility support.", SkipAll);
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QAccessibility::mainWindowTest()
|
||||
{
|
||||
#ifdef QTEST_ACCESSIBILITY
|
||||
QMainWindow mw;
|
||||
mw.resize(300, 200);
|
||||
mw.show(); // triggers layout
|
||||
|
||||
QLatin1String name = QLatin1String("I am the main window");
|
||||
mw.setWindowTitle(name);
|
||||
QTest::qWaitForWindowShown(&mw);
|
||||
|
||||
QAccessibleInterface *interface = QAccessible::queryAccessibleInterface(&mw);
|
||||
QCOMPARE(interface->text(QAccessible::Name, 0), name);
|
||||
QCOMPARE(interface->role(0), QAccessible::Window);
|
||||
delete interface;
|
||||
|
||||
#else
|
||||
QSKIP("Test needs accessibility support.", SkipAll);
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_QAccessibility::buttonTest()
|
||||
{
|
||||
//#ifdef QTEST_ACCESSIBILITY
|
||||
|
Loading…
Reference in New Issue
Block a user