diff options
author | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-11-14 09:50:23 +0100 |
---|---|---|
committer | Qt Forward Merge Bot <qt_forward_merge_bot@qt-project.org> | 2019-11-14 09:50:24 +0100 |
commit | 1619b7d207f7a84810e4790766ac33a3ac9aaa1a (patch) | |
tree | add23ef6ddf9f28157e65db17b04a81f9b22e87e /tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp | |
parent | 554309a1c1127b4a614cdba4f9ece46fc85df7e1 (diff) | |
parent | c89f7a221b7c31a0a4e1b0eed2e91d7633f4eab2 (diff) |
Merge remote-tracking branch 'origin/5.13' into 5.14
Change-Id: I06578422b4558feabf7a77426b01e77953ab60e2
Diffstat (limited to 'tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp')
-rw-r--r-- | tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp | 34 |
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 d1f6d67aa1..061d5f8a1a 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(); } |