diff options
Diffstat (limited to 'tests/auto/corelib')
1045 files changed, 8700 insertions, 14698 deletions
diff --git a/tests/auto/corelib/animation/qabstractanimation/tst_qabstractanimation.cpp b/tests/auto/corelib/animation/qabstractanimation/tst_qabstractanimation.cpp index 65e57e2d84..0408ad806b 100644 --- a/tests/auto/corelib/animation/qabstractanimation/tst_qabstractanimation.cpp +++ b/tests/auto/corelib/animation/qabstractanimation/tst_qabstractanimation.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 WITH Qt-GPL-exception-1.0 #include <QtCore/qabstractanimation.h> diff --git a/tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp b/tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp index a5cb2c021e..162f8ea9fc 100644 --- a/tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp +++ b/tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.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 WITH Qt-GPL-exception-1.0 #include <QTest> #include <QPauseAnimation> @@ -290,7 +265,8 @@ void tst_QAnimationGroup::setParentAutoAdd() void tst_QAnimationGroup::beginNestedGroup() { - QAnimationGroup *parent = new QParallelAnimationGroup(); + QParallelAnimationGroup group; + QAnimationGroup *parent = &group; for (int i = 0; i < 10; ++i) { if (i & 1) { @@ -347,7 +323,8 @@ void tst_QAnimationGroup::addChildTwice() void tst_QAnimationGroup::loopWithoutStartValue() { - QAnimationGroup *parent = new QSequentialAnimationGroup(); + QSequentialAnimationGroup group; + QAnimationGroup *parent = &group; QObject o; o.setProperty("ole", 0); QCOMPARE(o.property("ole").toInt(), 0); diff --git a/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp b/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp index 6cf7e5cb94..6d73725cff 100644 --- a/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp +++ b/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.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 WITH Qt-GPL-exception-1.0 #include <QTest> #include <QVariantAnimation> diff --git a/tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.cpp b/tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.cpp index 0688eafda8..ba57904620 100644 --- a/tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.cpp +++ b/tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.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 WITH Qt-GPL-exception-1.0 #include <QTest> diff --git a/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp index 1da69f8338..a5eff80e49 100644 --- a/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp +++ b/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.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 WITH Qt-GPL-exception-1.0 #include <QTest> #include <QtTest/private/qpropertytesthelper_p.h> @@ -291,16 +266,16 @@ void tst_QPropertyAnimation::statesAndSignals_data() void tst_QPropertyAnimation::statesAndSignals() { QFETCH(bool, uncontrolled); - QPropertyAnimation *anim; + std::unique_ptr<QPropertyAnimation> anim; if (uncontrolled) - anim = new UncontrolledAnimation; + anim = std::make_unique<UncontrolledAnimation>(); else - anim = new DummyPropertyAnimation; + anim = std::make_unique<DummyPropertyAnimation>(); anim->setDuration(100); - QSignalSpy finishedSpy(anim, &QPropertyAnimation::finished); - QSignalSpy runningSpy(anim, &QPropertyAnimation::stateChanged); - QSignalSpy currentLoopSpy(anim, &QPropertyAnimation::currentLoopChanged); + QSignalSpy finishedSpy(anim.get(), &QPropertyAnimation::finished); + QSignalSpy runningSpy(anim.get(), &QPropertyAnimation::stateChanged); + QSignalSpy currentLoopSpy(anim.get(), &QPropertyAnimation::currentLoopChanged); QVERIFY(finishedSpy.isValid()); QVERIFY(runningSpy.isValid()); @@ -371,8 +346,6 @@ void tst_QPropertyAnimation::statesAndSignals() QCOMPARE(runningSpy.count(), 1); // anim has stopped QCOMPARE(finishedSpy.count(), 2); QCOMPARE(anim->currentLoopTime(), 100); - - delete anim; } } @@ -421,9 +394,10 @@ void tst_QPropertyAnimation::deletion1() void tst_QPropertyAnimation::deletion2() { TestAnimationDriver timeDriver; - //test that the animation get deleted if the object is deleted + // test that the animation does not get deleted if the object is deleted QObject *object = new QWidget; QPointer<QPropertyAnimation> anim = new QPropertyAnimation(object,"minimumWidth"); + QVERIFY(anim->parent() != object); anim->setStartValue(10); anim->setEndValue(20); anim->setDuration(200); @@ -450,14 +424,18 @@ void tst_QPropertyAnimation::deletion2() QTimer::singleShot(0, object, SLOT(deleteLater())); timeDriver.wait(50); + QVERIFY(anim); QVERIFY(!anim->targetObject()); + + delete anim; } void tst_QPropertyAnimation::deletion3() { //test that the stopped signal is emit when the animation is destroyed TestAnimationDriver timeDriver; - QObject *object = new QWidget; + QWidget w; + QObject *object = &w; QPropertyAnimation *anim = new QPropertyAnimation(object,"minimumWidth"); anim->setStartValue(10); anim->setEndValue(20); @@ -1332,8 +1310,8 @@ void tst_QPropertyAnimation::totalDuration() void tst_QPropertyAnimation::zeroLoopCount() { - DummyPropertyAnimation* anim; - anim = new DummyPropertyAnimation; + DummyPropertyAnimation animation; + auto *anim = &animation; anim->setStartValue(0); anim->setDuration(20); anim->setLoopCount(0); diff --git a/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp b/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp index fbe3ffe4ae..61be0d00f5 100644 --- a/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp +++ b/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.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 WITH Qt-GPL-exception-1.0 #include <QTest> #include <QVariantAnimation> diff --git a/tests/auto/corelib/animation/qvariantanimation/tst_qvariantanimation.cpp b/tests/auto/corelib/animation/qvariantanimation/tst_qvariantanimation.cpp index cbb73296b4..2d8d674ba5 100644 --- a/tests/auto/corelib/animation/qvariantanimation/tst_qvariantanimation.cpp +++ b/tests/auto/corelib/animation/qvariantanimation/tst_qvariantanimation.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 WITH Qt-GPL-exception-1.0 #include <QtCore/qvariantanimation.h> diff --git a/tests/auto/corelib/global/q_func_info/tst_q_func_info.cpp b/tests/auto/corelib/global/q_func_info/tst_q_func_info.cpp index 9d6bc15d73..5320ba90c0 100644 --- a/tests/auto/corelib/global/q_func_info/tst_q_func_info.cpp +++ b/tests/auto/corelib/global/q_func_info/tst_q_func_info.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 WITH Qt-GPL-exception-1.0 #include <QString> diff --git a/tests/auto/corelib/global/qcompare/tst_qcompare.cpp b/tests/auto/corelib/global/qcompare/tst_qcompare.cpp index 61ea0eddc4..cc21bd9d14 100644 --- a/tests/auto/corelib/global/qcompare/tst_qcompare.cpp +++ b/tests/auto/corelib/global/qcompare/tst_qcompare.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2020 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** 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-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2020 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include <QtCore/QtCompare> #include <QtTest/QTest> diff --git a/tests/auto/corelib/global/qflags/CMakeLists.txt b/tests/auto/corelib/global/qflags/CMakeLists.txt index 998834d619..8ba02d93b4 100644 --- a/tests/auto/corelib/global/qflags/CMakeLists.txt +++ b/tests/auto/corelib/global/qflags/CMakeLists.txt @@ -1,5 +1,3 @@ -# Generated from qflags.pro. - ##################################################################### ## tst_qflags Test: ##################################################################### @@ -9,5 +7,9 @@ qt_internal_add_test(tst_qflags tst_qflags.cpp ) -## Scopes: -##################################################################### +qt_internal_add_test(tst_qflags_non_typesafe + SOURCES + tst_qflags.cpp + DEFINES + QFLAGS_TEST_NO_TYPESAFE_FLAGS +) diff --git a/tests/auto/corelib/global/qflags/tst_qflags.cpp b/tests/auto/corelib/global/qflags/tst_qflags.cpp index 3179cfc9d2..f267fc4497 100644 --- a/tests/auto/corelib/global/qflags/tst_qflags.cpp +++ b/tests/auto/corelib/global/qflags/tst_qflags.cpp @@ -1,38 +1,25 @@ -/**************************************************************************** -** -** Copyright (C) 2021 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$ -** -****************************************************************************/ -#include <QTest> +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#ifdef QFLAGS_TEST_NO_TYPESAFE_FLAGS +# ifdef QT_TYPESAFE_FLAGS +# undef QT_TYPESAFE_FLAGS +# endif +#else +# ifndef QT_TYPESAFE_FLAGS +# define QT_TYPESAFE_FLAGS +# endif +#endif -QT_WARNING_DISABLE_DEPRECATED +#include <QTest> class tst_QFlags: public QObject { Q_OBJECT private slots: + void boolCasts() const; + void operators() const; + void mixingDifferentEnums() const; void testFlag() const; void testFlagZeroFlag() const; void testFlagMultiBits() const; @@ -46,6 +33,105 @@ private slots: void adl(); }; +void tst_QFlags::boolCasts() const +{ + // This tests that the operator overloading is sufficient so that common + // idioms involving flags -> bool casts work as expected: + + const Qt::Alignment nonNull = Qt::AlignCenter; + const Qt::Alignment null = {}; + + // basic premiss: + QVERIFY(bool(nonNull)); + QVERIFY(!bool(null)); + + // The rest is just checking that stuff compiles: + + // QVERIFY should compile: + QVERIFY(nonNull); + QVERIFY(!null); + + // ifs should compile: + if (null) QFAIL("Can't contextually convert QFlags to bool!"); + if (!nonNull) QFAIL("Missing operator! on QFlags (shouldn't be necessary)."); + + // ternary should compile: + QVERIFY(nonNull ? true : false); + QVERIFY(!null ? true : false); + + // logical operators should compile: + QVERIFY(nonNull && true); + QVERIFY(nonNull || false); + QVERIFY(!null && true); + QVERIFY(!null || false); + + // ... in both directions: + QVERIFY(true && nonNull); + QVERIFY(false || nonNull); + QVERIFY(true && !null); + QVERIFY(false || !null); + + // ... and mixed: + QVERIFY(null || nonNull); + QVERIFY(!(null && nonNull)); +} + +void tst_QFlags::operators() const +{ +#define CHECK(op, LHS, RHS, RES) \ + do { \ + QCOMPARE((LHS op RHS), (RES)); \ + QCOMPARE(( /*CTAD*/ QFlags(LHS) op RHS), (RES)); \ + QCOMPARE((LHS op QFlags(RHS)), (RES)); \ + QCOMPARE((QFlags(LHS) op QFlags(RHS)), (RES)); \ + QCOMPARE((QFlags(LHS) op ## = RHS), (RES)); \ + QCOMPARE((QFlags(LHS) op ## = QFlags(RHS)), (RES)); \ + } while (false) + + CHECK(|, Qt::AlignHCenter, Qt::AlignVCenter, Qt::AlignCenter); + CHECK(|, Qt::AlignHCenter, Qt::AlignHCenter, Qt::AlignHCenter); + CHECK(&, Qt::AlignHCenter, Qt::AlignVCenter, Qt::Alignment()); + CHECK(&, Qt::AlignHCenter, Qt::AlignHCenter, Qt::AlignHCenter); + CHECK(^, Qt::AlignHCenter, Qt::AlignVCenter, Qt::AlignCenter); + CHECK(^, Qt::AlignHCenter, Qt::AlignHCenter, Qt::Alignment()); +#undef CHECK +} + +void tst_QFlags::mixingDifferentEnums() const +{ +#define CHECK(op, LHS, RHS, RES) \ + /* LHS must be QFlags'able */ \ + do { \ + QCOMPARE((LHS op RHS), (RES)); \ + QCOMPARE((RHS op LHS), (RES)); \ + /*QCOMPARE(( / *CTAD* / QFlags(LHS) op RHS), (RES));*/ \ + /*QCOMPARE((QFlags(LHS) op ## = RHS), (RES));*/ \ + } while (false) + + // AlignmentFlags <-> TextFlags + { + CHECK(|, Qt::AlignCenter, Qt::TextSingleLine, 0x0184); + CHECK(&, Qt::AlignCenter, Qt::TextSingleLine, 0x0000); + CHECK(^, Qt::AlignCenter, Qt::TextSingleLine, 0x0184); + } + // QFlags<AlignmentFlags> <-> TextFlags + { +#ifndef QT_TYPESAFE_FLAGS // QTBUG-101344 + Qt::Alignment MyAlignCenter = Qt::AlignCenter; // convert enum to QFlags + CHECK(|, MyAlignCenter, Qt::TextSingleLine, 0x0184U); // yes, unsigned! + CHECK(&, MyAlignCenter, Qt::TextSingleLine, 0x0000U); // yes, unsigned! + CHECK(^, MyAlignCenter, Qt::TextSingleLine, 0x0184U); // yes, unsigned! +#endif + } + // TextElideMode <-> TextFlags + { + CHECK(|, Qt::ElideNone, Qt::TextSingleLine, 0x0103); + CHECK(&, Qt::ElideNone, Qt::TextSingleLine, 0x0000); + CHECK(^, Qt::ElideNone, Qt::TextSingleLine, 0x0103); + } +#undef CHECK +} + void tst_QFlags::testFlag() const { Qt::MouseButtons btn = Qt::LeftButton | Qt::RightButton; @@ -150,6 +236,7 @@ void tst_QFlags::testAnyFlag() } template <unsigned int N, typename T> bool verifyConstExpr(T n) { return n == N; } +template <unsigned int N, typename T> bool verifyConstExpr(QFlags<T> n) { return n.toInt() == N; } constexpr Qt::MouseButtons testRelaxedConstExpr() { @@ -164,25 +251,32 @@ constexpr Qt::MouseButtons testRelaxedConstExpr() void tst_QFlags::constExpr() { Qt::MouseButtons btn = Qt::LeftButton | Qt::RightButton; - switch (btn) { + switch (btn.toInt()) { case Qt::LeftButton: QVERIFY(false); break; case Qt::RightButton: QVERIFY(false); break; - case int(Qt::LeftButton | Qt::RightButton): QVERIFY(true); break; - default: QFAIL(qPrintable(QStringLiteral("Unexpected button: %1").arg(btn))); + case (Qt::LeftButton | Qt::RightButton).toInt(): QVERIFY(true); break; + default: QFAIL(qPrintable(QStringLiteral("Unexpected button: %1").arg(btn.toInt()))); } - QVERIFY(verifyConstExpr<uint((Qt::LeftButton | Qt::RightButton) & Qt::LeftButton)>(Qt::LeftButton)); - QVERIFY(verifyConstExpr<uint((Qt::LeftButton | Qt::RightButton) & Qt::MiddleButton)>(0)); - QVERIFY(verifyConstExpr<uint((Qt::LeftButton | Qt::RightButton) | Qt::MiddleButton)>(Qt::LeftButton | Qt::RightButton | Qt::MiddleButton)); - QVERIFY(verifyConstExpr<uint(~(Qt::LeftButton | Qt::RightButton))>(~(Qt::LeftButton | Qt::RightButton))); - QVERIFY(verifyConstExpr<uint(Qt::MouseButtons(Qt::LeftButton) ^ Qt::RightButton)>(Qt::LeftButton ^ Qt::RightButton)); - QVERIFY(verifyConstExpr<uint(Qt::MouseButtons(0))>(0)); - QVERIFY(verifyConstExpr<uint(Qt::MouseButtons(Qt::RightButton) & 0xff)>(Qt::RightButton)); - QVERIFY(verifyConstExpr<uint(Qt::MouseButtons(Qt::RightButton) | 0xff)>(0xff)); +#define VERIFY_CONSTEXPR(expression, expected) \ + QVERIFY(verifyConstExpr<(expression).toInt()>(expected)) + + VERIFY_CONSTEXPR((Qt::LeftButton | Qt::RightButton) & Qt::LeftButton, Qt::LeftButton); + VERIFY_CONSTEXPR((Qt::LeftButton | Qt::RightButton) & Qt::MiddleButton, 0); + VERIFY_CONSTEXPR((Qt::LeftButton | Qt::RightButton) | Qt::MiddleButton, Qt::LeftButton | Qt::RightButton | Qt::MiddleButton); + VERIFY_CONSTEXPR(~(Qt::LeftButton | Qt::RightButton), ~(Qt::LeftButton | Qt::RightButton)); + VERIFY_CONSTEXPR(Qt::MouseButtons(Qt::LeftButton) ^ Qt::RightButton, Qt::LeftButton ^ Qt::RightButton); + VERIFY_CONSTEXPR(Qt::MouseButtons(0), 0); +#ifndef QT_TYPESAFE_FLAGS + QVERIFY(verifyConstExpr<(Qt::MouseButtons(Qt::RightButton) & 0xff)>(Qt::RightButton)); + QVERIFY(verifyConstExpr<(Qt::MouseButtons(Qt::RightButton) | 0xff)>(0xff)); +#endif QVERIFY(!verifyConstExpr<Qt::RightButton>(~Qt::MouseButtons(Qt::LeftButton))); - QVERIFY(verifyConstExpr<uint(testRelaxedConstExpr())>(Qt::MiddleButton)); + VERIFY_CONSTEXPR(testRelaxedConstExpr(), Qt::MiddleButton); + +#undef VERIFY_CONSTEXPR } void tst_QFlags::signedness() @@ -233,11 +327,14 @@ void tst_QFlags::classEnum() QVERIFY(!f0); +#ifndef QT_TYPESAFE_FLAGS QCOMPARE(f3 & int(1), 1); QCOMPARE(f3 & uint(1), 1); +#endif QCOMPARE(f3 & MyStrictEnum::StrictOne, 1); MyStrictFlags aux; +#ifndef QT_TYPESAFE_FLAGS aux = f3; aux &= int(1); QCOMPARE(aux, 1); @@ -245,6 +342,7 @@ void tst_QFlags::classEnum() aux = f3; aux &= uint(1); QCOMPARE(aux, 1); +#endif aux = f3; aux &= MyStrictEnum::StrictOne; diff --git a/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp b/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp index 35d7dbccf0..e61ceff1c0 100644 --- a/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp +++ b/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp @@ -1,31 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Copyright (C) 2016 by Southwest Research Institute (R) -** 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) 2021 The Qt Company Ltd. +// Copyright (C) 2016 by Southwest Research Institute (R) +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include <QTest> #include <QFloat16> @@ -213,13 +188,7 @@ void tst_qfloat16::qNaN() QVERIFY(qIsNaN(nan)); QVERIFY(qIsNaN(nan + one)); QVERIFY(qIsNaN(-nan)); -#ifdef Q_CC_INTEL - QEXPECT_FAIL("", "ICC optimizes zero * anything to zero", Continue); -#endif QVERIFY(qIsNaN(nan * zero)); -#ifdef Q_CC_INTEL - QEXPECT_FAIL("", "ICC optimizes zero * anything to zero", Continue); -#endif QVERIFY(qIsNaN(Bounds::infinity() * zero)); QVERIFY(!nan.isNormal()); @@ -540,14 +509,35 @@ void tst_qfloat16::properties() QVERIFY(Bounds::is_signed); QVERIFY(!Bounds::is_integer); QVERIFY(!Bounds::is_exact); + + // While we'd like to check for __STDC_IEC_559__, as per ISO/IEC 9899:2011 + // Annex F (C11, normative for C++11), there are a few corner cases regarding + // denormals where GHS compiler is relying hardware behavior that is not IEC + // 559 compliant. + + // On GHS the compiler reports std::numeric_limits<float>::is_iec559 as false. + // and the same supposed to be for qfloat16. +#if !defined(Q_CC_GHS) QVERIFY(Bounds::is_iec559); +#endif //Q_CC_GHS +#if QT_CONFIG(signaling_nan) + // Technically, presence of NaN and infinities are implied from the above check, but that checkings GHS compiler complies. + QVERIFY(Bounds::has_infinity && Bounds::has_quiet_NaN && Bounds::has_signaling_NaN); +#endif QVERIFY(Bounds::is_bounded); QVERIFY(!Bounds::is_modulo); QVERIFY(!Bounds::traps); QVERIFY(Bounds::has_infinity); QVERIFY(Bounds::has_quiet_NaN); +#if QT_CONFIG(signaling_nan) QVERIFY(Bounds::has_signaling_NaN); +#endif +#if !defined(Q_CC_GHS) QCOMPARE(Bounds::has_denorm, std::denorm_present); +#else + // For GHS compiler the "denorm_indeterminite" is the expected return value. + QCOMPARE(Bounds::has_denorm, std::denorm_indeterminate); +#endif // Q_CC_GHS QCOMPARE(Bounds::round_style, std::round_to_nearest); QCOMPARE(Bounds::radix, 2); // Untested: has_denorm_loss diff --git a/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp b/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp index 519c5fa88d..77a7fa4194 100644 --- a/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp +++ b/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp @@ -1,31 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Copyright (C) 2016 Intel Corporation. -** 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. +// Copyright (C) 2016 Intel Corporation. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include <qdebug.h> #include <QTest> diff --git a/tests/auto/corelib/global/qglobal/qglobal.c b/tests/auto/corelib/global/qglobal/qglobal.c index b577a6f71f..4d4f4475ea 100644 --- a/tests/auto/corelib/global/qglobal/qglobal.c +++ b/tests/auto/corelib/global/qglobal/qglobal.c @@ -1,42 +1,8 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Intel Corporation. -** 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) 2017 Intel Corporation. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include <QtCore/qglobal.h> -#if __has_include(<stdbool.h>) || __STDC_VERSION__ >= 199901L -# include <stdbool.h> -#else -# undef true -# define true 1 -# undef false -# define false 0 -#endif - #ifdef Q_COMPILER_THREAD_LOCAL # include <threads.h> #endif diff --git a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp index 7323cfe545..752fb948a5 100644 --- a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp +++ b/tests/auto/corelib/global/qglobal/tst_qglobal.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 WITH Qt-GPL-exception-1.0 #include <QTest> diff --git a/tests/auto/corelib/global/qglobalstatic/tst_qglobalstatic.cpp b/tests/auto/corelib/global/qglobalstatic/tst_qglobalstatic.cpp index 626c3757da..4c5d0da638 100644 --- a/tests/auto/corelib/global/qglobalstatic/tst_qglobalstatic.cpp +++ b/tests/auto/corelib/global/qglobalstatic/tst_qglobalstatic.cpp @@ -1,31 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Thiago Macieira <thiago@kde.org> -** Copyright (C) 2016 Intel Corporation. -** 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 Thiago Macieira <thiago@kde.org> +// Copyright (C) 2016 Intel Corporation. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include <QtCore/QThread> #include <QTest> @@ -148,7 +123,7 @@ void tst_QGlobalStatic::exception() exceptionCaught = true; } QVERIFY(exceptionCaught); - QCOMPARE(Q_QGS_throwingGS::guard.loadRelaxed(), 0); + QCOMPARE(QtGlobalStatic::Holder<Q_QGS_throwingGS>::guard.loadRelaxed(), 0); QVERIFY(!throwingGS.exists()); QVERIFY(!throwingGS.isDestroyed()); } @@ -206,7 +181,13 @@ void tst_QGlobalStatic::threadStressTest() if (expectedConstructionCount <= 0) QSKIP("This test cannot be run more than once"); +#ifdef Q_OS_INTEGRITY + // OPEN_REALTIME_THREADS = 123 on current INTEGRITY environment + // if try to create more, app is halted + const int numThreads = 122; +#else const int numThreads = 200; +#endif ThreadStressTestThread threads[numThreads]; QReadWriteLock lock; lock.lockForWrite(); diff --git a/tests/auto/corelib/global/qhooks/tst_qhooks.cpp b/tests/auto/corelib/global/qhooks/tst_qhooks.cpp index 5a24275177..26f628312b 100644 --- a/tests/auto/corelib/global/qhooks/tst_qhooks.cpp +++ b/tests/auto/corelib/global/qhooks/tst_qhooks.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Volker Krause <volker.krause@kdab.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtCore module 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 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Volker Krause <volker.krause@kdab.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include <QTest> diff --git a/tests/auto/corelib/global/qkeycombination/tst_qkeycombination.cpp b/tests/auto/corelib/global/qkeycombination/tst_qkeycombination.cpp index 7e70cdb70f..3091ed4129 100644 --- a/tests/auto/corelib/global/qkeycombination/tst_qkeycombination.cpp +++ b/tests/auto/corelib/global/qkeycombination/tst_qkeycombination.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2020 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> -** 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) 2020 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include <QObject> #include <QTest> diff --git a/tests/auto/corelib/global/qlogging/app/main.cpp b/tests/auto/corelib/global/qlogging/app/main.cpp index 4c26bb85e3..79d2dbcc92 100644 --- a/tests/auto/corelib/global/qlogging/app/main.cpp +++ b/tests/auto/corelib/global/qlogging/app/main.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 WITH Qt-GPL-exception-1.0 #include <QCoreApplication> #include <QLoggingCategory> diff --git a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp index af4a5989d8..5de7830113 100644 --- a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp +++ b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp @@ -1,31 +1,7 @@ -/**************************************************************************** -** -** Copyright (C) 2020 The Qt Company Ltd. -** Copyright (C) 2014 Olivier Goffart <ogoffart@woboq.com> -** 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) 2022 The Qt Company Ltd. +// Copyright (C) 2022 Intel Corporation. +// Copyright (C) 2014 Olivier Goffart <ogoffart@woboq.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include <qdebug.h> #include <qglobal.h> @@ -33,6 +9,8 @@ # include <QtCore/QProcess> #endif #include <QtTest/QTest> +#include <QList> +#include <QMap> class tst_qmessagehandler : public QObject { @@ -62,7 +40,10 @@ private slots: void formatLogMessage(); private: - QStringList m_baseEnvironment; + QString backtraceHelperPath(); +#if QT_CONFIG(process) + QProcessEnvironment m_baseEnvironment; +#endif }; static QtMsgType s_type; @@ -89,13 +70,9 @@ tst_qmessagehandler::tst_qmessagehandler() void tst_qmessagehandler::initTestCase() { #if QT_CONFIG(process) - m_baseEnvironment = QProcess::systemEnvironment(); - for (int i = 0; i < m_baseEnvironment.count(); ++i) { - if (m_baseEnvironment.at(i).startsWith("QT_MESSAGE_PATTERN=")) { - m_baseEnvironment.removeAt(i); - break; - } - } + m_baseEnvironment = QProcessEnvironment::systemEnvironment(); + m_baseEnvironment.remove("QT_MESSAGE_PATTERN"); + m_baseEnvironment.insert("QT_FORCE_STDERR_LOGGING", "1"); #endif // QT_CONFIG(process) } @@ -667,16 +644,16 @@ void tst_qmessagehandler::qMessagePattern_data() // %{file} is tricky because of shadow builds QTest::newRow("basic") << "%{type} %{appname} %{line} %{function} %{message}" << true << (QList<QByteArray>() - << "debug 39 T::T static constructor" + << "debug 14 T::T static constructor" // we can't be sure whether the QT_MESSAGE_PATTERN is already destructed << "static destructor" - << "debug tst_qlogging 60 MyClass::myFunction from_a_function 34" - << "debug tst_qlogging 70 main qDebug" - << "info tst_qlogging 71 main qInfo" - << "warning tst_qlogging 72 main qWarning" - << "critical tst_qlogging 73 main qCritical" - << "warning tst_qlogging 76 main qDebug with category" - << "debug tst_qlogging 80 main qDebug2"); + << "debug tst_qlogging 35 MyClass::myFunction from_a_function 34" + << "debug tst_qlogging 45 main qDebug" + << "info tst_qlogging 46 main qInfo" + << "warning tst_qlogging 47 main qWarning" + << "critical tst_qlogging 48 main qCritical" + << "warning tst_qlogging 51 main qDebug with category" + << "debug tst_qlogging 55 main qDebug2"); QTest::newRow("invalid") << "PREFIX: %{unknown} %{message}" << false << (QList<QByteArray>() @@ -777,18 +754,14 @@ void tst_qmessagehandler::qMessagePattern() QFETCH(QList<QByteArray>, expected); QProcess process; -#ifndef Q_OS_ANDROID - const QString appExe(QLatin1String(HELPER_BINARY)); -#else - const QString appExe(QCoreApplication::applicationDirPath() + QLatin1String("/lib" BACKTRACE_HELPER_NAME ".so")); -#endif + const QString appExe(backtraceHelperPath()); // // test QT_MESSAGE_PATTERN // - QStringList environment = m_baseEnvironment; - environment.prepend("QT_MESSAGE_PATTERN=\"" + pattern + QLatin1Char('"')); - process.setEnvironment(environment); + QProcessEnvironment environment = m_baseEnvironment; + environment.insert("QT_MESSAGE_PATTERN", pattern); + process.setProcessEnvironment(environment); process.start(appExe); QVERIFY2(process.waitForStarted(), qPrintable( @@ -803,13 +776,14 @@ void tst_qmessagehandler::qMessagePattern() for (const QByteArray &e : qAsConst(expected)) { if (!output.contains(e)) { - qDebug() << output; - qDebug() << "expected: " << e; - QVERIFY(output.contains(e)); + // use QDebug so we get proper string escaping for the newlines + QString buf; + QDebug(&buf) << "Got:" << output << "; Expected:" << e; + QVERIFY2(output.contains(e), qPrintable(buf)); } } if (pattern.startsWith("%{pid}")) - QVERIFY2(output.startsWith('"' + pid), "PID: " + pid + "\noutput:\n" + output); + QVERIFY2(output.startsWith(pid), "PID: " + pid + "\noutput:\n" + output); #endif } @@ -827,22 +801,10 @@ void tst_qmessagehandler::setMessagePattern() // QProcess process; -#ifndef Q_OS_ANDROID - const QString appExe(QLatin1String(HELPER_BINARY)); -#else - const QString appExe(QCoreApplication::applicationDirPath() + QLatin1String("/libhelper.so")); -#endif + const QString appExe(backtraceHelperPath()); // make sure there is no QT_MESSAGE_PATTERN in the environment - QStringList environment; - environment.reserve(m_baseEnvironment.size()); - const auto doesNotStartWith = [](QLatin1String s) { - return [s](const QString &str) { return !str.startsWith(s); }; - }; - std::copy_if(m_baseEnvironment.cbegin(), m_baseEnvironment.cend(), - std::back_inserter(environment), - doesNotStartWith(QLatin1String("QT_MESSAGE_PATTERN"))); - process.setEnvironment(environment); + process.setProcessEnvironment(m_baseEnvironment); process.start(appExe); QVERIFY2(process.waitForStarted(), qPrintable( @@ -928,6 +890,19 @@ void tst_qmessagehandler::formatLogMessage() QCOMPARE(r, result); } +QString tst_qmessagehandler::backtraceHelperPath() +{ +#ifdef Q_OS_ANDROID + QString appExe(QCoreApplication::applicationDirPath() + + QLatin1String("/lib" BACKTRACE_HELPER_NAME ".so")); +#elif defined(Q_OS_WEBOS) + QString appExe(QCoreApplication::applicationDirPath() + + QLatin1String("/" BACKTRACE_HELPER_NAME)); +#else + QString appExe(QLatin1String(HELPER_BINARY)); +#endif + return appExe; +} QTEST_MAIN(tst_qmessagehandler) #include "tst_qlogging.moc" diff --git a/tests/auto/corelib/global/qlogging/tst_qmessagelogger.cpp b/tests/auto/corelib/global/qlogging/tst_qmessagelogger.cpp index 4ff0469a49..4466c1b36b 100644 --- a/tests/auto/corelib/global/qlogging/tst_qmessagelogger.cpp +++ b/tests/auto/corelib/global/qlogging/tst_qmessagelogger.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2020 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) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include <qlogging.h> #include <qloggingcategory.h> diff --git a/tests/auto/corelib/global/qnativeinterface/tst_qnativeinterface.cpp b/tests/auto/corelib/global/qnativeinterface/tst_qnativeinterface.cpp index 5291133406..b7ec10df6c 100644 --- a/tests/auto/corelib/global/qnativeinterface/tst_qnativeinterface.cpp +++ b/tests/auto/corelib/global/qnativeinterface/tst_qnativeinterface.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2021 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) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include <QTest> diff --git a/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp b/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp index 5b54eeae01..03acf5c074 100644 --- a/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp +++ b/tests/auto/corelib/global/qnumeric/tst_qnumeric.cpp @@ -1,31 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Copyright (C) 2016 Intel Corporation. -** 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) 2022 The Qt Company Ltd. +// Copyright (C) 2016 Intel Corporation. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include <QTest> @@ -179,6 +154,15 @@ void tst_QNumeric::fuzzyIsNull() QCOMPARE(::qFuzzyIsNull(-value), isNull); } +static void clearFpExceptions() +{ + // Call after any functions that exercise floating-point exceptions, such as + // sqrt(-1) or log(0). +#ifdef Q_OS_WIN + _clearfp(); +#endif +} + #if defined __FAST_MATH__ && (__GNUC__ * 100 + __GNUC_MINOR__ >= 404) // turn -ffast-math off # pragma GCC optimize "no-fast-math" @@ -187,6 +171,7 @@ void tst_QNumeric::fuzzyIsNull() template<typename F> void tst_QNumeric::checkNaN(F nan) { + const auto cleanup = qScopeGuard([]() { clearFpExceptions(); }); #define CHECKNAN(value) \ do { \ const F v = (value); \ @@ -195,21 +180,23 @@ void tst_QNumeric::checkNaN(F nan) QVERIFY(!qIsFinite(v)); \ QVERIFY(!qIsInf(v)); \ } while (0) + const F zero(0), one(1), two(2); - QVERIFY(!(0 > nan)); - QVERIFY(!(0 < nan)); - QVERIFY(!(0 == nan)); + QVERIFY(!(zero > nan)); + QVERIFY(!(zero < nan)); + QVERIFY(!(zero == nan)); QVERIFY(!(nan == nan)); CHECKNAN(nan); - CHECKNAN(nan + 1); - CHECKNAN(nan - 1); + CHECKNAN(nan + one); + CHECKNAN(nan - one); CHECKNAN(-nan); - CHECKNAN(nan * 2.0); - CHECKNAN(nan / 2.0); - CHECKNAN(1.0 / nan); - CHECKNAN(0.0 / nan); - CHECKNAN(0.0 * nan); + CHECKNAN(nan * two); + CHECKNAN(nan / two); + CHECKNAN(one / nan); + CHECKNAN(zero / nan); + CHECKNAN(zero * nan); + CHECKNAN(sqrt(-one)); // When any NaN is expected, any NaN will do: QCOMPARE(nan, nan); @@ -297,6 +284,7 @@ void tst_QNumeric::generalNaN() template<typename F> void tst_QNumeric::infinity() { + const auto cleanup = qScopeGuard([]() { clearFpExceptions(); }); const F inf = qInf(); const F zero(0), one(1), two(2); QVERIFY(inf > zero); @@ -319,6 +307,7 @@ void tst_QNumeric::infinity() QCOMPARE(one / -inf, zero); QVERIFY(qIsNaN(zero * inf)); QVERIFY(qIsNaN(zero * -inf)); + QCOMPARE(log(zero), -inf); } template<typename F> @@ -402,9 +391,11 @@ void tst_QNumeric::distance() QFETCH(F, from); QFETCH(F, stop); QFETCH(Count, expectedDistance); -#ifdef Q_OS_QNX - QEXPECT_FAIL("denormal", "See QTBUG-37094", Continue); -#endif + if constexpr (std::numeric_limits<F>::has_denorm != std::denorm_present) { + if (qstrcmp(QTest::currentDataTag(), "denormal") == 0) { + QSKIP("Skipping 'denorm' as this type lacks denormals on this system"); + } + } QCOMPARE(qFloatDistance(from, stop), expectedDistance); QCOMPARE(qFloatDistance(stop, from), expectedDistance); } diff --git a/tests/auto/corelib/global/qoperatingsystemversion/tst_qoperatingsystemversion.cpp b/tests/auto/corelib/global/qoperatingsystemversion/tst_qoperatingsystemversion.cpp index d1f9279b57..9c602a459c 100644 --- a/tests/auto/corelib/global/qoperatingsystemversion/tst_qoperatingsystemversion.cpp +++ b/tests/auto/corelib/global/qoperatingsystemversion/tst_qoperatingsystemversion.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2020 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) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include <QTest> #include <qoperatingsystemversion.h> diff --git a/tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp b/tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp index 30e170b65d..a3b31eda3f 100644 --- a/tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp +++ b/tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Intel Corporation. -** 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) 2017 Intel Corporation. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include <QTest> #include <qlist.h> diff --git a/tests/auto/corelib/global/qtendian/tst_qtendian.cpp b/tests/auto/corelib/global/qtendian/tst_qtendian.cpp index 74c2deff52..7f13559067 100644 --- a/tests/auto/corelib/global/qtendian/tst_qtendian.cpp +++ b/tests/auto/corelib/global/qtendian/tst_qtendian.cpp @@ -1,40 +1,21 @@ -/**************************************************************************** -** -** Copyright (C) 2021 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) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include <QTest> #include <QtCore/qendian.h> #include <QtCore/private/qendian_p.h> - +#include <QtCore/qsysinfo.h> class tst_QtEndian: public QObject { Q_OBJECT +public: + enum Signedness { + Unsigned, + Signed + }; + Q_ENUM(Signedness); private slots: void fromBigEndian(); @@ -55,6 +36,9 @@ private slots: void endianIntegers(); void endianBitfields(); + + void endianBitfieldUnions_data(); + void endianBitfieldUnions(); }; struct TestData @@ -387,5 +371,100 @@ void tst_QtEndian::endianBitfields() QCOMPARE(u.bottom, -8); } +template<template<typename... Accessors> typename Union, template<int, int, typename> typename Member> +void testBitfieldUnion() +{ + using upper = Member<21, 11, uint>; + using lower = Member<10, 11, uint>; + using bottom = Member<0, 10, int>; + + using UnionType = Union<upper, lower, bottom>; + UnionType u; + + u.template set<upper>(200); + QCOMPARE(u.template get<upper>(), 200U); + u.template set<lower>(1000); + u.template set<bottom>(-8); + QCOMPARE(u.template get<lower>(), 1000U); + QCOMPARE(u.template get<upper>(), 200U); + + u.template set<lower>(u.template get<lower>() + u.template get<upper>()); + QCOMPARE(u.template get<upper>(), 200U); + QCOMPARE(u.template get<lower>(), 1200U); + + u.template set<upper>(65536 + 7); + u.template set<lower>(65535); + QCOMPARE(u.template get<lower>(), 65535U & ((1<<11) - 1)); + QCOMPARE(u.template get<upper>(), 7U); + + QCOMPARE(u.template get<bottom>(), -8); + + UnionType u2(QSpecialIntegerBitfieldZero); + QCOMPARE(u2.data(), 0U); + + UnionType u3(42U); + QCOMPARE(u3.data(), 42U); + + using BEUintAccessor = QSpecialIntegerAccessor<QBigEndianStorageType<uint>, 21, 11>; + using LEUintAccessor = QSpecialIntegerAccessor<QLittleEndianStorageType<uint>, 21, 11>; + using BEIntAccessor = QSpecialIntegerAccessor<QBigEndianStorageType<int>, 0, 10>; + using LEIntAccessor = QSpecialIntegerAccessor<QLittleEndianStorageType<int>, 0, 10>; + + if constexpr (std::is_same_v<BEUintAccessor, upper>) { + QCOMPARE(u.template get<BEUintAccessor>(), 7U); + } else if constexpr (std::is_same_v<LEUintAccessor, upper>) { + QCOMPARE(u.template get<LEUintAccessor>(), 7U); + } else if constexpr (std::is_same_v<BEIntAccessor, bottom>) { + QCOMPARE(u.template get<BEIntAccessor>(), -8); + } else if constexpr (std::is_same_v<LEIntAccessor, bottom>) { + QCOMPARE(u.template get<LEIntAccessor>(), -8); + } else { + QFAIL("none of the manually defined accessors match"); + } +} + +void tst_QtEndian::endianBitfieldUnions_data() +{ + QTest::addColumn<QSysInfo::Endian>("byteOrder"); + QTest::addColumn<Signedness>("signedness"); + + QTest::addRow("little endian unsigned") << QSysInfo::LittleEndian << Unsigned; + QTest::addRow("little endian signed") << QSysInfo::LittleEndian << Signed; + QTest::addRow("big endian unsigned") << QSysInfo::BigEndian << Unsigned; + QTest::addRow("big endian signed") << QSysInfo::BigEndian << Signed; +} + +void tst_QtEndian::endianBitfieldUnions() +{ + QFETCH(QSysInfo::Endian, byteOrder); + QFETCH(Signedness, signedness); + + switch (byteOrder) { + case QSysInfo::LittleEndian: + switch (signedness) { + case Unsigned: + testBitfieldUnion<quint32_le_bitfield_union, quint32_le_bitfield_member>(); + return; + case Signed: + testBitfieldUnion<qint32_le_bitfield_union, qint32_le_bitfield_member>(); + return; + } + Q_UNREACHABLE(); + return; + case QSysInfo::BigEndian: + switch (signedness) { + case Unsigned: + testBitfieldUnion<quint32_be_bitfield_union, quint32_be_bitfield_member>(); + return; + case Signed: + testBitfieldUnion<qint32_be_bitfield_union, qint32_be_bitfield_member>(); + return; + } + Q_UNREACHABLE(); + return; + } +} + + QTEST_MAIN(tst_QtEndian) #include "tst_qtendian.moc" diff --git a/tests/auto/corelib/global/qwinregistry/tst_qwinregistry.cpp b/tests/auto/corelib/global/qwinregistry/tst_qwinregistry.cpp index c73a0a7575..423c4ebc82 100644 --- a/tests/auto/corelib/global/qwinregistry/tst_qwinregistry.cpp +++ b/tests/auto/corelib/global/qwinregistry/tst_qwinregistry.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2019 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) 2019 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include <QTest> diff --git a/tests/auto/corelib/io/CMakeLists.txt b/tests/auto/corelib/io/CMakeLists.txt index a519a47956..f4cfc16f06 100644 --- a/tests/auto/corelib/io/CMakeLists.txt +++ b/tests/auto/corelib/io/CMakeLists.txt @@ -1,4 +1,8 @@ # Generated from io.pro. +# There is no mounted filesystem for IO testing on INTEGRITY yet. +if(INTEGRITY) + return() +endif() if(QT_FEATURE_private_tests) add_subdirectory(qabstractfileengine) @@ -18,7 +22,9 @@ add_subdirectory(qloggingcategory) add_subdirectory(qnodebug) add_subdirectory(qsavefile) add_subdirectory(qstandardpaths) -add_subdirectory(qstorageinfo) +if(NOT QNX) + add_subdirectory(qstorageinfo) +endif() add_subdirectory(qtemporarydir) add_subdirectory(qtemporaryfile) add_subdirectory(qurlquery) diff --git a/tests/auto/corelib/io/largefile/tst_largefile.cpp b/tests/auto/corelib/io/largefile/tst_largefile.cpp index d05c5bca9f..a9108c577f 100644 --- a/tests/auto/corelib/io/largefile/tst_largefile.cpp +++ b/tests/auto/corelib/io/largefile/tst_largefile.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 WITH Qt-GPL-exception-1.0 #include <QTest> @@ -62,12 +37,17 @@ public: , fd_(-1) , stream_(0) { - #if defined(QT_LARGEFILE_SUPPORT) && !defined(Q_OS_MAC) + #if defined(QT_LARGEFILE_SUPPORT) && !defined(Q_OS_MAC) && !defined(Q_OS_QNX) maxSizeBits = 36; // 64 GiB #elif defined(Q_OS_MAC) // HFS+ does not support sparse files, so we limit file size for the test // on Mac OS. maxSizeBits = 24; // 16 MiB + #elif defined(Q_OS_QNX) + // Many of the filesystems that QNX supports use a 32-bit format. + // This means that files are limited to 2 GB − 1 bytes. + // Limit max size to 256MB + maxSizeBits = 28; // 256 MiB #else maxSizeBits = 24; // 16 MiB #endif diff --git a/tests/auto/corelib/io/qabstractfileengine/qabstractfileengine.qrc b/tests/auto/corelib/io/qabstractfileengine/qabstractfileengine.qrc deleted file mode 100644 index 5401b086b2..0000000000 --- a/tests/auto/corelib/io/qabstractfileengine/qabstractfileengine.qrc +++ /dev/null @@ -1,5 +0,0 @@ -<!DOCTYPE RCC><RCC version="1.0"> -<qresource prefix="/tst_qabstractfileengine/"> - <file>resources/</file> -</qresource> -</RCC> diff --git a/tests/auto/corelib/io/qabstractfileengine/tst_qabstractfileengine.cpp b/tests/auto/corelib/io/qabstractfileengine/tst_qabstractfileengine.cpp index fc55208bbb..8f91ebe136 100644 --- a/tests/auto/corelib/io/qabstractfileengine/tst_qabstractfileengine.cpp +++ b/tests/auto/corelib/io/qabstractfileengine/tst_qabstractfileengine.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the FOO module 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 WITH Qt-GPL-exception-1.0 #include <QtCore/private/qabstractfileengine_p.h> #include <QtCore/private/qfsfileengine_p.h> @@ -76,8 +51,10 @@ public: { } - bool open(QIODevice::OpenMode openMode) override + bool open(QIODevice::OpenMode openMode, std::optional<QFile::Permissions> permissions) override { + Q_UNUSED(permissions); + if (openForRead_ || openForWrite_) { qWarning("%s: file is already open for %s", Q_FUNC_INFO, diff --git a/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp b/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp index 7a68da8192..93e0d6fce8 100644 --- a/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp +++ b/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp @@ -1,36 +1,14 @@ -/**************************************************************************** -** -** 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 WITH Qt-GPL-exception-1.0 #include <QTest> #include <QTestEventLoop> #include <QBuffer> #include <QByteArray> +#include <QElapsedTimer> + +#include <string> class tst_QBuffer : public QObject { @@ -43,6 +21,7 @@ private slots: void writeBlock_data(); void writeBlock(); void seek(); + void invalidSeeks(); void seekTest_data(); void seekTest(); void read_rawdata(); @@ -58,6 +37,7 @@ private slots: void readLineBoundaries(); void getAndUngetChar(); void writeAfterQByteArrayResize(); + void writeOfMoreThan2GiB(); void read_null(); protected slots: @@ -287,6 +267,29 @@ void tst_QBuffer::seek() QCOMPARE(buffer.size(), pos); } +void tst_QBuffer::invalidSeeks() +{ + if constexpr (sizeof(qsizetype) == sizeof(qint64)) { + // sizeof(qsizetype) == sizeof(qint64), so +1 would overflow + QSKIP("This is a 32-bit-only test."); + } else { + QBuffer buffer; + buffer.open(QIODevice::WriteOnly); + QCOMPARE(buffer.buffer().size(), qsizetype(0)); + QCOMPARE(buffer.pos(), qint64(0)); + constexpr qint64 MaxQByteArrayCapacity = (std::numeric_limits<qsizetype>::max)(); + // this should fail fast, not after trying to allocate nearly 2 GiB of data, + // potentially crashing in the process: + QVERIFY(!buffer.seek(2 * MaxQByteArrayCapacity - 1)); + QCOMPARE(buffer.buffer().size(), qsizetype(0)); + QCOMPARE(buffer.pos(), qint64(0)); + // ditto: + QVERIFY(!buffer.seek(MaxQByteArrayCapacity + 1)); + QCOMPARE(buffer.buffer().size(), qsizetype(0)); + QCOMPARE(buffer.pos(), qint64(0)); + } +} + void tst_QBuffer::seekTest_data() { writeBlock_data(); @@ -599,6 +602,55 @@ void tst_QBuffer::writeAfterQByteArrayResize() QCOMPARE(buffer.buffer().size(), 1000); } +void tst_QBuffer::writeOfMoreThan2GiB() +{ + if constexpr (sizeof(void*) == 4) + QSKIP("This is a 64-bit-only test"); + + [[maybe_unused]] constexpr size_t GiB = 1024 * 1024 * 1024; + +#ifndef QT_NO_EXCEPTIONS + + try { + // + // GIVEN: an empty QBuffer open for writing + // + QBuffer buffer; + QVERIFY(buffer.open(QIODevice::WriteOnly)); + + // + // WHEN: writing more than 2GiB in a singe chunk: + // + QElapsedTimer timer; + timer.start(); + + const std::string input(2 * GiB + 1, 42); + + qDebug("created dataset in %lld ms", timer.restart()); + + const auto inputSize = qint64(input.size()); + + QCOMPARE(buffer.write(input.data(), inputSize), inputSize); + + qDebug("performed write in %lld ms", timer.restart()); + + // + // THEN: the buffer contains the written data + // + QCOMPARE(buffer.buffer().size(), inputSize); + QVERIFY(buffer.buffer() == QByteArrayView{input}); + + qDebug("verified result in %lld ms", timer.elapsed()); + + } catch (const std::bad_alloc &) { + QSKIP("Cannot allocate enough memory for this test"); + } + +#else + QSKIP("This test requires exceptions enabled."); +#endif // QT_NO_EXCEPTIONS +} + void tst_QBuffer::read_null() { QByteArray buffer; diff --git a/tests/auto/corelib/io/qdataurl/tst_qdataurl.cpp b/tests/auto/corelib/io/qdataurl/tst_qdataurl.cpp index 9be0463b99..8cc1b0ae54 100644 --- a/tests/auto/corelib/io/qdataurl/tst_qdataurl.cpp +++ b/tests/auto/corelib/io/qdataurl/tst_qdataurl.cpp @@ -1,77 +1,58 @@ -/**************************************************************************** -** -** 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 WITH Qt-GPL-exception-1.0 #include "private/qdataurl_p.h" #include <QTest> #include <QtCore/QDebug> +using namespace Qt::Literals; + class tst_QDataUrl : public QObject { Q_OBJECT private slots: - void nonData(); - void emptyData(); - void alreadyPercentageEncoded(); + void decode_data(); + void decode(); }; -void tst_QDataUrl::nonData() +void tst_QDataUrl::decode_data() { - QLatin1String data("http://test.com"); - QUrl url(data); - QString mimeType; - QByteArray payload; - bool result = qDecodeDataUrl(url, mimeType, payload); - QVERIFY(!result); -} + QTest::addColumn<QString>("input"); + QTest::addColumn<bool>("result"); + QTest::addColumn<QString>("mimeType"); + QTest::addColumn<QByteArray>("payload"); -void tst_QDataUrl::emptyData() -{ - QLatin1String data("data:text/plain"); - QUrl url(data); - QString mimeType; - QByteArray payload; - bool result = qDecodeDataUrl(url, mimeType, payload); - QVERIFY(result); - QCOMPARE(mimeType, QLatin1String("text/plain;charset=US-ASCII")); - QVERIFY(payload.isNull()); + auto row = [](const char *tag, const char *url, bool success, QString mimeType = {}, QByteArray payload = {}) { + QTest::newRow(tag) << url << success <<mimeType << payload; + }; + + row("nonData", "http://test.com", false); + row("emptyData", "data:text/plain", true, + "text/plain;charset=US-ASCII"_L1); + row("alreadyPercentageEncoded", "data:text/plain,%E2%88%9A", true, + "text/plain"_L1, QByteArray::fromPercentEncoding("%E2%88%9A")); + row("everythingIsCaseInsensitive", "Data:texT/PlaiN;charSet=iSo-8859-1;Base64,SGVsbG8=", true, + "texT/PlaiN;charSet=iSo-8859-1"_L1, QByteArrayLiteral("Hello")); } -void tst_QDataUrl::alreadyPercentageEncoded() +void tst_QDataUrl::decode() { - QLatin1String data("data:text/plain,%E2%88%9A"); - QUrl url(data); - QString mimeType; - QByteArray payload; - bool result = qDecodeDataUrl(url, mimeType, payload); - QVERIFY(result); - QCOMPARE(mimeType, QLatin1String("text/plain")); - QCOMPARE(payload, QByteArray::fromPercentEncoding("%E2%88%9A")); + QFETCH(const QString, input); + QFETCH(const bool, result); + QFETCH(const QString, mimeType); + QFETCH(const QByteArray, payload); + + QString actualMimeType; + QByteArray actualPayload; + + QUrl url(input); + const bool actualResult = qDecodeDataUrl(url, actualMimeType, actualPayload); + + QCOMPARE(actualResult, result); + QCOMPARE(actualMimeType, mimeType); + QCOMPARE(actualPayload, payload); + QCOMPARE(actualPayload.isNull(), payload.isNull()); // assume nullness is significant } QTEST_MAIN(tst_QDataUrl) diff --git a/tests/auto/corelib/io/qdebug/CMakeLists.txt b/tests/auto/corelib/io/qdebug/CMakeLists.txt index 39b92b9d2f..067e3be04b 100644 --- a/tests/auto/corelib/io/qdebug/CMakeLists.txt +++ b/tests/auto/corelib/io/qdebug/CMakeLists.txt @@ -10,3 +10,7 @@ qt_internal_add_test(tst_qdebug PUBLIC_LIBRARIES Qt::Concurrent ) + +if (APPLE) + target_compile_options(tst_qdebug PRIVATE -x objective-c++) +endif() diff --git a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp index 9b9696d7c1..400625ba7d 100644 --- a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp +++ b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp @@ -1,31 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Copyright (C) 2016 Intel Corporation. -** 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. +// Copyright (C) 2016 Intel Corporation. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include <QtCore/QCoreApplication> @@ -52,6 +27,10 @@ struct ConvertsToQVariant { }; static_assert(!QTypeTraits::has_ostream_operator_v<QDebug, ConvertsToQVariant>); +#if defined(Q_OS_DARWIN) +#include <objc/runtime.h> +#include <Foundation/Foundation.h> +#endif class tst_QDebug: public QObject { @@ -88,6 +67,12 @@ private slots: void threadSafety() const; void toString() const; void noQVariantEndlessRecursion() const; +#if defined(Q_OS_DARWIN) + void objcInCppMode_data() const; + void objcInCppMode() const; + void objcInObjcMode_data() const; + void objcInObjcMode() const; +#endif }; void tst_QDebug::assignment() const @@ -873,6 +858,69 @@ void tst_QDebug::noQVariantEndlessRecursion() const qDebug() << var; } +#if defined(Q_OS_DARWIN) + +@interface MyObjcClass : NSObject +@end + +@implementation MyObjcClass : NSObject +- (NSString *)description +{ + return @"MyObjcClass is the best"; +} +@end + +void tst_QDebug::objcInCppMode_data() const +{ + QTest::addColumn<objc_object *>("object"); + QTest::addColumn<QString>("message"); + + QTest::newRow("nil") << static_cast<objc_object*>(nullptr) << QString::fromLatin1("(null)"); + + // Not an NSObject subclass + auto *nsproxy = reinterpret_cast<objc_object *>(class_createInstance(objc_getClass("NSProxy"), 0)); + QTest::newRow("NSProxy") << nsproxy << QString::fromLatin1("<NSProxy: 0x%1>").arg(uintptr_t(nsproxy), 1, 16); + + // Plain NSObject + auto *nsobject = reinterpret_cast<objc_object *>(class_createInstance(objc_getClass("NSObject"), 0)); + QTest::newRow("NSObject") << nsobject << QString::fromLatin1("<NSObject: 0x%1>").arg(uintptr_t(nsobject), 1, 16); + + auto str = QString::fromLatin1("foo"); + QTest::newRow("NSString") << reinterpret_cast<objc_object*>(str.toNSString()) << str; + + // Custom debug description + QTest::newRow("MyObjcClass") << reinterpret_cast<objc_object*>([[MyObjcClass alloc] init]) + << QString::fromLatin1("MyObjcClass is the best"); +} + +void tst_QDebug::objcInCppMode() const +{ + QFETCH(objc_object *, object); + QFETCH(QString, message); + + MessageHandlerSetter mhs(myMessageHandler); + { qDebug() << object; } + + QCOMPARE(s_msg, message); +} + +void tst_QDebug::objcInObjcMode_data() const +{ + objcInCppMode_data(); +} + +void tst_QDebug::objcInObjcMode() const +{ + QFETCH(objc_object *, object); + QFETCH(QString, message); + + MessageHandlerSetter mhs(myMessageHandler); + { qDebug() << static_cast<id>(object); } + + QCOMPARE(s_msg, message); +} +#endif + // Should compile: instentiation of unrelated operator<< should not cause cause compilation // error in QDebug operators (QTBUG-47375) class TestClassA {}; diff --git a/tests/auto/corelib/io/qdir/qdir.qrc b/tests/auto/corelib/io/qdir/qdir.qrc deleted file mode 100644 index 4c5b5af3b8..0000000000 --- a/tests/auto/corelib/io/qdir/qdir.qrc +++ /dev/null @@ -1,5 +0,0 @@ -<!DOCTYPE RCC><RCC version="1.0"> -<qresource prefix="/tst_qdir/"> - <file>resources/entryList/</file> -</qresource> -</RCC> diff --git a/tests/auto/corelib/io/qdir/testdir/dir/qrc_qdir.cpp b/tests/auto/corelib/io/qdir/testdir/dir/qrc_qdir.cpp index a1d5c2c9ff..cf4421c7d5 100644 --- a/tests/auto/corelib/io/qdir/testdir/dir/qrc_qdir.cpp +++ b/tests/auto/corelib/io/qdir/testdir/dir/qrc_qdir.cpp @@ -1,29 +1,4 @@ -/**************************************************************************** -** -** 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 WITH Qt-GPL-exception-1.0 diff --git a/tests/auto/corelib/io/qdir/testdir/dir/tst_qdir.cpp b/tests/auto/corelib/io/qdir/testdir/dir/tst_qdir.cpp index a1d5c2c9ff..cf4421c7d5 100644 --- a/tests/auto/corelib/io/qdir/testdir/dir/tst_qdir.cpp +++ b/tests/auto/corelib/io/qdir/testdir/dir/tst_qdir.cpp @@ -1,29 +1,4 @@ -/**************************************************************************** -** -** 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 WITH Qt-GPL-exception-1.0 diff --git a/tests/auto/corelib/io/qdir/tst_qdir.cpp b/tests/auto/corelib/io/qdir/tst_qdir.cpp index 9682bec34e..cfc786b292 100644 --- a/tests/auto/corelib/io/qdir/tst_qdir.cpp +++ b/tests/auto/corelib/io/qdir/tst_qdir.cpp @@ -1,31 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Copyright (C) 2017 Intel Corporation. -** 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) 2021 The Qt Company Ltd. +// Copyright (C) 2017 Intel Corporation. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include <QTest> #include <QTemporaryFile> @@ -75,6 +50,8 @@ extern Q_CORE_EXPORT int qt_ntfs_permission_lookup; #include "private/qdir_p.h" #endif +using namespace Qt::StringLiterals; + static QByteArray msgDoesNotExist(const QString &name) { return (QLatin1Char('"') + QDir::toNativeSeparators(name) @@ -451,6 +428,9 @@ void tst_QDir::mkdirOnSymlink() path = "two/four/five"; fi.setFile(path); +#if defined(Q_OS_QNX) + QSKIP("Fails on QNX QTBUG-98561"); +#endif QVERIFY2(fi.exists() && fi.isDir(), msgDoesNotExist(path).constData()); #endif } @@ -487,7 +467,7 @@ void tst_QDir::mkdirWithPermissions() QFile::ReadOwner, QFile::WriteOwner, QFile::ExeOwner }; - const QString path = u"tmpdir"_qs; + const QString path = u"tmpdir"_s; QDir dir; auto deleteDirectory = qScopeGuard([&dir, &path] { dir.rmdir(path); }); @@ -1329,19 +1309,19 @@ tst_QDir::cleanPath_data() QTest::newRow("unc-server-up") << "//server/path/.." << "//server"; QTest::newRow("unc-server-above-root") << "//server/.." << "//server/.."; - QTest::newRow("longpath") << uR"(\\?\d:\)"_qs << u"d:/"_qs; - QTest::newRow("longpath-slash") << u"//?/d:/"_qs << u"d:/"_qs; - QTest::newRow("longpath-mixed-slashes") << uR"(//?/d:\)"_qs << u"d:/"_qs; - QTest::newRow("longpath-mixed-slashes-2") << uR"(\\?\d:/)"_qs << u"d:/"_qs; - - QTest::newRow("unc-network-share") << uR"(\\?\UNC\localhost\c$\tmp.txt)"_qs - << u"//localhost/c$/tmp.txt"_qs; - QTest::newRow("unc-network-share-slash") << u"//?/UNC/localhost/c$/tmp.txt"_qs - << u"//localhost/c$/tmp.txt"_qs; - QTest::newRow("unc-network-share-mixed-slashes") << uR"(//?/UNC/localhost\c$\tmp.txt)"_qs - << u"//localhost/c$/tmp.txt"_qs; - QTest::newRow("unc-network-share-mixed-slashes-2") << uR"(\\?\UNC\localhost/c$/tmp.txt)"_qs - << u"//localhost/c$/tmp.txt"_qs; + QTest::newRow("longpath") << uR"(\\?\d:\)"_s << u"d:/"_s; + QTest::newRow("longpath-slash") << u"//?/d:/"_s << u"d:/"_s; + QTest::newRow("longpath-mixed-slashes") << uR"(//?/d:\)"_s << u"d:/"_s; + QTest::newRow("longpath-mixed-slashes-2") << uR"(\\?\d:/)"_s << u"d:/"_s; + + QTest::newRow("unc-network-share") << uR"(\\?\UNC\localhost\c$\tmp.txt)"_s + << u"//localhost/c$/tmp.txt"_s; + QTest::newRow("unc-network-share-slash") << u"//?/UNC/localhost/c$/tmp.txt"_s + << u"//localhost/c$/tmp.txt"_s; + QTest::newRow("unc-network-share-mixed-slashes") << uR"(//?/UNC/localhost\c$\tmp.txt)"_s + << u"//localhost/c$/tmp.txt"_s; + QTest::newRow("unc-network-share-mixed-slashes-2") << uR"(\\?\UNC\localhost/c$/tmp.txt)"_s + << u"//localhost/c$/tmp.txt"_s; #else QTest::newRow("data15") << "//c:/foo" << "/c:/foo"; #endif // non-windows @@ -1740,9 +1720,9 @@ void tst_QDir::dotAndDotDot() { QDir dir(QString((m_dataPath + "/testdir/"))); QStringList entryList = dir.entryList(QDir::Dirs); - QCOMPARE(entryList, QStringList({ u"."_qs, u".."_qs, u"dir"_qs, u"dir.lnk"_qs, u"spaces"_qs })); + QCOMPARE(entryList, QStringList({ u"."_s, u".."_s, u"dir"_s, u"dir.lnk"_s, u"spaces"_s })); entryList = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); - QCOMPARE(entryList, QStringList({ u"dir"_qs, u"dir.lnk"_qs, u"spaces"_qs })); + QCOMPARE(entryList, QStringList({ u"dir"_s, u"dir.lnk"_s, u"spaces"_s })); } void tst_QDir::homePath() @@ -1817,10 +1797,10 @@ void tst_QDir::nativeSeparators() QCOMPARE(QDir::fromNativeSeparators(QLatin1String("/")), QString("/")); QCOMPARE(QDir::fromNativeSeparators(QLatin1String("\\")), QString("/")); QCOMPARE(QDir::fromNativeSeparators(QLatin1String("\\\\?\\C:\\")), QString("C:/")); - QCOMPARE(QDir::fromNativeSeparators(uR"(\\?\UNC\localhost\c$\tmp.txt)"_qs), - u"//localhost/c$/tmp.txt"_qs); - QCOMPARE(QDir::fromNativeSeparators(uR"(//?/UNC/localhost\c$\tmp.txt)"_qs), - u"//localhost/c$/tmp.txt"_qs); + QCOMPARE(QDir::fromNativeSeparators(uR"(\\?\UNC\localhost\c$\tmp.txt)"_s), + u"//localhost/c$/tmp.txt"_s); + QCOMPARE(QDir::fromNativeSeparators(uR"(//?/UNC/localhost\c$\tmp.txt)"_s), + u"//localhost/c$/tmp.txt"_s); #else QCOMPARE(QDir::toNativeSeparators(QLatin1String("/")), QString("/")); QCOMPARE(QDir::toNativeSeparators(QLatin1String("\\")), QString("\\")); diff --git a/tests/auto/corelib/io/qdiriterator/qdiriterator.qrc b/tests/auto/corelib/io/qdiriterator/qdiriterator.qrc deleted file mode 100644 index af9998bdb4..0000000000 --- a/tests/auto/corelib/io/qdiriterator/qdiriterator.qrc +++ /dev/null @@ -1,6 +0,0 @@ -<!DOCTYPE RCC><RCC version="1.0"> -<qresource prefix="/testdata/"> - <file>entrylist/file</file> - <file>entrylist/directory/dummy</file> -</qresource> -</RCC> diff --git a/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp b/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp index 9761fbcfb3..628f1acad6 100644 --- a/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp +++ b/tests/auto/corelib/io/qdiriterator/tst_qdiriterator.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2021 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) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include <QTest> @@ -34,6 +9,8 @@ #include <qdiriterator.h> #include <qfileinfo.h> #include <qstringlist.h> +#include <QSet> +#include <QString> #include <QtCore/private/qfsfileengine_p.h> diff --git a/tests/auto/corelib/io/qfile/qfile.qrc b/tests/auto/corelib/io/qfile/qfile.qrc deleted file mode 100644 index 2c63d8afeb..0000000000 --- a/tests/auto/corelib/io/qfile/qfile.qrc +++ /dev/null @@ -1,5 +0,0 @@ -<!DOCTYPE RCC><RCC version="1.0"> -<qresource prefix="/tst_qfileinfo/"> - <file>resources/</file> -</qresource> -</RCC> diff --git a/tests/auto/corelib/io/qfile/stdinprocess/main.cpp b/tests/auto/corelib/io/qfile/stdinprocess/main.cpp index 77a1932bd5..1adde71921 100644 --- a/tests/auto/corelib/io/qfile/stdinprocess/main.cpp +++ b/tests/auto/corelib/io/qfile/stdinprocess/main.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 WITH Qt-GPL-exception-1.0 #include <QtCore/QCoreApplication> diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp index afcd2c2a7e..0d7b2a4079 100644 --- a/tests/auto/corelib/io/qfile/tst_qfile.cpp +++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp @@ -1,31 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Copyright (C) 2021 Intel Corporation. -** 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) 2021 The Qt Company Ltd. +// Copyright (C) 2021 Intel Corporation. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #define _CRT_SECURE_NO_WARNINGS 1 @@ -119,6 +94,8 @@ QT_END_NAMESPACE #define QT_OPEN_BINARY 0 #endif +using namespace Qt::StringLiterals; + Q_DECLARE_METATYPE(QFile::FileError) @@ -183,6 +160,8 @@ private slots: void ungetChar(); void createFile(); void createFileNewOnly(); + void createFilePermissions_data(); + void createFilePermissions(); void openFileExistingOnly(); void append(); void permissions_data(); @@ -1268,6 +1247,56 @@ void tst_QFile::createFileNewOnly() QFile::remove("createme.txt"); } +void tst_QFile::createFilePermissions_data() +{ + QTest::addColumn<QFile::Permissions>("permissions"); + + for (int u = 0; u < 8; ++u) { + for (int g = 0; g < 8; ++g) { + for (int o = 0; o < 8; ++o) { + auto permissions = QFileDevice::Permissions::fromInt((u << 12) | (g << 4) | o); + QTest::addRow("%04x", permissions.toInt()) << permissions; + } + } + } +} + +void tst_QFile::createFilePermissions() +{ + QFETCH(QFile::Permissions, permissions); + +#ifdef Q_OS_WIN + QScopedValueRollback<int> ntfsMode(qt_ntfs_permission_lookup); + ++qt_ntfs_permission_lookup; +#endif +#ifdef Q_OS_UNIX + auto restoreMask = qScopeGuard([oldMask = umask(0)] { umask(oldMask); }); +#endif + + const QFile::Permissions setPermissions = { + QFile::ReadOther, QFile::WriteOther, QFile::ExeOther, + QFile::ReadGroup, QFile::WriteGroup, QFile::ExeGroup, + QFile::ReadOwner, QFile::WriteOwner, QFile::ExeOwner + }; + + const QString fileName = u"createme.txt"_s; + + QFile::remove(fileName); + QVERIFY(!QFile::exists(fileName)); + + QFile f(fileName); + auto removeFile = qScopeGuard([&f] { + f.close(); + f.remove(); + }); + QVERIFY2(f.open(QIODevice::WriteOnly, permissions), msgOpenFailed(f).constData()); + + QVERIFY(QFile::exists(fileName)); + + auto actualPermissions = QFileInfo(fileName).permissions(); + QCOMPARE(actualPermissions & setPermissions, permissions); +} + void tst_QFile::openFileExistingOnly() { QFile::remove("dontcreateme.txt"); @@ -2883,7 +2912,7 @@ void tst_QFile::handle() // test if the QFile and the handle remain in sync QVERIFY(file.getChar(&c)); - QCOMPARE(c, '*'); + QCOMPARE(c, '/'); // same, but read from QFile first now file.close(); @@ -2898,7 +2927,7 @@ void tst_QFile::handle() QCOMPARE(QT_READ(fd, &c, 1), 1); #endif - QCOMPARE(c, '*'); + QCOMPARE(c, '/'); //test round trip of adopted stdio file handle QFile file2; diff --git a/tests/auto/corelib/io/qfileinfo/CMakeLists.txt b/tests/auto/corelib/io/qfileinfo/CMakeLists.txt index da955ff6a6..8b015d518c 100644 --- a/tests/auto/corelib/io/qfileinfo/CMakeLists.txt +++ b/tests/auto/corelib/io/qfileinfo/CMakeLists.txt @@ -45,3 +45,7 @@ qt_internal_extend_target(tst_qfileinfo CONDITION WIN32 advapi32 netapi32 ) + +if (APPLE) + target_compile_options(tst_qfileinfo PRIVATE -x objective-c++) +endif() diff --git a/tests/auto/corelib/io/qfileinfo/qfileinfo.qrc b/tests/auto/corelib/io/qfileinfo/qfileinfo.qrc deleted file mode 100644 index 2c63d8afeb..0000000000 --- a/tests/auto/corelib/io/qfileinfo/qfileinfo.qrc +++ /dev/null @@ -1,5 +0,0 @@ -<!DOCTYPE RCC><RCC version="1.0"> -<qresource prefix="/tst_qfileinfo/"> - <file>resources/</file> -</qresource> -</RCC> diff --git a/tests/auto/corelib/io/qfileinfo/testdata.qrc b/tests/auto/corelib/io/qfileinfo/testdata.qrc deleted file mode 100644 index d2974bae77..0000000000 --- a/tests/auto/corelib/io/qfileinfo/testdata.qrc +++ /dev/null @@ -1,8 +0,0 @@ -<RCC> - <qresource prefix="/testdata"> - <file>resources/file1</file> - <file>resources/file1.ext1</file> - <file>resources/file1.ext1.ext2</file> - <file>tst_qfileinfo.cpp</file> - </qresource> -</RCC> diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp index 9e4fd9d064..80f204156e 100644 --- a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2021 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) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include <QTest> #include <QStandardPaths> @@ -62,6 +37,10 @@ #include <private/qfileinfo_p.h> #include "../../../../shared/filesystem.h" +#if defined(Q_OS_MACOS) +#include <Foundation/Foundation.h> +#endif + #if defined(Q_OS_VXWORKS) #define Q_NO_SYMLINKS #endif @@ -73,6 +52,8 @@ QT_END_NAMESPACE bool IsUserAdmin(); #endif +using namespace Qt::StringLiterals; + inline bool qIsLikelyToBeFat(const QString &path) { QByteArray name = QStorageInfo(path).fileSystemType().toLower(); @@ -218,6 +199,9 @@ private slots: void isShortcut_data(); void isShortcut(); + void isAlias_data(); + void isAlias(); + void link_data(); void link(); @@ -1345,6 +1329,57 @@ void tst_QFileInfo::isShortcut() QCOMPARE(fi.isShortcut(), isShortcut); } +void tst_QFileInfo::isAlias_data() +{ + QFile::remove("symlink"); + QFile::remove("file-alias"); + QFile::remove("directory-alias"); + + QTest::addColumn<QString>("path"); + QTest::addColumn<bool>("isAlias"); + + QFile regularFile(m_sourceFile); + QTest::newRow("regular-file") << regularFile.fileName() << false; + QTest::newRow("directory") << QDir::currentPath() << false; + +#if defined(Q_OS_MACOS) + auto createAlias = [](const QString &target, const QString &alias) { + NSURL *targetUrl = [NSURL fileURLWithPath:target.toNSString()]; + NSURL *aliasUrl = [NSURL fileURLWithPath:alias.toNSString()]; + NSData *bookmarkData = [targetUrl bookmarkDataWithOptions:NSURLBookmarkCreationSuitableForBookmarkFile + includingResourceValuesForKeys:nil relativeToURL:nil error:nullptr]; + Q_ASSERT(bookmarkData); + + bool success = [NSURL writeBookmarkData:bookmarkData toURL:aliasUrl + options:NSURLBookmarkCreationSuitableForBookmarkFile error:nullptr]; + Q_ASSERT(success); + }; + + regularFile.link("symlink"); + QTest::newRow("symlink") << "symlink" << false; + + createAlias(regularFile.fileName(), QDir::current().filePath("file-alias")); + QTest::newRow("file-alias") << "file-alias" << true; + + createAlias(QDir::currentPath(), QDir::current().filePath("directory-alias")); + QTest::newRow("directory-alias") << "directory-alias" << true; + + regularFile.copy("non-existing-file"); + createAlias("non-existing-file", QDir::current().filePath("non-existing-file-alias")); + QDir::current().remove("non-existing-file"); + QTest::newRow("non-existing-file-alias") << "non-existing-file-alias" << true; +#endif +} + +void tst_QFileInfo::isAlias() +{ + QFETCH(QString, path); + QFETCH(bool, isAlias); + + QFileInfo fi(path); + QCOMPARE(fi.isAlias(), isAlias); +} + void tst_QFileInfo::isSymbolicLink_data() { QTest::addColumn<QString>("path"); @@ -1795,14 +1830,14 @@ void tst_QFileInfo::ntfsJunctionPointsAndSymlinks() creationResult.target = creationResult.target.sliced(4); // resolve volume to drive letter - static const QRegularExpression matchVolumeRe(uR"(^Volume\{([a-z]|[0-9]|-)+\}\\)"_qs, + static const QRegularExpression matchVolumeRe(uR"(^Volume\{([a-z]|[0-9]|-)+\}\\)"_s, QRegularExpression::CaseInsensitiveOption); auto matchVolume = matchVolumeRe.match(creationResult.target); if (matchVolume.hasMatch()) { Q_ASSERT(matchVolume.capturedStart() == 0); DWORD len; wchar_t buffer[MAX_PATH]; - const QString volumeName = uR"(\\?\)"_qs + matchVolume.captured(); + const QString volumeName = uR"(\\?\)"_s + matchVolume.captured(); if (GetVolumePathNamesForVolumeName(reinterpret_cast<LPCWSTR>(volumeName.utf16()), buffer, MAX_PATH, &len) != 0) { creationResult.target.replace(0, matchVolume.capturedLength(), @@ -1864,7 +1899,7 @@ void tst_QFileInfo::isWritable() #endif #if defined (Q_OS_QNX) // On QNX /etc is usually on a read-only filesystem - QVERIFY(!QFileInfo("/etc/passwd").isWritable()); + QCOMPARE(QFileInfo("/etc/passwd").isWritable(), (geteuid() == 0)); #elif defined (Q_OS_UNIX) && !defined(Q_OS_VXWORKS) // VxWorks does not have users/groups for (const char *attempt : { "/etc/passwd", "/etc/machine-id", "/proc/version" }) { if (access(attempt, F_OK) == -1) @@ -1878,7 +1913,13 @@ void tst_QFileInfo::isExecutable() { QString appPath = QCoreApplication::applicationDirPath(); #ifdef Q_OS_ANDROID - appPath += "/libtst_qfileinfo.so"; + QDir dir(appPath); + QVERIFY(dir.exists()); + dir.setNameFilters({ "libtst_qfileinfo*.so" }); + QStringList entries = dir.entryList(); + QCOMPARE(entries.size(), 1); + + appPath += "/" + entries[0]; #else appPath += "/tst_qfileinfo"; # if defined(Q_OS_WIN) @@ -1886,6 +1927,7 @@ void tst_QFileInfo::isExecutable() # endif #endif QFileInfo fi(appPath); + QVERIFY(fi.exists()); QCOMPARE(fi.isExecutable(), true); QCOMPARE(QFileInfo(m_proFile).isExecutable(), false); diff --git a/tests/auto/corelib/io/qfileselector/CMakeLists.txt b/tests/auto/corelib/io/qfileselector/CMakeLists.txt index 5f254044df..1ceb91212a 100644 --- a/tests/auto/corelib/io/qfileselector/CMakeLists.txt +++ b/tests/auto/corelib/io/qfileselector/CMakeLists.txt @@ -4,13 +4,6 @@ ## tst_qfileselectors Test: ##################################################################### -qt_internal_add_test(tst_qfileselectors - SOURCES - tst_qfileselector.cpp - PUBLIC_LIBRARIES - Qt::CorePrivate -) - # Resources: set(qfileselector_resource_files "extras/+custom1/test" @@ -62,10 +55,12 @@ set(qfileselector_resource_files "platforms/test5" ) -qt_internal_add_resource(tst_qfileselectors "qfileselector" - PREFIX - "/" - FILES - ${qfileselector_resource_files} +qt_internal_add_test(tst_qfileselectors + SOURCES + tst_qfileselector.cpp + PUBLIC_LIBRARIES + Qt::CorePrivate + TESTDATA ${qfileselector_resource_files} + BUILTIN_TESTDATA ) diff --git a/tests/auto/corelib/io/qfileselector/qfileselector.qrc b/tests/auto/corelib/io/qfileselector/qfileselector.qrc deleted file mode 100644 index f3b3ede575..0000000000 --- a/tests/auto/corelib/io/qfileselector/qfileselector.qrc +++ /dev/null @@ -1,51 +0,0 @@ -<RCC> - <qresource prefix="/"> - <file>extras/test</file> - <file>extras/test2</file> - <file>extras/+custom1/test</file> - <file>extras/+custom1/test3</file> - <file>extras/+custom2/test</file> - <file>extras/+custom3/test</file> - <file>extras/+custom3/+custom2/test</file> - <file>extras/+custom3/+custom4/test</file> - <file>extras/+custom3/+custom5/test</file> - <file>extras/+custom5/+custom3/test</file> - <file>platforms/test</file> - <file>platforms/+unix/+android/test</file> - <file>platforms/+unix/+darwin/test</file> - <file>platforms/+unix/+haiku/test</file> - <file>platforms/+unix/+linux/test</file> - <file>platforms/+unix/+qnx/test</file> - <file>platforms/+unix/test</file> - <file>platforms/+windows/+wince/test</file> - <file>platforms/+windows/+winnt/test</file> - <file>platforms/+windows/+winrt/test</file> - <file>platforms/+windows/test</file> - <file>platforms/+android/test</file> - <file>platforms/+ios/test</file> - <file>platforms/+macos/test</file> - <file>platforms/+darwin/test</file> - <file>platforms/+haiku/test</file> - <file>platforms/+linux/test</file> - <file>platforms/+qnx/test</file> - <file>platforms/+wince/test</file> - <file>platforms/+winrt/test</file> - <file>platforms/test2</file> - <file>platforms/+android/test2</file> - <file>platforms/+ios/test2</file> - <file>platforms/+macos/test2</file> - <file>platforms/+haiku/test2</file> - <file>platforms/+linux/test2</file> - <file>platforms/+qnx/test2</file> - <file>platforms/+wince/test2</file> - <file>platforms/+winnt/test2</file> - <file>platforms/+winrt/test2</file> - <file>platforms/test3</file> - <file>platforms/+windows/test3</file> - <file>platforms/+unix/test3</file> - <file>platforms/test4</file> - <file>platforms/test5</file> - <file>platforms/+unix/+darwin/+macos/test</file> - <file>platforms/+unix/+darwin/+ios/test</file> - </qresource> -</RCC> diff --git a/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp b/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp index 3d79507050..a3623cdc0b 100644 --- a/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp +++ b/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2013 BlackBerry Limited. All rights reserved. -** 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) 2013 BlackBerry Limited. All rights reserved. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include <QTest> #include <qplatformdefs.h> diff --git a/tests/auto/corelib/io/qfilesystementry/tst_qfilesystementry.cpp b/tests/auto/corelib/io/qfilesystementry/tst_qfilesystementry.cpp index a9ae848251..b6836ddbba 100644 --- a/tests/auto/corelib/io/qfilesystementry/tst_qfilesystementry.cpp +++ b/tests/auto/corelib/io/qfilesystementry/tst_qfilesystementry.cpp @@ -1,35 +1,12 @@ -/**************************************************************************** -** -** 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 WITH Qt-GPL-exception-1.0 #include <QTest> #include <QtCore/private/qfilesystementry_p.h> +using namespace Qt::StringLiterals; + class tst_QFileSystemEntry : public QObject { Q_OBJECT @@ -106,12 +83,12 @@ void tst_QFileSystemEntry::getSetCheck_data() << "A:dir/without/leading/backslash.bat" << "backslash.bat" << "backslash" << "backslash" << "bat" << "bat" << false << false; QTest::newRow("longpath") - << uR"(\\?\D:\)"_qs + << uR"(\\?\D:\)"_s << absPrefix + QLatin1String(R"(D:\)") << "D:/" << "" << "" << "" << "" << "" << true << false; QTest::newRow("uncprefix") - << uR"(\\?\UNC\localhost\C$\tmp.txt)"_qs + << uR"(\\?\UNC\localhost\C$\tmp.txt)"_s << absPrefix + QLatin1String(R"(UNC\localhost\C$\tmp.txt)") << "//localhost/C$/tmp.txt" << "tmp.txt" << "tmp" << "tmp" << "txt" << "txt" << true << false; diff --git a/tests/auto/corelib/io/qfilesystemmetadata/tst_qfilesystemmetadata.cpp b/tests/auto/corelib/io/qfilesystemmetadata/tst_qfilesystemmetadata.cpp index 880c88c441..53ba1d1311 100644 --- a/tests/auto/corelib/io/qfilesystemmetadata/tst_qfilesystemmetadata.cpp +++ b/tests/auto/corelib/io/qfilesystemmetadata/tst_qfilesystemmetadata.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include <QTest> #include <QtCore/private/qfilesystemmetadata_p.h> diff --git a/tests/auto/corelib/io/qfilesystemwatcher/BLACKLIST b/tests/auto/corelib/io/qfilesystemwatcher/BLACKLIST index 457499591d..3b59c6477a 100644 --- a/tests/auto/corelib/io/qfilesystemwatcher/BLACKLIST +++ b/tests/auto/corelib/io/qfilesystemwatcher/BLACKLIST @@ -1,10 +1,15 @@ # QTBUG-33574 QTBUG-30943 [signalsEmittedAfterFileMoved] -windows-7sp1 -windows-10 +windows [watchFileAndItsDirectory:native backend-testfile] osx windows [watchFileAndItsDirectory:native backend-specialchars] osx windows +# QTBUG-102095 +[watchDirectory] +macos arm ci +# QTBUG-102096 +[signalsEmittedAfterFileMoved] +macos arm ci diff --git a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp index 8b61025cc0..acf26039d1 100644 --- a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp +++ b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2021 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) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include <QTest> #include <QCoreApplication> @@ -33,6 +8,8 @@ #include <QFileSystemWatcher> #include <QElapsedTimer> #include <QTextStream> +#include <QMap> +#include <QString> #include <QDir> #include <QSignalSpy> #include <QTimer> @@ -124,7 +101,7 @@ void tst_QFileSystemWatcher::basicTest_data() + QChar(ushort(0x00DC)) // LATIN_CAPITAL_LETTER_U_WITH_DIAERESIS + QStringLiteral(".txt"); -#if !defined(Q_OS_QNX) || !defined(QT_NO_INOTIFY) +#if !defined(QT_NO_INOTIFY) QTest::newRow("native backend-testfile") << "native" << testFile; QTest::newRow("native backend-specialchars") << "native" << specialCharacterFile; #endif @@ -418,7 +395,7 @@ void tst_QFileSystemWatcher::addPaths() { QFileSystemWatcher watcher; QStringList paths; - paths << QDir::homePath() << QDir::currentPath(); + paths << QDir::homePath() << QDir::tempPath(); QCOMPARE(watcher.addPaths(paths), QStringList()); QCOMPARE(watcher.directories().count(), 2); @@ -486,7 +463,7 @@ void tst_QFileSystemWatcher::removePaths() { QFileSystemWatcher watcher; QStringList paths; - paths << QDir::homePath() << QDir::currentPath(); + paths << QDir::homePath() << QDir::tempPath(); QCOMPARE(watcher.addPaths(paths), QStringList()); QCOMPARE(watcher.directories().count(), 2); QCOMPARE(watcher.removePaths(paths), QStringList()); diff --git a/tests/auto/corelib/io/qiodevice/CMakeLists.txt b/tests/auto/corelib/io/qiodevice/CMakeLists.txt index 2bd6033440..ce15e80be5 100644 --- a/tests/auto/corelib/io/qiodevice/CMakeLists.txt +++ b/tests/auto/corelib/io/qiodevice/CMakeLists.txt @@ -13,24 +13,5 @@ qt_internal_add_test(tst_qiodevice PUBLIC_LIBRARIES Qt::Network TESTDATA ${test_data} + QT_TEST_SERVER_LIST "apache2" "cyrus" ) - -#### Keys ignored in scope 1:.:.:qiodevice.pro:<TRUE>: -# MOC_DIR = "tmp" - -## Scopes: -##################################################################### - -if(ANDROID) - # Resources: - set(android_testdata_resource_files - "tst_qiodevice.cpp" - ) - - qt_internal_add_resource(tst_qiodevice "android_testdata" - PREFIX - "/" - FILES - ${android_testdata_resource_files} - ) -endif() diff --git a/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp b/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp index 88e41092a6..07c2aa27b7 100644 --- a/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp +++ b/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2021 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) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include <QtCore/QCoreApplication> #include <QtNetwork/QtNetwork> @@ -104,15 +79,20 @@ void tst_QIODevice::getSetCheck() //---------------------------------------------------------------------------------- void tst_QIODevice::constructing_QTcpSocket() { +#ifdef QT_TEST_SERVER + if (!QtNetworkSettings::verifyConnection(QtNetworkSettings::imapServerName(), 143)) + QSKIP("No network test server available"); +#else if (!QtNetworkSettings::verifyTestNetworkSettings()) QSKIP("No network test server available"); +#endif QTcpSocket socket; QIODevice *device = &socket; QVERIFY(!device->isOpen()); - socket.connectToHost(QtNetworkSettings::serverName(), 143); + socket.connectToHost(QtNetworkSettings::imapServerName(), 143); QVERIFY(socket.waitForConnected(30000)); QVERIFY(device->isOpen()); QCOMPARE(device->readChannelCount(), 1); @@ -130,7 +110,7 @@ void tst_QIODevice::constructing_QTcpSocket() socket.close(); QCOMPARE(socket.readChannelCount(), 0); QCOMPARE(socket.writeChannelCount(), 0); - socket.connectToHost(QtNetworkSettings::serverName(), 143); + socket.connectToHost(QtNetworkSettings::imapServerName(), 143); QVERIFY(socket.waitForConnected(30000)); QVERIFY(device->isOpen()); @@ -270,9 +250,17 @@ void tst_QIODevice::unget() result = QByteArray("ZXCV"); lineResult = "ZXCV"; } else { - if (!QtNetworkSettings::verifyTestNetworkSettings()) - QSKIP("No network test server available"); - socket.connectToHost(QtNetworkSettings::serverName(), 80); +#ifdef QT_TEST_SERVER + const bool hasNetworkServer = + QtNetworkSettings::verifyConnection(QtNetworkSettings::httpServerName(), 80); +#else + const bool hasNetworkServer = QtNetworkSettings::verifyTestNetworkSettings(); +#endif + if (!hasNetworkServer) { + qInfo("No network test server: skipping QTcpSocket part of test."); + continue; + } + socket.connectToHost(QtNetworkSettings::httpServerName(), 80); socket.write("GET / HTTP/1.0\r\n\r\n"); QVERIFY(socket.waitForReadyRead()); dev = &socket; @@ -558,7 +546,8 @@ protected: qint64 readData(char *data, qint64 maxSize) override { maxSize = qMin(maxSize, qint64(buf->size() - offset)); - memcpy(data, buf->constData() + offset, maxSize); + if (maxSize > 0) + memcpy(data, buf->constData() + offset, maxSize); offset += maxSize; return maxSize; } @@ -601,13 +590,15 @@ protected: qint64 readData(char *data, qint64 maxSize) override { maxSize = qMin(maxSize, qint64(buf.size() - pos())); - memcpy(data, buf.constData() + pos(), maxSize); + if (maxSize > 0) + memcpy(data, buf.constData() + pos(), maxSize); return maxSize; } qint64 writeData(const char *data, qint64 maxSize) override { maxSize = qMin(maxSize, qint64(buf.size() - pos())); - memcpy(buf.data() + pos(), data, maxSize); + if (maxSize > 0) + memcpy(buf.data() + pos(), data, maxSize); return maxSize; } diff --git a/tests/auto/corelib/io/qipaddress/tst_qipaddress.cpp b/tests/auto/corelib/io/qipaddress/tst_qipaddress.cpp index 60b0c697c5..04d7268f06 100644 --- a/tests/auto/corelib/io/qipaddress/tst_qipaddress.cpp +++ b/tests/auto/corelib/io/qipaddress/tst_qipaddress.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Intel Corporation. -** 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 Intel Corporation. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #define _CRT_SECURE_NO_WARNINGS 1 diff --git a/tests/auto/corelib/io/qlockfile/qlockfiletesthelper/qlockfile_test_helper.cpp b/tests/auto/corelib/io/qlockfile/qlockfiletesthelper/qlockfile_test_helper.cpp index e086bf1904..c8a1f5a447 100644 --- a/tests/auto/corelib/io/qlockfile/qlockfiletesthelper/qlockfile_test_helper.cpp +++ b/tests/auto/corelib/io/qlockfile/qlockfiletesthelper/qlockfile_test_helper.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2013 David Faure <faure+bluesystems@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) 2013 David Faure <faure+bluesystems@kde.org> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include <QDebug> #include <QCoreApplication> diff --git a/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp b/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp index 2766ea51d5..f36334db02 100644 --- a/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp +++ b/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp @@ -1,31 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Copyright (C) 2013 David Faure <faure+bluesystems@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) 2021 The Qt Company Ltd. +// Copyright (C) 2013 David Faure <faure+bluesystems@kde.org> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include <QTest> diff --git a/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp b/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp index a2a96e32d3..a0a9bb940e 100644 --- a/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp +++ b/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp @@ -1,34 +1,11 @@ -/**************************************************************************** -** -** 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 WITH Qt-GPL-exception-1.0 #include <QTest> #include <QMutexLocker> #include <QLoggingCategory> +#include <QMap> +#include <QStringList> Q_LOGGING_CATEGORY(TST_LOG, "tst.log") Q_LOGGING_CATEGORY(Digia_Oslo_Office_com, "Digia.Oslo.Office.com") diff --git a/tests/auto/corelib/io/qloggingregistry/CMakeLists.txt b/tests/auto/corelib/io/qloggingregistry/CMakeLists.txt index a00fb8cb32..80da400032 100644 --- a/tests/auto/corelib/io/qloggingregistry/CMakeLists.txt +++ b/tests/auto/corelib/io/qloggingregistry/CMakeLists.txt @@ -14,23 +14,3 @@ qt_internal_add_test(tst_qloggingregistry Qt::CorePrivate TESTDATA ${test_data} ) - -#### Keys ignored in scope 1:.:.:qloggingregistry.pro:<TRUE>: -# TEMPLATE = "app" - -## Scopes: -##################################################################### - -if(ANDROID) - # Resources: - set(android_testdata_resource_files - "qtlogging.ini" - ) - - qt_internal_add_resource(tst_qloggingregistry "android_testdata" - PREFIX - "/" - FILES - ${android_testdata_resource_files} - ) -endif() diff --git a/tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp b/tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp index d46dc4b98c..1ee6bf80e7 100644 --- a/tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.cpp +++ b/tests/auto/corelib/io/qloggingregistry/tst_qloggingregistry.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 WITH Qt-GPL-exception-1.0 #include <QTest> #include <QLoggingCategory> diff --git a/tests/auto/corelib/io/qnodebug/tst_qnodebug.cpp b/tests/auto/corelib/io/qnodebug/tst_qnodebug.cpp index 7279aad287..67b74026ce 100644 --- a/tests/auto/corelib/io/qnodebug/tst_qnodebug.cpp +++ b/tests/auto/corelib/io/qnodebug/tst_qnodebug.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2020 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) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 // This test is for "release" mode, with -DQT_NO_DEBUG -DQT_NO_DEBUG_OUTPUT #ifndef QT_NO_DEBUG diff --git a/tests/auto/corelib/io/qprocess-noapplication/tst_qprocessnoapplication.cpp b/tests/auto/corelib/io/qprocess-noapplication/tst_qprocessnoapplication.cpp index c9949b4932..b7b7650e03 100644 --- a/tests/auto/corelib/io/qprocess-noapplication/tst_qprocessnoapplication.cpp +++ b/tests/auto/corelib/io/qprocess-noapplication/tst_qprocessnoapplication.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Intel Corporation. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtCore module 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 Intel Corporation. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include <QtCore/QCoreApplication> #include <QtCore/QProcess> diff --git a/tests/auto/corelib/io/qprocess/fileWriterProcess/main.cpp b/tests/auto/corelib/io/qprocess/fileWriterProcess/main.cpp index efeadadb93..01e49400af 100644 --- a/tests/auto/corelib/io/qprocess/fileWriterProcess/main.cpp +++ b/tests/auto/corelib/io/qprocess/fileWriterProcess/main.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 WITH Qt-GPL-exception-1.0 #include <QCoreApplication> #include <QFile> diff --git a/tests/auto/corelib/io/qprocess/testDetached/main.cpp b/tests/auto/corelib/io/qprocess/testDetached/main.cpp index c10e32d584..57d39f4f13 100644 --- a/tests/auto/corelib/io/qprocess/testDetached/main.cpp +++ b/tests/auto/corelib/io/qprocess/testDetached/main.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 WITH Qt-GPL-exception-1.0 #include <QCoreApplication> #include <QDebug> #include <QStringList> diff --git a/tests/auto/corelib/io/qprocess/testExitCodes/main.cpp b/tests/auto/corelib/io/qprocess/testExitCodes/main.cpp index f681870609..bd416d8fa3 100644 --- a/tests/auto/corelib/io/qprocess/testExitCodes/main.cpp +++ b/tests/auto/corelib/io/qprocess/testExitCodes/main.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 WITH Qt-GPL-exception-1.0 #include <stdlib.h> diff --git a/tests/auto/corelib/io/qprocess/testForwarding/main.cpp b/tests/auto/corelib/io/qprocess/testForwarding/main.cpp index b5d56a1138..cc1bb8163f 100644 --- a/tests/auto/corelib/io/qprocess/testForwarding/main.cpp +++ b/tests/auto/corelib/io/qprocess/testForwarding/main.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 WITH Qt-GPL-exception-1.0 #include <QtCore/QCoreApplication> #include <QtCore/QDeadlineTimer> diff --git a/tests/auto/corelib/io/qprocess/testForwardingHelper/main.cpp b/tests/auto/corelib/io/qprocess/testForwardingHelper/main.cpp index c902db9410..3ed5ae7360 100644 --- a/tests/auto/corelib/io/qprocess/testForwardingHelper/main.cpp +++ b/tests/auto/corelib/io/qprocess/testForwardingHelper/main.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2018 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) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include <fstream> #include <stdio.h> diff --git a/tests/auto/corelib/io/qprocess/testGuiProcess/main.cpp b/tests/auto/corelib/io/qprocess/testGuiProcess/main.cpp index 98babfacb8..eff79edbdc 100644 --- a/tests/auto/corelib/io/qprocess/testGuiProcess/main.cpp +++ b/tests/auto/corelib/io/qprocess/testGuiProcess/main.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 WITH Qt-GPL-exception-1.0 #include <QtWidgets/QApplication> #include <QtWidgets/QLabel> #include <stdio.h> diff --git a/tests/auto/corelib/io/qprocess/testProcessCrash/main.cpp b/tests/auto/corelib/io/qprocess/testProcessCrash/main.cpp index 298a74d2b0..1441c8ed0c 100644 --- a/tests/auto/corelib/io/qprocess/testProcessCrash/main.cpp +++ b/tests/auto/corelib/io/qprocess/testProcessCrash/main.cpp @@ -1,31 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Copyright (C) 2020 Intel Corporation. -** 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. +// Copyright (C) 2020 Intel Corporation. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 void crashFallback(volatile int *ptr = nullptr) { diff --git a/tests/auto/corelib/io/qprocess/testProcessDeadWhileReading/main.cpp b/tests/auto/corelib/io/qprocess/testProcessDeadWhileReading/main.cpp index eb780fbc3a..e13927a380 100644 --- a/tests/auto/corelib/io/qprocess/testProcessDeadWhileReading/main.cpp +++ b/tests/auto/corelib/io/qprocess/testProcessDeadWhileReading/main.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 WITH Qt-GPL-exception-1.0 #include <stdio.h> diff --git a/tests/auto/corelib/io/qprocess/testProcessEOF/main.cpp b/tests/auto/corelib/io/qprocess/testProcessEOF/main.cpp index 4fb2e29c2d..c997fbe5c2 100644 --- a/tests/auto/corelib/io/qprocess/testProcessEOF/main.cpp +++ b/tests/auto/corelib/io/qprocess/testProcessEOF/main.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 WITH Qt-GPL-exception-1.0 #include <stdio.h> diff --git a/tests/auto/corelib/io/qprocess/testProcessEcho/main.cpp b/tests/auto/corelib/io/qprocess/testProcessEcho/main.cpp index e18e48e516..b970704b1e 100644 --- a/tests/auto/corelib/io/qprocess/testProcessEcho/main.cpp +++ b/tests/auto/corelib/io/qprocess/testProcessEcho/main.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 WITH Qt-GPL-exception-1.0 #include <stdio.h> diff --git a/tests/auto/corelib/io/qprocess/testProcessEcho2/main.cpp b/tests/auto/corelib/io/qprocess/testProcessEcho2/main.cpp index ce4494b048..8420601d6e 100644 --- a/tests/auto/corelib/io/qprocess/testProcessEcho2/main.cpp +++ b/tests/auto/corelib/io/qprocess/testProcessEcho2/main.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 WITH Qt-GPL-exception-1.0 #include <stdio.h> diff --git a/tests/auto/corelib/io/qprocess/testProcessEcho3/main.cpp b/tests/auto/corelib/io/qprocess/testProcessEcho3/main.cpp index dfd6e009db..7f2c78e20d 100644 --- a/tests/auto/corelib/io/qprocess/testProcessEcho3/main.cpp +++ b/tests/auto/corelib/io/qprocess/testProcessEcho3/main.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 WITH Qt-GPL-exception-1.0 #include <stdio.h> diff --git a/tests/auto/corelib/io/qprocess/testProcessEchoGui/main_win.cpp b/tests/auto/corelib/io/qprocess/testProcessEchoGui/main_win.cpp index abe957c1ea..eab3275a38 100644 --- a/tests/auto/corelib/io/qprocess/testProcessEchoGui/main_win.cpp +++ b/tests/auto/corelib/io/qprocess/testProcessEchoGui/main_win.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 WITH Qt-GPL-exception-1.0 #include <windows.h> diff --git a/tests/auto/corelib/io/qprocess/testProcessEnvironment/main.cpp b/tests/auto/corelib/io/qprocess/testProcessEnvironment/main.cpp index 9f13f5c00f..d5a289fb49 100644 --- a/tests/auto/corelib/io/qprocess/testProcessEnvironment/main.cpp +++ b/tests/auto/corelib/io/qprocess/testProcessEnvironment/main.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 WITH Qt-GPL-exception-1.0 #include <stdio.h> #include <stdlib.h> diff --git a/tests/auto/corelib/io/qprocess/testProcessHang/main.cpp b/tests/auto/corelib/io/qprocess/testProcessHang/main.cpp index cb904134f9..bbfc7af19d 100644 --- a/tests/auto/corelib/io/qprocess/testProcessHang/main.cpp +++ b/tests/auto/corelib/io/qprocess/testProcessHang/main.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Intel Corporation. -** 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 Intel Corporation. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include <stdio.h> diff --git a/tests/auto/corelib/io/qprocess/testProcessNormal/main.cpp b/tests/auto/corelib/io/qprocess/testProcessNormal/main.cpp index 4611ed4547..ea78ca4353 100644 --- a/tests/auto/corelib/io/qprocess/testProcessNormal/main.cpp +++ b/tests/auto/corelib/io/qprocess/testProcessNormal/main.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 WITH Qt-GPL-exception-1.0 int main() diff --git a/tests/auto/corelib/io/qprocess/testProcessOutput/main.cpp b/tests/auto/corelib/io/qprocess/testProcessOutput/main.cpp index 4934708153..914d2ed26c 100644 --- a/tests/auto/corelib/io/qprocess/testProcessOutput/main.cpp +++ b/tests/auto/corelib/io/qprocess/testProcessOutput/main.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 WITH Qt-GPL-exception-1.0 #include <stdio.h> diff --git a/tests/auto/corelib/io/qprocess/testProcessSpacesArgs/main.cpp b/tests/auto/corelib/io/qprocess/testProcessSpacesArgs/main.cpp index 0d40a9b83c..c04c7171d5 100644 --- a/tests/auto/corelib/io/qprocess/testProcessSpacesArgs/main.cpp +++ b/tests/auto/corelib/io/qprocess/testProcessSpacesArgs/main.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 WITH Qt-GPL-exception-1.0 #include <stdio.h> diff --git a/tests/auto/corelib/io/qprocess/testSetNamedPipeHandleState/main.cpp b/tests/auto/corelib/io/qprocess/testSetNamedPipeHandleState/main.cpp index 488b03ab57..3f7260dd4e 100644 --- a/tests/auto/corelib/io/qprocess/testSetNamedPipeHandleState/main.cpp +++ b/tests/auto/corelib/io/qprocess/testSetNamedPipeHandleState/main.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 WITH Qt-GPL-exception-1.0 #include <windows.h> diff --git a/tests/auto/corelib/io/qprocess/testSetWorkingDirectory/main.cpp b/tests/auto/corelib/io/qprocess/testSetWorkingDirectory/main.cpp index 37d7deb1ac..86f5d65a46 100644 --- a/tests/auto/corelib/io/qprocess/testSetWorkingDirectory/main.cpp +++ b/tests/auto/corelib/io/qprocess/testSetWorkingDirectory/main.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 WITH Qt-GPL-exception-1.0 #include <QCoreApplication> diff --git a/tests/auto/corelib/io/qprocess/testSoftExit/main_unix.cpp b/tests/auto/corelib/io/qprocess/testSoftExit/main_unix.cpp index ed0f16ac17..fce8206170 100644 --- a/tests/auto/corelib/io/qprocess/testSoftExit/main_unix.cpp +++ b/tests/auto/corelib/io/qprocess/testSoftExit/main_unix.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 WITH Qt-GPL-exception-1.0 #include <sys/types.h> diff --git a/tests/auto/corelib/io/qprocess/testSoftExit/main_win.cpp b/tests/auto/corelib/io/qprocess/testSoftExit/main_win.cpp index 898029483f..29de8a5129 100644 --- a/tests/auto/corelib/io/qprocess/testSoftExit/main_win.cpp +++ b/tests/auto/corelib/io/qprocess/testSoftExit/main_win.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 WITH Qt-GPL-exception-1.0 #include <windows.h> diff --git a/tests/auto/corelib/io/qprocess/testSpaceInName/main.cpp b/tests/auto/corelib/io/qprocess/testSpaceInName/main.cpp index 0e2374de06..f86f575a3e 100644 --- a/tests/auto/corelib/io/qprocess/testSpaceInName/main.cpp +++ b/tests/auto/corelib/io/qprocess/testSpaceInName/main.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 WITH Qt-GPL-exception-1.0 #include <stdio.h> diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp index 41f90de1e7..674e232eca 100644 --- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp +++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp @@ -1,31 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Copyright (C) 2020 Intel Corporation. -** 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) 2021 The Qt Company Ltd. +// Copyright (C) 2022 Intel Corporation. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include <QTest> #include <QTestEventLoop> @@ -151,6 +126,8 @@ private slots: void startStopStartStopBuffers(); void processEventsInAReadyReadSlot_data(); void processEventsInAReadyReadSlot(); + void startFromCurrentWorkingDir_data(); + void startFromCurrentWorkingDir(); // keep these at the end, since they use lots of processes and sometimes // caused obscure failures to occur in tests that followed them (esp. on the Mac) @@ -1080,6 +1057,16 @@ void tst_QProcess::mergedChannels() QVERIFY(process.waitForStarted(5000)); + { + QCOMPARE(process.write("abc"), qlonglong(3)); + while (process.bytesAvailable() < 6) + QVERIFY(process.waitForReadyRead(5000)); + QCOMPARE(process.readAllStandardOutput(), QByteArray("aabbcc")); + QTest::ignoreMessage(QtWarningMsg, + "QProcess::readAllStandardError: Called with MergedChannels"); + QCOMPARE(process.readAllStandardError(), QByteArray()); + } + for (int i = 0; i < 100; ++i) { QCOMPARE(process.write("abc"), qlonglong(3)); while (process.bytesAvailable() < 6) @@ -1236,6 +1223,10 @@ void tst_QProcess::processInAThread() void tst_QProcess::processesInMultipleThreads() { +#if defined(Q_OS_QNX) + QSKIP("QNX: Large amount of threads is unstable and do not finish in given time"); +#endif + for (int i = 0; i < 10; ++i) { // run from 1 to 10 threads, but run at least some tests // with more threads than the ideal @@ -2520,5 +2511,94 @@ void tst_QProcess::processEventsInAReadyReadSlot() QVERIFY(process.waitForFinished()); } +enum class ChdirMode { + None = 0, + InParent, + InChild +}; +Q_DECLARE_METATYPE(ChdirMode) + +void tst_QProcess::startFromCurrentWorkingDir_data() +{ + qRegisterMetaType<ChdirMode>(); + QTest::addColumn<QString>("programPrefix"); + QTest::addColumn<ChdirMode>("chdirMode"); + QTest::addColumn<bool>("success"); + + constexpr bool IsWindows = true +#ifdef Q_OS_UNIX + && false +#endif + ; + + // baseline: trying to execute the directory, this can't possibly succeed! + QTest::newRow("plain-same-cwd") << QString() << ChdirMode::None << false; + + // cross-platform behavior: neither OS searches the setWorkingDirectory() + // dir without "./" + QTest::newRow("plain-child-chdir") << QString() << ChdirMode::InChild << false; + + // cross-platform behavior: both OSes search the parent's CWD with "./" + QTest::newRow("prefixed-parent-chdir") << "./" << ChdirMode::InParent << true; + + // opposite behaviors: Windows searches the parent's CWD and Unix searches + // the child's with "./" + QTest::newRow("prefixed-child-chdir") << "./" << ChdirMode::InChild << !IsWindows; + + // Windows searches the parent's CWD without "./" + QTest::newRow("plain-parent-chdir") << QString() << ChdirMode::InParent << IsWindows; +} + +void tst_QProcess::startFromCurrentWorkingDir() +{ + QFETCH(QString, programPrefix); + QFETCH(ChdirMode, chdirMode); + QFETCH(bool, success); + + QProcess process; + qRegisterMetaType<QProcess::ProcessError>(); + QSignalSpy errorSpy(&process, &QProcess::errorOccurred); + QVERIFY(errorSpy.isValid()); + + // both the dir name and the executable name + const QString target = QStringLiteral("testProcessNormal"); + process.setProgram(programPrefix + target); + +#ifdef Q_OS_UNIX + // Reset PATH, to be sure it doesn't contain . or the empty path. + // We can't do this on Windows because DLLs are searched in PATH + // and Windows always searches "." anyway. + auto restoreEnv = qScopeGuard([old = qgetenv("PATH")] { + qputenv("PATH", old); + }); + qputenv("PATH", "/"); +#endif + + switch (chdirMode) { + case ChdirMode::InParent: { + auto restoreCwd = qScopeGuard([old = QDir::currentPath()] { + QDir::setCurrent(old); + }); + QVERIFY(QDir::setCurrent(target)); + process.start(); + break; + } + case ChdirMode::InChild: + process.setWorkingDirectory(target); + Q_FALLTHROUGH(); + case ChdirMode::None: + process.start(); + break; + } + + QCOMPARE(process.waitForStarted(), success); + QCOMPARE(errorSpy.count(), int(!success)); + if (success) { + QVERIFY(process.waitForFinished()); + } else { + QCOMPARE(process.error(), QProcess::FailedToStart); + } +} + QTEST_MAIN(tst_QProcess) #include "tst_qprocess.moc" diff --git a/tests/auto/corelib/io/qprocessenvironment/tst_qprocessenvironment.cpp b/tests/auto/corelib/io/qprocessenvironment/tst_qprocessenvironment.cpp index d1035cb8c2..32a12c30bd 100644 --- a/tests/auto/corelib/io/qprocessenvironment/tst_qprocessenvironment.cpp +++ b/tests/auto/corelib/io/qprocessenvironment/tst_qprocessenvironment.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 WITH Qt-GPL-exception-1.0 #include <QTest> #include <QObject> diff --git a/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp b/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp index 1de5749d6e..13508d953a 100644 --- a/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp +++ b/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp @@ -1,31 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Copyright (C) 2019 Intel Corporation. -** 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) 2021 The Qt Company Ltd. +// Copyright (C) 2019 Intel Corporation. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include <QTest> #include <QResource> @@ -491,7 +466,7 @@ void tst_QResourceEngine::checkStructure() void tst_QResourceEngine::searchPath_data() { - auto searchPath = QFileInfo(QT_TESTCASE_SOURCEDIR "/testqrc").canonicalFilePath(); + auto searchPath = QFileInfo(QFINDTESTDATA("testqrc/test.qrc")).canonicalPath(); QTest::addColumn<QString>("searchPathPrefix"); QTest::addColumn<QString>("searchPath"); diff --git a/tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp b/tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp index 3d09ea291d..6879534144 100644 --- a/tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp +++ b/tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2012 David Faure <faure@kde.org> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtCore module 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) 2012 David Faure <faure@kde.org> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include <QTest> #include <QSaveFile> diff --git a/tests/auto/corelib/io/qsettings/.gitattributes b/tests/auto/corelib/io/qsettings/.gitattributes index a4ad8d7644..920df33b54 100644 --- a/tests/auto/corelib/io/qsettings/.gitattributes +++ b/tests/auto/corelib/io/qsettings/.gitattributes @@ -1,5 +1,3 @@ resourcefile.ini -crlf resourcefile2.ini -crlf resourcefile3.ini -crlf -resourcefile4.ini -crlf -resourcefile5.ini -crlf diff --git a/tests/auto/corelib/io/qsettings/CMakeLists.txt b/tests/auto/corelib/io/qsettings/CMakeLists.txt index 55a360166b..2b60d1efff 100644 --- a/tests/auto/corelib/io/qsettings/CMakeLists.txt +++ b/tests/auto/corelib/io/qsettings/CMakeLists.txt @@ -4,36 +4,29 @@ ## tst_qsettings Test: ##################################################################### -qt_internal_add_test(tst_qsettings - SOURCES - tst_qsettings.cpp - DEFINES - QT_DISABLE_DEPRECATED_BEFORE=0 - INCLUDE_DIRECTORIES - ../../kernel/qmetatype - PUBLIC_LIBRARIES - Qt::CorePrivate - Qt::Gui -) - -# Resources: +# Test: set(qsettings_resource_files "bom.ini" "resourcefile.ini" "resourcefile2.ini" "resourcefile3.ini" - "resourcefile4.ini" - "resourcefile5.ini" "resourcefile6.plist" "withcomments.ini" "float.ini" + "qt5settings.ini" + "utf8settings.ini" ) -qt_internal_add_resource(tst_qsettings "qsettings" - PREFIX - "/" - FILES - ${qsettings_resource_files} +qt_internal_add_test(tst_qsettings + SOURCES + tst_qsettings.cpp + INCLUDE_DIRECTORIES + ../../kernel/qmetatype + PUBLIC_LIBRARIES + Qt::CorePrivate + Qt::Gui + TESTDATA ${qsettings_resource_files} + BUILTIN_TESTDATA ) diff --git a/tests/auto/corelib/io/qsettings/qsettings.qrc b/tests/auto/corelib/io/qsettings/qsettings.qrc deleted file mode 100644 index 0501206c05..0000000000 --- a/tests/auto/corelib/io/qsettings/qsettings.qrc +++ /dev/null @@ -1,13 +0,0 @@ -<RCC> - <qresource prefix="/"> - <file>resourcefile.ini</file> - <file>resourcefile2.ini</file> - <file>resourcefile3.ini</file> - <file>resourcefile4.ini</file> - <file>resourcefile5.ini</file> - <file>resourcefile6.plist</file> - <file>bom.ini</file> - <file>withcomments.ini</file> - <file>float.ini</file> - </qresource> -</RCC> diff --git a/tests/auto/corelib/io/qsettings/qt5settings.ini b/tests/auto/corelib/io/qsettings/qt5settings.ini new file mode 100644 index 0000000000..59239d29f3 --- /dev/null +++ b/tests/auto/corelib/io/qsettings/qt5settings.ini @@ -0,0 +1,11 @@ +[General] +.%2C%27%25U%U0430%U0431%U0432%U0433%22%09=".,'%!@#$" +%U265F=\x2658\x265a +%UD83C%UDF0D=\xd83c\xdf10 + +[Test] +BAR=BAR +B%C4R=B\xc4R +OST=OST +%D6SE=\xd6SE +%U042D%U0442%U043E\%U0442%U0435%U0441%U0442=\x42d\x442\x43e \x442\x435\x441\x442 diff --git a/tests/auto/corelib/io/qsettings/resourcefile4.ini b/tests/auto/corelib/io/qsettings/resourcefile4.ini deleted file mode 100644 index 09c21b1591..0000000000 --- a/tests/auto/corelib/io/qsettings/resourcefile4.ini +++ /dev/null @@ -1,2 +0,0 @@ -[Fa%E7ade] -QU%C9BEC=Façade/QUÉBEC diff --git a/tests/auto/corelib/io/qsettings/resourcefile5.ini b/tests/auto/corelib/io/qsettings/resourcefile5.ini deleted file mode 100644 index d2d2103560..0000000000 --- a/tests/auto/corelib/io/qsettings/resourcefile5.ini +++ /dev/null @@ -1,2 +0,0 @@ -[Fa%E7ade] -QU%C9BEC=Faade/QUBEC diff --git a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp index 094d04252b..19ed36589e 100644 --- a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp +++ b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp @@ -1,52 +1,22 @@ -/**************************************************************************** -** -** 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) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include <QTest> #include <QtCore/QSettings> #include <private/qsettings_p.h> + +#include "tst_qmetatype_common.h" + #include <QtCore/QCoreApplication> -#include <QtCore/QDateTime> -#include <QtCore/QtGlobal> -#include <QtCore/QMetaType> -#include <QtCore/QString> #include <QtCore/QDir> +#include <QtCore/QtGlobal> #include <QtCore/QThread> #include <QtCore/QSysInfo> #if QT_CONFIG(shortcut) # include <QtGui/QKeySequence> #endif -#include <QtCore> -#include <QtGui> -#include "tst_qmetatype_common.h" - #include <cctype> #include <stdlib.h> #if defined(Q_OS_WIN) && defined(Q_CC_GNU) @@ -108,6 +78,16 @@ static inline bool canWriteNativeSystemSettings() static const char insufficientPermissionSkipMessage[] = "Insufficient permissions for this test."; +static void populateWithFormats() +{ + QTest::addColumn<QSettings::Format>("format"); + + QTest::newRow("native") << QSettings::NativeFormat; + QTest::newRow("ini") << QSettings::IniFormat; + QTest::newRow("custom1") << QSettings::CustomFormat1; + QTest::newRow("custom2") << QSettings::CustomFormat2; +} + class tst_QSettings : public QObject { Q_OBJECT @@ -120,7 +100,7 @@ public slots: void cleanup() { cleanupTestFiles(); } private slots: void getSetCheck(); - void ctor_data(); + void ctor_data() { populateWithFormats(); } void ctor(); void beginGroup(); void setValue(); @@ -132,16 +112,16 @@ private slots: void syncAlternateDataStream(); #endif void setFallbacksEnabled(); - void setFallbacksEnabled_data(); - void fromFile_data(); + void setFallbacksEnabled_data() { populateWithFormats(); } + void fromFile_data() { populateWithFormats(); } void fromFile(); - void testArrays_data(); + void testArrays_data() { populateWithFormats(); } void testArrays(); - void testCaseSensitivity_data(); + void testCaseSensitivity_data() { populateWithFormats(); } void testCaseSensitivity(); void testErrorHandling_data(); void testErrorHandling(); - void testChildKeysAndGroups_data(); + void testChildKeysAndGroups_data() { populateWithFormats(); } void testChildKeysAndGroups(); void testUpdateRequestEvent(); void testThreadSafety(); @@ -154,7 +134,7 @@ private slots: #ifdef Q_OS_MAC void fileName(); #endif - void isWritable_data(); + void isWritable_data() { populateWithFormats(); } void isWritable(); void registerFormat(); void setPath(); @@ -168,23 +148,23 @@ private slots: #endif #ifdef QT_BUILD_INTERNAL - void allKeys_data(); + void allKeys_data() { populateWithFormats(); } void allKeys(); - void childGroups_data(); + void childGroups_data() { populateWithFormats(); } void childGroups(); - void childKeys_data(); + void childKeys_data() { populateWithFormats(); } void childKeys(); void testIniParsing_data(); void testIniParsing(); void testEscapes(); void testNormalizedKey_data(); void testNormalizedKey(); - void testVariantTypes_data(); + void testVariantTypes_data() { populateWithFormats(); } void testVariantTypes(); void testMetaTypes_data(); void testMetaTypes(); #endif - void rainersSyncBugOnMac_data(); + void rainersSyncBugOnMac_data() { populateWithFormats(); } void rainersSyncBugOnMac(); void recursionBug(); @@ -198,6 +178,10 @@ private slots: void floatAsQVariant(); void testXdg(); + + void testReadKeys_data(); + void testReadKeys(); + private: void cleanupTestFiles(); @@ -280,16 +264,6 @@ static bool writeCustom3File(QIODevice &device, const QSettings::SettingsMap &ma return true; } -static void populateWithFormats() -{ - QTest::addColumn<QSettings::Format>("format"); - - QTest::newRow("native") << QSettings::NativeFormat; - QTest::newRow("ini") << QSettings::IniFormat; - QTest::newRow("custom1") << QSettings::CustomFormat1; - QTest::newRow("custom2") << QSettings::CustomFormat2; -} - tst_QSettings::tst_QSettings() : m_canWriteNativeSystemSettings(canWriteNativeSystemSettings()) { @@ -361,11 +335,6 @@ void tst_QSettings::cleanupTestFiles() Test the constructors and the assignment operator. */ -void tst_QSettings::ctor_data() -{ - populateWithFormats(); -} - void tst_QSettings::ctor() { QFETCH(QSettings::Format, format); @@ -955,7 +924,7 @@ void tst_QSettings::testIniParsing() if ( settings.status() == QSettings::NoError ) { // else no point proceeding QVariant v = settings.value(key); if (expect.isValid()) - QVERIFY(v.canConvert(expect.type())); + QVERIFY(v.canConvert(expect.metaType())); // check some types so as to give prettier error messages if ( v.typeId() == QMetaType::QString ) { QCOMPARE(v.toString(), expect.toString()); @@ -1183,7 +1152,7 @@ template<int MetaTypeId> static void testMetaTypesHelper(QSettings::Format format) { typedef typename MetaEnumToType<MetaTypeId>::Type Type; - const char *key = QMetaType::typeName(MetaTypeId); + const char *key = QMetaType(MetaTypeId).name(); Type *value = TestValueFactory<MetaTypeId>::create(); QVariant inputVariant = QVariant::fromValue(*value); @@ -1202,8 +1171,8 @@ static void testMetaTypesHelper(QSettings::Format format) QSettings settings(format, scope, organization, applicationName); QVariant outputVariant = settings.value(key); if (MetaTypeId != QMetaType::QVariant) - QVERIFY(outputVariant.canConvert(MetaTypeId)); - if (outputVariant.type() != inputVariant.type()) + QVERIFY(outputVariant.canConvert(QMetaType(MetaTypeId))); + if (outputVariant.typeId() != inputVariant.typeId()) qWarning() << "type mismatch between" << inputVariant << "and" << outputVariant; QCOMPARE(qvariant_cast<Type >(outputVariant), *value); } @@ -1242,7 +1211,7 @@ void tst_QSettings::testMetaTypes_data() #define ADD_METATYPE_TEST_ROW(MetaTypeName, MetaTypeId, RealType) \ { \ const char *formatName = QMetaEnum::fromType<QSettings::Format>().valueToKey(formats[i]); \ - const char *typeName = QMetaType::typeName(QMetaType::MetaTypeName); \ + const char *typeName = QMetaType(QMetaType::MetaTypeName).name(); \ QTest::newRow(QString("%1:%2").arg(formatName).arg(typeName).toLatin1().constData()) \ << QSettings::Format(formats[i]) << int(QMetaType::MetaTypeName); \ } @@ -1277,106 +1246,102 @@ FOR_EACH_CORE_METATYPE(RETURN_CREATE_FUNCTION) TypeTestFunctionGetter::get(type)(format); } - -void tst_QSettings::testVariantTypes_data() -{ - populateWithFormats(); -} #endif #ifdef QT_BUILD_INTERNAL void tst_QSettings::testVariantTypes() { -#define testVal(key, val, tp, rtype) \ - { \ - QSettings settings1(format, QSettings::UserScope, "software.org", "KillerAPP"); \ - settings1.setValue(key, QVariant::fromValue(val)); \ - } \ - QConfFile::clearCache(); \ - { \ - QSettings settings2(format, QSettings::UserScope, "software.org", "KillerAPP"); \ - QVariant v = settings2.value(key); \ - QVERIFY(qvariant_cast<tp >(v) == val); \ - QVERIFY(v.type() == QVariant::rtype); \ + QFETCH(QSettings::Format, format); + + { + QSettings settings(format, QSettings::UserScope, "software.org", "KillerAPP"); + QVERIFY(!settings.contains("empty")); + QCOMPARE(settings.value("empty"), QVariant()); + + settings.setValue("empty", QVariant()); + QVERIFY(settings.contains("empty")); + QCOMPARE(settings.value("empty"), QVariant()); + + settings.setValue("empty", QVariant(1)); + QVERIFY(settings.contains("empty")); + QCOMPARE(settings.value("empty"), QVariant(1)); + + settings.setValue("empty", QVariant()); + QVERIFY(settings.contains("empty")); + QCOMPARE(settings.value("empty"), QVariant()); + + settings.remove("empty"); + QVERIFY(!settings.contains("empty")); + QCOMPARE(settings.value("empty"), QVariant()); } - typedef QMap<QString, QVariant> TestVariantMap; + auto checker = [format](const char *key, auto value, QMetaType::Type expected) { + { + QSettings settings(format, QSettings::UserScope, "software.org", "KillerAPP"); + settings.setValue(key, QVariant::fromValue(value)); + } + QConfFile::clearCache(); + { + QSettings settings(format, QSettings::UserScope, "software.org", "KillerAPP"); + QVariant actual = settings.value(key); + QCOMPARE(actual.metaType().id(), expected); + QCOMPARE(qvariant_cast<decltype(value)>(actual), value); + } + }; +#define testValue(key, supplied, expected) do { \ + checker(key, supplied, QMetaType::expected); \ + if (QTest::currentTestFailed()) \ + return; \ + } while (0) - QFETCH(QSettings::Format, format); + typedef QMap<QString, QVariant> TestVariantMap; TestVariantMap m2; m2.insert("ene", "due"); m2.insert("rike", "fake"); m2.insert("borba", "dorba"); - testVal("key2", m2, TestVariantMap, Map); + testValue("customMap", m2, QVariantMap); - QStringList l2; + QStringList l2 { "ene", "due", "@Point(1 2)", "@fake" }; + testValue("stringsAt", l2, QStringList); - l2 << "ene" << "due" << "@Point(1 2)" << "@fake"; - testVal("key3", l2, QStringList, StringList); + l2 = { "ene", "due", "rike", "fake" }; + testValue("strings", l2, QStringList); - l2.clear(); - l2 << "ene" << "due" << "rike" << "fake"; - testVal("key3", l2, QStringList, StringList); - - QList<QVariant> l3; QDate date = QDate::currentDate(); QTime time = QTime::currentTime(); - l3 << QString("ene") << 10 << QVariant::fromValue(QColor(1, 2, 3)) << QVariant(QRect(1, 2, 3, 4)) - << QVariant(QSize(4, 56)) << QVariant(QPoint(4, 2)) << true << false << date << time; - testVal("key3", l3, QVariantList, List); - - testVal("key4", QString("hello"), QString, String); - testVal("key5", QColor(1, 2, 3), QColor, Color); - testVal("key6", QRect(1, 2, 3, 4), QRect, Rect); - testVal("key7", QSize(4, 56), QSize, Size); - testVal("key8", QPoint(4, 2), QPoint, Point); - testVal("key10", date, QDate, Date); - testVal("key11", time, QTime, Time); - testVal("key12", QByteArray("foo bar"), QByteArray, ByteArray); - - { - QSettings settings(format, QSettings::UserScope, "software.org", "KillerAPP"); - QVERIFY(!settings.contains("key99")); - QCOMPARE(settings.value("key99"), QVariant()); - - settings.setValue("key99", QVariant()); - QVERIFY(settings.contains("key99")); - QCOMPARE(settings.value("key99"), QVariant()); - - settings.setValue("key99", QVariant(1)); - QVERIFY(settings.contains("key99")); - QCOMPARE(settings.value("key99"), QVariant(1)); - - settings.setValue("key99", QVariant()); - QVERIFY(settings.contains("key99")); - QCOMPARE(settings.value("key99"), QVariant()); + QList<QVariant> l3 { QString("ene"), 10, QVariant::fromValue(QColor(1, 2, 3)), + QVariant(QRect(1, 2, 3, 4)), QVariant(QSize(4, 56)), QVariant(QPoint(4, 2)), + true, false, date, time }; + testValue("mixedList", l3, QVariantList); + + testValue("string", QString("hello"), QString); + testValue("color", QColor(1, 2, 3), QColor); + testValue("rect", QRect(1, 2, 3, 4), QRect); + testValue("size", QSize(4, 56), QSize); + testValue("point", QPoint(4, 2), QPoint); + testValue("date", date, QDate); + testValue("time", time, QTime); + testValue("byteArray", QByteArray("foo bar"), QByteArray); + + QList<QVariant> l4 { QVariant(m2), QVariant(l2), QVariant(l3) }; + testValue("collectList", l4, QVariantList); - settings.remove("key99"); - QVERIFY(!settings.contains("key99")); - QCOMPARE(settings.value("key99"), QVariant()); - } - - QList<QVariant> l4; - l4 << QVariant(m2) << QVariant(l2) << QVariant(l3); - testVal("key13", l4, QVariantList, List); QDateTime dt = QDateTime::currentDateTime(); dt.setOffsetFromUtc(3600); - testVal("key14", dt, QDateTime, DateTime); + testValue("dateTime", dt, QDateTime); #if QT_CONFIG(shortcut) // We store key sequences as strings instead of binary variant blob, for improved // readability in the resulting format. - if (format >= QSettings::InvalidFormat) { - testVal("keysequence", QKeySequence(Qt::ControlModifier + Qt::Key_F1), QKeySequence, KeySequence); - } else { - testVal("keysequence", - QKeySequence(Qt::ControlModifier + Qt::Key_F1).toString(QKeySequence::NativeText), - QString, String); - } + QKeySequence seq(Qt::ControlModifier | Qt::Key_F1); + if (format >= QSettings::InvalidFormat) + testValue("keySequence", seq, QKeySequence); + else + testValue("keySequence", seq.toString(QKeySequence::NativeText), QString); #endif // QT_CONFIG(shortcut) -#undef testVal +#undef testValue } #endif @@ -1864,11 +1829,6 @@ void tst_QSettings::syncAlternateDataStream() } #endif -void tst_QSettings::setFallbacksEnabled_data() -{ - populateWithFormats(); -} - void tst_QSettings::setFallbacksEnabled() { QFETCH(QSettings::Format, format); @@ -1953,11 +1913,6 @@ void tst_QSettings::setFallbacksEnabled() QVERIFY(!settings1.contains("key 5")); } -void tst_QSettings::testChildKeysAndGroups_data() -{ - populateWithFormats(); -} - void tst_QSettings::testChildKeysAndGroups() { QFETCH(QSettings::Format, format); @@ -2018,6 +1973,16 @@ void tst_QSettings::testChildKeysAndGroups() l.sort(); QCOMPARE(l, QStringList() << "bar" << "foo"); } + { + QSettings settings3(format, QSettings::UserScope, "software.org", "application"); + settings3.setFallbacksEnabled(false); + settings3.beginGroup("alpha"); + QCOMPARE(settings3.childGroups(), QStringList()); + settings3.setFallbacksEnabled(true); + QStringList children = settings3.childGroups(); + children.sort(); + QCOMPARE(children, QStringList({"beta", "gamma"})); + } } void tst_QSettings::testUpdateRequestEvent() @@ -2146,20 +2111,17 @@ void tst_QSettings::testNormalizedKey() inKey.detach(); - QString result = QSettingsPrivate::normalizedKey(inKey); - QCOMPARE(result, outKey); - - /* - If the key is already normalized, we verify that outKey is - just a shallow copy of the input string. This is an important - optimization that shouldn't be removed accidentally. - */ - if (inKey == outKey) { - QVERIFY(!result.isDetached()); - } else { - if (!result.isEmpty()) { - QVERIFY(result.isDetached()); - } + { + auto result = QSettingsPrivate::normalizedKey(inKey); + QCOMPARE(result, outKey); + } + { + auto result = QSettingsPrivate::normalizedKey(QUtf8StringView{inKey.toUtf8()}); + QCOMPARE(result, outKey); + } + { + auto result = QSettingsPrivate::normalizedKey(QLatin1String{inKey.toLatin1()}); + QCOMPARE(result, outKey); } } #endif @@ -2345,11 +2307,6 @@ void tst_QSettings::trailingWhitespace() } } -void tst_QSettings::fromFile_data() -{ - populateWithFormats(); -} - void tst_QSettings::fromFile() { QFETCH(QSettings::Format, format); @@ -2419,11 +2376,6 @@ static bool containsSubList(QStringList mom, QStringList son) return true; } -void tst_QSettings::testArrays_data() -{ - populateWithFormats(); -} - /* Tests beginReadArray(), beginWriteArray(), endArray(), and setArrayIndex(). @@ -2704,7 +2656,7 @@ static QByteArray iniEscapedKey(const QString &str) static QString iniUnescapedKey(const QByteArray &ba) { QString result; - QSettingsPrivate::iniUnescapedKey(ba, 0, ba.size(), result); + QSettingsPrivate::iniUnescapedKey(ba, result); return result; } @@ -2719,7 +2671,7 @@ static QStringList iniUnescapedStringList(const QByteArray &ba) { QStringList result; QString str; - bool isStringList = QSettingsPrivate::iniUnescapedStringList(ba, 0, ba.size(), str, result); + bool isStringList = QSettingsPrivate::iniUnescapedStringList(ba, str, result); if (!isStringList) result = QStringList(str); return result; @@ -2871,11 +2823,6 @@ void tst_QSettings::testEscapes() } #endif -void tst_QSettings::testCaseSensitivity_data() -{ - populateWithFormats(); -} - void tst_QSettings::testCaseSensitivity() { QFETCH(QSettings::Format, format); @@ -3025,11 +2972,6 @@ void tst_QSettings::fileName() } #endif -void tst_QSettings::isWritable_data() -{ - populateWithFormats(); -} - void tst_QSettings::isWritable() { QFETCH(QSettings::Format, format); @@ -3082,13 +3024,6 @@ void tst_QSettings::isWritable() } #ifdef QT_BUILD_INTERNAL -void tst_QSettings::childGroups_data() -{ - populateWithFormats(); -} -#endif - -#ifdef QT_BUILD_INTERNAL void tst_QSettings::childGroups() { QFETCH(QSettings::Format, format); @@ -3158,13 +3093,6 @@ void tst_QSettings::childGroups() #endif #ifdef QT_BUILD_INTERNAL -void tst_QSettings::childKeys_data() -{ - populateWithFormats(); -} -#endif - -#ifdef QT_BUILD_INTERNAL void tst_QSettings::childKeys() { QFETCH(QSettings::Format, format); @@ -3232,13 +3160,6 @@ void tst_QSettings::childKeys() #endif #ifdef QT_BUILD_INTERNAL -void tst_QSettings::allKeys_data() -{ - populateWithFormats(); -} -#endif - -#ifdef QT_BUILD_INTERNAL void tst_QSettings::allKeys() { QFETCH(QSettings::Format, format); @@ -3498,11 +3419,6 @@ void tst_QSettings::dontReorderIniKeysNeedlessly() } #endif -void tst_QSettings::rainersSyncBugOnMac_data() -{ - ctor_data(); -} - void tst_QSettings::rainersSyncBugOnMac() { QFETCH(QSettings::Format, format); @@ -3534,7 +3450,7 @@ void tst_QSettings::rainersSyncBugOnMac() void tst_QSettings::recursionBug() { QPixmap pix(10,10); - pix.fill("blue"); + pix.fill(Qt::blue); { QSettings settings(settingsPath("starrunner.ini"), QSettings::IniFormat); @@ -3653,5 +3569,39 @@ void tst_QSettings::testXdg() #endif } +void tst_QSettings::testReadKeys_data() +{ + QTest::addColumn<QString>("filepath"); + + QTest::newRow("escaped") << ":/qt5settings.ini"; + QTest::newRow("utf-8") << ":/utf8settings.ini"; +} + +void tst_QSettings::testReadKeys() +{ + QFETCH(QString, filepath); + + QSettings settings(filepath, QSettings::IniFormat); + QCOMPARE(settings.status(), QSettings::NoError); + + QVariantMap expectedValues; + expectedValues.insert("Test/BAR", "BAR"); + expectedValues.insert("Test/OST", "OST"); + expectedValues.insert("Test/B\xC3\x84R", "B\xC3\x84R"); // BÄR + expectedValues.insert("Test/\xC3\x96SE", "\xC3\x96SE"); // ÖSE + expectedValues.insert( + "Test/\xD0\xAD\xD1\x82\xD0\xBE/\xD1\x82\xD0\xB5\xD1\x81\xD1\x82", // Это/тест + "\xD0\xAD\xD1\x82\xD0\xBE \xD1\x82\xD0\xB5\xD1\x81\xD1\x82"); // Это тест + expectedValues.insert(".,'%U\xD0\xB0\xD0\xB1\xD0\xB2\xD0\xB3\"\t", ".,'%!@#$"); + expectedValues.insert("\xE2\x99\x9F", "\xE2\x99\x98\xE2\x99\x9A"); // ♟︎ ♘♚ + expectedValues.insert("\xF0\x9F\x8C\x8D", "\xF0\x9F\x8C\x90"); // 🌍 🌐 + + QVariantMap readValues; + for (const auto &key : settings.allKeys()) + readValues.insert(key, settings.value(key)); + + QCOMPARE(readValues, expectedValues); +} + QTEST_MAIN(tst_QSettings) #include "tst_qsettings.moc" diff --git a/tests/auto/corelib/io/qsettings/utf8settings.ini b/tests/auto/corelib/io/qsettings/utf8settings.ini new file mode 100644 index 0000000000..bac010254f --- /dev/null +++ b/tests/auto/corelib/io/qsettings/utf8settings.ini @@ -0,0 +1,11 @@ +[General] +.%2C%27%25Uабвг%22%09=".,'%!@#$" +♟=♘♚ +🌍=🌐 + +[Test] +BAR=BAR +BÄR=BÄR +OST=OST +ÖSE=ÖSE +Это\тест=Это тест diff --git a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp index d722b374d9..2c0500eec9 100644 --- a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp +++ b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp @@ -1,31 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2020 The Qt Company Ltd. -** Copyright (C) 2020 Intel Corporation. -** 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) 2020 The Qt Company Ltd. +// Copyright (C) 2020 Intel Corporation. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include <qstandardpaths.h> #include <QTest> diff --git a/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp b/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp index f7273d19cf..7e462537b3 100644 --- a/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp +++ b/tests/auto/corelib/io/qstorageinfo/tst_qstorageinfo.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2014 Ivan Komissarov <ABBAPOH@gmail.com> -** 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 Ivan Komissarov <ABBAPOH@gmail.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include <QTest> #include <QStorageInfo> diff --git a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp index d4760c0afd..7761ac5a6a 100644 --- a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp +++ b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2021 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) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include <QTest> @@ -49,6 +24,10 @@ #include "qplatformdefs.h" #endif +#include <optional> + +using namespace Qt::StringLiterals; + class tst_QTemporaryDir : public QObject { Q_OBJECT @@ -59,6 +38,7 @@ public slots: private slots: void construction(); + void moveSemantics(); void fileTemplate(); void fileTemplate_data(); void getSetCheck(); @@ -105,6 +85,58 @@ void tst_QTemporaryDir::construction() QCOMPARE(dir.errorString(), QString()); } +void tst_QTemporaryDir::moveSemantics() +{ + { + auto original = std::optional<QTemporaryDir>(std::in_place); + QVERIFY(original->isValid()); + + original->setAutoRemove(true); + + auto OriginalDirectoryInfo = QFileInfo(original->path()); + OriginalDirectoryInfo.setCaching(false); + QVERIFY(OriginalDirectoryInfo.exists()); + + QTemporaryDir movedInto = std::move(*original); + + original.reset(); + + QVERIFY(OriginalDirectoryInfo.exists()); + QVERIFY(movedInto.path() == OriginalDirectoryInfo.filePath()); + } + + { + auto movedInto = QTemporaryDir(); + QVERIFY(movedInto.isValid()); + + movedInto.setAutoRemove(true); + + auto movedIntoInitialDirectoryInfo = QFileInfo(movedInto.path()); + movedIntoInitialDirectoryInfo.setCaching(false); + QVERIFY(movedIntoInitialDirectoryInfo.exists()); + + auto OriginalDirectoryInfo = QFileInfo(); + OriginalDirectoryInfo.setCaching(false); + + { + auto original = QTemporaryDir(); + QVERIFY(original.isValid()); + + original.setAutoRemove(true); + + OriginalDirectoryInfo.setFile(original.path()); + QVERIFY(OriginalDirectoryInfo.exists()); + + movedInto = std::move(original); + } + + QVERIFY(!movedIntoInitialDirectoryInfo.exists()); + QVERIFY(OriginalDirectoryInfo.exists()); + + QVERIFY(movedInto.path() == OriginalDirectoryInfo.filePath()); + } +} + // Testing get/set functions void tst_QTemporaryDir::getSetCheck() { @@ -169,19 +201,19 @@ void tst_QTemporaryDir::fileTemplate_data() return; // skip if we have no drive letter tmp.data()[1] = u'$'; - const auto tmpPath = tmp + uR"(\UNC.XXXXXX.tmpDir)"_qs; + const auto tmpPath = tmp + uR"(\UNC.XXXXXX.tmpDir)"_s; QTest::newRow("UNC-backslash") - << uR"(\\localhost\)"_qs + tmpPath << "UNC." + << uR"(\\localhost\)"_s + tmpPath << "UNC." << ".tmpDir"; QTest::newRow("UNC-prefix") - << uR"(\\?\UNC\localhost\)"_qs + tmpPath << "UNC." + << uR"(\\?\UNC\localhost\)"_s + tmpPath << "UNC." << ".tmpDir"; QTest::newRow("UNC-slash") - << u"//localhost/"_qs + QDir::fromNativeSeparators(tmpPath) << "UNC." + << u"//localhost/"_s + QDir::fromNativeSeparators(tmpPath) << "UNC." << ".tmpDir"; QTest::newRow("UNC-prefix-slash") - << uR"(//?/UNC/localhost/)"_qs + QDir::fromNativeSeparators(tmpPath) << "UNC." + << uR"(//?/UNC/localhost/)"_s + QDir::fromNativeSeparators(tmpPath) << "UNC." << ".tmpDir"; #endif } diff --git a/tests/auto/corelib/io/qtemporaryfile/qtemporaryfile.qrc b/tests/auto/corelib/io/qtemporaryfile/qtemporaryfile.qrc deleted file mode 100644 index efadde8b4d..0000000000 --- a/tests/auto/corelib/io/qtemporaryfile/qtemporaryfile.qrc +++ /dev/null @@ -1,5 +0,0 @@ -<!DOCTYPE RCC><RCC version="1.0"> -<qresource> - <file>resources/test.txt</file> -</qresource> -</RCC>
\ No newline at end of file diff --git a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp index 732b2fa4a8..ba37285d5f 100644 --- a/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp +++ b/tests/auto/corelib/io/qtemporaryfile/tst_qtemporaryfile.cpp @@ -1,31 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Copyright (C) 2017 Intel Corporation. -** 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) 2021 The Qt Company Ltd. +// Copyright (C) 2017 Intel Corporation. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include <QTest> #include <qcoreapplication.h> @@ -60,6 +35,8 @@ #include "qplatformdefs.h" #endif +using namespace Qt::StringLiterals; + class tst_QTemporaryFile : public QObject { Q_OBJECT @@ -218,22 +195,22 @@ void tst_QTemporaryFile::fileTemplate_data() return; // skip if we have no drive letter tmp.data()[1] = u'$'; - const auto tmpPath = tmp + uR"(\QTBUG-74291.XXXXXX.tmpFile)"_qs; + const auto tmpPath = tmp + uR"(\QTBUG-74291.XXXXXX.tmpFile)"_s; QTest::newRow("UNC-backslash") - << uR"(\\localhost\)"_qs + tmpPath << "QTBUG-74291." + << uR"(\\localhost\)"_s + tmpPath << "QTBUG-74291." << ".tmpFile" << ""; QTest::newRow("UNC-prefix") - << uR"(\\?\UNC\localhost\)"_qs + tmpPath << "QTBUG-74291." + << uR"(\\?\UNC\localhost\)"_s + tmpPath << "QTBUG-74291." << ".tmpFile" << ""; QTest::newRow("UNC-slash") - << u"//localhost/"_qs + QDir::fromNativeSeparators(tmpPath) << "QTBUG-74291." + << u"//localhost/"_s + QDir::fromNativeSeparators(tmpPath) << "QTBUG-74291." << ".tmpFile" << ""; QTest::newRow("UNC-prefix-slash") - << uR"(//?/UNC/localhost/)"_qs + QDir::fromNativeSeparators(tmpPath) << "QTBUG-74291." + << uR"(//?/UNC/localhost/)"_s + QDir::fromNativeSeparators(tmpPath) << "QTBUG-74291." << ".tmpFile" << ""; #endif diff --git a/tests/auto/corelib/io/qurl/idna-test.c b/tests/auto/corelib/io/qurl/idna-test.c index 035d3e1c89..1360ee1072 100644 --- a/tests/auto/corelib/io/qurl/idna-test.c +++ b/tests/auto/corelib/io/qurl/idna-test.c @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation 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 WITH Qt-GPL-exception-1.0 struct idna { diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp index 205a99ef1b..48ffa09906 100644 --- a/tests/auto/corelib/io/qurl/tst_qurl.cpp +++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp @@ -1,31 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Copyright (C) 2016 Intel Corporation. -** 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. +// Copyright (C) 2016 Intel Corporation. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include <qurl.h> #include <QtCore/QDebug> @@ -40,6 +15,8 @@ #include <QtTest/private/qemulationdetector_p.h> +using namespace Qt::StringLiterals; + Q_DECLARE_METATYPE(QUrl::FormattingOptions) class tst_QUrl : public QObject @@ -2085,7 +2062,7 @@ void tst_QUrl::hasQuery() void tst_QUrl::nameprep() { // U+FB01 LATIN SMALL LIGATURE FI - QUrl url(u"http://www.\uFB01le.de/"_qs); + QUrl url(u"http://www.\uFB01le.de/"_s); QCOMPARE(url.toString(), QStringLiteral(u"http://www.file.de/")); } diff --git a/tests/auto/corelib/io/qurl/tst_qurl_mac.mm b/tests/auto/corelib/io/qurl/tst_qurl_mac.mm index b6e2a923f3..f23fb4ce06 100644 --- a/tests/auto/corelib/io/qurl/tst_qurl_mac.mm +++ b/tests/auto/corelib/io/qurl/tst_qurl_mac.mm @@ -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 WITH Qt-GPL-exception-1.0 #include <QTest> diff --git a/tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp b/tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp index 6c556f1f25..aa7564f300 100644 --- a/tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp +++ b/tests/auto/corelib/io/qurlinternal/tst_qurlinternal.cpp @@ -1,31 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Copyright (C) 2016 Intel Corporation. -** 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. +// Copyright (C) 2016 Intel Corporation. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include <QtCore/QUrl> #include <QTest> @@ -41,6 +16,8 @@ #define STRINGPREP_BIDI_BOTH_L_AND_RAL 4 #define STRINGPREP_BIDI_LEADTRAIL_NOT_RAL 5 +using namespace Qt::StringLiterals; + struct char16array { char16array() {} template <size_t N> @@ -259,8 +236,8 @@ void tst_QUrlInternal::ace_testsuite_data() QTest::newRow("ascii-upper") << "FLUKE" << "fluke" << "fluke" << "fluke"; // U+FB01 LATIN SMALL LIGATURE FI - QTest::newRow("asciifolded") << u"\uFB01le"_qs << "file" << "." << "file"; - QTest::newRow("asciifolded-dotcom") << u"\uFB01le.example.com"_qs << "file.example.com" << "." << "file.example.com"; + QTest::newRow("asciifolded") << u"\uFB01le"_s << "file" << "." << "file"; + QTest::newRow("asciifolded-dotcom") << u"\uFB01le.example.com"_s << "file.example.com" << "." << "file.example.com"; QTest::newRow("greek-mu") << QString::fromLatin1("\265V") <<"xn--v-lmb" << "." diff --git a/tests/auto/corelib/io/qurlinternal/utf8data.cpp b/tests/auto/corelib/io/qurlinternal/utf8data.cpp index ba2c3e054a..244da29d1c 100644 --- a/tests/auto/corelib/io/qurlinternal/utf8data.cpp +++ b/tests/auto/corelib/io/qurlinternal/utf8data.cpp @@ -1,31 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Copyright (C) 2018 Intel Corporation. -** 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) 2018 The Qt Company Ltd. +// Copyright (C) 2018 Intel Corporation. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include <QTest> void loadInvalidUtf8Rows() diff --git a/tests/auto/corelib/io/qurlquery/tst_qurlquery.cpp b/tests/auto/corelib/io/qurlquery/tst_qurlquery.cpp index de911b7aa4..c6985557d1 100644 --- a/tests/auto/corelib/io/qurlquery/tst_qurlquery.cpp +++ b/tests/auto/corelib/io/qurlquery/tst_qurlquery.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Intel Corporation. -** 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 Intel Corporation. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include <QtCore/QUrlQuery> #include <QTest> diff --git a/tests/auto/corelib/io/qurluts46/tst_qurluts46.cpp b/tests/auto/corelib/io/qurluts46/tst_qurluts46.cpp index a550397ee8..e36642974a 100644 --- a/tests/auto/corelib/io/qurluts46/tst_qurluts46.cpp +++ b/tests/auto/corelib/io/qurluts46/tst_qurluts46.cpp @@ -1,34 +1,11 @@ -/**************************************************************************** -** -** Copyright (C) 2021 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) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include <QtCore/QUrl> #include <QtCore/QFile> #include <QTest> +#include <QSet> +#include <QByteArray> #include <algorithm> class tst_QUrlUts46 : public QObject diff --git a/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp b/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp index 5719d9e046..423cc1bdc8 100644 --- a/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp +++ b/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.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 WITH Qt-GPL-exception-1.0 #include <QTest> diff --git a/tests/auto/corelib/itemmodels/qabstractproxymodel/tst_qabstractproxymodel.cpp b/tests/auto/corelib/itemmodels/qabstractproxymodel/tst_qabstractproxymodel.cpp index dced357d61..b8283709e2 100644 --- a/tests/auto/corelib/itemmodels/qabstractproxymodel/tst_qabstractproxymodel.cpp +++ b/tests/auto/corelib/itemmodels/qabstractproxymodel/tst_qabstractproxymodel.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2021 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) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include <QTest> #include <QtTest/private/qpropertytesthelper_p.h> @@ -44,6 +19,7 @@ private slots: void flags(); void headerData_data(); void headerData(); + void headerDataInBounds(); void itemData_data(); void itemData(); void mapFromSource_data(); @@ -174,6 +150,133 @@ void tst_QAbstractProxyModel::headerData() QCOMPARE(model.headerData(section, orientation, role), headerData); } +class SimpleTableReverseColumnsProxy : public QAbstractProxyModel +{ +public: + QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override + { + if (parent.isValid()) + return {}; + + if (row < 0 || row >= rowCount() || column < 0 || column >= columnCount()) + qFatal("error"); // cannot QFAIL here + + return createIndex(row, column); + } + + int rowCount(const QModelIndex &parent = QModelIndex()) const override + { + if (parent.isValid()) + return 0; + return sourceModel()->rowCount(); + } + + int columnCount(const QModelIndex &parent = QModelIndex()) const override + { + if (parent.isValid()) + return 0; + return sourceModel()->columnCount(); + } + + QModelIndex parent(const QModelIndex &) const override + { + return QModelIndex(); + } + + QModelIndex mapToSource(const QModelIndex &idx) const override + { + if (!idx.isValid()) + return QModelIndex(); + return sourceModel()->index(idx.row(), columnCount() - 1 - idx.column()); + } + + QModelIndex mapFromSource(const QModelIndex &idx) const override + { + if (idx.parent().isValid()) + return QModelIndex(); + return createIndex(idx.row(), columnCount() - 1 - idx.column()); + } +}; + +void tst_QAbstractProxyModel::headerDataInBounds() +{ + QStandardItemModel qsim(0, 5); + qsim.setHorizontalHeaderLabels({"Col1", "Col2", "Col3", "Col4", "Col5"}); + + SimpleTableReverseColumnsProxy proxy; + QSignalSpy headerDataChangedSpy(&proxy, &QAbstractItemModel::headerDataChanged); + QVERIFY(headerDataChangedSpy.isValid()); + proxy.setSourceModel(&qsim); + QCOMPARE(proxy.rowCount(), 0); + QCOMPARE(proxy.columnCount(), 5); + + for (int i = 0; i < proxy.columnCount(); ++i) { + QString expected = QString("Col%1").arg(i + 1); + QCOMPARE(proxy.headerData(i, Qt::Horizontal).toString(), expected); + } + + qsim.appendRow({ + new QStandardItem("A"), + new QStandardItem("B"), + new QStandardItem("C"), + new QStandardItem("D"), + new QStandardItem("E") + }); + + QCOMPARE(proxy.rowCount(), 1); + QCOMPARE(proxy.columnCount(), 5); + QCOMPARE(headerDataChangedSpy.count(), 1); + QCOMPARE(headerDataChangedSpy[0][0].value<Qt::Orientation>(), Qt::Horizontal); + QCOMPARE(headerDataChangedSpy[0][1].value<int>(), 0); + QCOMPARE(headerDataChangedSpy[0][2].value<int>(), 4); + + for (int i = 0; i < proxy.columnCount(); ++i) { + QString expected = QString("Col%1").arg(proxy.columnCount() - i); + QCOMPARE(proxy.headerData(i, Qt::Horizontal).toString(), expected); + } + + qsim.appendRow({ + new QStandardItem("A"), + new QStandardItem("B"), + new QStandardItem("C"), + new QStandardItem("D"), + new QStandardItem("E") + }); + QCOMPARE(proxy.rowCount(), 2); + QCOMPARE(proxy.columnCount(), 5); + QCOMPARE(headerDataChangedSpy.count(), 1); + + for (int i = 0; i < proxy.columnCount(); ++i) { + QString expected = QString("Col%1").arg(proxy.columnCount() - i); + QCOMPARE(proxy.headerData(i, Qt::Horizontal).toString(), expected); + } + + QVERIFY(qsim.removeRows(0, 1)); + + QCOMPARE(proxy.rowCount(), 1); + QCOMPARE(proxy.columnCount(), 5); + QCOMPARE(headerDataChangedSpy.count(), 1); + + for (int i = 0; i < proxy.columnCount(); ++i) { + QString expected = QString("Col%1").arg(proxy.columnCount() - i); + QCOMPARE(proxy.headerData(i, Qt::Horizontal).toString(), expected); + } + + QVERIFY(qsim.removeRows(0, 1)); + + QCOMPARE(proxy.rowCount(), 0); + QCOMPARE(proxy.columnCount(), 5); + QCOMPARE(headerDataChangedSpy.count(), 2); + QCOMPARE(headerDataChangedSpy[1][0].value<Qt::Orientation>(), Qt::Horizontal); + QCOMPARE(headerDataChangedSpy[1][1].value<int>(), 0); + QCOMPARE(headerDataChangedSpy[1][2].value<int>(), 4); + + for (int i = 0; i < proxy.columnCount(); ++i) { + QString expected = QString("Col%1").arg(i + 1); + QCOMPARE(proxy.headerData(i, Qt::Horizontal).toString(), expected); + } +} + void tst_QAbstractProxyModel::itemData_data() { QTest::addColumn<QModelIndex>("index"); diff --git a/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp b/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp index 0188768db5..9990aaf2ed 100644 --- a/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp +++ b/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author David Faure <david.faure@kdab.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** 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-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author David Faure <david.faure@kdab.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include <QSignalSpy> #include <QSortFilterProxyModel> diff --git a/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp b/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp index 72f3564746..b1de23d619 100644 --- a/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp +++ b/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module 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) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include <QAbstractItemModelTester> #include <QCoreApplication> diff --git a/tests/auto/corelib/itemmodels/qitemmodel/modelstotest.cpp b/tests/auto/corelib/itemmodels/qitemmodel/modelstotest.cpp index 3eb6c15ec2..b0256470e6 100644 --- a/tests/auto/corelib/itemmodels/qitemmodel/modelstotest.cpp +++ b/tests/auto/corelib/itemmodels/qitemmodel/modelstotest.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 WITH Qt-GPL-exception-1.0 #include <QTest> @@ -142,14 +117,14 @@ QAbstractItemModel *ModelsToTest::createModel(const QString &modelType) if (modelType == "QSortFilterProxyModelEmpty") { QSortFilterProxyModel *model = new QSortFilterProxyModel; - QStandardItemModel *standardItemModel = new QStandardItemModel; + QStandardItemModel *standardItemModel = new QStandardItemModel(model); model->setSourceModel(standardItemModel); return model; } if (modelType == "QSortFilterProxyModelRegExp") { QSortFilterProxyModel *model = new QSortFilterProxyModel; - QStandardItemModel *standardItemModel = new QStandardItemModel; + QStandardItemModel *standardItemModel = new QStandardItemModel(model); model->setSourceModel(standardItemModel); populateTestArea(model); model->setFilterRegularExpression(QRegularExpression("(^$|I.*)")); @@ -158,7 +133,7 @@ QAbstractItemModel *ModelsToTest::createModel(const QString &modelType) if (modelType == "QSortFilterProxyModel") { QSortFilterProxyModel *model = new QSortFilterProxyModel; - QStandardItemModel *standardItemModel = new QStandardItemModel; + QStandardItemModel *standardItemModel = new QStandardItemModel(model); model->setSourceModel(standardItemModel); populateTestArea(model); return model; diff --git a/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp b/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp index 40495c1d9e..1ce10c46aa 100644 --- a/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp +++ b/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.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 WITH Qt-GPL-exception-1.0 #include <QTest> #include <QSignalSpy> diff --git a/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp b/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp index 7c4dbaedbf..1a9875a1eb 100644 --- a/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp +++ b/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.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 WITH Qt-GPL-exception-1.0 #include <QTest> #include <QtTest/private/qpropertytesthelper_p.h> diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp index ad7fc6f8f8..99151a2065 100644 --- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp +++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2021 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) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "tst_qsortfilterproxymodel.h" #include "dynamictreemodel.h" @@ -72,6 +47,7 @@ void tst_QSortFilterProxyModel::initTestCase() m_model = new QStandardItemModel(0, 1); m_proxy = new QSortFilterProxyModel(); m_proxy->setSourceModel(m_model); + new QAbstractItemModelTester(m_proxy, this); } void tst_QSortFilterProxyModel::cleanupTestCase() @@ -3196,7 +3172,8 @@ void tst_QSortFilterProxyModel::mapFromToSource() QCOMPARE(proxy.mapFromSource(QModelIndex()), QModelIndex()); QCOMPARE(proxy.mapToSource(QModelIndex()), QModelIndex()); -#ifdef QT_NO_DEBUG //if Qt is compiled in debug mode, this will assert + // Will assert in debug, so only test in release +#if defined(QT_NO_DEBUG) && !defined(QT_FORCE_ASSERTS) QTest::ignoreMessage(QtWarningMsg, "QSortFilterProxyModel: index from wrong model passed to mapToSource"); QCOMPARE(proxy.mapToSource(source.index(2, 3)), QModelIndex()); QTest::ignoreMessage(QtWarningMsg, "QSortFilterProxyModel: index from wrong model passed to mapFromSource"); diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.h b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.h index baad28ec06..b63ec98baa 100644 --- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.h +++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.h @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2021 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) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #ifndef TST_QSORTFILTERPROXYMODEL_H #define TST_QSORTFILTERPROXYMODEL_H diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_recursive/tst_qsortfilterproxymodel_recursive.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel_recursive/tst_qsortfilterproxymodel_recursive.cpp index d6a09056ae..a880f8d204 100644 --- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_recursive/tst_qsortfilterproxymodel_recursive.cpp +++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel_recursive/tst_qsortfilterproxymodel_recursive.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, authors Filipe Azevedo <filipe.azevedo@kdab.com> and David Faure <david.faure@kdab.com> -** 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) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, authors Filipe Azevedo <filipe.azevedo@kdab.com> and David Faure <david.faure@kdab.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include <QTest> #include <QSignalSpy> diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_regularexpression/tst_qsortfilterproxymodel_regularexpression.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel_regularexpression/tst_qsortfilterproxymodel_regularexpression.cpp index 39376b3499..bce7b1733d 100644 --- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel_regularexpression/tst_qsortfilterproxymodel_regularexpression.cpp +++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel_regularexpression/tst_qsortfilterproxymodel_regularexpression.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 WITH Qt-GPL-exception-1.0 #include <QTest> #include <QSignalSpy> diff --git a/tests/auto/corelib/itemmodels/qstringlistmodel/qmodellistener.h b/tests/auto/corelib/itemmodels/qstringlistmodel/qmodellistener.h index e08a0bdb1f..0ea058d0ec 100644 --- a/tests/auto/corelib/itemmodels/qstringlistmodel/qmodellistener.h +++ b/tests/auto/corelib/itemmodels/qstringlistmodel/qmodellistener.h @@ -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 WITH Qt-GPL-exception-1.0 #include <QObject> #include <QModelIndex> diff --git a/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp b/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp index 5fe8784768..ac2eda0ef0 100644 --- a/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp +++ b/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.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 WITH Qt-GPL-exception-1.0 #include <QTest> #include <QSignalSpy> diff --git a/tests/auto/corelib/itemmodels/qtransposeproxymodel/tst_qtransposeproxymodel.cpp b/tests/auto/corelib/itemmodels/qtransposeproxymodel/tst_qtransposeproxymodel.cpp index f577c3c41b..353d700e2d 100644 --- a/tests/auto/corelib/itemmodels/qtransposeproxymodel/tst_qtransposeproxymodel.cpp +++ b/tests/auto/corelib/itemmodels/qtransposeproxymodel/tst_qtransposeproxymodel.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2018 Luca Beldi <v.ronin@yahoo.it> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** 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-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2018 Luca Beldi <v.ronin@yahoo.it> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include <QTest> #include <QSignalSpy> diff --git a/tests/auto/corelib/kernel/CMakeLists.txt b/tests/auto/corelib/kernel/CMakeLists.txt index 18f20bfadc..3083652945 100644 --- a/tests/auto/corelib/kernel/CMakeLists.txt +++ b/tests/auto/corelib/kernel/CMakeLists.txt @@ -49,4 +49,5 @@ endif() if(ANDROID) add_subdirectory(qjnienvironment) add_subdirectory(qjniobject) + add_subdirectory(qjnitypes) endif() diff --git a/tests/auto/corelib/kernel/qapplicationstatic/tst_qapplicationstatic.cpp b/tests/auto/corelib/kernel/qapplicationstatic/tst_qapplicationstatic.cpp index 9972e050db..987a20a589 100644 --- a/tests/auto/corelib/kernel/qapplicationstatic/tst_qapplicationstatic.cpp +++ b/tests/auto/corelib/kernel/qapplicationsta |