aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2017-08-30 15:58:42 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2017-08-31 13:20:51 +0000
commitf40583bb6400d4ed67f83bc6e22e88049a314e06 (patch)
tree78257dcf0854ef4c0b2edc11805afea5fe63221d /tests
parentf0697c622ab087faa19679725250c0ac7f79372d (diff)
Fix accessibility-related performance regressions
Before 089dd16f, we had a QQuickControlPrivate::accessibleAttached member that indicated whether accessibility was active. Since 4be38ab in qtdeclarative, it was possible to access QQuickAccessibleAttached:: attachedProperties() directly, but we ended up accidentally accessing it even when accessibility was not active, which added noticeable overhead. This improves those qmlbench test cases that call accessibility-aware setters such as QQuickAbstractButton::setChecked() a lot. For example, the test cases for CheckBox and RadioButton create large amounts of controls with a "checked: index % 2" binding. - CheckBox: 84 => 93 frames - RadioButton: 98 => 113 frames QAccessible::setActive(true) only notifies the observers, but does not really make accessibility active in the sense that the consequent calls to QAccessible::isActive() still return false. tst_accessible had to be changed to use QPlatformAccessible::setActive() instead. Change-Id: I8fd0fe2dddfd5633ce22a080bcda459f2d6e443e Reviewed-by: Liang Qi <liang.qi@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/accessibility/tst_accessibility.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/tests/auto/accessibility/tst_accessibility.cpp b/tests/auto/accessibility/tst_accessibility.cpp
index 614566e6..7e491b54 100644
--- a/tests/auto/accessibility/tst_accessibility.cpp
+++ b/tests/auto/accessibility/tst_accessibility.cpp
@@ -43,6 +43,9 @@
#include "../shared/util.h"
#if QT_CONFIG(accessibility)
+#include <QtGui/private/qguiapplication_p.h>
+#include <QtGui/qpa/qplatformintegration.h>
+#include <QtGui/qpa/qplatformaccessibility.h>
#include <QtQuick/private/qquickaccessibleattached_p.h>
#endif
@@ -113,6 +116,14 @@ void tst_accessibility::a11y_data()
QTest::newRow("WeekNumberColumn") << "weeknumbercolumn" << 0x0 << "WeekNumberColumn"; //QAccessible::NoRole
}
+#if QT_CONFIG(accessibility)
+static QPlatformAccessibility *platformAccessibility()
+{
+ QPlatformIntegration *pfIntegration = QGuiApplicationPrivate::platformIntegration();
+ return pfIntegration ? pfIntegration->accessibility() : nullptr;
+}
+#endif
+
void tst_accessibility::a11y()
{
QFETCH(QString, name);
@@ -150,7 +161,10 @@ void tst_accessibility::a11y()
QVERIFY(acc);
} else {
QVERIFY(!acc);
- QAccessible::setActive(true);
+ QPlatformAccessibility *accessibility = platformAccessibility();
+ if (!accessibility)
+ QSKIP("No QPlatformAccessibility available.");
+ accessibility->setActive(true);
acc = QQuickAccessibleAttached::attachedProperties(item);
}
}