summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/gui/kernel')
-rw-r--r--tests/auto/gui/kernel/CMakeLists.txt5
-rw-r--r--tests/auto/gui/kernel/noqteventloop/CMakeLists.txt8
-rw-r--r--tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp2
-rw-r--r--tests/auto/gui/kernel/qaction/CMakeLists.txt8
-rw-r--r--tests/auto/gui/kernel/qaction/tst_qaction.cpp64
-rw-r--r--tests/auto/gui/kernel/qactiongroup/CMakeLists.txt8
-rw-r--r--tests/auto/gui/kernel/qactiongroup/tst_qactiongroup.cpp2
-rw-r--r--tests/auto/gui/kernel/qaddpostroutine/CMakeLists.txt8
-rw-r--r--tests/auto/gui/kernel/qaddpostroutine/tst_qaddpostroutine.cpp2
-rw-r--r--tests/auto/gui/kernel/qbackingstore/CMakeLists.txt8
-rw-r--r--tests/auto/gui/kernel/qbackingstore/tst_qbackingstore.cpp85
-rw-r--r--tests/auto/gui/kernel/qclipboard/CMakeLists.txt6
-rw-r--r--tests/auto/gui/kernel/qclipboard/copier/CMakeLists.txt12
-rw-r--r--tests/auto/gui/kernel/qclipboard/copier/main.cpp2
-rw-r--r--tests/auto/gui/kernel/qclipboard/paster/CMakeLists.txt12
-rw-r--r--tests/auto/gui/kernel/qclipboard/paster/main.cpp2
-rw-r--r--tests/auto/gui/kernel/qclipboard/test/BLACKLIST5
-rw-r--r--tests/auto/gui/kernel/qclipboard/test/CMakeLists.txt3
-rw-r--r--tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp84
-rw-r--r--tests/auto/gui/kernel/qcursor/CMakeLists.txt8
-rw-r--r--tests/auto/gui/kernel/qcursor/tst_qcursor.cpp2
-rw-r--r--tests/auto/gui/kernel/qdrag/CMakeLists.txt8
-rw-r--r--tests/auto/gui/kernel/qdrag/tst_qdrag.cpp2
-rw-r--r--tests/auto/gui/kernel/qevent/CMakeLists.txt8
-rw-r--r--tests/auto/gui/kernel/qevent/tst_qevent.cpp62
-rw-r--r--tests/auto/gui/kernel/qfileopenevent/CMakeLists.txt6
-rw-r--r--tests/auto/gui/kernel/qfileopenevent/qfileopeneventexternal/CMakeLists.txt5
-rw-r--r--tests/auto/gui/kernel/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.cpp6
-rw-r--r--tests/auto/gui/kernel/qfileopenevent/test/CMakeLists.txt2
-rw-r--r--tests/auto/gui/kernel/qfileopenevent/test/tst_qfileopenevent.cpp22
-rw-r--r--tests/auto/gui/kernel/qguiapplication/CMakeLists.txt16
-rw-r--r--tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp170
-rw-r--r--tests/auto/gui/kernel/qguichronotimer/CMakeLists.txt38
-rw-r--r--tests/auto/gui/kernel/qguieventdispatcher/CMakeLists.txt39
-rw-r--r--tests/auto/gui/kernel/qguieventloop/CMakeLists.txt8
-rw-r--r--tests/auto/gui/kernel/qguimetatype/CMakeLists.txt8
-rw-r--r--tests/auto/gui/kernel/qguimetatype/tst_qguimetatype.cpp2
-rw-r--r--tests/auto/gui/kernel/qguitimer/CMakeLists.txt38
-rw-r--r--tests/auto/gui/kernel/qguivariant/CMakeLists.txt2
-rw-r--r--tests/auto/gui/kernel/qguivariant/no_application/CMakeLists.txt8
-rw-r--r--tests/auto/gui/kernel/qguivariant/no_application/main.cpp2
-rw-r--r--tests/auto/gui/kernel/qguivariant/test/CMakeLists.txt8
-rw-r--r--tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp2
-rw-r--r--tests/auto/gui/kernel/qhighdpi/CMakeLists.txt8
-rw-r--r--tests/auto/gui/kernel/qhighdpi/tst_qhighdpi.cpp107
-rw-r--r--tests/auto/gui/kernel/qinputdevice/CMakeLists.txt8
-rw-r--r--tests/auto/gui/kernel/qinputdevice/tst_qinputdevice.cpp4
-rw-r--r--tests/auto/gui/kernel/qinputmethod/CMakeLists.txt8
-rw-r--r--tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp16
-rw-r--r--tests/auto/gui/kernel/qkeyevent/CMakeLists.txt8
-rw-r--r--tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp4
-rw-r--r--tests/auto/gui/kernel/qkeysequence/CMakeLists.txt8
-rw-r--r--tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp7
-rw-r--r--tests/auto/gui/kernel/qmouseevent/CMakeLists.txt8
-rw-r--r--tests/auto/gui/kernel/qmouseevent/tst_qmouseevent.cpp28
-rw-r--r--tests/auto/gui/kernel/qmouseevent_modal/CMakeLists.txt8
-rw-r--r--tests/auto/gui/kernel/qmouseevent_modal/tst_qmouseevent_modal.cpp2
-rw-r--r--tests/auto/gui/kernel/qopenglwindow/CMakeLists.txt8
-rw-r--r--tests/auto/gui/kernel/qopenglwindow/tst_qopenglwindow.cpp5
-rw-r--r--tests/auto/gui/kernel/qpalette/CMakeLists.txt8
-rw-r--r--tests/auto/gui/kernel/qpalette/tst_qpalette.cpp73
-rw-r--r--tests/auto/gui/kernel/qpixelformat/CMakeLists.txt8
-rw-r--r--tests/auto/gui/kernel/qpixelformat/tst_qpixelformat.cpp2
-rw-r--r--tests/auto/gui/kernel/qrasterwindow/CMakeLists.txt8
-rw-r--r--tests/auto/gui/kernel/qrasterwindow/tst_qrasterwindow.cpp4
-rw-r--r--tests/auto/gui/kernel/qscreen/CMakeLists.txt8
-rw-r--r--tests/auto/gui/kernel/qscreen/tst_qscreen.cpp17
-rw-r--r--tests/auto/gui/kernel/qshortcut/CMakeLists.txt9
-rw-r--r--tests/auto/gui/kernel/qshortcut/tst_qshortcut.cpp65
-rw-r--r--tests/auto/gui/kernel/qsurfaceformat/CMakeLists.txt8
-rw-r--r--tests/auto/gui/kernel/qsurfaceformat/tst_qsurfaceformat.cpp2
-rw-r--r--tests/auto/gui/kernel/qtouchevent/CMakeLists.txt8
-rw-r--r--tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp103
-rw-r--r--tests/auto/gui/kernel/qwindow/BLACKLIST7
-rw-r--r--tests/auto/gui/kernel/qwindow/CMakeLists.txt30
-rw-r--r--tests/auto/gui/kernel/qwindow/tst_foreignwindow.cpp196
-rw-r--r--tests/auto/gui/kernel/qwindow/tst_qwindow.cpp521
77 files changed, 1688 insertions, 424 deletions
diff --git a/tests/auto/gui/kernel/CMakeLists.txt b/tests/auto/gui/kernel/CMakeLists.txt
index 6e0fbeed23..9acd817610 100644
--- a/tests/auto/gui/kernel/CMakeLists.txt
+++ b/tests/auto/gui/kernel/CMakeLists.txt
@@ -1,8 +1,6 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
-# Generated from kernel.pro.
-
if(QT_FEATURE_action)
add_subdirectory(qaction)
add_subdirectory(qactiongroup)
@@ -12,6 +10,7 @@ add_subdirectory(qcursor)
add_subdirectory(qdrag)
add_subdirectory(qevent)
add_subdirectory(qfileopenevent)
+add_subdirectory(qguichronotimer)
add_subdirectory(qguieventdispatcher)
add_subdirectory(qguitimer)
if(NOT ANDROID AND NOT WASM)
@@ -31,7 +30,7 @@ endif()
add_subdirectory(qpixelformat)
add_subdirectory(qrasterwindow)
add_subdirectory(qaddpostroutine)
-if(NOT ANDROID AND NOT UIKIT)
+if(NOT UIKIT)
add_subdirectory(qclipboard)
endif()
if(TARGET Qt::Network)
diff --git a/tests/auto/gui/kernel/noqteventloop/CMakeLists.txt b/tests/auto/gui/kernel/noqteventloop/CMakeLists.txt
index 11efe12a9e..e9d3d96af9 100644
--- a/tests/auto/gui/kernel/noqteventloop/CMakeLists.txt
+++ b/tests/auto/gui/kernel/noqteventloop/CMakeLists.txt
@@ -1,12 +1,16 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
-# Generated from noqteventloop.pro.
-
#####################################################################
## tst_noqteventloop Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_noqteventloop LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_noqteventloop
SOURCES
tst_noqteventloop.cpp
diff --git a/tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp b/tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp
index 8aec8ddcc6..65fe4a83ed 100644
--- a/tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.cpp
+++ b/tests/auto/gui/kernel/noqteventloop/tst_noqteventloop.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/gui/kernel/qaction/CMakeLists.txt b/tests/auto/gui/kernel/qaction/CMakeLists.txt
index 49c6bcc6cb..8f70a36c61 100644
--- a/tests/auto/gui/kernel/qaction/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qaction/CMakeLists.txt
@@ -1,12 +1,16 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
-# Generated from qaction.pro.
-
#####################################################################
## tst_qaction_kernel Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qaction_kernel LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qaction_kernel
SOURCES
tst_qaction.cpp
diff --git a/tests/auto/gui/kernel/qaction/tst_qaction.cpp b/tests/auto/gui/kernel/qaction/tst_qaction.cpp
index cebcf9ca5a..4a4d1a75c8 100644
--- a/tests/auto/gui/kernel/qaction/tst_qaction.cpp
+++ b/tests/auto/gui/kernel/qaction/tst_qaction.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 <QTest>
#include <QSignalSpy>
@@ -209,11 +209,11 @@ void tst_QAction::setToolTip()
QFETCH(QStringList, values);
QFETCH(QStringList, expectedToolTips);
- QCOMPARE(properties.count(), values.count());
- QCOMPARE(properties.count(), expectedToolTips.count());
+ QCOMPARE(properties.size(), values.size());
+ QCOMPARE(properties.size(), expectedToolTips.size());
QAction action(nullptr);
- for (int i = 0; i < properties.count(); ++i) {
+ for (int i = 0; i < properties.size(); ++i) {
const auto property = properties.at(i);
const auto value = values.at(i);
const auto expectedToolTip = expectedToolTips.at(i);
@@ -272,19 +272,19 @@ void tst_QAction::task229128TriggeredSignalWithoutActiongroup()
// test without a group
const QScopedPointer<QAction> actionWithoutGroup(new QAction("Test", nullptr));
QSignalSpy spyWithoutGroup(actionWithoutGroup.data(), QOverload<bool>::of(&QAction::triggered));
- QCOMPARE(spyWithoutGroup.count(), 0);
+ QCOMPARE(spyWithoutGroup.size(), 0);
actionWithoutGroup->trigger();
// signal should be emitted
- QCOMPARE(spyWithoutGroup.count(), 1);
+ QCOMPARE(spyWithoutGroup.size(), 1);
// it is now a checkable checked action
actionWithoutGroup->setCheckable(true);
actionWithoutGroup->setChecked(true);
spyWithoutGroup.clear();
- QCOMPARE(spyWithoutGroup.count(), 0);
+ QCOMPARE(spyWithoutGroup.size(), 0);
actionWithoutGroup->trigger();
// signal should be emitted
- QCOMPARE(spyWithoutGroup.count(), 1);
+ QCOMPARE(spyWithoutGroup.size(), 1);
}
void tst_QAction::setData() // QTBUG-62006
@@ -292,14 +292,14 @@ void tst_QAction::setData() // QTBUG-62006
QAction act(nullptr);
QSignalSpy spy(&act, &QAction::changed);
QCOMPARE(act.data(), QVariant());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
act.setData(QVariant());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
act.setData(-1);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
act.setData(-1);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
void tst_QAction::setEnabledSetVisible()
@@ -308,22 +308,22 @@ void tst_QAction::setEnabledSetVisible()
QSignalSpy spy(&action, &QAction::enabledChanged);
QVERIFY(action.isEnabled());
QVERIFY(action.isVisible());
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
action.setVisible(false);
QVERIFY(!action.isEnabled());
QVERIFY(!action.isVisible());
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
action.setEnabled(false);
QVERIFY(!action.isEnabled());
QVERIFY(!action.isVisible());
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
action.setVisible(true);
QVERIFY(!action.isEnabled());
QVERIFY(action.isVisible());
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
action.resetEnabled();
QVERIFY(action.isEnabled());
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
}
void tst_QAction::setCheckabledSetChecked()
@@ -334,37 +334,37 @@ void tst_QAction::setCheckabledSetChecked()
QSignalSpy checkableSpy(&action, &QAction::checkableChanged);
QVERIFY(!action.isCheckable());
QVERIFY(!action.isChecked());
- QCOMPARE(changedSpy.count(), 0);
- QCOMPARE(checkedSpy.count(), 0);
- QCOMPARE(checkableSpy.count(), 0);
+ QCOMPARE(changedSpy.size(), 0);
+ QCOMPARE(checkedSpy.size(), 0);
+ QCOMPARE(checkableSpy.size(), 0);
action.setCheckable(true);
QVERIFY(action.isCheckable());
QVERIFY(!action.isChecked());
- QCOMPARE(changedSpy.count(), 1);
- QCOMPARE(checkedSpy.count(), 0);
- QCOMPARE(checkableSpy.count(), 1);
+ QCOMPARE(changedSpy.size(), 1);
+ QCOMPARE(checkedSpy.size(), 0);
+ QCOMPARE(checkableSpy.size(), 1);
action.setChecked(true);
QVERIFY(action.isCheckable());
QVERIFY(action.isChecked());
- QCOMPARE(changedSpy.count(), 2);
- QCOMPARE(checkedSpy.count(), 1);
- QCOMPARE(checkableSpy.count(), 1);
+ QCOMPARE(changedSpy.size(), 2);
+ QCOMPARE(checkedSpy.size(), 1);
+ QCOMPARE(checkableSpy.size(), 1);
action.setCheckable(false);
QVERIFY(!action.isCheckable());
QVERIFY(!action.isChecked());
- QCOMPARE(changedSpy.count(), 3);
- QCOMPARE(checkedSpy.count(), 2);
- QCOMPARE(checkableSpy.count(), 2);
+ QCOMPARE(changedSpy.size(), 3);
+ QCOMPARE(checkedSpy.size(), 2);
+ QCOMPARE(checkableSpy.size(), 2);
action.setCheckable(true);
QVERIFY(action.isCheckable());
QVERIFY(action.isChecked());
- QCOMPARE(changedSpy.count(), 4);
- QCOMPARE(checkedSpy.count(), 3);
- QCOMPARE(checkableSpy.count(), 3);
+ QCOMPARE(changedSpy.size(), 4);
+ QCOMPARE(checkedSpy.size(), 3);
+ QCOMPARE(checkableSpy.size(), 3);
}
QTEST_MAIN(tst_QAction)
diff --git a/tests/auto/gui/kernel/qactiongroup/CMakeLists.txt b/tests/auto/gui/kernel/qactiongroup/CMakeLists.txt
index 8d506606ee..360a20cc95 100644
--- a/tests/auto/gui/kernel/qactiongroup/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qactiongroup/CMakeLists.txt
@@ -1,12 +1,16 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
-# Generated from qactiongroup.pro.
-
#####################################################################
## tst_qactiongroup_kernel Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qactiongroup_kernel LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qactiongroup_kernel
SOURCES
tst_qactiongroup.cpp
diff --git a/tests/auto/gui/kernel/qactiongroup/tst_qactiongroup.cpp b/tests/auto/gui/kernel/qactiongroup/tst_qactiongroup.cpp
index 2e04e13b7e..a9e331e111 100644
--- a/tests/auto/gui/kernel/qactiongroup/tst_qactiongroup.cpp
+++ b/tests/auto/gui/kernel/qactiongroup/tst_qactiongroup.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 <QTest>
diff --git a/tests/auto/gui/kernel/qaddpostroutine/CMakeLists.txt b/tests/auto/gui/kernel/qaddpostroutine/CMakeLists.txt
index e2faf393a6..46a0475521 100644
--- a/tests/auto/gui/kernel/qaddpostroutine/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qaddpostroutine/CMakeLists.txt
@@ -1,12 +1,16 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
-# Generated from qaddpostroutine.pro.
-
#####################################################################
## tst_qaddpostroutine Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qaddpostroutine LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qaddpostroutine
SOURCES
tst_qaddpostroutine.cpp
diff --git a/tests/auto/gui/kernel/qaddpostroutine/tst_qaddpostroutine.cpp b/tests/auto/gui/kernel/qaddpostroutine/tst_qaddpostroutine.cpp
index c56eb3ff4c..c5cc0a9b20 100644
--- a/tests/auto/gui/kernel/qaddpostroutine/tst_qaddpostroutine.cpp
+++ b/tests/auto/gui/kernel/qaddpostroutine/tst_qaddpostroutine.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2020 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/gui/kernel/qbackingstore/CMakeLists.txt b/tests/auto/gui/kernel/qbackingstore/CMakeLists.txt
index 3213e64cd3..811da8bb53 100644
--- a/tests/auto/gui/kernel/qbackingstore/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qbackingstore/CMakeLists.txt
@@ -1,12 +1,16 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
-# Generated from qbackingstore.pro.
-
#####################################################################
## tst_qbackingstore Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qbackingstore LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qbackingstore
SOURCES
tst_qbackingstore.cpp
diff --git a/tests/auto/gui/kernel/qbackingstore/tst_qbackingstore.cpp b/tests/auto/gui/kernel/qbackingstore/tst_qbackingstore.cpp
index d9528fc8e4..a830d14be8 100644
--- a/tests/auto/gui/kernel/qbackingstore/tst_qbackingstore.cpp
+++ b/tests/auto/gui/kernel/qbackingstore/tst_qbackingstore.cpp
@@ -1,9 +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 <qwindow.h>
#include <qbackingstore.h>
#include <qpa/qplatformbackingstore.h>
+#include <qpa/qplatformintegration.h>
+#include <private/qguiapplication_p.h>
#include <qpainter.h>
#include <QTest>
@@ -30,6 +32,8 @@ private slots:
void scroll();
void flush();
+
+ void staticContents();
};
void tst_QBackingStore::initTestCase_data()
@@ -89,6 +93,11 @@ void tst_QBackingStore::paint()
QRect rect(0, 0, 100, 100);
backingStore.resize(rect.size());
+ // Partial fill of a fresh backingstore should not crash
+ backingStore.beginPaint(QRect(0, 0, 50, 50));
+ backingStore.endPaint();
+ backingStore.flush(rect);
+
// Two rounds, with flush in between
for (int i = 0; i < 2; ++i) {
backingStore.beginPaint(rect);
@@ -267,5 +276,79 @@ void tst_QBackingStore::flush()
QTRY_VERIFY(window.isExposed());
}
+void tst_QBackingStore::staticContents()
+{
+ const auto *integration = QGuiApplicationPrivate::platformIntegration();
+ if (!integration->hasCapability(QPlatformIntegration::BackingStoreStaticContents))
+ QSKIP("Platform does not support static backingstore content");
+
+ QWindow window;
+ window.create();
+
+ const auto dpr = window.devicePixelRatio();
+
+ QBackingStore backingStore(&window);
+
+ QRect initialRect(0, 0, 100, 100);
+
+ // Static contents without paint first should not crash
+ backingStore.setStaticContents(initialRect);
+ backingStore.resize(initialRect.size());
+ QCOMPARE(backingStore.size(), initialRect.size());
+ backingStore.beginPaint(QRect(0, 0, 50, 50));
+ backingStore.endPaint();
+ backingStore.handle()->toImage();
+
+ {
+ backingStore.setStaticContents(QRect());
+ backingStore.beginPaint(initialRect);
+ QPainter p(backingStore.paintDevice());
+ p.fillRect(initialRect, Qt::green);
+ p.end();
+ backingStore.endPaint();
+
+ QImage image = backingStore.handle()->toImage();
+ if (image.isNull())
+ QSKIP("Platform backingstore does not implement toImage");
+
+ QCOMPARE(image.pixelColor(initialRect.topLeft() * dpr), Qt::green);
+ QCOMPARE(image.pixelColor(initialRect.bottomLeft() * dpr), Qt::green);
+ QCOMPARE(image.pixelColor(initialRect.topRight() * dpr), Qt::green);
+ QCOMPARE(image.pixelColor(initialRect.bottomRight() * dpr), Qt::green);
+ }
+
+ {
+ backingStore.setStaticContents(initialRect);
+
+ QRect resizedRect(0, 0, 200, 200);
+ backingStore.resize(resizedRect.size());
+
+ QRegion repaintRegion = QRegion(resizedRect) - QRegion(initialRect);
+
+ backingStore.beginPaint(repaintRegion);
+ QPainter p(backingStore.paintDevice());
+ for (auto repaintRect : repaintRegion)
+ p.fillRect(repaintRect, Qt::red);
+ p.end();
+ backingStore.endPaint();
+
+ QImage image = backingStore.handle()->toImage();
+ if (image.isNull())
+ QSKIP("Platform backingstore does not implement toImage");
+
+ QCOMPARE(image.pixelColor(initialRect.topLeft() * dpr), Qt::green);
+ QCOMPARE(image.pixelColor(initialRect.bottomLeft() * dpr), Qt::green);
+ QCOMPARE(image.pixelColor(initialRect.topRight() * dpr), Qt::green);
+ QCOMPARE(image.pixelColor(initialRect.bottomRight() * dpr), Qt::green);
+
+ for (auto repaintRect : repaintRegion) {
+ QCOMPARE(image.pixelColor(repaintRect.topLeft() * dpr), Qt::red);
+ QCOMPARE(image.pixelColor(repaintRect.bottomLeft() * dpr), Qt::red);
+ QCOMPARE(image.pixelColor(repaintRect.topRight() * dpr), Qt::red);
+ QCOMPARE(image.pixelColor(repaintRect.bottomRight() * dpr), Qt::red);
+ }
+ }
+}
+
#include <tst_qbackingstore.moc>
QTEST_MAIN(tst_QBackingStore);
diff --git a/tests/auto/gui/kernel/qclipboard/CMakeLists.txt b/tests/auto/gui/kernel/qclipboard/CMakeLists.txt
index c779174136..b7a0467758 100644
--- a/tests/auto/gui/kernel/qclipboard/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qclipboard/CMakeLists.txt
@@ -1,7 +1,11 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
-# Generated from qclipboard.pro.
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qclipboard LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
add_subdirectory(copier)
add_subdirectory(paster)
diff --git a/tests/auto/gui/kernel/qclipboard/copier/CMakeLists.txt b/tests/auto/gui/kernel/qclipboard/copier/CMakeLists.txt
index 8ec9889037..ea7def8c0d 100644
--- a/tests/auto/gui/kernel/qclipboard/copier/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qclipboard/copier/CMakeLists.txt
@@ -1,26 +1,16 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
-# Generated from copier.pro.
-
#####################################################################
## copier Binary:
#####################################################################
-# special case begin
set(args OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
-# special case end
qt_internal_add_executable(copier
- ${args} # special case
+ ${args}
SOURCES
main.cpp
LIBRARIES
Qt::Gui
)
-
-## Scopes:
-#####################################################################
-
-#### Keys ignored in scope 2:.:.:copier.pro:WIN32:
-# DESTDIR = "../copier"
diff --git a/tests/auto/gui/kernel/qclipboard/copier/main.cpp b/tests/auto/gui/kernel/qclipboard/copier/main.cpp
index 411ac1e00e..362ede38b7 100644
--- a/tests/auto/gui/kernel/qclipboard/copier/main.cpp
+++ b/tests/auto/gui/kernel/qclipboard/copier/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 <QtGui/QGuiApplication>
#include <QtGui/QClipboard>
#include <QtCore/QStringList>
diff --git a/tests/auto/gui/kernel/qclipboard/paster/CMakeLists.txt b/tests/auto/gui/kernel/qclipboard/paster/CMakeLists.txt
index 1f6f2bd221..9bc1985ee4 100644
--- a/tests/auto/gui/kernel/qclipboard/paster/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qclipboard/paster/CMakeLists.txt
@@ -1,26 +1,16 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
-# Generated from paster.pro.
-
#####################################################################
## paster Binary:
#####################################################################
-# special case begin
set(args OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
-# special case end
qt_internal_add_executable(paster
- ${args} # special case
+ ${args}
SOURCES
main.cpp
LIBRARIES
Qt::Gui
)
-
-## Scopes:
-#####################################################################
-
-#### Keys ignored in scope 2:.:.:paster.pro:WIN32:
-# DESTDIR = "../paster"
diff --git a/tests/auto/gui/kernel/qclipboard/paster/main.cpp b/tests/auto/gui/kernel/qclipboard/paster/main.cpp
index 06db447569..bf47b10ba6 100644
--- a/tests/auto/gui/kernel/qclipboard/paster/main.cpp
+++ b/tests/auto/gui/kernel/qclipboard/paster/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 <QtGui/QGuiApplication>
#include <QtGui/QClipboard>
#include <QtGui/QImage>
diff --git a/tests/auto/gui/kernel/qclipboard/test/BLACKLIST b/tests/auto/gui/kernel/qclipboard/test/BLACKLIST
new file mode 100644
index 0000000000..3ca7791b37
--- /dev/null
+++ b/tests/auto/gui/kernel/qclipboard/test/BLACKLIST
@@ -0,0 +1,5 @@
+# QTBUG-87429
+[testSignals]
+android
+[setMimeData]
+android
diff --git a/tests/auto/gui/kernel/qclipboard/test/CMakeLists.txt b/tests/auto/gui/kernel/qclipboard/test/CMakeLists.txt
index aef88e9346..fad30c16fd 100644
--- a/tests/auto/gui/kernel/qclipboard/test/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qclipboard/test/CMakeLists.txt
@@ -1,8 +1,6 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
-# Generated from test.pro.
-
#####################################################################
## tst_qclipboard Test:
#####################################################################
@@ -24,5 +22,4 @@ qt_internal_extend_target(tst_qclipboard CONDITION MACOS
${FWAppKit}
)
-#### Keys ignored in scope 6:.:.:test.pro:NOT ANDROID:
# TEST_HELPER_INSTALLS = "../copier/copier" "../paster/paster"
diff --git a/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp b/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp
index 4163d072e0..30366c6aa1 100644
--- a/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp
+++ b/tests/auto/gui/kernel/qclipboard/tst_qclipboard.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>
@@ -21,8 +21,9 @@
#ifdef Q_OS_WIN
# include <QtGui/private/qguiapplication_p.h>
-# include <QtGui/private/qwindowsmime_p.h>
+# include <QtGui/qwindowsmimeconverter.h>
# include <QtGui/qpa/qplatformintegration.h>
+# include <QtCore/qt_windows.h>
#endif
class tst_QClipboard : public QObject
@@ -41,6 +42,7 @@ private slots:
void testSignals();
void setMimeData();
void clearBeforeSetText();
+ void getTextFromHTMLMimeType();
# ifdef Q_OS_WIN
void testWindowsMimeRegisterType();
void testWindowsMime_data();
@@ -61,7 +63,7 @@ void tst_QClipboard::initTestCase()
#if QT_CONFIG(clipboard)
void tst_QClipboard::init()
{
-#if QT_CONFIG(process)
+#if QT_CONFIG(process) && !defined(Q_OS_ANDROID)
const QString testdataDir = QFileInfo(QFINDTESTDATA("copier")).absolutePath();
QVERIFY2(QDir::setCurrent(testdataDir), qPrintable("Could not chdir to " + testdataDir));
#endif
@@ -124,7 +126,7 @@ public:
operator bool() const
{
- if (m_timer.elapsed() && !m_spy.count())
+ if (m_timer.elapsed() && !m_spy.size())
return true;
m_spy.clear();
return false;
@@ -166,11 +168,11 @@ void tst_QClipboard::testSignals()
// Test the default mode signal.
clipboard->setText(text);
- QTRY_COMPARE(dataChangedSpy.count(), 1);
- QCOMPARE(searchChangedSpy.count(), 0);
- QCOMPARE(selectionChangedSpy.count(), 0);
- QCOMPARE(changedSpy.count(), 1);
- QCOMPARE(changedSpy.at(0).count(), 1);
+ QTRY_COMPARE(dataChangedSpy.size(), 1);
+ QCOMPARE(searchChangedSpy.size(), 0);
+ QCOMPARE(selectionChangedSpy.size(), 0);
+ QCOMPARE(changedSpy.size(), 1);
+ QCOMPARE(changedSpy.at(0).size(), 1);
QCOMPARE(qvariant_cast<QClipboard::Mode>(changedSpy.at(0).at(0)), QClipboard::Clipboard);
changedSpy.clear();
@@ -178,29 +180,29 @@ void tst_QClipboard::testSignals()
// Test the selection mode signal.
if (clipboard->supportsSelection()) {
clipboard->setText(text, QClipboard::Selection);
- QCOMPARE(selectionChangedSpy.count(), 1);
- QCOMPARE(changedSpy.count(), 1);
- QCOMPARE(changedSpy.at(0).count(), 1);
+ QCOMPARE(selectionChangedSpy.size(), 1);
+ QCOMPARE(changedSpy.size(), 1);
+ QCOMPARE(changedSpy.at(0).size(), 1);
QCOMPARE(qvariant_cast<QClipboard::Mode>(changedSpy.at(0).at(0)), QClipboard::Selection);
} else {
- QCOMPARE(selectionChangedSpy.count(), 0);
+ QCOMPARE(selectionChangedSpy.size(), 0);
}
- QCOMPARE(dataChangedSpy.count(), 1);
- QCOMPARE(searchChangedSpy.count(), 0);
+ QCOMPARE(dataChangedSpy.size(), 1);
+ QCOMPARE(searchChangedSpy.size(), 0);
changedSpy.clear();
// Test the search mode signal.
if (clipboard->supportsFindBuffer()) {
clipboard->setText(text, QClipboard::FindBuffer);
- QCOMPARE(searchChangedSpy.count(), 1);
- QCOMPARE(changedSpy.count(), 1);
- QCOMPARE(changedSpy.at(0).count(), 1);
+ QCOMPARE(searchChangedSpy.size(), 1);
+ QCOMPARE(changedSpy.size(), 1);
+ QCOMPARE(changedSpy.at(0).size(), 1);
QCOMPARE(qvariant_cast<QClipboard::Mode>(changedSpy.at(0).at(0)), QClipboard::FindBuffer);
} else {
- QCOMPARE(searchChangedSpy.count(), 0);
+ QCOMPARE(searchChangedSpy.size(), 0);
}
- QCOMPARE(dataChangedSpy.count(), 1);
+ QCOMPARE(dataChangedSpy.size(), 1);
}
#if defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(Q_OS_QNX)
@@ -340,16 +342,16 @@ void tst_QClipboard::setMimeData()
QGuiApplication::clipboard()->clear(QClipboard::FindBuffer);
if (QGuiApplication::clipboard()->supportsSelection())
- QCOMPARE(spySelection.count(), 1);
+ QCOMPARE(spySelection.size(), 1);
else
- QCOMPARE(spySelection.count(), 0);
+ QCOMPARE(spySelection.size(), 0);
if (QGuiApplication::clipboard()->supportsFindBuffer())
- QCOMPARE(spyFindBuffer.count(), 1);
+ QCOMPARE(spyFindBuffer.size(), 1);
else
- QCOMPARE(spyFindBuffer.count(), 0);
+ QCOMPARE(spyFindBuffer.size(), 0);
- QTRY_COMPARE(spyData.count(), 1);
+ QTRY_COMPARE(spyData.size(), 1);
// an other crash test
data = new QMimeData;
@@ -376,16 +378,16 @@ void tst_QClipboard::setMimeData()
QGuiApplication::clipboard()->setMimeData(newData, QClipboard::FindBuffer);
if (QGuiApplication::clipboard()->supportsSelection())
- QCOMPARE(spySelection.count(), 1);
+ QCOMPARE(spySelection.size(), 1);
else
- QCOMPARE(spySelection.count(), 0);
+ QCOMPARE(spySelection.size(), 0);
if (QGuiApplication::clipboard()->supportsFindBuffer())
- QCOMPARE(spyFindBuffer.count(), 1);
+ QCOMPARE(spyFindBuffer.size(), 1);
else
- QCOMPARE(spyFindBuffer.count(), 0);
+ QCOMPARE(spyFindBuffer.size(), 0);
- QTRY_COMPARE(spyData.count(), 1);
+ QTRY_COMPARE(spyData.size(), 1);
}
void tst_QClipboard::clearBeforeSetText()
@@ -424,12 +426,30 @@ void tst_QClipboard::clearBeforeSetText()
QCOMPARE(QGuiApplication::clipboard()->text(), text);
}
+void tst_QClipboard::getTextFromHTMLMimeType()
+{
+ QClipboard * clipboard = QGuiApplication::clipboard();
+ QMimeData * mimeData = new QMimeData();
+ const QString testString("TEST");
+ const QString htmlString(QLatin1String("<html><body>") + testString + QLatin1String("</body></html>"));
+
+ mimeData->setText(testString);
+ mimeData->setHtml(htmlString);
+ clipboard->setMimeData(mimeData);
+
+ QCOMPARE(clipboard->text(), testString);
+ QVERIFY(clipboard->mimeData()->hasText());
+ QVERIFY(clipboard->mimeData()->hasHtml());
+ QCOMPARE(clipboard->mimeData()->text(), testString);
+ QCOMPARE(clipboard->mimeData()->html(), htmlString);
+}
+
# ifdef Q_OS_WIN
-using QWindowsMime = QNativeInterface::Private::QWindowsMime;
+using QWindowsMimeConverter = QWindowsMimeConverter;
using QWindowsApplication = QNativeInterface::Private::QWindowsApplication;
-class TestMime : public QWindowsMime
+class TestMime : public QWindowsMimeConverter
{
public:
bool canConvertFromMime(const FORMATETC &, const QMimeData *) const override
diff --git a/tests/auto/gui/kernel/qcursor/CMakeLists.txt b/tests/auto/gui/kernel/qcursor/CMakeLists.txt
index 1f5902ed93..52c88fc231 100644
--- a/tests/auto/gui/kernel/qcursor/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qcursor/CMakeLists.txt
@@ -1,12 +1,16 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
-# Generated from qcursor.pro.
-
#####################################################################
## tst_qcursor Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qcursor LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qcursor
SOURCES
tst_qcursor.cpp
diff --git a/tests/auto/gui/kernel/qcursor/tst_qcursor.cpp b/tests/auto/gui/kernel/qcursor/tst_qcursor.cpp
index 42ef690efa..edc44b9ea6 100644
--- a/tests/auto/gui/kernel/qcursor/tst_qcursor.cpp
+++ b/tests/auto/gui/kernel/qcursor/tst_qcursor.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2017 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtTest/QTest>
#include <qcursor.h>
diff --git a/tests/auto/gui/kernel/qdrag/CMakeLists.txt b/tests/auto/gui/kernel/qdrag/CMakeLists.txt
index d615df8d70..015cfe70d0 100644
--- a/tests/auto/gui/kernel/qdrag/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qdrag/CMakeLists.txt
@@ -1,12 +1,16 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
-# Generated from qdrag.pro.
-
#####################################################################
## tst_qdrag Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qdrag LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qdrag
SOURCES
tst_qdrag.cpp
diff --git a/tests/auto/gui/kernel/qdrag/tst_qdrag.cpp b/tests/auto/gui/kernel/qdrag/tst_qdrag.cpp
index 8891ddc4ea..9e0d5ad0f4 100644
--- a/tests/auto/gui/kernel/qdrag/tst_qdrag.cpp
+++ b/tests/auto/gui/kernel/qdrag/tst_qdrag.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/gui/kernel/qevent/CMakeLists.txt b/tests/auto/gui/kernel/qevent/CMakeLists.txt
index f406e977b6..c6ad861f25 100644
--- a/tests/auto/gui/kernel/qevent/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qevent/CMakeLists.txt
@@ -1,12 +1,16 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
-# Generated from qevent.pro.
-
#####################################################################
## tst_qevent Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qevent LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qevent
SOURCES
tst_qevent.cpp
diff --git a/tests/auto/gui/kernel/qevent/tst_qevent.cpp b/tests/auto/gui/kernel/qevent/tst_qevent.cpp
index f1ffb8c35e..8e8169b16c 100644
--- a/tests/auto/gui/kernel/qevent/tst_qevent.cpp
+++ b/tests/auto/gui/kernel/qevent/tst_qevent.cpp
@@ -1,12 +1,57 @@
// 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/qguiapplication.h>
#include <QtGui/qevent.h>
+#if QT_CONFIG(future)
#include <QtCore/private/qfutureinterface_p.h>
+#endif
+
+
+#if QT_CONFIG(future)
+#define X_QFutureCallOutEvent(X) X(QFutureCallOutEvent, ())
+#else
+#define X_QFutureCallOutEvent(X)
+#endif
+
+#if QT_CONFIG(wheelevent)
+#define X_QWheelEvent(X) X(QWheelEvent, ({}, {}, {}, {}, {}, {}, {}, {}))
+#else
+#define X_QWheelEvent(X)
+#endif
+
+#if QT_CONFIG(tabletevent)
+#define X_QTabletEvent(X) X(QTabletEvent, (QEvent::None, QPointingDevice::primaryPointingDevice(), {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}))
+#else
+#define X_QTabletEvent(X)
+#endif
+
+#if QT_CONFIG(gestures)
+#define X_QNativeGestureEvent(X) X(QNativeGestureEvent, ({}, QPointingDevice::primaryPointingDevice(), 0, {}, {}, {}, {}, {}))
+#else
+#define X_QNativeGestureEvent(X)
+#endif
+
+#if QT_CONFIG(whatsthis)
+#define X_QWhatsThisClickedEvent(X) X(QWhatsThisClickedEvent, ({}))
+#else
+#define X_QWhatsThisClickedEvent(X)
+#endif
+
+#if QT_CONFIG(action)
+#define X_QActionEvent(X) X(QActionEvent, (0, nullptr))
+#else
+#define X_QActionEvent(X)
+#endif
+
+#if QT_CONFIG(shortcut)
+#define X_QShortcutEvent(X) X(QShortcutEvent, ({}, 0))
+#else
+#define X_QShortcutEvent(X)
+#endif
#define FOR_EACH_CORE_EVENT(X) \
/* qcoreevent.h */ \
@@ -14,9 +59,8 @@
X(QTimerEvent, (42)) \
X(QChildEvent, (QEvent::ChildAdded, nullptr)) \
X(QDynamicPropertyChangeEvent, ("size")) \
- X(QDeferredDeleteEvent, ()) \
/* qfutureinterface_p.h */ \
- X(QFutureCallOutEvent, ()) \
+ X_QFutureCallOutEvent(X) \
/* end */
#define FOR_EACH_GUI_EVENT(X) \
@@ -28,9 +72,9 @@
X(QEnterEvent, ({}, {}, {})) \
X(QMouseEvent, (QEvent::None, {}, {}, {}, {}, {}, {}, {}, QPointingDevice::primaryPointingDevice())) \
X(QHoverEvent, (QEvent::None, {}, {}, QPointF{})) \
- X(QWheelEvent, ({}, {}, {}, {}, {}, {}, {}, {})) \
- X(QTabletEvent, (QEvent::None, QPointingDevice::primaryPointingDevice(), {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {})) \
- X(QNativeGestureEvent, ({}, QPointingDevice::primaryPointingDevice(), 0, {}, {}, {}, {}, {})) \
+ X_QWheelEvent(X) \
+ X_QTabletEvent(X) \
+ X_QNativeGestureEvent(X) \
X(QKeyEvent, (QEvent::None, 0, {})) \
X(QFocusEvent, (QEvent::None)) \
X(QPaintEvent, (QRect{0, 0, 100, 100})) \
@@ -51,11 +95,11 @@
X(QDragLeaveEvent, ()) \
X(QHelpEvent, ({}, {}, {})) \
X(QStatusTipEvent, ({})) \
- X(QWhatsThisClickedEvent, ({})) \
- X(QActionEvent, (0, nullptr)) \
+ X_QWhatsThisClickedEvent(X) \
+ X_QActionEvent(X) \
X(QFileOpenEvent, (QString{})) \
X(QToolBarChangeEvent, (false)) \
- X(QShortcutEvent, ({}, 0)) \
+ X_QShortcutEvent(X) \
X(QWindowStateChangeEvent, ({})) \
X(QTouchEvent, (QEvent::None)) \
X(QScrollPrepareEvent, ({})) \
diff --git a/tests/auto/gui/kernel/qfileopenevent/CMakeLists.txt b/tests/auto/gui/kernel/qfileopenevent/CMakeLists.txt
index c4a1a93236..9906400a66 100644
--- a/tests/auto/gui/kernel/qfileopenevent/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qfileopenevent/CMakeLists.txt
@@ -1,7 +1,11 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
-# Generated from qfileopenevent.pro.
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qfileopenevent LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
add_subdirectory(test)
add_subdirectory(qfileopeneventexternal)
diff --git a/tests/auto/gui/kernel/qfileopenevent/qfileopeneventexternal/CMakeLists.txt b/tests/auto/gui/kernel/qfileopenevent/qfileopeneventexternal/CMakeLists.txt
index 785c9e32e4..7a39bc111c 100644
--- a/tests/auto/gui/kernel/qfileopenevent/qfileopeneventexternal/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qfileopenevent/qfileopeneventexternal/CMakeLists.txt
@@ -1,8 +1,6 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
-# Generated from qfileopeneventexternal.pro.
-
#####################################################################
## qfileopeneventexternal Binary:
#####################################################################
@@ -14,6 +12,3 @@ qt_internal_add_executable(qfileopeneventexternal
LIBRARIES
Qt::Gui
)
-
-#### Keys ignored in scope 1:.:.:qfileopeneventexternal.pro:<TRUE>:
-# TEMPLATE = "app"
diff --git a/tests/auto/gui/kernel/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.cpp b/tests/auto/gui/kernel/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.cpp
index 6e50a96258..bd74e7497f 100644
--- a/tests/auto/gui/kernel/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.cpp
+++ b/tests/auto/gui/kernel/qfileopenevent/qfileopeneventexternal/qfileopeneventexternal.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 <QtGui>
#include <QEvent>
@@ -14,8 +14,8 @@ struct MyApplication : public QGuiApplication
{
if (event->type() == QEvent::FileOpen) {
QFileOpenEvent* ev = static_cast<QFileOpenEvent *>(event);
- QFile file;
- bool ok = ev->openFile(file, QFile::Append | QFile::Unbuffered);
+ QFile file(ev->file());
+ bool ok = file.open(QFile::Append | QFile::Unbuffered);
if (ok)
file.write(QByteArray("+external"));
return true;
diff --git a/tests/auto/gui/kernel/qfileopenevent/test/CMakeLists.txt b/tests/auto/gui/kernel/qfileopenevent/test/CMakeLists.txt
index 146b1fb21e..d7f4e32f70 100644
--- a/tests/auto/gui/kernel/qfileopenevent/test/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qfileopenevent/test/CMakeLists.txt
@@ -1,8 +1,6 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
-# Generated from test.pro.
-
#####################################################################
## tst_qfileopenevent Test:
#####################################################################
diff --git a/tests/auto/gui/kernel/qfileopenevent/test/tst_qfileopenevent.cpp b/tests/auto/gui/kernel/qfileopenevent/test/tst_qfileopenevent.cpp
index b526240d88..4b9a23ffcf 100644
--- a/tests/auto/gui/kernel/qfileopenevent/test/tst_qfileopenevent.cpp
+++ b/tests/auto/gui/kernel/qfileopenevent/test/tst_qfileopenevent.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 <QtCore/QTemporaryDir>
#include <QTest>
@@ -54,7 +54,7 @@ void tst_qfileopenevent::cleanupTestCase()
void tst_qfileopenevent::createFile(const QString &filename, const QByteArray &content)
{
QFile file(filename);
- file.open(QFile::WriteOnly);
+ QVERIFY(file.open(QFile::WriteOnly));
file.write(content);
file.close();
}
@@ -78,8 +78,9 @@ void tst_qfileopenevent::constructor()
QByteArray tst_qfileopenevent::readFileContent(QFileOpenEvent& event)
{
- QFile file;
- event.openFile(file, QFile::ReadOnly);
+ QFile file(event.file());
+ if (!file.open(QFile::ReadOnly))
+ qFatal("Cannot open file %s", qPrintable(event.file()));
file.seek(0);
QByteArray data = file.readAll();
return data;
@@ -87,8 +88,8 @@ QByteArray tst_qfileopenevent::readFileContent(QFileOpenEvent& event)
bool tst_qfileopenevent::appendFileContent(QFileOpenEvent& event, const QByteArray& writeContent)
{
- QFile file;
- bool ok = event.openFile(file, QFile::Append | QFile::Unbuffered);
+ QFile file(event.file());
+ bool ok = file.open(QFile::Append | QFile::Unbuffered);
if (ok)
ok = file.write(writeContent) == writeContent.size();
return ok;
@@ -127,8 +128,8 @@ void tst_qfileopenevent::handleLifetime()
QScopedPointer<QFileOpenEvent> event(createFileAndEvent(QLatin1String("testHandleLifetime"), QByteArray("test content")));
// open a QFile after the original RFile is closed
- QFile qFile;
- QCOMPARE(event->openFile(qFile, QFile::Append | QFile::Unbuffered), true);
+ QFile qFile(event->file());
+ QVERIFY(qFile.open(QFile::Append | QFile::Unbuffered));
event.reset(0);
// write to the QFile after the event is closed
@@ -138,7 +139,7 @@ void tst_qfileopenevent::handleLifetime()
// check the content
QFile checkContent("testHandleLifetime");
- checkContent.open(QFile::ReadOnly);
+ QVERIFY(checkContent.open(QFile::ReadOnly));
QString content(checkContent.readAll());
QCOMPARE(content, QLatin1String("test content+closed original handles"));
checkContent.close();
@@ -152,7 +153,8 @@ void tst_qfileopenevent::multiOpen()
QFile files[5];
for (int i=0; i<5; i++) {
- QCOMPARE(event->openFile(files[i], QFile::ReadOnly), true);
+ files[i].setFileName(event->file());
+ QVERIFY(files[i].open(QFile::ReadOnly));
}
for (int i=0; i<5; i++)
files[i].seek(i);
diff --git a/tests/auto/gui/kernel/qguiapplication/CMakeLists.txt b/tests/auto/gui/kernel/qguiapplication/CMakeLists.txt
index e2bc3bb0f8..6f1f845edd 100644
--- a/tests/auto/gui/kernel/qguiapplication/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qguiapplication/CMakeLists.txt
@@ -1,19 +1,21 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
-# Generated from qguiapplication.pro.
-
#####################################################################
## tst_qguiapplication Test:
#####################################################################
-# special case begin
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qguiapplication LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
if (WIN32)
set(target_version "1.2.3.4")
else()
set(target_version "1.2.3")
endif()
-# special case end
# Resources:
set(tst_qguiapplication_resource_files
@@ -22,9 +24,9 @@ set(tst_qguiapplication_resource_files
)
qt_internal_add_test(tst_qguiapplication
- VERSION ${target_version} # special case
+ VERSION ${target_version}
SOURCES
- ../../../corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp ../../../corelib/kernel/qcoreapplication/tst_qcoreapplication.h # special case
+ ../../../corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp ../../../corelib/kernel/qcoreapplication/tst_qcoreapplication.h
tst_qguiapplication.cpp
DEFINES
QT_QGUIAPPLICATIONTEST=1
@@ -40,9 +42,7 @@ qt_internal_add_test(tst_qguiapplication
if (ANDROID)
set_property(TARGET tst_qguiapplication PROPERTY QT_ANDROID_VERSION_NAME ${target_version})
endif()
-# special case begin
if (APPLE)
set_property(TARGET tst_qguiapplication PROPERTY MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Info.plist")
set_property(TARGET tst_qguiapplication PROPERTY PROPERTY MACOSX_BUNDLE TRUE)
endif()
-# special case end
diff --git a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp
index f1851e72bc..d1a50e3d69 100644
--- a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp
+++ b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.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>
@@ -47,6 +47,7 @@ private slots:
void changeFocusWindow();
void keyboardModifiers();
void palette();
+ void paletteNoCrash();
void font();
void modalWindow();
void quitOnLastWindowClosed();
@@ -60,6 +61,8 @@ private slots:
void staticFunctions();
+ void topLevelAt();
+
void settableStyleHints_data();
void settableStyleHints(); // Needs to run last as it changes style hints.
};
@@ -98,20 +101,20 @@ void tst_QGuiApplication::displayName()
QGuiApplication::setApplicationName("The Core Application");
QCOMPARE(QGuiApplication::applicationName(), QString::fromLatin1("The Core Application"));
QCOMPARE(QGuiApplication::applicationDisplayName(), QString::fromLatin1("The Core Application"));
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QGuiApplication::setApplicationDisplayName("The GUI Application");
QCOMPARE(QGuiApplication::applicationDisplayName(), QString::fromLatin1("The GUI Application"));
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
QGuiApplication::setApplicationName("The Core Application 2");
QCOMPARE(QGuiApplication::applicationName(), QString::fromLatin1("The Core Application 2"));
QCOMPARE(QGuiApplication::applicationDisplayName(), QString::fromLatin1("The GUI Application"));
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
QGuiApplication::setApplicationDisplayName("The GUI Application 2");
QCOMPARE(QGuiApplication::applicationDisplayName(), QString::fromLatin1("The GUI Application 2"));
- QCOMPARE(spy.count(), 3);
+ QCOMPARE(spy.size(), 3);
}
void tst_QGuiApplication::desktopFileName()
@@ -122,8 +125,8 @@ void tst_QGuiApplication::desktopFileName()
QCOMPARE(QGuiApplication::desktopFileName(), QString());
- QGuiApplication::setDesktopFileName("io.qt.QGuiApplication.desktop");
- QCOMPARE(QGuiApplication::desktopFileName(), QString::fromLatin1("io.qt.QGuiApplication.desktop"));
+ QGuiApplication::setDesktopFileName("io.qt.QGuiApplication");
+ QCOMPARE(QGuiApplication::desktopFileName(), QString::fromLatin1("io.qt.QGuiApplication"));
QGuiApplication::setDesktopFileName(QString());
QCOMPARE(QGuiApplication::desktopFileName(), QString());
@@ -222,12 +225,12 @@ void tst_QGuiApplication::focusObject()
window1.setFocusObject(&obj1);
QCOMPARE(app.focusObject(), &obj1);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
window1.setFocusObject(&obj2);
QCOMPARE(app.focusObject(), &obj2);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
window2.setFocusObject(&obj3);
@@ -236,12 +239,12 @@ void tst_QGuiApplication::focusObject()
QVERIFY(QTest::qWaitForWindowExposed(&window2));
QTRY_COMPARE(app.focusWindow(), &window2);
QCOMPARE(app.focusObject(), &obj3);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
// focus change on unfocused window does not show
spy.clear();
window1.setFocusObject(&obj1);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
QCOMPARE(app.focusObject(), &obj3);
}
@@ -253,13 +256,13 @@ void tst_QGuiApplication::allWindows()
QWindow *window2 = new QWindow(window1);
QVERIFY(app.allWindows().contains(window1));
QVERIFY(app.allWindows().contains(window2));
- QCOMPARE(app.allWindows().count(), 2);
+ QCOMPARE(app.allWindows().size(), 2);
delete window1;
window1 = nullptr;
window2 = nullptr;
QVERIFY(!app.allWindows().contains(window2));
QVERIFY(!app.allWindows().contains(window1));
- QCOMPARE(app.allWindows().count(), 0);
+ QCOMPARE(app.allWindows().size(), 0);
}
void tst_QGuiApplication::topLevelWindows()
@@ -270,13 +273,13 @@ void tst_QGuiApplication::topLevelWindows()
QWindow *window2 = new QWindow(window1);
QVERIFY(app.topLevelWindows().contains(window1));
QVERIFY(!app.topLevelWindows().contains(window2));
- QCOMPARE(app.topLevelWindows().count(), 1);
+ QCOMPARE(app.topLevelWindows().size(), 1);
delete window1;
window1 = nullptr;
window2 = nullptr;
QVERIFY(!app.topLevelWindows().contains(window2));
QVERIFY(!app.topLevelWindows().contains(window1));
- QCOMPARE(app.topLevelWindows().count(), 0);
+ QCOMPARE(app.topLevelWindows().size(), 0);
}
class ShowCloseShowWindow : public QWindow
@@ -457,16 +460,12 @@ void tst_QGuiApplication::keyboardModifiers()
QCOMPARE(QGuiApplication::keyboardModifiers(), Qt::ControlModifier);
// wheel events
- QPoint global = window->mapToGlobal(center);
QPoint delta(0, 1);
- QWindowSystemInterface::handleWheelEvent(window.data(), center, global, delta, delta, Qt::NoModifier);
- QWindowSystemInterface::sendWindowSystemEvents(QEventLoop::AllEvents);
+ QTest::wheelEvent(window.data(), center, delta, delta, Qt::NoModifier);
QCOMPARE(QGuiApplication::keyboardModifiers(), Qt::NoModifier);
- QWindowSystemInterface::handleWheelEvent(window.data(), center, global, delta, delta, Qt::AltModifier);
- QWindowSystemInterface::sendWindowSystemEvents(QEventLoop::AllEvents);
+ QTest::wheelEvent(window.data(), center, delta, delta, Qt::AltModifier);
QCOMPARE(QGuiApplication::keyboardModifiers(), Qt::AltModifier);
- QWindowSystemInterface::handleWheelEvent(window.data(), center, global, delta, delta, Qt::ControlModifier);
- QWindowSystemInterface::sendWindowSystemEvents(QEventLoop::AllEvents);
+ QTest::wheelEvent(window.data(), center, delta, delta, Qt::ControlModifier);
QCOMPARE(QGuiApplication::keyboardModifiers(), Qt::ControlModifier);
// touch events
@@ -531,7 +530,7 @@ void tst_QGuiApplication::palette()
QGuiApplication::setPalette(newPalette);
QVERIFY(palettesMatch(QGuiApplication::palette(), newPalette));
#if QT_DEPRECATED_SINCE(6, 0)
- QCOMPARE(signalSpy.count(), 1);
+ QCOMPARE(signalSpy.size(), 1);
QVERIFY(palettesMatch(signalSpy.at(0).at(0).value<QPalette>(), newPalette));
#endif
QCOMPARE(QGuiApplication::palette(), QPalette());
@@ -539,7 +538,7 @@ void tst_QGuiApplication::palette()
QGuiApplication::setPalette(oldPalette);
QVERIFY(palettesMatch(QGuiApplication::palette(), oldPalette));
#if QT_DEPRECATED_SINCE(6, 0)
- QCOMPARE(signalSpy.count(), 2);
+ QCOMPARE(signalSpy.size(), 2);
QVERIFY(palettesMatch(signalSpy.at(1).at(0).value<QPalette>(), oldPalette));
#endif
QCOMPARE(QGuiApplication::palette(), QPalette());
@@ -547,11 +546,20 @@ void tst_QGuiApplication::palette()
QGuiApplication::setPalette(oldPalette);
QVERIFY(palettesMatch(QGuiApplication::palette(), oldPalette));
#if QT_DEPRECATED_SINCE(6, 0)
- QCOMPARE(signalSpy.count(), 2);
+ QCOMPARE(signalSpy.size(), 2);
#endif
QCOMPARE(QGuiApplication::palette(), QPalette());
}
+void tst_QGuiApplication::paletteNoCrash()
+{
+ QGuiApplication::setDesktopSettingsAware(false);
+ int argc = 1;
+ char *argv[] = { const_cast<char*>("tst_qguiapplication") };
+ // this would crash on windows (QTBUG-111527)
+ QGuiApplication a(argc, argv);
+}
+
void tst_QGuiApplication::font()
{
int argc = 1;
@@ -567,21 +575,21 @@ void tst_QGuiApplication::font()
QGuiApplication::setFont(newFont);
QCOMPARE(QGuiApplication::font(), newFont);
#if QT_DEPRECATED_SINCE(6, 0)
- QCOMPARE(signalSpy.count(), 1);
+ QCOMPARE(signalSpy.size(), 1);
QCOMPARE(signalSpy.at(0).at(0), QVariant(newFont));
#endif
QGuiApplication::setFont(oldFont);
QCOMPARE(QGuiApplication::font(), oldFont);
#if QT_DEPRECATED_SINCE(6, 0)
- QCOMPARE(signalSpy.count(), 2);
+ QCOMPARE(signalSpy.size(), 2);
QCOMPARE(signalSpy.at(1).at(0), QVariant(oldFont));
#endif
QGuiApplication::setFont(oldFont);
QCOMPARE(QGuiApplication::font(), oldFont);
#if QT_DEPRECATED_SINCE(6, 0)
- QCOMPARE(signalSpy.count(), 2);
+ QCOMPARE(signalSpy.size(), 2);
#endif
}
@@ -887,9 +895,9 @@ void tst_QGuiApplication::quitOnLastWindowClosed()
app.exec();
- QCOMPARE(spyAboutToQuit.count(), 1);
+ QCOMPARE(spyAboutToQuit.size(), 1);
// Should be around 10 if closing caused the quit
- QVERIFY2(spyTimeout.count() < 15, QByteArray::number(spyTimeout.count()).constData());
+ QVERIFY2(spyTimeout.size() < 15, QByteArray::number(spyTimeout.size()).constData());
}
void tst_QGuiApplication::quitOnLastWindowClosedMulti()
@@ -930,7 +938,7 @@ void tst_QGuiApplication::quitOnLastWindowClosedMulti()
app.exec();
QVERIFY(!prematureQuit);
- QCOMPARE(spyAboutToQuit.count(), 1); // fired only once
+ QCOMPARE(spyAboutToQuit.size(), 1); // fired only once
}
void tst_QGuiApplication::dontQuitOnLastWindowClosed()
@@ -958,8 +966,8 @@ void tst_QGuiApplication::dontQuitOnLastWindowClosed()
app.setQuitOnLastWindowClosed(true); // restore underlying static to default value
- QCOMPARE(spyTimeout.count(), 1); // quit timer fired
- QCOMPARE(spyLastWindowClosed.count(), 1); // lastWindowClosed emitted
+ QCOMPARE(spyTimeout.size(), 1); // quit timer fired
+ QCOMPARE(spyLastWindowClosed.size(), 1); // lastWindowClosed emitted
}
class QuitSpy : public QObject
@@ -996,10 +1004,27 @@ void tst_QGuiApplication::quitOnLastWindowClosedWithEventLoopLocker()
});
{
- // Disabling QEventLoopLocker support should not affect
- // quitting when last window is closed.
+ // Disabling QEventLoopLocker automatic quit should not affect
+ // quitting when last window is closed if there are no lockers.
+ app.setQuitLockEnabled(false);
+
+ QuitSpy quitSpy;
+ QWindow window;
+ window.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&window));
+ QTimer::singleShot(0, &window, &QWindow::close);
+ QTimer::singleShot(200, &app, []{ QCoreApplication::exit(0); });
+ app.exec();
+ QCOMPARE(quitSpy.quits, 1);
+ }
+
+ {
+ // Disabling QEventLoopLocker automatic quit should still block
+ // quitting when last window is closed if there is a locker alive.
app.setQuitLockEnabled(false);
+ QScopedPointer<QEventLoopLocker> locker(new QEventLoopLocker);
+
QuitSpy quitSpy;
QWindow window;
window.show();
@@ -1007,12 +1032,27 @@ void tst_QGuiApplication::quitOnLastWindowClosedWithEventLoopLocker()
QTimer::singleShot(0, &window, &QWindow::close);
QTimer::singleShot(200, &app, []{ QCoreApplication::exit(0); });
app.exec();
+ QCOMPARE(quitSpy.quits, 0);
+ }
+
+ {
+ // Disabling quitOnLastWindowClosed automatic quit should not affect
+ // quitting when last QEventLoopLocker goes out of scope if
+ // there are no windows.
+ app.setQuitLockEnabled(true);
+ app.setQuitOnLastWindowClosed(false);
+
+ QuitSpy quitSpy;
+ QScopedPointer<QEventLoopLocker> locker(new QEventLoopLocker);
+ QTimer::singleShot(0, [&]{ locker.reset(nullptr); });
+ QTimer::singleShot(200, &app, []{ QCoreApplication::exit(0); });
+ app.exec();
QCOMPARE(quitSpy.quits, 1);
}
{
- // Disabling quitOnLastWindowClosed support should not affect
- // quitting when last QEventLoopLocker goes out of scope.
+ // Disabling quitOnLastWindowClosed automatic quit should still block
+ // quitting via QEventLoopLocker if there's a window alive.
app.setQuitLockEnabled(true);
app.setQuitOnLastWindowClosed(false);
@@ -1024,7 +1064,7 @@ void tst_QGuiApplication::quitOnLastWindowClosedWithEventLoopLocker()
QTimer::singleShot(0, [&]{ locker.reset(nullptr); });
QTimer::singleShot(200, &app, []{ QCoreApplication::exit(0); });
app.exec();
- QCOMPARE(quitSpy.quits, 1);
+ QCOMPARE(quitSpy.quits, 0);
}
{
@@ -1138,8 +1178,6 @@ void tst_QGuiApplication::genericPluginsAndWindowSystemEvents()
QVERIFY(QGuiApplication::primaryScreen());
QCOMPARE(QGuiApplication::primaryScreen()->orientation(), testOrientationToSend);
- if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive))
- QEXPECT_FAIL("", "Wayland: This fails. See QTBUG-100891.", Abort);
QCOMPARE(testReceiver.customEvents, 0);
QCoreApplication::sendPostedEvents(&testReceiver);
QCOMPARE(testReceiver.customEvents, 1);
@@ -1163,12 +1201,12 @@ void tst_QGuiApplication::layoutDirection()
QGuiApplication::setLayoutDirection(oldDirection);
QCOMPARE(QGuiApplication::layoutDirection(), oldDirection);
- QCOMPARE(signalSpy.count(), 1);
+ QCOMPARE(signalSpy.size(), 1);
QCOMPARE(signalSpy.at(0).at(0).toInt(), static_cast<int>(oldDirection));
QGuiApplication::setLayoutDirection(oldDirection);
QCOMPARE(QGuiApplication::layoutDirection(), oldDirection);
- QCOMPARE(signalSpy.count(), 1);
+ QCOMPARE(signalSpy.size(), 1);
// with QGuiApplication instantiated, install a translator that gives us control
class LayoutDirectionTranslator : public QTranslator
@@ -1199,31 +1237,31 @@ void tst_QGuiApplication::layoutDirection()
LayoutDirectionTranslator translator(oldDirection);
QGuiApplication::installTranslator(&translator);
QCOMPARE(QGuiApplication::layoutDirection(), translator.direction);
- QCOMPARE(signalSpy.count(), layoutDirectionChangedCount);
+ QCOMPARE(signalSpy.size(), layoutDirectionChangedCount);
}
- QCOMPARE(signalSpy.count(), layoutDirectionChangedCount); // ltrTranslator removed, no change
+ QCOMPARE(signalSpy.size(), layoutDirectionChangedCount); // ltrTranslator removed, no change
// install a new translator that changes the direction
{
LayoutDirectionTranslator translator(newDirection);
QGuiApplication::installTranslator(&translator);
QCOMPARE(QGuiApplication::layoutDirection(), translator.direction);
- QCOMPARE(signalSpy.count(), ++layoutDirectionChangedCount);
+ QCOMPARE(signalSpy.size(), ++layoutDirectionChangedCount);
}
// rtlTranslator removed
- QCOMPARE(signalSpy.count(), ++layoutDirectionChangedCount);
+ QCOMPARE(signalSpy.size(), ++layoutDirectionChangedCount);
// override translation
QGuiApplication::setLayoutDirection(newDirection);
- QCOMPARE(signalSpy.count(), ++layoutDirectionChangedCount);
+ QCOMPARE(signalSpy.size(), ++layoutDirectionChangedCount);
{
// this translator will be ignored
LayoutDirectionTranslator translator(oldDirection);
QGuiApplication::installTranslator(&translator);
QCOMPARE(QGuiApplication::layoutDirection(), newDirection);
- QCOMPARE(signalSpy.count(), layoutDirectionChangedCount);
+ QCOMPARE(signalSpy.size(), layoutDirectionChangedCount);
}
- QCOMPARE(signalSpy.count(), layoutDirectionChangedCount);
+ QCOMPARE(signalSpy.size(), layoutDirectionChangedCount);
}
@@ -1317,6 +1355,40 @@ void tst_QGuiApplication::staticFunctions()
QPixmap::defaultDepth();
}
+void tst_QGuiApplication::topLevelAt()
+{
+ int argc = 1;
+ char *argv[] = { const_cast<char*>("tst_qguiapplication") };
+ QGuiApplication app(argc, argv);
+
+ if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive))
+ QSKIP("QGuiApplication::topLevelAt() is not Wayland compliant, see also QTBUG-121015");
+
+ QWindow bottom;
+ bottom.setObjectName("Bottom");
+ bottom.setFlag(Qt::FramelessWindowHint);
+ bottom.setGeometry(200, 200, 200, 200);
+ bottom.showNormal();
+ QVERIFY(QTest::qWaitForWindowExposed(&bottom));
+ QTRY_COMPARE(app.topLevelAt(QPoint(300, 300)), &bottom);
+
+ QWindow top;
+ top.setObjectName("Top");
+ top.setFlag(Qt::FramelessWindowHint);
+ top.setGeometry(200, 200, 200, 200);
+ top.showNormal();
+ QVERIFY(QTest::qWaitForWindowExposed(&top));
+ top.raise();
+ QTRY_COMPARE(app.topLevelAt(QPoint(300, 300)), &top);
+
+ if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowMasks))
+ QSKIP("QWindow::setMask() is not supported.");
+
+ top.setMask(QRect(0, 0, 50, 50));
+ QTRY_COMPARE(app.topLevelAt(QPoint(300, 300)), &bottom);
+ QTRY_COMPARE(app.topLevelAt(QPoint(225, 225)), &top);
+}
+
void tst_QGuiApplication::settableStyleHints_data()
{
QTest::addColumn<bool>("appInstance");
diff --git a/tests/auto/gui/kernel/qguichronotimer/CMakeLists.txt b/tests/auto/gui/kernel/qguichronotimer/CMakeLists.txt
new file mode 100644
index 0000000000..37848d8cec
--- /dev/null
+++ b/tests/auto/gui/kernel/qguichronotimer/CMakeLists.txt
@@ -0,0 +1,38 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
+#####################################################################
+## tst_qguichronotimer Test:
+#####################################################################
+
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qguichronotimer LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
+function(addGuiChronoTimerTest test)
+ qt_internal_add_test(${test}
+ SOURCES
+ ../../../corelib/kernel/qchronotimer/tst_qchronotimer.cpp
+ LIBRARIES
+ Qt::CorePrivate
+ Qt::Gui
+ Qt::TestPrivate
+ )
+endfunction()
+
+addGuiChronoTimerTest(tst_qguichronotimer)
+qt_internal_extend_target(tst_qguichronotimer
+ DEFINES
+ tst_Qtimer=tst_QGuiChronoTimer
+)
+
+if(QT_FEATURE_glib AND UNIX)
+ addGuiChronoTimerTest(tst_qguichronotimer_no_glib)
+ qt_internal_extend_target(tst_qguichronotimer_no_glib
+ DEFINES
+ DISABLE_GLIB
+ tst_QTimer=tst_QGuiChronoTimer_no_glib # Class name in the unittest
+ )
+endif()
diff --git a/tests/auto/gui/kernel/qguieventdispatcher/CMakeLists.txt b/tests/auto/gui/kernel/qguieventdispatcher/CMakeLists.txt
index aa8f245d97..62299f77df 100644
--- a/tests/auto/gui/kernel/qguieventdispatcher/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qguieventdispatcher/CMakeLists.txt
@@ -1,15 +1,40 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
-# Generated from qguieventdispatcher.pro.
-
#####################################################################
## tst_qguieventdispatcher Test:
#####################################################################
-qt_internal_add_test(tst_qguieventdispatcher
- SOURCES
- ../../../corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp
- LIBRARIES
- Qt::Gui
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qguieventdispatcher LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
+set(test_names "tst_qguieventdispatcher")
+if(QT_FEATURE_glib AND UNIX)
+ list(APPEND test_names "tst_qguieventdispatcher_no_glib")
+endif()
+
+foreach(test ${test_names})
+ qt_internal_add_test(${test}
+ NO_BATCH
+ SOURCES
+ ../../../corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp
+ LIBRARIES
+ Qt::Gui
+ )
+endforeach()
+
+qt_internal_extend_target(tst_qguieventdispatcher
+ DEFINES
+ tst_QEventDispatcher=tst_qguieventdispatcher
)
+
+if (TARGET tst_qeventdispatcher_no_glib)
+ qt_internal_extend_target(tst_qguieventdispatcher_no_glib
+ DEFINES
+ DISABLE_GLIB
+ tst_QEventDispatcher=tst_qguieventdispatcher_no_glib
+ )
+endif()
diff --git a/tests/auto/gui/kernel/qguieventloop/CMakeLists.txt b/tests/auto/gui/kernel/qguieventloop/CMakeLists.txt
index 834eceba1c..89c518be10 100644
--- a/tests/auto/gui/kernel/qguieventloop/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qguieventloop/CMakeLists.txt
@@ -1,12 +1,16 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
-# Generated from qguieventloop.pro.
-
#####################################################################
## tst_qguieventloop Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qguieventloop LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qguieventloop
SOURCES
../../../corelib/kernel/qeventloop/tst_qeventloop.cpp
diff --git a/tests/auto/gui/kernel/qguimetatype/CMakeLists.txt b/tests/auto/gui/kernel/qguimetatype/CMakeLists.txt
index b94a6b291b..7c93e4b8a2 100644
--- a/tests/auto/gui/kernel/qguimetatype/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qguimetatype/CMakeLists.txt
@@ -1,12 +1,16 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
-# Generated from qguimetatype.pro.
-
#####################################################################
## tst_qguimetatype Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qguimetatype LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qguimetatype
SOURCES
tst_qguimetatype.cpp
diff --git a/tests/auto/gui/kernel/qguimetatype/tst_qguimetatype.cpp b/tests/auto/gui/kernel/qguimetatype/tst_qguimetatype.cpp
index 686e2a0e8b..54e95a2b38 100644
--- a/tests/auto/gui/kernel/qguimetatype/tst_qguimetatype.cpp
+++ b/tests/auto/gui/kernel/qguimetatype/tst_qguimetatype.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 <QtCore>
diff --git a/tests/auto/gui/kernel/qguitimer/CMakeLists.txt b/tests/auto/gui/kernel/qguitimer/CMakeLists.txt
index 79b0e706ad..bc292e133b 100644
--- a/tests/auto/gui/kernel/qguitimer/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qguitimer/CMakeLists.txt
@@ -1,16 +1,38 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
-# Generated from qguitimer.pro.
-
#####################################################################
## tst_qguitimer Test:
#####################################################################
-qt_internal_add_test(tst_qguitimer
- SOURCES
- ../../../corelib/kernel/qtimer/tst_qtimer.cpp
- LIBRARIES
- Qt::CorePrivate
- Qt::Gui
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qguitimer LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
+function(addGuiTimerTest test)
+ qt_internal_add_test(${test}
+ SOURCES
+ ../../../corelib/kernel/qtimer/tst_qtimer.cpp
+ LIBRARIES
+ Qt::CorePrivate
+ Qt::Gui
+ Qt::TestPrivate
+ )
+endfunction()
+
+addGuiTimerTest(tst_qguitimer)
+qt_internal_extend_target(tst_qguitimer
+ DEFINES
+ tst_Qtimer=tst_QGuiTimer
)
+
+if(QT_FEATURE_glib AND UNIX)
+ addGuiTimerTest(tst_qguitimer_no_glib)
+ qt_internal_extend_target(tst_qguitimer_no_glib
+ DEFINES
+ DISABLE_GLIB
+ tst_QTimer=tst_QGuiTimer_no_glib # Class name in the unittest
+ )
+endif()
diff --git a/tests/auto/gui/kernel/qguivariant/CMakeLists.txt b/tests/auto/gui/kernel/qguivariant/CMakeLists.txt
index aa539eb627..eda22152ec 100644
--- a/tests/auto/gui/kernel/qguivariant/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qguivariant/CMakeLists.txt
@@ -1,7 +1,5 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
-# Generated from qguivariant.pro.
-
add_subdirectory(test)
add_subdirectory(no_application)
diff --git a/tests/auto/gui/kernel/qguivariant/no_application/CMakeLists.txt b/tests/auto/gui/kernel/qguivariant/no_application/CMakeLists.txt
index a5c65d7f40..4470411a3b 100644
--- a/tests/auto/gui/kernel/qguivariant/no_application/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qguivariant/no_application/CMakeLists.txt
@@ -1,12 +1,16 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
-# Generated from no_application.pro.
-
#####################################################################
## no_application Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_gui_variant_no_application LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_gui_variant_no_application
SOURCES
main.cpp
diff --git a/tests/auto/gui/kernel/qguivariant/no_application/main.cpp b/tests/auto/gui/kernel/qguivariant/no_application/main.cpp
index bf6e2080b2..2b6ec7b870 100644
--- a/tests/auto/gui/kernel/qguivariant/no_application/main.cpp
+++ b/tests/auto/gui/kernel/qguivariant/no_application/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 <QTest>
diff --git a/tests/auto/gui/kernel/qguivariant/test/CMakeLists.txt b/tests/auto/gui/kernel/qguivariant/test/CMakeLists.txt
index f1570f21d5..36b732e4ae 100644
--- a/tests/auto/gui/kernel/qguivariant/test/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qguivariant/test/CMakeLists.txt
@@ -1,12 +1,16 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
-# Generated from test.pro.
-
#####################################################################
## tst_qguivariant Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qguivariant LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
# Resources:
file(GLOB_RECURSE qguivariant_resource_files
RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
diff --git a/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp b/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp
index 27ba5e9386..cb22024f76 100644
--- a/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp
+++ b/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.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/gui/kernel/qhighdpi/CMakeLists.txt b/tests/auto/gui/kernel/qhighdpi/CMakeLists.txt
index cc3fda2f0b..aa61bfbb0b 100644
--- a/tests/auto/gui/kernel/qhighdpi/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qhighdpi/CMakeLists.txt
@@ -1,12 +1,16 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
-# Generated from qhighdpi.pro.
-
#####################################################################
## tst_qhighdpi Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qhighdpi LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qhighdpi
SOURCES
tst_qhighdpi.cpp
diff --git a/tests/auto/gui/kernel/qhighdpi/tst_qhighdpi.cpp b/tests/auto/gui/kernel/qhighdpi/tst_qhighdpi.cpp
index 2196724f41..6fe4faec03 100644
--- a/tests/auto/gui/kernel/qhighdpi/tst_qhighdpi.cpp
+++ b/tests/auto/gui/kernel/qhighdpi/tst_qhighdpi.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2020 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 <private/qhighdpiscaling_p.h>
#include <qpa/qplatformscreen.h>
@@ -10,6 +10,7 @@
#include <QJsonObject>
#include <QJsonDocument>
#include <QStringView>
+#include <QSignalSpy>
Q_LOGGING_CATEGORY(lcTests, "qt.gui.tests")
@@ -35,6 +36,7 @@ private slots:
void screenDpiAndDpr_data();
void screenDpiAndDpr();
void screenDpiChange();
+ void screenDpiChangeWithWindow();
void environment_QT_SCALE_FACTOR();
void environment_QT_SCREEN_SCALE_FACTORS_data();
void environment_QT_SCREEN_SCALE_FACTORS();
@@ -55,6 +57,8 @@ private slots:
void mouseVelocity_data();
void setCursor();
void setCursor_data();
+ void setGlobalFactorEmits();
+ void setScreenFactorEmits();
};
/// Offscreen platform plugin test setup
@@ -65,7 +69,7 @@ const int standardScreenCount = 3;
QJsonArray tst_QHighDpi::createStandardScreens(const QList<qreal> &dpiValues)
{
- Q_ASSERT(dpiValues.count() == standardScreenCount);
+ Q_ASSERT(dpiValues.size() == standardScreenCount);
// Create row of three screens: screen#0 screen#1 screen#2
return QJsonArray {
@@ -235,6 +239,9 @@ void tst_QHighDpi::screenDpiAndDpr()
QWindow window(screen);
QCOMPARE(window.devicePixelRatio(), screen->devicePixelRatio());
+ window.setGeometry(QRect(screen->geometry().center(), QSize(10, 10)));
+ window.create();
+ QCOMPARE(window.devicePixelRatio(), screen->devicePixelRatio());
}
}
@@ -261,12 +268,48 @@ void tst_QHighDpi::screenDpiChange()
for (QScreen *screen : app->screens()) {
QCOMPARE(screen->devicePixelRatio(), newDpi / standardBaseDpi);
QCOMPARE(screen->logicalDotsPerInch(), newDpi / screen->devicePixelRatio());
+
QWindow window(screen);
QCOMPARE(window.devicePixelRatio(), screen->devicePixelRatio());
+ window.create();
+ QCOMPARE(window.devicePixelRatio(), screen->devicePixelRatio());
}
QCOMPARE(app->devicePixelRatio(), newDpi / standardBaseDpi);
}
+void tst_QHighDpi::screenDpiChangeWithWindow()
+{
+ QList<qreal> dpiValues = { 96, 192, 288 };
+ std::unique_ptr<QGuiApplication> app(createStandardOffscreenApp(dpiValues));
+
+ // Create windows for screens
+ QList<QScreen *> screens = app->screens();
+ QList<QWindow *> windows;
+ for (int i = 0; i < screens.count(); ++i) {
+ QScreen *screen = screens[i];
+ QWindow *window = new QWindow();
+ windows.append(window);
+ window->setGeometry(QRect(screen->geometry().center(), QSize(10, 10)));
+ window->create();
+ QCOMPARE(window->devicePixelRatio(), dpiValues[i] / standardBaseDpi);
+ }
+
+ // Change screen DPI
+ QList<qreal> newDpiValues = { 288, 192, 96 };
+ QJsonValue config = offscreenConfiguration();
+ QCborMap map = QCborMap::fromJsonObject(config.toObject());
+ for (int i = 0; i < screens.count(); ++i) {
+ map[QLatin1String("screens")][i][QLatin1String("logicalDpi")] = newDpiValues[i];
+ }
+ setOffscreenConfiguration(map.toJsonObject());
+
+ // Verify that window DPR changes on Screen DPI change.
+ for (int i = 0; i < screens.count(); ++i) {
+ QWindow *window = windows[i];
+ QCOMPARE(window->devicePixelRatio(), newDpiValues[i] / standardBaseDpi);
+ }
+}
+
void tst_QHighDpi::environment_QT_SCALE_FACTOR()
{
qreal factor = 3.1415;
@@ -313,9 +356,10 @@ void tst_QHighDpi::environment_QT_SCREEN_SCALE_FACTORS()
QFETCH(QByteArray, environment);
QFETCH(QList<qreal>, expectedDprValues);
+ qputenv("QT_SCREEN_SCALE_FACTORS", environment);
+
// Verify that setting QT_SCREEN_SCALE_FACTORS overrides the from-platform-screen-DPI DPR.
{
- qputenv("QT_SCREEN_SCALE_FACTORS", environment);
std::unique_ptr<QGuiApplication> app(createStandardOffscreenApp(platformScreenDpi));
int i = 0;
for (QScreen *screen : app->screens()) {
@@ -327,6 +371,18 @@ void tst_QHighDpi::environment_QT_SCREEN_SCALE_FACTORS()
QCOMPARE(window.devicePixelRatio(), expextedDpr);
}
}
+
+ // Verify that setHighDpiScaleFactorRoundingPolicy applies to QT_SCREEN_SCALE_FACTORS as well
+ QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::Round);
+ {
+ std::unique_ptr<QGuiApplication> app(createStandardOffscreenApp(platformScreenDpi));
+ int i = 0;
+ for (QScreen *screen : app->screens()) {
+ qreal expectedRounderDpr = qRound(expectedDprValues[i++]);
+ qreal windowDpr = QWindow(screen).devicePixelRatio();
+ QCOMPARE(windowDpr, expectedRounderDpr);
+ }
+ }
}
void tst_QHighDpi::environment_QT_USE_PHYSICAL_DPI()
@@ -361,21 +417,21 @@ void tst_QHighDpi::environment_QT_SCALE_FACTOR_ROUNDING_POLICY()
qputenv("QT_SCALE_FACTOR_ROUNDING_POLICY", "PassThrough");
{
std::unique_ptr<QGuiApplication> app(createStandardOffscreenApp(dpiValues));
- for (int i = 0; i < dpiValues.count(); ++i)
+ for (int i = 0; i < dpiValues.size(); ++i)
QCOMPARE(app->screens()[i]->devicePixelRatio(), dpiValues[i] / qreal(96));
}
qputenv("QT_SCALE_FACTOR_ROUNDING_POLICY", "Round");
{
std::unique_ptr<QGuiApplication> app(createStandardOffscreenApp(dpiValues));
- for (int i = 0; i < dpiValues.count(); ++i)
+ for (int i = 0; i < dpiValues.size(); ++i)
QCOMPARE(app->screens()[i]->devicePixelRatio(), qRound(dpiValues[i] / qreal(96)));
}
qunsetenv("QT_SCALE_FACTOR_ROUNDING_POLICY");
{
std::unique_ptr<QGuiApplication> app(createStandardOffscreenApp(dpiValues));
- for (int i = 0; i < dpiValues.count(); ++i)
+ for (int i = 0; i < dpiValues.size(); ++i)
QCOMPARE(app->screens()[i]->devicePixelRatio(), dpiValues[i] / qreal(96));
}
}
@@ -386,14 +442,14 @@ void tst_QHighDpi::application_setScaleFactorRoundingPolicy()
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::Round);
{
std::unique_ptr<QGuiApplication> app(createStandardOffscreenApp(dpiValues));
- for (int i = 0; i < dpiValues.count(); ++i)
+ for (int i = 0; i < dpiValues.size(); ++i)
QCOMPARE(app->screens()[i]->devicePixelRatio(), qRound(dpiValues[i] / qreal(96)));
}
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
{
std::unique_ptr<QGuiApplication> app(createStandardOffscreenApp(dpiValues));
- for (int i = 0; i < dpiValues.count(); ++i)
+ for (int i = 0; i < dpiValues.size(); ++i)
QCOMPARE(app->screens()[i]->devicePixelRatio(), dpiValues[i] / qreal(96));
}
@@ -402,7 +458,7 @@ void tst_QHighDpi::application_setScaleFactorRoundingPolicy()
qputenv("QT_SCALE_FACTOR_ROUNDING_POLICY", "PassThrough");
{
std::unique_ptr<QGuiApplication> app(createStandardOffscreenApp(dpiValues));
- for (int i = 0; i < dpiValues.count(); ++i)
+ for (int i = 0; i < dpiValues.size(); ++i)
QCOMPARE(app->screens()[i]->devicePixelRatio(), dpiValues[i] / qreal(96));
}
}
@@ -450,7 +506,7 @@ void tst_QHighDpi::screenAt()
QFETCH(QList<qreal>, dpiValues);
std::unique_ptr<QGuiApplication> app(createStandardOffscreenApp(dpiValues));
- QCOMPARE(app->screens().count(), standardScreenCount); // standard setup
+ QCOMPARE(app->screens().size(), standardScreenCount); // standard setup
// Verify that screenAt() returns the correct or no screen for various points,
// for all screens.
@@ -459,7 +515,7 @@ void tst_QHighDpi::screenAt()
qreal dpi = dpiValues[i++];
// veryfy virtualSiblings and that AA_EnableHighDpiScaling is active
- QCOMPARE(screen->virtualSiblings().count(), standardScreenCount);
+ QCOMPARE(screen->virtualSiblings().size(), standardScreenCount);
QCOMPARE(screen->geometry().size(), QSize(standardScreenWidth, standardScreenHeight) * (96.0 / dpi));
// test points on screen
@@ -798,5 +854,34 @@ void tst_QHighDpi::setCursor()
}
}
+void tst_QHighDpi::setGlobalFactorEmits()
+{
+ QList<qreal> dpiValues { 96, 96, 96 };
+ std::unique_ptr<QGuiApplication> app(createStandardOffscreenApp(dpiValues));
+
+ std::vector<std::unique_ptr<QSignalSpy>> spies;
+ for (QScreen *screen : app->screens())
+ spies.push_back(std::make_unique<QSignalSpy>(screen, &QScreen::geometryChanged));
+
+ QHighDpiScaling::setGlobalFactor(2);
+
+ for (const auto &spy : spies)
+ QCOMPARE(spy->count(), 1);
+
+ QHighDpiScaling::setGlobalFactor(1);
+}
+
+void tst_QHighDpi::setScreenFactorEmits()
+{
+ QList<qreal> dpiValues { 96, 96, 96 };
+ std::unique_ptr<QGuiApplication> app(createStandardOffscreenApp(dpiValues));
+
+ for (QScreen *screen : app->screens()) {
+ QSignalSpy spy(screen, &QScreen::geometryChanged);
+ QHighDpiScaling::setScreenFactor(screen, 2);
+ QCOMPARE(spy.count(), 1);
+ }
+}
+
#include "tst_qhighdpi.moc"
QTEST_APPLESS_MAIN(tst_QHighDpi);
diff --git a/tests/auto/gui/kernel/qinputdevice/CMakeLists.txt b/tests/auto/gui/kernel/qinputdevice/CMakeLists.txt
index 8749a9cdef..afbfd9bb37 100644
--- a/tests/auto/gui/kernel/qinputdevice/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qinputdevice/CMakeLists.txt
@@ -1,12 +1,16 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
-# Generated from qinputdevice.pro.
-
#####################################################################
## tst_qinputdevice Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qinputdevice LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qinputdevice
SOURCES
tst_qinputdevice.cpp
diff --git a/tests/auto/gui/kernel/qinputdevice/tst_qinputdevice.cpp b/tests/auto/gui/kernel/qinputdevice/tst_qinputdevice.cpp
index 67c65f1160..8587aebf2a 100644
--- a/tests/auto/gui/kernel/qinputdevice/tst_qinputdevice.cpp
+++ b/tests/auto/gui/kernel/qinputdevice/tst_qinputdevice.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2020 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 <qpa/qwindowsysteminterface.h>
@@ -78,7 +78,7 @@ void tst_QInputDevice::multiSeatDevices()
QWindowSystemInterface::registerInputDevice(new QPointingDevice("seat 2 mouse", 2010, QInputDevice::DeviceType::Mouse, QPointingDevice::PointerType::Generic,
QInputDevice::Capability::Position | QInputDevice::Capability::Hover,
1, 2, "seat 2", QPointingDeviceUniqueId(), this));
- QVERIFY(QInputDevice::devices().count() >= 4);
+ QVERIFY(QInputDevice::devices().size() >= 4);
QVERIFY(QInputDevicePrivate::fromId(1010));
QVERIFY(QInputDevicePrivate::fromId(1010)->hasCapability(QInputDevice::Capability::Scroll));
QVERIFY(QInputDevicePrivate::fromId(2010));
diff --git a/tests/auto/gui/kernel/qinputmethod/CMakeLists.txt b/tests/auto/gui/kernel/qinputmethod/CMakeLists.txt
index 9bf079b4b1..e3ce0774bc 100644
--- a/tests/auto/gui/kernel/qinputmethod/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qinputmethod/CMakeLists.txt
@@ -1,12 +1,16 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
-# Generated from qinputmethod.pro.
-
#####################################################################
## tst_qinputmethod Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qinputmethod LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qinputmethod
SOURCES
tst_qinputmethod.cpp
diff --git a/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp b/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp
index 86669fde62..619de7bed3 100644
--- a/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.cpp
+++ b/tests/auto/gui/kernel/qinputmethod/tst_qinputmethod.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 <QSignalSpy>
@@ -125,7 +125,7 @@ void tst_qinputmethod::animating()
QSignalSpy spy(qApp->inputMethod(), SIGNAL(animatingChanged()));
m_platformInputContext.emitAnimatingChanged();
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
void tst_qinputmethod::keyboarRectangle()
@@ -137,7 +137,7 @@ void tst_qinputmethod::keyboarRectangle()
QSignalSpy spy(qApp->inputMethod(), SIGNAL(keyboardRectangleChanged()));
m_platformInputContext.emitKeyboardRectChanged();
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
void tst_qinputmethod::inputItemTransform()
@@ -152,7 +152,7 @@ void tst_qinputmethod::inputItemTransform()
qApp->inputMethod()->setInputItemTransform(transform);
QCOMPARE(qApp->inputMethod()->inputItemTransform(), transform);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
// reset
qApp->inputMethod()->setInputItemTransform(QTransform());
@@ -249,13 +249,13 @@ void tst_qinputmethod::query()
void tst_qinputmethod::inputDirection()
{
- QCOMPARE(m_platformInputContext.m_inputDirectionCallCount, 0);
+ auto originalCount = m_platformInputContext.m_inputDirectionCallCount;
qApp->inputMethod()->inputDirection();
- QCOMPARE(m_platformInputContext.m_inputDirectionCallCount, 1);
+ QCOMPARE(m_platformInputContext.m_inputDirectionCallCount, originalCount + 1);
- QCOMPARE(m_platformInputContext.m_localeCallCount, 0);
+ originalCount = m_platformInputContext.m_localeCallCount;
qApp->inputMethod()->locale();
- QCOMPARE(m_platformInputContext.m_localeCallCount, 1);
+ QCOMPARE(m_platformInputContext.m_localeCallCount, originalCount + 1);
}
void tst_qinputmethod::inputMethodAccepted()
diff --git a/tests/auto/gui/kernel/qkeyevent/CMakeLists.txt b/tests/auto/gui/kernel/qkeyevent/CMakeLists.txt
index 092c24f593..c3c9892d14 100644
--- a/tests/auto/gui/kernel/qkeyevent/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qkeyevent/CMakeLists.txt
@@ -1,12 +1,16 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
-# Generated from qkeyevent.pro.
-
#####################################################################
## tst_qkeyevent Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qkeyevent LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qkeyevent
SOURCES
tst_qkeyevent.cpp
diff --git a/tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp b/tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp
index 4f2379fbb4..7d8e0aa5dc 100644
--- a/tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp
+++ b/tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp
@@ -1,5 +1,7 @@
// Copyright (C) 2017 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 <QTest>
diff --git a/tests/auto/gui/kernel/qkeysequence/CMakeLists.txt b/tests/auto/gui/kernel/qkeysequence/CMakeLists.txt
index f6b81d0d47..1676302d1b 100644
--- a/tests/auto/gui/kernel/qkeysequence/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qkeysequence/CMakeLists.txt
@@ -1,12 +1,16 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
-# Generated from qkeysequence.pro.
-
#####################################################################
## tst_qkeysequence Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qkeysequence LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
# Resources:
set(qkeysequence_resource_files
"keys_de.qm"
diff --git a/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp b/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
index a923c9bf8d..67fef3cf44 100644
--- a/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp
+++ b/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.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>
@@ -473,6 +473,7 @@ void tst_QKeySequence::toStringFromKeycode_data()
QTest::newRow("A") << QKeySequence(Qt::Key_A) << "A";
QTest::newRow("-1") << QKeySequence(-1) << "";
QTest::newRow("Unknown") << QKeySequence(Qt::Key_unknown) << "";
+ QTest::newRow("Ctrl+Unknown") << QKeySequence(Qt::ControlModifier | Qt::Key_unknown) << "";
QTest::newRow("Ctrl+Num+Ins") << QKeySequence(Qt::ControlModifier | Qt::KeypadModifier | Qt::Key_Insert) << "Ctrl+Num+Ins";
QTest::newRow("Ctrl+Num+Del") << QKeySequence(Qt::ControlModifier | Qt::KeypadModifier | Qt::Key_Delete) << "Ctrl+Num+Del";
QTest::newRow("Ctrl+Alt+Num+Del") << QKeySequence(Qt::ControlModifier | Qt::AltModifier | Qt::KeypadModifier | Qt::Key_Delete) << "Ctrl+Alt+Num+Del";
@@ -558,10 +559,6 @@ void tst_QKeySequence::parseString_data()
//QTest::newRow("Ctrl") << "Ctrl" << QKeySequence(Qt::CTRL);
//QTest::newRow("Shift") << "Shift" << QKeySequence(Qt::SHIFT);
- // Only Keys
- QTest::newRow("a") << "a" << QKeySequence(Qt::Key_A);
- QTest::newRow("A") << "A" << QKeySequence(Qt::Key_A);
-
// Incomplete
QTest::newRow("Meta+Shift+") << "Meta+Shift+" << QKeySequence(Qt::Key_unknown);
}
diff --git a/tests/auto/gui/kernel/qmouseevent/CMakeLists.txt b/tests/auto/gui/kernel/qmouseevent/CMakeLists.txt
index 29f79e82f1..ac2200792b 100644
--- a/tests/auto/gui/kernel/qmouseevent/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qmouseevent/CMakeLists.txt
@@ -1,12 +1,16 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
-# Generated from qmouseevent.pro.
-
#####################################################################
## tst_qmouseevent Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qmouseevent LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qmouseevent
SOURCES
tst_qmouseevent.cpp
diff --git a/tests/auto/gui/kernel/qmouseevent/tst_qmouseevent.cpp b/tests/auto/gui/kernel/qmouseevent/tst_qmouseevent.cpp
index 5420adca14..f703111384 100644
--- a/tests/auto/gui/kernel/qmouseevent/tst_qmouseevent.cpp
+++ b/tests/auto/gui/kernel/qmouseevent/tst_qmouseevent.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2020 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>
@@ -7,6 +7,8 @@
#include <qwindow.h>
#include <QtGui/private/qpointingdevice_p.h>
+#include <QtCore/qpointer.h>
+
Q_LOGGING_CATEGORY(lcTests, "qt.gui.tests")
class MouseEventWidget : public QWindow
@@ -97,6 +99,7 @@ private slots:
void grabbers_data();
void grabbers();
void velocity();
+ void clone();
private:
MouseEventWidget* testMouseWidget;
@@ -263,14 +266,14 @@ void tst_QMouseEvent::grabbers()
auto firstEPD = devPriv->pointById(0);
QCOMPARE(firstEPD->eventPoint.pressTimestamp(), testMouseWidget->pressTimestamp);
QCOMPARE(firstEPD->exclusiveGrabber, grabExclusive ? testMouseWidget : nullptr);
- QCOMPARE(firstEPD->passiveGrabbers.count(), grabPassive ? 1 : 0);
+ QCOMPARE(firstEPD->passiveGrabbers.size(), grabPassive ? 1 : 0);
if (grabPassive)
QCOMPARE(firstEPD->passiveGrabbers.first(), testMouseWidget);
// Ensure that grabbers are forgotten after release delivery
QTest::mouseRelease(testMouseWidget, Qt::LeftButton, Qt::KeyboardModifiers(), {10, 10});
QTRY_COMPARE(firstEPD->exclusiveGrabber, nullptr);
- QCOMPARE(firstEPD->passiveGrabbers.count(), 0);
+ QCOMPARE(firstEPD->passiveGrabbers.size(), 0);
}
void tst_QMouseEvent::velocity()
@@ -309,5 +312,24 @@ void tst_QMouseEvent::velocity()
QVERIFY(testMouseWidget->velocity.y() > 0);
}
+void tst_QMouseEvent::clone()
+{
+ const QPointF pos(10.0f, 10.0f);
+
+ QMouseEvent originalMe(QEvent::MouseButtonPress, pos, pos, pos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
+ QVERIFY(!originalMe.allPointsAccepted());
+ QVERIFY(!originalMe.points().first().isAccepted());
+
+ // create a clone of the original
+ std::unique_ptr<QMouseEvent> clonedMe(originalMe.clone());
+ QVERIFY(!clonedMe->allPointsAccepted());
+ QVERIFY(!clonedMe->points().first().isAccepted());
+
+ // now we alter originalMe, which should *not* change clonedMe
+ originalMe.setAccepted(true);
+ QVERIFY(!clonedMe->allPointsAccepted());
+ QVERIFY(!clonedMe->points().first().isAccepted());
+}
+
QTEST_MAIN(tst_QMouseEvent)
#include "tst_qmouseevent.moc"
diff --git a/tests/auto/gui/kernel/qmouseevent_modal/CMakeLists.txt b/tests/auto/gui/kernel/qmouseevent_modal/CMakeLists.txt
index 7b9afd2c62..034b9c794d 100644
--- a/tests/auto/gui/kernel/qmouseevent_modal/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qmouseevent_modal/CMakeLists.txt
@@ -1,12 +1,16 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
-# Generated from qmouseevent_modal.pro.
-
#####################################################################
## tst_qmouseevent_modal Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qmouseevent_modal LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qmouseevent_modal
SOURCES
tst_qmouseevent_modal.cpp
diff --git a/tests/auto/gui/kernel/qmouseevent_modal/tst_qmouseevent_modal.cpp b/tests/auto/gui/kernel/qmouseevent_modal/tst_qmouseevent_modal.cpp
index e589e54195..0fe218d503 100644
--- a/tests/auto/gui/kernel/qmouseevent_modal/tst_qmouseevent_modal.cpp
+++ b/tests/auto/gui/kernel/qmouseevent_modal/tst_qmouseevent_modal.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/gui/kernel/qopenglwindow/CMakeLists.txt b/tests/auto/gui/kernel/qopenglwindow/CMakeLists.txt
index f19930944d..0f57b98bc3 100644
--- a/tests/auto/gui/kernel/qopenglwindow/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qopenglwindow/CMakeLists.txt
@@ -1,12 +1,16 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
-# Generated from qopenglwindow.pro.
-
#####################################################################
## tst_qopenglwindow Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qopenglwindow LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qopenglwindow
SOURCES
tst_qopenglwindow.cpp
diff --git a/tests/auto/gui/kernel/qopenglwindow/tst_qopenglwindow.cpp b/tests/auto/gui/kernel/qopenglwindow/tst_qopenglwindow.cpp
index e1c4bab677..06a1ffb296 100644
--- a/tests/auto/gui/kernel/qopenglwindow/tst_qopenglwindow.cpp
+++ b/tests/auto/gui/kernel/qopenglwindow/tst_qopenglwindow.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 <QtOpenGL/QOpenGLWindow>
#include <QTest>
@@ -119,6 +119,9 @@ void tst_QOpenGLWindow::resize()
if (isPlatformWayland())
QSKIP("Wayland: Crashes on Intel Mesa due to a driver bug (QTBUG-66848).");
+ if (QGuiApplication::platformName().startsWith(QLatin1String("eglfs"), Qt::CaseInsensitive))
+ QSKIP("EGLFS does not allow resizing on top level window");
+
Window w;
w.reset();
w.resize(640, 480);
diff --git a/tests/auto/gui/kernel/qpalette/CMakeLists.txt b/tests/auto/gui/kernel/qpalette/CMakeLists.txt
index e1c8ba97bd..7983b9ac25 100644
--- a/tests/auto/gui/kernel/qpalette/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qpalette/CMakeLists.txt
@@ -1,12 +1,16 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
-# Generated from qpalette.pro.
-
#####################################################################
## tst_qpalette Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qpalette LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qpalette
SOURCES
tst_qpalette.cpp
diff --git a/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp b/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp
index 2e9a484b8b..c21828bee2 100644
--- a/tests/auto/gui/kernel/qpalette/tst_qpalette.cpp
+++ b/tests/auto/gui/kernel/qpalette/tst_qpalette.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>
@@ -23,6 +23,7 @@ private Q_SLOTS:
void cannotCheckIfInvalidBrushSet();
void checkIfBrushForCurrentGroupSet();
void cacheKey();
+ void dataStream();
};
void tst_QPalette::roleValues_data()
@@ -51,9 +52,10 @@ void tst_QPalette::roleValues_data()
QTest::newRow("QPalette::ToolTipBase") << int(QPalette::ToolTipBase) << 18;
QTest::newRow("QPalette::ToolTipText") << int(QPalette::ToolTipText) << 19;
QTest::newRow("QPalette::PlaceholderText") << int(QPalette::PlaceholderText) << 20;
+ QTest::newRow("QPalette::Accent") << int(QPalette::Accent) << 21;
// Change this value as you add more roles.
- QTest::newRow("QPalette::NColorRoles") << int(QPalette::NColorRoles) << 21;
+ QTest::newRow("QPalette::NColorRoles") << int(QPalette::NColorRoles) << 22;
}
void tst_QPalette::roleValues()
@@ -236,8 +238,14 @@ void tst_QPalette::setAllPossibleBrushes()
}
for (int r = 0; r < QPalette::NColorRoles; ++r) {
+ const QPalette::ColorRole role = static_cast<QPalette::ColorRole>(r);
for (int g = 0; g < QPalette::NColorGroups; ++g) {
- QVERIFY(p.isBrushSet(QPalette::ColorGroup(g), QPalette::ColorRole(r)));
+ const QPalette::ColorGroup group = static_cast<QPalette::ColorGroup>(g);
+ // NoRole has no resolve bit => isBrushSet returns false
+ if (role == QPalette::NoRole)
+ QVERIFY(!p.isBrushSet(group, role));
+ else
+ QVERIFY(p.isBrushSet(group, role));
}
}
}
@@ -274,6 +282,14 @@ void tst_QPalette::cacheKey()
const auto defaultSerNo = defaultCacheKey >> 32;
const auto defaultDetachNo = defaultCacheKey & 0xffffffff;
+ QPalette changeTwicePalette(defaultPalette);
+ changeTwicePalette.setBrush(QPalette::All, QPalette::ButtonText, Qt::red);
+ const auto firstChangeCacheKey = changeTwicePalette.cacheKey();
+ QCOMPARE_NE(firstChangeCacheKey, defaultCacheKey);
+ changeTwicePalette.setBrush(QPalette::All, QPalette::ButtonText, Qt::green);
+ const auto secondChangeCacheKey = changeTwicePalette.cacheKey();
+ QCOMPARE_NE(firstChangeCacheKey, secondChangeCacheKey);
+
QPalette copyDifferentData(defaultPalette);
QPalette copyDifferentMask(defaultPalette);
QPalette copyDifferentMaskAndData(defaultPalette);
@@ -285,6 +301,10 @@ void tst_QPalette::cacheKey()
const auto differentDataKey = copyDifferentData.cacheKey();
const auto differentDataSerNo = differentDataKey >> 32;
const auto differentDataDetachNo = differentDataKey & 0xffffffff;
+ auto loggerDeepDetach = qScopeGuard([&](){
+ qDebug() << "Deep detach serial" << differentDataSerNo;
+ qDebug() << "Deep detach detach number" << differentDataDetachNo;
+ });
QCOMPARE_NE(copyDifferentData.cacheKey(), defaultCacheKey);
QCOMPARE(defaultPalette.cacheKey(), defaultCacheKey);
@@ -294,6 +314,11 @@ void tst_QPalette::cacheKey()
const auto differentMaskKey = copyDifferentMask.cacheKey();
const auto differentMaskSerNo = differentMaskKey >> 32;
const auto differentMaskDetachNo = differentMaskKey & 0xffffffff;
+ auto loggerShallowDetach = qScopeGuard([&](){
+ qDebug() << "Shallow detach serial" << differentMaskSerNo;
+ qDebug() << "Shallow detach detach number" << differentMaskDetachNo;
+ });
+
QCOMPARE(differentMaskSerNo, defaultSerNo);
QCOMPARE_NE(differentMaskSerNo, defaultDetachNo);
QCOMPARE_NE(differentMaskKey, defaultCacheKey);
@@ -319,6 +344,48 @@ void tst_QPalette::cacheKey()
QCOMPARE_NE(modifiedAllKey, defaultCacheKey);
QCOMPARE_NE(modifiedAllKey, differentDataKey);
QCOMPARE_NE(modifiedAllKey, modifiedCacheKey);
+
+ loggerDeepDetach.dismiss();
+ loggerShallowDetach.dismiss();
+}
+
+void tst_QPalette::dataStream()
+{
+ const QColor highlight(42, 42, 42);
+ const QColor accent(13, 13, 13);
+ QPalette palette;
+ palette.setBrush(QPalette::Highlight, highlight);
+ palette.setBrush(QPalette::Accent, accent);
+
+ // When saved with Qt_6_5 or earlier, Accent defaults to Highlight
+ {
+ QByteArray b;
+ {
+ QDataStream stream(&b, QIODevice::WriteOnly);
+ stream.setVersion(QDataStream::Qt_6_5);
+ stream << palette;
+ }
+ QPalette test;
+ QDataStream stream (&b, QIODevice::ReadOnly);
+ stream.setVersion(QDataStream::Qt_6_5);
+ stream >> test;
+ QCOMPARE(test.accent().color(), highlight);
+ }
+
+ // When saved with Qt_6_6 or later, Accent is saved explicitly
+ {
+ QByteArray b;
+ {
+ QDataStream stream(&b, QIODevice::WriteOnly);
+ stream.setVersion(QDataStream::Qt_6_6);
+ stream << palette;
+ }
+ QPalette test;
+ QDataStream stream (&b, QIODevice::ReadOnly);
+ stream.setVersion(QDataStream::Qt_6_6);
+ stream >> test;
+ QCOMPARE(test.accent().color(), accent);
+ }
}
QTEST_MAIN(tst_QPalette)
diff --git a/tests/auto/gui/kernel/qpixelformat/CMakeLists.txt b/tests/auto/gui/kernel/qpixelformat/CMakeLists.txt
index 56d74f6ad0..c711ceeafa 100644
--- a/tests/auto/gui/kernel/qpixelformat/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qpixelformat/CMakeLists.txt
@@ -1,12 +1,16 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
-# Generated from qpixelformat.pro.
-
#####################################################################
## tst_qpixelformat Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qpixelformat LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qpixelformat
SOURCES
tst_qpixelformat.cpp
diff --git a/tests/auto/gui/kernel/qpixelformat/tst_qpixelformat.cpp b/tests/auto/gui/kernel/qpixelformat/tst_qpixelformat.cpp
index a0cf95c7f4..d6d471bf6b 100644
--- a/tests/auto/gui/kernel/qpixelformat/tst_qpixelformat.cpp
+++ b/tests/auto/gui/kernel/qpixelformat/tst_qpixelformat.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/qpixelformat.h>
diff --git a/tests/auto/gui/kernel/qrasterwindow/CMakeLists.txt b/tests/auto/gui/kernel/qrasterwindow/CMakeLists.txt
index 11f677df23..dc9d6a70c7 100644
--- a/tests/auto/gui/kernel/qrasterwindow/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qrasterwindow/CMakeLists.txt
@@ -1,12 +1,16 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
-# Generated from qrasterwindow.pro.
-
#####################################################################
## tst_qrasterwindow Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qrasterwindow LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qrasterwindow
SOURCES
tst_qrasterwindow.cpp
diff --git a/tests/auto/gui/kernel/qrasterwindow/tst_qrasterwindow.cpp b/tests/auto/gui/kernel/qrasterwindow/tst_qrasterwindow.cpp
index 64e418a251..a06e360e35 100644
--- a/tests/auto/gui/kernel/qrasterwindow/tst_qrasterwindow.cpp
+++ b/tests/auto/gui/kernel/qrasterwindow/tst_qrasterwindow.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 <QtGui/QRasterWindow>
#include <QTest>
@@ -45,7 +45,7 @@ void tst_QRasterWindow::basic()
w.reset();
w.resize(400, 400);
w.show();
- QVERIFY(QTest::qWaitForWindowExposed(&w));;
+ QVERIFY(QTest::qWaitForWindowExposed(&w));
QVERIFY(w.paintCount >= 1);
diff --git a/tests/auto/gui/kernel/qscreen/CMakeLists.txt b/tests/auto/gui/kernel/qscreen/CMakeLists.txt
index acb4d8a396..8502176ca4 100644
--- a/tests/auto/gui/kernel/qscreen/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qscreen/CMakeLists.txt
@@ -1,12 +1,16 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
-# Generated from qscreen.pro.
-
#####################################################################
## tst_qscreen Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qscreen LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qscreen
SOURCES
tst_qscreen.cpp
diff --git a/tests/auto/gui/kernel/qscreen/tst_qscreen.cpp b/tests/auto/gui/kernel/qscreen/tst_qscreen.cpp
index 9d85a31d5a..74a03ac851 100644
--- a/tests/auto/gui/kernel/qscreen/tst_qscreen.cpp
+++ b/tests/auto/gui/kernel/qscreen/tst_qscreen.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 <qpainter.h>
#include <qrasterwindow.h>
@@ -158,35 +158,34 @@ void tst_QScreen::orientationChange()
QWindowSystemInterface::handleScreenOrientationChange(screen, Qt::LandscapeOrientation);
QWindowSystemInterface::flushWindowSystemEvents();
QTRY_COMPARE(screen->orientation(), Qt::LandscapeOrientation);
- QCOMPARE(spy.count(), ++expectedSignalCount);
+ QCOMPARE(spy.size(), ++expectedSignalCount);
QWindowSystemInterface::handleScreenOrientationChange(screen, Qt::PortraitOrientation);
QWindowSystemInterface::flushWindowSystemEvents();
QTRY_COMPARE(screen->orientation(), Qt::PortraitOrientation);
- QCOMPARE(spy.count(), ++expectedSignalCount);
+ QCOMPARE(spy.size(), ++expectedSignalCount);
QWindowSystemInterface::handleScreenOrientationChange(screen, Qt::InvertedLandscapeOrientation);
QWindowSystemInterface::flushWindowSystemEvents();
QTRY_COMPARE(screen->orientation(), Qt::InvertedLandscapeOrientation);
- QCOMPARE(spy.count(), ++expectedSignalCount);
+ QCOMPARE(spy.size(), ++expectedSignalCount);
QWindowSystemInterface::handleScreenOrientationChange(screen, Qt::InvertedPortraitOrientation);
QWindowSystemInterface::flushWindowSystemEvents();
QTRY_COMPARE(screen->orientation(), Qt::InvertedPortraitOrientation);
- QCOMPARE(spy.count(), ++expectedSignalCount);
+ QCOMPARE(spy.size(), ++expectedSignalCount);
QWindowSystemInterface::handleScreenOrientationChange(screen, Qt::LandscapeOrientation);
QWindowSystemInterface::flushWindowSystemEvents();
QTRY_COMPARE(screen->orientation(), Qt::LandscapeOrientation);
- QCOMPARE(spy.count(), ++expectedSignalCount);
+ QCOMPARE(spy.size(), ++expectedSignalCount);
}
void tst_QScreen::grabWindow_data()
{
- if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(
- QPlatformIntegration::ScreenWindowGrabbing)) {
+ if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ScreenWindowGrabbing)
+ || (QGuiApplication::platformName().toLower() == QStringLiteral("xcb") && !qEnvironmentVariableIsEmpty("WAYLAND_DISPLAY")))
QSKIP("This platform does not support grabbing windows on screen.");
- }
QTest::addColumn<int>("screenIndex");
QTest::addColumn<QByteArray>("screenName");
QTest::addColumn<bool>("grabWindow");
diff --git a/tests/auto/gui/kernel/qshortcut/CMakeLists.txt b/tests/auto/gui/kernel/qshortcut/CMakeLists.txt
index 0681181f3e..517a4e8a1a 100644
--- a/tests/auto/gui/kernel/qshortcut/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qshortcut/CMakeLists.txt
@@ -1,15 +1,20 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
-# Generated from qshortcut.pro.
-
#####################################################################
## tst_qshortcut_kernel Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qshortcut_kernel LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qshortcut_kernel
SOURCES
tst_qshortcut.cpp
LIBRARIES
Qt::Gui
+ Qt::GuiPrivate
)
diff --git a/tests/auto/gui/kernel/qshortcut/tst_qshortcut.cpp b/tests/auto/gui/kernel/qshortcut/tst_qshortcut.cpp
index 8a1b2888a2..cb6ebab800 100644
--- a/tests/auto/gui/kernel/qshortcut/tst_qshortcut.cpp
+++ b/tests/auto/gui/kernel/qshortcut/tst_qshortcut.cpp
@@ -1,56 +1,59 @@
// 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 <QTest>
#include <QtGui/qguiapplication.h>
#include <QtGui/qshortcut.h>
-#include <QtGui/qpainter.h>
-#include <QtGui/qrasterwindow.h>
-#include <QtGui/qscreen.h>
#include <QtGui/qwindow.h>
+#include <QtTest/qsignalspy.h>
+
+#include <QtGui/private/qguiapplication_p.h>
+#include <qpa/qplatformintegration.h>
class tst_QShortcut : public QObject
{
Q_OBJECT
-public:
private slots:
- void trigger();
-};
-
-class ColoredWindow : public QRasterWindow {
-public:
- ColoredWindow(QColor c) : m_color(c) {}
-
-protected:
- void paintEvent(QPaintEvent *event) override;
-
-private:
- const QColor m_color;
+ void applicationShortcut();
+ void windowShortcut();
};
-void ColoredWindow::paintEvent(QPaintEvent *)
+void tst_QShortcut::applicationShortcut()
{
- QPainter p(this);
- p.fillRect(QRect(QPoint(), size()), m_color);
+ if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))
+ QSKIP("Window activation is not supported");
+
+ auto *shortcut = new QShortcut(Qt::CTRL | Qt::Key_A, this);
+ shortcut->setContext(Qt::ApplicationShortcut);
+ QSignalSpy activatedSpy(shortcut, &QShortcut::activated);
+
+ // Need a window to send key event to, even if the shortcut is application
+ // global. The documentation for Qt::ApplicationShortcut also says that
+ // the shortcut "is active when one of the applications windows are active",
+ // but this is only honored for Qt Widgets, not for Qt Gui. For now we
+ // activate the window just in case.
+ QWindow window;
+ window.show();
+ QVERIFY(QTest::qWaitForWindowActive(&window));
+ QTRY_COMPARE(QGuiApplication::applicationState(), Qt::ApplicationActive);
+ QTest::sendKeyEvent(QTest::Shortcut, &window, Qt::Key_A, 'a', Qt::ControlModifier);
+
+ QVERIFY(activatedSpy.size() > 0);
}
-static void sendKey(QWindow *target, Qt::Key k, char c, Qt::KeyboardModifiers modifiers)
+void tst_QShortcut::windowShortcut()
{
- QTest::sendKeyEvent(QTest::Press, target, k, c, modifiers);
- QTest::sendKeyEvent(QTest::Release, target, k, c, modifiers);
-}
-
-void tst_QShortcut::trigger()
-{
- ColoredWindow w(Qt::yellow);
- w.setTitle(QTest::currentTestFunction());
- w.resize(QGuiApplication::primaryScreen()->size() / 4);
+ QWindow w;
new QShortcut(Qt::CTRL | Qt::Key_Q, &w, SLOT(close()));
w.show();
QVERIFY(QTest::qWaitForWindowExposed(&w));
+
+ if (QGuiApplication::platformName().startsWith(QLatin1String("wayland"), Qt::CaseInsensitive))
+ QEXPECT_FAIL("", "It failed on Wayland, QTBUG-120334", Abort);
+
QTRY_VERIFY(QGuiApplication::applicationState() == Qt::ApplicationActive);
- sendKey(&w, Qt::Key_Q, 'q', Qt::ControlModifier);
+ QTest::sendKeyEvent(QTest::Click, &w, Qt::Key_Q, 'q', Qt::ControlModifier);
QTRY_VERIFY(!w.isVisible());
}
diff --git a/tests/auto/gui/kernel/qsurfaceformat/CMakeLists.txt b/tests/auto/gui/kernel/qsurfaceformat/CMakeLists.txt
index 8d7c4d5f09..1303f48cf3 100644
--- a/tests/auto/gui/kernel/qsurfaceformat/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qsurfaceformat/CMakeLists.txt
@@ -1,12 +1,16 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
-# Generated from qsurfaceformat.pro.
-
#####################################################################
## tst_qsurfaceformat Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qsurfaceformat LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qsurfaceformat
SOURCES
tst_qsurfaceformat.cpp
diff --git a/tests/auto/gui/kernel/qsurfaceformat/tst_qsurfaceformat.cpp b/tests/auto/gui/kernel/qsurfaceformat/tst_qsurfaceformat.cpp
index 0b2d301ad9..3f655bd905 100644
--- a/tests/auto/gui/kernel/qsurfaceformat/tst_qsurfaceformat.cpp
+++ b/tests/auto/gui/kernel/qsurfaceformat/tst_qsurfaceformat.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 <qsurfaceformat.h>
diff --git a/tests/auto/gui/kernel/qtouchevent/CMakeLists.txt b/tests/auto/gui/kernel/qtouchevent/CMakeLists.txt
index 9eb636d10f..160263ac66 100644
--- a/tests/auto/gui/kernel/qtouchevent/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qtouchevent/CMakeLists.txt
@@ -1,12 +1,16 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
-# Generated from qtouchevent.pro.
-
#####################################################################
## tst_qtouchevent Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qtouchevent LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qtouchevent
SOURCES
tst_qtouchevent.cpp
diff --git a/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp b/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp
index b8e673efa3..37ddcb8962 100644
--- a/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp
+++ b/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2020 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 <QtGui/QCursor>
#include <QtGui/QScreen>
@@ -17,6 +17,10 @@
#include <QtGui/private/qeventpoint_p.h>
#include <private/qhighdpiscaling_p.h>
#include <private/qpointingdevice_p.h>
+#include <private/qguiapplication_p.h>
+#include <qpa/qplatformintegration.h>
+
+#include <QtCore/qpointer.h>
Q_LOGGING_CATEGORY(lcTests, "qt.gui.tests")
@@ -54,13 +58,13 @@ public:
painter.drawText(rect(), Qt::AlignHCenter | Qt::AlignCenter, objectName());
static const QString pointFormat = QString::fromUtf8("\360\237\226\227 %1, %2");
painter.setPen(Qt::darkGreen);
- for (const auto &pt : qAsConst(touchBeginPoints))
+ for (const auto &pt : std::as_const(touchBeginPoints))
painter.drawText(pt.position(), pointFormat.arg(pt.position().toPoint().x()).arg(pt.position().toPoint().y()));
painter.setPen(Qt::darkYellow);
- for (const auto &pt : qAsConst(touchUpdatePoints))
+ for (const auto &pt : std::as_const(touchUpdatePoints))
painter.drawText(pt.position(), pointFormat.arg(pt.position().toPoint().x()).arg(pt.position().toPoint().y()));
painter.setPen(Qt::darkRed);
- for (const auto &pt : qAsConst(touchEndPoints))
+ for (const auto &pt : std::as_const(touchEndPoints))
painter.drawText(pt.position(), pointFormat.arg(pt.position().toPoint().x()).arg(pt.position().toPoint().y()));
}
@@ -77,7 +81,7 @@ public:
auto touchEvent = static_cast<QTouchEvent *>(event);
touchBeginPoints = touchEvent->points();
Q_ASSERT(touchBeginPoints.first().device() == touchEvent->pointingDevice());
- for (const QEventPoint &pt : qAsConst(touchBeginPoints))
+ for (const QEventPoint &pt : std::as_const(touchBeginPoints))
lastNormalizedPositions << pt.normalizedPosition();
timestamp = touchEvent->timestamp();
deviceFromEvent = touchEvent->pointingDevice();
@@ -95,7 +99,7 @@ public:
seenTouchUpdate = seenTouchBegin && !seenTouchEnd;
auto touchEvent = static_cast<QTouchEvent *>(event);
touchUpdatePoints = touchEvent->points();
- for (const QEventPoint &pt : qAsConst(touchUpdatePoints))
+ for (const QEventPoint &pt : std::as_const(touchUpdatePoints))
lastNormalizedPositions << pt.normalizedPosition();
timestamp = touchEvent->timestamp();
deviceFromEvent = touchEvent->pointingDevice();
@@ -113,7 +117,7 @@ public:
seenTouchEnd = seenTouchBegin && !seenTouchEnd;
auto touchEvent = static_cast<QTouchEvent *>(event);
touchEndPoints = touchEvent->points();
- for (const QEventPoint &pt : qAsConst(touchEndPoints))
+ for (const QEventPoint &pt : std::as_const(touchEndPoints))
lastNormalizedPositions << pt.normalizedPosition();
timestamp = touchEvent->timestamp();
deviceFromEvent = touchEvent->pointingDevice();
@@ -732,7 +736,7 @@ void tst_QTouchEvent::basicRawEventTranslation()
QVERIFY(touchWidget.seenTouchBegin);
QVERIFY(!touchWidget.seenTouchUpdate);
QVERIFY(!touchWidget.seenTouchEnd);
- QCOMPARE(touchWidget.touchBeginPoints.count(), 1);
+ QCOMPARE(touchWidget.touchBeginPoints.size(), 1);
QCOMPARE(touchWidget.timestamp, timestamp);
QEventPoint touchBeginPoint = touchWidget.touchBeginPoints.first();
QCOMPARE(touchBeginPoint.id(), 0);
@@ -762,7 +766,7 @@ void tst_QTouchEvent::basicRawEventTranslation()
QVERIFY(touchWidget.seenTouchBegin);
QVERIFY(touchWidget.seenTouchUpdate);
QVERIFY(!touchWidget.seenTouchEnd);
- QCOMPARE(touchWidget.touchUpdatePoints.count(), 1);
+ QCOMPARE(touchWidget.touchUpdatePoints.size(), 1);
QEventPoint touchUpdatePoint = touchWidget.touchUpdatePoints.first();
QCOMPARE(touchUpdatePoint.id(), 0);
QCOMPARE(touchUpdatePoint.state(), rawTouchPoint.state());
@@ -790,7 +794,7 @@ void tst_QTouchEvent::basicRawEventTranslation()
QVERIFY(touchWidget.seenTouchBegin);
QVERIFY(touchWidget.seenTouchUpdate);
QVERIFY(touchWidget.seenTouchEnd);
- QCOMPARE(touchWidget.touchEndPoints.count(), 1);
+ QCOMPARE(touchWidget.touchEndPoints.size(), 1);
QEventPoint touchEndPoint = touchWidget.touchEndPoints.first();
QCOMPARE(touchEndPoint.id(), 0);
QCOMPARE(touchEndPoint.state(), rawTouchPoint.state());
@@ -859,8 +863,8 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen()
QVERIFY(rightWidget.seenTouchBegin);
QVERIFY(!rightWidget.seenTouchUpdate);
QVERIFY(!rightWidget.seenTouchEnd);
- QCOMPARE(leftWidget.touchBeginPoints.count(), 1);
- QCOMPARE(rightWidget.touchBeginPoints.count(), 1);
+ QCOMPARE(leftWidget.touchBeginPoints.size(), 1);
+ QCOMPARE(rightWidget.touchBeginPoints.size(), 1);
const int touchPointId0 = 0;
const int touchPointId1 = touchPointId0 + 1;
{
@@ -907,8 +911,8 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen()
QVERIFY(rightWidget.seenTouchBegin);
QVERIFY(rightWidget.seenTouchUpdate);
QVERIFY(!rightWidget.seenTouchEnd);
- QCOMPARE(leftWidget.touchUpdatePoints.count(), 1);
- QCOMPARE(rightWidget.touchUpdatePoints.count(), 1);
+ QCOMPARE(leftWidget.touchUpdatePoints.size(), 1);
+ QCOMPARE(rightWidget.touchUpdatePoints.size(), 1);
{
const QEventPoint &leftTouchPoint = leftWidget.touchUpdatePoints.first();
QCOMPARE(leftTouchPoint.id(), touchPointId0);
@@ -953,8 +957,8 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen()
QVERIFY(rightWidget.seenTouchBegin);
QVERIFY(rightWidget.seenTouchUpdate);
QVERIFY(rightWidget.seenTouchEnd);
- QCOMPARE(leftWidget.touchEndPoints.count(), 1);
- QCOMPARE(rightWidget.touchEndPoints.count(), 1);
+ QCOMPARE(leftWidget.touchEndPoints.size(), 1);
+ QCOMPARE(rightWidget.touchEndPoints.size(), 1);
{
const QEventPoint &leftTouchPoint = leftWidget.touchEndPoints.first();
QCOMPARE(leftTouchPoint.id(), touchPointId0);
@@ -1012,7 +1016,7 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens()
QVERIFY(touchWidget.seenTouchBegin);
QVERIFY(!touchWidget.seenTouchUpdate);
QVERIFY(!touchWidget.seenTouchEnd);
- QCOMPARE(touchWidget.touchBeginPoints.count(), 1);
+ QCOMPARE(touchWidget.touchBeginPoints.size(), 1);
QCOMPARE(touchWidget.timestamp, timestamp);
QEventPoint touchBeginPoint = touchWidget.touchBeginPoints.first();
QCOMPARE(touchBeginPoint.id(), 1);
@@ -1027,7 +1031,7 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens()
QWindowSystemInterface::handleTouchEvent(window, ++timestamp, secondaryTouchScreenDevice, nativeTouchPoints);
QCoreApplication::processEvents();
QVERIFY(!touchWidget.seenTouchEnd);
- QCOMPARE(touchWidget.touchBeginPoints.count(), 1);
+ QCOMPARE(touchWidget.touchBeginPoints.size(), 1);
QCOMPARE(touchWidget.timestamp, timestamp);
touchBeginPoint = touchWidget.touchBeginPoints[0];
QCOMPARE(touchBeginPoint.id(), 10);
@@ -1042,7 +1046,7 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens()
QWindowSystemInterface::handleTouchEvent(window, ++timestamp, secondaryTouchScreenDevice, nativeTouchPoints);
QCoreApplication::processEvents();
QVERIFY(!touchWidget.seenTouchEnd);
- QCOMPARE(touchWidget.touchBeginPoints.count(), 1);
+ QCOMPARE(touchWidget.touchBeginPoints.size(), 1);
QCOMPARE(touchWidget.timestamp, timestamp);
touchBeginPoint = touchWidget.touchBeginPoints[0];
QCOMPARE(touchBeginPoint.id(), 11);
@@ -1058,7 +1062,7 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens()
QVERIFY(touchWidget.seenTouchBegin);
QVERIFY(touchWidget.seenTouchUpdate);
QVERIFY(!touchWidget.seenTouchEnd);
- QCOMPARE(touchWidget.touchUpdatePoints.count(), 1);
+ QCOMPARE(touchWidget.touchUpdatePoints.size(), 1);
QEventPoint touchUpdatePoint = touchWidget.touchUpdatePoints.first();
QCOMPARE(touchUpdatePoint.id(), 1);
QCOMPARE(touchUpdatePoint.state(), QEventPoint::State::Updated);
@@ -1073,7 +1077,7 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens()
QVERIFY(touchWidget.seenTouchBegin);
QVERIFY(touchWidget.seenTouchUpdate);
QVERIFY(touchWidget.seenTouchEnd);
- QCOMPARE(touchWidget.touchEndPoints.count(), 1);
+ QCOMPARE(touchWidget.touchEndPoints.size(), 1);
QEventPoint touchEndPoint = touchWidget.touchEndPoints.first();
QCOMPARE(touchEndPoint.id(), 1);
QCOMPARE(touchEndPoint.state(), QEventPoint::State::Released);
@@ -1098,7 +1102,7 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens()
QVERIFY(touchWidget.seenTouchBegin);
QVERIFY(touchWidget.seenTouchUpdate);
QVERIFY(!touchWidget.seenTouchEnd);
- QCOMPARE(touchWidget.touchUpdatePoints.count(), 2);
+ QCOMPARE(touchWidget.touchUpdatePoints.size(), 2);
QCOMPARE(touchWidget.touchUpdatePoints[0].id(), 10);
QCOMPARE(touchWidget.touchUpdatePoints[1].id(), 11);
@@ -1113,7 +1117,7 @@ void tst_QTouchEvent::touchOnMultipleTouchscreens()
QVERIFY(touchWidget.seenTouchBegin);
QVERIFY(touchWidget.seenTouchUpdate);
QVERIFY(touchWidget.seenTouchEnd);
- QCOMPARE(touchWidget.touchEndPoints.count(), 1);
+ QCOMPARE(touchWidget.touchEndPoints.size(), 1);
touchEndPoint = touchWidget.touchEndPoints.first();
QCOMPARE(touchEndPoint.id(), 11);
QCOMPARE(touchEndPoint.state(), QEventPoint::State::Released);
@@ -1129,6 +1133,9 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad()
QSKIP("The macOS mouse cursor interferes with this test can cannot be moved away");
#endif
+ if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))
+ QSKIP("QWindow::requestActivate() is not supported.");
+
tst_QTouchEventWidget touchWidget;
touchWidget.setObjectName("touchWidget");
touchWidget.setWindowTitle(QTest::currentTestFunction());
@@ -1185,9 +1192,9 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad()
QVERIFY(!rightWidget.seenTouchBegin);
QVERIFY(!rightWidget.seenTouchUpdate);
QVERIFY(!rightWidget.seenTouchEnd);
- QCOMPARE(leftWidget.touchBeginPoints.count(), 2);
- QCOMPARE(rightWidget.touchBeginPoints.count(), 0);
- QCOMPARE(leftWidget.lastNormalizedPositions.count(), 2);
+ QCOMPARE(leftWidget.touchBeginPoints.size(), 2);
+ QCOMPARE(rightWidget.touchBeginPoints.size(), 0);
+ QCOMPARE(leftWidget.lastNormalizedPositions.size(), 2);
{
QEventPoint leftTouchPoint = leftWidget.touchBeginPoints.at(0);
qCDebug(lcTests) << "lastNormalizedPositions after press" << leftWidget.lastNormalizedPositions;
@@ -1248,9 +1255,9 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad()
QVERIFY(!rightWidget.seenTouchBegin);
QVERIFY(!rightWidget.seenTouchUpdate);
QVERIFY(!rightWidget.seenTouchEnd);
- QCOMPARE(leftWidget.touchUpdatePoints.count(), 2);
- QCOMPARE(rightWidget.touchUpdatePoints.count(), 0);
- QCOMPARE(leftWidget.lastNormalizedPositions.count(), 2);
+ QCOMPARE(leftWidget.touchUpdatePoints.size(), 2);
+ QCOMPARE(rightWidget.touchUpdatePoints.size(), 0);
+ QCOMPARE(leftWidget.lastNormalizedPositions.size(), 2);
{
QEventPoint leftTouchPoint = leftWidget.touchUpdatePoints.at(0);
qCDebug(lcTests) << "lastNormalizedPositions after update" << leftWidget.lastNormalizedPositions;
@@ -1311,9 +1318,9 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad()
QVERIFY(!rightWidget.seenTouchBegin);
QVERIFY(!rightWidget.seenTouchUpdate);
QVERIFY(!rightWidget.seenTouchEnd);
- QCOMPARE(leftWidget.touchEndPoints.count(), 2);
- QCOMPARE(rightWidget.touchEndPoints.count(), 0);
- QCOMPARE(leftWidget.lastNormalizedPositions.count(), 2);
+ QCOMPARE(leftWidget.touchEndPoints.size(), 2);
+ QCOMPARE(rightWidget.touchEndPoints.size(), 0);
+ QCOMPARE(leftWidget.lastNormalizedPositions.size(), 2);
{
QEventPoint leftTouchPoint = leftWidget.touchEndPoints.at(0);
qCDebug(lcTests) << "lastNormalizedPositions after release" << leftWidget.lastNormalizedPositions;
@@ -1396,16 +1403,16 @@ void tst_QTouchEvent::basicRawEventTranslationOfIds()
QVERIFY(touchWidget.seenTouchBegin);
QVERIFY(!touchWidget.seenTouchUpdate);
QVERIFY(!touchWidget.seenTouchEnd);
- QCOMPARE(touchWidget.touchBeginPoints.count(), 2);
+ QCOMPARE(touchWidget.touchBeginPoints.size(), 2);
- for (int i = 0; i < touchWidget.touchBeginPoints.count(); ++i) {
+ for (int i = 0; i < touchWidget.touchBeginPoints.size(); ++i) {
QEventPoint touchBeginPoint = touchWidget.touchBeginPoints.at(i);
QCOMPARE(touchBeginPoint.id(), i);
QCOMPARE(touchBeginPoint.state(), rawTouchPoints[i].state());
}
// moving the point should translate to TouchUpdate
- for (int i = 0; i < rawTouchPoints.count(); ++i) {
+ for (int i = 0; i < rawTouchPoints.size(); ++i) {
auto &p = rawTouchPoints[i];
QMutableEventPoint::setState(p, QEventPoint::State::Updated);
QMutableEventPoint::setGlobalPosition(p, p.globalPosition() + delta);
@@ -1417,7 +1424,7 @@ void tst_QTouchEvent::basicRawEventTranslationOfIds()
QVERIFY(touchWidget.seenTouchBegin);
QVERIFY(touchWidget.seenTouchUpdate);
QVERIFY(!touchWidget.seenTouchEnd);
- QCOMPARE(touchWidget.touchUpdatePoints.count(), 2);
+ QCOMPARE(touchWidget.touchUpdatePoints.size(), 2);
QCOMPARE(touchWidget.touchUpdatePoints.at(0).id(), 0);
QCOMPARE(touchWidget.touchUpdatePoints.at(1).id(), 1);
@@ -1432,7 +1439,7 @@ void tst_QTouchEvent::basicRawEventTranslationOfIds()
QVERIFY(touchWidget.seenTouchBegin);
QVERIFY(touchWidget.seenTouchUpdate);
QCOMPARE(touchWidget.seenTouchEnd, false);
- QCOMPARE(touchWidget.touchUpdatePoints.count(), 2);
+ QCOMPARE(touchWidget.touchUpdatePoints.size(), 2);
QCOMPARE(touchWidget.touchUpdatePoints[0].id(), 0);
QCOMPARE(touchWidget.touchUpdatePoints[1].id(), 1);
@@ -1446,7 +1453,7 @@ void tst_QTouchEvent::basicRawEventTranslationOfIds()
QVERIFY(touchWidget.seenTouchBegin);
QVERIFY(touchWidget.seenTouchUpdate);
QVERIFY(!touchWidget.seenTouchEnd);
- QCOMPARE(touchWidget.touchUpdatePoints.count(), 2);
+ QCOMPARE(touchWidget.touchUpdatePoints.size(), 2);
QCOMPARE(touchWidget.touchUpdatePoints[0].id(), 0);
QCOMPARE(touchWidget.touchUpdatePoints[1].id(), 42);
@@ -1460,7 +1467,7 @@ void tst_QTouchEvent::basicRawEventTranslationOfIds()
QVERIFY(touchWidget.seenTouchBegin);
QVERIFY(touchWidget.seenTouchUpdate);
QVERIFY(touchWidget.seenTouchEnd);
- QCOMPARE(touchWidget.touchUpdatePoints.count(), 2);
+ QCOMPARE(touchWidget.touchUpdatePoints.size(), 2);
QCOMPARE(touchWidget.touchUpdatePoints[0].id(), 0);
QCOMPARE(touchWidget.touchUpdatePoints[1].id(), 42);
}
@@ -1824,25 +1831,25 @@ void tst_QTouchEvent::testQGuiAppDelivery()
// Now the real thing.
QWindowSystemInterface::handleTouchEvent(&w, touchScreenDevice, points); // TouchBegin
QCoreApplication::processEvents();
- QCOMPARE(filter.d.count(), 1);
+ QCOMPARE(filter.d.size(), 1);
QCOMPARE(filter.d.contains(touchScreenDevice), true);
- QCOMPARE(filter.d.value(touchScreenDevice).points.count(), 1);
+ QCOMPARE(filter.d.value(touchScreenDevice).points.size(), 1);
QCOMPARE(filter.d.value(touchScreenDevice).lastSeenType, QEvent::TouchBegin);
points[0].state = QEventPoint::State::Updated;
QWindowSystemInterface::handleTouchEvent(&w, touchScreenDevice, points); // TouchUpdate
QCoreApplication::processEvents();
- QCOMPARE(filter.d.count(), 1);
+ QCOMPARE(filter.d.size(), 1);
QCOMPARE(filter.d.contains(touchScreenDevice), true);
- QCOMPARE(filter.d.value(touchScreenDevice).points.count(), 2);
+ QCOMPARE(filter.d.value(touchScreenDevice).points.size(), 2);
QCOMPARE(filter.d.value(touchScreenDevice).lastSeenType, QEvent::TouchUpdate);
points[0].state = QEventPoint::State::Released;
QWindowSystemInterface::handleTouchEvent(&w, touchScreenDevice, points); // TouchEnd
QCoreApplication::processEvents();
- QCOMPARE(filter.d.count(), 1);
+ QCOMPARE(filter.d.size(), 1);
QCOMPARE(filter.d.contains(touchScreenDevice), true);
- QCOMPARE(filter.d.value(touchScreenDevice).points.count(), 3);
+ QCOMPARE(filter.d.value(touchScreenDevice).points.size(), 3);
QCOMPARE(filter.d.value(touchScreenDevice).lastSeenType, QEvent::TouchEnd);
}
@@ -1885,8 +1892,8 @@ void tst_QTouchEvent::testMultiDevice()
QCOMPARE(filter.d.value(touchScreenDevice).lastSeenType, QEvent::TouchBegin);
QCOMPARE(filter.d.value(deviceTwo).lastSeenType, QEvent::TouchBegin);
- QCOMPARE(filter.d.value(touchScreenDevice).points.count(), 1);
- QCOMPARE(filter.d.value(deviceTwo).points.count(), 2);
+ QCOMPARE(filter.d.value(touchScreenDevice).points.size(), 1);
+ QCOMPARE(filter.d.value(deviceTwo).points.size(), 2);
QCOMPARE(filter.d.value(touchScreenDevice).points.at(0).globalPosition(), area0.center());
// This fails because QGuiApplicationPrivate::processTouchEvent() sends synth-mouse events
@@ -1941,7 +1948,7 @@ void tst_QTouchEvent::grabbers()
// Ensure that grabbers are persistent between events, within the stored touchpoints
QCOMPARE(devPriv->pointById(0)->exclusiveGrabber, grabExclusive ? &w : nullptr);
- QCOMPARE(devPriv->pointById(0)->passiveGrabbers.count(), grabPassive ? 1 : 0);
+ QCOMPARE(devPriv->pointById(0)->passiveGrabbers.size(), grabPassive ? 1 : 0);
if (grabPassive)
QCOMPARE(devPriv->pointById(0)->passiveGrabbers.first(), &w);
diff --git a/tests/auto/gui/kernel/qwindow/BLACKLIST b/tests/auto/gui/kernel/qwindow/BLACKLIST
index 328d3f51b1..69df8883c8 100644
--- a/tests/auto/gui/kernel/qwindow/BLACKLIST
+++ b/tests/auto/gui/kernel/qwindow/BLACKLIST
@@ -11,8 +11,6 @@ windows
# QTBUG-69162
windows-10
android
-[testInputEvents]
-rhel-7.4
[modalWindowPosition]
# QTBUG-69161
android
@@ -23,3 +21,8 @@ android
android
[modalWindowModallity]
android
+[enterLeaveOnWindowShowHide]
+windows-10
+windows-11
+android
+rhel
diff --git a/tests/auto/gui/kernel/qwindow/CMakeLists.txt b/tests/auto/gui/kernel/qwindow/CMakeLists.txt
index 61694f6a9f..5824989ac3 100644
--- a/tests/auto/gui/kernel/qwindow/CMakeLists.txt
+++ b/tests/auto/gui/kernel/qwindow/CMakeLists.txt
@@ -1,12 +1,16 @@
# Copyright (C) 2022 The Qt Company Ltd.
# SPDX-License-Identifier: BSD-3-Clause
-# Generated from qwindow.pro.
-
#####################################################################
## tst_qwindow Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qwindow LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qwindow
SOURCES
tst_qwindow.cpp
@@ -16,6 +20,28 @@ qt_internal_add_test(tst_qwindow
Qt::GuiPrivate
)
+if(APPLE OR WIN32 OR QT_FEATURE_xcb)
+ qt_internal_add_test(tst_foreignwindow
+ LOWDPI
+ SOURCES
+ tst_foreignwindow.cpp
+ LIBRARIES
+ Qt::CorePrivate
+ Qt::Gui
+ Qt::GuiPrivate
+ )
+
+ if(APPLE)
+ enable_language(OBJCXX)
+ set_source_files_properties(tst_foreignwindow.cpp PROPERTIES LANGUAGE OBJCXX)
+ set_property(TARGET tst_foreignwindow PROPERTY PROPERTY MACOSX_BUNDLE TRUE)
+ endif()
+
+ if(QT_FEATURE_xcb)
+ target_link_libraries(tst_foreignwindow PRIVATE XCB::XCB)
+ endif()
+endif()
+
## Scopes:
#####################################################################
diff --git a/tests/auto/gui/kernel/qwindow/tst_foreignwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_foreignwindow.cpp
new file mode 100644
index 0000000000..fdb1b333ef
--- /dev/null
+++ b/tests/auto/gui/kernel/qwindow/tst_foreignwindow.cpp
@@ -0,0 +1,196 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
+
+#include <QTest>
+
+#include <QtCore/qloggingcategory.h>
+#include <private/qguiapplication_p.h>
+#include <qpa/qplatformintegration.h>
+
+#include "../../../../shared/nativewindow.h"
+
+class tst_ForeignWindow: public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void initTestCase()
+ {
+ auto *platformIntegration = QGuiApplicationPrivate::platformIntegration();
+ if (!platformIntegration->hasCapability(QPlatformIntegration::ForeignWindows))
+ QSKIP("This platform does not support foreign windows");
+ }
+
+ void fromWinId();
+ void initialState();
+
+ void embedForeignWindow();
+ void embedInForeignWindow();
+
+ void destroyExplicitly();
+ void destroyWhenParentIsDestroyed();
+};
+
+void tst_ForeignWindow::fromWinId()
+{
+ NativeWindow nativeWindow;
+ QVERIFY(nativeWindow);
+
+ std::unique_ptr<QWindow> foreignWindow(QWindow::fromWinId(nativeWindow));
+ QVERIFY(foreignWindow);
+ QVERIFY(foreignWindow->flags().testFlag(Qt::ForeignWindow));
+ QVERIFY(foreignWindow->handle());
+
+ // fromWinId does not take (exclusive) ownership of the native window,
+ // so deleting the foreign window should not be a problem/cause crashes.
+ foreignWindow.reset();
+}
+
+void tst_ForeignWindow::initialState()
+{
+ NativeWindow nativeWindow;
+ QVERIFY(nativeWindow);
+
+ // A foreign window can be used to embed a Qt UI in a foreign window hierarchy,
+ // in which case the foreign window merely acts as a parent and should not be
+ // modified, or to embed a foreign window in a Qt UI, in which case the foreign
+ // window must to be able to re-parent, move, resize, show, etc, so that the
+ // containing Qt UI can treat it as any other window.
+
+ // At the point of creation though, we don't know what the foreign window
+ // will be used for, so the platform should not assume it can modify the
+ // window. Any properties set on the native window should persist past
+ // creation of the foreign window.
+
+ const QRect initialGeometry(123, 456, 321, 654);
+ nativeWindow.setGeometry(initialGeometry);
+ QTRY_COMPARE(nativeWindow.geometry(), initialGeometry);
+
+ std::unique_ptr<QWindow> foreignWindow(QWindow::fromWinId(nativeWindow));
+ QCOMPARE(nativeWindow.geometry(), initialGeometry);
+
+ // For extra bonus points, the foreign window should actually
+ // reflect the state of the native window.
+ QCOMPARE(foreignWindow->geometry(), initialGeometry);
+}
+
+void tst_ForeignWindow::embedForeignWindow()
+{
+ // A foreign window embedded into a Qt UI requires that the rest of Qt
+ // is to be able to treat the foreign child window as any other window
+ // that it can show, hide, stack, and move around.
+
+ QWindow parentWindow;
+
+ NativeWindow nativeWindow;
+ QVERIFY(nativeWindow);
+
+ // As a prerequisite to that, we must be able to reparent the foreign window
+ std::unique_ptr<QWindow> foreignWindow(QWindow::fromWinId(nativeWindow));
+ foreignWindow->setParent(&parentWindow);
+ QTRY_COMPARE(nativeWindow.parentWinId(), parentWindow.winId());
+
+ // FIXME: This test is flakey on Linux. Figure out why
+#if !defined(Q_OS_LINUX)
+ foreignWindow->setParent(nullptr);
+ QTRY_VERIFY(nativeWindow.parentWinId() != parentWindow.winId());
+#endif
+}
+
+void tst_ForeignWindow::embedInForeignWindow()
+{
+ // When a foreign window is used as a container to embed a Qt UI
+ // in a foreign window hierarchy, the foreign window merely acts
+ // as a parent, and should not be modified.
+
+ {
+ // At a minimum, we must be able to reparent into the window
+ NativeWindow nativeWindow;
+ QVERIFY(nativeWindow);
+
+ std::unique_ptr<QWindow> foreignWindow(QWindow::fromWinId(nativeWindow));
+
+ QWindow embeddedWindow;
+ embeddedWindow.setParent(foreignWindow.get());
+ QTRY_VERIFY(nativeWindow.isParentOf(embeddedWindow.winId()));
+ }
+
+ {
+ // The foreign window's native window should not be reparent as a
+ // result of creating the foreign window, adding and removing children,
+ // or destroying the foreign window.
+
+ NativeWindow topLevelNativeWindow;
+ NativeWindow childNativeWindow;
+ childNativeWindow.setParent(topLevelNativeWindow);
+ QVERIFY(topLevelNativeWindow.isParentOf(childNativeWindow));
+
+ std::unique_ptr<QWindow> foreignWindow(QWindow::fromWinId(childNativeWindow));
+ QVERIFY(topLevelNativeWindow.isParentOf(childNativeWindow));
+
+ QWindow embeddedWindow;
+ embeddedWindow.setParent(foreignWindow.get());
+ QTRY_VERIFY(childNativeWindow.isParentOf(embeddedWindow.winId()));
+ QVERIFY(topLevelNativeWindow.isParentOf(childNativeWindow));
+
+ embeddedWindow.setParent(nullptr);
+ QVERIFY(topLevelNativeWindow.isParentOf(childNativeWindow));
+
+ foreignWindow.reset();
+ QVERIFY(topLevelNativeWindow.isParentOf(childNativeWindow));
+ }
+}
+
+void tst_ForeignWindow::destroyExplicitly()
+{
+ NativeWindow nativeWindow;
+ QVERIFY(nativeWindow);
+
+ std::unique_ptr<QWindow> foreignWindow(QWindow::fromWinId(nativeWindow));
+ QVERIFY(foreignWindow->handle());
+
+ // Explicitly destroying a foreign window is a no-op, as
+ // the documentation claims that it "releases the native
+ // platform resources associated with this window.", which
+ // is not technically true for foreign windows.
+ auto *windowHandleBeforeDestroy = foreignWindow->handle();
+ foreignWindow->destroy();
+ QCOMPARE(foreignWindow->handle(), windowHandleBeforeDestroy);
+}
+
+void tst_ForeignWindow::destroyWhenParentIsDestroyed()
+{
+ QWindow parentWindow;
+
+ NativeWindow nativeWindow;
+ QVERIFY(nativeWindow);
+
+ std::unique_ptr<QWindow> foreignWindow(QWindow::fromWinId(nativeWindow));
+ foreignWindow->setParent(&parentWindow);
+ QTRY_COMPARE(nativeWindow.parentWinId(), parentWindow.winId());
+
+ // Reparenting into a window will result in creating it
+ QVERIFY(parentWindow.handle());
+
+ parentWindow.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&parentWindow));
+
+ // Destroying the parent window of the foreign window results
+ // in destroying the foreign window as well, as the foreign
+ // window no longer has a parent it can be embedded in.
+ QVERIFY(foreignWindow->handle());
+ parentWindow.destroy();
+ QVERIFY(!foreignWindow->handle());
+
+ // But the foreign window can be recreated again, and will
+ // continue to be a native child of the parent window.
+ foreignWindow->create();
+ QVERIFY(foreignWindow->handle());
+ QTRY_COMPARE(nativeWindow.parentWinId(), parentWindow.winId());
+
+ parentWindow.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&parentWindow));
+}
+
+#include <tst_foreignwindow.moc>
+QTEST_MAIN(tst_ForeignWindow)
diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
index 2ebb9472f6..a9e2c5f882 100644
--- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
+++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.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 <qrasterwindow.h>
#include <qpa/qwindowsysteminterface.h>
@@ -7,6 +7,7 @@
#include <qpa/qplatformwindow.h>
#include <private/qguiapplication_p.h>
#include <private/qhighdpiscaling_p.h>
+#include <private/qwindow_p.h>
#include <QtGui/QPainter>
#include <QTest>
@@ -22,6 +23,12 @@
Q_LOGGING_CATEGORY(lcTests, "qt.gui.tests")
+static bool isPlatformEglFS()
+{
+ static const bool isEglFS = !QGuiApplication::platformName().compare(QLatin1String("eglfs"), Qt::CaseInsensitive);
+ return isEglFS;
+}
+
class tst_QWindow: public QObject
{
Q_OBJECT
@@ -30,6 +37,7 @@ private slots:
void create();
void setParent();
void setVisible();
+ void setVisibleThenCreate();
void setVisibleFalseDoesNotCreateWindow();
void eventOrderOnShow();
void paintEvent();
@@ -70,6 +78,7 @@ private slots:
void modalWithChildWindow();
void modalWindowModallity();
void modalWindowPosition();
+ void modalCloseWhileBlocked();
#ifndef QT_NO_CURSOR
void modalWindowEnterEventOnHide_QTBUG35109();
void spuriousMouseMove();
@@ -87,6 +96,14 @@ private slots:
void activateDeactivateEvent();
void qobject_castOnDestruction();
void touchToMouseTranslationByPopup();
+ void stateChangeSignal();
+#ifndef QT_NO_CURSOR
+ void enterLeaveOnWindowShowHide_data();
+ void enterLeaveOnWindowShowHide();
+#endif
+ void windowExposedAfterReparent();
+ void childEvents();
+ void parentEvents();
private:
QPoint m_availableTopLeft;
@@ -104,6 +121,10 @@ static bool isPlatformWayland()
void tst_QWindow::initTestCase()
{
+#ifdef Q_OS_ANDROID
+ if (QNativeInterface::QAndroidApplication::sdkVersion() == 33)
+ QSKIP("Is flaky on Android 13 / RHEL 8.6 and 8.8 (QTQAINFRA-5606)");
+#endif
// Size of reference window, 200 for < 2000, scale up for larger screens
// to avoid Windows warnings about minimum size for decorated windows.
int width = 200;
@@ -229,6 +250,40 @@ void tst_QWindow::setVisible()
QVERIFY(QTest::qWaitForWindowExposed(&i));
}
+class SurfaceCreatedWindow : public QWindow
+{
+ Q_OBJECT
+public:
+ using QWindow::QWindow;
+
+ bool eventFilter(QObject *o, QEvent *e) override
+ {
+ if (e->type() == QEvent::PlatformSurface) {
+ auto type = static_cast<QPlatformSurfaceEvent*>(e)->surfaceEventType();
+ if (type == QPlatformSurfaceEvent::SurfaceCreated)
+ ++surfaceCreatedEvents;
+ }
+ return QWindow::eventFilter(o, e);
+ }
+
+ int surfaceCreatedEvents = 0;
+};
+
+void tst_QWindow::setVisibleThenCreate()
+{
+ QWindow parent;
+ parent.setObjectName("Parent");
+ SurfaceCreatedWindow child(&parent);
+ child.installEventFilter(&child);
+ child.setObjectName("Child");
+ child.setVisible(true);
+ child.create();
+ QCOMPARE(child.surfaceCreatedEvents, 1);
+ parent.setVisible(true);
+ QCOMPARE(child.surfaceCreatedEvents, 1);
+ QVERIFY(QTest::qWaitForWindowExposed(&child));
+}
+
void tst_QWindow::setVisibleFalseDoesNotCreateWindow()
{
QWindow w;
@@ -427,11 +482,16 @@ void tst_QWindow::resizeEventAfterResize()
// Make sure we get a resizeEvent after calling resize
window.resize(m_testWindowSize);
+ if (isPlatformEglFS())
+ QEXPECT_FAIL("", "eglfs windows are fullscreen by default.", Continue);
+
QTRY_COMPARE(window.received(QEvent::Resize), 2);
}
void tst_QWindow::exposeEventOnShrink_QTBUG54040()
{
+ if (isPlatformEglFS())
+ QSKIP("", "eglfs windows are fullscreen by default.", Continue);
Window window;
window.setGeometry(QRect(m_availableTopLeft + QPoint(80, 80), m_testWindowSize));
window.setTitle(QTest::currentTestFunction());
@@ -614,6 +674,8 @@ void tst_QWindow::childWindowPositioning_data()
void tst_QWindow::childWindowPositioning()
{
+ if (isPlatformEglFS())
+ QSKIP("eglfs does not support child windows.");
const QPoint topLeftOrigin(0, 0);
ColoredWindow topLevelWindowFirst(Qt::green);
@@ -716,7 +778,7 @@ void tst_QWindow::stateChange()
// explicitly use non-fullscreen show. show() can be fullscreen on some platforms
window.showNormal();
QVERIFY(QTest::qWaitForWindowExposed(&window));
- for (Qt::WindowState state : qAsConst(stateSequence)) {
+ for (Qt::WindowState state : std::as_const(stateSequence)) {
window.setWindowState(state);
QCoreApplication::processEvents();
}
@@ -993,7 +1055,7 @@ public:
}
touchEventType = event->type();
QList<QTouchEvent::TouchPoint> points = event->points();
- for (int i = 0; i < points.count(); ++i) {
+ for (int i = 0; i < points.size(); ++i) {
const auto &point = points.at(i);
switch (point.state()) {
case QEventPoint::State::Pressed:
@@ -1510,7 +1572,7 @@ void tst_QWindow::orientation()
QSignalSpy spy(&window, SIGNAL(contentOrientationChanged(Qt::ScreenOrientation)));
window.reportContentOrientationChange(Qt::LandscapeOrientation);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
}
void tst_QWindow::sizes()
@@ -1529,40 +1591,40 @@ void tst_QWindow::sizes()
QCOMPARE(window.minimumHeight(), 0);
QCOMPARE(window.minimumSize(), QSize(10, 0));
QCOMPARE(window.maximumSize(), oldMaximum);
- QCOMPARE(minimumWidthSpy.count(), 1);
- QCOMPARE(minimumHeightSpy.count(), 0);
- QCOMPARE(maximumWidthSpy.count(), 0);
- QCOMPARE(maximumHeightSpy.count(), 0);
+ QCOMPARE(minimumWidthSpy.size(), 1);
+ QCOMPARE(minimumHeightSpy.size(), 0);
+ QCOMPARE(maximumWidthSpy.size(), 0);
+ QCOMPARE(maximumHeightSpy.size(), 0);
window.setMinimumHeight(10);
QCOMPARE(window.minimumWidth(), 10);
QCOMPARE(window.minimumHeight(), 10);
QCOMPARE(window.minimumSize(), QSize(10, 10));
QCOMPARE(window.maximumSize(), oldMaximum);
- QCOMPARE(minimumWidthSpy.count(), 1);
- QCOMPARE(minimumHeightSpy.count(), 1);
- QCOMPARE(maximumWidthSpy.count(), 0);
- QCOMPARE(maximumHeightSpy.count(), 0);
+ QCOMPARE(minimumWidthSpy.size(), 1);
+ QCOMPARE(minimumHeightSpy.size(), 1);
+ QCOMPARE(maximumWidthSpy.size(), 0);
+ QCOMPARE(maximumHeightSpy.size(), 0);
window.setMaximumWidth(100);
QCOMPARE(window.maximumWidth(), 100);
QCOMPARE(window.maximumHeight(), oldMaximum.height());
QCOMPARE(window.minimumSize(), QSize(10, 10));
QCOMPARE(window.maximumSize(), QSize(100, oldMaximum.height()));
- QCOMPARE(minimumWidthSpy.count(), 1);
- QCOMPARE(minimumHeightSpy.count(), 1);
- QCOMPARE(maximumWidthSpy.count(), 1);
- QCOMPARE(maximumHeightSpy.count(), 0);
+ QCOMPARE(minimumWidthSpy.size(), 1);
+ QCOMPARE(minimumHeightSpy.size(), 1);
+ QCOMPARE(maximumWidthSpy.size(), 1);
+ QCOMPARE(maximumHeightSpy.size(), 0);
window.setMaximumHeight(100);
QCOMPARE(window.maximumWidth(), 100);
QCOMPARE(window.maximumHeight(), 100);
QCOMPARE(window.minimumSize(), QSize(10, 10));
QCOMPARE(window.maximumSize(), QSize(100, 100));
- QCOMPARE(minimumWidthSpy.count(), 1);
- QCOMPARE(minimumHeightSpy.count(), 1);
- QCOMPARE(maximumWidthSpy.count(), 1);
- QCOMPARE(maximumHeightSpy.count(), 1);
+ QCOMPARE(minimumWidthSpy.size(), 1);
+ QCOMPARE(minimumHeightSpy.size(), 1);
+ QCOMPARE(maximumWidthSpy.size(), 1);
+ QCOMPARE(maximumHeightSpy.size(), 1);
// test if min and max limits will change the size
QVERIFY(window.minimumWidth() < 50 && window.maximumWidth() > 80);
@@ -1574,6 +1636,13 @@ void tst_QWindow::sizes()
window.resize(80, 80);
window.setMaximumSize(QSize(70, 70));
QCOMPARE(window.size(), QSize(70, 70));
+
+ // QTBUG-113233
+ // test for an invalid min/max pair
+ window.setMinimumSize(QSize(80, 80)); // current maximumSize = QSize(70, 70)
+ QCOMPARE(window.size(), QSize(70, 70));
+ window.setMaximumSize(QSize(90, 90));
+ QCOMPARE(window.size(), QSize(80, 80));
}
class CloseOnCloseEventWindow : public QWindow
@@ -1805,25 +1874,25 @@ void tst_QWindow::windowModality()
QCOMPARE(window.modality(), Qt::NonModal);
window.setModality(Qt::NonModal);
QCOMPARE(window.modality(), Qt::NonModal);
- QCOMPARE(spy.count(), 0);
+ QCOMPARE(spy.size(), 0);
window.setModality(Qt::WindowModal);
QCOMPARE(window.modality(), Qt::WindowModal);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
window.setModality(Qt::WindowModal);
QCOMPARE(window.modality(), Qt::WindowModal);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
window.setModality(Qt::ApplicationModal);
QCOMPARE(window.modality(), Qt::ApplicationModal);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
window.setModality(Qt::ApplicationModal);
QCOMPARE(window.modality(), Qt::ApplicationModal);
- QCOMPARE(spy.count(), 2);
+ QCOMPARE(spy.size(), 2);
window.setModality(Qt::NonModal);
QCOMPARE(window.modality(), Qt::NonModal);
- QCOMPARE(spy.count(), 3);
+ QCOMPARE(spy.size(), 3);
}
void tst_QWindow::inputReentrancy()
@@ -2006,32 +2075,32 @@ void tst_QWindow::visibility()
QVERIFY(window.isVisible());
QVERIFY(window.visibility() != QWindow::Hidden);
QVERIFY(window.visibility() != QWindow::AutomaticVisibility);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
window.setVisibility(QWindow::Hidden);
QVERIFY(!window.isVisible());
QCOMPARE(window.visibility(), QWindow::Hidden);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
window.setVisibility(QWindow::FullScreen);
QVERIFY(window.isVisible());
QCOMPARE(window.windowState(), Qt::WindowFullScreen);
QCOMPARE(window.visibility(), QWindow::FullScreen);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QTRY_COMPARE(window.lastReceivedWindowState, Qt::WindowFullScreen);
spy.clear();
window.setWindowState(Qt::WindowNoState);
QCOMPARE(window.visibility(), QWindow::Windowed);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
QTRY_COMPARE(window.lastReceivedWindowState, Qt::WindowNoState);
spy.clear();
window.setVisible(false);
QCOMPARE(window.visibility(), QWindow::Hidden);
- QCOMPARE(spy.count(), 1);
+ QCOMPARE(spy.size(), 1);
spy.clear();
}
@@ -2078,6 +2147,10 @@ void tst_QWindow::initialSize()
w.setTitle(QLatin1String(QTest::currentTestFunction()));
w.setWidth(m_testWindowSize.width());
w.showNormal();
+
+ if (isPlatformEglFS())
+ QEXPECT_FAIL("", "eglfs windows are fullscreen by default.", Continue);
+
QTRY_COMPARE(w.width(), m_testWindowSize.width());
QTRY_VERIFY(w.height() > 0);
}
@@ -2089,6 +2162,8 @@ void tst_QWindow::initialSize()
w.showNormal();
const QSize expectedSize = testSize;
+ if (isPlatformEglFS())
+ QEXPECT_FAIL("", "eglfs windows are fullscreen by default.", Continue);
QTRY_COMPARE(w.size(), expectedSize);
}
}
@@ -2264,9 +2339,29 @@ void tst_QWindow::modalWindowPosition()
window.setModality(Qt::WindowModal);
window.show();
QVERIFY(QTest::qWaitForWindowExposed(&window));
+
+ if (isPlatformEglFS())
+ QEXPECT_FAIL("", "eglfs windows are fullscreen by default.", Continue);
+
QCOMPARE(window.geometry(), origGeo);
}
+void tst_QWindow::modalCloseWhileBlocked()
+{
+ QWindow first;
+ first.setModality(Qt::ApplicationModal);
+ first.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&first));
+
+ QWindow second;
+ second.setModality(Qt::ApplicationModal);
+ second.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&first));
+
+ first.close();
+ QTRY_VERIFY(!first.isVisible());
+}
+
#ifndef QT_NO_CURSOR
void tst_QWindow::modalWindowEnterEventOnHide_QTBUG35109()
{
@@ -2276,6 +2371,9 @@ void tst_QWindow::modalWindowEnterEventOnHide_QTBUG35109()
if (isPlatformOffscreenOrMinimal())
QSKIP("Can't test window focusing on offscreen/minimal");
+ if (isPlatformEglFS())
+ QSKIP("QCursor::setPos() is not supported on this platform");
+
const QPoint center = QGuiApplication::primaryScreen()->availableGeometry().center();
const int childOffset = 16;
@@ -2456,6 +2554,8 @@ void tst_QWindow::spuriousMouseMove()
QSKIP("No enter events sent");
if (platformName == QLatin1String("wayland"))
QSKIP("Setting mouse cursor position is not possible on Wayland");
+ if (isPlatformEglFS())
+ QSKIP("QCursor::setPos() is not supported on this platform");
const QRect screenGeometry = QGuiApplication::primaryScreen()->geometry();
const QPoint center = screenGeometry.center();
QCursor::setPos(center);
@@ -2761,6 +2861,365 @@ void tst_QWindow::touchToMouseTranslationByPopup()
QTRY_COMPARE(window.mouseReleaseButton, int(Qt::LeftButton));
}
+// Test that windowStateChanged is not emitted on noop change (QTBUG-102478)
+void tst_QWindow::stateChangeSignal()
+{
+ // Test only for Windows, Linux and macOS
+#if !defined(Q_OS_LINUX) && !defined(Q_OS_WINDOWS) && !defined(Q_OS_DARWIN)
+ QSKIP("Singular windowStateChanged signal emission is guaranteed for Linux, Windows and macOS only.\n"
+ "On other operating systems, the signal may be emitted twice.");
+#endif
+ QWindow w;
+ Q_ASSERT(connect (&w, &QWindow::windowStateChanged, [](Qt::WindowState s){qCDebug(lcTests) << "State change to" << s;}));
+ QSignalSpy spy(&w, SIGNAL(windowStateChanged(Qt::WindowState)));
+ unsigned short signalCount = 0;
+ QList<Qt::WindowState> effectiveStates;
+ Q_ASSERT(connect(&w, &QWindow::windowStateChanged, [&effectiveStates](Qt::WindowState state)
+ { effectiveStates.append(state); }));
+ // Part 1:
+ // => test signal emission on programmatic state changes
+ QCOMPARE(w.windowState(), Qt::WindowNoState);
+ // - wait for target state to be set
+ // - wait for signal spy to have reached target count
+ // - extract state from signal and compare to target
+#define CHECK_STATE(State)\
+ QTRY_VERIFY(QTest::qWaitFor([&w](){return (w.windowState() == State); }));\
+ CHECK_SIGNAL(State)
+#define CHECK_SIGNAL(State)\
+ QTRY_COMPARE(spy.count(), signalCount);\
+ if (signalCount > 0) {\
+ QVariantList list = spy.at(signalCount - 1).toList();\
+ QCOMPARE(list.count(), 1);\
+ bool ok;\
+ const int stateInt = list.at(0).toInt(&ok);\
+ QVERIFY(ok);\
+ const Qt::WindowState newState = static_cast<Qt::WindowState>(stateInt);\
+ QCOMPARE(newState, State);\
+ }
+ // Check initialization
+ CHECK_STATE(Qt::WindowNoState);
+ // showMaximized after init
+ // expected behavior: signal emitted once with state == WindowMaximized
+ ++signalCount;
+ w.showMaximized();
+ CHECK_STATE(Qt::WindowMaximized);
+ // setWindowState to normal
+ // expected behavior: signal emitted once with state == WindowNoState
+ ++signalCount;
+ w.setWindowState(Qt::WindowNoState);
+ CHECK_STATE(Qt::WindowNoState);
+ // redundant setWindowState to normal - except windows, where the no-op is counted
+ // expected behavior: No emits.
+ // On Windows, a no-op state change causes a no-op resize and repaint, leading to a
+ // no-op state change and singal emission.
+#ifdef Q_OS_WINDOWS
+ ++signalCount;
+ ++signalCount;
+#endif
+ w.setWindowState(Qt::WindowNoState);
+ CHECK_STATE(Qt::WindowNoState);
+ // setWindowState to minimized
+ // expected behavior: signal emitted once with state == WindowMinimized
+ ++signalCount;
+ w.showMinimized();
+ CHECK_STATE(Qt::WindowMinimized);
+ // setWindowState to Normal
+ // expected behavior: signal emitted once with state == WindowNoState
+ ++signalCount;
+ w.showNormal();
+ CHECK_STATE(Qt::WindowNoState);
+ /*
+ - Testcase showFullScreen is omitted: Depending on window manager,
+ WindowFullScreen can be mapped to WindowMaximized
+ - Transition from WindowMinimized to WindowMaximized is omitted:
+ WindowNoState to WindowMaximized
+ */
+ // Part 2:
+ // => test signal emission on simulated user interaction
+ // To test the code path, inject state change events into the QPA event queue.
+ // Test the signal emission only, not the window's actual visible state.
+
+ // Flush pending events and clear
+ QCoreApplication::processEvents();
+ spy.clear();
+ effectiveStates.clear();
+ signalCount = 0;
+ // Maximize window
+ QWindowSystemInterface::handleWindowStateChanged(&w, Qt::WindowMaximized, w.windowState());
+ ++signalCount;
+ CHECK_SIGNAL(Qt::WindowMaximized);
+ // Normalize window
+ QWindowSystemInterface::handleWindowStateChanged(&w, Qt::WindowNoState, w.windowState());
+ ++signalCount;
+ CHECK_SIGNAL(Qt::WindowNoState);
+ // Minimize window
+ QWindowSystemInterface::handleWindowStateChanged(&w, Qt::WindowMinimized, w.windowState());
+ ++signalCount;
+ CHECK_SIGNAL(Qt::WindowMinimized);
+}
+
+#ifndef QT_NO_CURSOR
+void tst_QWindow::enterLeaveOnWindowShowHide_data()
+{
+ QTest::addColumn<Qt::WindowType>("windowType");
+ QTest::addRow("dialog") << Qt::Dialog;
+ QTest::addRow("popup") << Qt::Popup;
+}
+
+/*!
+ Verify that we get enter and leave events if the window under the mouse
+ opens and closes a modal dialog or popup. QWindow might get multiple
+ events in a row, as the various QPA plugins need to use different techniques
+ to synthesize events if the native platform doesn't provide them for us.
+*/
+void tst_QWindow::enterLeaveOnWindowShowHide()
+{
+ if (isPlatformWayland())
+ QSKIP("Can't set cursor position and qWaitForWindowActive on Wayland");
+
+ if (isPlatformEglFS())
+ QSKIP("QCursor::setPos() is not supported on this platform");
+
+ QFETCH(Qt::WindowType, windowType);
+
+ class Window : public QWindow
+ {
+ public:
+ int numEnterEvents = 0;
+ int numLeaveEvents = 0;
+ QPoint enterPosition;
+ protected:
+ bool event(QEvent *e) override
+ {
+ switch (e->type()) {
+ case QEvent::Enter:
+ ++numEnterEvents;
+ enterPosition = static_cast<QEnterEvent*>(e)->position().toPoint();
+ break;
+ case QEvent::Leave:
+ ++numLeaveEvents;
+ break;
+ default:
+ break;
+ }
+ return QWindow::event(e);
+ }
+ };
+
+ int expectedEnter = 0;
+ int expectedLeave = 0;
+
+ Window window;
+ const QRect screenGeometry = window.screen()->availableGeometry();
+ const QPoint cursorPos = screenGeometry.topLeft() + QPoint(50, 50);
+ window.setGeometry(QRect(cursorPos - QPoint(50, 50), screenGeometry.size() / 4));
+ QCursor::setPos(cursorPos);
+
+ if (!QTest::qWaitFor([&]{ return window.geometry().contains(QCursor::pos()); }))
+ QSKIP("We can't move the cursor");
+
+ window.show();
+ window.requestActivate();
+ QVERIFY(QTest::qWaitForWindowActive(&window));
+
+ ++expectedEnter;
+ QTRY_COMPARE_WITH_TIMEOUT(window.numEnterEvents, expectedEnter, 250);
+ QCOMPARE(window.enterPosition, window.mapFromGlobal(QCursor::pos()));
+
+ QWindow secondary;
+ secondary.setFlag(windowType);
+ secondary.setModality(Qt::WindowModal);
+ secondary.setTransientParent(&window);
+ secondary.setPosition(cursorPos + QPoint(50, 50));
+ secondary.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&secondary));
+ ++expectedLeave;
+ QTRY_VERIFY(window.numLeaveEvents >= expectedLeave);
+ secondary.close();
+ ++expectedEnter;
+ QTRY_VERIFY(window.numEnterEvents >= expectedEnter);
+ QCOMPARE(window.enterPosition, window.mapFromGlobal(QCursor::pos()));
+}
+#endif
+
+void tst_QWindow::windowExposedAfterReparent()
+{
+ QWindow parent;
+ QWindow child(&parent);
+ child.show();
+ parent.show();
+
+ QVERIFY(QTest::qWaitForWindowExposed(&parent));
+ QVERIFY(QTest::qWaitForWindowExposed(&child));
+
+ child.setParent(nullptr);
+ QCoreApplication::processEvents();
+ QVERIFY(QTest::qWaitForWindowExposed(&child));
+
+ child.setParent(&parent);
+ QCoreApplication::processEvents();
+ QVERIFY(QTest::qWaitForWindowExposed(&child));
+}
+
+struct ParentWindow : public QWindow
+{
+ bool event(QEvent *event) override
+ {
+ [&]() -> void {
+ if (event->type() == QEvent::ChildWindowAdded
+ || event->type() == QEvent::ChildWindowRemoved) {
+ // We should not receive child events after the window has been destructed
+ QVERIFY(this->isWindowType());
+
+ auto *parentWindow = this;
+ auto *childEvent = static_cast<QChildWindowEvent*>(event);
+ auto *childWindow = childEvent->child();
+
+ if (event->type() == QEvent::ChildWindowAdded) {
+ QVERIFY(childWindow->parent());
+ QVERIFY(parentWindow->isAncestorOf(childWindow));
+ if (childWindow->handle())
+ QVERIFY(childWindow->handle()->parent() == parentWindow->handle());
+
+ } else {
+ QVERIFY(!childWindow->parent());
+ QVERIFY(!parentWindow->isAncestorOf(childWindow));
+ if (childWindow->handle())
+ QVERIFY(childWindow->handle()->parent() != parentWindow->handle());
+ }
+ }
+ }();
+
+ return QWindow::event(event);
+ }
+};
+
+void tst_QWindow::childEvents()
+{
+ ParentWindow parent;
+
+ {
+ // ChildAdded via constructor
+ QWindow constructorChild(&parent);
+ if (QTest::currentTestFailed()) return;
+ // ChildRemoved via destructor
+ }
+
+ if (QTest::currentTestFailed()) return;
+
+ // ChildAdded and ChildRemoved via setParent
+ QWindow child;
+ child.setParent(&parent);
+ if (QTest::currentTestFailed()) return;
+ child.setParent(nullptr);
+ if (QTest::currentTestFailed()) return;
+
+ parent.create();
+ child.create();
+
+ // ChildAdded and ChildRemoved after creation
+ child.setParent(&parent);
+ if (QTest::currentTestFailed()) return;
+ child.setParent(nullptr);
+ if (QTest::currentTestFailed()) return;
+}
+
+struct ChildWindowPrivate;
+struct ChildWindow : public QWindow
+{
+ ChildWindow(QWindow *parent = nullptr);
+};
+
+struct ChildWindowPrivate : public QWindowPrivate
+{
+ ChildWindowPrivate() : QWindowPrivate()
+ {
+ receiveParentEvents = true;
+ }
+};
+
+ChildWindow::ChildWindow(QWindow *parent)
+ : QWindow(*new ChildWindowPrivate, parent)
+{}
+
+struct ParentEventTester : public QObject
+{
+ bool eventFilter(QObject *object, QEvent *event) override
+ {
+ [&]() -> void {
+ if (event->type() == QEvent::ParentWindowAboutToChange
+ || event->type() == QEvent::ParentWindowChange) {
+ // We should not receive parent events after the window has been destructed
+ QVERIFY(object->isWindowType());
+ auto *window = static_cast<QWindow*>(object);
+
+ if (event->type() == QEvent::ParentWindowAboutToChange) {
+ QVERIFY(window->parent() != nextExpectedParent);
+ if (window->handle()) {
+ QVERIFY(window->handle()->parent() !=
+ (nextExpectedParent ? nextExpectedParent->handle() : nullptr));
+ }
+ } else {
+ QVERIFY(window->parent() == nextExpectedParent);
+ if (window->handle()) {
+ QVERIFY(window->handle()->parent() ==
+ (nextExpectedParent ? nextExpectedParent->handle() : nullptr));
+ }
+ }
+ }
+ }();
+
+ return QObject::eventFilter(object, event);
+ }
+
+ QWindow *nextExpectedParent = nullptr;
+};
+
+
+
+void tst_QWindow::parentEvents()
+{
+ QWindow parent;
+
+ {
+ ParentEventTester tester;
+
+ {
+ // We can't hook in early enough to get the parent change during
+ // QObject construction.
+ ChildWindow child(&parent);
+
+ // But we can observe the one during destruction
+ child.installEventFilter(&tester);
+ tester.nextExpectedParent = nullptr;
+ }
+ }
+ if (QTest::currentTestFailed()) return;
+
+ ParentEventTester tester;
+ ChildWindow child;
+ child.installEventFilter(&tester);
+
+ tester.nextExpectedParent = &parent;
+ child.setParent(&parent);
+ if (QTest::currentTestFailed()) return;
+
+ tester.nextExpectedParent = nullptr;
+ child.setParent(nullptr);
+ if (QTest::currentTestFailed()) return;
+
+ parent.create();
+ child.create();
+
+ tester.nextExpectedParent = &parent;
+ child.setParent(&parent);
+ if (QTest::currentTestFailed()) return;
+
+ tester.nextExpectedParent = nullptr;
+ child.setParent(nullptr);
+ if (QTest::currentTestFailed()) return;
+}
+
#include <tst_qwindow.moc>
QTEST_MAIN(tst_QWindow)