summaryrefslogtreecommitdiffstats
path: root/tests/auto/other
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/other')
-rw-r--r--tests/auto/other/CMakeLists.txt18
-rw-r--r--tests/auto/other/android/CMakeLists.txt24
-rw-r--r--tests/auto/other/android/testdata/assets/test.txt1
-rw-r--r--tests/auto/other/android/tst_android.cpp57
-rw-r--r--tests/auto/other/android_deployment_settings/CMakeLists.txt85
-rw-r--r--tests/auto/other/android_deployment_settings/noop.cpp7
-rw-r--r--tests/auto/other/android_deployment_settings/tst_android_deployment_settings.cpp112
-rw-r--r--tests/auto/other/gestures/BLACKLIST50
-rw-r--r--tests/auto/other/gestures/CMakeLists.txt10
-rw-r--r--tests/auto/other/gestures/tst_gestures.cpp218
-rw-r--r--tests/auto/other/languagechange/CMakeLists.txt16
-rw-r--r--tests/auto/other/languagechange/tst_languagechange.cpp2
-rw-r--r--tests/auto/other/macgui/BLACKLIST3
-rw-r--r--tests/auto/other/macgui/CMakeLists.txt15
-rw-r--r--tests/auto/other/macgui/guitest.cpp3
-rw-r--r--tests/auto/other/macgui/guitest.h2
-rw-r--r--tests/auto/other/macgui/tst_macgui.cpp63
-rw-r--r--tests/auto/other/macnativeevents/CMakeLists.txt13
-rw-r--r--tests/auto/other/macnativeevents/expectedeventlist.cpp2
-rw-r--r--tests/auto/other/macnativeevents/expectedeventlist.h2
-rw-r--r--tests/auto/other/macnativeevents/nativeeventlist.cpp2
-rw-r--r--tests/auto/other/macnativeevents/nativeeventlist.h2
-rw-r--r--tests/auto/other/macnativeevents/qnativeevents.cpp2
-rw-r--r--tests/auto/other/macnativeevents/qnativeevents.h2
-rw-r--r--tests/auto/other/macnativeevents/qnativeevents_mac.cpp2
-rw-r--r--tests/auto/other/macnativeevents/tst_macnativeevents.cpp2
-rw-r--r--tests/auto/other/macplist/CMakeLists.txt10
-rw-r--r--tests/auto/other/macplist/app/CMakeLists.txt6
-rw-r--r--tests/auto/other/macplist/app/main.cpp2
-rw-r--r--tests/auto/other/macplist/test/CMakeLists.txt4
-rw-r--r--tests/auto/other/macplist/tst_macplist.cpp2
-rw-r--r--tests/auto/other/networkselftest/BLACKLIST1
-rw-r--r--tests/auto/other/networkselftest/CMakeLists.txt15
-rw-r--r--tests/auto/other/networkselftest/tst_networkselftest.cpp21
-rw-r--r--tests/auto/other/qabstractitemmodelutils/dynamictreemodel.cpp14
-rw-r--r--tests/auto/other/qabstractitemmodelutils/dynamictreemodel.h2
-rw-r--r--tests/auto/other/qaccessibility/CMakeLists.txt11
-rw-r--r--tests/auto/other/qaccessibility/accessiblewidgets.h4
-rw-r--r--tests/auto/other/qaccessibility/tst_qaccessibility.cpp433
-rw-r--r--tests/auto/other/qaccessibilitylinux/CMakeLists.txt13
-rw-r--r--tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp15
-rw-r--r--tests/auto/other/qaccessibilitymac/CMakeLists.txt27
-rw-r--r--tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac.cpp125
-rw-r--r--tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac.mm (renamed from tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac_helpers.mm)461
-rw-r--r--tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac_helpers.h16
-rw-r--r--tests/auto/other/qcomplextext/CMakeLists.txt10
-rw-r--r--tests/auto/other/qcomplextext/bidireorderstring.h2
-rw-r--r--tests/auto/other/qcomplextext/tst_qcomplextext.cpp18
-rw-r--r--tests/auto/other/qfocusevent/CMakeLists.txt11
-rw-r--r--tests/auto/other/qfocusevent/tst_qfocusevent.cpp12
-rw-r--r--tests/auto/other/qnetworkaccessmanager_and_qprogressdialog/CMakeLists.txt10
-rw-r--r--tests/auto/other/qnetworkaccessmanager_and_qprogressdialog/tst_qnetworkaccessmanager_and_qprogressdialog.cpp2
-rw-r--r--tests/auto/other/qobjectrace/CMakeLists.txt10
-rw-r--r--tests/auto/other/qobjectrace/tst_qobjectrace.cpp9
-rw-r--r--tests/auto/other/qprocess_and_guieventloop/CMakeLists.txt11
-rw-r--r--tests/auto/other/qprocess_and_guieventloop/tst_qprocess_and_guieventloop.cpp8
-rw-r--r--tests/auto/other/qprocess_and_guieventloop/write-read-write/CMakeLists.txt8
-rw-r--r--tests/auto/other/qprocess_and_guieventloop/write-read-write/main.cpp2
-rw-r--r--tests/auto/other/qsharedpointer_and_qwidget/CMakeLists.txt10
-rw-r--r--tests/auto/other/qsharedpointer_and_qwidget/tst_qsharedpointer_and_qwidget.cpp2
-rw-r--r--tests/auto/other/qvariant_common/tst_qvariant_common.h2
-rw-r--r--tests/auto/other/sessionmanagement_macos/tst_sessionmanagement_macos.mm2
-rw-r--r--tests/auto/other/toolsupport/CMakeLists.txt10
-rw-r--r--tests/auto/other/toolsupport/tst_toolsupport.cpp7
-rw-r--r--tests/auto/other/xkbkeyboard/CMakeLists.txt10
-rw-r--r--tests/auto/other/xkbkeyboard/tst_xkbkeyboard.cpp2
66 files changed, 1312 insertions, 743 deletions
diff --git a/tests/auto/other/CMakeLists.txt b/tests/auto/other/CMakeLists.txt
index 029075498c..16f96cd5f4 100644
--- a/tests/auto/other/CMakeLists.txt
+++ b/tests/auto/other/CMakeLists.txt
@@ -1,17 +1,15 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-
-# Generated from other.pro.
+# SPDX-License-Identifier: BSD-3-Clause
if(NOT CMAKE_CROSSCOMPILING)
- # add_subdirectory(atwrapper) <- does not exist # special case
+ # add_subdirectory(atwrapper) <- does not exist
endif()
if(TARGET Qt::Widgets)
add_subdirectory(gestures)
add_subdirectory(languagechange)
add_subdirectory(qfocusevent)
add_subdirectory(qsharedpointer_and_qwidget)
- # add_subdirectory(windowsmobile) <- does not exist # special case
+ # add_subdirectory(windowsmobile) <- does not exist
endif()
if(TARGET Qt::Network AND TARGET Qt::Widgets)
add_subdirectory(qnetworkaccessmanager_and_qprogressdialog)
@@ -32,15 +30,15 @@ if(TARGET Qt::Gui)
endif()
add_subdirectory(qobjectrace)
add_subdirectory(toolsupport)
-# QTBUG-87670 # special case
+# QTBUG-87670
if(QT_FEATURE_process AND TARGET Qt::Gui AND NOT ANDROID)
add_subdirectory(qprocess_and_guieventloop)
endif()
if(QT_FEATURE_accessibility_atspi_bridge AND TARGET Qt::Gui AND TARGET Qt::Widgets)
- #add_subdirectory(qaccessibilitylinux) # special case # This test is broken
+ #add_subdirectory(qaccessibilitylinux) # TODO: This test is broken
endif()
if(MACOS AND TARGET Qt::Gui)
- # add_subdirectory(macnativeevents) # special case it's disabled in qmake too
+ # add_subdirectory(macnativeevents) # TODO: it's disabled in qmake too
endif()
if(embedded)
add_subdirectory(qdirectpainter)
@@ -48,3 +46,7 @@ endif()
if(QT_FEATURE_xkbcommon AND TARGET Qt::Gui)
add_subdirectory(xkbkeyboard)
endif()
+
+if(ANDROID AND QT_BUILD_STANDALONE_TESTS)
+ add_subdirectory(android_deployment_settings)
+endif()
diff --git a/tests/auto/other/android/CMakeLists.txt b/tests/auto/other/android/CMakeLists.txt
deleted file mode 100644
index 19c5dd69d0..0000000000
--- a/tests/auto/other/android/CMakeLists.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-
-# Generated from android.pro.
-
-#####################################################################
-## tst_android Test:
-#####################################################################
-
-qt_internal_add_test(tst_android
- SOURCES
- tst_android.cpp
-)
-
-if(ANDROID)
- set_property(TARGET tst_android APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
- ${CMAKE_CURRENT_SOURCE_DIR}/testdata
- )
- # QTBUG-88840 # special case
- qt_android_generate_deployment_settings(tst_android) # special case
-endif()
-
-#### Keys ignored in scope 1:.:.:android.pro:<TRUE>:
-# DISTFILES = "testdata/assets/test.txt"
diff --git a/tests/auto/other/android/testdata/assets/test.txt b/tests/auto/other/android/testdata/assets/test.txt
deleted file mode 100644
index 61e2c47c25..0000000000
--- a/tests/auto/other/android/testdata/assets/test.txt
+++ /dev/null
@@ -1 +0,0 @@
-FooBar \ No newline at end of file
diff --git a/tests/auto/other/android/tst_android.cpp b/tests/auto/other/android/tst_android.cpp
deleted file mode 100644
index 938ff3c9b2..0000000000
--- a/tests/auto/other/android/tst_android.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-
-#include <jni.h>
-
-#include <QTest>
-#include <QtCore/qnativeinterface.h>
-#include <QtCore/qjniobject.h>
-
-class tst_Android : public QObject
-{
-Q_OBJECT
-private slots:
- void assetsRead();
- void assetsNotWritable();
- void testAndroidSdkVersion();
- void testAndroidActivity();
-};
-
-void tst_Android::assetsRead()
-{
- {
- QFile file(QStringLiteral("assets:/test.txt"));
- QVERIFY(file.open(QIODevice::ReadOnly));
- QCOMPARE(file.readAll(), QByteArray("FooBar"));
- }
-
- {
- QFile file(QStringLiteral("assets:/test.txt"));
- QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text));
- QCOMPARE(file.readAll(), QByteArray("FooBar"));
- }
-}
-
-void tst_Android::assetsNotWritable()
-{
- QFile file(QStringLiteral("assets:/test.txt"));
- QVERIFY(!file.open(QIODevice::WriteOnly));
- QVERIFY(!file.open(QIODevice::ReadWrite));
- QVERIFY(!file.open(QIODevice::Append));
-}
-
-void tst_Android::testAndroidSdkVersion()
-{
- QVERIFY(QNativeInterface::QAndroidApplication::sdkVersion() > 0);
-}
-
-void tst_Android::testAndroidActivity()
-{
- QJniObject activity = QNativeInterface::QAndroidApplication::context();
- QVERIFY(activity.isValid());
- QVERIFY(activity.callMethod<jboolean>("isTaskRoot"));
-}
-
-QTEST_MAIN(tst_Android)
-#include "tst_android.moc"
-
diff --git a/tests/auto/other/android_deployment_settings/CMakeLists.txt b/tests/auto/other/android_deployment_settings/CMakeLists.txt
new file mode 100644
index 0000000000..f2ba135328
--- /dev/null
+++ b/tests/auto/other/android_deployment_settings/CMakeLists.txt
@@ -0,0 +1,85 @@
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_android_deployment_settings LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
+function(tst_generate_android_deployment_setting target)
+ # Qt build always use new property format that supports generator expressions. In this test we
+ # want to test user scenario so disable all Qt specific options to make sure that
+ # qt6_android_generate_deployment_settings behave like in user projects.
+ set(QT_BUILD_STANDALONE_TESTS FALSE)
+ set(QT_BUILDING_QT FALSE)
+ set(QT_INTERNAL_IS_STANDALONE_TEST FALSE)
+
+ qt6_android_generate_deployment_settings(${target})
+endfunction()
+
+qt6_policy(SET QTP0002 NEW)
+
+set(target tst_android_deployment_settings_new)
+qt6_add_executable(${target} MANUAL_FINALIZATION EXCLUDE_FROM_ALL noop.cpp)
+set_target_properties(${target} PROPERTIES
+ my_package_source_dir "path/to/source/dir"
+ my_libs_property "some/path/to/lib2.so;some/path/to/lib3.so"
+ my_plugins_property "some/path/to/plugin2.so;some/path/to/plugin3.so"
+
+ QT_ANDROID_SDK_BUILD_TOOLS_REVISION "23.0.2"
+ QT_ANDROID_MIN_SDK_VERSION "1"
+ QT_ANDROID_TARGET_SDK_VERSION "2"
+ QT_ANDROID_DEPLOYMENT_DEPENDENCIES "dep1.so;dep2.so;dep3.so"
+ QT_ANDROID_DEPLOYMENT_SETTINGS_FILE "attempt_to_rewrite.json"
+ QT_ANDROID_EXTRA_LIBS
+ "some/path/to/lib1.so;$<TARGET_PROPERTY:${target},my_libs_property>;some/path/to/lib4.so"
+ QT_ANDROID_EXTRA_PLUGINS
+ "some/path/to/plugin1.so;$<TARGET_PROPERTY:${target},my_plugins_property>"
+ QT_ANDROID_PACKAGE_SOURCE_DIR "$<TARGET_PROPERTY:${target},my_package_source_dir>"
+ QT_ANDROID_SYSTEM_LIBS_PREFIX "myLibPrefix"
+
+ # Make sure that this property is overwritten by
+ # qt6_android_generate_deployment_settings
+ QT_ANDROID_DEPLOYMENT_SETTINGS_FILE "custom_deployment_settings.json"
+)
+tst_generate_android_deployment_setting(${target})
+
+qt6_policy(SET QTP0002 OLD)
+
+set(target tst_android_deployment_settings_old)
+qt6_add_executable(${target} MANUAL_FINALIZATION EXCLUDE_FROM_ALL noop.cpp)
+set_target_properties(${target} PROPERTIES
+ QT_ANDROID_SDK_BUILD_TOOLS_REVISION "23.0.2"
+ QT_ANDROID_MIN_SDK_VERSION "1"
+ QT_ANDROID_TARGET_SDK_VERSION "2"
+ QT_ANDROID_DEPLOYMENT_DEPENDENCIES "dep1.so;dep2.so;dep3.so"
+ QT_ANDROID_EXTRA_LIBS
+ "some/path/to/lib1.so;some/path\\to/lib2.so;some\\path\\to\\lib3.so;some/path/to/lib4.so"
+ QT_ANDROID_EXTRA_PLUGINS
+ "some\\path\\to\\plugin1.so;some/path\\to/plugin2.so;some/path/to/plugin3.so"
+ QT_ANDROID_PACKAGE_SOURCE_DIR "path\\to/source\\dir"
+ QT_ANDROID_SYSTEM_LIBS_PREFIX "myLibPrefix"
+)
+tst_generate_android_deployment_setting(${target})
+
+get_target_property(new_settings
+ tst_android_deployment_settings_new QT_ANDROID_DEPLOYMENT_SETTINGS_FILE)
+get_target_property(old_settings
+ tst_android_deployment_settings_old QT_ANDROID_DEPLOYMENT_SETTINGS_FILE)
+set_source_files_properties("${new_settings}" PROPERTIES QT_RESOURCE_ALIAS "new_settings.json")
+set_source_files_properties("${old_settings}" PROPERTIES QT_RESOURCE_ALIAS "old_settings.json")
+qt_internal_add_test(tst_android_deployment_settings
+ SOURCES
+ tst_android_deployment_settings.cpp
+ DEFINES
+ DEFAULT_ABI="${CMAKE_ANDROID_ARCH_ABI}"
+)
+qt6_add_resources(tst_android_deployment_settings
+ "deployment_settings_res"
+ PREFIX
+ "/"
+ FILES
+ "${new_settings}"
+ "${old_settings}"
+)
diff --git a/tests/auto/other/android_deployment_settings/noop.cpp b/tests/auto/other/android_deployment_settings/noop.cpp
new file mode 100644
index 0000000000..6f2ee31826
--- /dev/null
+++ b/tests/auto/other/android_deployment_settings/noop.cpp
@@ -0,0 +1,7 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+int main(int, char *[])
+{
+ return 0;
+}
diff --git a/tests/auto/other/android_deployment_settings/tst_android_deployment_settings.cpp b/tests/auto/other/android_deployment_settings/tst_android_deployment_settings.cpp
new file mode 100644
index 0000000000..d68d08b58e
--- /dev/null
+++ b/tests/auto/other/android_deployment_settings/tst_android_deployment_settings.cpp
@@ -0,0 +1,112 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QJsonDocument>
+#include <QJsonObject>
+#include <QFile>
+#include <QTest>
+#include <QLibraryInfo>
+#include <QDir>
+
+class tst_android_deployment_settings : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void initTestCase_data();
+ void init();
+
+ void DeploymentSettings_data();
+ void DeploymentSettings();
+
+ void QtPaths_data();
+ void QtPaths();
+
+private:
+ static QString makePath(QLibraryInfo::LibraryLocation loc);
+ QJsonDocument jsonDoc;
+};
+
+QString tst_android_deployment_settings::makePath(QLibraryInfo::LibraryLocation loc)
+{
+ const auto prefix = QLibraryInfo::path(QLibraryInfo::PrefixPath);
+ auto path = QLibraryInfo::path(loc);
+ path.remove(0, prefix.size() + 1);
+ if (path.isEmpty()) // Assume that if path is empty it's '.'
+ path = ".";
+ return path;
+}
+
+void tst_android_deployment_settings::initTestCase_data()
+{
+ QTest::addColumn<QString>("file");
+ QTest::newRow("old") << ":/old_settings.json";
+ QTest::newRow("new") << ":/new_settings.json";
+}
+
+void tst_android_deployment_settings::init()
+{
+ QFETCH_GLOBAL(QString, file);
+ QFile settings(file);
+ QVERIFY(settings.open(QIODeviceBase::ReadOnly));
+ jsonDoc = QJsonDocument::fromJson(settings.readAll());
+ QVERIFY(!jsonDoc.isNull());
+}
+
+void tst_android_deployment_settings::DeploymentSettings_data()
+{
+ QTest::addColumn<QString>("key");
+ QTest::addColumn<QString>("value");
+
+ QTest::newRow("sdkBuildToolsRevision") << "sdkBuildToolsRevision"
+ << "23.0.2";
+ QTest::newRow("deployment-dependencies") << "deployment-dependencies"
+ << "dep1.so,dep2.so,dep3.so";
+ QTest::newRow("android-extra-plugins")
+ << "android-extra-plugins"
+ << "some/path/to/plugin1.so,some/path/to/plugin2.so,some/path/to/plugin3.so";
+ QTest::newRow("android-extra-libs") << "android-extra-libs"
+ << "some/path/to/lib1.so,some/path/to/lib2.so,some/path/to/"
+ "lib3.so,some/path/to/lib4.so";
+ QTest::newRow("android-system-libs-prefix") << "android-system-libs-prefix"
+ << "myLibPrefix";
+ QTest::newRow("android-package-source-directory") << "android-package-source-directory"
+ << "path/to/source/dir";
+ QTest::newRow("android-min-sdk-version") << "android-min-sdk-version"
+ << "1";
+ QTest::newRow("android-target-sdk-version") << "android-target-sdk-version"
+ << "2";
+}
+
+void tst_android_deployment_settings::DeploymentSettings()
+{
+ QFETCH(QString, key);
+ QFETCH(QString, value);
+ QCOMPARE(jsonDoc[key].toString(), value);
+}
+
+void tst_android_deployment_settings::QtPaths_data()
+{
+ QTest::addColumn<QString>("key");
+ QTest::addColumn<QString>("value");
+
+ QTest::newRow("qtDataDirectory") << "qtDataDirectory" << makePath(QLibraryInfo::DataPath);
+ QTest::newRow("qtLibExecsDirectory")
+ << "qtLibExecsDirectory" << makePath(QLibraryInfo::LibraryExecutablesPath);
+ QTest::newRow("qtLibsDirectory") << "qtLibsDirectory" << makePath(QLibraryInfo::LibrariesPath);
+ QTest::newRow("qtPluginsDirectory")
+ << "qtPluginsDirectory" << makePath(QLibraryInfo::PluginsPath);
+ QTest::newRow("qtQmlDirectory") << "qtQmlDirectory" << makePath(QLibraryInfo::QmlImportsPath);
+}
+
+void tst_android_deployment_settings::QtPaths()
+{
+ QFETCH(QString, key);
+ QFETCH(QString, value);
+ QCOMPARE(QDir::cleanPath(jsonDoc[key].toObject()[DEFAULT_ABI].toString()),
+ QDir::cleanPath(value));
+}
+
+QTEST_MAIN(tst_android_deployment_settings)
+
+#include "tst_android_deployment_settings.moc"
diff --git a/tests/auto/other/gestures/BLACKLIST b/tests/auto/other/gestures/BLACKLIST
index ec8ebd82d2..8e96992e4d 100644
--- a/tests/auto/other/gestures/BLACKLIST
+++ b/tests/auto/other/gestures/BLACKLIST
@@ -1,50 +1,4 @@
-[autoCancelGestures2]
-rhel
-centos
-ubuntu-18.04
-ubuntu-20.04
-[explicitGraphicsObjectTarget]
-rhel
-centos
-ubuntu-18.04
-ubuntu-20.04
-[graphicsItemGesture]
-rhel
-centos
-ubuntu-18.04
-ubuntu-20.04
-[graphicsView]
-rhel
-centos
-ubuntu-18.04
-ubuntu-20.04
-[graphicsViewParentPropagation]
-rhel
-centos
-ubuntu-18.04
-ubuntu-20.04
[panelPropagation]
-rhel
-centos
-ubuntu-18.04
-ubuntu-20.04
+ubuntu-22.04 ci
[panelStacksBehindParent]
-rhel
-centos
-ubuntu-18.04
-ubuntu-20.04
-[partialGesturePropagation]
-rhel
-centos
-ubuntu-18.04
-ubuntu-20.04
-[testReuseCanceledGestures]
-rhel
-centos
-ubuntu-18.04
-ubuntu-20.04
-[conflictingGesturesInGraphicsView]
-ubuntu-20.04
-[graphicsItemTreeGesture]
-ubuntu-18.04
-ubuntu-20.04
+ubuntu-22.04 ci
diff --git a/tests/auto/other/gestures/CMakeLists.txt b/tests/auto/other/gestures/CMakeLists.txt
index 38af09eaed..815846305a 100644
--- a/tests/auto/other/gestures/CMakeLists.txt
+++ b/tests/auto/other/gestures/CMakeLists.txt
@@ -1,12 +1,16 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-
-# Generated from gestures.pro.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_gestures Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_gestures LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_gestures
SOURCES
tst_gestures.cpp
diff --git a/tests/auto/other/gestures/tst_gestures.cpp b/tests/auto/other/gestures/tst_gestures.cpp
index 88ae2661a5..a413268321 100644
--- a/tests/auto/other/gestures/tst_gestures.cpp
+++ b/tests/auto/other/gestures/tst_gestures.cpp
@@ -1,6 +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 <QTest>
#include <QtTest/qtesttouch.h>
@@ -209,7 +208,7 @@ protected:
QGestureEvent *e = static_cast<QGestureEvent*>(event);
++gestureEventsReceived;
eventsPtr = &events;
- foreach(Qt::GestureType type, ignoredGestures)
+ for (Qt::GestureType type : std::as_const(ignoredGestures))
e->ignore(e->gesture(type));
} else if (event->type() == QEvent::GestureOverride) {
++gestureOverrideEventsReceived;
@@ -219,8 +218,8 @@ protected:
}
if (eventsPtr) {
QGestureEvent *e = static_cast<QGestureEvent*>(event);
- QList<QGesture*> gestures = e->gestures();
- foreach(QGesture *g, gestures) {
+ const QList<QGesture*> gestures = e->gestures();
+ for (QGesture *g : gestures) {
eventsPtr->all << g->gestureType();
switch(g->state()) {
case Qt::GestureStarted:
@@ -282,6 +281,10 @@ Q_OBJECT
private slots:
void initTestCase();
void cleanupTestCase();
+
+ void init();
+ void cleanup();
+
void customGesture();
void autoCancelingGestures();
void gestureOverChild();
@@ -318,22 +321,45 @@ private slots:
void testQGestureRecognizerCleanup();
void testReuseCanceledGestures();
void bug_13501_gesture_not_accepted();
+private:
+ QPoint m_availableTopLeft;
};
void tst_Gestures::initTestCase()
{
+ const QScreen *screen = QGuiApplication::primaryScreen();
+ m_availableTopLeft = screen->availableGeometry().topLeft();
+}
+
+void tst_Gestures::cleanupTestCase()
+{
+}
+
+void tst_Gestures::init()
+{
CustomGesture::GestureType = QGestureRecognizer::registerRecognizer(new CustomGestureRecognizer);
QVERIFY(CustomGesture::GestureType != Qt::GestureType(0));
QVERIFY(CustomGesture::GestureType != Qt::CustomGesture);
}
-void tst_Gestures::cleanupTestCase()
+void tst_Gestures::cleanup()
{
QGestureRecognizer::unregisterRecognizer(CustomGesture::GestureType);
}
+static QtMessageHandler originalMessageHandler = nullptr;
+static bool skipCustomGesture = false;
+static void messageHandler(QtMsgType type, const QMessageLogContext &context, const QString &text)
+{
+ if (type == QtMsgType::QtWarningMsg && text == "QGestureManager::deliverEvent: could not find the target for gesture")
+ skipCustomGesture = true;
+ originalMessageHandler(type, context, text);
+}
+
void tst_Gestures::customGesture()
{
+ originalMessageHandler = qInstallMessageHandler(messageHandler);
+ auto guard = qScopeGuard([](){ qInstallMessageHandler(originalMessageHandler); });
GestureWidget widget;
widget.grabGesture(CustomGesture::GestureType, Qt::DontStartGestureOnChildren);
widget.show();
@@ -343,10 +369,12 @@ void tst_Gestures::customGesture()
event.hotSpot = widget.mapToGlobal(QPoint(5,5));
event.hasHotSpot = true;
sendCustomGesture(&event, &widget);
+ if (skipCustomGesture)
+ QSKIP("QApplication unable to access test widget.");
static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1;
static const int TotalCustomEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialMaybeThreshold + 1;
- QCOMPARE(widget.customEventsReceived, TotalCustomEventsCount);
+ QTRY_COMPARE(widget.customEventsReceived, TotalCustomEventsCount);
QCOMPARE(widget.gestureEventsReceived, TotalGestureEventsCount);
QCOMPARE(widget.gestureOverrideEventsReceived, 0);
QCOMPARE(widget.events.all.size(), TotalGestureEventsCount);
@@ -406,7 +434,7 @@ void tst_Gestures::gestureOverChild()
static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1;
static const int TotalCustomEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialMaybeThreshold + 1;
- QCOMPARE(child->customEventsReceived, TotalCustomEventsCount);
+ QTRY_COMPARE(child->customEventsReceived, TotalCustomEventsCount);
QCOMPARE(widget.customEventsReceived, 0);
QCOMPARE(child->gestureEventsReceived, 0);
QCOMPARE(child->gestureOverrideEventsReceived, 0);
@@ -421,7 +449,7 @@ void tst_Gestures::gestureOverChild()
sendCustomGesture(&event, child);
- QCOMPARE(child->customEventsReceived, TotalCustomEventsCount);
+ QTRY_COMPARE(child->customEventsReceived, TotalCustomEventsCount);
QCOMPARE(widget.customEventsReceived, 0);
QCOMPARE(child->gestureEventsReceived, 0);
@@ -453,7 +481,7 @@ void tst_Gestures::multipleWidgetOnlyGestureInTree()
CustomEvent event;
sendCustomGesture(&event, child);
- QCOMPARE(child->customEventsReceived, TotalCustomEventsCount);
+ QTRY_COMPARE(child->customEventsReceived, TotalCustomEventsCount);
QCOMPARE(parent.customEventsReceived, 0);
QCOMPARE(child->gestureEventsReceived, TotalGestureEventsCount);
QCOMPARE(child->gestureOverrideEventsReceived, 0);
@@ -466,8 +494,8 @@ void tst_Gestures::multipleWidgetOnlyGestureInTree()
// same for the parent widget
sendCustomGesture(&event, &parent);
- QCOMPARE(child->customEventsReceived, 0);
QCOMPARE(parent.customEventsReceived, TotalCustomEventsCount);
+ QCOMPARE(child->customEventsReceived, 0);
QCOMPARE(child->gestureEventsReceived, 0);
QCOMPARE(child->gestureOverrideEventsReceived, 0);
QCOMPARE(parent.gestureEventsReceived, TotalGestureEventsCount);
@@ -494,7 +522,7 @@ void tst_Gestures::conflictingGestures()
CustomEvent event;
sendCustomGesture(&event, child);
- QCOMPARE(child->gestureOverrideEventsReceived, 1);
+ QTRY_COMPARE(child->gestureOverrideEventsReceived, 1);
QCOMPARE(child->gestureEventsReceived, TotalGestureEventsCount);
QCOMPARE(parent.gestureOverrideEventsReceived, 0);
QCOMPARE(parent.gestureEventsReceived, 0);
@@ -562,8 +590,8 @@ void tst_Gestures::conflictingGestures()
// sending events to the child and making sure there is no conflict
sendCustomGesture(&event, child);
+ QTRY_COMPARE(child->gestureEventsReceived, TotalGestureEventsCount);
QCOMPARE(child->gestureOverrideEventsReceived, 1);
- QCOMPARE(child->gestureEventsReceived, TotalGestureEventsCount);
QCOMPARE(parent.gestureOverrideEventsReceived, 1);
QCOMPARE(parent.gestureEventsReceived, TotalGestureEventsCount);
@@ -571,6 +599,9 @@ void tst_Gestures::conflictingGestures()
child->reset();
Qt::GestureType ContinuousGesture = QGestureRecognizer::registerRecognizer(new CustomContinuousGestureRecognizer);
+ auto unregisterRecognizer = qScopeGuard([ContinuousGesture]{
+ QGestureRecognizer::unregisterRecognizer(ContinuousGesture);
+ });
static const int ContinuousGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialMaybeThreshold + 1;
child->grabGesture(ContinuousGesture);
// child accepts override. And it also receives another custom gesture.
@@ -578,13 +609,11 @@ void tst_Gestures::conflictingGestures()
child->acceptGestureOverride = true;
sendCustomGesture(&event, child);
+ QTRY_VERIFY(child->gestureEventsReceived > TotalGestureEventsCount);
QCOMPARE(child->gestureOverrideEventsReceived, 1);
- QVERIFY(child->gestureEventsReceived > TotalGestureEventsCount);
- QCOMPARE(child->events.all.count(), TotalGestureEventsCount + ContinuousGestureEventsCount);
+ QCOMPARE(child->events.all.size(), TotalGestureEventsCount + ContinuousGestureEventsCount);
QCOMPARE(parent.gestureOverrideEventsReceived, 0);
QCOMPARE(parent.gestureEventsReceived, 0);
-
- QGestureRecognizer::unregisterRecognizer(ContinuousGesture);
}
void tst_Gestures::finishedWithoutStarted()
@@ -597,7 +626,7 @@ void tst_Gestures::finishedWithoutStarted()
ev.serial = CustomGesture::SerialFinishedThreshold;
QApplication::sendEvent(&widget, &ev);
- QCOMPARE(widget.customEventsReceived, 1);
+ QTRY_COMPARE(widget.customEventsReceived, 1);
QCOMPARE(widget.gestureEventsReceived, 2);
QCOMPARE(widget.gestureOverrideEventsReceived, 0);
QCOMPARE(widget.events.all.size(), 2);
@@ -619,7 +648,7 @@ void tst_Gestures::unknownGesture()
static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1;
- QCOMPARE(widget.gestureEventsReceived, TotalGestureEventsCount);
+ QTRY_COMPARE(widget.gestureEventsReceived, TotalGestureEventsCount);
}
static const QColor InstanceColors[] = {
@@ -713,9 +742,10 @@ public:
++gestureEventsReceived;
eventsPtr = &events;
QGestureEvent *e = static_cast<QGestureEvent *>(event);
- foreach(Qt::GestureType type, ignoredGestures)
+ for (Qt::GestureType type : std::as_const(ignoredGestures))
e->ignore(e->gesture(type));
- foreach(QGesture *g, e->gestures()) {
+ const auto gestures = e->gestures();
+ for (QGesture *g : gestures) {
switch (g->state()) {
case Qt::GestureStarted:
if (ignoredStartedGestures.contains(g->gestureType()))
@@ -741,8 +771,8 @@ public:
}
if (eventsPtr) {
QGestureEvent *e = static_cast<QGestureEvent*>(event);
- QList<QGesture*> gestures = e->gestures();
- foreach(QGesture *g, gestures) {
+ const QList<QGesture*> gestures = e->gestures();
+ for (QGesture *g : gestures) {
eventsPtr->all << g->gestureType();
switch(g->state()) {
case Qt::GestureStarted:
@@ -800,6 +830,7 @@ void tst_Gestures::graphicsItemGesture()
QGraphicsScene scene;
QGraphicsView view(&scene);
view.setWindowFlags(Qt::X11BypassWindowManagerHint);
+ view.move(m_availableTopLeft);
GestureItem *item = new GestureItem("item");
scene.addItem(item);
@@ -822,7 +853,7 @@ void tst_Gestures::graphicsItemGesture()
QTest::ignoreMessage(QtWarningMsg, "QGestureManager::deliverEvent: could not find the target for gesture");
sendCustomGesture(&event, item, &scene);
- QCOMPARE(item->customEventsReceived, TotalCustomEventsCount);
+ QTRY_COMPARE(item->customEventsReceived, TotalCustomEventsCount);
QCOMPARE(item->gestureEventsReceived, 0);
QCOMPARE(item->gestureOverrideEventsReceived, 0);
@@ -862,6 +893,7 @@ void tst_Gestures::graphicsView()
QGraphicsScene scene;
QGraphicsView view(&scene);
view.setWindowFlags(Qt::X11BypassWindowManagerHint);
+ view.move(m_availableTopLeft);
GestureItem *item = new GestureItem("item");
scene.addItem(item);
@@ -882,7 +914,7 @@ void tst_Gestures::graphicsView()
event.hasHotSpot = true;
sendCustomGesture(&event, item, &scene);
- QCOMPARE(item->customEventsReceived, TotalCustomEventsCount);
+ QTRY_COMPARE(item->customEventsReceived, TotalCustomEventsCount);
QCOMPARE(item->gestureEventsReceived, TotalGestureEventsCount);
QCOMPARE(item->gestureOverrideEventsReceived, 0);
@@ -917,8 +949,8 @@ void tst_Gestures::graphicsView()
item->grabGesture(CustomGesture::GestureType);
sendCustomGesture(&event, item, &newScene);
+ QTRY_COMPARE(item->gestureEventsReceived, TotalGestureEventsCount);
QCOMPARE(item->customEventsReceived, TotalCustomEventsCount);
- QCOMPARE(item->gestureEventsReceived, TotalGestureEventsCount);
QCOMPARE(item->gestureOverrideEventsReceived, 0);
}
@@ -927,6 +959,7 @@ void tst_Gestures::graphicsItemTreeGesture()
QGraphicsScene scene;
QGraphicsView view(&scene);
view.setWindowFlags(Qt::X11BypassWindowManagerHint);
+ view.move(m_availableTopLeft);
GestureItem *item1 = new GestureItem("item1");
item1->setPos(100, 100);
@@ -957,12 +990,12 @@ void tst_Gestures::graphicsItemTreeGesture()
item1->ignoredGestures << CustomGesture::GestureType;
sendCustomGesture(&event, item1_child1, &scene);
+ QTRY_COMPARE(item1->gestureEventsReceived, TotalGestureEventsCount);
QCOMPARE(item1_child1->gestureOverrideEventsReceived, 0);
QCOMPARE(item1_child1->gestureEventsReceived, 0);
QCOMPARE(item1_child2->gestureEventsReceived, 0);
QCOMPARE(item1_child2->gestureOverrideEventsReceived, 0);
QCOMPARE(item1->gestureOverrideEventsReceived, 0);
- QCOMPARE(item1->gestureEventsReceived, TotalGestureEventsCount);
item1->reset(); item1_child1->reset(); item1_child2->reset();
@@ -971,7 +1004,7 @@ void tst_Gestures::graphicsItemTreeGesture()
item1->ignoredGestures << CustomGesture::GestureType;
item1_child1->ignoredGestures << CustomGesture::GestureType;
sendCustomGesture(&event, item1_child1, &scene);
- QCOMPARE(item1_child1->gestureOverrideEventsReceived, 1);
+ QTRY_COMPARE(item1_child1->gestureOverrideEventsReceived, 1);
QCOMPARE(item1_child1->gestureEventsReceived, TotalGestureEventsCount);
QCOMPARE(item1_child2->gestureEventsReceived, 0);
QCOMPARE(item1_child2->gestureOverrideEventsReceived, 0);
@@ -984,6 +1017,7 @@ void tst_Gestures::explicitGraphicsObjectTarget()
QGraphicsScene scene;
QGraphicsView view(&scene);
view.setWindowFlags(Qt::X11BypassWindowManagerHint);
+ view.move(m_availableTopLeft);
GestureItem *item1 = new GestureItem("item1");
scene.addItem(item1);
@@ -1017,9 +1051,9 @@ void tst_Gestures::explicitGraphicsObjectTarget()
sendCustomGesture(&event, item1, &scene);
- QCOMPARE(item1->gestureEventsReceived, 0);
+ QTRY_COMPARE(item2_child1->gestureEventsReceived, TotalGestureEventsCount);
QCOMPARE(item1->gestureOverrideEventsReceived, 1);
- QCOMPARE(item2_child1->gestureEventsReceived, TotalGestureEventsCount);
+ QCOMPARE(item1->gestureEventsReceived, 0);
QCOMPARE(item2_child1->gestureOverrideEventsReceived, 1);
QCOMPARE(item2_child1->events.all.size(), TotalGestureEventsCount);
for(int i = 0; i < item2_child1->events.all.size(); ++i)
@@ -1060,7 +1094,7 @@ void tst_Gestures::gestureOverChildGraphicsItem()
item2_child1->setPos(0, 0);
view.show();
- QVERIFY(QTest::qWaitForWindowExposed(&view));
+ QTRY_VERIFY(QTest::qWaitForWindowExposed(&view));
view.ensureVisible(scene.sceneRect());
item1->grabGesture(CustomGesture::GestureType);
@@ -1073,7 +1107,7 @@ void tst_Gestures::gestureOverChildGraphicsItem()
event.hasHotSpot = true;
sendCustomGesture(&event, item0, &scene);
- QCOMPARE(item0->customEventsReceived, TotalCustomEventsCount);
+ QTRY_COMPARE(item0->customEventsReceived, TotalCustomEventsCount);
QCOMPARE(item2_child1->gestureEventsReceived, 0);
QCOMPARE(item2_child1->gestureOverrideEventsReceived, 0);
QCOMPARE(item2->gestureEventsReceived, 0);
@@ -1089,11 +1123,11 @@ void tst_Gestures::gestureOverChildGraphicsItem()
event.hasHotSpot = true;
sendCustomGesture(&event, item0, &scene);
- QCOMPARE(item2_child1->gestureEventsReceived, 0);
- QCOMPARE(item2_child1->gestureOverrideEventsReceived, 0);
+ QTRY_COMPARE(item1->gestureEventsReceived, TotalGestureEventsCount);
QCOMPARE(item2->gestureEventsReceived, 1);
QCOMPARE(item2->gestureOverrideEventsReceived, 1);
- QCOMPARE(item1->gestureEventsReceived, TotalGestureEventsCount);
+ QCOMPARE(item2_child1->gestureEventsReceived, 0);
+ QCOMPARE(item2_child1->gestureOverrideEventsReceived, 0);
QCOMPARE(item1->gestureOverrideEventsReceived, 1);
item0->reset(); item1->reset(); item2->reset(); item2_child1->reset();
@@ -1105,9 +1139,9 @@ void tst_Gestures::gestureOverChildGraphicsItem()
event.hasHotSpot = true;
sendCustomGesture(&event, item0, &scene);
+ QTRY_COMPARE(item2->gestureEventsReceived, TotalGestureEventsCount);
QCOMPARE(item2_child1->gestureEventsReceived, 0);
QCOMPARE(item2_child1->gestureOverrideEventsReceived, 0);
- QCOMPARE(item2->gestureEventsReceived, TotalGestureEventsCount);
QCOMPARE(item2->gestureOverrideEventsReceived, 1);
QCOMPARE(item1->gestureEventsReceived, 1);
QCOMPARE(item1->gestureOverrideEventsReceived, 1);
@@ -1122,9 +1156,9 @@ void tst_Gestures::gestureOverChildGraphicsItem()
event.hasHotSpot = true;
sendCustomGesture(&event, item0, &scene);
+ QTRY_COMPARE(item2->gestureEventsReceived, TotalGestureEventsCount);
QCOMPARE(item2_child1->gestureEventsReceived, 0);
QCOMPARE(item2_child1->gestureOverrideEventsReceived, 0);
- QCOMPARE(item2->gestureEventsReceived, TotalGestureEventsCount);
QCOMPARE(item2->gestureOverrideEventsReceived, 1);
QCOMPARE(item1->gestureEventsReceived, TotalGestureEventsCount);
QCOMPARE(item1->gestureOverrideEventsReceived, 1);
@@ -1138,6 +1172,9 @@ void tst_Gestures::twoGesturesOnDifferentLevel()
l->addWidget(child);
Qt::GestureType SecondGesture = QGestureRecognizer::registerRecognizer(new CustomGestureRecognizer);
+ auto unregisterRecognizer = qScopeGuard([SecondGesture]{
+ QGestureRecognizer::unregisterRecognizer(SecondGesture);
+ });
parent.grabGesture(CustomGesture::GestureType);
child->grabGesture(SecondGesture);
@@ -1152,20 +1189,18 @@ void tst_Gestures::twoGesturesOnDifferentLevel()
static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1;
static const int TotalCustomEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialMaybeThreshold + 1;
- QCOMPARE(child->customEventsReceived, TotalCustomEventsCount);
+ QTRY_COMPARE(child->customEventsReceived, TotalCustomEventsCount);
QCOMPARE(child->gestureEventsReceived, TotalGestureEventsCount);
QCOMPARE(child->gestureOverrideEventsReceived, 0);
QCOMPARE(child->events.all.size(), TotalGestureEventsCount);
for(int i = 0; i < child->events.all.size(); ++i)
QCOMPARE(child->events.all.at(i), SecondGesture);
+ QCOMPARE(parent.events.all.size(), TotalGestureEventsCount);
QCOMPARE(parent.gestureEventsReceived, TotalGestureEventsCount);
QCOMPARE(parent.gestureOverrideEventsReceived, 0);
- QCOMPARE(parent.events.all.size(), TotalGestureEventsCount);
for(int i = 0; i < child->events.all.size(); ++i)
QCOMPARE(parent.events.all.at(i), CustomGesture::GestureType);
-
- QGestureRecognizer::unregisterRecognizer(SecondGesture);
}
void tst_Gestures::multipleGesturesInTree()
@@ -1179,6 +1214,10 @@ void tst_Gestures::multipleGesturesInTree()
Qt::GestureType FirstGesture = CustomGesture::GestureType;
Qt::GestureType SecondGesture = QGestureRecognizer::registerRecognizer(new CustomGestureRecognizer);
Qt::GestureType ThirdGesture = QGestureRecognizer::registerRecognizer(new CustomGestureRecognizer);
+ auto unregisterRecognizer = qScopeGuard([SecondGesture, ThirdGesture]{
+ QGestureRecognizer::unregisterRecognizer(SecondGesture);
+ QGestureRecognizer::unregisterRecognizer(ThirdGesture);
+ });
Qt::GestureFlags flags = Qt::ReceivePartialGestures;
A->grabGesture(FirstGesture, flags); // A [1 3]
@@ -1203,7 +1242,7 @@ void tst_Gestures::multipleGesturesInTree()
static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1;
// gesture override events
- QCOMPARE(D->overrideEvents.all.count(FirstGesture), 1);
+ QTRY_COMPARE(D->overrideEvents.all.count(FirstGesture), 1);
QCOMPARE(D->overrideEvents.all.count(SecondGesture), 0);
QCOMPARE(D->overrideEvents.all.count(ThirdGesture), 1);
@@ -1235,9 +1274,6 @@ void tst_Gestures::multipleGesturesInTree()
QCOMPARE(A->events.all.count(FirstGesture), TotalGestureEventsCount);
QCOMPARE(A->events.all.count(SecondGesture), 0);
QCOMPARE(A->events.all.count(ThirdGesture), TotalGestureEventsCount);
-
- QGestureRecognizer::unregisterRecognizer(SecondGesture);
- QGestureRecognizer::unregisterRecognizer(ThirdGesture);
}
void tst_Gestures::multipleGesturesInComplexTree()
@@ -1255,6 +1291,14 @@ void tst_Gestures::multipleGesturesInComplexTree()
Qt::GestureType FifthGesture = QGestureRecognizer::registerRecognizer(new CustomGestureRecognizer);
Qt::GestureType SixthGesture = QGestureRecognizer::registerRecognizer(new CustomGestureRecognizer);
Qt::GestureType SeventhGesture = QGestureRecognizer::registerRecognizer(new CustomGestureRecognizer);
+ auto unregisterRecognizer = qScopeGuard([=]{
+ QGestureRecognizer::unregisterRecognizer(SecondGesture);
+ QGestureRecognizer::unregisterRecognizer(ThirdGesture);
+ QGestureRecognizer::unregisterRecognizer(FourthGesture);
+ QGestureRecognizer::unregisterRecognizer(FifthGesture);
+ QGestureRecognizer::unregisterRecognizer(SixthGesture);
+ QGestureRecognizer::unregisterRecognizer(SeventhGesture);
+ });
Qt::GestureFlags flags = Qt::ReceivePartialGestures;
A->grabGesture(FirstGesture, flags); // A [1,3,4]
@@ -1284,7 +1328,7 @@ void tst_Gestures::multipleGesturesInComplexTree()
static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1;
// gesture override events
- QCOMPARE(D->overrideEvents.all.count(FirstGesture), 1);
+ QTRY_COMPARE(D->overrideEvents.all.count(FirstGesture), 1);
QCOMPARE(D->overrideEvents.all.count(SecondGesture), 0);
QCOMPARE(D->overrideEvents.all.count(ThirdGesture), 1);
@@ -1332,13 +1376,6 @@ void tst_Gestures::multipleGesturesInComplexTree()
QCOMPARE(A->events.all.count(FifthGesture), 0);
QCOMPARE(A->events.all.count(SixthGesture), 0);
QCOMPARE(A->events.all.count(SeventhGesture), 0);
-
- QGestureRecognizer::unregisterRecognizer(SecondGesture);
- QGestureRecognizer::unregisterRecognizer(ThirdGesture);
- QGestureRecognizer::unregisterRecognizer(FourthGesture);
- QGestureRecognizer::unregisterRecognizer(FifthGesture);
- QGestureRecognizer::unregisterRecognizer(SixthGesture);
- QGestureRecognizer::unregisterRecognizer(SeventhGesture);
}
void tst_Gestures::testMapToScene()
@@ -1401,13 +1438,13 @@ void tst_Gestures::ungrabGesture() // a method on QWidget
// sending an event will cause the QGesture objects to be instantiated for the widgets
sendCustomGesture(&event, b);
- QCOMPARE(a->gestures.count(), 1);
+ QTRY_COMPARE(a->gestures.size(), 1);
QPointer<QGesture> customGestureA;
customGestureA = *(a->gestures.begin());
QVERIFY(!customGestureA.isNull());
QCOMPARE(customGestureA->gestureType(), CustomGesture::GestureType);
- QCOMPARE(b->gestures.count(), 1);
+ QCOMPARE(b->gestures.size(), 1);
QPointer<QGesture> customGestureB;
customGestureB = *(b->gestures.begin());
QVERIFY(!customGestureB.isNull());
@@ -1418,7 +1455,7 @@ void tst_Gestures::ungrabGesture() // a method on QWidget
// sending an event will cause the QGesture objects to be instantiated for the widget
sendCustomGesture(&event, a);
- QCOMPARE(a->gestures.count(), 1);
+ QTRY_COMPARE(a->gestures.size(), 1);
customGestureA = *(a->gestures.begin());
QVERIFY(!customGestureA.isNull());
QCOMPARE(customGestureA->gestureType(), CustomGesture::GestureType);
@@ -1426,7 +1463,7 @@ void tst_Gestures::ungrabGesture() // a method on QWidget
a->ungrabGesture(CustomGesture::GestureType);
//We changed the deletion of Gestures to lazy during QT-4022, so we can't ensure the QGesture is deleted until now
- QVERIFY(!customGestureB.isNull());
+ QTRY_VERIFY(!customGestureB.isNull());
a->gestures.clear();
a->reset();
@@ -1463,7 +1500,7 @@ void tst_Gestures::autoCancelGestures()
{
if (event->type() == QEvent::Gesture) {
QGestureEvent *ge = static_cast<QGestureEvent*>(event);
- if (ge->gestures().count() != 1)
+ if (ge->gestures().size() != 1)
++badGestureEvents; // event should contain exactly one gesture
ge->gestures().first()->setGestureCancelPolicy(QGesture::CancelAllInContext);
}
@@ -1474,6 +1511,9 @@ void tst_Gestures::autoCancelGestures()
};
const Qt::GestureType secondGesture = QGestureRecognizer::registerRecognizer(new CustomGestureRecognizer);
+ auto unregisterRecognizer = qScopeGuard([secondGesture]{
+ QGestureRecognizer::unregisterRecognizer(secondGesture);
+ });
MockWidget parent("parent"); // this one sets the cancel policy to CancelAllInContext
parent.resize(300, 100);
@@ -1496,15 +1536,15 @@ void tst_Gestures::autoCancelGestures()
CustomEvent event;
event.serial = CustomGesture::SerialStartedThreshold;
QApplication::sendEvent(child, &event);
- QCOMPARE(child->events.all.count(), 2);
- QCOMPARE(child->events.started.count(), 1);
- QCOMPARE(child->events.canceled.count(), 1);
- QCOMPARE(parent.events.all.count(), 1);
+ QCOMPARE(child->events.all.size(), 2);
+ QCOMPARE(child->events.started.size(), 1);
+ QCOMPARE(child->events.canceled.size(), 1);
+ QCOMPARE(parent.events.all.size(), 1);
// clean up, make the parent gesture finish
event.serial = CustomGesture::SerialFinishedThreshold;
QApplication::sendEvent(child, &event);
- QCOMPARE(parent.events.all.count(), 2);
+ QCOMPARE(parent.events.all.size(), 2);
QCOMPARE(parent.badGestureEvents, 0);
}
@@ -1518,7 +1558,7 @@ void tst_Gestures::autoCancelGestures2()
{
if (event->type() == QEvent::Gesture) {
QGestureEvent *ge = static_cast<QGestureEvent*>(event);
- if (ge->gestures().count() != 1)
+ if (ge->gestures().size() != 1)
++badGestureEvents; // event should contain exactly one gesture
ge->gestures().first()->setGestureCancelPolicy(QGesture::CancelAllInContext);
}
@@ -1529,10 +1569,14 @@ void tst_Gestures::autoCancelGestures2()
};
const Qt::GestureType secondGesture = QGestureRecognizer ::registerRecognizer(new CustomGestureRecognizer);
+ auto unregisterRecognizer = qScopeGuard([secondGesture]{
+ QGestureRecognizer::unregisterRecognizer(secondGesture);
+ });
QGraphicsScene scene;
QGraphicsView view(&scene);
view.setWindowFlags(Qt::X11BypassWindowManagerHint);
+ view.move(m_availableTopLeft);
MockItem *parent = new MockItem("parent");
GestureItem *child = new GestureItem("child");
@@ -1552,15 +1596,15 @@ void tst_Gestures::autoCancelGestures2()
event.hasHotSpot = true;
event.hotSpot = mapToGlobal(QPointF(5, 5), child, &view);
scene.sendEvent(child, &event);
- QCOMPARE(parent->events.all.count(), 1);
- QCOMPARE(child->events.started.count(), 1);
- QCOMPARE(child->events.canceled.count(), 1);
- QCOMPARE(child->events.all.count(), 2);
+ QCOMPARE(parent->events.all.size(), 1);
+ QCOMPARE(child->events.started.size(), 1);
+ QCOMPARE(child->events.canceled.size(), 1);
+ QCOMPARE(child->events.all.size(), 2);
// clean up, make the parent gesture finish
event.serial = CustomGesture::SerialFinishedThreshold;
scene.sendEvent(child, &event);
- QCOMPARE(parent->events.all.count(), 2);
+ QCOMPARE(parent->events.all.size(), 2);
QCOMPARE(parent->badGestureEvents, 0);
}
@@ -1569,6 +1613,7 @@ void tst_Gestures::graphicsViewParentPropagation()
QGraphicsScene scene;
QGraphicsView view(&scene);
view.setWindowFlags(Qt::X11BypassWindowManagerHint);
+ view.move(m_availableTopLeft);
GestureItem *item0 = new GestureItem("item0");
scene.addItem(item0);
@@ -1614,7 +1659,7 @@ void tst_Gestures::graphicsViewParentPropagation()
event.hasHotSpot = true;
sendCustomGesture(&event, item0, &scene);
- QCOMPARE(item1_c1_c1->gestureEventsReceived, TotalGestureEventsCount);
+ QTRY_COMPARE(item1_c1_c1->gestureEventsReceived, TotalGestureEventsCount);
QCOMPARE(item1_c1_c1->gestureOverrideEventsReceived, 1);
QCOMPARE(item1_c1->gestureEventsReceived, TotalGestureEventsCount-1);
QCOMPARE(item1_c1->gestureOverrideEventsReceived, 1);
@@ -1629,6 +1674,7 @@ void tst_Gestures::panelPropagation()
QGraphicsScene scene;
QGraphicsView view(&scene);
view.setWindowFlags(Qt::X11BypassWindowManagerHint);
+ view.move(m_availableTopLeft);
GestureItem *item0 = new GestureItem("item0");
scene.addItem(item0);
@@ -1686,11 +1732,11 @@ void tst_Gestures::panelPropagation()
event.hasHotSpot = true;
sendCustomGesture(&event, item1, &scene);
+ QCOMPARE(item1->gestureEventsReceived, TotalGestureEventsCount);
QCOMPARE(item1_child1_child1->gestureEventsReceived, 0);
QCOMPARE(item1_child1_child1->gestureOverrideEventsReceived, 0);
QCOMPARE(item1_child1->gestureEventsReceived, 0);
QCOMPARE(item1_child1->gestureOverrideEventsReceived, 0);
- QCOMPARE(item1->gestureEventsReceived, TotalGestureEventsCount);
QCOMPARE(item1->gestureOverrideEventsReceived, 1);
QCOMPARE(item0->gestureEventsReceived, 0);
QCOMPARE(item0->gestureOverrideEventsReceived, 1);
@@ -1740,7 +1786,7 @@ void tst_Gestures::panelPropagation()
QCOMPARE(item1_child1_child1->gestureEventsReceived, 0);
QCOMPARE(item1_child1_child1->gestureOverrideEventsReceived, 0);
- QCOMPARE(item1_child1->gestureEventsReceived, TotalGestureEventsCount);
+ QTRY_COMPARE(item1_child1->gestureEventsReceived, TotalGestureEventsCount);
QCOMPARE(item1_child1->gestureOverrideEventsReceived, 0);
QCOMPARE(item1->gestureEventsReceived, 0);
QCOMPARE(item1->gestureOverrideEventsReceived, 0);
@@ -1753,6 +1799,7 @@ void tst_Gestures::panelStacksBehindParent()
QGraphicsScene scene;
QGraphicsView view(&scene);
view.setWindowFlags(Qt::X11BypassWindowManagerHint);
+ view.move(m_availableTopLeft);
GestureItem *item1 = new GestureItem("item1");
item1->grabGesture(CustomGesture::GestureType);
@@ -1932,7 +1979,7 @@ void tst_Gestures::viewportCoordinates()
event.hotSpot = mapToGlobal(item1->boundingRect().center(), item1, &view);
event.hasHotSpot = true;
sendCustomGesture(&event, item1, &scene);
- QVERIFY(item1->gestureEventsReceived != 0);
+ QTRY_VERIFY(item1->gestureEventsReceived != 0);
}
void tst_Gestures::partialGesturePropagation()
@@ -1940,6 +1987,7 @@ void tst_Gestures::partialGesturePropagation()
QGraphicsScene scene;
QGraphicsView view(&scene);
view.setWindowFlags(Qt::X11BypassWindowManagerHint);
+ view.move(m_availableTopLeft);
GestureItem *item1 = new GestureItem("item1");
item1->grabGesture(CustomGesture::GestureType);
@@ -1974,13 +2022,14 @@ void tst_Gestures::partialGesturePropagation()
static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1;
+ QCOMPARE(item1->gestureEventsReceived, TotalGestureEventsCount);
+ QCOMPARE(item2->gestureEventsReceived, TotalGestureEventsCount-2); // except for started and finished
+
QCOMPARE(item1->gestureOverrideEventsReceived, 1);
QCOMPARE(item2->gestureOverrideEventsReceived, 1);
QCOMPARE(item3->gestureOverrideEventsReceived, 1);
QCOMPARE(item4->gestureOverrideEventsReceived, 1);
- QCOMPARE(item1->gestureEventsReceived, TotalGestureEventsCount);
- QCOMPARE(item2->gestureEventsReceived, TotalGestureEventsCount-2); // except for started and finished
QCOMPARE(item3->gestureEventsReceived, 0);
QCOMPARE(item4->gestureEventsReceived, 0);
}
@@ -2030,10 +2079,14 @@ void tst_Gestures::testQGestureRecognizerCleanup()
// Mimic QGestureManager: register both default and "platform" recognizers
// (this is done in windows when QT_NO_NATIVE_GESTURES is not defined)
PanRecognizer *def = new PanRecognizer(PanRecognizer::Default);
- QGestureRecognizer::registerRecognizer(def);
+ auto defRecognizer = QGestureRecognizer::registerRecognizer(def);
PanRecognizer *plt = new PanRecognizer(PanRecognizer::Platform);
- QGestureRecognizer::registerRecognizer(plt);
+ auto pltRecognizer = QGestureRecognizer::registerRecognizer(plt);
qDebug () << "register: default =" << def << "; platform =" << plt;
+ auto unregisterRecognizer = qScopeGuard([defRecognizer, pltRecognizer]{
+ QGestureRecognizer::unregisterRecognizer(defRecognizer);
+ QGestureRecognizer::unregisterRecognizer(pltRecognizer);
+ });
// ^-- Qt singleton QGManager initialization
@@ -2147,11 +2200,16 @@ void tst_Gestures::testReuseCanceledGestures()
new ReuseCanceledGesturesRecognizer(ReuseCanceledGesturesRecognizer::RmbAndCancelAllType));
Qt::GestureType tapGestureTypeId = QGestureRecognizer::registerRecognizer(
new ReuseCanceledGesturesRecognizer(ReuseCanceledGesturesRecognizer::LmbType));
+ auto unregisterRecognizer = qScopeGuard([=]{
+ QGestureRecognizer::unregisterRecognizer(cancellingGestureTypeId);
+ QGestureRecognizer::unregisterRecognizer(tapGestureTypeId);
+ });
QMainWindow mw;
mw.setWindowFlags(Qt::X11BypassWindowManagerHint);
QGraphicsView *gv = new QGraphicsView(&mw);
QGraphicsScene *scene = new QGraphicsScene;
+ mw.move(m_availableTopLeft);
gv->setScene(scene);
scene->setSceneRect(0,0,100,100);
@@ -2254,8 +2312,8 @@ void tst_Gestures::conflictingGesturesInGraphicsView()
event.hotSpot = mapToGlobal(item2->boundingRect().center(), item2, &view);
event.hasHotSpot = true;
sendCustomGesture(&event, item2, &scene);
+ QTRY_COMPARE(item2->gestureEventsReceived, TotalGestureEventsCount);
QCOMPARE(item2->gestureOverrideEventsReceived, 1);
- QCOMPARE(item2->gestureEventsReceived, TotalGestureEventsCount);
QCOMPARE(item1->gestureOverrideEventsReceived, 1);
QCOMPARE(item1->gestureEventsReceived, 0);
@@ -2267,8 +2325,8 @@ void tst_Gestures::conflictingGesturesInGraphicsView()
event.hotSpot = mapToGlobal(item2->boundingRect().center(), item2, &view);
event.hasHotSpot = true;
sendCustomGesture(&event, item2, &scene);
- QCOMPARE(item2->gestureOverrideEventsReceived, 1);
QCOMPARE(item2->gestureEventsReceived, TotalGestureEventsCount);
+ QCOMPARE(item2->gestureOverrideEventsReceived, 1);
QCOMPARE(item1->gestureOverrideEventsReceived, 0);
QCOMPARE(item1->gestureEventsReceived, 0);
@@ -2280,11 +2338,11 @@ void tst_Gestures::conflictingGesturesInGraphicsView()
event.hotSpot = mapToGlobal(item2->boundingRect().center(), item2, &view);
event.hasHotSpot = true;
sendCustomGesture(&event, item2, &scene);
+ QCOMPARE(item1->gestureEventsReceived, TotalGestureEventsCount);
QCOMPARE(item2->gestureOverrideEventsReceived, 1);
QCOMPARE(item2->gestureEventsReceived, 0);
QCOMPARE(item1->gestureOverrideEventsReceived, 1);
- QCOMPARE(item1->gestureEventsReceived, TotalGestureEventsCount);
}
class NoConsumeWidgetBug13501 :public QWidget
diff --git a/tests/auto/other/languagechange/CMakeLists.txt b/tests/auto/other/languagechange/CMakeLists.txt
index 36bbc76dac..07f3547d58 100644
--- a/tests/auto/other/languagechange/CMakeLists.txt
+++ b/tests/auto/other/languagechange/CMakeLists.txt
@@ -1,12 +1,16 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-
-# Generated from languagechange.pro.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_languagechange Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_languagechange LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_languagechange
SOURCES
tst_languagechange.cpp
@@ -16,9 +20,3 @@ qt_internal_add_test(tst_languagechange
Qt::GuiPrivate
Qt::Widgets
)
-
-## Scopes:
-#####################################################################
-
-#### Keys ignored in scope 2:.:.:languagechange.pro:WIN32:
-# testcase.timeout = "1800"
diff --git a/tests/auto/other/languagechange/tst_languagechange.cpp b/tests/auto/other/languagechange/tst_languagechange.cpp
index f5ae7c0717..8f99730a19 100644
--- a/tests/auto/other/languagechange/tst_languagechange.cpp
+++ b/tests/auto/other/languagechange/tst_languagechange.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 <QTest>
diff --git a/tests/auto/other/macgui/BLACKLIST b/tests/auto/other/macgui/BLACKLIST
index 05e529e519..a6dc56611b 100644
--- a/tests/auto/other/macgui/BLACKLIST
+++ b/tests/auto/other/macgui/BLACKLIST
@@ -1,5 +1,2 @@
-[nonModalOrder]
-osx
-
[scrollbarPainting]
macos
diff --git a/tests/auto/other/macgui/CMakeLists.txt b/tests/auto/other/macgui/CMakeLists.txt
index 3faf6ccbd2..afa3f0b8df 100644
--- a/tests/auto/other/macgui/CMakeLists.txt
+++ b/tests/auto/other/macgui/CMakeLists.txt
@@ -1,12 +1,16 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+# SPDX-License-Identifier: BSD-3-Clause
-# Generated from macgui.pro.
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_macgui LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
if(NOT APPLE)
return()
endif()
-if(NOT TARGET Qt::Widgets) # special case
+if(NOT TARGET Qt::Widgets)
return()
endif()
@@ -18,14 +22,13 @@ qt_internal_add_test(tst_macgui
SOURCES
guitest.cpp guitest.h
tst_macgui.cpp
+ NO_PCH_SOURCES
+ guitest.cpp # undef QT_NO_FOREACH
LIBRARIES
Qt::CorePrivate
Qt::WidgetsPrivate
)
-#### Keys ignored in scope 1:.:.:macgui.pro:<TRUE>:
-# _REQUIREMENTS = "mac" "widgets"
-
## Scopes:
#####################################################################
diff --git a/tests/auto/other/macgui/guitest.cpp b/tests/auto/other/macgui/guitest.cpp
index 1f9ca0efcc..fbae891065 100644
--- a/tests/auto/other/macgui/guitest.cpp
+++ b/tests/auto/other/macgui/guitest.cpp
@@ -1,6 +1,7 @@
// 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
+#undef QT_NO_FOREACH // this file contains unported legacy Q_FOREACH uses
#include "guitest.h"
#include <QDebug>
diff --git a/tests/auto/other/macgui/guitest.h b/tests/auto/other/macgui/guitest.h
index 69f2ba4be5..80a2103fc9 100644
--- a/tests/auto/other/macgui/guitest.h
+++ b/tests/auto/other/macgui/guitest.h
@@ -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
#ifndef GUITEST_H
#define GUITEST_H
diff --git a/tests/auto/other/macgui/tst_macgui.cpp b/tests/auto/other/macgui/tst_macgui.cpp
index 4d09db9b7f..efcecef9ad 100644
--- a/tests/auto/other/macgui/tst_macgui.cpp
+++ b/tests/auto/other/macgui/tst_macgui.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 <QApplication>
@@ -126,40 +126,6 @@ void tst_MacGui::splashScreenModality()
QVERIFY(!QTestEventLoop::instance().timeout());
}
-class PrimaryWindowDialog : public QDialog
-{
-Q_OBJECT
-public:
- PrimaryWindowDialog();
- QWidget *secondaryWindow;
- QWidget *frontWidget;
-public slots:
- void showSecondaryWindow();
- void test();
-};
-
-PrimaryWindowDialog::PrimaryWindowDialog() : QDialog(0)
-{
- frontWidget = 0;
- secondaryWindow = new ColorWidget(this);
- secondaryWindow->setWindowFlags(Qt::Window);
- secondaryWindow->resize(400, 400);
- secondaryWindow->move(100, 100);
- QTimer::singleShot(1000, this, SLOT(showSecondaryWindow()));
- QTimer::singleShot(2000, this, SLOT(test()));
- QTimer::singleShot(3000, this, SLOT(close()));
-}
-
-void PrimaryWindowDialog::showSecondaryWindow()
-{
- secondaryWindow->show();
-}
-
-void PrimaryWindowDialog::test()
-{
- frontWidget = QApplication::widgetAt(secondaryWindow->mapToGlobal(QPoint(100, 100)));
-}
-
/*
Test that a non-modal child window of a modal dialog is shown in front
of the dialog even if the dialog becomes modal after the child window
@@ -168,11 +134,28 @@ void PrimaryWindowDialog::test()
void tst_MacGui::nonModalOrder()
{
clearSequence();
- PrimaryWindowDialog primary;
- primary.resize(400, 400);
- primary.move(100, 100);
- primary.exec();
- QCOMPARE(primary.frontWidget, primary.secondaryWindow);
+
+ QDialog dialog;
+ dialog.resize(400, 400);
+ dialog.move(100, 100);
+
+ ColorWidget child(&dialog);
+ // The child window needs to be a dialog, as only subclasses of NSPanel
+ // are allowed to override worksWhenModal, which is needed to mark the
+ // transient child as working within the modal session of the parent.
+ child.setWindowFlags(Qt::Window | Qt::Dialog);
+ child.resize(400, 400);
+ child.move(100, 100);
+
+ QTimer::singleShot(0, [&]{
+ QVERIFY(QTest::qWaitForWindowExposed(&dialog));
+ child.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&child));
+ QCOMPARE(QApplication::widgetAt(child.mapToGlobal(QPoint(100, 100))), &child);
+ dialog.close();
+ });
+
+ dialog.exec();
}
/*
diff --git a/tests/auto/other/macnativeevents/CMakeLists.txt b/tests/auto/other/macnativeevents/CMakeLists.txt
index 179c89122e..c44cf61920 100644
--- a/tests/auto/other/macnativeevents/CMakeLists.txt
+++ b/tests/auto/other/macnativeevents/CMakeLists.txt
@@ -1,7 +1,11 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+# SPDX-License-Identifier: BSD-3-Clause
-# Generated from macnativeevents.pro.
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_macnativeevents LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
if(NOT APPLE)
return()
@@ -18,13 +22,8 @@ qt_internal_add_test(tst_macnativeevents
qnativeevents.cpp qnativeevents.h
qnativeevents_mac.cpp
tst_macnativeevents.cpp
- DEFINES
- QT_DISABLE_DEPRECATED_BEFORE=0
LIBRARIES
${FWAppKit}
Qt::Gui
Qt::Widgets
)
-
-#### Keys ignored in scope 1:.:.:macnativeevents.pro:<TRUE>:
-# _REQUIREMENTS = "mac"
diff --git a/tests/auto/other/macnativeevents/expectedeventlist.cpp b/tests/auto/other/macnativeevents/expectedeventlist.cpp
index 51437da05d..a8c662ad93 100644
--- a/tests/auto/other/macnativeevents/expectedeventlist.cpp
+++ b/tests/auto/other/macnativeevents/expectedeventlist.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 "expectedeventlist.h"
#include <QDebug>
diff --git a/tests/auto/other/macnativeevents/expectedeventlist.h b/tests/auto/other/macnativeevents/expectedeventlist.h
index b8f9758050..f21b56c9b2 100644
--- a/tests/auto/other/macnativeevents/expectedeventlist.h
+++ b/tests/auto/other/macnativeevents/expectedeventlist.h
@@ -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
#ifndef EVENTFILTER
#define EVENTFILTER
diff --git a/tests/auto/other/macnativeevents/nativeeventlist.cpp b/tests/auto/other/macnativeevents/nativeeventlist.cpp
index 7266ec2fca..6216c9682f 100644
--- a/tests/auto/other/macnativeevents/nativeeventlist.cpp
+++ b/tests/auto/other/macnativeevents/nativeeventlist.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 "nativeeventlist.h"
diff --git a/tests/auto/other/macnativeevents/nativeeventlist.h b/tests/auto/other/macnativeevents/nativeeventlist.h
index de1b8da13b..20e91a689a 100644
--- a/tests/auto/other/macnativeevents/nativeeventlist.h
+++ b/tests/auto/other/macnativeevents/nativeeventlist.h
@@ -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
#ifndef Q_NATIVE_PLAYBACK
#define Q_NATIVE_PLAYBACK
diff --git a/tests/auto/other/macnativeevents/qnativeevents.cpp b/tests/auto/other/macnativeevents/qnativeevents.cpp
index d4784ff6cd..a516fc28d6 100644
--- a/tests/auto/other/macnativeevents/qnativeevents.cpp
+++ b/tests/auto/other/macnativeevents/qnativeevents.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 "qnativeevents.h"
diff --git a/tests/auto/other/macnativeevents/qnativeevents.h b/tests/auto/other/macnativeevents/qnativeevents.h
index b96dc5bd8c..cab2472083 100644
--- a/tests/auto/other/macnativeevents/qnativeevents.h
+++ b/tests/auto/other/macnativeevents/qnativeevents.h
@@ -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
#ifndef Q_NATIVE_INPUT
#define Q_NATIVE_INPUT
diff --git a/tests/auto/other/macnativeevents/qnativeevents_mac.cpp b/tests/auto/other/macnativeevents/qnativeevents_mac.cpp
index d9d76c8fd0..a2e1a66c65 100644
--- a/tests/auto/other/macnativeevents/qnativeevents_mac.cpp
+++ b/tests/auto/other/macnativeevents/qnativeevents_mac.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 "qnativeevents.h"
#include <CoreGraphics/CoreGraphics.h>
diff --git a/tests/auto/other/macnativeevents/tst_macnativeevents.cpp b/tests/auto/other/macnativeevents/tst_macnativeevents.cpp
index bc2145d1a4..3cb934d7d5 100644
--- a/tests/auto/other/macnativeevents/tst_macnativeevents.cpp
+++ b/tests/auto/other/macnativeevents/tst_macnativeevents.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 <QApplication>
#include <QWidget>
diff --git a/tests/auto/other/macplist/CMakeLists.txt b/tests/auto/other/macplist/CMakeLists.txt
index 765a6951ae..6a98d4dc16 100644
--- a/tests/auto/other/macplist/CMakeLists.txt
+++ b/tests/auto/other/macplist/CMakeLists.txt
@@ -1,9 +1,13 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+# SPDX-License-Identifier: BSD-3-Clause
-# Generated from macplist.pro.
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_macplist LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
-if(NOT TARGET Qt::Widgets) # special case
+if(NOT TARGET Qt::Widgets)
return()
endif()
add_subdirectory(app)
diff --git a/tests/auto/other/macplist/app/CMakeLists.txt b/tests/auto/other/macplist/app/CMakeLists.txt
index 353b532d0b..8af8e9f578 100644
--- a/tests/auto/other/macplist/app/CMakeLists.txt
+++ b/tests/auto/other/macplist/app/CMakeLists.txt
@@ -1,7 +1,5 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-
-# Generated from app.pro.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## app Binary:
@@ -9,7 +7,7 @@
qt_internal_add_executable(app
GUI
- OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} # special case
+ OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
SOURCES
main.cpp
LIBRARIES
diff --git a/tests/auto/other/macplist/app/main.cpp b/tests/auto/other/macplist/app/main.cpp
index 6647fda781..2f07fe3c25 100644
--- a/tests/auto/other/macplist/app/main.cpp
+++ b/tests/auto/other/macplist/app/main.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 <QtWidgets/QApplication>
diff --git a/tests/auto/other/macplist/test/CMakeLists.txt b/tests/auto/other/macplist/test/CMakeLists.txt
index 5c6235d3c8..e55dfb2591 100644
--- a/tests/auto/other/macplist/test/CMakeLists.txt
+++ b/tests/auto/other/macplist/test/CMakeLists.txt
@@ -1,7 +1,5 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-
-# Generated from test.pro.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_macplist Test:
diff --git a/tests/auto/other/macplist/tst_macplist.cpp b/tests/auto/other/macplist/tst_macplist.cpp
index 8928600f63..12240c45b5 100644
--- a/tests/auto/other/macplist/tst_macplist.cpp
+++ b/tests/auto/other/macplist/tst_macplist.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 <QTest>
diff --git a/tests/auto/other/networkselftest/BLACKLIST b/tests/auto/other/networkselftest/BLACKLIST
index 20f0295b48..9865f4def5 100644
--- a/tests/auto/other/networkselftest/BLACKLIST
+++ b/tests/auto/other/networkselftest/BLACKLIST
@@ -1,6 +1,5 @@
# QTBUG-27571
[ftpProxyServer]
-windows-7sp1
windows-10
[smbServer]
opensuse-leap
diff --git a/tests/auto/other/networkselftest/CMakeLists.txt b/tests/auto/other/networkselftest/CMakeLists.txt
index 46a3a73a0d..6491c510f6 100644
--- a/tests/auto/other/networkselftest/CMakeLists.txt
+++ b/tests/auto/other/networkselftest/CMakeLists.txt
@@ -1,20 +1,21 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-
-# Generated from networkselftest.pro.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_networkselftest Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_networkselftest LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_networkselftest
SOURCES
tst_networkselftest.cpp
LIBRARIES
Qt::CorePrivate
Qt::Network
- QT_TEST_SERVER_LIST "danted" "squid" "apache2" "ftp-proxy" "vsftpd" "cyrus" "echo" # special case
+ QT_TEST_SERVER_LIST "danted" "squid" "apache2" "ftp-proxy" "vsftpd" "cyrus" "echo"
)
-
-#### Keys ignored in scope 1:.:.:networkselftest.pro:<TRUE>:
-# QT_TEST_SERVER_LIST = "cyrus" "vsftpd" "apache2" "ftp-proxy" "danted" "squid" "echo"
diff --git a/tests/auto/other/networkselftest/tst_networkselftest.cpp b/tests/auto/other/networkselftest/tst_networkselftest.cpp
index 824f26aeaa..81d3b60248 100644
--- a/tests/auto/other/networkselftest/tst_networkselftest.cpp
+++ b/tests/auto/other/networkselftest/tst_networkselftest.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 <QTest>
#include <QtNetwork/QtNetwork>
@@ -105,8 +105,8 @@ static QString prettyByteArray(const QByteArray &array)
{
// any control chars?
QString result;
- result.reserve(array.length() + array.length() / 3);
- for (int i = 0; i < array.length(); ++i) {
+ result.reserve(array.size() + array.size() / 3);
+ for (int i = 0; i < array.size(); ++i) {
char c = array.at(i);
switch (c) {
case '\n':
@@ -208,11 +208,11 @@ static void netChat(int port, const QList<Chat> &chat)
switch (it->type) {
case Chat::Expect: {
qDebug() << i << "Expecting" << prettyByteArray(it->data);
- if (!doSocketRead(&socket, it->data.length(), 3 * defaultReadTimeoutMS))
- QFAIL(msgDoSocketReadFailed(serverName, port, i, it->data.length()));
+ if (!doSocketRead(&socket, it->data.size(), 3 * defaultReadTimeoutMS))
+ QFAIL(msgDoSocketReadFailed(serverName, port, i, it->data.size()));
// pop that many bytes off the socket
- QByteArray received = socket.read(it->data.length());
+ QByteArray received = socket.read(it->data.size());
// is it what we expected?
QVERIFY2(received == it->data,
@@ -226,8 +226,8 @@ static void netChat(int port, const QList<Chat> &chat)
qDebug() << i << "Discarding until" << prettyByteArray(it->data);
while (true) {
// scan the buffer until we have our string
- if (!doSocketRead(&socket, it->data.length()))
- QFAIL(msgDoSocketReadFailed(serverName, port, i, it->data.length()));
+ if (!doSocketRead(&socket, it->data.size()))
+ QFAIL(msgDoSocketReadFailed(serverName, port, i, it->data.size()));
QByteArray buffer;
buffer.resize(socket.bytesAvailable());
@@ -239,7 +239,7 @@ static void netChat(int port, const QList<Chat> &chat)
continue;
}
- buffer = socket.read(pos + it->data.length());
+ buffer = socket.read(pos + it->data.size());
qDebug() << i << "Discarded" << prettyByteArray(buffer);
break;
}
@@ -354,7 +354,7 @@ void tst_NetworkSelfTest::initTestCase()
if (resolved.error() == QHostInfo::NoError && !resolved.addresses().isEmpty())
ftpServerIpAddress = resolved.addresses().first();
// TODO: 'ssh', port 22.
- QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::ftpProxyServerName(), 2121));
+ // QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::ftpProxyServerName(), 2121));
QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::httpServerName(), 80));
// TODO: 'smb', port 139.
QVERIFY(QtNetworkSettings::verifyConnection(QtNetworkSettings::imapServerName(), 143));
@@ -511,6 +511,7 @@ void tst_NetworkSelfTest::ftpServer()
void tst_NetworkSelfTest::ftpProxyServer()
{
+ QSKIP("FTP not currently supported.");
netChat(2121, ftpChat("@" + QtNetworkSettings::ftpServerName().toLatin1()));
}
diff --git a/tests/auto/other/qabstractitemmodelutils/dynamictreemodel.cpp b/tests/auto/other/qabstractitemmodelutils/dynamictreemodel.cpp
index 378c198949..d670cec196 100644
--- a/tests/auto/other/qabstractitemmodelutils/dynamictreemodel.cpp
+++ b/tests/auto/other/qabstractitemmodelutils/dynamictreemodel.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2009 Stephen Kelly <steveire@gmail.com>
-// 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 "dynamictreemodel.h"
@@ -191,7 +191,7 @@ void ModelMoveCommand::doCommand()
return;
for (int column = 0; column < m_numCols; ++column) {
- QList<qint64> l = m_model->m_childItems.value(srcParent.internalId())[column].mid(
+ const QList<qint64> l = m_model->m_childItems.value(srcParent.internalId())[column].mid(
m_startRow, m_endRow - m_startRow + 1);
for (int i = m_startRow; i <= m_endRow; i++)
@@ -206,7 +206,7 @@ void ModelMoveCommand::doCommand()
d = m_destRow;
}
- foreach (const qint64 id, l)
+ for (qint64 id : l)
m_model->m_childItems[destParent.internalId()][column].insert(d++, id);
}
@@ -283,9 +283,7 @@ void ModelChangeChildrenLayoutsCommand::doCommand()
const QPersistentModelIndex parent1 = findIndex(m_rowNumbers);
const QPersistentModelIndex parent2 = findIndex(m_secondRowNumbers);
- QList<QPersistentModelIndex> parents;
- parents << parent1;
- parents << parent2;
+ const QList<QPersistentModelIndex> parents = { parent1, parent2 };
emit m_model->layoutAboutToBeChanged(parents);
@@ -309,13 +307,13 @@ void ModelChangeChildrenLayoutsCommand::doCommand()
// changing any children of that parent. The reason is that we're keeping parent1 and parent2
// around as QPersistentModelIndex instances, and we query idx.parent() in the loop.
QModelIndexList persistent = m_model->persistentIndexList();
- foreach (const QModelIndex &parent, parents) {
+ for (const QPersistentModelIndex &parent : parents) {
int idx = persistent.indexOf(parent);
if (idx != -1)
persistent.move(idx, 0);
}
- foreach (const QModelIndex &idx, persistent) {
+ for (const QModelIndex &idx : std::as_const(persistent)) {
if (idx.parent() == parent1) {
if (idx.row() == rowSize1 - 1) {
m_model->changePersistentIndex(idx,
diff --git a/tests/auto/other/qabstractitemmodelutils/dynamictreemodel.h b/tests/auto/other/qabstractitemmodelutils/dynamictreemodel.h
index 1f24830602..bc7db2ad0f 100644
--- a/tests/auto/other/qabstractitemmodelutils/dynamictreemodel.h
+++ b/tests/auto/other/qabstractitemmodelutils/dynamictreemodel.h
@@ -1,5 +1,5 @@
// Copyright (C) 2009 Stephen Kelly <steveire@gmail.com>
-// 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
#ifndef DYNAMICTREEMODEL_H
#define DYNAMICTREEMODEL_H
diff --git a/tests/auto/other/qaccessibility/CMakeLists.txt b/tests/auto/other/qaccessibility/CMakeLists.txt
index 191af68d6b..9160bafe52 100644
--- a/tests/auto/other/qaccessibility/CMakeLists.txt
+++ b/tests/auto/other/qaccessibility/CMakeLists.txt
@@ -1,7 +1,11 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+# SPDX-License-Identifier: BSD-3-Clause
-# Generated from qaccessibility.pro.
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qaccessibility LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
if(NOT QT_FEATURE_accessibility)
return()
@@ -23,9 +27,6 @@ qt_internal_add_test(tst_qaccessibility
Qt::WidgetsPrivate
)
-#### Keys ignored in scope 1:.:.:qaccessibility.pro:<TRUE>:
-# _REQUIREMENTS = "qtConfig(accessibility)"
-
## Scopes:
#####################################################################
diff --git a/tests/auto/other/qaccessibility/accessiblewidgets.h b/tests/auto/other/qaccessibility/accessiblewidgets.h
index 2e93f24fd3..76b1f1f473 100644
--- a/tests/auto/other/qaccessibility/accessiblewidgets.h
+++ b/tests/auto/other/qaccessibility/accessiblewidgets.h
@@ -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
#ifndef ACCESSIBLEWIDGETS_H
@@ -116,7 +116,7 @@ public:
int cursorPosition() const override { return textWidget()->cursorPosition; }
void setCursorPosition(int position) override { textWidget()->cursorPosition = position; }
QString text(int startOffset, int endOffset) const override { return textWidget()->text.mid(startOffset, endOffset); }
- int characterCount() const override { return textWidget()->text.length(); }
+ int characterCount() const override { return textWidget()->text.size(); }
QRect characterRect(int) const override { return QRect(); }
int offsetAtPoint(const QPoint &) const override { return 0; }
void scrollToSubstring(int, int) override {}
diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
index 89ef57e29b..5fd695e2e6 100644
--- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
+++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
@@ -1,12 +1,11 @@
// 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 <QtCore/qglobal.h>
#ifdef Q_OS_WIN
# include <QtCore/qt_windows.h>
# include <oleacc.h>
-# include <QtGui/private/qwindowsuiawrapper_p.h>
+# include <uiautomation.h>
# include <servprov.h>
# include <winuser.h>
#endif
@@ -18,9 +17,13 @@
#include <qpa/qplatformnativeinterface.h>
#include <qpa/qplatformintegration.h>
#include <qpa/qplatformaccessibility.h>
+#ifdef Q_OS_WIN
+#include <QtCore/private/qfunctions_win_p.h>
+#endif
#include <QtGui/private/qguiapplication_p.h>
#include <QtGui/private/qhighdpiscaling_p.h>
+#include <QtWidgets/private/qapplication_p.h>
#include <QtWidgets/private/qdialog_p.h>
#if defined(Q_OS_WIN) && defined(interface)
@@ -36,6 +39,7 @@
#include <QtTest/private/qtesthelpers_p.h>
using namespace QTestPrivate;
+using namespace Qt::StringLiterals;
static inline bool verifyChild(QWidget *child, QAccessibleInterface *interface,
int index, const QRect &domain)
@@ -163,6 +167,7 @@ public slots:
void cleanup();
private slots:
void eventTest();
+ void eventWithChildTest();
void customWidget();
void deletedWidget();
void subclassedWidget();
@@ -209,13 +214,16 @@ private slots:
void listTest();
void treeTest();
void tableTest();
+ void rootIndexView();
+ void uniqueIdTest();
void calendarWidgetTest();
void dockWidgetTest();
void comboBoxTest();
void accessibleName();
#if QT_CONFIG(shortcut)
void labelTest();
+ void relationTest();
void accelerators();
#endif
void bridgeTest();
@@ -292,9 +300,9 @@ void tst_QAccessibility::cleanup()
{
const EventList list = QTestAccessibility::events();
if (!list.isEmpty()) {
- qWarning("%zd accessibility event(s) were not handled in testfunction '%s':", size_t(list.count()),
+ qWarning("%zd accessibility event(s) were not handled in testfunction '%s':", size_t(list.size()),
QString(QTest::currentTestFunction()).toLatin1().constData());
- for (int i = 0; i < list.count(); ++i)
+ for (int i = 0; i < list.size(); ++i)
qWarning(" %d: Object: %p Event: '%s' Child: %d", i + 1, list.at(i)->object(),
qAccessibleEventString(list.at(i)->type()), list.at(i)->child());
}
@@ -353,6 +361,33 @@ void tst_QAccessibility::eventTest()
QTestAccessibility::clearEvents();
}
+void tst_QAccessibility::eventWithChildTest()
+{
+ // make sure that QAccessibleEvent created using either of the two QAccessibleEvent
+ // behaves the same when the same underlying QObject is used
+ QWidget widget;
+ QWidget childWidget(&widget);
+
+ // QAccessibleEvent constructor called with the QObject*
+ QAccessibleEvent event1(&widget, QAccessible::Focus);
+
+ // QAccessibleEvent constructor called with the QAccessibleInterface* for the same QObject*
+ QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(&widget);
+ QAccessibleEvent event2(iface, QAccessible::Focus);
+
+ QVERIFY(event1.accessibleInterface() != nullptr);
+ QVERIFY(event2.accessibleInterface() != nullptr);
+ QCOMPARE(event1.accessibleInterface(), event2.accessibleInterface());
+
+ // set same child for both
+ event1.setChild(0);
+ event2.setChild(0);
+
+ QVERIFY(event1.accessibleInterface() != nullptr);
+ QVERIFY(event2.accessibleInterface() != nullptr);
+ QCOMPARE(event1.accessibleInterface(), event2.accessibleInterface());
+}
+
void tst_QAccessibility::customWidget()
{
{
@@ -630,7 +665,7 @@ void tst_QAccessibility::textAttributes_data()
defaultComplexFont.setStyle(QFont::StyleItalic);
defaultComplexFont.setUnderline(true);
- static QStringList defaults = QString("font-style:normal;font-weight:normal;text-align:left;text-position:baseline;font-size:13pt").split(';');
+ static QStringList defaults = QString("font-style:normal;font-weight:normal;text-align:left;text-position:baseline;font-size:13pt;text-line-through-type:none").split(';');
static QStringList bold = defaults;
bold[1] = QString::fromLatin1("font-weight:bold");
@@ -666,7 +701,7 @@ void tst_QAccessibility::textAttributes_data()
defaultFontDifferentBoldItalic[1] = QString::fromLatin1("font-weight:bold");
static QStringList defaultFontDifferentMonospace = defaultFontDifferent;
- defaultFontDifferentMonospace[7] = (QLatin1String("font-family:\"monospace\""));
+ defaultFontDifferentMonospace[8] = (QLatin1String("font-family:\"monospace\""));
static QStringList defaultFontDifferentFont8pt = defaultFontDifferent;
defaultFontDifferentFont8pt[4] = (QLatin1String("font-size:8pt"));
@@ -753,7 +788,7 @@ void tst_QAccessibility::textAttributes()
QAccessibleInterface *interface = QAccessible::queryAccessibleInterface(&textEdit);
QAccessibleTextInterface *textInterface=interface->textInterface();
QVERIFY(textInterface);
- QCOMPARE(textInterface->characterCount(), textEdit.toPlainText().length());
+ QCOMPARE(textInterface->characterCount(), textEdit.toPlainText().size());
int startOffset = -1;
int endOffset = -1;
@@ -886,7 +921,7 @@ void tst_QAccessibility::applicationTest()
QWidget widget;
widget.show();
- qApp->setActiveWindow(&widget);
+ QApplicationPrivate::setActiveWindow(&widget);
QVERIFY(QTest::qWaitForWindowActive(&widget));
QAccessibleInterface *widgetIface = QAccessible::queryAccessibleInterface(&widget);
@@ -913,7 +948,7 @@ void tst_QAccessibility::mainWindowTest()
auto mw = mwHolder.get();
mw->resize(300, 200);
mw->show(); // triggers layout
- qApp->setActiveWindow(mw);
+ QApplicationPrivate::setActiveWindow(mw);
QLatin1String name = QLatin1String("I am the main window");
mw->setWindowTitle(name);
@@ -1084,7 +1119,10 @@ void tst_QAccessibility::buttonTest()
interface = QAccessible::queryAccessibleInterface(&toggleButton);
actionInterface = interface->actionInterface();
QCOMPARE(interface->role(), QAccessible::CheckBox);
- QCOMPARE(actionInterface->actionNames(), QStringList() << QAccessibleActionInterface::toggleAction() << QAccessibleActionInterface::setFocusAction());
+ QCOMPARE(actionInterface->actionNames(),
+ QStringList() << QAccessibleActionInterface::toggleAction()
+ << QAccessibleActionInterface::pressAction()
+ << QAccessibleActionInterface::setFocusAction());
QCOMPARE(actionInterface->localizedActionDescription(QAccessibleActionInterface::toggleAction()), QString("Toggles the state"));
QVERIFY(!toggleButton.isChecked());
QVERIFY(!interface->state().checked);
@@ -1120,12 +1158,18 @@ void tst_QAccessibility::buttonTest()
interface = QAccessible::queryAccessibleInterface(&checkBox);
actionInterface = interface->actionInterface();
QCOMPARE(interface->role(), QAccessible::CheckBox);
- QCOMPARE(actionInterface->actionNames(), QStringList() << QAccessibleActionInterface::toggleAction() << QAccessibleActionInterface::setFocusAction());
+ QCOMPARE(actionInterface->actionNames(),
+ QStringList() << QAccessibleActionInterface::toggleAction()
+ << QAccessibleActionInterface::pressAction()
+ << QAccessibleActionInterface::setFocusAction());
QVERIFY(!interface->state().checked);
actionInterface->doAction(QAccessibleActionInterface::toggleAction());
QTest::qWait(500);
- QCOMPARE(actionInterface->actionNames(), QStringList() << QAccessibleActionInterface::toggleAction() << QAccessibleActionInterface::setFocusAction());
+ QCOMPARE(actionInterface->actionNames(),
+ QStringList() << QAccessibleActionInterface::toggleAction()
+ << QAccessibleActionInterface::pressAction()
+ << QAccessibleActionInterface::setFocusAction());
QVERIFY(interface->state().checked);
QVERIFY(checkBox.isChecked());
QAccessible::State st;
@@ -1915,7 +1959,7 @@ void tst_QAccessibility::mdiAreaTest()
mdiArea.addSubWindow(new QWidget, Qt::Dialog)->show();
QList<QMdiSubWindow *> subWindows = mdiArea.subWindowList();
- QCOMPARE(subWindows.count(), subWindowCount);
+ QCOMPARE(subWindows.size(), subWindowCount);
QAccessibleInterface *interface = QAccessible::queryAccessibleInterface(&mdiArea);
QVERIFY(interface);
@@ -1930,7 +1974,7 @@ void tst_QAccessibility::mdiSubWindowTest()
{
QMdiArea mdiArea;
mdiArea.show();
- qApp->setActiveWindow(&mdiArea);
+ QApplicationPrivate::setActiveWindow(&mdiArea);
QVERIFY(QTest::qWaitForWindowActive(&mdiArea));
@@ -1953,7 +1997,7 @@ void tst_QAccessibility::mdiSubWindowTest()
}
QList<QMdiSubWindow *> subWindows = mdiArea.subWindowList();
- QCOMPARE(subWindows.count(), subWindowCount);
+ QCOMPARE(subWindows.size(), subWindowCount);
QMdiSubWindow *testWindow = subWindows.at(3);
QVERIFY(testWindow);
@@ -1998,7 +2042,7 @@ void tst_QAccessibility::mdiSubWindowTest()
testWindow->setEnabled(false);
QVERIFY(interface->state().disabled);
testWindow->setEnabled(true);
- qApp->setActiveWindow(&mdiArea);
+ QApplicationPrivate::setActiveWindow(&mdiArea);
mdiArea.setActiveSubWindow(testWindow);
testWindow->setFocus();
QVERIFY(testWindow->isAncestorOf(qApp->focusWidget()));
@@ -2077,10 +2121,10 @@ void tst_QAccessibility::lineEditTest()
QCOMPARE(iface->text(QAccessible::Value), QString());
le->setEchoMode(QLineEdit::Password);
QVERIFY(iface->state().passwordEdit);
- QCOMPARE(iface->text(QAccessible::Value), QString(secret.length(), QLatin1Char('*')));
+ QCOMPARE(iface->text(QAccessible::Value), QString(secret.size(), QLatin1Char('*')));
le->setEchoMode(QLineEdit::PasswordEchoOnEdit);
QVERIFY(iface->state().passwordEdit);
- QCOMPARE(iface->text(QAccessible::Value), QString(secret.length(), QLatin1Char('*')));
+ QCOMPARE(iface->text(QAccessible::Value), QString(secret.size(), QLatin1Char('*')));
le->setEchoMode(QLineEdit::Normal);
QVERIFY(!(iface->state().passwordEdit));
QCOMPARE(iface->text(QAccessible::Value), secret);
@@ -2172,7 +2216,7 @@ void tst_QAccessibility::lineEditTest()
QCOMPARE(textIface->textAtOffset(5, QAccessible::ParagraphBoundary,&start,&end), cite);
QCOMPARE(start, 0);
- QCOMPARE(end, cite.length());
+ QCOMPARE(end, cite.size());
QCOMPARE(textIface->textAtOffset(5, QAccessible::LineBoundary,&start,&end), cite);
QCOMPARE(textIface->textAtOffset(5, QAccessible::NoBoundary,&start,&end), cite);
@@ -2216,8 +2260,8 @@ void tst_QAccessibility::lineEditTest()
QVERIFY_EVENT(&sel);
lineEdit->selectAll();
- sel.setSelection(0, lineEdit->text().length());
- sel.setCursorPosition(lineEdit->text().length());
+ sel.setSelection(0, lineEdit->text().size());
+ sel.setCursorPosition(lineEdit->text().size());
QVERIFY_EVENT(&sel);
lineEdit->setSelection(10, -4);
@@ -2573,7 +2617,7 @@ void tst_QAccessibility::dialogButtonBoxTest()
std::sort(buttons.begin(), buttons.end(), accessibleInterfaceLeftOf);
- for (int i = 0; i < buttons.count(); ++i)
+ for (int i = 0; i < buttons.size(); ++i)
actualOrder << buttons.at(i)->text(QAccessible::Name);
QStringList expectedOrder;
@@ -2625,7 +2669,7 @@ void tst_QAccessibility::dialogButtonBoxTest()
std::sort(buttons.begin(), buttons.end(), accessibleInterfaceAbove);
- for (int i = 0; i < buttons.count(); ++i)
+ for (int i = 0; i < buttons.size(); ++i)
actualOrder << buttons.at(i)->text(QAccessible::Name);
QStringList expectedOrder;
@@ -2835,6 +2879,12 @@ void tst_QAccessibility::listTest()
QCOMPARE(iface->indexOfChild(child3), 2);
QCOMPARE(child3->text(QAccessible::Name), QString("Brisbane"));
}
+
+ // Check that application is accessible parent, since it's a top-level widget
+ QAccessibleInterface *parentIface = iface->parent();
+ QVERIFY(parentIface);
+ QVERIFY(parentIface->role() == QAccessible::Application);
+
QTestAccessibility::clearEvents();
// Check for events
@@ -2886,7 +2936,8 @@ void tst_QAccessibility::listTest()
QVERIFY(!(cell4->state().expandable));
QVERIFY( (cell4->state().selectable));
QVERIFY(!(cell4->state().selected));
- table2->selectRow(3);
+ QAccessibleSelectionInterface *selection2 = iface->selectionInterface();
+ selection2->select(cell4);
QCOMPARE(listView->selectedItems().size(), 1);
QCOMPARE(listView->selectedItems().at(0)->text(), QLatin1String("Munich"));
QVERIFY(cell4->state().selected);
@@ -3357,6 +3408,70 @@ void tst_QAccessibility::tableTest()
QTestAccessibility::clearEvents();
}
+void tst_QAccessibility::rootIndexView()
+{
+ QStandardItemModel model;
+ for (int i = 0; i < 2; ++i) {
+ QStandardItem *item = new QStandardItem(u"root %1"_s.arg(i));
+ for (int j = 0; j < 5 * (i + 1); ++j) {
+ switch (i) {
+ case 0:
+ item->appendRow(new QStandardItem(u"child0/%1"_s.arg(j)));
+ break;
+ case 1:
+ item->appendRow({new QStandardItem(u"column0 1/%1"_s.arg(j)),
+ new QStandardItem(u"column1 1/%1"_s.arg(j))
+ });
+ break;
+ }
+ }
+ model.appendRow(item);
+ }
+
+ QListView view;
+ view.setModel(&model);
+ QTestAccessibility::clearEvents();
+
+ QAccessibleInterface *accView = QAccessible::queryAccessibleInterface(&view);
+ QVERIFY(accView);
+ QAccessibleTableInterface *accTable = accView->tableInterface();
+ QVERIFY(accTable);
+ QCOMPARE(accTable->rowCount(), 2);
+ QCOMPARE(accTable->columnCount(), 1);
+
+ view.setRootIndex(model.index(0, 0));
+ QAccessibleTableModelChangeEvent resetEvent(&view, QAccessibleTableModelChangeEvent::ModelReset);
+ QVERIFY(QTestAccessibility::containsEvent(&resetEvent));
+
+ QCOMPARE(accTable->rowCount(), 5);
+ QCOMPARE(accTable->columnCount(), 1);
+
+ view.setRootIndex(model.index(1, 0));
+ QCOMPARE(accTable->rowCount(), 10);
+ QCOMPARE(accTable->columnCount(), 2);
+
+ QTestAccessibility::clearEvents();
+}
+
+void tst_QAccessibility::uniqueIdTest()
+{
+ // Test that an ID isn't reassigned to another interface right away when an accessible interface
+ // that has just been created is removed from the cache and deleted before the next
+ // accessible interface is registered.
+ // For example for AT-SPI, that would result in the same object path being used, and thus
+ // data from the old and new interface can get confused due to caching.
+ QWidget widget1;
+ QAccessibleInterface *iface1 = QAccessible::queryAccessibleInterface(&widget1);
+ QAccessible::Id id1 = QAccessible::uniqueId(iface1);
+ QAccessible::deleteAccessibleInterface(id1);
+
+ QWidget widget2;
+ QAccessibleInterface *iface2 = QAccessible::queryAccessibleInterface(&widget2);
+ QAccessible::Id id2 = QAccessible::uniqueId(iface2);
+
+ QVERIFY(id1 != id2);
+}
+
void tst_QAccessibility::calendarWidgetTest()
{
#if QT_CONFIG(calendarwidget)
@@ -3384,7 +3499,7 @@ void tst_QAccessibility::calendarWidgetTest()
QCOMPARE(interface->rect(), globalGeometry);
QWidget *navigationBar = 0;
- foreach (QObject *child, calendarWidget.children()) {
+ for (QObject *child : calendarWidget.children()) {
if (child->objectName() == QLatin1String("qt_calendar_navigationbar")) {
navigationBar = static_cast<QWidget *>(child);
break;
@@ -3394,7 +3509,7 @@ void tst_QAccessibility::calendarWidgetTest()
QVERIFY(verifyChild(navigationBar, interface, 0, globalGeometry));
QAbstractItemView *calendarView = 0;
- foreach (QObject *child, calendarWidget.children()) {
+ for (QObject *child : calendarWidget.children()) {
if (child->objectName() == QLatin1String("qt_calendar_calendarview")) {
calendarView = static_cast<QAbstractItemView *>(child);
break;
@@ -3596,6 +3711,8 @@ void tst_QAccessibility::comboBoxTest()
QCOMPARE(iface->text(QAccessible::Name), QLatin1String("one"));
#endif
QCOMPARE(iface->text(QAccessible::Value), QLatin1String("one"));
+ QCOMPARE(combo.view()->selectionModel()->currentIndex().row(), 0);
+
combo.setCurrentIndex(2);
#ifdef Q_OS_UNIX
QCOMPARE(iface->text(QAccessible::Name), QLatin1String("three"));
@@ -3606,7 +3723,13 @@ void tst_QAccessibility::comboBoxTest()
QCOMPARE(listIface->role(), QAccessible::List);
QCOMPARE(listIface->childCount(), 3);
+ QAccessibleSelectionInterface *selectionIface = listIface->selectionInterface();
+ QVERIFY(selectionIface);
+ QCOMPARE(selectionIface->selectedItemCount(), 1);
+ QCOMPARE(listIface->indexOfChild(selectionIface->selectedItem(0)), 2);
+
QVERIFY(!combo.view()->isVisible());
+ QCOMPARE(combo.view()->selectionModel()->currentIndex().row(), 2);
QVERIFY(iface->actionInterface());
QCOMPARE(iface->actionInterface()->actionNames(), QStringList() << QAccessibleActionInterface::showMenuAction() << QAccessibleActionInterface::pressAction());
iface->actionInterface()->doAction(QAccessibleActionInterface::showMenuAction());
@@ -3636,6 +3759,69 @@ void tst_QAccessibility::comboBoxTest()
QTestAccessibility::clearEvents();
}
+void tst_QAccessibility::relationTest()
+{
+ auto windowHolder = std::make_unique<QWidget>();
+ auto window = windowHolder.get();
+ QString text = "Hello World";
+ QLabel *label = new QLabel(text, window);
+ setFrameless(label);
+ QSpinBox *spinBox = new QSpinBox(window);
+ label->setBuddy(spinBox);
+ QProgressBar *pb = new QProgressBar(window);
+ pb->setRange(0, 99);
+ connect(spinBox, SIGNAL(valueChanged(int)), pb, SLOT(setValue(int)));
+
+ window->resize(320, 200);
+ window->show();
+
+ QVERIFY(QTest::qWaitForWindowExposed(window));
+#if defined(Q_OS_UNIX)
+ QCoreApplication::processEvents();
+#endif
+ QTest::qWait(100);
+
+ QAccessibleInterface *acc_label = QAccessible::queryAccessibleInterface(label);
+ QVERIFY(acc_label);
+ QAccessibleInterface *acc_spinBox = QAccessible::queryAccessibleInterface(spinBox);
+ QVERIFY(acc_spinBox);
+ QAccessibleInterface *acc_pb = QAccessible::queryAccessibleInterface(pb);
+ QVERIFY(acc_pb);
+
+ typedef QPair<QAccessibleInterface*, QAccessible::Relation> RelationPair;
+ {
+ const QList<RelationPair> rels = acc_label->relations(QAccessible::Labelled);
+ QCOMPARE(rels.size(), 1);
+ const RelationPair relPair = rels.first();
+
+ // spinBox is Labelled by acc_label
+ QCOMPARE(relPair.first->object(), spinBox);
+ QCOMPARE(relPair.second, QAccessible::Labelled);
+ }
+
+ {
+ // Test multiple relations (spinBox have two)
+ const QList<RelationPair> rels = acc_spinBox->relations();
+ QCOMPARE(rels.size(), 2);
+ int visitCount = 0;
+ for (const auto &relPair : rels) {
+ if (relPair.second & QAccessible::Label) {
+ // label is the Label of spinBox
+ QCOMPARE(relPair.first->object(), label);
+ ++visitCount;
+ } else if (relPair.second & QAccessible::Controlled) {
+ // progressbar is Controlled by the spinBox
+ QCOMPARE(relPair.first->object(), pb);
+ ++visitCount;
+ }
+ }
+ QCOMPARE(visitCount, rels.size());
+ }
+
+ windowHolder.reset();
+ QTestAccessibility::clearEvents();
+}
+
#if QT_CONFIG(shortcut)
void tst_QAccessibility::labelTest()
@@ -3658,6 +3844,8 @@ void tst_QAccessibility::labelTest()
QAccessibleInterface *acc_label = QAccessible::queryAccessibleInterface(label);
QVERIFY(acc_label);
+ QAccessibleInterface *acc_lineEdit = QAccessible::queryAccessibleInterface(buddy);
+ QVERIFY(acc_lineEdit);
QCOMPARE(acc_label->text(QAccessible::Name), text);
QCOMPARE(acc_label->state().editable, false);
@@ -3667,13 +3855,23 @@ void tst_QAccessibility::labelTest()
QCOMPARE(acc_label->state().focusable, false);
QCOMPARE(acc_label->state().readOnly, true);
- QList<QPair<QAccessibleInterface *, QAccessible::Relation>> rels = acc_label->relations();
- QCOMPARE(rels.count(), 1);
- QAccessibleInterface *iface = rels.first().first;
- QAccessible::Relation rel = rels.first().second;
- QCOMPARE(rel, QAccessible::Labelled);
- QCOMPARE(iface->role(), QAccessible::EditableText);
+ typedef QPair<QAccessibleInterface*, QAccessible::Relation> RelationPair;
+ {
+ const QList<RelationPair> rels = acc_label->relations(QAccessible::Labelled);
+ QCOMPARE(rels.size(), 1);
+ const RelationPair relPair = rels.first();
+ QCOMPARE(relPair.first->object(), buddy);
+ QCOMPARE(relPair.second, QAccessible::Labelled);
+ }
+
+ {
+ const QList<RelationPair> rels = acc_lineEdit->relations(QAccessible::Label);
+ QCOMPARE(rels.size(), 1);
+ const RelationPair relPair = rels.first();
+ QCOMPARE(relPair.first->object(), label);
+ QCOMPARE(relPair.second, QAccessible::Label);
+ }
windowHolder.reset();
QTestAccessibility::clearEvents();
@@ -3769,6 +3967,7 @@ void tst_QAccessibility::bridgeTest()
// For now this is a simple test to see if the bridge is working at all.
// Ideally it should be extended to test all aspects of the bridge.
#if defined(Q_OS_WIN)
+ auto guard = qScopeGuard([]() { QTestAccessibility::clearEvents(); });
QWidget window;
QVBoxLayout *lay = new QVBoxLayout(&window);
@@ -3817,14 +4016,14 @@ void tst_QAccessibility::bridgeTest()
POINT pt{nativePos.x(), nativePos.y()};
// Initialize COM stuff.
- HRESULT hr = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
- QVERIFY(SUCCEEDED(hr));
+ QComHelper comHelper;
+ QVERIFY(comHelper.isValid());
// Get UI Automation interface.
const GUID CLSID_CUIAutomation_test{0xff48dba4, 0x60ef, 0x4201,
{0xaa,0x87, 0x54,0x10,0x3e,0xef,0x59,0x4e}};
IUIAutomation *automation = nullptr;
- hr = CoCreateInstance(CLSID_CUIAutomation_test, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&automation));
+ HRESULT hr = CoCreateInstance(CLSID_CUIAutomation_test, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&automation));
QVERIFY(SUCCEEDED(hr));
// Get button element from UI Automation using point.
@@ -3906,10 +4105,105 @@ void tst_QAccessibility::bridgeTest()
QCOMPARE(controlTypeId, UIA_ButtonControlTypeId);
// Edit
- hr = nodeList.at(2)->get_CurrentControlType(&controlTypeId);
+ IUIAutomationElement *uiaElement = nodeList.at(2);
+ hr = uiaElement->get_CurrentControlType(&controlTypeId);
QVERIFY(SUCCEEDED(hr));
QCOMPARE(controlTypeId, UIA_EditControlTypeId);
+ // "hello world\nhow are you today?\n"
+ IUIAutomationTextPattern *textPattern = nullptr;
+ hr = uiaElement->GetCurrentPattern(UIA_TextPattern2Id, reinterpret_cast<IUnknown**>(&textPattern));
+ QVERIFY(SUCCEEDED(hr));
+ QVERIFY(textPattern);
+
+ IUIAutomationTextRange *docRange = nullptr;
+ hr = textPattern->get_DocumentRange(&docRange);
+ QVERIFY(SUCCEEDED(hr));
+ QVERIFY(docRange);
+
+ IUIAutomationTextRange *textRange = nullptr;
+ hr = docRange->Clone(&textRange);
+ QVERIFY(SUCCEEDED(hr));
+ QVERIFY(textRange);
+ int moved;
+
+ auto rangeText = [](IUIAutomationTextRange *textRange) {
+ BSTR str;
+ QString res = "IUIAutomationTextRange::GetText() failed";
+ HRESULT hr = textRange->GetText(-1, &str);
+ if (SUCCEEDED(hr)) {
+ res = QString::fromWCharArray(str);
+ ::SysFreeString(str);
+ }
+ return res;
+ };
+
+ // Move start endpoint past "hello " to "world"
+ hr = textRange->Move(TextUnit_Character, 6, &moved);
+ QVERIFY(SUCCEEDED(hr));
+ QCOMPARE(moved, 6);
+ // If the range was not empty, it should be collapsed to contain a single text unit
+ QCOMPARE(rangeText(textRange), QString("w"));
+
+ // Move end endpoint to end of "world"
+ hr = textRange->MoveEndpointByUnit(TextPatternRangeEndpoint_End, TextUnit_Character, 4, &moved);
+ QVERIFY(SUCCEEDED(hr));
+ QCOMPARE(moved, 4);
+ QCOMPARE(rangeText(textRange), QString("world"));
+
+ // MSDN: "Zero has no effect". This behavior was also verified with native controls.
+ hr = textRange->Move(TextUnit_Character, 0, &moved);
+ QVERIFY(SUCCEEDED(hr));
+ QCOMPARE(moved, 0);
+ QCOMPARE(rangeText(textRange), QString("world"));
+
+ hr = textRange->Move(TextUnit_Character, 1, &moved);
+ QVERIFY(SUCCEEDED(hr));
+ QCOMPARE(rangeText(textRange), QString("o"));
+
+ // move as far towards the end as possible
+ hr = textRange->Move(TextUnit_Character, 999, &moved);
+ QVERIFY(SUCCEEDED(hr));
+ QCOMPARE(rangeText(textRange), QString(""));
+
+ hr = textRange->MoveEndpointByUnit(TextPatternRangeEndpoint_Start, TextUnit_Character, -1, &moved);
+ QVERIFY(SUCCEEDED(hr));
+ QCOMPARE(rangeText(textRange), QString("\n"));
+
+ // move one forward (last possible position again)
+ hr = textRange->Move(TextUnit_Character, 1, &moved);
+ QVERIFY(SUCCEEDED(hr));
+ QCOMPARE(rangeText(textRange), QString(""));
+
+ hr = textRange->Move(TextUnit_Character, -7, &moved);
+ QVERIFY(SUCCEEDED(hr));
+ QCOMPARE(moved, -7);
+ QCOMPARE(rangeText(textRange), QString(""));
+ // simulate moving cursor (empty range) towards (and past) the end
+ QString today(" today?\n");
+ for (int i = 1; i < 9; ++i) { // 9 is deliberately too much
+ // peek one character back
+ hr = textRange->MoveEndpointByUnit(TextPatternRangeEndpoint_Start, TextUnit_Character, -1, &moved);
+ QVERIFY(SUCCEEDED(hr));
+ QCOMPARE(rangeText(textRange), today.mid(i - 1, 1));
+
+ hr = textRange->Move(TextUnit_Character, 1, &moved);
+ QVERIFY(SUCCEEDED(hr));
+ QCOMPARE(rangeText(textRange), today.mid(i, moved)); // when we cannot move further, moved will be 0
+
+ // Make the range empty again
+ hr = textRange->MoveEndpointByUnit(TextPatternRangeEndpoint_End, TextUnit_Character, -moved, &moved);
+ QVERIFY(SUCCEEDED(hr));
+
+ // advance the empty range
+ hr = textRange->Move(TextUnit_Character, 1, &moved);
+ QVERIFY(SUCCEEDED(hr));
+ }
+ docRange->Release();
+ textRange->Release();
+ textPattern->Release();
+
+
// Table
hr = nodeList.at(3)->get_CurrentControlType(&controlTypeId);
QVERIFY(SUCCEEDED(hr));
@@ -3927,9 +4221,6 @@ void tst_QAccessibility::bridgeTest()
controlWalker->Release();
windowElement->Release();
automation->Release();
- CoUninitialize();
-
- QTestAccessibility::clearEvents();
#endif
}
@@ -4020,6 +4311,9 @@ private:
void tst_QAccessibility::focusChild()
{
+ if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))
+ QSKIP("Platform does not support window activation");
+
{
QMainWindow mainWindow;
QtTestAccessibleWidget *widget1 = new QtTestAccessibleWidget(0, "Widget1");
@@ -4125,7 +4419,7 @@ void tst_QAccessibility::focusChild()
spy.clear();
tableView->setCurrentCell(2, 1);
- QTRY_COMPARE(spy.count(), 1);
+ QTRY_COMPARE(spy.size(), 1);
QAccessibleInterface *child = iface->focusChild();
QVERIFY(child);
@@ -4133,7 +4427,7 @@ void tst_QAccessibility::focusChild()
spy.clear();
tableView->setCurrentCell(1, 2);
- QTRY_COMPARE(spy.count(), 1);
+ QTRY_COMPARE(spy.size(), 1);
child = iface->focusChild();
QVERIFY(child);
@@ -4185,7 +4479,7 @@ void tst_QAccessibility::focusChild()
spy.clear();
treeView->setCurrentItem(item2);
- QTRY_COMPARE(spy.count(), 1);
+ QTRY_COMPARE(spy.size(), 1);
QAccessibleInterface *child = iface->focusChild();
QVERIFY(child);
@@ -4193,12 +4487,53 @@ void tst_QAccessibility::focusChild()
spy.clear();
treeView->setCurrentItem(item3);
- QTRY_COMPARE(spy.count(), 1);
+ QTRY_COMPARE(spy.size(), 1);
child = iface->focusChild();
QVERIFY(child);
QCOMPARE(child->text(QAccessible::Name), QStringLiteral("Klimt"));
}
+ {
+ QWidget window;
+ // takes the initial focus
+ QLineEdit lineEdit;
+ QComboBox comboBox;
+ comboBox.addItems({"One", "Two", "Three"});
+ QComboBox editableComboBox;
+ editableComboBox.setEditable(true);
+ editableComboBox.addItems({"A", "B", "C"});
+ QVBoxLayout vbox;
+ vbox.addWidget(&lineEdit);
+ vbox.addWidget(&comboBox);
+ vbox.addWidget(&editableComboBox);
+ window.setLayout(&vbox);
+
+ window.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&window));
+ QTestAccessibility::clearEvents();
+ QAccessibleInterface *iface = nullptr;
+
+ comboBox.setFocus();
+ {
+ QAccessibleEvent focusEvent(&comboBox, QAccessible::Focus);
+ QVERIFY(QTestAccessibility::containsEvent(&focusEvent));
+ }
+ iface = QAccessible::queryAccessibleInterface(&comboBox);
+ QVERIFY(iface);
+ QCOMPARE(iface->focusChild(), nullptr);
+
+ editableComboBox.setFocus();
+ // Qt updates about the editable combobox, not the lineedit, as the
+ // combobox is the lineedit's focus proxy.
+ {
+ QAccessibleEvent focusEvent(&editableComboBox, QAccessible::Focus);
+ QVERIFY(QTestAccessibility::containsEvent(&focusEvent));
+ }
+ iface = QAccessible::queryAccessibleInterface(&editableComboBox);
+ QVERIFY(iface);
+ QVERIFY(iface->focusChild());
+ QCOMPARE(iface->focusChild()->role(), QAccessible::EditableText);
+ }
}
void tst_QAccessibility::messageBoxTest_data()
@@ -4288,20 +4623,10 @@ void tst_QAccessibility::messageBoxTest()
if (!boxPrivate->canBeNativeDialog()) {
// platforms that use a native message box will not emit accessibility events
box.show();
- QVERIFY(QTest::qWaitForWindowActive(&box));
QAccessibleEvent showEvent(&box, QAccessible::DialogStart);
QVERIFY(QTestAccessibility::containsEvent(&showEvent));
- // on some platforms, like macOS, not all widgets get key board focus; we
- // only care about a push button getting focus
- if (QTest::qWaitFor([&box]{ return qobject_cast<QPushButton *>(box.focusWidget()); }, 1000)) {
- // a widget that gets focus through window activation should not emit an accessibility
- // notification
- QAccessibleEvent focusEvent(box.focusWidget(), QAccessible::Focus);
- QVERIFY(!QTestAccessibility::containsEvent(&focusEvent));
- }
-
box.hide();
QAccessibleEvent hideEvent(&box, QAccessible::DialogEnd);
diff --git a/tests/auto/other/qaccessibilitylinux/CMakeLists.txt b/tests/auto/other/qaccessibilitylinux/CMakeLists.txt
index 2033d810fd..5c85827a3b 100644
--- a/tests/auto/other/qaccessibilitylinux/CMakeLists.txt
+++ b/tests/auto/other/qaccessibilitylinux/CMakeLists.txt
@@ -1,13 +1,16 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+# SPDX-License-Identifier: BSD-3-Clause
+
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qaccessibilitylinux LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
-# Generated from qaccessibilitylinux.pro.
-# special case begin
if (NOT QT_FEATURE_accessibility OR NOT TARGET Qt::LinuxAccessibilitySupportPrivate
OR (QT_BUILD_STANDALONE_TESTS AND QT_WILL_INSTALL))
return()
endif()
-# special case end
#####################################################################
## tst_qaccessibilitylinux Test:
@@ -26,9 +29,7 @@ qt_internal_add_test(tst_qaccessibilitylinux
Qt::Widgets
)
-# special case begin
# require for struct_marshallers_p.h which is included dbus_interface.h
target_include_directories(tst_qaccessibilitylinux PRIVATE
../../../../src/platformsupport/linuxaccessibility
)
-# special case end
diff --git a/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp b/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
index beb0a0805a..18bcdeca29 100644
--- a/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp
+++ b/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.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 <QTest>
#include <QtGui>
@@ -103,7 +103,7 @@ QStringList tst_QAccessibilityLinux::getChildren(QDBusInterface *interface)
Q_ASSERT(interface->property("ChildCount").toInt() == list.count());
QStringList children;
- Q_FOREACH (const QSpiObjectReference &ref, list)
+ for (const QSpiObjectReference &ref : std::as_const(list))
children << ref.path.path();
return children;
@@ -154,6 +154,7 @@ void tst_QAccessibilityLinux::initTestCase()
QVERIFY(!address.isEmpty());
m_window = new AccessibleTestWindow();
+ m_window->setObjectName("mainWindow"_L1);
m_window->show();
QVERIFY(QTest::qWaitForWindowExposed(m_window));
@@ -211,8 +212,11 @@ bool hasState(QDBusInterface *interface, AtspiStateType state)
void tst_QAccessibilityLinux::testLabel()
{
QLabel *l = new QLabel(m_window);
+ l->setObjectName("theObjectName"_L1);
l->setText("Hello A11y");
m_window->addWidget(l);
+ auto a11yEmpty = new QLabel(m_window);
+ m_window->addWidget(l);
// Application
QCOMPARE(getParent(mainWindow), QLatin1String(ATSPI_DBUS_PATH_ROOT));
@@ -224,6 +228,8 @@ void tst_QAccessibilityLinux::testLabel()
QCOMPARE(getChildren(labelInterface).count(), 0);
QCOMPARE(labelInterface->call(QDBus::Block, "GetRoleName").arguments().first().toString(), QLatin1String("label"));
QCOMPARE(labelInterface->call(QDBus::Block, "GetRole").arguments().first().toUInt(), 29u);
+ QCOMPARE(labelInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
+ "mainWindow.theObjectName"_L1);
QCOMPARE(getParent(labelInterface), mainWindow->path());
QVERIFY(!hasState(labelInterface, ATSPI_STATE_EDITABLE));
QVERIFY(hasState(labelInterface, ATSPI_STATE_READ_ONLY));
@@ -231,7 +237,12 @@ void tst_QAccessibilityLinux::testLabel()
l->setText("New text");
QCOMPARE(labelInterface->property("Name").toString(), l->text());
+ auto *a11yEmptyInterface = getInterface(children.at(1), "org.a11y.atspi.Accessible");
+ QCOMPARE(a11yEmptyInterface->call(QDBus::Block, "GetAccessibleId").arguments().first().toString(),
+ "mainWindow.QLabel"_L1);
+
m_window->clearChildren();
+ delete a11yEmptyInterface;
delete labelInterface;
}
diff --git a/tests/auto/other/qaccessibilitymac/CMakeLists.txt b/tests/auto/other/qaccessibilitymac/CMakeLists.txt
index d475c6cba3..66896ed384 100644
--- a/tests/auto/other/qaccessibilitymac/CMakeLists.txt
+++ b/tests/auto/other/qaccessibilitymac/CMakeLists.txt
@@ -1,35 +1,22 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+# SPDX-License-Identifier: BSD-3-Clause
-# Generated from qaccessibilitymac.pro.
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qaccessibilitymac LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
if(NOT APPLE)
return()
endif()
-#####################################################################
-## tst_qaccessibilitymac Test:
-#####################################################################
-
qt_internal_add_test(tst_qaccessibilitymac
SOURCES
- tst_qaccessibilitymac.cpp
- tst_qaccessibilitymac_helpers.h
+ tst_qaccessibilitymac.mm
LIBRARIES
Qt::Gui
Qt::Widgets
-)
-
-#### Keys ignored in scope 1:.:.:qaccessibilitymac.pro:<TRUE>:
-# _REQUIREMENTS = "mac"
-
-## Scopes:
-#####################################################################
-
-qt_internal_extend_target(tst_qaccessibilitymac CONDITION APPLE
- SOURCES
- tst_qaccessibilitymac_helpers.mm
- LIBRARIES
${FWAppKit}
${FWApplicationServices}
${FWSecurity}
diff --git a/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac.cpp b/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac.cpp
deleted file mode 100644
index 2141869f16..0000000000
--- a/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac.cpp
+++ /dev/null
@@ -1,125 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-
-#include <QApplication>
-#include <QtWidgets>
-#include <QTest>
-#include <QtCore/qcoreapplication.h>
-
-#include "tst_qaccessibilitymac_helpers.h"
-
-QT_USE_NAMESPACE
-
-
-class AccessibleTestWindow : public QWidget
-{
- Q_OBJECT
-public:
- AccessibleTestWindow()
- {
- new QHBoxLayout(this);
- }
-
- void addWidget(QWidget* widget)
- {
- layout()->addWidget(widget);
- widget->show();
- QVERIFY(QTest::qWaitForWindowExposed(widget));
- }
-
- void clearChildren()
- {
- qDeleteAll(children());
- new QHBoxLayout(this);
- }
-};
-
-class tst_QAccessibilityMac : public QObject
-{
-Q_OBJECT
-private slots:
- void init();
- void cleanup();
-
- void singleWidgetTest();
- void lineEditTest();
- void hierarchyTest();
- void notificationsTest();
- void checkBoxTest();
-
-private:
- AccessibleTestWindow *m_window;
-};
-
-
-void tst_QAccessibilityMac::init()
-{
- m_window = new AccessibleTestWindow();
- m_window->setWindowTitle("Test window");
- m_window->show();
- m_window->resize(400, 400);
-
- QVERIFY(QTest::qWaitForWindowExposed(m_window));
-}
-
-void tst_QAccessibilityMac::cleanup()
-{
- delete m_window;
-}
-
-void tst_QAccessibilityMac::singleWidgetTest()
-{
- delete m_window;
- m_window = 0;
-
- QVERIFY(singleWidget());
-}
-
-void tst_QAccessibilityMac::lineEditTest()
-{
- QLineEdit *lineEdit = new QLineEdit(m_window);
- lineEdit->setText("a11y test QLineEdit");
- m_window->addWidget(lineEdit);
- QVERIFY(QTest::qWaitForWindowExposed(m_window));
- QCoreApplication::processEvents();
-
- QVERIFY(testLineEdit());
-}
-
-void tst_QAccessibilityMac::hierarchyTest()
-{
- QWidget *w = new QWidget(m_window);
- m_window->addWidget(w);
-
- w->setLayout(new QVBoxLayout());
- QPushButton *b = new QPushButton(w);
- w->layout()->addWidget(b);
- b->setText("I am a button");
-
- QPushButton *b2 = new QPushButton(w);
- w->layout()->addWidget(b2);
- b2->setText("Button 2");
-
- QVERIFY(QTest::qWaitForWindowExposed(m_window));
- QCoreApplication::processEvents();
- QVERIFY(testHierarchy(w));
-}
-
-void tst_QAccessibilityMac::notificationsTest()
-{
- QVERIFY(notifications(m_window));
-}
-
-void tst_QAccessibilityMac::checkBoxTest()
-{
- QCheckBox *cb = new QCheckBox(m_window);
- cb->setText("Great option");
- m_window->addWidget(cb);
- QVERIFY(QTest::qWaitForWindowExposed(m_window));
- QCoreApplication::processEvents();
-
- QVERIFY(testCheckBox(cb));
-}
-
-QTEST_MAIN(tst_QAccessibilityMac)
-#include "tst_qaccessibilitymac.moc"
diff --git a/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac_helpers.mm b/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac.mm
index ceac828eed..4bedd07e15 100644
--- a/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac_helpers.mm
+++ b/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac.mm
@@ -1,10 +1,14 @@
// 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 <QApplication>
+#include <QtWidgets>
+#include <QTest>
+#include <QtCore/qcoreapplication.h>
// some versions of CALayer.h use 'slots' as an identifier
#define QT_NO_KEYWORDS
-#include "tst_qaccessibilitymac_helpers.h"
#include <QtWidgets/qapplication.h>
#include <QtWidgets/qlineedit.h>
#include <QtWidgets/qpushbutton.h>
@@ -55,17 +59,10 @@ QDebug operator<<(QDebug dbg, AXErrorTag err)
return dbg;
}
-#define EXPECT(cond) \
- if (!(cond)) { \
- qWarning("Failure in %s, line: %d", __FILE__ , __LINE__); \
- return false; \
- } \
-
-#define TRY_EXPECT(cond) EXPECT(QTest::qWaitFor([&]{ return (cond); }))
-
@interface TestAXObject : NSObject
{
AXUIElementRef reference;
+ bool axError;
}
@property (readonly) NSString *role;
@property (readonly) NSString *title;
@@ -81,11 +78,13 @@ QDebug operator<<(QDebug dbg, AXErrorTag err)
if ((self = [super init])) {
reference = ref;
+ axError = false;
}
return self;
}
- (AXUIElementRef) ref { return reference; }
+- (bool)errorOccurred { return axError; }
- (void) print {
NSLog(@"Accessible Object role: '%@', title: '%@', description: '%@', value: '%@', rect: '%@'", self.role, self.title, self.description, self.value, NSStringFromRect(NSRectFromCGRect(self.rect)));
NSLog(@" Children: %ld", [[self childList] count]);
@@ -113,6 +112,28 @@ QDebug operator<<(QDebug dbg, AXErrorTag err)
return list;
}
+- (NSArray *)tableRows
+{
+ NSArray *arr;
+ AXUIElementCopyAttributeValues(
+ reference,
+ kAXRowsAttribute,
+ 0, 100, /*min, max*/
+ (CFArrayRef *) &arr);
+ return arr;
+}
+
+- (NSArray *)tableColumns
+{
+ NSArray *arr;
+ AXUIElementCopyAttributeValues(
+ reference,
+ kAXColumnsAttribute,
+ 0, 100, /*min, max*/
+ (CFArrayRef *) &arr);
+ return arr;
+}
+
- (AXUIElementRef) findDirectChildByRole: (CFStringRef) role
{
TestAXObject *result = nil;
@@ -207,8 +228,8 @@ QDebug operator<<(QDebug dbg, AXErrorTag err)
CFTypeRef value = NULL;
AXError err;
- if (kAXErrorSuccess != (err = AXUIElementCopyAttributeValue(reference, attribute, &value)))
- {
+ if (kAXErrorSuccess != (err = AXUIElementCopyAttributeValue(reference, attribute, &value))) {
+ axError = true;
qDebug() << "AXUIElementCopyAttributeValue(" << QString::fromCFString(attribute) << ") returned error = " << AXErrorTag(err);
}
return value;
@@ -254,8 +275,8 @@ QDebug operator<<(QDebug dbg, AXErrorTag err)
CFTypeRef value = NULL;
AXError err;
- if (kAXErrorSuccess != (err = AXUIElementCopyParameterizedAttributeValue(reference, attribute, parameter, &value)))
- {
+ if (kAXErrorSuccess != (err = AXUIElementCopyParameterizedAttributeValue(reference, attribute, parameter, &value))) {
+ axError = true;
CFStringRef description = CFCopyDescription(parameter);
qDebug() << "AXUIElementCopyParameterizedAttributeValue(" << QString::fromCFString(attribute) << ", parameter=" << QString::fromCFString(description) << ") returned error = " << AXErrorTag(err);
CFRelease(description);
@@ -293,8 +314,8 @@ QDebug operator<<(QDebug dbg, AXErrorTag err)
AXError err;
CFArrayRef actions;
- if (kAXErrorSuccess != (err = AXUIElementCopyActionNames(reference, &actions)))
- {
+ if (kAXErrorSuccess != (err = AXUIElementCopyActionNames(reference, &actions))) {
+ axError = true;
qDebug() << "AXUIElementCopyActionNames(...) returned error = " << AXErrorTag(err);
}
@@ -305,8 +326,8 @@ QDebug operator<<(QDebug dbg, AXErrorTag err)
{
AXError err;
- if (kAXErrorSuccess != (err = AXUIElementPerformAction(reference, action)))
- {
+ if (kAXErrorSuccess != (err = AXUIElementPerformAction(reference, action))) {
+ axError = true;
qDebug() << "AXUIElementPerformAction(" << QString::fromCFString(action) << ") returned error = " << AXErrorTag(err);
}
}
@@ -341,66 +362,140 @@ QDebug operator<<(QDebug dbg, AXErrorTag err)
@end
+QVector<int> notificationList;
+
+void observerCallback(AXObserverRef /*observer*/, AXUIElementRef /*element*/, CFStringRef notification, void *)
+{
+ if ([(NSString*)notification isEqualToString: NSAccessibilityFocusedUIElementChangedNotification])
+ notificationList.append(QAccessible::Focus);
+ else if ([(NSString*)notification isEqualToString: NSAccessibilityValueChangedNotification])
+ notificationList.append(QAccessible::ValueChanged);
+ else
+ notificationList.append(-1);
+}
-bool singleWidget()
+class AccessibleTestWindow : public QWidget
{
+ Q_OBJECT
+public:
+ AccessibleTestWindow()
+ {
+ new QHBoxLayout(this);
+ }
+
+ void addWidget(QWidget* widget)
+ {
+ layout()->addWidget(widget);
+ widget->show();
+ QVERIFY(QTest::qWaitForWindowExposed(widget));
+ }
+
+ void clearChildren()
+ {
+ qDeleteAll(children());
+ new QHBoxLayout(this);
+ }
+};
+
+class tst_QAccessibilityMac : public QObject
+{
+Q_OBJECT
+private Q_SLOTS:
+ void init();
+ void cleanup();
+
+ void singleWidgetTest();
+ void lineEditTest();
+ void hierarchyTest();
+ void notificationsTest();
+ void checkBoxTest();
+ void tableViewTest();
+ void treeViewTest();
+
+private:
+ AccessibleTestWindow *m_window;
+};
+
+
+void tst_QAccessibilityMac::init()
+{
+ m_window = new AccessibleTestWindow();
+ m_window->setWindowTitle(QString("Test window - %1").arg(QTest::currentTestFunction()));
+ m_window->show();
+ m_window->resize(400, 400);
+
+ QVERIFY(QTest::qWaitForWindowExposed(m_window));
+}
+
+void tst_QAccessibilityMac::cleanup()
+{
+ delete m_window;
+}
+
+void tst_QAccessibilityMac::singleWidgetTest()
+{
+ delete m_window;
+ m_window = 0;
+
QLineEdit *le = new QLineEdit();
le->setText("button");
le->show();
- EXPECT(QTest::qWaitForWindowExposed(le));
+ QVERIFY(QTest::qWaitForWindowExposed(le));
QCoreApplication::processEvents();
TestAXObject *appObject = [TestAXObject getApplicationAXObject];
- EXPECT(appObject);
+ QVERIFY(appObject);
- NSArray *windows = [appObject windowList];
- EXPECT([windows count] == 1);
+ QTRY_VERIFY(appObject.windowList.count == 1);
- AXUIElementRef windowRef = (AXUIElementRef) [windows objectAtIndex: 0];
- EXPECT(windowRef != nil);
+ AXUIElementRef windowRef = (AXUIElementRef) [appObject.windowList objectAtIndex: 0];
+ QVERIFY(windowRef != nil);
TestAXObject *window = [[TestAXObject alloc] initWithAXUIElementRef: windowRef];
AXUIElementRef lineEditRef = [window findDirectChildByRole: kAXTextFieldRole];
- EXPECT(lineEditRef != nil);
+ QVERIFY(lineEditRef != nil);
TestAXObject *lineEdit = [[TestAXObject alloc] initWithAXUIElementRef: lineEditRef];
- EXPECT([[lineEdit value] isEqualToString:@"button"]);
+ QVERIFY([[lineEdit value] isEqualToString:@"button"]);
// Access invalid reference, should return empty value
delete le;
QCoreApplication::processEvents();
TestAXObject *lineEditInvalid = [[TestAXObject alloc] initWithAXUIElementRef: lineEditRef];
- EXPECT([[lineEditInvalid value] length] == 0);
-
- return true;
+ QVERIFY([[lineEditInvalid value] length] == 0);
}
-bool testLineEdit()
+void tst_QAccessibilityMac::lineEditTest()
{
+ QLineEdit *lineEdit = new QLineEdit(m_window);
+ lineEdit->setText("a11y test QLineEdit");
+ m_window->addWidget(lineEdit);
+ QVERIFY(QTest::qWaitForWindowExposed(m_window));
+ QCoreApplication::processEvents();
+
TestAXObject *appObject = [TestAXObject getApplicationAXObject];
- EXPECT(appObject);
+ QVERIFY(appObject);
- NSArray *windowList = [appObject windowList];
// one window
- EXPECT([windowList count] == 1);
- AXUIElementRef windowRef = (AXUIElementRef) [windowList objectAtIndex: 0];
- EXPECT(windowRef != nil);
+ QTRY_VERIFY(appObject.windowList.count == 1);
+ AXUIElementRef windowRef = (AXUIElementRef) [appObject.windowList objectAtIndex: 0];
+ QVERIFY(windowRef != nil);
TestAXObject *window = [[TestAXObject alloc] initWithAXUIElementRef: windowRef];
- EXPECT([window rect].size.width == 400);
+ QVERIFY([window rect].size.width == 400);
// height of window includes title bar
- EXPECT([window rect].size.height >= 400);
+ QVERIFY([window rect].size.height >= 400);
- EXPECT([window.title isEqualToString:@"Test window"]);
+ QVERIFY([window.title isEqualToString:@"Test window - lineEditTest"]);
// children of window:
- AXUIElementRef lineEdit = [window findDirectChildByRole: kAXTextFieldRole];
- EXPECT(lineEdit != nil);
+ AXUIElementRef lineEditElement = [window findDirectChildByRole: kAXTextFieldRole];
+ QVERIFY(lineEditElement != nil);
- TestAXObject *le = [[TestAXObject alloc] initWithAXUIElementRef: lineEdit];
+ TestAXObject *le = [[TestAXObject alloc] initWithAXUIElementRef: lineEditElement];
NSString *value = @"a11y test QLineEdit";
- EXPECT([le.value isEqualToString:value]);
- EXPECT(value.length <= NSIntegerMax);
- EXPECT(le.numberOfCharacters == static_cast<NSInteger>(value.length));
+ QVERIFY([le.value isEqualToString:value]);
+ QVERIFY(value.length <= NSIntegerMax);
+ QVERIFY(le.numberOfCharacters == static_cast<NSInteger>(value.length));
const NSRange ranges[] = {
{ 0, 0},
{ 0, 1},
@@ -415,82 +510,81 @@ bool testLineEdit()
NSString *expectedSubstring = [value substringWithRange:range];
NSString *actualSubstring = [le stringForRange:range];
NSString *actualAttributedSubstring = [le attributedStringForRange:range].string;
- EXPECT([actualSubstring isEqualTo:expectedSubstring]);
- EXPECT([actualAttributedSubstring isEqualTo:expectedSubstring]);
+ QVERIFY([actualSubstring isEqualTo:expectedSubstring]);
+ QVERIFY([actualAttributedSubstring isEqualTo:expectedSubstring]);
}
- return true;
}
-bool testHierarchy(QWidget *w)
+void tst_QAccessibilityMac::hierarchyTest()
{
+ QWidget *w = new QWidget(m_window);
+ m_window->addWidget(w);
+
+ w->setLayout(new QVBoxLayout());
+ QPushButton *b = new QPushButton(w);
+ w->layout()->addWidget(b);
+ b->setText("I am a button");
+
+ QPushButton *b2 = new QPushButton(w);
+ w->layout()->addWidget(b2);
+ b2->setText("Button 2");
+
+ QVERIFY(QTest::qWaitForWindowExposed(m_window));
+ QCoreApplication::processEvents();
+
TestAXObject *appObject = [TestAXObject getApplicationAXObject];
- EXPECT(appObject);
+ QVERIFY(appObject);
- NSArray *windowList = [appObject windowList];
// one window
- EXPECT([windowList count] == 1);
- AXUIElementRef windowRef = (AXUIElementRef) [windowList objectAtIndex: 0];
- EXPECT(windowRef != nil);
+ QTRY_VERIFY(appObject.windowList.count == 1);
+ AXUIElementRef windowRef = (AXUIElementRef) [appObject.windowList objectAtIndex: 0];
+ QVERIFY(windowRef != nil);
TestAXObject *window = [[TestAXObject alloc] initWithAXUIElementRef: windowRef];
// Because the plain widget is filtered out of the hierarchy, we expect the button
// to be a direct child of the window
AXUIElementRef buttonRef = [window findDirectChildByRole: kAXButtonRole];
- EXPECT(buttonRef != nil);
+ QVERIFY(buttonRef != nil);
TestAXObject *buttonObject = [[TestAXObject alloc] initWithAXUIElementRef: buttonRef];
TestAXObject *parentObject = [[TestAXObject alloc] initWithAXUIElementRef: [buttonObject parent]];
// check that the parent is a window
- EXPECT([[parentObject role] isEqualToString: NSAccessibilityWindowRole]);
+ QVERIFY([[parentObject role] isEqualToString: NSAccessibilityWindowRole]);
// test the focus
// child 0 is the layout, then button1 and 2
QPushButton *button1 = qobject_cast<QPushButton*>(w->children().at(1));
- EXPECT(button1);
+ QVERIFY(button1);
QPushButton *button2 = qobject_cast<QPushButton*>(w->children().at(2));
- EXPECT(button2);
+ QVERIFY(button2);
button2->setFocus();
AXUIElementRef systemWideElement = AXUIElementCreateSystemWide();
AXUIElementRef focussedElement = NULL;
AXError error = AXUIElementCopyAttributeValue(systemWideElement,
(CFStringRef)NSAccessibilityFocusedUIElementAttribute, (CFTypeRef*)&focussedElement);
- EXPECT(!error);
- EXPECT(focussedElement);
+ QVERIFY(!error);
+ QVERIFY(focussedElement);
TestAXObject *focusButton2 = [[TestAXObject alloc] initWithAXUIElementRef: focussedElement];
- EXPECT([[focusButton2 role] isEqualToString: NSAccessibilityButtonRole]);
- EXPECT([[focusButton2 title] isEqualToString: @"Button 2"]);
+ QVERIFY([[focusButton2 role] isEqualToString: NSAccessibilityButtonRole]);
+ QVERIFY([[focusButton2 title] isEqualToString: @"Button 2"]);
button1->setFocus();
error = AXUIElementCopyAttributeValue(systemWideElement,
(CFStringRef)NSAccessibilityFocusedUIElementAttribute, (CFTypeRef*)&focussedElement);
- EXPECT(!error);
- EXPECT(focussedElement);
+ QVERIFY(!error);
+ QVERIFY(focussedElement);
TestAXObject *focusButton1 = [[TestAXObject alloc] initWithAXUIElementRef: focussedElement];
- EXPECT([[focusButton1 role] isEqualToString: NSAccessibilityButtonRole]);
- EXPECT([[focusButton1 title] isEqualToString: @"I am a button"]);
-
- return true;
+ QVERIFY([[focusButton1 role] isEqualToString: NSAccessibilityButtonRole]);
+ QVERIFY([[focusButton1 title] isEqualToString: @"I am a button"]);
}
-QVector<int> notificationList;
-
-void observerCallback(AXObserverRef /*observer*/, AXUIElementRef /*element*/, CFStringRef notification, void *)
-{
- if ([(NSString*)notification isEqualToString: NSAccessibilityFocusedUIElementChangedNotification])
- notificationList.append(QAccessible::Focus);
- else if ([(NSString*)notification isEqualToString: NSAccessibilityValueChangedNotification])
- notificationList.append(QAccessible::ValueChanged);
- else
- notificationList.append(-1);
-}
-
-
-bool notifications(QWidget *w)
+void tst_QAccessibilityMac::notificationsTest()
{
+ auto *w = m_window;
QLineEdit *le1 = new QLineEdit(w);
QLineEdit *le2 = new QLineEdit(w);
w->layout()->addWidget(le1);
@@ -500,76 +594,215 @@ bool notifications(QWidget *w)
QTest::qWait(100);
TestAXObject *appObject = [TestAXObject getApplicationAXObject];
- EXPECT(appObject);
+ QVERIFY(appObject);
- NSArray *windowList = [appObject windowList];
// one window
- EXPECT([windowList count] == 1);
- AXUIElementRef windowRef = (AXUIElementRef) [windowList objectAtIndex: 0];
- EXPECT(windowRef != nil);
+ QTRY_VERIFY(appObject.windowList.count == 1);
+ AXUIElementRef windowRef = (AXUIElementRef) [appObject.windowList objectAtIndex: 0];
+ QVERIFY(windowRef != nil);
TestAXObject *window = [[TestAXObject alloc] initWithAXUIElementRef: windowRef];
AXUIElementRef lineEdit1 = [window findDirectChildByRole: kAXTextFieldRole];
- EXPECT(lineEdit1 != nil);
+ QVERIFY(lineEdit1 != nil);
AXObserverRef observer = 0;
AXError err = AXObserverCreate(getpid(), observerCallback, &observer);
- EXPECT(!err);
+ QVERIFY(!err);
AXObserverAddNotification(observer, appObject.ref, kAXFocusedUIElementChangedNotification, 0);
AXObserverAddNotification(observer, lineEdit1, kAXValueChangedNotification, 0);
CFRunLoopAddSource( [[NSRunLoop currentRunLoop] getCFRunLoop], AXObserverGetRunLoopSource(observer), kCFRunLoopDefaultMode);
- EXPECT(notificationList.length() == 0);
+ QVERIFY(notificationList.length() == 0);
le2->setFocus();
- TRY_EXPECT(notificationList.length() == 1);
- TRY_EXPECT(notificationList.at(0) == QAccessible::Focus);
+ QTRY_VERIFY(notificationList.length() == 1);
+ QTRY_VERIFY(notificationList.at(0) == QAccessible::Focus);
le1->setFocus();
- TRY_EXPECT(notificationList.length() == 2);
- TRY_EXPECT(notificationList.at(1) == QAccessible::Focus);
+ QTRY_VERIFY(notificationList.length() == 2);
+ QTRY_VERIFY(notificationList.at(1) == QAccessible::Focus);
le1->setText("hello");
- TRY_EXPECT(notificationList.length() == 3);
- TRY_EXPECT(notificationList.at(2) == QAccessible::ValueChanged);
+ QTRY_VERIFY(notificationList.length() == 3);
+ QTRY_VERIFY(notificationList.at(2) == QAccessible::ValueChanged);
le1->setText("foo");
- TRY_EXPECT(notificationList.length() == 4);
- TRY_EXPECT(notificationList.at(3) == QAccessible::ValueChanged);
-
- return true;
+ QTRY_VERIFY(notificationList.length() == 4);
+ QTRY_VERIFY(notificationList.at(3) == QAccessible::ValueChanged);
}
-bool testCheckBox(QCheckBox *ckBox)
+void tst_QAccessibilityMac::checkBoxTest()
{
+ QCheckBox *ckBox = new QCheckBox(m_window);
+ ckBox->setText("Great option");
+ m_window->addWidget(ckBox);
+ QVERIFY(QTest::qWaitForWindowExposed(m_window));
+ QCoreApplication::processEvents();
+
TestAXObject *appObject = [TestAXObject getApplicationAXObject];
- EXPECT(appObject);
+ QVERIFY(appObject);
- NSArray *windowList = [appObject windowList];
// one window
- EXPECT([windowList count] == 1);
- AXUIElementRef windowRef = (AXUIElementRef) [windowList objectAtIndex: 0];
- EXPECT(windowRef != nil);
+ QTRY_VERIFY(appObject.windowList.count == 1);
+ AXUIElementRef windowRef = (AXUIElementRef) [appObject.windowList objectAtIndex: 0];
+ QVERIFY(windowRef != nil);
TestAXObject *window = [[TestAXObject alloc] initWithAXUIElementRef: windowRef];
// children of window:
AXUIElementRef checkBox = [window findDirectChildByRole: kAXCheckBoxRole];
- EXPECT(checkBox != nil);
+ QVERIFY(checkBox != nil);
TestAXObject *cb = [[TestAXObject alloc] initWithAXUIElementRef: checkBox];
// here start actual checkbox tests
- EXPECT([cb valueNumber] == 0);
- EXPECT([cb.title isEqualToString:@"Great option"]);
+ QVERIFY([cb valueNumber] == 0);
+ QVERIFY([cb.title isEqualToString:@"Great option"]);
// EXPECT(cb.description == nil); // currently returns "" instead of nil
- EXPECT([cb.actions containsObject:(NSString*)kAXPressAction]);
+ QVERIFY([cb.actions containsObject:(NSString*)kAXPressAction]);
[cb performAction:kAXPressAction];
- EXPECT([cb valueNumber] == 1);
+ QVERIFY([cb valueNumber] == 1);
[cb performAction:kAXPressAction];
- EXPECT([cb valueNumber] == 0);
+ QVERIFY([cb valueNumber] == 0);
ckBox->setCheckState(Qt::PartiallyChecked);
- EXPECT([cb valueNumber] == 2);
+ QVERIFY([cb valueNumber] == 2);
+}
+
+void tst_QAccessibilityMac::tableViewTest()
+{
+ QTableWidget *tw = new QTableWidget(3, 2, m_window);
+ struct Person
+ {
+ const char *name;
+ const char *address;
+ };
+ const Person contents[] = { { "Socrates", "Greece" },
+ { "Confucius", "China" },
+ { "Kant", "Preussia" }
+ };
+ for (int i = 0; i < int(sizeof(contents) / sizeof(Person)); ++i) {
+ Person p = contents[i];
+ QTableWidgetItem *name = new QTableWidgetItem(QString::fromLatin1(p.name));
+ tw->setItem(i, 0, name);
+ QTableWidgetItem *address = new QTableWidgetItem(QString::fromLatin1(p.address));
+ tw->setItem(i, 1, address);
+ }
+ m_window->addWidget(tw);
+ QVERIFY(QTest::qWaitForWindowExposed(m_window));
+ QCoreApplication::processEvents();
+
+ TestAXObject *appObject = [TestAXObject getApplicationAXObject];
+ QVERIFY(appObject);
- return true;
+ NSArray *windowList = [appObject windowList];
+ // one window
+ QVERIFY([windowList count] == 1);
+ AXUIElementRef windowRef = (AXUIElementRef)[windowList objectAtIndex:0];
+ QVERIFY(windowRef != nil);
+ TestAXObject *window = [[TestAXObject alloc] initWithAXUIElementRef:windowRef];
+
+ // children of window:
+ AXUIElementRef tableView = [window findDirectChildByRole:kAXTableRole];
+ QVERIFY(tableView != nil);
+
+ TestAXObject *tv = [[TestAXObject alloc] initWithAXUIElementRef:tableView];
+
+ // here start actual tableview tests
+ // Should have 2 columns
+ const unsigned int columnCount = 2;
+ NSArray *columnArray = [tv tableColumns];
+ QCOMPARE([columnArray count], columnCount);
+
+ // should have 3 rows
+ const unsigned int rowCount = 3;
+ NSArray *rowArray = [tv tableRows];
+ QCOMPARE([rowArray count], rowCount);
+
+ // The individual cells are children of the rows
+ TestAXObject *row = [[TestAXObject alloc] initWithAXUIElementRef:(AXUIElementRef)rowArray[0]];
+ TestAXObject *cell = [[TestAXObject alloc] initWithAXUIElementRef:(AXUIElementRef)[row childList][0]];
+ QVERIFY([cell.title isEqualToString:@"Socrates"]);
+ row = [[TestAXObject alloc] initWithAXUIElementRef:(AXUIElementRef)rowArray[2]];
+ cell = [[TestAXObject alloc] initWithAXUIElementRef:(AXUIElementRef)[row childList][1]];
+ QVERIFY([cell.title isEqualToString:@"Preussia"]);
+
+ // both rows and columns are direct children of the table
+ NSArray *childList = [tv childList];
+ QCOMPARE([childList count], columnCount + rowCount);
+ for (id child in childList) {
+ TestAXObject *childObject = [[TestAXObject alloc] initWithAXUIElementRef:(AXUIElementRef)child];
+ QVERIFY([childObject.role isEqualToString:NSAccessibilityRowRole] ||
+ [childObject.role isEqualToString:NSAccessibilityColumnRole]);
+ }
}
+
+void tst_QAccessibilityMac::treeViewTest()
+{
+ QTreeWidget *tw = new QTreeWidget;
+ tw->setColumnCount(2);
+ QTreeWidgetItem *root = new QTreeWidgetItem(tw, {"/", "0"});
+ root->setExpanded(false);
+ QTreeWidgetItem *users = new QTreeWidgetItem(root,{ "Users", "1"});
+ (void)new QTreeWidgetItem(root, {"Applications", "2"});
+ QTreeWidgetItem *lastChild = new QTreeWidgetItem(root, {"Libraries", "3"});
+
+ m_window->addWidget(tw);
+ QVERIFY(QTest::qWaitForWindowExposed(m_window));
+ QCoreApplication::processEvents();
+
+ TestAXObject *appObject = [TestAXObject getApplicationAXObject];
+ QVERIFY(appObject);
+
+ NSArray *windowList = [appObject windowList];
+ // one window
+ QVERIFY([windowList count] == 1);
+ AXUIElementRef windowRef = (AXUIElementRef)[windowList objectAtIndex:0];
+ QVERIFY(windowRef != nil);
+ TestAXObject *window = [[TestAXObject alloc] initWithAXUIElementRef:windowRef];
+
+ // children of window
+ AXUIElementRef treeView = [window findDirectChildByRole:kAXOutlineRole];
+ QVERIFY(treeView != nil);
+
+ TestAXObject *tv = [[TestAXObject alloc] initWithAXUIElementRef:treeView];
+
+ // here start actual treeview tests. NSAccessibilityOutline is a specialization
+ // of NSAccessibilityTable, and we represent trees as tables.
+ // Should have 2 columns
+ const unsigned int columnCount = 2;
+ NSArray *columnArray = [tv tableColumns];
+ QCOMPARE([columnArray count], columnCount);
+
+ // should have 1 row for now - as long as the root item is not expanded
+ NSArray *rowArray = [tv tableRows];
+ QCOMPARE(int([rowArray count]), 1);
+
+ root->setExpanded(true);
+ rowArray = [tv tableRows];
+ QCOMPARE(int([rowArray count]), root->childCount() + 1);
+
+ // this should not trigger any assert
+ tw->setCurrentItem(lastChild);
+
+ bool errorOccurred = false;
+
+ const auto cellText = [rowArray, &errorOccurred](int rowIndex, int columnIndex) -> QString {
+ TestAXObject *row = [[TestAXObject alloc] initWithAXUIElementRef:(AXUIElementRef)rowArray[rowIndex]];
+ Q_ASSERT(row);
+ TestAXObject *cell = [[TestAXObject alloc] initWithAXUIElementRef:(AXUIElementRef)[row childList][columnIndex]];
+ Q_ASSERT(cell);
+ const QString result = QString::fromNSString(cell.title);
+ errorOccurred = cell.errorOccurred;
+ return result;
+ };
+
+ QString text = cellText(0, 0);
+ if (errorOccurred)
+ QSKIP("Cocoa Accessibility API error, aborting");
+ QCOMPARE(text, root->text(0));
+ QCOMPARE(cellText(1, 0), users->text(0));
+ QCOMPARE(cellText(1, 1), users->text(1));
+}
+
+QTEST_MAIN(tst_QAccessibilityMac)
+#include "tst_qaccessibilitymac.moc"
diff --git a/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac_helpers.h b/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac_helpers.h
deleted file mode 100644
index 003aa90dfd..0000000000
--- a/tests/auto/other/qaccessibilitymac/tst_qaccessibilitymac_helpers.h
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-#include <QtCore/QString>
-#include <QtCore/QPair>
-#include <QtWidgets/QWidget>
-#include <QtWidgets/QCheckBox>
-
-#pragma once // Yeah, it's deprecated in general, but it's standard practice for Mac OS X.
-
-QT_USE_NAMESPACE
-
-bool testLineEdit();
-bool testHierarchy(QWidget *w);
-bool singleWidget();
-bool notifications(QWidget *w);
-bool testCheckBox(QCheckBox *ckBox);
diff --git a/tests/auto/other/qcomplextext/CMakeLists.txt b/tests/auto/other/qcomplextext/CMakeLists.txt
index 79f89741ad..74996c7ad7 100644
--- a/tests/auto/other/qcomplextext/CMakeLists.txt
+++ b/tests/auto/other/qcomplextext/CMakeLists.txt
@@ -1,12 +1,16 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-
-# Generated from qcomplextext.pro.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qcomplextext Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qcomplextext LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
# Collect test data
list(APPEND test_data "data")
diff --git a/tests/auto/other/qcomplextext/bidireorderstring.h b/tests/auto/other/qcomplextext/bidireorderstring.h
index 3b9e4c40ca..831fd34883 100644
--- a/tests/auto/other/qcomplextext/bidireorderstring.h
+++ b/tests/auto/other/qcomplextext/bidireorderstring.h
@@ -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
struct LV {
const char *name;
const char *logical;
diff --git a/tests/auto/other/qcomplextext/tst_qcomplextext.cpp b/tests/auto/other/qcomplextext/tst_qcomplextext.cpp
index 1b944bf1b6..b8014126ed 100644
--- a/tests/auto/other/qcomplextext/tst_qcomplextext.cpp
+++ b/tests/auto/other/qcomplextext/tst_qcomplextext.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 <QTest>
#include <QtGui/QtGui>
@@ -84,7 +84,7 @@ void tst_QComplexText::bidiReorderString()
if (si.analysis.bidiLevel % 2) {
// reverse sub
QChar *a = sub.data();
- QChar *b = a + sub.length() - 1;
+ QChar *b = a + sub.size() - 1;
while (a < b) {
QChar tmp = *a;
*a = *b;
@@ -93,7 +93,7 @@ void tst_QComplexText::bidiReorderString()
--b;
}
a = (QChar *)sub.unicode();
- b = a + sub.length();
+ b = a + sub.size();
while (a<b) {
*a = a->mirroredChar();
++a;
@@ -315,7 +315,7 @@ static void testBidiString(const QString &data, int paragraphDirection,
if (si.analysis.bidiLevel % 2) {
// reverse sub
QChar *a = sub.data();
- QChar *b = a + sub.length() - 1;
+ QChar *b = a + sub.size() - 1;
while (a < b) {
QChar tmp = *a;
*a = *b;
@@ -324,7 +324,7 @@ static void testBidiString(const QString &data, int paragraphDirection,
--b;
}
a = (QChar *)sub.unicode();
- b = a + sub.length();
+ b = a + sub.size();
// while (a<b) {
// *a = a->mirroredChar();
// ++a;
@@ -347,9 +347,7 @@ void tst_QComplexText::bidiCharacterTest()
{
QString testFile = QFINDTESTDATA("data/BidiCharacterTest.txt");
QFile f(testFile);
- QVERIFY(f.exists());
-
- f.open(QIODevice::ReadOnly);
+ QVERIFY(f.open(QIODevice::ReadOnly));
int linenum = 0;
while (!f.atEnd()) {
@@ -441,9 +439,7 @@ void tst_QComplexText::bidiTest()
{
QString testFile = QFINDTESTDATA("data/BidiTest.txt");
QFile f(testFile);
- QVERIFY(f.exists());
-
- f.open(QIODevice::ReadOnly);
+ QVERIFY(f.open(QIODevice::ReadOnly));
int linenum = 0;
QList<int> resolvedLevels;
diff --git a/tests/auto/other/qfocusevent/CMakeLists.txt b/tests/auto/other/qfocusevent/CMakeLists.txt
index d5d6698cb8..61682af4e7 100644
--- a/tests/auto/other/qfocusevent/CMakeLists.txt
+++ b/tests/auto/other/qfocusevent/CMakeLists.txt
@@ -1,12 +1,16 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-
-# Generated from qfocusevent.pro.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qfocusevent Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qfocusevent LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qfocusevent
SOURCES
tst_qfocusevent.cpp
@@ -14,4 +18,5 @@ qt_internal_add_test(tst_qfocusevent
Qt::Gui
Qt::GuiPrivate
Qt::Widgets
+ Qt::WidgetsPrivate
)
diff --git a/tests/auto/other/qfocusevent/tst_qfocusevent.cpp b/tests/auto/other/qfocusevent/tst_qfocusevent.cpp
index 0d34b8dfea..8297b53ea1 100644
--- a/tests/auto/other/qfocusevent/tst_qfocusevent.cpp
+++ b/tests/auto/other/qfocusevent/tst_qfocusevent.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 <QTest>
@@ -16,6 +16,8 @@
#include <qpa/qplatformintegration.h>
#include <private/qguiapplication_p.h>
+#include <QtWidgets/private/qapplication_p.h>
+
QT_FORWARD_DECLARE_CLASS(QWidget)
class FocusLineEdit : public QLineEdit
@@ -112,7 +114,7 @@ void tst_QFocusEvent::initWidget()
{
// On X11 we have to ensure the event was processed before doing any checking, on Windows
// this is processed straight away.
- QApplication::setActiveWindow(testFocusWidget);
+ QApplicationPrivate::setActiveWindow(testFocusWidget);
childFocusWidgetOne->setFocus(); // The first lineedit should have focus
QVERIFY(QTest::qWaitForWindowActive(testFocusWidget));
QTRY_VERIFY(childFocusWidgetOne->hasFocus());
@@ -310,7 +312,6 @@ void tst_QFocusEvent::checkReason_ActiveWindow()
QVERIFY(QTest::qWaitForWindowExposed(d));
d->activateWindow(); // ### CDE
- QApplication::setActiveWindow(d);
QVERIFY(QTest::qWaitForWindowActive(d));
QTRY_VERIFY(childFocusWidgetOne->focusOutEventRecieved);
@@ -332,9 +333,10 @@ void tst_QFocusEvent::checkReason_ActiveWindow()
d->hide();
if (!QGuiApplication::platformName().compare(QLatin1String("offscreen"), Qt::CaseInsensitive)
- || !QGuiApplication::platformName().compare(QLatin1String("minimal"), Qt::CaseInsensitive)) {
+ || !QGuiApplication::platformName().compare(QLatin1String("minimal"), Qt::CaseInsensitive)
+ || !QGuiApplication::platformName().compare(QLatin1String("cocoa"), Qt::CaseInsensitive)) {
// Activate window of testFocusWidget, focus in that window goes to childFocusWidgetOne
- qWarning("Platforms offscreen and minimal require explicit activateWindow()");
+ qWarning("Platforms offscreen, minimal and macOS require explicit activateWindow()");
testFocusWidget->activateWindow();
}
diff --git a/tests/auto/other/qnetworkaccessmanager_and_qprogressdialog/CMakeLists.txt b/tests/auto/other/qnetworkaccessmanager_and_qprogressdialog/CMakeLists.txt
index 322f961fb4..313d9464a3 100644
--- a/tests/auto/other/qnetworkaccessmanager_and_qprogressdialog/CMakeLists.txt
+++ b/tests/auto/other/qnetworkaccessmanager_and_qprogressdialog/CMakeLists.txt
@@ -1,12 +1,16 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-
-# Generated from qnetworkaccessmanager_and_qprogressdialog.pro.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qnetworkaccessmanager_and_qprogressdialog Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qnetworkaccessmanager_and_qprogressdialog LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qnetworkaccessmanager_and_qprogressdialog
SOURCES
tst_qnetworkaccessmanager_and_qprogressdialog.cpp
diff --git a/tests/auto/other/qnetworkaccessmanager_and_qprogressdialog/tst_qnetworkaccessmanager_and_qprogressdialog.cpp b/tests/auto/other/qnetworkaccessmanager_and_qprogressdialog/tst_qnetworkaccessmanager_and_qprogressdialog.cpp
index 30cc76830a..c665068f72 100644
--- a/tests/auto/other/qnetworkaccessmanager_and_qprogressdialog/tst_qnetworkaccessmanager_and_qprogressdialog.cpp
+++ b/tests/auto/other/qnetworkaccessmanager_and_qprogressdialog/tst_qnetworkaccessmanager_and_qprogressdialog.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 <QTest>
diff --git a/tests/auto/other/qobjectrace/CMakeLists.txt b/tests/auto/other/qobjectrace/CMakeLists.txt
index 40afbd044d..6516c9ee73 100644
--- a/tests/auto/other/qobjectrace/CMakeLists.txt
+++ b/tests/auto/other/qobjectrace/CMakeLists.txt
@@ -1,12 +1,16 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-
-# Generated from qobjectrace.pro.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## qobjectrace Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qobjectrace LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qobjectrace
SOURCES
tst_qobjectrace.cpp
diff --git a/tests/auto/other/qobjectrace/tst_qobjectrace.cpp b/tests/auto/other/qobjectrace/tst_qobjectrace.cpp
index 1dbaf33e32..af6634f253 100644
--- a/tests/auto/other/qobjectrace/tst_qobjectrace.cpp
+++ b/tests/auto/other/qobjectrace/tst_qobjectrace.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2022 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 <QtCore>
@@ -309,8 +309,7 @@ public slots:
break;
}
- Q_UNREACHABLE();
- return false;
+ Q_UNREACHABLE_RETURN(false);
}
private:
@@ -319,9 +318,6 @@ private:
void tst_QObjectRace::blockingQueuedDestroyRace()
{
-#if !QT_CONFIG(cxx11_future)
- QSKIP("This test requires QThread::create");
-#else
enum { MinIterations = 100, MinTime = 3000, WaitTime = 25 };
BlockingQueuedDestroyRaceObject sender;
@@ -367,7 +363,6 @@ void tst_QObjectRace::blockingQueuedDestroyRace()
thread->wait();
}
-#endif
}
static QAtomicInteger<unsigned> countedStructObjectsCount;
diff --git a/tests/auto/other/qprocess_and_guieventloop/CMakeLists.txt b/tests/auto/other/qprocess_and_guieventloop/CMakeLists.txt
index d1e8ed78e1..3383677009 100644
--- a/tests/auto/other/qprocess_and_guieventloop/CMakeLists.txt
+++ b/tests/auto/other/qprocess_and_guieventloop/CMakeLists.txt
@@ -1,12 +1,16 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-
-# Generated from qprocess_and_guieventloop.pro.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qprocess_and_guieventloop Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qprocess_and_guieventloop LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qprocess_and_guieventloop
SOURCES
tst_qprocess_and_guieventloop.cpp
@@ -14,3 +18,4 @@ qt_internal_add_test(tst_qprocess_and_guieventloop
Qt::Gui
)
add_subdirectory(write-read-write)
+add_dependencies(tst_qprocess_and_guieventloop write-read-write)
diff --git a/tests/auto/other/qprocess_and_guieventloop/tst_qprocess_and_guieventloop.cpp b/tests/auto/other/qprocess_and_guieventloop/tst_qprocess_and_guieventloop.cpp
index e70d132ea7..b5b8c4cfc3 100644
--- a/tests/auto/other/qprocess_and_guieventloop/tst_qprocess_and_guieventloop.cpp
+++ b/tests/auto/other/qprocess_and_guieventloop/tst_qprocess_and_guieventloop.cpp
@@ -1,6 +1,6 @@
// Copyright (C) 2021 The Qt Company Ltd.
// Copyright (C) 2016 Intel Corporation.
-// 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 <QtGui/QGuiApplication>
#include <QTest>
@@ -35,20 +35,20 @@ void tst_QProcess_and_GuiEventLoop::waitForAndEventLoop()
qApp->processEvents(QEventLoop::AllEvents, 100);
// we mustn't have read anything in the event loop
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
// ensure the process hasn't died
QVERIFY(!process.waitForFinished(250));
// we mustn't have read anything during waitForFinished either
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
// release the child for the second write
process.write("\n");
QVERIFY(process.waitForFinished(5000));
QCOMPARE(int(process.exitStatus()), int(QProcess::NormalExit));
QCOMPARE(process.exitCode(), 0);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QCOMPARE(process.readAll().trimmed(), msg);
#endif
}
diff --git a/tests/auto/other/qprocess_and_guieventloop/write-read-write/CMakeLists.txt b/tests/auto/other/qprocess_and_guieventloop/write-read-write/CMakeLists.txt
index 289bbf231f..2bc1ebb7b0 100644
--- a/tests/auto/other/qprocess_and_guieventloop/write-read-write/CMakeLists.txt
+++ b/tests/auto/other/qprocess_and_guieventloop/write-read-write/CMakeLists.txt
@@ -1,8 +1,12 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## write-read-write Binary:
#####################################################################
-add_executable(write-read-write main.cpp)
+qt_internal_add_executable(write-read-write
+ OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/"
+ SOURCES
+ main.cpp
+)
diff --git a/tests/auto/other/qprocess_and_guieventloop/write-read-write/main.cpp b/tests/auto/other/qprocess_and_guieventloop/write-read-write/main.cpp
index b062542bb0..126c85dfd7 100644
--- a/tests/auto/other/qprocess_and_guieventloop/write-read-write/main.cpp
+++ b/tests/auto/other/qprocess_and_guieventloop/write-read-write/main.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 Intel Corporation.
-// 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 <stdio.h>
diff --git a/tests/auto/other/qsharedpointer_and_qwidget/CMakeLists.txt b/tests/auto/other/qsharedpointer_and_qwidget/CMakeLists.txt
index c5031fe42b..a405f54151 100644
--- a/tests/auto/other/qsharedpointer_and_qwidget/CMakeLists.txt
+++ b/tests/auto/other/qsharedpointer_and_qwidget/CMakeLists.txt
@@ -1,12 +1,16 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-
-# Generated from qsharedpointer_and_qwidget.pro.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_qsharedpointer_and_qwidget Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qsharedpointer_and_qwidget LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qsharedpointer_and_qwidget
SOURCES
tst_qsharedpointer_and_qwidget.cpp
diff --git a/tests/auto/other/qsharedpointer_and_qwidget/tst_qsharedpointer_and_qwidget.cpp b/tests/auto/other/qsharedpointer_and_qwidget/tst_qsharedpointer_and_qwidget.cpp
index 9eaff74557..5fa9d8740a 100644
--- a/tests/auto/other/qsharedpointer_and_qwidget/tst_qsharedpointer_and_qwidget.cpp
+++ b/tests/auto/other/qsharedpointer_and_qwidget/tst_qsharedpointer_and_qwidget.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 <QtWidgets/QWidget>
#include <QtWidgets/QPushButton>
diff --git a/tests/auto/other/qvariant_common/tst_qvariant_common.h b/tests/auto/other/qvariant_common/tst_qvariant_common.h
index 86da11ee47..553c396e47 100644
--- a/tests/auto/other/qvariant_common/tst_qvariant_common.h
+++ b/tests/auto/other/qvariant_common/tst_qvariant_common.h
@@ -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
#ifndef TST_QVARIANT_COMMON
#define TST_QVARIANT_COMMON
diff --git a/tests/auto/other/sessionmanagement_macos/tst_sessionmanagement_macos.mm b/tests/auto/other/sessionmanagement_macos/tst_sessionmanagement_macos.mm
index a59ff03a06..02a3464ec7 100644
--- a/tests/auto/other/sessionmanagement_macos/tst_sessionmanagement_macos.mm
+++ b/tests/auto/other/sessionmanagement_macos/tst_sessionmanagement_macos.mm
@@ -1,5 +1,5 @@
// Copyright (C) 2019 Samuel Gaist <samuel.gaist@idiap.ch>
-// 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 <QTest>
diff --git a/tests/auto/other/toolsupport/CMakeLists.txt b/tests/auto/other/toolsupport/CMakeLists.txt
index 79b89b5373..5b2cc0c0e2 100644
--- a/tests/auto/other/toolsupport/CMakeLists.txt
+++ b/tests/auto/other/toolsupport/CMakeLists.txt
@@ -1,12 +1,16 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-
-# Generated from toolsupport.pro.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_toolsupport Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_toolsupport LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_toolsupport
SOURCES
tst_toolsupport.cpp
diff --git a/tests/auto/other/toolsupport/tst_toolsupport.cpp b/tests/auto/other/toolsupport/tst_toolsupport.cpp
index 6a146bae3a..965b55977c 100644
--- a/tests/auto/other/toolsupport/tst_toolsupport.cpp
+++ b/tests/auto/other/toolsupport/tst_toolsupport.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2015 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 <QTest>
@@ -38,6 +38,7 @@ template <typename T, typename K>
size_t pmm_to_offsetof(T K:: *pmm)
{
#ifdef Q_CC_MSVC
+
// Even on 64 bit MSVC uses 4 byte offsets.
quint32 ret;
#else
@@ -114,10 +115,10 @@ void tst_toolsupport::offsets_data()
QTestData &data = QTest::newRow("QFilePrivate::fileName")
<< pmm_to_offsetof(&QFilePrivate::fileName);
// Please heed the comment at the top of this file when changing one of these lines:
-#ifdef Q_PROCESSOR_X86
+#ifdef Q_PROCESSOR_X86_32
// x86 32-bit has weird alignment rules. Refer to QtPrivate::AlignOf in
// qglobal.h for more details.
- data << 264 << 424;
+ data << 264 << -1;
#else
data << 300 << 424;
#endif
diff --git a/tests/auto/other/xkbkeyboard/CMakeLists.txt b/tests/auto/other/xkbkeyboard/CMakeLists.txt
index e32d61ace9..06e471c68b 100644
--- a/tests/auto/other/xkbkeyboard/CMakeLists.txt
+++ b/tests/auto/other/xkbkeyboard/CMakeLists.txt
@@ -1,12 +1,16 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
-
-# Generated from xkbkeyboard.pro.
+# SPDX-License-Identifier: BSD-3-Clause
#####################################################################
## tst_xkbkeyboard Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_xkbkeyboard LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_xkbkeyboard
SOURCES
tst_xkbkeyboard.cpp
diff --git a/tests/auto/other/xkbkeyboard/tst_xkbkeyboard.cpp b/tests/auto/other/xkbkeyboard/tst_xkbkeyboard.cpp
index 05950eee81..323693bb84 100644
--- a/tests/auto/other/xkbkeyboard/tst_xkbkeyboard.cpp
+++ b/tests/auto/other/xkbkeyboard/tst_xkbkeyboard.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2019 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 <QtCore>
#include <QtGui>