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/CMakeLists.txt6
-rw-r--r--tests/auto/quick/qquickaccessible/data/hittest.qml2
-rw-r--r--tests/auto/quick/qquickaccessible/data/ignored.qml2
-rw-r--r--tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp80
4 files changed, 86 insertions, 4 deletions
diff --git a/tests/auto/quick/qquickaccessible/CMakeLists.txt b/tests/auto/quick/qquickaccessible/CMakeLists.txt
index ddf890d1dc..517e910f73 100644
--- a/tests/auto/quick/qquickaccessible/CMakeLists.txt
+++ b/tests/auto/quick/qquickaccessible/CMakeLists.txt
@@ -7,6 +7,12 @@
## tst_qquickaccessible Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qquickaccessible LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
# Collect test data
file(GLOB_RECURSE test_data_glob
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
diff --git a/tests/auto/quick/qquickaccessible/data/hittest.qml b/tests/auto/quick/qquickaccessible/data/hittest.qml
index 825f454b2c..09d60d8f07 100644
--- a/tests/auto/quick/qquickaccessible/data/hittest.qml
+++ b/tests/auto/quick/qquickaccessible/data/hittest.qml
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick 2.0
diff --git a/tests/auto/quick/qquickaccessible/data/ignored.qml b/tests/auto/quick/qquickaccessible/data/ignored.qml
index a4218cc627..150a2bd8ef 100644
--- a/tests/auto/quick/qquickaccessible/data/ignored.qml
+++ b/tests/auto/quick/qquickaccessible/data/ignored.qml
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick 2.0
diff --git a/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp b/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp
index e7da38a5ce..d2a9ea9997 100644
--- a/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp
+++ b/tests/auto/quick/qquickaccessible/tst_qquickaccessible.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtTest/QtTest>
@@ -19,6 +19,7 @@
#include <QtQuick/private/qquickaccessibleattached_p.h>
#include <QtQuick/private/qquicklistview_p.h>
#include <QtQuick/private/qquicktext_p.h>
+#include <QtQuick/private/qquicktextinput_p.h>
#include <QtQuickTestUtils/private/qmlutils_p.h>
#include <QtQuickTestUtils/private/visualtestutils_p.h>
@@ -56,10 +57,13 @@ private slots:
void commonTests();
void quickAttachedProperties();
+ void attachedWins();
void basicPropertiesTest();
void hitTest();
void checkableTest();
void ignoredTest();
+ void passwordTest();
+ void announceTest();
};
tst_QQuickAccessible::tst_QQuickAccessible()
@@ -158,7 +162,7 @@ void tst_QQuickAccessible::quickAttachedProperties()
// Attaching to non-item
{
QObject parent;
- QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML QtObject: Accessible must be attached to an Item");
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QML QtObject: Accessible must be attached to an Item or an Action");
QQuickAccessibleAttached *attachedObj = new QQuickAccessibleAttached(&parent);
QCOMPARE(attachedObj->ignored(), false);
@@ -322,6 +326,31 @@ void tst_QQuickAccessible::quickAttachedProperties()
QTestAccessibility::clearEvents();
}
+// Verify that a role can be explicitly set, and that the values from the
+// attached object are used even if the item has a default role - QTBUG-110114
+void tst_QQuickAccessible::attachedWins()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData(R"(
+ import QtQuick
+ import QtQuick.Controls
+ Button {
+ text: "Button"
+ objectName: "button"
+ Accessible.role: Accessible.RadioButton
+ Accessible.description: "Radio Button"
+ })", QUrl());
+ auto button = std::unique_ptr<QObject>(component.create());
+ QVERIFY(button);
+
+ QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(button.get());
+ QVERIFY(iface);
+
+ QCOMPARE(iface->role(), QAccessible::RadioButton);
+ QTestAccessibility::clearEvents();
+}
+
void tst_QQuickAccessible::basicPropertiesTest()
{
@@ -643,6 +672,53 @@ void tst_QQuickAccessible::ignoredTest()
QTestAccessibility::clearEvents();
}
+void tst_QQuickAccessible::passwordTest()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick\nTextInput {\n"
+ "Accessible.role: Accessible.EditableText\n"
+ "Accessible.name: \"Password\"\n"
+ "Accessible.passwordEdit: true\n"
+ "echoMode: TextInput.Password\n"
+ "text: \"Green\"\n"
+ "}", QUrl());
+ auto object = std::unique_ptr<QObject>(component.create());
+ QVERIFY(object != nullptr);
+
+ QQuickTextInput *textInput = qobject_cast<QQuickTextInput *>(object.get());
+ QVERIFY(textInput != nullptr);
+
+ const auto passwordCharacter = textInput->passwordCharacter();
+ const auto passwordLength = textInput->text().length();
+ const auto password = passwordCharacter.repeated(passwordLength);
+
+ QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(object.get());
+ QVERIFY(iface);
+ QCOMPARE(iface->text(QAccessible::Value), password);
+
+ QTestAccessibility::clearEvents();
+}
+
+void tst_QQuickAccessible::announceTest()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick\nItem {\n"
+ "Component.onCompleted: Accessible.announce('I am complete!')"
+ "}",
+ QUrl());
+ auto object = std::unique_ptr<QObject>(component.create());
+ QVERIFY(object != nullptr);
+
+ QAccessibleEvent createdEvent(object.get(), QAccessible::ObjectCreated);
+ QVERIFY_EVENT(&createdEvent);
+ QAccessibleAnnouncementEvent event(object.get(), QStringLiteral("I am complete!"));
+ QVERIFY_EVENT(&event);
+
+ QTestAccessibility::clearEvents();
+}
+
QTEST_MAIN(tst_QQuickAccessible)
#include "tst_qquickaccessible.moc"