diff options
Diffstat (limited to 'tests/auto/printsupport/kernel')
7 files changed, 59 insertions, 104 deletions
diff --git a/tests/auto/printsupport/kernel/CMakeLists.txt b/tests/auto/printsupport/kernel/CMakeLists.txt index 8154d5e868..f633590f62 100644 --- a/tests/auto/printsupport/kernel/CMakeLists.txt +++ b/tests/auto/printsupport/kernel/CMakeLists.txt @@ -1,4 +1,5 @@ -# Generated from kernel.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause add_subdirectory(qprintdevice) add_subdirectory(qprinter) diff --git a/tests/auto/printsupport/kernel/qprintdevice/CMakeLists.txt b/tests/auto/printsupport/kernel/qprintdevice/CMakeLists.txt index 8cdd82068e..3df4d6e135 100644 --- a/tests/auto/printsupport/kernel/qprintdevice/CMakeLists.txt +++ b/tests/auto/printsupport/kernel/qprintdevice/CMakeLists.txt @@ -1,15 +1,22 @@ -# Generated from qprintdevice.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## 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 DEFINES QT_USE_USING_NAMESPACE - PUBLIC_LIBRARIES + LIBRARIES Qt::Gui Qt::PrintSupportPrivate ) diff --git a/tests/auto/printsupport/kernel/qprintdevice/tst_qprintdevice.cpp b/tests/auto/printsupport/kernel/qprintdevice/tst_qprintdevice.cpp index e079659d3a..81b50c1084 100644 --- a/tests/auto/printsupport/kernel/qprintdevice/tst_qprintdevice.cpp +++ b/tests/auto/printsupport/kernel/qprintdevice/tst_qprintdevice.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2014 John Layt <jlayt@kde.org> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2014 John Layt <jlayt@kde.org> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QTest> #include <QMimeType> @@ -50,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 2fffa945a7..c861a122d9 100644 --- a/tests/auto/printsupport/kernel/qprinter/CMakeLists.txt +++ b/tests/auto/printsupport/kernel/qprinter/CMakeLists.txt @@ -1,13 +1,20 @@ -# Generated from qprinter.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## 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 - PUBLIC_LIBRARIES + LIBRARIES Qt::Gui Qt::PrintSupport Qt::Widgets diff --git a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp index bd0f4feb09..d2ccf7b990 100644 --- a/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp +++ b/tests/auto/printsupport/kernel/qprinter/tst_qprinter.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QTest> @@ -45,7 +20,7 @@ #include <math.h> #ifdef Q_OS_WIN -#include <windows.h> +#include <qt_windows.h> #endif #if QT_CONFIG(printer) @@ -928,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; @@ -1218,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; @@ -1340,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; @@ -1433,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); @@ -1727,7 +1705,7 @@ void tst_QPrinter::reusePageMetrics() QPrinter defaultP; QPrinterInfo info(defaultP); QString otherPrinterName; - for (QPrinterInfo i : qAsConst(availablePrinters)) { + for (QPrinterInfo i : std::as_const(availablePrinters)) { if (i.printerName() != defaultP.printerName()) { otherPrinterName = i.printerName(); break; @@ -1737,9 +1715,9 @@ void tst_QPrinter::reusePageMetrics() QList<QPageSize> defaultPageSizes = info.supportedPageSizes(); QList<QPageSize> otherPageSizes = QPrinterInfo(otherP).supportedPageSizes(); QPageSize unavailableSizeToSet; - for (QPageSize s : qAsConst(defaultPageSizes)) { + for (QPageSize s : std::as_const(defaultPageSizes)) { bool found = false; - for (QPageSize os : qAsConst(otherPageSizes)) { + for (QPageSize os : std::as_const(otherPageSizes)) { if (os.isEquivalentTo(s)) { found = true; break; diff --git a/tests/auto/printsupport/kernel/qprinterinfo/CMakeLists.txt b/tests/auto/printsupport/kernel/qprinterinfo/CMakeLists.txt index 18a093c4e3..84d0de4d5e 100644 --- a/tests/auto/printsupport/kernel/qprinterinfo/CMakeLists.txt +++ b/tests/auto/printsupport/kernel/qprinterinfo/CMakeLists.txt @@ -1,15 +1,22 @@ -# Generated from qprinterinfo.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## 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 DEFINES QT_USE_USING_NAMESPACE - PUBLIC_LIBRARIES + LIBRARIES Qt::Gui Qt::PrintSupport ) diff --git a/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp b/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp index ebe0990164..110f2996fd 100644 --- a/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp +++ b/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QTest> #include <QtGlobal> @@ -33,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> @@ -74,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"); } @@ -119,7 +98,7 @@ QStringList tst_QPrinterInfo::getPrintersFromSystem() QString output = getOutputFromCommand({ "lpstat", "-e" }); QStringList list = output.split(QChar::fromLatin1('\n')); - QRegularExpression reg("^([.a-zA-Z0-9-_@]+)"); + QRegularExpression reg("^([.a-zA-Z0-9-_@/]+)"); QRegularExpressionMatch match; for (int c = 0; c < list.size(); ++c) { match = reg.match(list[c]); @@ -199,7 +178,7 @@ QString tst_QPrinterInfo::getOutputFromCommand(const QStringList &command) { // Forces the ouptut from the command to be in English const QByteArray origSoftwareEnv = qgetenv("SOFTWARE"); - qputenv("SOFTWARE", QByteArray()); + qputenv("SOFTWARE", nullptr); QString output = getOutputFromCommandInternal(command); qputenv("SOFTWARE", origSoftwareEnv); return output; @@ -361,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()); |