aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp')
-rw-r--r--tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp82
1 files changed, 75 insertions, 7 deletions
diff --git a/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp b/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp
index e843f9e5a1..1bfeb94161 100644
--- a/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp
+++ b/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp
@@ -42,9 +42,11 @@
#include <QtQml/qqmlengine.h>
#include <QtQml/qqmlproperty.h>
#include <QtQuick/private/qquickaccessibleattached_p.h>
+#include <QtQuick/private/qquicklistview_p.h>
+#include <QtQuick/private/qquicktext_p.h>
#include "../../shared/util.h"
-
+#include "../shared/visualtestutil.h"
#define EXPECT(cond) \
do { \
@@ -143,7 +145,7 @@ void tst_QQuickAccessible::commonTests()
view->setSource(testFileUrl(accessibleRoleFileName));
view->show();
// view->setFocus();
- QVERIFY(view->rootObject() != 0);
+ QVERIFY(view->rootObject() != nullptr);
QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(view);
QVERIFY(iface);
@@ -160,10 +162,10 @@ void tst_QQuickAccessible::quickAttachedProperties()
component.setData("import QtQuick 2.0\nItem {\n"
"}", QUrl());
QObject *object = component.create();
- QVERIFY(object != 0);
+ QVERIFY(object != nullptr);
QObject *attachedObject = QQuickAccessibleAttached::attachedProperties(object);
- QCOMPARE(attachedObject, static_cast<QObject*>(0));
+ QCOMPARE(attachedObject, static_cast<QObject*>(nullptr));
delete object;
}
@@ -181,7 +183,7 @@ void tst_QQuickAccessible::quickAttachedProperties()
"Accessible.role: Accessible.Button\n"
"}", QUrl());
QObject *object = component.create();
- QVERIFY(object != 0);
+ QVERIFY(object != nullptr);
QObject *attachedObject = QQuickAccessibleAttached::attachedProperties(object);
QVERIFY(attachedObject);
@@ -207,7 +209,7 @@ void tst_QQuickAccessible::quickAttachedProperties()
"Accessible.description: \"Duck\"\n"
"}", QUrl());
QObject *object = component.create();
- QVERIFY(object != 0);
+ QVERIFY(object != nullptr);
QObject *attachedObject = QQuickAccessibleAttached::attachedProperties(object);
QVERIFY(attachedObject);
@@ -224,6 +226,72 @@ void tst_QQuickAccessible::quickAttachedProperties()
}
delete object;
}
+
+ // Check overriding of attached role for Text
+ {
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0\nText {\n"
+ "Accessible.role: Accessible.Button\n"
+ "Accessible.name: \"TextButton\"\n"
+ "Accessible.description: \"Text Button\"\n"
+ "}", QUrl());
+ QObject *object = component.create();
+ QVERIFY(object != nullptr);
+
+ QObject *attachedObject = QQuickAccessibleAttached::attachedProperties(object);
+ QVERIFY(attachedObject);
+ if (attachedObject) {
+ QVariant p = attachedObject->property("role");
+ QCOMPARE(p.isNull(), false);
+ QCOMPARE(p.toInt(), int(QAccessible::PushButton));
+ p = attachedObject->property("name");
+ QCOMPARE(p.isNull(), false);
+ QCOMPARE(p.toString(), QLatin1String("TextButton"));
+ p = attachedObject->property("description");
+ QCOMPARE(p.isNull(), false);
+ QCOMPARE(p.toString(), QLatin1String("Text Button"));
+ }
+ delete object;
+ }
+ // Check overriding of attached role for Text
+ {
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0\nListView {\n"
+ "id: list\n"
+ "model: 5\n"
+ "delegate: Text {\n"
+ "objectName: \"acc_text\"\n"
+ "Accessible.role: Accessible.Button\n"
+ "Accessible.name: \"TextButton\"\n"
+ "Accessible.description: \"Text Button\"\n"
+ "}\n"
+ "}", QUrl());
+ QObject *object = component.create();
+ QVERIFY(object != nullptr);
+
+ QQuickListView *listview = qobject_cast<QQuickListView *>(object);
+ QVERIFY(listview != nullptr);
+ QQuickItem *contentItem = listview->contentItem();
+ QQuickText *childItem = QQuickVisualTestUtil::findItem<QQuickText>(contentItem, "acc_text");
+ QVERIFY(childItem != nullptr);
+
+ QObject *attachedObject = QQuickAccessibleAttached::attachedProperties(childItem);
+ QVERIFY(attachedObject);
+ if (attachedObject) {
+ QVariant p = attachedObject->property("role");
+ QCOMPARE(p.isNull(), false);
+ QCOMPARE(p.toInt(), int(QAccessible::PushButton));
+ p = attachedObject->property("name");
+ QCOMPARE(p.isNull(), false);
+ QCOMPARE(p.toString(), QLatin1String("TextButton"));
+ p = attachedObject->property("description");
+ QCOMPARE(p.isNull(), false);
+ QCOMPARE(p.toString(), QLatin1String("Text Button"));
+ }
+ delete object;
+ }
QTestAccessibility::clearEvents();
}
@@ -282,7 +350,7 @@ QAccessibleInterface *topLevelChildAt(QAccessibleInterface *iface, int x, int y)
{
QAccessibleInterface *child = iface->childAt(x, y);
if (!child)
- return 0;
+ return nullptr;
QAccessibleInterface *childOfChild;
while ( ( childOfChild = child->childAt(x, y)) ) {