diff options
Diffstat (limited to 'tests/auto/corelib')
1347 files changed, 32871 insertions, 36008 deletions
diff --git a/tests/auto/corelib/CMakeLists.txt b/tests/auto/corelib/CMakeLists.txt index b9bf269745..7654fe0c20 100644 --- a/tests/auto/corelib/CMakeLists.txt +++ b/tests/auto/corelib/CMakeLists.txt @@ -1,10 +1,12 @@ -# Generated from corelib.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause add_subdirectory(kernel) if(NOT UIKIT) add_subdirectory(animation) add_subdirectory(global) add_subdirectory(io) + add_subdirectory(ipc) add_subdirectory(itemmodels) add_subdirectory(mimetypes) add_subdirectory(plugin) diff --git a/tests/auto/corelib/animation/CMakeLists.txt b/tests/auto/corelib/animation/CMakeLists.txt index 79c2d6c4e9..85c121d243 100644 --- a/tests/auto/corelib/animation/CMakeLists.txt +++ b/tests/auto/corelib/animation/CMakeLists.txt @@ -1,4 +1,5 @@ -# Generated from animation.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause add_subdirectory(qabstractanimation) add_subdirectory(qanimationgroup) diff --git a/tests/auto/corelib/animation/qabstractanimation/CMakeLists.txt b/tests/auto/corelib/animation/qabstractanimation/CMakeLists.txt index 1ab378546d..14e09b314e 100644 --- a/tests/auto/corelib/animation/qabstractanimation/CMakeLists.txt +++ b/tests/auto/corelib/animation/qabstractanimation/CMakeLists.txt @@ -1,4 +1,5 @@ -# Generated from qabstractanimation.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_qabstractanimation Test: 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/CMakeLists.txt b/tests/auto/corelib/animation/qanimationgroup/CMakeLists.txt index 5dcdf49836..da7f8b69a3 100644 --- a/tests/auto/corelib/animation/qanimationgroup/CMakeLists.txt +++ b/tests/auto/corelib/animation/qanimationgroup/CMakeLists.txt @@ -1,4 +1,5 @@ -# Generated from qanimationgroup.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_qanimationgroup Test: diff --git a/tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp b/tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp index a5cb2c021e..af84961531 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> @@ -134,7 +109,7 @@ void tst_QAnimationGroup::emptyGroup() QCOMPARE(group.state(), QAnimationGroup::Stopped); group.start(); - QCOMPARE(groupStateChangedSpy.count(), 2); + QCOMPARE(groupStateChangedSpy.size(), 2); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(groupStateChangedSpy.at(0).first()), QAnimationGroup::Running); @@ -146,7 +121,7 @@ void tst_QAnimationGroup::emptyGroup() QTest::ignoreMessage(QtWarningMsg, "QAbstractAnimation::pause: Cannot pause a stopped animation"); group.pause(); - QCOMPARE(groupStateChangedSpy.count(), 2); + QCOMPARE(groupStateChangedSpy.size(), 2); QCOMPARE(group.state(), QAnimationGroup::Stopped); group.start(); @@ -160,7 +135,7 @@ void tst_QAnimationGroup::emptyGroup() group.stop(); - QCOMPARE(groupStateChangedSpy.count(), 4); + QCOMPARE(groupStateChangedSpy.size(), 4); QCOMPARE(group.state(), QAnimationGroup::Stopped); } @@ -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/CMakeLists.txt b/tests/auto/corelib/animation/qparallelanimationgroup/CMakeLists.txt index 9a6c9f45db..5959440f0a 100644 --- a/tests/auto/corelib/animation/qparallelanimationgroup/CMakeLists.txt +++ b/tests/auto/corelib/animation/qparallelanimationgroup/CMakeLists.txt @@ -1,4 +1,5 @@ -# Generated from qparallelanimationgroup.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_qparallelanimationgroup Test: diff --git a/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp b/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp index 6cf7e5cb94..3c5d9ed3a9 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> @@ -259,38 +234,38 @@ void tst_QParallelAnimationGroup::stateChanged() //first; let's start forward group.start(); //all the animations should be started - QCOMPARE(spy1.count(), 1); + QCOMPARE(spy1.size(), 1); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy1.last().first()), TestAnimation::Running); - QCOMPARE(spy2.count(), 1); + QCOMPARE(spy2.size(), 1); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy2.last().first()), TestAnimation::Running); - QCOMPARE(spy3.count(), 1); + QCOMPARE(spy3.size(), 1); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy3.last().first()), TestAnimation::Running); - QCOMPARE(spy4.count(), 1); + QCOMPARE(spy4.size(), 1); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy4.last().first()), TestAnimation::Running); group.setCurrentTime(1500); //anim1 should be finished QCOMPARE(group.state(), QAnimationGroup::Running); - QCOMPARE(spy1.count(), 2); + QCOMPARE(spy1.size(), 2); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy1.last().first()), TestAnimation::Stopped); - QCOMPARE(spy2.count(), 1); //no change - QCOMPARE(spy3.count(), 1); //no change - QCOMPARE(spy4.count(), 1); //no change + QCOMPARE(spy2.size(), 1); //no change + QCOMPARE(spy3.size(), 1); //no change + QCOMPARE(spy4.size(), 1); //no change group.setCurrentTime(2500); //anim2 should be finished QCOMPARE(group.state(), QAnimationGroup::Running); - QCOMPARE(spy1.count(), 2); //no change - QCOMPARE(spy2.count(), 2); + QCOMPARE(spy1.size(), 2); //no change + QCOMPARE(spy2.size(), 2); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy2.last().first()), TestAnimation::Stopped); - QCOMPARE(spy3.count(), 1); //no change - QCOMPARE(spy4.count(), 1); //no change + QCOMPARE(spy3.size(), 1); //no change + QCOMPARE(spy4.size(), 1); //no change group.setCurrentTime(3500); //everything should be finished QCOMPARE(group.state(), QAnimationGroup::Stopped); - QCOMPARE(spy1.count(), 2); //no change - QCOMPARE(spy2.count(), 2); //no change - QCOMPARE(spy3.count(), 2); + QCOMPARE(spy1.size(), 2); //no change + QCOMPARE(spy2.size(), 2); //no change + QCOMPARE(spy3.size(), 2); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy3.last().first()), TestAnimation::Stopped); - QCOMPARE(spy4.count(), 2); + QCOMPARE(spy4.size(), 2); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy4.last().first()), TestAnimation::Stopped); //cleanup @@ -305,38 +280,38 @@ void tst_QParallelAnimationGroup::stateChanged() //only anim3 and anim4 should be started QCOMPARE(group.state(), QAnimationGroup::Running); - QCOMPARE(spy1.count(), 0); - QCOMPARE(spy2.count(), 0); - QCOMPARE(spy3.count(), 1); + QCOMPARE(spy1.size(), 0); + QCOMPARE(spy2.size(), 0); + QCOMPARE(spy3.size(), 1); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy3.last().first()), TestAnimation::Running); - QCOMPARE(spy4.count(), 1); + QCOMPARE(spy4.size(), 1); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy4.last().first()), TestAnimation::Running); group.setCurrentTime(1500); //anim2 should be started QCOMPARE(group.state(), QAnimationGroup::Running); - QCOMPARE(spy1.count(), 0); //no change - QCOMPARE(spy2.count(), 1); + QCOMPARE(spy1.size(), 0); //no change + QCOMPARE(spy2.size(), 1); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy2.last().first()), TestAnimation::Running); - QCOMPARE(spy3.count(), 1); //no change - QCOMPARE(spy4.count(), 1); //no change + QCOMPARE(spy3.size(), 1); //no change + QCOMPARE(spy4.size(), 1); //no change group.setCurrentTime(500); //anim1 is finally also started QCOMPARE(group.state(), QAnimationGroup::Running); - QCOMPARE(spy1.count(), 1); + QCOMPARE(spy1.size(), 1); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy1.last().first()), TestAnimation::Running); - QCOMPARE(spy2.count(), 1); //no change - QCOMPARE(spy3.count(), 1); //no change - QCOMPARE(spy4.count(), 1); //no change + QCOMPARE(spy2.size(), 1); //no change + QCOMPARE(spy3.size(), 1); //no change + QCOMPARE(spy4.size(), 1); //no change group.setCurrentTime(0); //everything should be stopped QCOMPARE(group.state(), QAnimationGroup::Stopped); - QCOMPARE(spy1.count(), 2); + QCOMPARE(spy1.size(), 2); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy1.last().first()), TestAnimation::Stopped); - QCOMPARE(spy2.count(), 2); + QCOMPARE(spy2.size(), 2); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy2.last().first()), TestAnimation::Stopped); - QCOMPARE(spy3.count(), 2); + QCOMPARE(spy3.size(), 2); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy3.last().first()), TestAnimation::Stopped); - QCOMPARE(spy4.count(), 2); + QCOMPARE(spy4.size(), 2); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy4.last().first()), TestAnimation::Stopped); } @@ -430,8 +405,8 @@ void tst_QParallelAnimationGroup::updateChildrenWithRunningGroup() QVERIFY(groupStateChangedSpy.isValid()); QVERIFY(childStateChangedSpy.isValid()); - QCOMPARE(groupStateChangedSpy.count(), 0); - QCOMPARE(childStateChangedSpy.count(), 0); + QCOMPARE(groupStateChangedSpy.size(), 0); + QCOMPARE(childStateChangedSpy.size(), 0); QCOMPARE(group.state(), QAnimationGroup::Stopped); QCOMPARE(anim.state(), QAnimationGroup::Stopped); @@ -442,8 +417,8 @@ void tst_QParallelAnimationGroup::updateChildrenWithRunningGroup() QCOMPARE(group.state(), QAnimationGroup::Running); QCOMPARE(anim.state(), QAnimationGroup::Running); - QCOMPARE(groupStateChangedSpy.count(), 1); - QCOMPARE(childStateChangedSpy.count(), 1); + QCOMPARE(groupStateChangedSpy.size(), 1); + QCOMPARE(childStateChangedSpy.size(), 1); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(groupStateChangedSpy.at(0).first()), QAnimationGroup::Running); @@ -453,8 +428,8 @@ void tst_QParallelAnimationGroup::updateChildrenWithRunningGroup() // starting directly a running child will not have any effect anim.start(); - QCOMPARE(groupStateChangedSpy.count(), 1); - QCOMPARE(childStateChangedSpy.count(), 1); + QCOMPARE(groupStateChangedSpy.size(), 1); + QCOMPARE(childStateChangedSpy.size(), 1); anim.pause(); @@ -597,8 +572,8 @@ void tst_QParallelAnimationGroup::startGroupWithRunningChild() QVERIFY(stateChangedSpy1.isValid()); QVERIFY(stateChangedSpy2.isValid()); - QCOMPARE(stateChangedSpy1.count(), 0); - QCOMPARE(stateChangedSpy2.count(), 0); + QCOMPARE(stateChangedSpy1.size(), 0); + QCOMPARE(stateChangedSpy2.size(), 0); QCOMPARE(group.state(), QAnimationGroup::Stopped); QCOMPARE(anim1.state(), QAnimationGroup::Stopped); QCOMPARE(anim2.state(), QAnimationGroup::Stopped); @@ -623,13 +598,13 @@ void tst_QParallelAnimationGroup::startGroupWithRunningChild() group.start(); - QCOMPARE(stateChangedSpy1.count(), 3); + QCOMPARE(stateChangedSpy1.size(), 3); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy1.at(1).first()), QAnimationGroup::Stopped); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy1.at(2).first()), QAnimationGroup::Running); - QCOMPARE(stateChangedSpy2.count(), 4); + QCOMPARE(stateChangedSpy2.size(), 4); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy2.at(2).first()), QAnimationGroup::Stopped); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy2.at(3).first()), @@ -680,22 +655,22 @@ void tst_QParallelAnimationGroup::zeroDurationAnimation() group.addAnimation(&anim1); group.addAnimation(&anim2); group.addAnimation(&anim3); - QCOMPARE(stateChangedSpy1.count(), 0); + QCOMPARE(stateChangedSpy1.size(), 0); group.start(); - QCOMPARE(stateChangedSpy1.count(), 2); - QCOMPARE(finishedSpy1.count(), 1); + QCOMPARE(stateChangedSpy1.size(), 2); + QCOMPARE(finishedSpy1.size(), 1); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy1.at(0).first()), QAnimationGroup::Running); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy1.at(1).first()), QAnimationGroup::Stopped); - QCOMPARE(stateChangedSpy2.count(), 1); - QCOMPARE(finishedSpy2.count(), 0); + QCOMPARE(stateChangedSpy2.size(), 1); + QCOMPARE(finishedSpy2.size(), 0); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy1.at(0).first()), QAnimationGroup::Running); - QCOMPARE(stateChangedSpy3.count(), 1); - QCOMPARE(finishedSpy3.count(), 0); + QCOMPARE(stateChangedSpy3.size(), 1); + QCOMPARE(finishedSpy3.size(), 0); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy3.at(0).first()), QAnimationGroup::Running); @@ -713,21 +688,21 @@ void tst_QParallelAnimationGroup::zeroDurationAnimation() stateChangedSpy3.clear(); group.start(); - QCOMPARE(stateChangedSpy1.count(), 2); - QCOMPARE(stateChangedSpy2.count(), 1); - QCOMPARE(stateChangedSpy3.count(), 1); + QCOMPARE(stateChangedSpy1.size(), 2); + QCOMPARE(stateChangedSpy2.size(), 1); + QCOMPARE(stateChangedSpy3.size(), 1); group.setCurrentTime(50); - QCOMPARE(stateChangedSpy1.count(), 2); - QCOMPARE(stateChangedSpy2.count(), 1); - QCOMPARE(stateChangedSpy3.count(), 2); + QCOMPARE(stateChangedSpy1.size(), 2); + QCOMPARE(stateChangedSpy2.size(), 1); + QCOMPARE(stateChangedSpy3.size(), 2); group.setCurrentTime(150); - QCOMPARE(stateChangedSpy1.count(), 4); - QCOMPARE(stateChangedSpy2.count(), 3); - QCOMPARE(stateChangedSpy3.count(), 4); + QCOMPARE(stateChangedSpy1.size(), 4); + QCOMPARE(stateChangedSpy2.size(), 3); + QCOMPARE(stateChangedSpy3.size(), 4); group.setCurrentTime(50); - QCOMPARE(stateChangedSpy1.count(), 6); - QCOMPARE(stateChangedSpy2.count(), 5); - QCOMPARE(stateChangedSpy3.count(), 6); + QCOMPARE(stateChangedSpy1.size(), 6); + QCOMPARE(stateChangedSpy2.size(), 5); + QCOMPARE(stateChangedSpy3.size(), 6); } @@ -759,7 +734,7 @@ void tst_QParallelAnimationGroup::stopUncontrolledAnimations() group.start(); - QCOMPARE(stateChangedSpy.count(), 2); + QCOMPARE(stateChangedSpy.size(), 2); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy.at(0).first()), QAnimationGroup::Running); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy.at(1).first()), @@ -968,7 +943,7 @@ void tst_QParallelAnimationGroup::pauseResume() QTest::qWait(100); QCOMPARE(group.state(), QAnimationGroup::Running); QCOMPARE(anim->state(), QAnimationGroup::Running); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); spy.clear(); const int currentTime = group.currentLoopTime(); QCOMPARE(anim->currentLoopTime(), currentTime); @@ -978,7 +953,7 @@ void tst_QParallelAnimationGroup::pauseResume() QCOMPARE(group.currentLoopTime(), currentTime); QCOMPARE(anim->state(), QAnimationGroup::Paused); QCOMPARE(anim->currentLoopTime(), currentTime); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); spy.clear(); group.resume(); @@ -986,21 +961,21 @@ void tst_QParallelAnimationGroup::pauseResume() QCOMPARE(group.currentLoopTime(), currentTime); QCOMPARE(anim->state(), QAnimationGroup::Running); QCOMPARE(anim->currentLoopTime(), currentTime); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); group.stop(); spy.clear(); new TestAnimation2(500, &group); group.start(); - QCOMPARE(spy.count(), 1); //the animation should have been started + QCOMPARE(spy.size(), 1); //the animation should have been started QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy.last().first()), TestAnimation::Running); group.setCurrentTime(250); //end of first animation - QCOMPARE(spy.count(), 2); //the animation should have been stopped + QCOMPARE(spy.size(), 2); //the animation should have been stopped QCOMPARE(qvariant_cast<QAbstractAnimation::State>(spy.last().first()), TestAnimation::Stopped); group.pause(); - QCOMPARE(spy.count(), 2); //this shouldn't have changed + QCOMPARE(spy.size(), 2); //this shouldn't have changed group.resume(); - QCOMPARE(spy.count(), 2); //this shouldn't have changed + QCOMPARE(spy.size(), 2); //this shouldn't have changed } // This is a regression test for QTBUG-8910, where a crash occurred when the diff --git a/tests/auto/corelib/animation/qpauseanimation/CMakeLists.txt b/tests/auto/corelib/animation/qpauseanimation/CMakeLists.txt index bc846d33e7..a6ec4bffad 100644 --- a/tests/auto/corelib/animation/qpauseanimation/CMakeLists.txt +++ b/tests/auto/corelib/animation/qpauseanimation/CMakeLists.txt @@ -1,4 +1,5 @@ -# Generated from qpauseanimation.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_qpauseanimation Test: @@ -7,6 +8,6 @@ qt_internal_add_test(tst_qpauseanimation SOURCES tst_qpauseanimation.cpp - PUBLIC_LIBRARIES + LIBRARIES Qt::CorePrivate ) 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/CMakeLists.txt b/tests/auto/corelib/animation/qpropertyanimation/CMakeLists.txt index 89a4d0a8e1..627e716ba0 100644 --- a/tests/auto/corelib/animation/qpropertyanimation/CMakeLists.txt +++ b/tests/auto/corelib/animation/qpropertyanimation/CMakeLists.txt @@ -1,4 +1,5 @@ -# Generated from qpropertyanimation.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_qpropertyanimation Test: @@ -7,7 +8,7 @@ qt_internal_add_test(tst_qpropertyanimation SOURCES tst_qpropertyanimation.cpp - PUBLIC_LIBRARIES + LIBRARIES Qt::CorePrivate Qt::Gui Qt::Widgets diff --git a/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp index 1da69f8338..d739164a10 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()); @@ -308,9 +283,9 @@ void tst_QPropertyAnimation::statesAndSignals() anim->setCurrentTime(1); anim->setCurrentTime(100); - QCOMPARE(finishedSpy.count(), 0); - QCOMPARE(runningSpy.count(), 0); - QCOMPARE(currentLoopSpy.count(), 0); + QCOMPARE(finishedSpy.size(), 0); + QCOMPARE(runningSpy.size(), 0); + QCOMPARE(currentLoopSpy.size(), 0); QCOMPARE(anim->state(), QAnimationGroup::Stopped); anim->setLoopCount(3); @@ -319,26 +294,26 @@ void tst_QPropertyAnimation::statesAndSignals() if (uncontrolled) QSKIP("Uncontrolled animations don't handle looping"); - QCOMPARE(currentLoopSpy.count(), 1); + QCOMPARE(currentLoopSpy.size(), 1); QCOMPARE(anim->currentLoop(), 1); anim->setCurrentTime(0); - QCOMPARE(currentLoopSpy.count(), 2); + QCOMPARE(currentLoopSpy.size(), 2); QCOMPARE(anim->currentLoop(), 0); anim->start(); QCOMPARE(anim->state(), QAnimationGroup::Running); - QCOMPARE(runningSpy.count(), 1); //anim must have started + QCOMPARE(runningSpy.size(), 1); //anim must have started QCOMPARE(anim->currentLoop(), 0); runningSpy.clear(); anim->stop(); QCOMPARE(anim->state(), QAnimationGroup::Stopped); - QCOMPARE(runningSpy.count(), 1); //anim must have stopped - QCOMPARE(finishedSpy.count(), 0); + QCOMPARE(runningSpy.size(), 1); //anim must have stopped + QCOMPARE(finishedSpy.size(), 0); QCOMPARE(anim->currentLoopTime(), 0); QCOMPARE(anim->currentLoop(), 0); - QCOMPARE(currentLoopSpy.count(), 2); + QCOMPARE(currentLoopSpy.size(), 2); runningSpy.clear(); { @@ -346,33 +321,31 @@ void tst_QPropertyAnimation::statesAndSignals() anim->start(); timeDriver.wait(1000); QCOMPARE(anim->state(), QAnimationGroup::Stopped); - QCOMPARE(runningSpy.count(), 2); //started and stopped again + QCOMPARE(runningSpy.size(), 2); //started and stopped again runningSpy.clear(); - QCOMPARE(finishedSpy.count(), 1); + QCOMPARE(finishedSpy.size(), 1); QCOMPARE(anim->currentLoopTime(), 100); QCOMPARE(anim->currentLoop(), 2); - QCOMPARE(currentLoopSpy.count(), 4); + QCOMPARE(currentLoopSpy.size(), 4); anim->start(); // auto-rewinds QCOMPARE(anim->state(), QAnimationGroup::Running); QCOMPARE(anim->currentTime(), 0); QCOMPARE(anim->currentLoop(), 0); - QCOMPARE(currentLoopSpy.count(), 5); - QCOMPARE(runningSpy.count(), 1); // anim has started - QCOMPARE(finishedSpy.count(), 1); + QCOMPARE(currentLoopSpy.size(), 5); + QCOMPARE(runningSpy.size(), 1); // anim has started + QCOMPARE(finishedSpy.size(), 1); QCOMPARE(anim->currentLoop(), 0); runningSpy.clear(); timeDriver.wait(1000); - QCOMPARE(currentLoopSpy.count(), 7); + QCOMPARE(currentLoopSpy.size(), 7); QCOMPARE(anim->state(), QAnimationGroup::Stopped); QCOMPARE(anim->currentLoop(), 2); - QCOMPARE(runningSpy.count(), 1); // anim has stopped - QCOMPARE(finishedSpy.count(), 2); + QCOMPARE(runningSpy.size(), 1); // anim has stopped + QCOMPARE(finishedSpy.size(), 2); QCOMPARE(anim->currentLoopTime(), 100); - - delete anim; } } @@ -391,8 +364,8 @@ void tst_QPropertyAnimation::deletion1() anim->setEndValue(20); anim->setDuration(200); anim->start(); - QCOMPARE(runningSpy.count(), 1); - QCOMPARE(finishedSpy.count(), 0); + QCOMPARE(runningSpy.size(), 1); + QCOMPARE(finishedSpy.size(), 0); QVERIFY(anim); QCOMPARE(anim->state(), QAnimationGroup::Running); @@ -402,8 +375,8 @@ void tst_QPropertyAnimation::deletion1() timeDriver.wait(150); QVERIFY(anim); //The animation should not have been deleted QCOMPARE(anim->state(), QAnimationGroup::Stopped); - QCOMPARE(runningSpy.count(), 2); - QCOMPARE(finishedSpy.count(), 1); + QCOMPARE(runningSpy.size(), 2); + QCOMPARE(finishedSpy.size(), 1); anim->start(QVariantAnimation::DeleteWhenStopped); QVERIFY(anim); @@ -412,8 +385,8 @@ void tst_QPropertyAnimation::deletion1() QVERIFY(anim); QCOMPARE(anim->state(), QAnimationGroup::Running); timeDriver.wait(150); - QCOMPARE(runningSpy.count(), 4); - QCOMPARE(finishedSpy.count(), 2); + QCOMPARE(runningSpy.size(), 4); + QCOMPARE(finishedSpy.size(), 2); QVERIFY(!anim); //The animation must have been deleted delete object; } @@ -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); @@ -443,21 +417,25 @@ void tst_QPropertyAnimation::deletion2() QVERIFY(anim); QCOMPARE(anim->state(), QAnimationGroup::Running); - QCOMPARE(runningSpy.count(), 1); - QCOMPARE(finishedSpy.count(), 0); + QCOMPARE(runningSpy.size(), 1); + QCOMPARE(finishedSpy.size(), 0); //we can't call deletaLater directly because the delete would only happen in the next loop of _this_ event loop 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); @@ -473,11 +451,11 @@ void tst_QPropertyAnimation::deletion3() timeDriver.wait(50); QCOMPARE(anim->state(), QAnimationGroup::Running); - QCOMPARE(runningSpy.count(), 1); - QCOMPARE(finishedSpy.count(), 0); + QCOMPARE(runningSpy.size(), 1); + QCOMPARE(finishedSpy.size(), 0); delete anim; - QCOMPARE(runningSpy.count(), 2); - QCOMPARE(finishedSpy.count(), 0); + QCOMPARE(runningSpy.size(), 2); + QCOMPARE(finishedSpy.size(), 0); } void tst_QPropertyAnimation::duration0() @@ -569,7 +547,7 @@ void tst_QPropertyAnimation::startWhenAnotherIsRunning() QVERIFY(runningSpy.isValid()); anim->start(QVariantAnimation::DeleteWhenStopped); timeDriver.wait(anim->duration()); - QCOMPARE(runningSpy.count(), 2); //started and then stopped + QCOMPARE(runningSpy.size(), 2); //started and then stopped QVERIFY(!anim); } { @@ -581,7 +559,7 @@ void tst_QPropertyAnimation::startWhenAnotherIsRunning() timeDriver.wait(anim->duration()/2); QPointer<QVariantAnimation> anim2 = new QPropertyAnimation(&o, "ole"); anim2->setEndValue(100); - QCOMPARE(runningSpy.count(), 1); + QCOMPARE(runningSpy.size(), 1); QCOMPARE(anim->state(), QVariantAnimation::Running); //anim2 will interrupt anim1 @@ -930,7 +908,7 @@ void tst_QPropertyAnimation::zeroDurationStart() anim.start(); //the animation stops immediately QCOMPARE(anim.state(), QAbstractAnimation::Stopped); - QCOMPARE(spy.count(), 2); + QCOMPARE(spy.size(), 2); //let's check the first state change const QVariantList firstChange = spy.first(); @@ -1215,8 +1193,8 @@ void tst_QPropertyAnimation::valueChanged() QCOMPARE(anim.currentTime(), anim.duration()); //let's check that the values go forward - QCOMPARE(spy.count(), 6); //we should have got everything from 0 to 5 - for (int i = 0; i < spy.count(); ++i) { + QCOMPARE(spy.size(), 6); //we should have got everything from 0 to 5 + for (int i = 0; i < spy.size(); ++i) { QCOMPARE(qvariant_cast<QVariant>(spy.at(i).first()).toInt(), i); } } @@ -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); @@ -1346,15 +1324,15 @@ void tst_QPropertyAnimation::zeroLoopCount() QCOMPARE(anim->state(), QAnimationGroup::Stopped); QCOMPARE(anim->currentValue().toInt(), 0); - QCOMPARE(runningSpy.count(), 0); - QCOMPARE(finishedSpy.count(), 0); + QCOMPARE(runningSpy.size(), 0); + QCOMPARE(finishedSpy.size(), 0); anim->start(); QCOMPARE(anim->state(), QAnimationGroup::Stopped); QCOMPARE(anim->currentValue().toInt(), 0); - QCOMPARE(runningSpy.count(), 0); - QCOMPARE(finishedSpy.count(), 0); + QCOMPARE(runningSpy.size(), 0); + QCOMPARE(finishedSpy.size(), 0); } diff --git a/tests/auto/corelib/animation/qsequentialanimationgroup/CMakeLists.txt b/tests/auto/corelib/animation/qsequentialanimationgroup/CMakeLists.txt index e56f9f6ff8..61dca7c74d 100644 --- a/tests/auto/corelib/animation/qsequentialanimationgroup/CMakeLists.txt +++ b/tests/auto/corelib/animation/qsequentialanimationgroup/CMakeLists.txt @@ -1,4 +1,5 @@ -# Generated from qsequentialanimationgroup.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_qsequentialanimationgroup Test: diff --git a/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp b/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp index 779b225bfb..e6e8731378 100644 --- a/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp +++ b/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp @@ -1,33 +1,9 @@ -/**************************************************************************** -** -** 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> +#include <QProperty> #include <QPropertyAnimation> #include <QSignalSpy> #include <QParallelAnimationGroup> @@ -575,8 +551,8 @@ using StateList = QList<QAbstractAnimation::State>; static bool compareStates(const QSignalSpy& spy, const StateList &expectedStates) { bool equals = true; - for (int i = 0; i < qMax(expectedStates.count(), spy.count()); ++i) { - if (i >= spy.count() || i >= expectedStates.count()) { + for (int i = 0; i < qMax(expectedStates.size(), spy.size()); ++i) { + if (i >= spy.size() || i >= expectedStates.size()) { equals = false; break; } @@ -591,14 +567,14 @@ static bool compareStates(const QSignalSpy& spy, const StateList &expectedStates if (!equals) { const char *stateStrings[] = {"Stopped", "Paused", "Running"}; QString e,a; - for (int i = 0; i < qMax(expectedStates.count(), spy.count()); ++i) { - if (i < expectedStates.count()) { + for (int i = 0; i < qMax(expectedStates.size(), spy.size()); ++i) { + if (i < expectedStates.size()) { int exp = int(expectedStates.at(i)); if (!e.isEmpty()) e += QLatin1String(", "); e += QLatin1String(stateStrings[exp]); } - if (i < spy.count()) { + if (i < spy.size()) { QList<QVariant> args = spy.at(i); QAbstractAnimation::State actual = qvariant_cast<QAbstractAnimation::State>(args.value(1)); if (!a.isEmpty()) @@ -613,7 +589,7 @@ static bool compareStates(const QSignalSpy& spy, const StateList &expectedStates } qDebug("\n" "expected (count == %zd): %s\n" - "actual (count == %zd): %s\n", size_t(expectedStates.count()), qPrintable(e), size_t(spy.count()), qPrintable(a)); + "actual (count == %zd): %s\n", size_t(expectedStates.size()), qPrintable(e), size_t(spy.size()), qPrintable(a)); } return equals; } @@ -660,8 +636,8 @@ void tst_QSequentialAnimationGroup::pauseAndResume() QCOMPARE(a2_s_o1->state(), QAnimationGroup::Stopped); QCOMPARE(a3_s_o1->state(), QAnimationGroup::Paused); - QCOMPARE(a1StateChangedSpy.count(), 5); // Running,Paused,Stopped,Running,Stopped - QCOMPARE(seqStateChangedSpy.count(), 2); // Running,Paused + QCOMPARE(a1StateChangedSpy.size(), 5); // Running,Paused,Stopped,Running,Stopped + QCOMPARE(seqStateChangedSpy.size(), 2); // Running,Paused QVERIFY(compareStates(a1StateChangedSpy, (StateList() << QAbstractAnimation::Running << QAbstractAnimation::Paused @@ -702,7 +678,7 @@ void tst_QSequentialAnimationGroup::pauseAndResume() QCOMPARE(a3_s_o1->currentLoop(), 0); QVERIFY(a3_s_o1->currentLoopTime() >= 1); - QCOMPARE(seqStateChangedSpy.count(), 3); // Running,Paused,Running + QCOMPARE(seqStateChangedSpy.size(), 3); // Running,Paused,Running QCOMPARE(qvariant_cast<QAbstractAnimation::State>(seqStateChangedSpy.at(2).first()), QAnimationGroup::Running); @@ -723,13 +699,13 @@ void tst_QSequentialAnimationGroup::pauseAndResume() QCOMPARE(a3_s_o1->currentLoop(), 0); QVERIFY(a3_s_o1->currentLoopTime() >= 1); - QCOMPARE(seqStateChangedSpy.count(), 4); // Running,Paused,Running,Paused + QCOMPARE(seqStateChangedSpy.size(), 4); // Running,Paused,Running,Paused QCOMPARE(qvariant_cast<QAbstractAnimation::State>(seqStateChangedSpy.at(3).first()), QAnimationGroup::Paused); group.stop(); - QCOMPARE(seqStateChangedSpy.count(), 5); // Running,Paused,Running,Paused,Stopped + QCOMPARE(seqStateChangedSpy.size(), 5); // Running,Paused,Running,Paused,Stopped QCOMPARE(qvariant_cast<QAbstractAnimation::State>(seqStateChangedSpy.at(4).first()), QAnimationGroup::Stopped); } @@ -773,7 +749,7 @@ void tst_QSequentialAnimationGroup::restart() QTRY_COMPARE(group.state(), QAnimationGroup::Stopped); for (int i = 0; i < 3; i++) { - QCOMPARE(animsStateChanged[i]->count(), 4); + QCOMPARE(animsStateChanged[i]->size(), 4); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(animsStateChanged[i]->at(0).first()), QAnimationGroup::Running); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(animsStateChanged[i]->at(1).first()), @@ -784,22 +760,22 @@ void tst_QSequentialAnimationGroup::restart() QAnimationGroup::Stopped); } - QCOMPARE(seqStateChangedSpy.count(), 2); + QCOMPARE(seqStateChangedSpy.size(), 2); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(seqStateChangedSpy.at(0).first()), QAnimationGroup::Running); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(seqStateChangedSpy.at(1).first()), QAnimationGroup::Stopped); - QCOMPARE(seqCurrentAnimChangedSpy.count(), 6); - for(int i=0; i<seqCurrentAnimChangedSpy.count(); i++) + QCOMPARE(seqCurrentAnimChangedSpy.size(), 6); + for(int i=0; i<seqCurrentAnimChangedSpy.size(); i++) QCOMPARE(static_cast<QAbstractAnimation*>(anims[i%3]), qvariant_cast<QAbstractAnimation*>(seqCurrentAnimChangedSpy.at(i).at(0))); group.start(); - QCOMPARE(animsStateChanged[0]->count(), 5); - QCOMPARE(animsStateChanged[1]->count(), 4); - QCOMPARE(animsStateChanged[2]->count(), 4); - QCOMPARE(seqStateChangedSpy.count(), 3); + QCOMPARE(animsStateChanged[0]->size(), 5); + QCOMPARE(animsStateChanged[1]->size(), 4); + QCOMPARE(animsStateChanged[2]->size(), 4); + QCOMPARE(seqStateChangedSpy.size(), 3); } void tst_QSequentialAnimationGroup::looping() @@ -855,21 +831,21 @@ void tst_QSequentialAnimationGroup::looping() QCOMPARE(a2_s_o1->state(), QAnimationGroup::Stopped); QCOMPARE(a3_s_o1->state(), QAnimationGroup::Paused); - QCOMPARE(a1Spy.count(), 5); // Running,Paused,Stopped,Running,Stopped + QCOMPARE(a1Spy.size(), 5); // Running,Paused,Stopped,Running,Stopped QVERIFY(compareStates(a1Spy, (StateList() << QAbstractAnimation::Running << QAbstractAnimation::Paused << QAbstractAnimation::Stopped << QAbstractAnimation::Running << QAbstractAnimation::Stopped))); - QCOMPARE(a2Spy.count(), 4); // Running,Stopped,Running,Stopped + QCOMPARE(a2Spy.size(), 4); // Running,Stopped,Running,Stopped QVERIFY(compareStates(a3Spy, (StateList() << QAbstractAnimation::Running << QAbstractAnimation::Stopped << QAbstractAnimation::Running << QAbstractAnimation::Paused))); - QCOMPARE(seqSpy.count(), 2); // Running,Paused - QCOMPARE(groupSpy.count(), 2); // Running,Paused + QCOMPARE(seqSpy.size(), 2); // Running,Paused + QCOMPARE(groupSpy.size(), 2); // Running,Paused // Looping, current time = duration + 1 group.setCurrentTime(group.duration() + 1); @@ -890,8 +866,8 @@ void tst_QSequentialAnimationGroup::looping() QCOMPARE(a2_s_o1->state(), QAnimationGroup::Stopped); QCOMPARE(a3_s_o1->state(), QAnimationGroup::Stopped); - QCOMPARE(a1Spy.count(), 7); // Running,Paused,Stopped,Running,Stopped,Running,Stopped - QCOMPARE(a2Spy.count(), 4); // Running, Stopped, Running, Stopped + QCOMPARE(a1Spy.size(), 7); // Running,Paused,Stopped,Running,Stopped,Running,Stopped + QCOMPARE(a2Spy.size(), 4); // Running, Stopped, Running, Stopped QVERIFY(compareStates(a3Spy, (StateList() << QAbstractAnimation::Running << QAbstractAnimation::Stopped << QAbstractAnimation::Running @@ -902,7 +878,7 @@ void tst_QSequentialAnimationGroup::looping() << QAbstractAnimation::Stopped << QAbstractAnimation::Running << QAbstractAnimation::Paused))); - QCOMPARE(groupSpy.count(), 2); + QCOMPARE(groupSpy.size(), 2); } void tst_QSequentialAnimationGroup::startDelay() @@ -1101,8 +1077,8 @@ void tst_QSequentialAnimationGroup::updateChildrenWithRunningGroup() QVERIFY(groupStateChangedSpy.isValid()); QVERIFY(childStateChangedSpy.isValid()); - QCOMPARE(groupStateChangedSpy.count(), 0); - QCOMPARE(childStateChangedSpy.count(), 0); + QCOMPARE(groupStateChangedSpy.size(), 0); + QCOMPARE(childStateChangedSpy.size(), 0); QCOMPARE(group.state(), QAnimationGroup::Stopped); QCOMPARE(anim.state(), QAnimationGroup::Stopped); @@ -1113,8 +1089,8 @@ void tst_QSequentialAnimationGroup::updateChildrenWithRunningGroup() QCOMPARE(group.state(), QAnimationGroup::Running); QCOMPARE(anim.state(), QAnimationGroup::Running); - QCOMPARE(groupStateChangedSpy.count(), 1); - QCOMPARE(childStateChangedSpy.count(), 1); + QCOMPARE(groupStateChangedSpy.size(), 1); + QCOMPARE(childStateChangedSpy.size(), 1); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(groupStateChangedSpy.at(0).first()), QAnimationGroup::Running); @@ -1124,8 +1100,8 @@ void tst_QSequentialAnimationGroup::updateChildrenWithRunningGroup() // starting directly a running child will not have any effect anim.start(); - QCOMPARE(groupStateChangedSpy.count(), 1); - QCOMPARE(childStateChangedSpy.count(), 1); + QCOMPARE(groupStateChangedSpy.size(), 1); + QCOMPARE(childStateChangedSpy.size(), 1); anim.pause(); @@ -1268,8 +1244,8 @@ void tst_QSequentialAnimationGroup::startGroupWithRunningChild() QVERIFY(stateChangedSpy1.isValid()); QVERIFY(stateChangedSpy2.isValid()); - QCOMPARE(stateChangedSpy1.count(), 0); - QCOMPARE(stateChangedSpy2.count(), 0); + QCOMPARE(stateChangedSpy1.size(), 0); + QCOMPARE(stateChangedSpy2.size(), 0); QCOMPARE(group.state(), QAnimationGroup::Stopped); QCOMPARE(anim1->state(), QAnimationGroup::Stopped); QCOMPARE(anim2->state(), QAnimationGroup::Stopped); @@ -1307,7 +1283,7 @@ void tst_QSequentialAnimationGroup::startGroupWithRunningChild() QCOMPARE(group.state(), QAnimationGroup::Running); QCOMPARE(anim2->state(), QAnimationGroup::Running); - QCOMPARE(stateChangedSpy2.count(), 4); + QCOMPARE(stateChangedSpy2.size(), 4); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy2.at(2).first()), QAnimationGroup::Stopped); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy2.at(3).first()), @@ -1347,7 +1323,7 @@ void tst_QSequentialAnimationGroup::zeroDurationAnimation() group.setLoopCount(2); group.start(); - QCOMPARE(stateChangedSpy.count(), 2); + QCOMPARE(stateChangedSpy.size(), 2); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy.at(0).first()), QAnimationGroup::Running); QCOMPARE(qvariant_cast<QAbstractAnimation::State>(stateChangedSpy.at(1).first()), @@ -1424,7 +1400,7 @@ void tst_QSequentialAnimationGroup::finishWithUncontrolledAnimation() const int actualDuration = notTimeDriven.currentLoopTime(); QCOMPARE(group.state(), QAnimationGroup::Stopped); QCOMPARE(group.currentLoopTime(), actualDuration); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); //2nd case: // lets make sure the seeking will work again @@ -1440,29 +1416,29 @@ void tst_QSequentialAnimationGroup::finishWithUncontrolledAnimation() //3rd case: //now let's add a perfectly defined animation at the end - QCOMPARE(animStateChangedSpy.count(), 0); + QCOMPARE(animStateChangedSpy.size(), 0); group.start(); QCOMPARE(group.state(), QAnimationGroup::Running); QCOMPARE(notTimeDriven.state(), QAnimationGroup::Running); QCOMPARE(group.currentLoopTime(), 0); QCOMPARE(notTimeDriven.currentLoopTime(), 0); - QCOMPARE(animStateChangedSpy.count(), 0); + QCOMPARE(animStateChangedSpy.size(), 0); QTest::qWait(300); //wait for the end of notTimeDriven QTRY_COMPARE(notTimeDriven.state(), QAnimationGroup::Stopped); QCOMPARE(group.state(), QAnimationGroup::Running); QCOMPARE(anim.state(), QAnimationGroup::Running); QCOMPARE(group.currentAnimation(), static_cast<QAbstractAnimation*>(&anim)); - QCOMPARE(animStateChangedSpy.count(), 1); + QCOMPARE(animStateChangedSpy.size(), 1); QTest::qWait(300); //wait for the end of anim QTRY_COMPARE(anim.state(), QAnimationGroup::Stopped); QCOMPARE(anim.currentLoopTime(), anim.duration()); //we should simply be at the end - QCOMPARE(spy.count(), 1); - QCOMPARE(animStateChangedSpy.count(), 2); + QCOMPARE(spy.size(), 1); + QCOMPARE(animStateChangedSpy.size(), 2); QCOMPARE(group.currentLoopTime(), notTimeDriven.currentLoopTime() + anim.currentLoopTime()); } @@ -1647,7 +1623,7 @@ void tst_QSequentialAnimationGroup::pauseResume() QTest::qWait(100); QTRY_COMPARE(group.state(), QAnimationGroup::Running); QCOMPARE(anim->state(), QAnimationGroup::Running); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); spy.clear(); const int currentTime = group.currentLoopTime(); QCOMPARE(anim->currentLoopTime(), currentTime); @@ -1657,7 +1633,7 @@ void tst_QSequentialAnimationGroup::pauseResume() QCOMPARE(group.currentLoopTime(), currentTime); QCOMPARE(anim->state(), QAnimationGroup::Paused); QCOMPARE(anim->currentLoopTime(), currentTime); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); spy.clear(); group.resume(); @@ -1665,7 +1641,7 @@ void tst_QSequentialAnimationGroup::pauseResume() QCOMPARE(group.currentLoopTime(), currentTime); QCOMPARE(anim->state(), QAnimationGroup::Running); QCOMPARE(anim->currentLoopTime(), currentTime); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); } void tst_QSequentialAnimationGroup::bindings() @@ -1691,18 +1667,18 @@ void tst_QSequentialAnimationGroup::bindings() group.setCurrentTime(int(totalDuration * 0.5 / 3)); QCOMPARE(currentAnim.value(), anim1.get()); - QCOMPARE(spy.count(), 0); + QCOMPARE(spy.size(), 0); group.setCurrentTime(int(totalDuration * 1.5 / 3)); QCOMPARE(currentAnim.value(), anim2.get()); - QCOMPARE(spy.count(), 1); + QCOMPARE(spy.size(), 1); // change to other style of formulating a binding to test both currentAnim.setBinding(group.bindableCurrentAnimation().makeBinding()); group.setCurrentTime(int(totalDuration * 2.5 / 3)); QCOMPARE(currentAnim.value(), anim3.get()); - QCOMPARE(spy.count(), 2); + QCOMPARE(spy.size(), 2); // currentAnimation is read-only. Binding it to something should have no effect QProperty<QAbstractAnimation *> leader; diff --git a/tests/auto/corelib/animation/qvariantanimation/CMakeLists.txt b/tests/auto/corelib/animation/qvariantanimation/CMakeLists.txt index 08fd743e33..34149c9a03 100644 --- a/tests/auto/corelib/animation/qvariantanimation/CMakeLists.txt +++ b/tests/auto/corelib/animation/qvariantanimation/CMakeLists.txt @@ -1,4 +1,5 @@ -# Generated from qvariantanimation.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_qvariantanimation Test: 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/CMakeLists.txt b/tests/auto/corelib/global/CMakeLists.txt index fe63402288..68574c396d 100644 --- a/tests/auto/corelib/global/CMakeLists.txt +++ b/tests/auto/corelib/global/CMakeLists.txt @@ -1,4 +1,6 @@ -# Generated from global.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + if(NOT INTEGRITY) add_subdirectory(qcompare) endif() @@ -18,6 +20,4 @@ add_subdirectory(qtendian) add_subdirectory(qglobalstatic) add_subdirectory(qhooks) add_subdirectory(qoperatingsystemversion) -if(WIN32) - add_subdirectory(qwinregistry) -endif() +add_subdirectory(qxp) diff --git a/tests/auto/corelib/global/q_func_info/CMakeLists.txt b/tests/auto/corelib/global/q_func_info/CMakeLists.txt index 93257c31de..98f8afad15 100644 --- a/tests/auto/corelib/global/q_func_info/CMakeLists.txt +++ b/tests/auto/corelib/global/q_func_info/CMakeLists.txt @@ -1,4 +1,5 @@ -# Generated from q_func_info.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_q_func_info Test: 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/CMakeLists.txt b/tests/auto/corelib/global/qcompare/CMakeLists.txt index 0fbf696d0e..1e0971ebcd 100644 --- a/tests/auto/corelib/global/qcompare/CMakeLists.txt +++ b/tests/auto/corelib/global/qcompare/CMakeLists.txt @@ -1,4 +1,5 @@ -# Generated from qcompare.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_qcompare Test: 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..54853bf792 100644 --- a/tests/auto/corelib/global/qflags/CMakeLists.txt +++ b/tests/auto/corelib/global/qflags/CMakeLists.txt @@ -1,4 +1,5 @@ -# Generated from qflags.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_qflags Test: @@ -9,5 +10,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..c3f69846aa 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() @@ -207,7 +301,7 @@ Q_DECLARE_FLAGS( MyStrictNoOpFlags, MyStrictNoOpEnum ) static_assert( !QTypeInfo<MyStrictFlags>::isComplex ); static_assert( QTypeInfo<MyStrictFlags>::isRelocatable ); -static_assert( !QTypeInfo<MyStrictFlags>::isPointer ); +static_assert( !std::is_pointer_v<MyStrictFlags> ); void tst_QFlags::classEnum() { @@ -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; @@ -377,7 +475,7 @@ Q_DECLARE_OPERATORS_FOR_FLAGS( MyFlags ) static_assert( !QTypeInfo<MyFlags>::isComplex ); static_assert( QTypeInfo<MyFlags>::isRelocatable ); -static_assert( !QTypeInfo<MyFlags>::isPointer ); +static_assert( !std::is_pointer_v<MyFlags> ); QTEST_MAIN(tst_QFlags) #include "tst_qflags.moc" diff --git a/tests/auto/corelib/global/qfloat16/CMakeLists.txt b/tests/auto/corelib/global/qfloat16/CMakeLists.txt index 1dbc95ec95..1ab6ecae71 100644 --- a/tests/auto/corelib/global/qfloat16/CMakeLists.txt +++ b/tests/auto/corelib/global/qfloat16/CMakeLists.txt @@ -1,4 +1,5 @@ -# Generated from qfloat16.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_qfloat16 Test: @@ -7,6 +8,6 @@ qt_internal_add_test(tst_qfloat16 SOURCES tst_qfloat16.cpp - PUBLIC_LIBRARIES + LIBRARIES Qt::TestPrivate ) diff --git a/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp b/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp index 35d7dbccf0..7260c2900d 100644 --- a/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp +++ b/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp @@ -1,34 +1,11 @@ -/**************************************************************************** -** -** 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> +#include <QMetaType> +#include <QTextStream> #include <math.h> @@ -66,6 +43,8 @@ private slots: void properties(); void limits(); void mantissaOverflow(); + void dataStream(); + void textStream(); }; void tst_qfloat16::fuzzyCompare_data() @@ -213,13 +192,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()); @@ -332,7 +305,7 @@ void tst_qfloat16::promotionTests() QCOMPARE(sizeof(double),sizeof(qfloat16(1.f)*1)); QCOMPARE(sizeof(double),sizeof(qfloat16(1.f)/1)); - QCOMPARE(QString::number(1.f),QString::number(qfloat16(1.f))); + QCOMPARE(QString::number(1.f),QString::number(double(qfloat16(1.f)))); } void tst_qfloat16::arithOps_data() @@ -540,14 +513,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 @@ -634,12 +628,67 @@ void tst_qfloat16::mantissaOverflow() float f; memcpy(&f, &in, 4); - qfloat16 f16 = f; + qfloat16 f16 = qfloat16(f); qfloat16 f16s[1]; qFloatToFloat16(f16s, &f, 1); QCOMPARE(f16, f16s[0]); QVERIFY(qIsNaN(f16)); } +void tst_qfloat16::dataStream() +{ + QByteArray ba; + QDataStream ds(&ba, QIODevice::ReadWrite); + ds << qfloat16(1.5) << qfloat16(-1); + QCOMPARE(ba.size(), 4); + QCOMPARE(ds.status(), QDataStream::Ok); + QCOMPARE(ba, QByteArray("\x3e\0\xbc\0", 4)); + + ds.device()->seek(0); + ds.resetStatus(); + ds.setByteOrder(QDataStream::LittleEndian); + ds << qfloat16(0) << qfloat16(-1); + QCOMPARE(ds.status(), QDataStream::Ok); + QCOMPARE(ba, QByteArray("\0\0\0\xbc", 4)); + + ds.device()->seek(0); + ds.resetStatus(); + qfloat16 zero = 1; + ds >> zero; + QCOMPARE(ds.status(), QDataStream::Ok); + QCOMPARE(zero, qfloat16(0)); + + ds.device()->seek(0); + ds.resetStatus(); + QMetaType mt = QMetaType(QMetaType::Float16); + QVERIFY(mt.save(ds, &zero)); + + ds.device()->seek(0); + ds.resetStatus(); + zero = -1; + QVERIFY(mt.load(ds, &zero)); + QCOMPARE(zero, qfloat16(0)); +} + +void tst_qfloat16::textStream() +{ + QString buffer; + { + QTextStream ts(&buffer); + ts << qfloat16(0) << Qt::endl << qfloat16(1.5); + QCOMPARE(ts.status(), QTextStream::Ok); + } + QCOMPARE(buffer, "0\n1.5"); + + { + QTextStream ts(&buffer); + qfloat16 zero = qfloat16(-2.5), threehalves = 1234; + ts >> zero >> threehalves; + QCOMPARE(ts.status(), QTextStream::Ok); + QCOMPARE(zero, qfloat16(0)); + QCOMPARE(threehalves, 1.5); + } +} + QTEST_APPLESS_MAIN(tst_qfloat16) #include "tst_qfloat16.moc" diff --git a/tests/auto/corelib/global/qgetputenv/CMakeLists.txt b/tests/auto/corelib/global/qgetputenv/CMakeLists.txt index 79d45c58b0..f6f18b1ab7 100644 --- a/tests/auto/corelib/global/qgetputenv/CMakeLists.txt +++ b/tests/auto/corelib/global/qgetputenv/CMakeLists.txt @@ -1,4 +1,5 @@ -# Generated from qgetputenv.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_qgetputenv Test: diff --git a/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp b/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp index 519c5fa88d..832319a652 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> @@ -85,7 +60,11 @@ void tst_QGetPutEnv::getSetCheck() QCOMPARE(sresult, QString()); #endif - QVERIFY(qputenv(varName, QByteArray("supervalue"))); + constexpr char varValueFullString[] = "supervalue123"; + const auto varValueQBA = QByteArray::fromRawData(varValueFullString, sizeof varValueFullString - 4); + QCOMPARE_EQ(varValueQBA, "supervalue"); + + QVERIFY(qputenv(varName, varValueQBA)); QVERIFY(qEnvironmentVariableIsSet(varName)); QVERIFY(!qEnvironmentVariableIsEmpty(varName)); @@ -212,7 +191,7 @@ void tst_QGetPutEnv::intValue() bool actualOk = !ok; // Self-test: confirm that it was like the docs said it should be - if (value.length() < maxlen) { + if (value.size() < maxlen) { QCOMPARE(value.toInt(&actualOk, 0), expected); QCOMPARE(actualOk, ok); } diff --git a/tests/auto/corelib/global/qglobal/CMakeLists.txt b/tests/auto/corelib/global/qglobal/CMakeLists.txt index de9a94629a..aded9e8c9f 100644 --- a/tests/auto/corelib/global/qglobal/CMakeLists.txt +++ b/tests/auto/corelib/global/qglobal/CMakeLists.txt @@ -1,4 +1,5 @@ -# Generated from qglobal.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_qglobal Test: diff --git a/tests/auto/corelib/global/qglobal/qglobal.c b/tests/auto/corelib/global/qglobal/qglobal.c index b577a6f71f..abe6ec4fde 100644 --- a/tests/auto/corelib/global/qglobal/qglobal.c +++ b/tests/auto/corelib/global/qglobal/qglobal.c @@ -1,41 +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 +#include <QtCore/qtversion.h> #ifdef Q_COMPILER_THREAD_LOCAL # include <threads.h> @@ -85,7 +52,8 @@ int tst_QtVersion() return QT_VERSION; } -const char *tst_qVersion() Q_DECL_NOEXCEPT +const char *tst_qVersion() Q_DECL_NOEXCEPT; +const char *tst_qVersion() { #if !defined(QT_NAMESPACE) return qVersion(); diff --git a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp index 7323cfe545..3f4e903a9a 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> @@ -33,6 +8,7 @@ #include <QSysInfo> #include <QLatin1String> #include <QString> +#include <QtVersion> #include <cmath> @@ -109,7 +85,7 @@ void tst_QGlobal::for_each() foreach(int i, list) { QCOMPARE(i, counter++); } - QCOMPARE(counter, list.count()); + QCOMPARE(counter, list.size()); // do it again, to make sure we don't have any for-scoping // problems with older compilers @@ -117,21 +93,21 @@ void tst_QGlobal::for_each() foreach(int i, list) { QCOMPARE(i, counter++); } - QCOMPARE(counter, list.count()); + QCOMPARE(counter, list.size()); // check whether we can pass a constructor as container argument counter = 0; foreach (int i, QList<int>(list)) { QCOMPARE(i, counter++); } - QCOMPARE(counter, list.count()); + QCOMPARE(counter, list.size()); // check whether we can use a lambda counter = 0; foreach (int i, [&](){ return list; }()) { QCOMPARE(i, counter++); } - QCOMPARE(counter, list.count()); + QCOMPARE(counter, list.size()); // Should also work with an existing variable int local = 0; @@ -139,7 +115,7 @@ void tst_QGlobal::for_each() foreach (local, list) { QCOMPARE(local, counter++); } - QCOMPARE(counter, list.count()); + QCOMPARE(counter, list.size()); QCOMPARE(local, counter - 1); // Test the macro does not mess if/else conditions @@ -149,7 +125,7 @@ void tst_QGlobal::for_each() QCOMPARE(i, counter++); else QFAIL("If/Else mismatch"); - QCOMPARE(counter, list.count()); + QCOMPARE(counter, list.size()); counter = 0; if (false) @@ -160,7 +136,7 @@ void tst_QGlobal::for_each() foreach (int i, list) if (false) { } else QCOMPARE(i, counter++); - QCOMPARE(counter, list.count()); + QCOMPARE(counter, list.size()); // break and continue counter = 0; diff --git a/tests/auto/corelib/global/qglobalstatic/CMakeLists.txt b/tests/auto/corelib/global/qglobalstatic/CMakeLists.txt index ea978bdadb..0d09598e79 100644 --- a/tests/auto/corelib/global/qglobalstatic/CMakeLists.txt +++ b/tests/auto/corelib/global/qglobalstatic/CMakeLists.txt @@ -1,4 +1,5 @@ -# Generated from qglobalstatic.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_qglobalstatic Test: @@ -8,7 +9,7 @@ qt_internal_add_test(tst_qglobalstatic EXCEPTIONS SOURCES tst_qglobalstatic.cpp - PUBLIC_LIBRARIES + LIBRARIES Qt::CorePrivate Qt::TestPrivate ) 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/CMakeLists.txt b/tests/auto/corelib/global/qhooks/CMakeLists.txt index c8d6f1a769..71812c4c53 100644 --- a/tests/auto/corelib/global/qhooks/CMakeLists.txt +++ b/tests/auto/corelib/global/qhooks/CMakeLists.txt @@ -1,4 +1,5 @@ -# Generated from qhooks.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_qhooks Test: @@ -7,6 +8,6 @@ qt_internal_add_test(tst_qhooks SOURCES tst_qhooks.cpp - PUBLIC_LIBRARIES + LIBRARIES Qt::CorePrivate ) 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/CMakeLists.txt b/tests/auto/corelib/global/qkeycombination/CMakeLists.txt index 9553a35dea..a49ecd1709 100644 --- a/tests/auto/corelib/global/qkeycombination/CMakeLists.txt +++ b/tests/auto/corelib/global/qkeycombination/CMakeLists.txt @@ -1,4 +1,5 @@ -# Generated from qkeycombination.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_qkeycombination Test: 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/CMakeLists.txt b/tests/auto/corelib/global/qlogging/CMakeLists.txt index a9950d3414..bfbf62dccd 100644 --- a/tests/auto/corelib/global/qlogging/CMakeLists.txt +++ b/tests/auto/corelib/global/qlogging/CMakeLists.txt @@ -1,6 +1,5 @@ -# Generated from qlogging.pro. -# This file is almost completely custom written -# special case skip regeneration +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause qt_internal_add_executable(qlogging_helper NO_INSTALL @@ -18,12 +17,10 @@ set_target_properties(qlogging_helper PROPERTIES CXX_VISIBILITY_PRESET default) qt_internal_add_test(tst_qlogging SOURCES tst_qlogging.cpp DEFINES QT_MESSAGELOGCONTEXT - QT_DISABLE_DEPRECATED_BEFORE=0 HELPER_BINARY="${CMAKE_CURRENT_BINARY_DIR}/qlogging_helper" ) qt_internal_add_test(tst_qmessagelogger SOURCES tst_qmessagelogger.cpp DEFINES QT_MESSAGELOGCONTEXT - QT_DISABLE_DEPRECATED_BEFORE=0 ) 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..665da3ff22 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 { @@ -52,6 +30,8 @@ private slots: #ifdef QT_BUILD_INTERNAL void cleanupFuncinfo_data(); void cleanupFuncinfo(); + void cleanupFuncinfoBad_data(); + void cleanupFuncinfoBad(); #endif void qMessagePattern_data(); @@ -62,7 +42,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 +72,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) } @@ -189,9 +168,13 @@ public: int operator%(int) { ADD("TestClass1::operator%"); return 0; } int x; int &operator++() { ADD("TestClass1::operator++"); return x; } - int operator++(int) { ADD("TestClass1::operator++"); return 0; } int &operator--() { ADD("TestClass1::operator--"); return x; } - int operator--(int) { ADD("TestClass1::operator--"); return 0; } + + // slightly different to avoid duplicate test rows +#define ADD2(x) QTest::newRow(x ".postfix") << Q_FUNC_INFO << x; + int operator++(int) { ADD2("TestClass1::operator++"); return 0; } + int operator--(int) { ADD2("TestClass1::operator--"); return 0; } +#undef ADD2 int nested_struct() { @@ -553,7 +536,7 @@ void tst_qmessagehandler::cleanupFuncinfo_data() QTest::newRow("msvc_28") << "class std::map<long,void const *,struct std::less<long>,class std::allocator<struct std::pair<long const ,void const *> > > *__thiscall TestClass2<class std::map<long,void const *,struct std::less<long>,class std::allocator<struct std::pair<long const ,void const *> > > >::func_template1<class TestClass2<class std::map<long,void const *,struct std::less<long>,class std::allocator<struct std::pair<long const ,void const *> > > >>(void)" << "TestClass2::func_template1"; - QTest::newRow("gcc_21") + QTest::newRow("gcc_28") << "T* TestClass2<T>::func_template1() [with S = TestClass2<std::map<long int, const void*, std::less<long int>, std::allocator<std::pair<const long int, const void*> > > >, T = std::map<long int, const void*, std::less<long int>, std::allocator<std::pair<const long int, const void*> > >]" << "TestClass2::func_template1"; @@ -622,6 +605,26 @@ void tst_qmessagehandler::cleanupFuncinfo_data() << "int TestClass1::operator>(int)" << "TestClass1::operator>"; + QTest::newRow("gcc_40") + << "Polymorphic<void (*)(int)>::~Polymorphic()" + << "Polymorphic::~Polymorphic"; + + QTest::newRow("gcc_41") + << "function<void (int*)>()::S::f()" + << "function()::S::f"; + + QTest::newRow("msvc_41") + << "void `void function<void __cdecl(int *)>(void)'::`2'::S::f(void)" + << "function(void)'::`2'::S::f"; + + QTest::newRow("gcc_42") + << "function<Polymorphic<void (int*)> >()::S::f(Polymorphic<void (int*)>*)" + << "function()::S::f"; + + QTest::newRow("msvc_42") + << "void `void function<Polymorphic<void __cdecl(int *)> >(void)'::`2'::S::f(Polymorphic<void __cdecl(int *)> *)" + << "function(void)'::`2'::S::f"; + QTest::newRow("objc_1") << "-[SomeClass someMethod:withArguments:]" << "-[SomeClass someMethod:withArguments:]"; @@ -637,6 +640,14 @@ void tst_qmessagehandler::cleanupFuncinfo_data() QTest::newRow("objc_4") << "__31-[SomeClass someMethodSchedulingBlock]_block_invoke" << "__31-[SomeClass someMethodSchedulingBlock]_block_invoke"; + + QTest::newRow("thunk-1") + << "non-virtual thunk to QFutureWatcherBasePrivate::postCallOutEvent(QFutureCallOutEvent const&)" + << "QFutureWatcherBasePrivate::postCallOutEvent"; + + QTest::newRow("thunk-2") + << "virtual thunk to std::basic_iostream<char, std::char_traits<char> >::~basic_iostream()" + << "std::basic_iostream::~basic_iostream"; } #endif @@ -657,6 +668,41 @@ void tst_qmessagehandler::cleanupFuncinfo() QEXPECT_FAIL("TestClass1::nested_struct_const", "Nested function processing is broken", Continue); QTEST(QString::fromLatin1(result), "expected"); } + +void tst_qmessagehandler::cleanupFuncinfoBad_data() +{ + QTest::addColumn<QByteArray>("funcinfo"); + + auto addBadFrame = [i = 0](const char *symbol) mutable { + QTest::addRow("%d", ++i) << QByteArray(symbol); + }; + addBadFrame("typeinfo for QEventLoop"); + addBadFrame("typeinfo name for QtPrivate::ResultStoreBase"); + addBadFrame("typeinfo name for ._anon_476"); + addBadFrame("typeinfo name for std::__1::__function::__base<bool (void*, void*)>"); + addBadFrame("vtable for BezierEase"); + addBadFrame("vtable for Polymorphic<void ()>"); + addBadFrame("vtable for Polymorphic<void (*)(int)>"); + addBadFrame("TLS wrapper function for (anonymous namespace)::jitStacks"); + addBadFrame("lcCheckIndex()::category"); + addBadFrame("guard variable for lcEPDetach()::category"); + addBadFrame("guard variable for QImageReader::read(QImage*)::disableNxImageLoading"); + addBadFrame("VTT for std::__1::ostrstream"); + addBadFrame("qIsRelocatable<(anonymous namespace)::Data>"); + addBadFrame("qt_incomplete_metaTypeArray<(anonymous namespace)::qt_meta_stringdata_CLASSQNonContiguousByteDeviceIoDeviceImplENDCLASS_t, QtPrivate::TypeAndForceComplete<void, std::integral_constant<bool, true> > >"); + addBadFrame("f()::i"); +} + +void tst_qmessagehandler::cleanupFuncinfoBad() +{ + QFETCH(QByteArray, funcinfo); + + // A corrupted stack trace may find non-sensical symbols that aren't + // functions. The result doesn't matter, so long as we don't crash or hang. + + QByteArray result = qCleanupFuncinfo(funcinfo); + qDebug() << "Decode of" << funcinfo << "produced" << result; +} #endif void tst_qmessagehandler::qMessagePattern_data() @@ -667,16 +713,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>() @@ -739,28 +785,39 @@ void tst_qmessagehandler::qMessagePattern_data() #define BACKTRACE_HELPER_NAME "qlogging_helper" -#ifdef __GLIBC__ #ifdef QT_NAMESPACE #define QT_NAMESPACE_STR QT_STRINGIFY(QT_NAMESPACE::) #else #define QT_NAMESPACE_STR "" #endif -#if QT_CONFIG(static) - QSKIP("These test cases don't work with static Qt builds"); -#else -#ifndef QT_NO_DEBUG - QTest::newRow("backtrace") << "[%{backtrace}] %{message}" << true << (QList<QByteArray>() - // MyClass::qt_static_metacall is explicitly marked as hidden in the Q_OBJECT macro - << "[MyClass::myFunction|MyClass::mySlot1|?" BACKTRACE_HELPER_NAME "?|" QT_NAMESPACE_STR "QMetaMethod::invoke|" QT_NAMESPACE_STR "QMetaObject::invokeMethod] from_a_function 34"); -#endif +#ifdef __GLIBC__ +# if QT_CONFIG(static) + // These test cases don't work with static Qt builds +# elif defined(QT_ASAN_ENABLED) + // These tests produce far more call frames under ASan +# else +# ifndef QT_NO_DEBUG + QList<QByteArray> expectedBacktrace = { + // MyClass::qt_static_metacall is explicitly marked as hidden in the + // Q_OBJECT macro hence the ?helper? frame + "[MyClass::myFunction|MyClass::mySlot1|?" BACKTRACE_HELPER_NAME "?|", + + // QMetaObject::invokeMethodImpl calls internal function + // (QMetaMethodPrivate::invokeImpl, at the tims of this writing), which + // will usually show only as ?libQt6Core.so? or equivalent, so we skip + + // end of backtrace, actual message + "|" QT_NAMESPACE_STR "QMetaObject::invokeMethodImpl] from_a_function 34" + }; + QTest::newRow("backtrace") << "[%{backtrace}] %{message}" << true << expectedBacktrace; +# endif QTest::newRow("backtrace depth,separator") << "[%{backtrace depth=2 separator=\"\n\"}] %{message}" << true << (QList<QByteArray>() << "[MyClass::myFunction\nMyClass::mySlot1] from_a_function 34" << "[T::T\n"); -#endif // #if !QT_CONFIG(process) +# endif // #if !QT_CONFIG(static) #endif // #ifdef __GLIBC__ - } @@ -777,18 +834,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( @@ -801,15 +854,16 @@ void tst_qmessagehandler::qMessagePattern() QVERIFY(!output.isEmpty()); QCOMPARE(!output.contains("QT_MESSAGE_PATTERN"), valid); - for (const QByteArray &e : qAsConst(expected)) { + for (const QByteArray &e : std::as_const(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 +881,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 +970,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/CMakeLists.txt b/tests/auto/corelib/global/qnativeinterface/CMakeLists.txt index 639c7c3ec7..bf41effc42 100644 --- a/tests/auto/corelib/global/qnativeinterface/CMakeLists.txt +++ b/tests/auto/corelib/global/qnativeinterface/CMakeLists.txt @@ -1,4 +1,9 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + qt_internal_add_test(tst_qnativeinterface SOURCES tst_qnativeinterface.cpp + LIBRARIES + Qt::CorePrivate ) diff --git a/tests/auto/corelib/global/qnativeinterface/tst_qnativeinterface.cpp b/tests/auto/corelib/global/qnativeinterface/tst_qnativeinterface.cpp index dd4cc4755b..b7ec10df6c 100644 --- a/tests/auto/corelib/global/qnativeinterface/tst_qnativeinterface.cpp +++ b/tests/auto/corelib/global/qnativeinterface/tst_qnativeinterface.cpp @@ -1,34 +1,10 @@ -/**************************************************************************** -** -** 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/qnativeinterface.h> +#include <QtCore/private/qnativeinterface_p.h> class tst_QNativeInterface: public QObject { diff --git a/tests/auto/corelib/global/qnumeric/CMakeLists.txt b/tests/auto/corelib/global/qnumeric/CMakeLists.txt index f86ddffc1d..adb467c778 100644 --- a/tests/auto/corelib/global/qnumeric/CMakeLists.txt +++ b/tests/auto/corelib/global/qnumeric/CMakeLists.txt @@ -1,4 +1,5 @@ -# Generated from qnumeric.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_qnumeric Test: @@ -7,7 +8,7 @@ qt_internal_add_test(tst_qnumeric SOURCES tst_qnumeric.cpp - PUBLIC_LIBRARIES + LIBRARIES Qt::CorePrivate ) 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/CMakeLists.txt b/tests/auto/corelib/global/qoperatingsystemversion/CMakeLists.txt index 619297fdab..00e5ac0f02 100644 --- a/tests/auto/corelib/global/qoperatingsystemversion/CMakeLists.txt +++ b/tests/auto/corelib/global/qoperatingsystemversion/CMakeLists.txt @@ -1,4 +1,5 @@ -# Generated from qoperatingsystemversion.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_qoperatingsystemversion Test: diff --git a/tests/auto/corelib/global/qoperatingsystemversion/tst_qoperatingsystemversion.cpp b/tests/auto/corelib/global/qoperatingsystemversion/tst_qoperatingsystemversion.cpp index b109666be5..5d4ec34e8f 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> @@ -35,11 +10,17 @@ class tst_QOperatingSystemVersion : public QObject private slots: void construction_data(); void construction(); + void globals_data(); + void globals(); void anyOf(); void comparison_data(); void comparison(); + void comparison2_data(); + void comparison2(); + + void mixedComparison(); }; void tst_QOperatingSystemVersion::construction_data() @@ -75,6 +56,34 @@ void tst_QOperatingSystemVersion::construction() QVERIFY(!systemVersion.name().isEmpty()); } +void tst_QOperatingSystemVersion::globals_data() +{ + QTest::addColumn<QOperatingSystemVersion>("osver"); + QTest::addColumn<QOperatingSystemVersion::OSType>("osType"); + +#define ADDROW(os) QTest::newRow(#os) << QOperatingSystemVersion(QOperatingSystemVersion::os) + // legacy ones (global variables) + ADDROW(Windows7) << QOperatingSystemVersion::Windows; + ADDROW(Windows10) << QOperatingSystemVersion::Windows; + ADDROW(OSXMavericks) << QOperatingSystemVersion::MacOS; + ADDROW(MacOSMonterey) << QOperatingSystemVersion::MacOS; + ADDROW(AndroidJellyBean) << QOperatingSystemVersion::Android; + ADDROW(Android11) << QOperatingSystemVersion::Android; + + // new ones (static constexpr) + ADDROW(Windows11) << QOperatingSystemVersion::Windows; + ADDROW(Android12) << QOperatingSystemVersion::Android; +#undef ADDROW +} + +void tst_QOperatingSystemVersion::globals() +{ + QFETCH(QOperatingSystemVersion, osver); + QFETCH(QOperatingSystemVersion::OSType, osType); + QCOMPARE(osver.type(), osType); + QCOMPARE_NE(osver.majorVersion(), 0); +} + void tst_QOperatingSystemVersion::anyOf() { std::initializer_list<QOperatingSystemVersion::OSType> typesToCheck = { @@ -177,5 +186,72 @@ void tst_QOperatingSystemVersion::comparison() QCOMPARE(lhsSystemInfo >= rhsSystemInfo, moreEqualResult); } +void tst_QOperatingSystemVersion::comparison2_data() +{ + QTest::addColumn<QOperatingSystemVersion>("lhs"); + QTest::addColumn<QOperatingSystemVersion>("rhs"); + QTest::addColumn<int>("result"); + +#define ADDROW(os1, os2) \ + QTest::newRow(#os1 "-vs-" #os2) << QOperatingSystemVersion(QOperatingSystemVersion::os1) \ + << QOperatingSystemVersion(QOperatingSystemVersion::os2) + + // Cross-OS testing: not comparables. + ADDROW(Windows10, MacOSMonterey) << -128; + ADDROW(Windows11, MacOSMonterey) << -128; + ADDROW(MacOSMonterey, Windows10) << -128; + ADDROW(MacOSMonterey, Windows11) << -128; + ADDROW(Windows10, MacOSVentura) << -128; + ADDROW(Windows11, MacOSVentura) << -128; + ADDROW(MacOSVentura, Windows10) << -128; + ADDROW(MacOSVentura, Windows11) << -128; + ADDROW(Windows10, Android10) << -128; + ADDROW(Windows11, Android11) << -128; + + // Same-OS tests. This list does not have to be exhaustive. + ADDROW(Windows7, Windows7) << 0; + ADDROW(Windows7, Windows8) << -1; + ADDROW(Windows8, Windows7) << 1; + ADDROW(Windows8, Windows10) << -1; + ADDROW(Windows10, Windows8) << 1; + ADDROW(Windows10, Windows10_21H1) << -1; + ADDROW(Windows10_21H1, Windows10) << 1; + ADDROW(Windows10, Windows11) << -1; + ADDROW(MacOSCatalina, MacOSCatalina) << 0; + ADDROW(MacOSCatalina, MacOSBigSur) << -1; + ADDROW(MacOSBigSur, MacOSCatalina) << 1; + ADDROW(MacOSMonterey, MacOSVentura) << -1; + ADDROW(MacOSVentura, MacOSVentura) << 0; + ADDROW(MacOSVentura, MacOSMonterey) << 1; +#undef ADDROW +} + +void tst_QOperatingSystemVersion::comparison2() +{ + QFETCH(QOperatingSystemVersion, lhs); + QFETCH(QOperatingSystemVersion, rhs); + QFETCH(int, result); + + QEXPECT_FAIL("Windows10-vs-Windows10_21H1", "QTBUG-107907: Unexpected behavior", Abort); + QEXPECT_FAIL("Windows10-vs-Windows11", "QTBUG-107907: Unexpected behavior", Abort); + + // value -128 indicates "not comparable" + bool comparable = (result != -128); + QCOMPARE(lhs < rhs, result < 0 && comparable); + QEXPECT_FAIL("Windows10_21H1-vs-Windows10", "QTBUG-107907: Unexpected behavior", Abort); + QCOMPARE(lhs <= rhs, result <= 0 && comparable); + QCOMPARE(lhs > rhs, result > 0 && comparable); + QCOMPARE(lhs >= rhs, result >= 0 && comparable); +} + +void tst_QOperatingSystemVersion::mixedComparison() +{ + // == + QVERIFY(QOperatingSystemVersion::Windows10 + >= QOperatingSystemVersionBase(QOperatingSystemVersionBase::Windows, 10, 0)); + QVERIFY(QOperatingSystemVersion::Windows10 + <= QOperatingSystemVersionBase(QOperatingSystemVersionBase::Windows, 10, 0)); +} + QTEST_MAIN(tst_QOperatingSystemVersion) #include "tst_qoperatingsystemversion.moc" diff --git a/tests/auto/corelib/global/qrandomgenerator/CMakeLists.txt b/tests/auto/corelib/global/qrandomgenerator/CMakeLists.txt index 54fa36b5df..b9468caabb 100644 --- a/tests/auto/corelib/global/qrandomgenerator/CMakeLists.txt +++ b/tests/auto/corelib/global/qrandomgenerator/CMakeLists.txt @@ -1,4 +1,5 @@ -# Generated from qrandomgenerator.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_qrandomgenerator Test: @@ -7,6 +8,6 @@ qt_internal_add_test(tst_qrandomgenerator SOURCES tst_qrandomgenerator.cpp - PUBLIC_LIBRARIES + LIBRARIES Qt::CorePrivate ) diff --git a/tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp b/tests/auto/corelib/global/qrandomgenerator/tst_qrandomgenerator.cpp index 30e170b65d..d0b1803d55 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> @@ -39,7 +14,6 @@ # define HAVE_FALLBACK_ENGINE #endif -#define COMMA , #define QVERIFY_3TIMES(statement) \ do {\ if (!static_cast<bool>(statement))\ @@ -190,8 +164,8 @@ QT_WARNING_POP QRandomGenerator64 systemRng64 = *system64; systemRng64 = *system64; - static_assert(std::is_same<decltype(rng64.generate()) COMMA quint64>::value); - static_assert(std::is_same<decltype(system64->generate()) COMMA quint64>::value); + static_assert(std::is_same_v<decltype(rng64.generate()), quint64>); + static_assert(std::is_same_v<decltype(system64->generate()), quint64>); } void tst_QRandomGenerator::knownSequence() @@ -636,7 +610,7 @@ template <typename UInt> static void boundedQuality_template() QVector<UInt> buffer(BufferCount, filler); generate(buffer.begin(), buffer.end(), [&] { return rng.bounded(Bound); }); - for (UInt value : qAsConst(buffer)) { + for (UInt value : std::as_const(buffer)) { QVERIFY(value < Bound); histogram[value]++; } @@ -920,18 +894,20 @@ void tst_QRandomGenerator::stdGenerateCanonical() { QFETCH(uint, control); RandomGenerator rng(control); + auto generate_canonical = [&rng]() { + return std::generate_canonical<qreal, 32>(rng); + }; for (int i = 0; i < 4; ++i) { QVERIFY_3TIMES([&] { - qreal value = std::generate_canonical<qreal COMMA 32>(rng); + qreal value = generate_canonical(); return value > 0 && value < 1 && value != RandomValueFP; }()); } // and should hopefully be different from repeated calls for (int i = 0; i < 4; ++i) - QVERIFY_3TIMES(std::generate_canonical<qreal COMMA 32>(rng) != - std::generate_canonical<qreal COMMA 32>(rng)); + QVERIFY_3TIMES(generate_canonical() != generate_canonical()); } void tst_QRandomGenerator::stdUniformRealDistribution_data() diff --git a/tests/auto/corelib/global/qtendian/CMakeLists.txt b/tests/auto/corelib/global/qtendian/CMakeLists.txt index acd0981991..d3e91450ce 100644 --- a/tests/auto/corelib/global/qtendian/CMakeLists.txt +++ b/tests/auto/corelib/global/qtendian/CMakeLists.txt @@ -1,4 +1,5 @@ -# Generated from qtendian.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_qtendian Test: @@ -7,6 +8,6 @@ qt_internal_add_test(tst_qtendian SOURCES tst_qtendian.cpp - PUBLIC_LIBRARIES + LIBRARIES Qt::CorePrivate ) diff --git a/tests/auto/corelib/global/qtendian/tst_qtendian.cpp b/tests/auto/corelib/global/qtendian/tst_qtendian.cpp index 74c2deff52..885e693c8d 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(); @@ -54,7 +35,8 @@ private slots: void endianIntegers_data(); void endianIntegers(); - void endianBitfields(); + void endianBitfieldUnions_data(); + void endianBitfieldUnions(); }; struct TestData @@ -360,32 +342,108 @@ void tst_QtEndian::endianIntegers() #endif } -void tst_QtEndian::endianBitfields() +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 all = Member<0, 32, uint>; + + using UnionType = Union<upper, lower, bottom, all>; + 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); + + u2.template set<all>(std::numeric_limits<uint>::max()); + QCOMPARE(u2.template get<all>(), std::numeric_limits<uint>::max()); + + u2.template set<all>(453); + QCOMPARE(u2.template get<all>(), 453U); + + u2.template set<all>(0); + QCOMPARE(u2.template get<all>(), 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() { - union { - quint32_be_bitfield<21, 11> upper; - quint32_be_bitfield<10, 11> lower; - qint32_be_bitfield<0, 10> bottom; - } u; - - u.upper = 200; - QCOMPARE(u.upper, 200U); - u.lower = 1000; - u.bottom = -8; - QCOMPARE(u.lower, 1000U); - QCOMPARE(u.upper, 200U); - - u.lower += u.upper; - QCOMPARE(u.upper, 200U); - QCOMPARE(u.lower, 1200U); - - u.upper = 65536 + 7; - u.lower = 65535; - QCOMPARE(u.lower, 65535U & ((1<<11) - 1)); - QCOMPARE(u.upper, 7U); - - QCOMPARE(u.bottom, -8); + 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/CMakeLists.txt b/tests/auto/corelib/global/qwinregistry/CMakeLists.txt deleted file mode 100644 index 95d591a125..0000000000 --- a/tests/auto/corelib/global/qwinregistry/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -# Generated from qwinregistry.pro. - -##################################################################### -## tst_qwinregistry Test: -##################################################################### - -qt_internal_add_test(tst_qwinregistry - SOURCES - tst_qwinregistry.cpp - PUBLIC_LIBRARIES - Qt::CorePrivate -) diff --git a/tests/auto/corelib/global/qwinregistry/tst_qwinregistry.cpp b/tests/auto/corelib/global/qwinregistry/tst_qwinregistry.cpp deleted file mode 100644 index c73a0a7575..0000000000 --- a/tests/auto/corelib/global/qwinregistry/tst_qwinregistry.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - -#include <QTest> - -#include <QtCore/qoperatingsystemversion.h> - -#include <QtCore/private/qwinregistry_p.h> - -class tst_QWinRegistry : public QObject -{ - Q_OBJECT - -public Q_SLOTS: - void initTestCase(); - -private Q_SLOTS: - void values(); -}; - -void tst_QWinRegistry::initTestCase() -{ - if (QOperatingSystemVersion::current() < QOperatingSystemVersion::Windows10) - QSKIP("This test requires registry values present in Windows 10"); -} - -void tst_QWinRegistry::values() -{ - QWinRegistryKey key(HKEY_LOCAL_MACHINE, LR"(SOFTWARE\Microsoft\Windows NT\CurrentVersion)"); - QVERIFY(key.isValid()); - QVERIFY(!key.stringValue(L"ProductName").isEmpty()); - QVERIFY(key.stringValue(L"NonExistingKey").isEmpty()); - auto majorVersion = key.dwordValue(L"CurrentMajorVersionNumber"); - QVERIFY(majorVersion.second); - QVERIFY(majorVersion.first > 0); - auto nonExistingValue = key.dwordValue(L"NonExistingKey"); - QVERIFY(!nonExistingValue.second); - QCOMPARE(nonExistingValue.first, 0u); -} - -QTEST_APPLESS_MAIN(tst_QWinRegistry); - -#include "tst_qwinregistry.moc" diff --git a/tests/auto/corelib/global/qxp/CMakeLists.txt b/tests/auto/corelib/global/qxp/CMakeLists.txt new file mode 100644 index 0000000000..f289a04701 --- /dev/null +++ b/tests/auto/corelib/global/qxp/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(function_ref) diff --git a/tests/auto/corelib/global/qxp/function_ref/CMakeLists.txt b/tests/auto/corelib/global/qxp/function_ref/CMakeLists.txt new file mode 100644 index 0000000000..d52618d527 --- /dev/null +++ b/tests/auto/corelib/global/qxp/function_ref/CMakeLists.txt @@ -0,0 +1,10 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +qt_internal_add_test(tst_qxp_function_ref + EXCEPTIONS + SOURCES + tst_qxp_function_ref.cpp + LIBRARIES + Qt::Core +) diff --git a/tests/auto/corelib/global/qxp/function_ref/tst_qxp_function_ref.cpp b/tests/auto/corelib/global/qxp/function_ref/tst_qxp_function_ref.cpp new file mode 100644 index 0000000000..6264e6a5ae --- /dev/null +++ b/tests/auto/corelib/global/qxp/function_ref/tst_qxp_function_ref.cpp @@ -0,0 +1,279 @@ +// 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 <QtCore/qxpfunctional.h> + +#include <QTest> + +#include <type_traits> + +// checking dependency q20::remove_cvref_t: +#define CHECK(in, out) \ + static_assert(std::is_same_v<q20::remove_cvref_t< in >, out >) +CHECK(int, int); +CHECK(const int, int); +CHECK(int &, int); +CHECK(const int &, int); +CHECK(int &&, int); +CHECK(const int &&, int); +CHECK(int *, int *); +CHECK(const int *, const int *); +CHECK(int[4], int[4]); +CHECK(const int (&)[4], int[4]); +#undef CHECK + +template <typename T> constexpr inline bool +is_noexcept_function_ref_helper_v = false; +template <typename R, typename...Args> constexpr inline bool +is_noexcept_function_ref_helper_v<qxp::function_ref<R(Args...) noexcept(true)>> = true; +template <typename R, typename...Args> constexpr inline bool +is_noexcept_function_ref_helper_v<qxp::function_ref<R(Args...) const noexcept(true)>> = true; + +template <typename T> constexpr inline bool +is_noexcept_function_ref_v = is_noexcept_function_ref_helper_v<q20::remove_cvref_t<T>>; + +class tst_qxp_function_ref : public QObject +{ + Q_OBJECT +public: + using QObject::QObject; + +private Q_SLOTS: + void basics(); + void constOverloads(); + void constExpr(); + void voidReturning(); + void ctad(); +}; + +void tst_qxp_function_ref::basics() +{ + static_assert(std::is_trivially_copyable_v<qxp::function_ref<int(int)>>); + static_assert(std::is_trivially_copyable_v<qxp::function_ref<int()>>); + static_assert(std::is_trivially_copyable_v<qxp::function_ref<void()>>); + + { + Q_CONSTINIT static int invoked = 0; + auto lambda = [](int i) noexcept { ++invoked; return i; }; + const qxp::function_ref<int(int)> f = lambda; + QCOMPARE(invoked, 0); + QCOMPARE(f(42), 42); + QCOMPARE(invoked, 1); + + const int fourtyTwo = 42; + + const qxp::function_ref<int(int) noexcept> f2 = std::move(lambda); + QCOMPARE(invoked, 1); + QCOMPARE(f2(fourtyTwo), 42); + QCOMPARE(invoked, 2); + + int (*fpr)(int) = lambda; + + const qxp::function_ref f3 = fpr; + static_assert(!is_noexcept_function_ref_v<decltype(f3)>); + QCOMPARE(invoked, 2); + QCOMPARE(f3(42), 42); + QCOMPARE(invoked, 3); + + int (*fpr2)(int) noexcept = lambda; + + const qxp::function_ref f4 = fpr2; + static_assert(is_noexcept_function_ref_v<decltype(f4)>); + QCOMPARE(invoked, 3); + QCOMPARE(f4(42), 42); + QCOMPARE(invoked, 4); + } + { + Q_CONSTINIT static int invoked = 0; + auto lambda = [] { ++invoked; return 42; }; + const qxp::function_ref<int()> f = lambda; + QCOMPARE(invoked, 0); + QCOMPARE(f(), 42); + QCOMPARE(invoked, 1); + + const qxp::function_ref<int()> f2 = std::move(lambda); + QCOMPARE(invoked, 1); + QCOMPARE(f2(), 42); + QCOMPARE(invoked, 2); + + int (*fpr)() = lambda; + + const qxp::function_ref f3 = fpr; + static_assert(!is_noexcept_function_ref_v<decltype(f3)>); + QCOMPARE(invoked, 2); + QCOMPARE(f3(), 42); + QCOMPARE(invoked, 3); + } + { + Q_CONSTINIT static int invoked = 0; + auto lambda = [] { ++invoked; }; + const qxp::function_ref<void()> f = lambda; + QCOMPARE(invoked, 0); + f(); + QCOMPARE(invoked, 1); + + const qxp::function_ref<void()> f2 = std::move(lambda); + QCOMPARE(invoked, 1); + f2(); + QCOMPARE(invoked, 2); + + void (*fpr)() = lambda; + + const qxp::function_ref f3 = fpr; + QCOMPARE(invoked, 2); + f3(); + QCOMPARE(invoked, 3); + } +} + +void tst_qxp_function_ref::constOverloads() +{ + auto func_c = [](qxp::function_ref<int() const> callable) + { + return callable(); + }; + auto func_m = [](qxp::function_ref<int() /*mutable*/> callable) + { + return callable(); + }; + + struct S + { + int operator()() { return 1; } + int operator()() const { return 2; } + }; + S s; + QCOMPARE(func_c(s), 2); + QCOMPARE(func_m(s), 1); + const S cs; + QCOMPARE(func_c(cs), 2); +#if 0 + // this should not compile (and doesn't, but currently fails with an error in the impl, + // not by failing a constructor constaint → spec issue?). + QCOMPARE(func_m(cs), 2); +#endif +} + +void tst_qxp_function_ref::constExpr() +{ + Q_CONSTINIT static int invoked = 0; + { + Q_CONSTINIT static auto lambda = [] (int i) { ++invoked; return i; }; + // the function object constructor is constexpr, so this should be constinit: + Q_CONSTINIT static qxp::function_ref<int(int)> f = lambda; + + QCOMPARE(invoked, 0); + QCOMPARE(f(15), 15); + QCOMPARE(invoked, 1); + } + { + constexpr static auto lambda = [] (int i) { ++invoked; return i; }; + // the function object constructor is constexpr, so this should be constinit: + Q_CONSTINIT static qxp::function_ref<int(int) const> f = lambda; + + QCOMPARE(invoked, 1); + QCOMPARE(f(51), 51); + QCOMPARE(invoked, 2); + +#if 0 // ### should this work?: + Q_CONSTINIT static qxp::function_ref<int(int)> f2 = lambda; + + QCOMPARE(invoked, 2); + QCOMPARE(f(150), 150); + QCOMPARE(invoked, 3); +#endif + + } +} + +int i_f_i_nx(int i) noexcept { return i; } +void v_f_i_nx(int) noexcept {} +int i_f_v_nx() noexcept { return 42; } +void v_f_v_nx() noexcept {} + +int i_f_i_ex(int i) { return i; } +void v_f_i_ex(int) {} +int i_f_v_ex() { return 42; } +void v_f_v_ex() {} + +void tst_qxp_function_ref::voidReturning() +{ + // check that "casting" int to void returns works: + + using Fi = qxp::function_ref<void(int)>; + using Fv = qxp::function_ref<void()>; + + { + Fi fi = i_f_i_nx; + fi(42); + Fv fv = i_f_v_nx; + fv(); + } + + { + Fi fi = i_f_i_ex; + fi(42); + Fv fv = i_f_v_ex; + fv(); + } + + // now with lambdas + + bool ok = false; // prevent lambdas from decaying to function pointers + { + auto lambda1 = [&](int i) noexcept { return i + int(ok); }; + Fi fi = lambda1; + fi(42); + auto lambda2 = [&]() noexcept { return int(ok); }; + Fv fv = lambda2; + fv(); + } + + { + auto lambda1 = [&](int i) { return i + int(ok); }; + Fi fi = lambda1; + fi(42); + auto lambda2 = [&]() { return int(ok); }; + Fv fv = lambda2; + fv(); + } +} + +void tst_qxp_function_ref::ctad() +{ +#define CHECK(fun, sig) \ + do { \ + qxp::function_ref f = fun; \ + static_assert(std::is_same_v<decltype(f), \ + qxp::function_ref<sig>>); \ + qxp::function_ref f2 = &fun; \ + static_assert(std::is_same_v<decltype(f2), \ + qxp::function_ref<sig>>); \ + } while (false) + + CHECK(i_f_i_nx, int (int) noexcept); + CHECK(v_f_i_nx, void(int) noexcept); + CHECK(i_f_v_nx, int ( ) noexcept); + CHECK(v_f_v_nx, void( ) noexcept); + + CHECK(i_f_i_ex, int (int)); + CHECK(v_f_i_ex, void(int)); + CHECK(i_f_v_ex, int ( )); + CHECK(v_f_v_ex, void( )); + +#undef CHECK + +#if 0 // no deduction guides for the non-function-pointer case, so no CTAD for lambdas + { + auto lambda = [](int i) -> int { return i; }; + qxp::function_ref f = lambda; + static_assert(std::is_same_v<decltype(f), + qxp::function_ref<int(int)>>); + } +#endif +} + + +QTEST_APPLESS_MAIN(tst_qxp_function_ref); + +#include "tst_qxp_function_ref.moc" diff --git a/tests/auto/corelib/io/CMakeLists.txt b/tests/auto/corelib/io/CMakeLists.txt index a519a47956..4100ce17d5 100644 --- a/tests/auto/corelib/io/CMakeLists.txt +++ b/tests/auto/corelib/io/CMakeLists.txt @@ -1,4 +1,10 @@ -# Generated from io.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +# 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 +24,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) @@ -34,10 +42,10 @@ if(NOT ANDROID) add_subdirectory(qdir) add_subdirectory(qresourceengine) endif() -if(QT_FEATURE_private_tests OR UNIX) +if(QT_FEATURE_private_tests) add_subdirectory(qfilesystementry) endif() -# QTBUG-88508 # special case +# QTBUG-88508 if(QT_FEATURE_filesystemwatcher AND NOT ANDROID) add_subdirectory(qfilesystemwatcher) endif() diff --git a/tests/auto/corelib/io/largefile/CMakeLists.txt b/tests/auto/corelib/io/largefile/CMakeLists.txt index a82aa0c985..1f03eb2cb6 100644 --- a/tests/auto/corelib/io/largefile/CMakeLists.txt +++ b/tests/auto/corelib/io/largefile/CMakeLists.txt @@ -1,4 +1,5 @@ -# Generated from largefile.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_largefile Test: @@ -7,6 +8,6 @@ qt_internal_add_test(tst_largefile SOURCES tst_largefile.cpp - PUBLIC_LIBRARIES + LIBRARIES Qt::TestPrivate ) 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/CMakeLists.txt b/tests/auto/corelib/io/qabstractfileengine/CMakeLists.txt index 7e3b79403d..bfa3c55558 100644 --- a/tests/auto/corelib/io/qabstractfileengine/CMakeLists.txt +++ b/tests/auto/corelib/io/qabstractfileengine/CMakeLists.txt @@ -1,4 +1,5 @@ -# Generated from qabstractfileengine.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_qabstractfileengine Test: @@ -7,7 +8,7 @@ qt_internal_add_test(tst_qabstractfileengine SOURCES tst_qabstractfileengine.cpp - PUBLIC_LIBRARIES + LIBRARIES Qt::CorePrivate ) 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 f85742354e..b093644013 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, @@ -193,28 +170,6 @@ public: return true; } - // bool link(const QString &newName) - // { - // Q_UNUSED(newName); - // return false; - // } - - // bool mkdir(const QString &dirName, bool createParentDirectories) const - // { - // Q_UNUSED(dirName); - // Q_UNUSED(createParentDirectories); - - // return false; - // } - - // bool rmdir(const QString &dirName, bool recurseParentDirectories) const - // { - // Q_UNUSED(dirName); - // Q_UNUSED(recurseParentDirectories); - - // return false; - // } - bool setSize(qint64 size) override { if (size < 0) @@ -245,13 +200,6 @@ public: return FileFlags(); } - // bool setPermissions(uint perms) - // { - // Q_UNUSED(perms); - - // return false; - // } - QString fileName(FileName file) const override { switch (file) { @@ -265,8 +213,10 @@ public: return QLatin1String("AbsoluteName"); case AbsolutePathName: return QLatin1String("AbsolutePathName"); - case LinkName: - return QLatin1String("LinkName"); + case AbsoluteLinkTarget: + return QLatin1String("AbsoluteLinkTarget"); + case RawLinkPath: + return QLatin1String("RawLinkPath"); case CanonicalName: return QLatin1String("CanonicalName"); case CanonicalPathName: @@ -355,13 +305,6 @@ public: return QDateTime(); } - bool setFileTime(const QDateTime &newDate, FileTime time) override - { - Q_UNUSED(newDate); - Q_UNUSED(time); - return false; - } - void setFileName(const QString &file) override { if (openForRead_ || openForWrite_) @@ -370,20 +313,6 @@ public: fileName_ = file; } - // typedef QAbstractFileEngineIterator Iterator; - // Iterator *beginEntryList(QDir::Filters filters, const QStringList &filterNames) - // { - // Q_UNUSED(filters); - // Q_UNUSED(filterNames); - - // return 0; - // } - - // Iterator *endEntryList() - // { - // return 0; - // } - qint64 read(char *data, qint64 maxLen) override { if (!openForRead_) { diff --git a/tests/auto/corelib/io/qbuffer/CMakeLists.txt b/tests/auto/corelib/io/qbuffer/CMakeLists.txt index 7d57d78b3f..393d3cb8e0 100644 --- a/tests/auto/corelib/io/qbuffer/CMakeLists.txt +++ b/tests/auto/corelib/io/qbuffer/CMakeLists.txt @@ -1,4 +1,5 @@ -# Generated from qbuffer.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_qbuffer Test: diff --git a/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp b/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp index 7a68da8192..6fe192f3ab 100644 --- a/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp +++ b/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp @@ -1,48 +1,28 @@ -/**************************************************************************** -** -** 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 { Q_OBJECT private slots: void open(); + void openWriteOnlyDoesNotTruncate(); void getSetCheck(); void readBlock(); void readBlockPastEnd(); void writeBlock_data(); void writeBlock(); void seek(); + void invalidSeeks(); void seekTest_data(); void seekTest(); void read_rawdata(); @@ -58,6 +38,7 @@ private slots: void readLineBoundaries(); void getAndUngetChar(); void writeAfterQByteArrayResize(); + void writeOfMoreThan2GiB(); void read_null(); protected slots: @@ -131,6 +112,29 @@ void tst_QBuffer::open() b.close(); } +void tst_QBuffer::openWriteOnlyDoesNotTruncate() +{ + QBuffer b; + const auto data = QByteArrayLiteral("Hey, presto!"); + + { + QVERIFY(b.open(QIODevice::WriteOnly)); + b.write(data); + b.close(); + } + { + QVERIFY(b.open(QIODevice::ReadOnly)); + QCOMPARE(b.readAll(), data); + b.close(); + } + { + QVERIFY(b.open(QIODevice::WriteOnly)); + QCOMPARE(b.size(), data.size()); + QCOMPARE(b.pos(), 0); + b.close(); + } +} + // some status() tests, too void tst_QBuffer::readBlock() { @@ -287,6 +291,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 +626,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/CMakeLists.txt b/tests/auto/corelib/io/qdataurl/CMakeLists.txt index b13a235d3b..5e0a6bab60 100644 --- a/tests/auto/corelib/io/qdataurl/CMakeLists.txt +++ b/tests/auto/corelib/io/qdataurl/CMakeLists.txt @@ -1,4 +1,5 @@ -# Generated from qdataurl.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_qdataurl Test: @@ -7,6 +8,6 @@ qt_internal_add_test(tst_qdataurl SOURCES tst_qdataurl.cpp - PUBLIC_LIBRARIES + LIBRARIES Qt::CorePrivate ) 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..cef57a2186 100644 --- a/tests/auto/corelib/io/qdebug/CMakeLists.txt +++ b/tests/auto/corelib/io/qdebug/CMakeLists.txt @@ -1,4 +1,5 @@ -# Generated from qdebug.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_qdebug Test: @@ -7,6 +8,10 @@ qt_internal_add_test(tst_qdebug SOURCES tst_qdebug.cpp - PUBLIC_LIBRARIES + 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..a54018c3fa 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> @@ -39,8 +14,19 @@ #include <QLine> #include <QMimeType> #include <QMimeDatabase> +#include <QMetaType> + +#ifdef __cpp_lib_memory_resource +# include <memory_resource> +namespace pmr = std::pmr; +#else +namespace pmr = std; +#endif + +using namespace Qt::StringLiterals; static_assert(QTypeTraits::has_ostream_operator_v<QDebug, int>); +static_assert(QTypeTraits::has_ostream_operator_v<QDebug, QMetaType>); static_assert(QTypeTraits::has_ostream_operator_v<QDebug, QList<int>>); static_assert(QTypeTraits::has_ostream_operator_v<QDebug, QMap<int, QString>>); struct NonStreamable {}; @@ -52,6 +38,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 { @@ -75,10 +65,21 @@ private slots: void stateSaver() const; void veryLongWarningMessage() const; void qDebugQChar() const; + void qDebugQMetaType() const; void qDebugQString() const; void qDebugQStringView() const; void qDebugQUtf8StringView() const; void qDebugQLatin1String() const; + void qDebugStdString() const; + void qDebugStdStringView() const; + void qDebugStdWString() const; + void qDebugStdWStringView() const; + void qDebugStdU8String() const; + void qDebugStdU8StringView() const; + void qDebugStdU16String() const; + void qDebugStdU16StringView() const; + void qDebugStdU32String() const; + void qDebugStdU32StringView() const; void qDebugQByteArray() const; void qDebugQByteArrayView() const; void qDebugQFlags() const; @@ -88,6 +89,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 @@ -443,6 +450,25 @@ void tst_QDebug::qDebugQChar() const } +void tst_QDebug::qDebugQMetaType() const +{ + QString file, function; + int line = 0; + MessageHandlerSetter mhs(myMessageHandler); + { + QDebug d = qDebug(); + d << QMetaType::fromType<int>() << QMetaType::fromType<QString>(); + } +#ifndef QT_NO_MESSAGELOGCONTEXT + file = __FILE__; line = __LINE__ - 4; function = Q_FUNC_INFO; +#endif + QCOMPARE(s_msgType, QtDebugMsg); + QCOMPARE(s_msg, R"(QMetaType(int) QMetaType(QString))"_L1); + QCOMPARE(QString::fromLatin1(s_file), file); + QCOMPARE(s_line, line); + QCOMPARE(QString::fromLatin1(s_function), function); +} + void tst_QDebug::qDebugQString() const { /* Use a basic string. */ @@ -639,6 +665,324 @@ void tst_QDebug::qDebugQLatin1String() const QCOMPARE(s_msg, QString("\"\\nSm\\u00F8rg\\u00E5sbord\\\\\"")); } +void tst_QDebug::qDebugStdString() const +{ + QString file, function; + int line = 0; + MessageHandlerSetter mhs(myMessageHandler); + { + QDebug d = qDebug(); + d << pmr::string("foo") << std::string("") << std::string("barbaz", 3); + d.nospace().noquote() << std::string("baz"); + } +#ifndef QT_NO_MESSAGELOGCONTEXT + file = __FILE__; line = __LINE__ - 5; function = Q_FUNC_INFO; +#endif + QCOMPARE(s_msgType, QtDebugMsg); + QCOMPARE(s_msg, QString::fromLatin1("\"foo\" \"\" \"bar\" baz")); + QCOMPARE(QString::fromLatin1(s_file), file); + QCOMPARE(s_line, line); + QCOMPARE(QString::fromLatin1(s_function), function); + + /* simpler tests from now on */ + std::string string("\"Hello\""); + qDebug() << string; + QCOMPARE(s_msg, QString("\"\\\"Hello\\\"\"")); + + qDebug().noquote().nospace() << string; + QCOMPARE(s_msg, QString::fromStdString(string)); + + qDebug().noquote().nospace() << qSetFieldWidth(8) << string; + QCOMPARE(s_msg, " " + QString::fromStdString(string)); +} + +void tst_QDebug::qDebugStdStringView() const +{ + QString file, function; + int line = 0; + MessageHandlerSetter mhs(myMessageHandler); + { + QDebug d = qDebug(); + d << std::string_view("foo") << std::string_view("") << std::string_view("barbaz", 3); + d.nospace().noquote() << std::string_view("baz"); + } +#ifndef QT_NO_MESSAGELOGCONTEXT + file = __FILE__; line = __LINE__ - 5; function = Q_FUNC_INFO; +#endif + QCOMPARE(s_msgType, QtDebugMsg); + QCOMPARE(s_msg, QString::fromLatin1("\"foo\" \"\" \"bar\" baz")); + QCOMPARE(QString::fromLatin1(s_file), file); + QCOMPARE(s_line, line); + QCOMPARE(QString::fromLatin1(s_function), function); + + /* simpler tests from now on */ + std::string_view string("\"Hello\""); + qDebug() << string; + QCOMPARE(s_msg, QString("\"\\\"Hello\\\"\"")); + + qDebug().noquote().nospace() << string; + QCOMPARE(s_msg, QString::fromStdString(std::string(string))); + + qDebug().noquote().nospace() << qSetFieldWidth(8) << string; + QCOMPARE(s_msg, " " + QString::fromStdString(std::string(string))); +} + +void tst_QDebug::qDebugStdWString() const +{ + QString file, function; + int line = 0; + MessageHandlerSetter mhs(myMessageHandler); + { + QDebug d = qDebug(); + d << pmr::wstring(L"foo") << std::wstring(L"") << std::wstring(L"barbaz", 3); + d.nospace().noquote() << std::wstring(L"baz"); + } +#ifndef QT_NO_MESSAGELOGCONTEXT + file = __FILE__; line = __LINE__ - 5; function = Q_FUNC_INFO; +#endif + QCOMPARE(s_msgType, QtDebugMsg); + QCOMPARE(s_msg, QString::fromLatin1("\"foo\" \"\" \"bar\" baz")); + QCOMPARE(QString::fromLatin1(s_file), file); + QCOMPARE(s_line, line); + QCOMPARE(QString::fromLatin1(s_function), function); + + /* simpler tests from now on */ + std::wstring string(L"\"Hello\""); + qDebug() << string; + QCOMPARE(s_msg, QString("\"\\\"Hello\\\"\"")); + + qDebug().noquote().nospace() << string; + QCOMPARE(s_msg, QString::fromStdWString(string)); + + qDebug().noquote().nospace() << qSetFieldWidth(8) << string; + QCOMPARE(s_msg, " " + QString::fromStdWString(string)); +} + +void tst_QDebug::qDebugStdWStringView() const +{ + QString file, function; + int line = 0; + MessageHandlerSetter mhs(myMessageHandler); + { + QDebug d = qDebug(); + d << std::wstring_view(L"foo") << std::wstring_view(L"") << std::wstring_view(L"barbaz", 3); + d.nospace().noquote() << std::wstring_view(L"baz"); + } +#ifndef QT_NO_MESSAGELOGCONTEXT + file = __FILE__; line = __LINE__ - 5; function = Q_FUNC_INFO; +#endif + QCOMPARE(s_msgType, QtDebugMsg); + QCOMPARE(s_msg, QString::fromLatin1("\"foo\" \"\" \"bar\" baz")); + QCOMPARE(QString::fromLatin1(s_file), file); + QCOMPARE(s_line, line); + QCOMPARE(QString::fromLatin1(s_function), function); + + /* simpler tests from now on */ + std::wstring_view string(L"\"Hello\""); + qDebug() << string; + QCOMPARE(s_msg, QString("\"\\\"Hello\\\"\"")); + + qDebug().noquote().nospace() << string; + QCOMPARE(s_msg, QString::fromStdWString(std::wstring(string))); + + qDebug().noquote().nospace() << qSetFieldWidth(8) << string; + QCOMPARE(s_msg, " " + QString::fromStdWString(std::wstring(string))); +} + +void tst_QDebug::qDebugStdU8String() const +{ +#ifndef __cpp_lib_char8_t + QSKIP("This test requires C++20 char8_t support enabled in the compiler."); +#else + QString file, function; + int line = 0; + MessageHandlerSetter mhs(myMessageHandler); + { + QDebug d = qDebug(); + d << pmr::u8string(u8"foo") << std::u8string(u8"") << std::u8string(u8"barbaz", 3); + d.nospace().noquote() << std::u8string(u8"baz"); + } +#ifndef QT_NO_MESSAGELOGCONTEXT + file = __FILE__; line = __LINE__ - 5; function = Q_FUNC_INFO; +#endif + QCOMPARE(s_msgType, QtDebugMsg); + QCOMPARE(s_msg, QString::fromLatin1("\"foo\" \"\" \"bar\" baz")); + QCOMPARE(QString::fromLatin1(s_file), file); + QCOMPARE(s_line, line); + QCOMPARE(QString::fromLatin1(s_function), function); + + /* simpler tests from now on */ + std::u8string string(u8"\"Hello\""); + qDebug() << string; + QCOMPARE(s_msg, QString("\"\\\"Hello\\\"\"")); + + qDebug().noquote().nospace() << string; + QCOMPARE(s_msg, QUtf8StringView(string).toString()); + + qDebug().noquote().nospace() << qSetFieldWidth(8) << string; + QCOMPARE(s_msg, " " + QUtf8StringView(string).toString()); +#endif // __cpp_lib_char8_t +} + +void tst_QDebug::qDebugStdU8StringView() const +{ +#ifndef __cpp_lib_char8_t + QSKIP("This test requires C++20 char8_t support enabled in the compiler."); +#else + QString file, function; + int line = 0; + MessageHandlerSetter mhs(myMessageHandler); + { + QDebug d = qDebug(); + d << std::u16string_view(u"foo") << std::u16string_view(u"") << std::u16string_view(u"barbaz", 3); + d.nospace().noquote() << std::u16string_view(u"baz"); + } +#ifndef QT_NO_MESSAGELOGCONTEXT + file = __FILE__; line = __LINE__ - 5; function = Q_FUNC_INFO; +#endif + QCOMPARE(s_msgType, QtDebugMsg); + QCOMPARE(s_msg, QString::fromLatin1("\"foo\" \"\" \"bar\" baz")); + QCOMPARE(QString::fromLatin1(s_file), file); + QCOMPARE(s_line, line); + QCOMPARE(QString::fromLatin1(s_function), function); + + /* simpler tests from now on */ + std::u16string_view string(u"\"Hello\""); + qDebug() << string; + QCOMPARE(s_msg, QString("\"\\\"Hello\\\"\"")); + + qDebug().noquote().nospace() << string; + QCOMPARE(s_msg, QString::fromStdU16String(std::u16string(string))); + + qDebug().noquote().nospace() << qSetFieldWidth(8) << string; + QCOMPARE(s_msg, " " + QString::fromStdU16String(std::u16string(string))); +#endif // __cpp_lib_char8_t +} + +void tst_QDebug::qDebugStdU16String() const +{ + QString file, function; + int line = 0; + MessageHandlerSetter mhs(myMessageHandler); + { + QDebug d = qDebug(); + d << pmr::u16string(u"foo") << std::u16string(u"") << std::u16string(u"barbaz", 3); + d.nospace().noquote() << std::u16string(u"baz"); + } +#ifndef QT_NO_MESSAGELOGCONTEXT + file = __FILE__; line = __LINE__ - 5; function = Q_FUNC_INFO; +#endif + QCOMPARE(s_msgType, QtDebugMsg); + QCOMPARE(s_msg, QString::fromLatin1("\"foo\" \"\" \"bar\" baz")); + QCOMPARE(QString::fromLatin1(s_file), file); + QCOMPARE(s_line, line); + QCOMPARE(QString::fromLatin1(s_function), function); + + /* simpler tests from now on */ + std::u16string string(u"\"Hello\""); + qDebug() << string; + QCOMPARE(s_msg, QString("\"\\\"Hello\\\"\"")); + + qDebug().noquote().nospace() << string; + QCOMPARE(s_msg, QString::fromStdU16String(string)); + + qDebug().noquote().nospace() << qSetFieldWidth(8) << string; + QCOMPARE(s_msg, " " + QString::fromStdU16String(string)); +} + +void tst_QDebug::qDebugStdU16StringView() const +{ + QString file, function; + int line = 0; + MessageHandlerSetter mhs(myMessageHandler); + { + QDebug d = qDebug(); + d << std::u16string_view(u"foo") << std::u16string_view(u"") << std::u16string_view(u"barbaz", 3); + d.nospace().noquote() << std::u16string_view(u"baz"); + } +#ifndef QT_NO_MESSAGELOGCONTEXT + file = __FILE__; line = __LINE__ - 5; function = Q_FUNC_INFO; +#endif + QCOMPARE(s_msgType, QtDebugMsg); + QCOMPARE(s_msg, QString::fromLatin1("\"foo\" \"\" \"bar\" baz")); + QCOMPARE(QString::fromLatin1(s_file), file); + QCOMPARE(s_line, line); + QCOMPARE(QString::fromLatin1(s_function), function); + + /* simpler tests from now on */ + std::u16string_view string(u"\"Hello\""); + qDebug() << string; + QCOMPARE(s_msg, QString("\"\\\"Hello\\\"\"")); + + qDebug().noquote().nospace() << string; + QCOMPARE(s_msg, QString::fromStdU16String(std::u16string(string))); + + qDebug().noquote().nospace() << qSetFieldWidth(8) << string; + QCOMPARE(s_msg, " " + QString::fromStdU16String(std::u16string(string))); +} + +void tst_QDebug::qDebugStdU32String() const +{ + QString file, function; + int line = 0; + MessageHandlerSetter mhs(myMessageHandler); + { + QDebug d = qDebug(); + d << pmr::u32string(U"foo") << std::u32string(U"") << std::u32string(U"barbaz", 3); + d.nospace().noquote() << std::u32string(U"baz"); + } +#ifndef QT_NO_MESSAGELOGCONTEXT + file = __FILE__; line = __LINE__ - 5; function = Q_FUNC_INFO; +#endif + QCOMPARE(s_msgType, QtDebugMsg); + QCOMPARE(s_msg, QString::fromLatin1("\"foo\" \"\" \"bar\" baz")); + QCOMPARE(QString::fromLatin1(s_file), file); + QCOMPARE(s_line, line); + QCOMPARE(QString::fromLatin1(s_function), function); + + /* simpler tests from now on */ + std::u32string string(U"\"Hello\""); + qDebug() << string; + QCOMPARE(s_msg, QString("\"\\\"Hello\\\"\"")); + + qDebug().noquote().nospace() << string; + QCOMPARE(s_msg, QString::fromStdU32String(string)); + + qDebug().noquote().nospace() << qSetFieldWidth(8) << string; + QCOMPARE(s_msg, " " + QString::fromStdU32String(string)); +} + +void tst_QDebug::qDebugStdU32StringView() const +{ + QString file, function; + int line = 0; + MessageHandlerSetter mhs(myMessageHandler); + { + QDebug d = qDebug(); + d << std::u32string_view(U"foo") << std::u32string_view(U"") << std::u32string_view(U"barbaz", 3); + d.nospace().noquote() << std::u32string_view(U"baz"); + } +#ifndef QT_NO_MESSAGELOGCONTEXT + file = __FILE__; line = __LINE__ - 5; function = Q_FUNC_INFO; +#endif + QCOMPARE(s_msgType, QtDebugMsg); + QCOMPARE(s_msg, QString::fromLatin1("\"foo\" \"\" \"bar\" baz")); + QCOMPARE(QString::fromLatin1(s_file), file); + QCOMPARE(s_line, line); + QCOMPARE(QString::fromLatin1(s_function), function); + + /* simpler tests from now on */ + std::u32string_view string(U"\"Hello\""); + qDebug() << string; + QCOMPARE(s_msg, QString("\"\\\"Hello\\\"\"")); + + qDebug().noquote().nospace() << string; + QCOMPARE(s_msg, QString::fromStdU32String(std::u32string(string))); + + qDebug().noquote().nospace() << qSetFieldWidth(8) << string; + QCOMPARE(s_msg, " " + QString::fromStdU32String(std::u32string(string))); +} + void tst_QDebug::qDebugQByteArray() const { QString file, function; @@ -837,7 +1181,7 @@ void tst_QDebug::threadSafety() const s_sema.release(numThreads); sync.waitForFinished(); QMutexLocker lock(&s_mutex); - QCOMPARE(s_messages.count(), numThreads); + QCOMPARE(s_messages.size(), numThreads); for (int i = 0; i < numThreads; ++i) { QCOMPARE(s_messages.at(i), QStringLiteral("doDebug")); } @@ -873,6 +1217,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/CMakeLists.txt b/tests/auto/corelib/io/qdir/CMakeLists.txt index ee24703bd3..966cf3e486 100644 --- a/tests/auto/corelib/io/qdir/CMakeLists.txt +++ b/tests/auto/corelib/io/qdir/CMakeLists.txt @@ -1,4 +1,5 @@ -# Generated from qdir.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_qdir Test: @@ -16,7 +17,7 @@ list(APPEND test_data "tst_qdir.cpp") qt_internal_add_test(tst_qdir SOURCES tst_qdir.cpp - PUBLIC_LIBRARIES + LIBRARIES Qt::CorePrivate TESTDATA ${test_data} ) @@ -33,13 +34,9 @@ qt_internal_add_resource(tst_qdir "qdir" ${qdir_resource_files} ) - ## Scopes: ##################################################################### -#### Keys ignored in scope 2:.:.:qdir.pro:IOS: -# QMAKE_INFO_PLIST = "Info.plist" - qt_internal_extend_target(tst_qdir CONDITION CONFIG___contains___builtin_testdata DEFINES BUILTIN_TESTDATA 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/CMakeLists.txt b/tests/auto/corelib/io/qdir/testdir/dir/CMakeLists.txt index 92ce7b4e89..d0ec6dee9a 100644 --- a/tests/auto/corelib/io/qdir/testdir/dir/CMakeLists.txt +++ b/tests/auto/corelib/io/qdir/testdir/dir/CMakeLists.txt @@ -1,4 +1,5 @@ -# Generated from qdir.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## qdir Binary: @@ -6,8 +7,6 @@ qt_internal_add_executable(qdir GUI - DEFINES - QT_DISABLE_DEPRECATED_BEFORE=0 - PUBLIC_LIBRARIES + LIBRARIES Qt::Gui ) diff --git a/tests/auto/corelib/io/qdir/testdir/dir/qdir.pro b/tests/auto/corelib/io/qdir/testdir/dir/qdir.pro index 856d5ea2fb..e69de29bb2 100644 --- a/tests/auto/corelib/io/qdir/testdir/dir/qdir.pro +++ b/tests/auto/corelib/io/qdir/testdir/dir/qdir.pro @@ -1,3 +0,0 @@ - - -DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 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/t |