aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickaccessible
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2019-11-05 15:49:23 +0100
committerMitch Curtis <mitch.curtis@qt.io>2019-11-06 13:43:50 +0100
commitb802031e2d8b4b38267f1ec2c00507bfd8ed1f5f (patch)
treeee811e7e1cc23dcf9f85219b755ec69eafee011c /tests/auto/quick/qquickaccessible
parent21844350df530a65071e8679d5e047adf553e0f7 (diff)
QQuickAccessibleAttached: keep track of name being explicitly set
This allows types to attach an accessible name to an item, so long as the user hasn't done so themselves. Task-number: QTBUG-66583 Change-Id: I04f26815ffeaf1198fee25dc414253de8b8dfabe Reviewed-by: Liang Qi <liang.qi@qt.io>
Diffstat (limited to 'tests/auto/quick/qquickaccessible')
-rw-r--r--tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp34
1 files changed, 32 insertions, 2 deletions
diff --git a/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp b/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp
index c5fdb6c1b9..2a1b65c392 100644
--- a/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp
+++ b/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp
@@ -185,7 +185,8 @@ void tst_QQuickAccessible::quickAttachedProperties()
QObject *object = component.create();
QVERIFY(object != nullptr);
- QObject *attachedObject = QQuickAccessibleAttached::attachedProperties(object);
+ const auto attachedObject = qobject_cast<QQuickAccessibleAttached*>(
+ QQuickAccessibleAttached::attachedProperties(object));
QVERIFY(attachedObject);
if (attachedObject) {
QVariant p = attachedObject->property("role");
@@ -195,6 +196,7 @@ void tst_QQuickAccessible::quickAttachedProperties()
QCOMPARE(p.isNull(), true);
p = attachedObject->property("description");
QCOMPARE(p.isNull(), true);
+ QCOMPARE(attachedObject->wasNameExplicitlySet(), false);
}
delete object;
}
@@ -211,7 +213,8 @@ void tst_QQuickAccessible::quickAttachedProperties()
QObject *object = component.create();
QVERIFY(object != nullptr);
- QObject *attachedObject = QQuickAccessibleAttached::attachedProperties(object);
+ const auto attachedObject = qobject_cast<QQuickAccessibleAttached*>(
+ QQuickAccessibleAttached::attachedProperties(object));
QVERIFY(attachedObject);
if (attachedObject) {
QVariant p = attachedObject->property("role");
@@ -223,6 +226,7 @@ void tst_QQuickAccessible::quickAttachedProperties()
p = attachedObject->property("description");
QCOMPARE(p.isNull(), false);
QCOMPARE(p.toString(), QLatin1String("Duck"));
+ QCOMPARE(attachedObject->wasNameExplicitlySet(), true);
}
delete object;
}
@@ -292,6 +296,32 @@ void tst_QQuickAccessible::quickAttachedProperties()
}
delete object;
}
+ // Check that a name can be implicitly set.
+ {
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData(R"(
+ import QtQuick 2.0
+ Text {
+ Accessible.role: Accessible.Button
+ Accessible.description: "Text Button"
+ })", QUrl());
+ QScopedPointer<QObject> object(component.create());
+ QVERIFY(object);
+
+ const auto attachedObject = qobject_cast<QQuickAccessibleAttached*>(
+ QQuickAccessibleAttached::attachedProperties(object.data()));
+ QVERIFY(attachedObject);
+ QVERIFY(!attachedObject->wasNameExplicitlySet());
+
+ attachedObject->setNameImplicitly(QLatin1String("Implicit"));
+ QCOMPARE(attachedObject->name(), QLatin1String("Implicit"));
+ QVERIFY(!attachedObject->wasNameExplicitlySet());
+
+ attachedObject->setName(QLatin1String("Explicit"));
+ QCOMPARE(attachedObject->name(), QLatin1String("Explicit"));
+ QVERIFY(attachedObject->wasNameExplicitlySet());
+ }
QTestAccessibility::clearEvents();
}