summaryrefslogtreecommitdiffstats
path: root/tests/auto/printsupport
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/printsupport')
-rw-r--r--tests/auto/printsupport/dialogs/qabstractprintdialog/CMakeLists.txt6
-rw-r--r--tests/auto/printsupport/dialogs/qabstractprintdialog/tst_qabstractprintdialog.cpp35
-rw-r--r--tests/auto/printsupport/kernel/qprintdevice/CMakeLists.txt6
-rw-r--r--tests/auto/printsupport/kernel/qprintdevice/tst_qprintdevice.cpp9
-rw-r--r--tests/auto/printsupport/kernel/qprinter/CMakeLists.txt6
-rw-r--r--tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp13
-rw-r--r--tests/auto/printsupport/kernel/qprinterinfo/CMakeLists.txt6
-rw-r--r--tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp12
8 files changed, 79 insertions, 14 deletions
diff --git a/tests/auto/printsupport/dialogs/qabstractprintdialog/CMakeLists.txt b/tests/auto/printsupport/dialogs/qabstractprintdialog/CMakeLists.txt
index f3cfd65928..64a7792d77 100644
--- a/tests/auto/printsupport/dialogs/qabstractprintdialog/CMakeLists.txt
+++ b/tests/auto/printsupport/dialogs/qabstractprintdialog/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qabstractprintdialog Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qabstractprintdialog LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qabstractprintdialog
SOURCES
tst_qabstractprintdialog.cpp
diff --git a/tests/auto/printsupport/dialogs/qabstractprintdialog/tst_qabstractprintdialog.cpp b/tests/auto/printsupport/dialogs/qabstractprintdialog/tst_qabstractprintdialog.cpp
index 8dcfab8e64..c3785efe18 100644
--- a/tests/auto/printsupport/dialogs/qabstractprintdialog/tst_qabstractprintdialog.cpp
+++ b/tests/auto/printsupport/dialogs/qabstractprintdialog/tst_qabstractprintdialog.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>
@@ -24,6 +24,8 @@ private slots:
void getSetCheck();
void setMinMax();
void setFromTo();
+
+ void hideNativeByDestruction();
#endif
};
@@ -135,6 +137,37 @@ void tst_QAbstractPrintDialog::setFromTo()
QCOMPARE(obj1.maxPage(), 50);
}
+void tst_QAbstractPrintDialog::hideNativeByDestruction()
+{
+#ifdef Q_OS_WINDOWS
+ QSKIP("This test fails on windows, the QPrintDialog::setVisible implementation blocks");
+#endif
+
+ QWidget window;
+ QWidget *child = new QWidget(&window);
+ QPointer<QPrintDialog> dialog = new QPrintDialog(child);
+ // Make it application modal so that we don't end up with a sheet on macOS
+ dialog->setWindowModality(Qt::ApplicationModal);
+ window.show();
+ QVERIFY(QTest::qWaitForWindowActive(&window));
+ dialog->open();
+
+ // We test that the dialog opens and closes by watching the activation of the
+ // transient parent window. If it doesn't deactivate, then we have to skip.
+ const auto windowActive = [&window]{ return window.isActiveWindow(); };
+ const auto windowInactive = [&window]{ return !window.isActiveWindow(); };
+ if (!QTest::qWaitFor(windowInactive, 2000))
+ QSKIP("Dialog didn't activate");
+
+ // This should destroy the dialog and close the native window
+ child->deleteLater();
+ QTRY_VERIFY(!dialog);
+ // If the native window is still open, then the transient parent can't become
+ // active
+ window.activateWindow();
+ QVERIFY(QTest::qWaitFor(windowActive));
+}
+
#endif
QTEST_MAIN(tst_QAbstractPrintDialog)
diff --git a/tests/auto/printsupport/kernel/qprintdevice/CMakeLists.txt b/tests/auto/printsupport/kernel/qprintdevice/CMakeLists.txt
index 1ac8a5cb6c..3df4d6e135 100644
--- a/tests/auto/printsupport/kernel/qprintdevice/CMakeLists.txt
+++ b/tests/auto/printsupport/kernel/qprintdevice/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qprintdevice Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qprintdevice LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qprintdevice
SOURCES
tst_qprintdevice.cpp
diff --git a/tests/auto/printsupport/kernel/qprintdevice/tst_qprintdevice.cpp b/tests/auto/printsupport/kernel/qprintdevice/tst_qprintdevice.cpp
index a496b5bfb9..81b50c1084 100644
--- a/tests/auto/printsupport/kernel/qprintdevice/tst_qprintdevice.cpp
+++ b/tests/auto/printsupport/kernel/qprintdevice/tst_qprintdevice.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2014 John Layt <jlayt@kde.org>
-// 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 <QMimeType>
@@ -25,16 +25,17 @@ void tst_QPrintDevice::basics()
QSKIP("Could not load platform plugin");
QString defaultId = ps->defaultPrintDeviceId();
+ const QStringList availableIds = ps->availablePrintDeviceIds();
if (defaultId.isEmpty()) {
qDebug() << "No default printer found";
} else {
- QVERIFY(ps->availablePrintDeviceIds().contains(defaultId));
+ QVERIFY(availableIds.contains(defaultId));
}
- qDebug() << "Available Printer IDs :" << ps->availablePrintDeviceIds();
+ qDebug() << "Available Printer IDs :" << availableIds;
// Just exercise the api for now as we don't know what is installed
- foreach (const QString id, ps->availablePrintDeviceIds()) {
+ for (const QString &id : availableIds) {
QPrintDevice printDevice = ps->createPrintDevice(id);
const char quote = id == defaultId ? '*' : '"';
qDebug().noquote().nospace() << "\nCreated printer " << quote << id
diff --git a/tests/auto/printsupport/kernel/qprinter/CMakeLists.txt b/tests/auto/printsupport/kernel/qprinter/CMakeLists.txt
index eac48bd383..c861a122d9 100644
--- a/tests/auto/printsupport/kernel/qprinter/CMakeLists.txt
+++ b/tests/auto/printsupport/kernel/qprinter/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qprinter Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qprinter LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qprinter
SOURCES
tst_qprinter.cpp
diff --git a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp
index 6b058c88f4..d2ccf7b990 100644
--- a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp
+++ b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.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>
@@ -903,7 +903,8 @@ void tst_QPrinter::duplex()
QPrinter::DuplexMode expected = printerInfo.defaultDuplexMode();
QCOMPARE(native.duplex(), expected);
// Test set/get (skipping Auto as that will return something different)
- foreach (QPrinter::DuplexMode mode, printerInfo.supportedDuplexModes()) {
+ const auto supported = printerInfo.supportedDuplexModes();
+ for (QPrinter::DuplexMode mode : supported) {
if (mode != expected && mode != QPrinter::DuplexAuto) {
expected = mode;
break;
@@ -1193,7 +1194,8 @@ void tst_QPrinter::paperSource()
QPrinter::PaperSource expected = QPrinter::Manual;
#ifdef Q_OS_WIN
expected = QPrinter::Auto;
- foreach (QPrinter::PaperSource supported, native.supportedPaperSources()) {
+ const auto sources = native.supportedPaperSources();
+ for (QPrinter::PaperSource supported : sources) {
if (supported != QPrinter::Auto) {
expected = supported;
break;
@@ -1315,7 +1317,8 @@ void tst_QPrinter::printerName()
// Test set/get
QString expected = QPrinterInfo::defaultPrinter().printerName();
- foreach (const QPrinterInfo &available, QPrinterInfo::availablePrinters()) {
+ const auto allAvailable = QPrinterInfo::availablePrinters();
+ for (const QPrinterInfo &available : allAvailable) {
if (available.printerName() != expected) {
expected = available.printerName();
break;
@@ -1408,7 +1411,7 @@ void tst_QPrinter::resolution()
#ifdef Q_OS_MAC
// QMacPrintEngine chooses the closest supported resolution.
const QList<int> all_supported = native.supportedResolutions();
- foreach (int supported, all_supported) {
+ for (int supported : all_supported) {
// Test setting a supported resolution
int requested = supported;
native.setResolution(requested);
diff --git a/tests/auto/printsupport/kernel/qprinterinfo/CMakeLists.txt b/tests/auto/printsupport/kernel/qprinterinfo/CMakeLists.txt
index 9d5aa19389..84d0de4d5e 100644
--- a/tests/auto/printsupport/kernel/qprinterinfo/CMakeLists.txt
+++ b/tests/auto/printsupport/kernel/qprinterinfo/CMakeLists.txt
@@ -5,6 +5,12 @@
## tst_qprinterinfo Test:
#####################################################################
+if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT)
+ cmake_minimum_required(VERSION 3.16)
+ project(tst_qprinterinfo LANGUAGES CXX)
+ find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST)
+endif()
+
qt_internal_add_test(tst_qprinterinfo
SOURCES
tst_qprinterinfo.cpp
diff --git a/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp b/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp
index c883df8637..110f2996fd 100644
--- a/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp
+++ b/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.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 <QtGlobal>
@@ -8,7 +8,7 @@
#include <algorithm>
-#if defined(Q_OS_UNIX) && !defined(Q_OS_INTEGRITY)
+#if defined(Q_OS_UNIX) && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_VXWORKS)
# include <unistd.h>
# include <sys/types.h>
# include <sys/wait.h>
@@ -49,6 +49,10 @@ private:
#ifdef QT_NO_PRINTER
void tst_QPrinterInfo::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
QSKIP("This test requires printing support");
}
@@ -336,11 +340,11 @@ void tst_QPrinterInfo::testAssignment()
void tst_QPrinterInfo::namedPrinter()
{
- QList<QPrinterInfo> printers = QPrinterInfo::availablePrinters();
+ const QList<QPrinterInfo> printers = QPrinterInfo::availablePrinters();
QStringList printerNames;
- foreach (const QPrinterInfo &pi, printers) {
+ for (const QPrinterInfo &pi : printers) {
QPrinterInfo pi2 = QPrinterInfo::printerInfo(pi.printerName());
QCOMPARE(pi2.printerName(), pi.printerName());
QCOMPARE(pi2.description(), pi.description());