aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickaccessible
diff options
context:
space:
mode:
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();
}