diff options
Diffstat (limited to 'tests')
264 files changed, 7557 insertions, 3312 deletions
diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt index c780096854..0e6da23c09 100644 --- a/tests/auto/cmake/CMakeLists.txt +++ b/tests/auto/cmake/CMakeLists.txt @@ -97,6 +97,7 @@ if (NOT WIN32 OR (WIN32 AND NOT CMAKE_VERSION VERSION_LESS 2.8.11)) expect_pass(test_add_binary_resources_delayed_file BINARY test_add_binary_resources_delayed_file) endif() expect_pass(test_private_includes) +expect_pass(test_private_targets) expect_pass(test_testlib_definitions) expect_pass(test_json_plugin_includes) diff --git a/tests/auto/cmake/test_QFINDTESTDATA/tests/main.cpp b/tests/auto/cmake/test_QFINDTESTDATA/tests/main.cpp index 0a5b6acd32..4e73598200 100644 --- a/tests/auto/cmake/test_QFINDTESTDATA/tests/main.cpp +++ b/tests/auto/cmake/test_QFINDTESTDATA/tests/main.cpp @@ -1,31 +1,26 @@ /**************************************************************************** ** ** Copyright (C) 2016 Stephen Kelly <steveire@gmail,com> -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** 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$ ** diff --git a/tests/auto/cmake/test_private_targets/CMakeLists.txt b/tests/auto/cmake/test_private_targets/CMakeLists.txt new file mode 100644 index 0000000000..f7f3902869 --- /dev/null +++ b/tests/auto/cmake/test_private_targets/CMakeLists.txt @@ -0,0 +1,9 @@ + +cmake_minimum_required(VERSION 3.0) + +project(test_private_targets) + +find_package(Qt5Gui REQUIRED) + +add_executable(testapp main.cpp) +target_link_libraries(testapp Qt5::GuiPrivate) diff --git a/tests/auto/cmake/test_private_targets/main.cpp b/tests/auto/cmake/test_private_targets/main.cpp new file mode 100644 index 0000000000..40dc4c243c --- /dev/null +++ b/tests/auto/cmake/test_private_targets/main.cpp @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Stephen Kelly <steveire@gmail.com> +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QGuiApplication> + +#include <private/qwindow_p.h> +#include <private/qobject_p.h> +#include <QtGui/private/qwindow_p.h> +#include <QtCore/private/qobject_p.h> + +int main(int argc, char **argv) +{ + QGuiApplication app(argc, argv); + + QWindow window; + + auto windowPrivate = QWindowPrivate::get(&window); + + if (windowPrivate->visible) + return 1; + + auto objectPrivate = QObjectPrivate::get(&window); + + auto mo = window.metaObject(); + + // Should be 0 + return objectPrivate->signalIndex("destroyed()", &mo); +} diff --git a/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp b/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp index a8d64f1cd9..18a6268ec0 100644 --- a/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp +++ b/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp @@ -786,6 +786,9 @@ struct AnimState { int time; int state; }; +QT_BEGIN_NAMESPACE +Q_DECLARE_TYPEINFO(AnimState, Q_MOVABLE_TYPE); +QT_END_NAMESPACE #define Running QAbstractAnimation::Running #define Stopped QAbstractAnimation::Stopped diff --git a/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp index b0b0a307e9..cf4c4e1bdb 100644 --- a/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp +++ b/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp @@ -427,7 +427,7 @@ public: void setOle(int v) { o = v; values << v; } int o; - QList<int> values; + QVector<int> values; }; void tst_QPropertyAnimation::noStartValue() @@ -672,19 +672,15 @@ struct Number Number(int n) : n(n) {} - Number(const Number &other) - : n(other.n){} - - Number &operator=(const Number &other) { - n = other.n; - return *this; - } bool operator==(const Number &other) const { return n == other.n; } int n; }; +QT_BEGIN_NAMESPACE +Q_DECLARE_TYPEINFO(Number, Q_PRIMITIVE_TYPE); +QT_END_NAMESPACE Q_DECLARE_METATYPE(Number) diff --git a/tests/auto/corelib/animation/qsequentialanimationgroup/BLACKLIST b/tests/auto/corelib/animation/qsequentialanimationgroup/BLACKLIST index e11e4ae6fb..36b777de34 100644 --- a/tests/auto/corelib/animation/qsequentialanimationgroup/BLACKLIST +++ b/tests/auto/corelib/animation/qsequentialanimationgroup/BLACKLIST @@ -2,3 +2,4 @@ windows [finishWithUncontrolledAnimation] windows +macos-10.12 diff --git a/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp b/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp index 6d66f05835..06e9fe7a66 100644 --- a/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp +++ b/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp @@ -563,7 +563,7 @@ void tst_QSequentialAnimationGroup::seekingBackwards() QCOMPARE(a1_s_o3->state(), QAnimationGroup::Stopped); } -typedef QList<QAbstractAnimation::State> StateList; +typedef QVector<QAbstractAnimation::State> StateList; static bool compareStates(const QSignalSpy& spy, const StateList &expectedStates) { diff --git a/tests/auto/corelib/global/global.pro b/tests/auto/corelib/global/global.pro index 219e9de818..b4cc8035e6 100644 --- a/tests/auto/corelib/global/global.pro +++ b/tests/auto/corelib/global/global.pro @@ -5,6 +5,7 @@ SUBDIRS=\ qgetputenv \ qglobal \ qnumeric \ + qfloat16 \ qrand \ qlogging \ qtendian \ diff --git a/tests/auto/corelib/global/qflags/tst_qflags.cpp b/tests/auto/corelib/global/qflags/tst_qflags.cpp index 634d9a2df3..d70b099fe3 100644 --- a/tests/auto/corelib/global/qflags/tst_qflags.cpp +++ b/tests/auto/corelib/global/qflags/tst_qflags.cpp @@ -134,11 +134,11 @@ void tst_QFlags::signedness() // underlying type is implementation-defined, we need to allow for // a different signedness, so we only check that the relative // signedness of the types matches: - Q_STATIC_ASSERT((QtPrivate::QIsUnsignedEnum<Qt::MouseButton>::value == - QtPrivate::QIsUnsignedEnum<Qt::MouseButtons::Int>::value)); + Q_STATIC_ASSERT((std::is_unsigned<typename std::underlying_type<Qt::MouseButton>::type>::value == + std::is_unsigned<Qt::MouseButtons::Int>::value)); - Q_STATIC_ASSERT((QtPrivate::QIsSignedEnum<Qt::AlignmentFlag>::value == - QtPrivate::QIsSignedEnum<Qt::Alignment::Int>::value)); + Q_STATIC_ASSERT((std::is_signed<typename std::underlying_type<Qt::AlignmentFlag>::type>::value == + std::is_signed<Qt::Alignment::Int>::value)); } #if defined(Q_COMPILER_CLASS_ENUM) diff --git a/tests/auto/corelib/global/qfloat16/qfloat16.pro b/tests/auto/corelib/global/qfloat16/qfloat16.pro new file mode 100644 index 0000000000..42081181b4 --- /dev/null +++ b/tests/auto/corelib/global/qfloat16/qfloat16.pro @@ -0,0 +1,4 @@ +CONFIG += testcase +TARGET = tst_qfloat16 +QT = core testlib +SOURCES = tst_qfloat16.cpp diff --git a/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp b/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp new file mode 100644 index 0000000000..3ec863302e --- /dev/null +++ b/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp @@ -0,0 +1,254 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include <QFloat16> + +#include <math.h> + +class tst_qfloat16: public QObject +{ + Q_OBJECT + +private slots: + void fuzzyCompare_data(); + void fuzzyCompare(); + void ltgt_data(); + void ltgt(); + void qNan(); + void float_cast(); + void float_cast_data(); + void promotionTests(); +}; + +void tst_qfloat16::fuzzyCompare_data() +{ + QTest::addColumn<qfloat16>("val1"); + QTest::addColumn<qfloat16>("val2"); + QTest::addColumn<bool>("fuzEqual"); + QTest::addColumn<bool>("isEqual"); + + QTest::newRow("zero") << qfloat16(0.0f) << qfloat16(0.0f) << true << true; + QTest::newRow("ten") << qfloat16(1e1f) << qfloat16(1e1f) << true << true; + QTest::newRow("large") << qfloat16(1e4f) << qfloat16(1e4f) << true << true; + QTest::newRow("small") << qfloat16(1e-5f) << qfloat16(1e-5f) << true << true; + QTest::newRow("eps") << qfloat16(10.01f) << qfloat16(10.02f) << true << false; + QTest::newRow("eps2") << qfloat16(1024.f) << qfloat16(1033.f) << true << false; + + QTest::newRow("mis1") << qfloat16(0.0f) << qfloat16(1.0f) << false << false; + QTest::newRow("mis2") << qfloat16(0.0f) << qfloat16(1e7f) << false << false; + QTest::newRow("mis3") << qfloat16(0.0f) << qfloat16(1e-4f) << false << false; + QTest::newRow("mis4") << qfloat16(1e8f) << qfloat16(1e-8f) << false << false; + QTest::newRow("mis5") << qfloat16(1e-4f) << qfloat16(1e-5) << false << false; + QTest::newRow("mis6") << qfloat16(1024.f) << qfloat16(1034.f) << false << false; +} + +void tst_qfloat16::fuzzyCompare() +{ + QFETCH(qfloat16, val1); + QFETCH(qfloat16, val2); + QFETCH(bool, fuzEqual); + QFETCH(bool, isEqual); + + if (!isEqual && (val1==val2)) + qWarning() << "Identical arguments provided unintentionally!"; + + if (fuzEqual) { + QVERIFY(::qFuzzyCompare(val1, val2)); + QVERIFY(::qFuzzyCompare(val2, val1)); + QVERIFY(::qFuzzyCompare(-val1, -val2)); + QVERIFY(::qFuzzyCompare(-val2, -val1)); + } else { + QVERIFY(!::qFuzzyCompare(val1, val2)); + QVERIFY(!::qFuzzyCompare(val2, val1)); + QVERIFY(!::qFuzzyCompare(-val1, -val2)); + QVERIFY(!::qFuzzyCompare(-val2, -val1)); + } +} + +void tst_qfloat16::ltgt_data() +{ + QTest::addColumn<float>("val1"); + QTest::addColumn<float>("val2"); + + QTest::newRow("zero") << 0.0f << 0.0f; + QTest::newRow("ten") << 10.0f << 10.0f; + QTest::newRow("large") << 100000.0f << 100000.0f; + QTest::newRow("small") << 0.0000001f << 0.0000001f; + QTest::newRow("eps") << 10.000000000000001f << 10.00000000000002f; + QTest::newRow("eps2") << 10.000000000000001f << 10.000000000000009f; + + QTest::newRow("mis1") << 0.0f << 1.0f; + QTest::newRow("mis2") << 0.0f << 10000000.0f; + QTest::newRow("mis3") << 0.0f << 0.0001f; + QTest::newRow("mis4") << 100000000.0f << 0.000000001f; + QTest::newRow("mis5") << 0.0001f << 0.00001f; + + QTest::newRow("45,23") << 45.f << 23.f; + QTest::newRow("1000,76") << 1000.f << 76.f; +} + +void tst_qfloat16::ltgt() +{ + QFETCH(float, val1); + QFETCH(float, val2); + + QCOMPARE(qfloat16(val1) == qfloat16(val2), val1 == val2); + QCOMPARE(qfloat16(val1) < qfloat16(val2), val1 < val2); + QCOMPARE(qfloat16(val1) <= qfloat16(val2), val1 <= val2); + QCOMPARE(qfloat16(val1) > qfloat16(val2), val1 > val2); + QCOMPARE(qfloat16(val1) >= qfloat16(val2), val1 >= val2); + + QCOMPARE(qfloat16(val1) == qfloat16(-val2), val1 == -val2); + QCOMPARE(qfloat16(val1) < qfloat16(-val2), val1 < -val2); + QCOMPARE(qfloat16(val1) <= qfloat16(-val2), val1 <= -val2); + QCOMPARE(qfloat16(val1) > qfloat16(-val2), val1 > -val2); + QCOMPARE(qfloat16(val1) >= qfloat16(-val2), val1 >= -val2); + + QCOMPARE(qfloat16(-val1) == qfloat16(val2), -val1 == val2); + QCOMPARE(qfloat16(-val1) < qfloat16(val2), -val1 < val2); + QCOMPARE(qfloat16(-val1) <= qfloat16(val2), -val1 <= val2); + QCOMPARE(qfloat16(-val1) > qfloat16(val2), -val1 > val2); + QCOMPARE(qfloat16(-val1) >= qfloat16(val2), -val1 >= val2); + + QCOMPARE(qfloat16(-val1) == qfloat16(-val2), -val1 == -val2); + QCOMPARE(qfloat16(-val1) < qfloat16(-val2), -val1 < -val2); + QCOMPARE(qfloat16(-val1) <= qfloat16(-val2), -val1 <= -val2); + QCOMPARE(qfloat16(-val1) > qfloat16(-val2), -val1 > -val2); + QCOMPARE(qfloat16(-val1) >= qfloat16(-val2), -val1 >= -val2); +} + +#if defined __FAST_MATH__ && (__GNUC__ * 100 + __GNUC_MINOR__ >= 404) + // turn -ffast-math off +# pragma GCC optimize "no-fast-math" +#endif + +void tst_qfloat16::qNan() +{ +#if defined __FAST_MATH__ && (__GNUC__ * 100 + __GNUC_MINOR__ < 404) + QSKIP("Non-conformant fast math mode is enabled, cannot run test"); +#endif + qfloat16 nan = qQNaN(); + QVERIFY(!(0. > nan)); + QVERIFY(!(0. < nan)); + QVERIFY(qIsNaN(nan)); + QVERIFY(qIsNaN(nan + 1.f)); + QVERIFY(qIsNaN(-nan)); + qfloat16 inf = qInf(); + QVERIFY(inf > qfloat16(0)); + QVERIFY(-inf < qfloat16(0)); + QVERIFY(qIsInf(inf)); + QVERIFY(qIsInf(-inf)); + QVERIFY(qIsInf(2.f*inf)); + QVERIFY(qIsInf(inf*2.f)); + QCOMPARE(qfloat16(1.f/inf), qfloat16(0.f)); +#ifdef Q_CC_INTEL + QEXPECT_FAIL("", "ICC optimizes zero * anything to zero", Continue); +#endif + QVERIFY(qIsNaN(nan*0.f)); +#ifdef Q_CC_INTEL + QEXPECT_FAIL("", "ICC optimizes zero * anything to zero", Continue); +#endif + QVERIFY(qIsNaN(inf*0.f)); + QVERIFY(qFuzzyCompare(qfloat16(1.f/inf), qfloat16(0.0))); +} + +void tst_qfloat16::float_cast_data() +{ + QTest::addColumn<float>("val"); + + QTest::newRow("zero") << 0.f; + QTest::newRow("one") << 1e0f; + QTest::newRow("ten") << 1e1f; + QTest::newRow("hund") << 1e2f; + QTest::newRow("thou") << 1e3f; + QTest::newRow("tthou") << 1e4f; + //QTest::newRow("hthou") << 1e5f; + //QTest::newRow("mil") << 1e6f; + //QTest::newRow("tmil") << 1e7f; + //QTest::newRow("hmil") << 1e8f; +} + +void tst_qfloat16::float_cast() +{ + QFETCH(float, val); + + QVERIFY(qFuzzyCompare(float(qfloat16(val)),val)); + QVERIFY(qFuzzyCompare(float(qfloat16(-val)),-val)); +} + +void tst_qfloat16::promotionTests() +{ + QCOMPARE(sizeof(qfloat16),sizeof(qfloat16(1.f)+qfloat16(1.f))); + QCOMPARE(sizeof(qfloat16),sizeof(qfloat16(1.f)-qfloat16(1.f))); + QCOMPARE(sizeof(qfloat16),sizeof(qfloat16(1.f)*qfloat16(1.f))); + QCOMPARE(sizeof(qfloat16),sizeof(qfloat16(1.f)/qfloat16(1.f))); + + QCOMPARE(sizeof(float),sizeof(1.f+qfloat16(1.f))); + QCOMPARE(sizeof(float),sizeof(1.f-qfloat16(1.f))); + QCOMPARE(sizeof(float),sizeof(1.f*qfloat16(1.f))); + QCOMPARE(sizeof(float),sizeof(1.f/qfloat16(1.f))); + + QCOMPARE(sizeof(float),sizeof(qfloat16(1.f)+1.f)); + QCOMPARE(sizeof(float),sizeof(qfloat16(1.f)-1.f)); + QCOMPARE(sizeof(float),sizeof(qfloat16(1.f)*1.f)); + QCOMPARE(sizeof(float),sizeof(qfloat16(1.f)/1.f)); + + QCOMPARE(sizeof(double),sizeof(1.+qfloat16(1.f))); + QCOMPARE(sizeof(double),sizeof(1.-qfloat16(1.f))); + QCOMPARE(sizeof(double),sizeof(1.*qfloat16(1.f))); + QCOMPARE(sizeof(double),sizeof(1./qfloat16(1.f))); + + QCOMPARE(sizeof(double),sizeof(qfloat16(1.f)+1.)); + QCOMPARE(sizeof(double),sizeof(qfloat16(1.f)-1.)); + QCOMPARE(sizeof(double),sizeof(qfloat16(1.f)*1.)); + QCOMPARE(sizeof(double),sizeof(qfloat16(1.f)/1.)); + + QCOMPARE(sizeof(long double),sizeof((long double)(1.)+qfloat16(1.f))); + QCOMPARE(sizeof(long double),sizeof((long double)(1.)-qfloat16(1.f))); + QCOMPARE(sizeof(long double),sizeof((long double)(1.)*qfloat16(1.f))); + QCOMPARE(sizeof(long double),sizeof((long double)(1.)/qfloat16(1.f))); + + QCOMPARE(sizeof(long double),sizeof(qfloat16(1.f)+(long double)(1.))); + QCOMPARE(sizeof(long double),sizeof(qfloat16(1.f)-(long double)(1.))); + QCOMPARE(sizeof(long double),sizeof(qfloat16(1.f)*(long double)(1.))); + QCOMPARE(sizeof(long double),sizeof(qfloat16(1.f)/(long double)(1.))); + + QCOMPARE(sizeof(double),sizeof(1+qfloat16(1.f))); + QCOMPARE(sizeof(double),sizeof(1-qfloat16(1.f))); + QCOMPARE(sizeof(double),sizeof(1*qfloat16(1.f))); + QCOMPARE(sizeof(double),sizeof(1/qfloat16(1.f))); + + QCOMPARE(sizeof(double),sizeof(qfloat16(1.f)+1)); + QCOMPARE(sizeof(double),sizeof(qfloat16(1.f)-1)); + QCOMPARE(sizeof(double),sizeof(qfloat16(1.f)*1)); + QCOMPARE(sizeof(double),sizeof(qfloat16(1.f)/1)); +} + +QTEST_APPLESS_MAIN(tst_qfloat16) +#include "tst_qfloat16.moc" diff --git a/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp b/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp index 7ffb5d0fd7..66fc578d5f 100644 --- a/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp +++ b/tests/auto/corelib/global/qgetputenv/tst_qgetputenv.cpp @@ -112,13 +112,13 @@ void tst_QGetPutEnv::intValue_data() ROW(0xffffffff, 0, false); const int bases[] = {10, 8, 16}; for (size_t i = 0; i < sizeof bases / sizeof *bases; ++i) { - QTest::newRow(qPrintable(QString::asprintf("INT_MAX, base %d", bases[i]))) + QTest::addRow("INT_MAX, base %d", bases[i]) << QByteArray::number(INT_MAX) << INT_MAX << true; - QTest::newRow(qPrintable(QString::asprintf("INT_MAX+1, base %d", bases[i]))) + QTest::addRow("INT_MAX+1, base %d", bases[i]) << QByteArray::number(qlonglong(INT_MAX) + 1) << 0 << false; - QTest::newRow(qPrintable(QString::asprintf("INT_MIN, base %d", bases[i]))) + QTest::addRow("INT_MIN, base %d", bases[i]) << QByteArray::number(INT_MIN) << INT_MIN << true; - QTest::newRow(qPrintable(QString::asprintf("INT_MIN-1, base %d", bases[i]))) + QTest::addRow("INT_MIN-1, base %d", bases[i]) << QByteArray::number(qlonglong(INT_MIN) - 1) << 0 << false; }; } diff --git a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp index bb6ec1c8e7..083526fdc4 100644 --- a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp +++ b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp @@ -102,6 +102,13 @@ void tst_QGlobal::for_each() QCOMPARE(i, counter++); } QCOMPARE(counter, list.count()); + + // check whether we can use a lambda + counter = 0; + foreach (int i, [&](){ return list; }()) { + QCOMPARE(i, counter++); + } + QCOMPARE(counter, list.count()); } void tst_QGlobal::qassert() diff --git a/tests/auto/corelib/global/qglobalstatic/qglobalstatic.pro b/tests/auto/corelib/global/qglobalstatic/qglobalstatic.pro index 056d940da7..21bb040b8d 100644 --- a/tests/auto/corelib/global/qglobalstatic/qglobalstatic.pro +++ b/tests/auto/corelib/global/qglobalstatic/qglobalstatic.pro @@ -5,7 +5,6 @@ QT -= gui TARGET = tst_qglobalstatic CONFIG += console -CONFIG -= app_bundle CONFIG += exceptions SOURCES += tst_qglobalstatic.cpp diff --git a/tests/auto/corelib/global/qglobalstatic/tst_qglobalstatic.cpp b/tests/auto/corelib/global/qglobalstatic/tst_qglobalstatic.cpp index 1253a32f97..2d7db813dd 100644 --- a/tests/auto/corelib/global/qglobalstatic/tst_qglobalstatic.cpp +++ b/tests/auto/corelib/global/qglobalstatic/tst_qglobalstatic.cpp @@ -4,9 +4,9 @@ ** Copyright (C) 2016 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** -** This file is part of the QtCore module of the Qt Toolkit. +** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:BSD$ +** $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 @@ -15,35 +15,13 @@ ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** 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$ ** diff --git a/tests/auto/corelib/global/qlogging/app/app.pro b/tests/auto/corelib/global/qlogging/app/app.pro index 8ada04acdc..6fba1b6129 100644 --- a/tests/auto/corelib/global/qlogging/app/app.pro +++ b/tests/auto/corelib/global/qlogging/app/app.pro @@ -11,5 +11,7 @@ CONFIG += console SOURCES += main.cpp DEFINES += QT_MESSAGELOGCONTEXT -gcc:!mingw:!haiku: QMAKE_LFLAGS += -rdynamic - +gcc:!mingw:!haiku { + QMAKE_LFLAGS += -rdynamic + contains(QT_ARCH, arm): QMAKE_CXXFLAGS += -funwind-tables +} diff --git a/tests/auto/corelib/global/qlogging/test/test.pro b/tests/auto/corelib/global/qlogging/test/test.pro index 93eee7307a..7c46ae9d16 100644 --- a/tests/auto/corelib/global/qlogging/test/test.pro +++ b/tests/auto/corelib/global/qlogging/test/test.pro @@ -1,5 +1,5 @@ CONFIG += testcase -CONFIG -= app_bundle debug_and_release_target +CONFIG -= debug_and_release_target qtConfig(c++11): CONFIG += c++11 qtConfig(c++14): CONFIG += c++14 TARGET = ../tst_qlogging diff --git a/tests/auto/corelib/io/io.pro b/tests/auto/corelib/io/io.pro index ec2c803012..01ed84fda9 100644 --- a/tests/auto/corelib/io/io.pro +++ b/tests/auto/corelib/io/io.pro @@ -11,6 +11,7 @@ SUBDIRS=\ largefile \ qfileinfo \ qfileselector \ + qfilesystemmetadata \ qfilesystementry \ qfilesystemwatcher \ qiodevice \ @@ -61,14 +62,16 @@ SUBDIRS=\ qurlinternal \ qloggingregistry -!qtConfig(process): SUBDIRS -= \ - qprocess \ - qprocess-noapplication \ - qprocessenvironment - win32:!qtConfig(private_tests): SUBDIRS -= \ qfilesystementry +!qtConfig(processenvironment): SUBDIRS -= \ + qprocessenvironment + +!qtConfig(process): SUBDIRS -= \ + qprocess \ + qprocess-noapplication + winrt: SUBDIRS -= \ qstorageinfo \ qwinoverlappedionotifier diff --git a/tests/auto/corelib/io/largefile/largefile.pro b/tests/auto/corelib/io/largefile/largefile.pro index 6c1bb8d7ea..e96d1398ca 100644 --- a/tests/auto/corelib/io/largefile/largefile.pro +++ b/tests/auto/corelib/io/largefile/largefile.pro @@ -2,3 +2,5 @@ CONFIG += testcase TARGET = tst_largefile QT = core testlib SOURCES = tst_largefile.cpp +INCLUDEPATH += ../../../../shared/ +HEADERS += ../../../../shared/emulationdetector.h diff --git a/tests/auto/corelib/io/largefile/tst_largefile.cpp b/tests/auto/corelib/io/largefile/tst_largefile.cpp index 7a174b79fd..99e1d5a32f 100644 --- a/tests/auto/corelib/io/largefile/tst_largefile.cpp +++ b/tests/auto/corelib/io/largefile/tst_largefile.cpp @@ -47,6 +47,8 @@ # endif #endif // Q_OS_WIN +#include "emulationdetector.h" + class tst_LargeFile : public QObject { @@ -68,6 +70,10 @@ public: #else maxSizeBits = 24; // 16 MiB #endif + + // QEMU only supports < 4GB files + if (EmulationDetector::isRunningArmOnX86()) + maxSizeBits = qMin(maxSizeBits, 28); } private: diff --git a/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp b/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp index 5b03b35780..0068411b94 100644 --- a/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp +++ b/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp @@ -77,6 +77,9 @@ private slots: void stream_QDateTime_data(); void stream_QDateTime(); + void stream_nullptr_t_data(); + void stream_nullptr_t(); + void stream_QFont_data(); void stream_QFont(); @@ -187,6 +190,7 @@ private: void writeQBrush(QDataStream *s); void writeQColor(QDataStream *s); void writeQByteArray(QDataStream *s); + void writenullptr_t(QDataStream *s); #ifndef QT_NO_CURSOR void writeQCursor(QDataStream *s); #endif @@ -216,6 +220,7 @@ private: void readQBrush(QDataStream *s); void readQColor(QDataStream *s); void readQByteArray(QDataStream *s); + void readnullptr_t(QDataStream *s); #ifndef QT_NO_CURSOR void readQCursor(QDataStream *s); #endif @@ -1008,6 +1013,11 @@ void tst_QDataStream::writeQByteArray(QDataStream *s) *s << d4; } +void tst_QDataStream::writenullptr_t(QDataStream *s) +{ + *s << nullptr; +} + void tst_QDataStream::readQByteArray(QDataStream *s) { QByteArray test(qByteArrayData(dataIndex(QTest::currentDataTag()))); @@ -1016,6 +1026,13 @@ void tst_QDataStream::readQByteArray(QDataStream *s) QCOMPARE(d4, test); } +void tst_QDataStream::readnullptr_t(QDataStream *s) +{ + std::nullptr_t ptr; + *s >> ptr; + QCOMPARE(ptr, nullptr); +} + // ************************************ #ifndef QT_NO_CURSOR static QCursor qCursorData(int index) @@ -1263,6 +1280,17 @@ void tst_QDataStream::stream_QDateTime() STREAM_IMPL(QDateTime); } +void tst_QDataStream::stream_nullptr_t_data() +{ + stream_data(1); // there's only one value possible +} + +void tst_QDataStream::stream_nullptr_t() +{ + using namespace std; + STREAM_IMPL(nullptr_t); +} + void tst_QDataStream::writeQDateTime(QDataStream *s) { QDateTime dt(qDateTimeData(dataIndex(QTest::currentDataTag()))); diff --git a/tests/auto/corelib/io/qdir/tst_qdir.cpp b/tests/auto/corelib/io/qdir/tst_qdir.cpp index 5a46c1159e..946620d61f 100644 --- a/tests/auto/corelib/io/qdir/tst_qdir.cpp +++ b/tests/auto/corelib/io/qdir/tst_qdir.cpp @@ -1,5 +1,6 @@ /**************************************************************************** ** +** Copyright (C) 2017 Intel Corporation. ** Copyright (C) 2016 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** @@ -101,6 +102,7 @@ private slots: void mkdirRmdir_data(); void mkdirRmdir(); + void mkdirOnSymlink(); void makedirReturnCode(); @@ -208,6 +210,9 @@ private slots: void cdBelowRoot_data(); void cdBelowRoot(); + void emptyDir(); + void nonEmptyDir(); + private: #ifdef BUILTIN_TESTDATA QString m_dataPath; @@ -384,6 +389,56 @@ void tst_QDir::mkdirRmdir() QVERIFY(!fi.exists()); } +void tst_QDir::mkdirOnSymlink() +{ +#ifndef Q_OS_UNIX + QSKIP("Test only valid on an OS that supports symlinks"); +#else + // Create the structure: + // . + // ├── symlink -> two/three + // └── two + // └── three + // so when we mkdir("symlink/../four/five"), we end up with: + // . + // ├── symlink -> two/three + // └── two + // ├── four + // │ └── five + // └── three + + QDir dir; + struct Clean { + QDir &dir; + Clean(QDir &dir) : dir(dir) {} + ~Clean() { doClean(); } + void doClean() { + dir.rmpath("two/three"); + dir.rmpath("two/four/five"); + // in case the test fails, don't leave junk behind + dir.rmpath("four/five"); + QFile::remove("symlink"); + } + }; + Clean clean(dir); + clean.doClean(); + + // create our structure: + dir.mkpath("two/three"); + ::symlink("two/three", "symlink"); + + // try it: + QString path = "symlink/../four/five"; + QVERIFY(dir.mkpath(path)); + QFileInfo fi(path); + QVERIFY2(fi.exists() && fi.isDir(), msgDoesNotExist(path).constData()); + + path = "two/four/five"; + fi.setFile(path); + QVERIFY2(fi.exists() && fi.isDir(), msgDoesNotExist(path).constData()); +#endif +} + void tst_QDir::makedirReturnCode() { QString dirName = QString::fromLatin1("makedirReturnCode"); @@ -2264,6 +2319,26 @@ void tst_QDir::cdBelowRoot() QCOMPARE(dir.path(), rootPath); } +void tst_QDir::emptyDir() +{ + const QString tempDir = QDir::currentPath() + "/tmpdir/"; + QVERIFY(QDir().mkdir(tempDir)); + QVERIFY(QDir(tempDir).mkdir("emptyDirectory")); + + QDir testDir(tempDir + "emptyDirectory"); + QVERIFY(testDir.isEmpty()); + QVERIFY(!testDir.isEmpty(QDir::AllEntries)); + QVERIFY(!testDir.isEmpty(QDir::AllEntries | QDir::NoDot)); + QVERIFY(!testDir.isEmpty(QDir::AllEntries | QDir::NoDotDot)); + QVERIFY(QDir(tempDir).removeRecursively()); +} + +void tst_QDir::nonEmptyDir() +{ + const QDir dir(m_dataPath); + QVERIFY(!dir.isEmpty()); +} + QTEST_MAIN(tst_QDir) #include "tst_qdir.moc" diff --git a/tests/auto/corelib/io/qfile/test/test.pro b/tests/auto/corelib/io/qfile/test/test.pro index c0c4b9d5d2..7ad047e8a2 100644 --- a/tests/auto/corelib/io/qfile/test/test.pro +++ b/tests/auto/corelib/io/qfile/test/test.pro @@ -1,11 +1,13 @@ CONFIG += testcase -CONFIG -= app_bundle debug_and_release_target +CONFIG -= debug_and_release_target QT = core-private core testlib qtHaveModule(network): QT += network else: DEFINES += QT_NO_NETWORK TARGET = ../tst_qfile SOURCES = ../tst_qfile.cpp +INCLUDEPATH += ../../../../../shared/ +HEADERS += ../../../../../shared/emulationdetector.h RESOURCES += ../qfile.qrc ../rename-fallback.qrc ../copy-fallback.qrc diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp index 8595c048b2..81c11ef085 100644 --- a/tests/auto/corelib/io/qfile/tst_qfile.cpp +++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp @@ -41,6 +41,8 @@ #include <private/qfsfileengine_p.h> #include <private/qfilesystemengine_p.h> +#include "emulationdetector.h" + #ifdef Q_OS_WIN QT_BEGIN_NAMESPACE extern Q_CORE_EXPORT int qt_ntfs_permission_lookup; @@ -1141,6 +1143,7 @@ void tst_QFile::invalidFile_data() #else #if !defined(Q_OS_WINRT) QTest::newRow( "colon2" ) << invalidDriveLetter() + QString::fromLatin1(":ail:invalid"); + QTest::newRow( "date" ) << QString( "testLog-03:20.803Z.txt" ); #endif QTest::newRow( "colon3" ) << QString( ":failinvalid" ); QTest::newRow( "forwardslash" ) << QString( "fail/invalid" ); @@ -1375,10 +1378,8 @@ void tst_QFile::copyFallback() #ifdef Q_OS_WIN #include <objbase.h> -#ifndef Q_OS_WINPHONE #include <shlobj.h> #endif -#endif #if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) static QString getWorkingDirectoryForLink(const QString &linkFileName) @@ -1688,7 +1689,7 @@ void tst_QFile::isSequential() void tst_QFile::encodeName() { - QCOMPARE(QFile::encodeName(QString::null), QByteArray()); + QCOMPARE(QFile::encodeName(QString()), QByteArray()); } void tst_QFile::truncate() @@ -2394,7 +2395,11 @@ void tst_QFile::virtualFile() // open the file QFile f(fname); QVERIFY2(f.open(QIODevice::ReadOnly), msgOpenFailed(f).constData()); + if (EmulationDetector::isRunningArmOnX86()) + QEXPECT_FAIL("","QEMU does not read /proc/self/maps size correctly", Continue); QCOMPARE(f.size(), Q_INT64_C(0)); + if (EmulationDetector::isRunningArmOnX86()) + QEXPECT_FAIL("","QEMU does not read /proc/self/maps size correctly", Continue); QVERIFY(f.atEnd()); // read data diff --git a/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp b/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp index f2d09429cc..c537e43802 100644 --- a/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp +++ b/tests/auto/corelib/io/qfileselector/tst_qfileselector.cpp @@ -146,7 +146,7 @@ void tst_QFileSelector::basicTest_data() << QString(":/extras/test2"); QTest::newRow("custom1-withselector-nobasefile") << QString(":/extras/test3") << (QStringList() << custom1) - << QString(":/extras/test3"); + << QString(":/extras/+custom1/test3"); QString custom2("custom2"); QString custom3("custom3"); diff --git a/tests/auto/corelib/io/qfilesystemmetadata/qfilesystemmetadata.pro b/tests/auto/corelib/io/qfilesystemmetadata/qfilesystemmetadata.pro new file mode 100644 index 0000000000..a7d50ece43 --- /dev/null +++ b/tests/auto/corelib/io/qfilesystemmetadata/qfilesystemmetadata.pro @@ -0,0 +1,4 @@ +CONFIG += testcase parallel_test +TARGET = tst_qfilesystemmetadata +QT = core-private testlib +SOURCES = tst_qfilesystemmetadata.cpp diff --git a/tests/auto/corelib/io/qfilesystemmetadata/tst_qfilesystemmetadata.cpp b/tests/auto/corelib/io/qfilesystemmetadata/tst_qfilesystemmetadata.cpp new file mode 100644 index 0000000000..1c104688a5 --- /dev/null +++ b/tests/auto/corelib/io/qfilesystemmetadata/tst_qfilesystemmetadata.cpp @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include <QtCore/private/qfilesystemmetadata_p.h> + +class tst_QFileSystemMetaData : public QObject +{ + Q_OBJECT + +private slots: + void timeSinceEpoch(); +}; + +#if defined(QT_BUILD_INTERNAL) && defined(QT_SHARED) +#ifdef Q_OS_WIN +static FILETIME epochToFileTime(long seconds) +{ + const qint64 sec = 10000000; + // FILETIME is time in 1e-7s units since 1601's start: epoch is 1970's + // start, 369 years (of which 3*24 +69/4 = 89 were leap) later. + const qint64 offset = qint64(365 * 369 + 89) * 24 * 3600; + const qint64 convert = (offset + seconds) * sec; + FILETIME parts; + parts.dwHighDateTime = convert >> 32; + parts.dwLowDateTime = convert & 0xffffffff; + return parts; +} +#endif + +void tst_QFileSystemMetaData::timeSinceEpoch() +{ + // Regression test for QTBUG-48306, used to fail for TZ=Russia/Moscow + // Oct 22 2014 6:00 UTC; TZ=Russia/Moscow changed from +4 to +3 on Oct 26. + const long afterEpochUtc = 1413957600L; + QFileSystemMetaData meta; +#ifdef Q_OS_WIN + WIN32_FIND_DATA data; + memset(&data, 0, sizeof(data)); + data.dwFileAttributes = FILE_ATTRIBUTE_NORMAL; + /* data.ftLastAccessTime = data.ftLastWriteTime = */ + data.ftCreationTime = epochToFileTime(afterEpochUtc); + meta.fillFromFindData(data); +#else + QT_STATBUF data; + memset(&data, 0, sizeof(data)); + data.st_ctime = afterEpochUtc; + meta.fillFromStatBuf(data); +#endif + QCOMPARE(meta.creationTime().toUTC(), + QDateTime::fromMSecsSinceEpoch(afterEpochUtc * qint64(1000), Qt::UTC)); +} +#else // i.e. no Q_AUTOTEST_EXPORT +void tst_QFileSystemMetaData::timeSinceEpoch() +{ + QSKIP("QFileSystemMetaData methods aren't available to test"); +} +#endif +QTEST_MAIN(tst_QFileSystemMetaData) +#include <tst_qfilesystemmetadata.moc> diff --git a/tests/auto/corelib/io/qlockfile/tst_qlockfile.pro b/tests/auto/corelib/io/qlockfile/tst_qlockfile.pro index 7b83d5dbe8..7a304fe779 100644 --- a/tests/auto/corelib/io/qlockfile/tst_qlockfile.pro +++ b/tests/auto/corelib/io/qlockfile/tst_qlockfile.pro @@ -1,5 +1,4 @@ CONFIG += testcase -CONFIG -= app_bundle TARGET = tst_qlockfile SOURCES += tst_qlockfile.cpp diff --git a/tests/auto/corelib/io/qprocess-noapplication/qprocess-noapplication.pro b/tests/auto/corelib/io/qprocess-noapplication/qprocess-noapplication.pro index e46e7e1100..8e46320e0c 100644 --- a/tests/auto/corelib/io/qprocess-noapplication/qprocess-noapplication.pro +++ b/tests/auto/corelib/io/qprocess-noapplication/qprocess-noapplication.pro @@ -1,4 +1,4 @@ CONFIG += testcase -CONFIG -= app_bundle debug_and_release_target +CONFIG -= debug_and_release_target QT = core testlib SOURCES = tst_qprocessnoapplication.cpp diff --git a/tests/auto/corelib/io/qprocess/test/test.pro b/tests/auto/corelib/io/qprocess/test/test.pro index 96d105a4b4..7d6a7973dc 100644 --- a/tests/auto/corelib/io/qprocess/test/test.pro +++ b/tests/auto/corelib/io/qprocess/test/test.pro @@ -1,5 +1,5 @@ CONFIG += testcase -CONFIG -= app_bundle debug_and_release_target +CONFIG -= debug_and_release_target QT = core-private testlib network SOURCES = ../tst_qprocess.cpp diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp index 82efbdcb2c..0783a65d8b 100644 --- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp +++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp @@ -1015,7 +1015,7 @@ void tst_QProcess::softExitInSlots() SoftExitProcess proc(signalToConnect); proc.writeAfterStart("OLEBOLE", 8); // include the \0 proc.start(appName); - QTRY_VERIFY_WITH_TIMEOUT(proc.waitedForFinished, 10000); + QTRY_VERIFY_WITH_TIMEOUT(proc.waitedForFinished, 60000); QCOMPARE(proc.state(), QProcess::NotRunning); } diff --git a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp index 199ab442c4..332c2dcc01 100644 --- a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp +++ b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp @@ -184,6 +184,7 @@ private slots: void embeddedZeroByte_data(); void embeddedZeroByte(); + void testXdg(); private: void cleanupTestFiles(); @@ -3565,5 +3566,77 @@ void tst_QSettings::consistentRegistryStorage() } #endif +#if defined(QT_BUILD_INTERNAL) && defined(Q_OS_UNIX) && !defined(Q_OS_DARWIN) && !defined(Q_OS_ANDROID) && !defined(QT_NO_STANDARDPATHS) +QT_BEGIN_NAMESPACE +extern void clearDefaultPaths(); +QT_END_NAMESPACE +#endif +void tst_QSettings::testXdg() +{ +#if defined(QT_BUILD_INTERNAL) && defined(Q_OS_UNIX) && !defined(Q_OS_DARWIN) && !defined(Q_OS_ANDROID) && !defined(QT_NO_STANDARDPATHS) + // Note: The XDG_CONFIG_DIRS test must be done before overriding the system path + // by QSettings::setPath/setSystemIniPath (used in cleanupTestFiles()). + clearDefaultPaths(); + + // Initialize the env. variable & populate testing files. + const QStringList config_dirs = { settingsPath("xdg_1st"), settingsPath("xdg_2nd"), settingsPath("xdg_3rd") }; + qputenv("XDG_CONFIG_DIRS", config_dirs.join(':').toUtf8()); + QList<QSettings *> xdg_orgs, xdg_apps; + for (const auto & dir : config_dirs) { + xdg_orgs << new QSettings{dir + "/software.org.conf", QSettings::NativeFormat}; + xdg_apps << new QSettings{dir + "/software.org/KillerAPP.conf", QSettings::NativeFormat}; + } + Q_ASSERT(config_dirs.size() == 3 && xdg_orgs.size() == 3 && xdg_apps.size() == 3); + for (int i = 0; i < 3; ++i) { + xdg_orgs[i]->setValue("all", QString{"all_org%1"}.arg(i)); + xdg_apps[i]->setValue("all", QString{"all_app%1"}.arg(i)); + xdg_orgs[i]->setValue("all_only_org", QString{"all_only_org%1"}.arg(i)); + xdg_apps[i]->setValue("all_only_app", QString{"all_only_app%1"}.arg(i)); + + if (i > 0) { + xdg_orgs[i]->setValue("from2nd", QString{"from2nd_org%1"}.arg(i)); + xdg_apps[i]->setValue("from2nd", QString{"from2nd_app%1"}.arg(i)); + xdg_orgs[i]->setValue("from2nd_only_org", QString{"from2nd_only_org%1"}.arg(i)); + xdg_apps[i]->setValue("from2nd_only_app", QString{"from2nd_only_app%1"}.arg(i)); + } + + if (i > 1) { + xdg_orgs[i]->setValue("from3rd", QString{"from3rd_org%1"}.arg(i)); + xdg_apps[i]->setValue("from3rd", QString{"from3rd_app%1"}.arg(i)); + xdg_orgs[i]->setValue("from3rd_only_org", QString{"from3rd_only_org%1"}.arg(i)); + xdg_apps[i]->setValue("from3rd_only_app", QString{"from3rd_only_app%1"}.arg(i)); + } + } + qDeleteAll(xdg_apps); + qDeleteAll(xdg_orgs); + + // Do the test. + QSettings app{QSettings::SystemScope, "software.org", "KillerAPP"}, org{QSettings::SystemScope, "software.org"}; + + QVERIFY(app.value("all").toString() == "all_app0"); + QVERIFY(org.value("all").toString() == "all_org0"); + QVERIFY(app.value("all_only_org").toString() == "all_only_org0"); + QVERIFY(org.value("all_only_org").toString() == "all_only_org0"); + QVERIFY(app.value("all_only_app").toString() == "all_only_app0"); + QVERIFY(org.value("all_only_app").toString() == QString{}); + + QVERIFY(app.value("from2nd").toString() == "from2nd_app1"); + QVERIFY(org.value("from2nd").toString() == "from2nd_org1"); + QVERIFY(app.value("from2nd_only_org").toString() == "from2nd_only_org1"); + QVERIFY(org.value("from2nd_only_org").toString() == "from2nd_only_org1"); + QVERIFY(app.value("from2nd_only_app").toString() == "from2nd_only_app1"); + QVERIFY(org.value("from2nd_only_app").toString() == QString{}); + + QVERIFY(app.value("from3rd").toString() == "from3rd_app2"); + QVERIFY(org.value("from3rd").toString() == "from3rd_org2"); + QVERIFY(app.value("from3rd_only_org").toString() == "from3rd_only_org2"); + QVERIFY(org.value("from3rd_only_org").toString() == "from3rd_only_org2"); + QVERIFY(app.value("from3rd_only_app").toString() == "from3rd_only_app2"); + QVERIFY(org.value("from3rd_only_app").toString() == QString{}); +#else + QSKIP("This test is performed in QT_BUILD_INTERNAL on Q_XDG_PLATFORM with use of standard paths only."); +#endif +} + QTEST_MAIN(tst_QSettings) #include "tst_qsettings.moc" diff --git a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp index a7a761a2da..0a00e00d83 100644 --- a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp +++ b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp @@ -385,7 +385,7 @@ void tst_qstandardpaths::testFindExecutable_data() QTest::newRow("win-cmd-nosuffix") << QString() << QString::fromLatin1("cmd") << cmdPath; - if (QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS8) { + if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows8) { // The logo executable on Windows 8 is perfectly suited for testing that the // suffix mechanism is not thrown off by dots in the name. // Note: Requires disabling WOW64 redirection, see initTestCase() diff --git a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp index 487c13be94..758bbead84 100644 --- a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp +++ b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp @@ -57,6 +57,8 @@ private slots: void fileTemplate_data(); void getSetCheck(); void fileName(); + void filePath_data(); + void filePath(); void autoRemove(); void nonWritableCurrentDir(); void openOnRootDrives(); @@ -204,6 +206,29 @@ void tst_QTemporaryDir::fileName() QCOMPARE(absoluteFilePath, absoluteTempPath); } +void tst_QTemporaryDir::filePath_data() +{ + QTest::addColumn<QString>("templatePath"); + QTest::addColumn<QString>("fileName"); + + QTest::newRow("0") << QString() << "/tmpfile"; + QTest::newRow("1") << QString() << "tmpfile"; + QTest::newRow("2") << "XXXXX" << "tmpfile"; + QTest::newRow("3") << "YYYYY" << "subdir/file"; +} + +void tst_QTemporaryDir::filePath() +{ + QFETCH(QString, templatePath); + QFETCH(QString, fileName); + + QTemporaryDir dir(templatePath); + const QString filePath = dir.filePath(fileName); + const QString expectedFilePath = QDir::isAbsolutePath(fileName) ? + QString() : dir.path() + QLatin1Char('/') + fileName; + QCOMPARE(filePath, expectedFilePath); +} + void tst_QTemporaryDir::autoRemove() { // Test auto remove diff --git a/tests/auto/corelib/json/json.pro b/tests/auto/corelib/json/json.pro index 16c2ae2fb7..8fa17c5c38 100644 --- a/tests/auto/corelib/json/json.pro +++ b/tests/auto/corelib/json/json.pro @@ -1,6 +1,5 @@ TARGET = tst_json QT = core-private testlib -CONFIG -= app_bundle CONFIG += testcase !android:TESTDATA += bom.json test.json test.bjson test3.json test2.json diff --git a/tests/auto/corelib/kernel/qcoreapplication/Info.plist b/tests/auto/corelib/kernel/qcoreapplication/Info.plist new file mode 100644 index 0000000000..a2927358bc --- /dev/null +++ b/tests/auto/corelib/kernel/qcoreapplication/Info.plist @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>CFBundleVersion</key> + <string>1.2.3</string> +</dict> +</plist> diff --git a/tests/auto/corelib/kernel/qcoreapplication/qcoreapplication.pro b/tests/auto/corelib/kernel/qcoreapplication/qcoreapplication.pro index d166351490..e37542be65 100644 --- a/tests/auto/corelib/kernel/qcoreapplication/qcoreapplication.pro +++ b/tests/auto/corelib/kernel/qcoreapplication/qcoreapplication.pro @@ -3,4 +3,7 @@ TARGET = tst_qcoreapplication QT = core testlib core-private SOURCES = tst_qcoreapplication.cpp HEADERS = tst_qcoreapplication.h +win32: VERSION = 1.2.3.4 +else: VERSION = 1.2.3 +darwin: QMAKE_LFLAGS += -Wl,-sectcreate,__TEXT,__info_plist,$$shell_quote($$PWD/Info.plist) requires(qtConfig(private_tests)) diff --git a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp index 0feffe0e96..31e76c4407 100644 --- a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp +++ b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.cpp @@ -153,6 +153,41 @@ void tst_QCoreApplication::qAppName() QCOMPARE(QCoreApplication::applicationName(), QString()); } +void tst_QCoreApplication::qAppVersion() +{ +#if defined(Q_OS_WIN) + const char appVersion[] = "1.2.3.4"; +#elif defined(Q_OS_DARWIN) || defined(Q_OS_ANDROID) + const char appVersion[] = "1.2.3"; +#else + const char appVersion[] = ""; +#endif + + { + int argc = 0; + char *argv[] = { nullptr }; + TestApplication app(argc, argv); + QCOMPARE(QCoreApplication::applicationVersion(), QString::fromLatin1(appVersion)); + } + // The application version should still be available after destruction + QCOMPARE(QCoreApplication::applicationVersion(), QString::fromLatin1(appVersion)); + + // Setting the appversion before creating the application should work + const QString wantedAppVersion("0.0.1"); + { + int argc = 0; + char *argv[] = { nullptr }; + QCoreApplication::setApplicationVersion(wantedAppVersion); + TestApplication app(argc, argv); + QCOMPARE(QCoreApplication::applicationVersion(), wantedAppVersion); + } + QCOMPARE(QCoreApplication::applicationVersion(), wantedAppVersion); + + // Restore to initial value + QCoreApplication::setApplicationVersion(QString()); + QCOMPARE(QCoreApplication::applicationVersion(), QString()); +} + void tst_QCoreApplication::argc() { #if defined(Q_OS_WINRT) diff --git a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.h b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.h index 381ff5d497..b6c20a915f 100644 --- a/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.h +++ b/tests/auto/corelib/kernel/qcoreapplication/tst_qcoreapplication.h @@ -39,6 +39,7 @@ private slots: void sendEventsOnProcessEvents(); // this must be the first test void getSetCheck(); void qAppName(); + void qAppVersion(); void argc(); void postEvent(); void removePostedEvents(); diff --git a/tests/auto/corelib/kernel/qmetamethod/qmetamethod.pro b/tests/auto/corelib/kernel/qmetamethod/qmetamethod.pro index a42cd60236..9dfa29b0fc 100644 --- a/tests/auto/corelib/kernel/qmetamethod/qmetamethod.pro +++ b/tests/auto/corelib/kernel/qmetamethod/qmetamethod.pro @@ -2,4 +2,3 @@ CONFIG += testcase TARGET = tst_qmetamethod QT = core testlib SOURCES = tst_qmetamethod.cpp -mac:CONFIG -= app_bundle diff --git a/tests/auto/corelib/kernel/qmetaobjectbuilder/qmetaobjectbuilder.pro b/tests/auto/corelib/kernel/qmetaobjectbuilder/qmetaobjectbuilder.pro index f3153b3fd4..4da90c1096 100644 --- a/tests/auto/corelib/kernel/qmetaobjectbuilder/qmetaobjectbuilder.pro +++ b/tests/auto/corelib/kernel/qmetaobjectbuilder/qmetaobjectbuilder.pro @@ -2,4 +2,3 @@ CONFIG += testcase TARGET = tst_qmetaobjectbuilder QT = core-private testlib SOURCES = tst_qmetaobjectbuilder.cpp -mac:CONFIG -= app_bundle diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp index 7e1979dfb3..143bf2f95d 100644 --- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp +++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp @@ -377,6 +377,8 @@ void tst_QMetaType::typeName_data() QT_FOR_EACH_STATIC_TYPE(TYPENAME_DATA) QTest::newRow("QMetaType::UnknownType") << int(QMetaType::UnknownType) << static_cast<const char*>(0); + QTest::newRow("QMetaType::User-1") << (int(QMetaType::User) - 1) << static_cast<const char *>(nullptr); + QTest::newRow("QMetaType::FirstWidgetsType-1") << (int(QMetaType::FirstWidgetsType) - 1) << static_cast<const char *>(nullptr); QTest::newRow("Whity<double>") << ::qMetaTypeId<Whity<double> >() << QString::fromLatin1("Whity<double>"); QTest::newRow("Whity<int>") << ::qMetaTypeId<Whity<int> >() << QString::fromLatin1("Whity<int>"); @@ -404,10 +406,12 @@ void tst_QMetaType::typeName() QFETCH(int, aType); QFETCH(QString, aTypeName); - QString name = QString::fromLatin1(QMetaType::typeName(aType)); + const char *rawname = QMetaType::typeName(aType); + QString name = QString::fromLatin1(rawname); QCOMPARE(name, aTypeName); QCOMPARE(name.toLatin1(), QMetaObject::normalizedType(name.toLatin1().constData())); + QCOMPARE(rawname == nullptr, aTypeName.isNull()); } void tst_QMetaType::type_data() @@ -731,7 +735,7 @@ QT_FOR_EACH_STATIC_CORE_POINTER(ADD_METATYPE_TEST_ROW) QTest::newRow("QPair<P,C>") << ::qMetaTypeId<QPair<P,C> >() << false << true << false << false; QTest::newRow("QPair<P,M>") << ::qMetaTypeId<QPair<P,M> >() << true << true << false << false; QTest::newRow("QPair<P,P>") << ::qMetaTypeId<QPair<P,P> >() << true << false << false << false; - QTest::newRow("FlagsDataEnum") << ::qMetaTypeId<FlagsDataEnum>() << true << true << false << true; + QTest::newRow("FlagsDataEnum") << ::qMetaTypeId<FlagsDataEnum>() << true << false << false << true; // invalid ids. QTest::newRow("-1") << -1 << false << false << false << false; diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp index 50f0061905..db6bdf0809 100644 --- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp +++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp @@ -3403,14 +3403,12 @@ void tst_QObject::dumpObjectInfo() QObject a, b; QObject::connect(&a, SIGNAL(destroyed(QObject*)), &b, SLOT(deleteLater())); a.disconnect(&b); -#ifdef QT_DEBUG QTest::ignoreMessage(QtDebugMsg, "OBJECT QObject::unnamed"); QTest::ignoreMessage(QtDebugMsg, " SIGNALS OUT"); QTest::ignoreMessage(QtDebugMsg, " signal: destroyed(QObject*)"); QTest::ignoreMessage(QtDebugMsg, " <Disconnected receiver>"); QTest::ignoreMessage(QtDebugMsg, " SIGNALS IN"); QTest::ignoreMessage(QtDebugMsg, " <None>"); -#endif a.dumpObjectInfo(); // should not crash } @@ -5309,6 +5307,15 @@ void tst_QObject::connectNoDefaultConstructorArg() QVERIFY(connect(&ob, &NoDefaultContructorArguments::mySignal, &ob, &NoDefaultContructorArguments::mySlot, Qt::QueuedConnection)); } +struct MoveOnly +{ + int value; + explicit MoveOnly(int v = 1) : value(v) {} + MoveOnly(MoveOnly &&o) : value(o.value) { o.value = -1; } + MoveOnly &operator=(MoveOnly &&o) { value = o.value; o.value = -1; return *this; } + Q_DISABLE_COPY(MoveOnly); +}; + class ReturnValue : public QObject { friend class tst_QObject; Q_OBJECT @@ -5318,6 +5325,7 @@ signals: int returnInt(int); void returnVoid(int); CustomType returnCustomType(int); + MoveOnly returnMoveOnly(int); QObject *returnPointer(); public slots: @@ -5330,6 +5338,7 @@ public slots: QString returnHello() { return QStringLiteral("hello"); } QObject *returnThisSlot1() { return this; } ReturnValue *returnThisSlot2() { return this; } + MoveOnly returnMoveOnlySlot(int i) { return MoveOnly(i); } public: struct VariantFunctor { QVariant operator()(int i) { return i; } @@ -5346,6 +5355,9 @@ public: struct VoidFunctor { void operator()(int) {} }; + struct MoveOnlyFunctor { + MoveOnly operator()(int i) { return MoveOnly(i); } + }; }; QString someFunctionReturningString(int i) { @@ -5383,6 +5395,7 @@ void tst_QObject::returnValue() emit r.returnVoid(45); QCOMPARE((emit r.returnCustomType(45)).value(), CustomType().value()); QCOMPARE((emit r.returnPointer()), static_cast<QObject *>(0)); + QCOMPARE((emit r.returnMoveOnly(666)).value, MoveOnly().value); } { // connected to a slot returning the same type CheckInstanceCount checker; @@ -5397,6 +5410,8 @@ void tst_QObject::returnValue() QCOMPARE((emit r.returnCustomType(45)).value(), CustomType(45).value()); QVERIFY(connect(&r, &ReturnValue::returnPointer, &receiver, &ReturnValue::returnThisSlot1, type)); QCOMPARE((emit r.returnPointer()), static_cast<QObject *>(&receiver)); + QVERIFY(connect(&r, &ReturnValue::returnMoveOnly, &receiver, &ReturnValue::returnMoveOnlySlot, type)); + QCOMPARE((emit r.returnMoveOnly(666)).value, 666); } if (!isBlockingQueued) { // connected to simple functions or functor CheckInstanceCount checker; @@ -5415,6 +5430,10 @@ void tst_QObject::returnValue() ReturnValue::IntFunctor intFunctor; QVERIFY(connect(&r, &ReturnValue::returnInt, intFunctor)); QCOMPARE(emit r.returnInt(45), int(45)); + + ReturnValue::MoveOnlyFunctor moveOnlyFunctor; + QVERIFY(connect(&r, &ReturnValue::returnMoveOnly, moveOnlyFunctor)); + QCOMPARE((emit r.returnMoveOnly(666)).value, 666); } { // connected to a slot with different type CheckInstanceCount checker; @@ -5453,6 +5472,8 @@ void tst_QObject::returnValue() QCOMPARE((emit r.returnCustomType(45)).value(), CustomType().value()); QVERIFY(connect(&r, &ReturnValue::returnPointer, &receiver, &ReturnValue::returnVoidSlot, type)); QCOMPARE((emit r.returnPointer()), static_cast<QObject *>(0)); + QVERIFY(connect(&r, &ReturnValue::returnMoveOnly, &receiver, &ReturnValue::returnVoidSlot, type)); + QCOMPARE((emit r.returnMoveOnly(666)).value, MoveOnly().value); } if (!isBlockingQueued) { // queued connection should not forward the return value @@ -5468,6 +5489,8 @@ void tst_QObject::returnValue() QCOMPARE((emit r.returnCustomType(45)).value(), CustomType().value()); QVERIFY(connect(&r, &ReturnValue::returnPointer, &receiver, &ReturnValue::returnThisSlot1, Qt::QueuedConnection)); QCOMPARE((emit r.returnPointer()), static_cast<QObject *>(0)); + QVERIFY(connect(&r, &ReturnValue::returnMoveOnly, &receiver, &ReturnValue::returnMoveOnlySlot, Qt::QueuedConnection)); + QCOMPARE((emit r.returnMoveOnly(666)).value, MoveOnly().value); QCoreApplication::processEvents(); @@ -5551,6 +5574,8 @@ void tst_QObject::returnValue2() QCOMPARE(emit r.returnInt(45), int(45)); QVERIFY(connect(&r, SIGNAL(returnCustomType(int)), &receiver, SLOT(returnCustomTypeSlot(int)), type)); QCOMPARE((emit r.returnCustomType(45)).value(), CustomType(45).value()); + QVERIFY(connect(&r, SIGNAL(returnMoveOnly(int)), &receiver, SLOT(returnMoveOnlySlot(int)), type)); + QCOMPARE((emit r.returnMoveOnly(45)).value, 45); } { // connected to a slot returning void CheckInstanceCount checker; @@ -5563,6 +5588,8 @@ void tst_QObject::returnValue2() QCOMPARE(emit r.returnInt(45), int()); QVERIFY(connect(&r, SIGNAL(returnCustomType(int)), &receiver, SLOT(returnVoidSlot()), type)); QCOMPARE((emit r.returnCustomType(45)).value(), CustomType().value()); + QVERIFY(connect(&r, SIGNAL(returnMoveOnly(int)), &receiver, SLOT(returnVoidSlot()), type)); + QCOMPARE((emit r.returnMoveOnly(45)).value, MoveOnly().value); } if (!isBlockingQueued) { // queued connection should not forward the return value @@ -5576,6 +5603,9 @@ void tst_QObject::returnValue2() QCOMPARE(emit r.returnInt(45), int()); QVERIFY(connect(&r, SIGNAL(returnCustomType(int)), &receiver, SLOT(returnCustomTypeSlot(int)), Qt::QueuedConnection)); QCOMPARE((emit r.returnCustomType(45)).value(), CustomType().value()); + QVERIFY(connect(&r, SIGNAL(returnMoveOnly(int)), &receiver, SLOT(returnMoveOnlySlot(int)), Qt::QueuedConnection)); + QCOMPARE((emit r.returnMoveOnly(45)).value, MoveOnly().value); + QCoreApplication::processEvents(); //Queued conneciton with different return type should be safe @@ -5682,6 +5712,27 @@ public slots: virtual void slot2() { ++virtual_base_count; } }; +struct NormalBase +{ + QByteArray lastCalled; + virtual ~NormalBase() {} + virtual void virtualBaseSlot() { lastCalled = "virtualBaseSlot"; } + void normalBaseSlot() { lastCalled = "normalBaseSlot"; } +}; + +class ObjectWithMultiInheritance : public VirtualSlotsObject, public NormalBase +{ + Q_OBJECT +}; + +// Normally, the class that inherit QObject always must go first, because of the way qobject_cast +// work, and moc checks for that. But if we don't use Q_OBJECT, this should work +class ObjectWithMultiInheritance2 : public NormalBase, public VirtualSlotsObject +{ + // no QObject as QObject always must go first + // Q_OBJECT +}; + // VMI = Virtual or Multiple Inheritance // (in this case, both) void tst_QObject::connectSlotsVMIClass() @@ -5764,6 +5815,93 @@ void tst_QObject::connectSlotsVMIClass() QCOMPARE(obj.virtual_base_count, 1); QCOMPARE(obj.regular_call_count, 0); } + + // test connecting a slot that is virtual within the second base + { + ObjectWithMultiInheritance obj; + void (ObjectWithMultiInheritance::*slot)() = &ObjectWithMultiInheritance::virtualBaseSlot; + QVERIFY( QObject::connect(&obj, &VirtualSlotsObjectBase::signal1, &obj, slot, Qt::UniqueConnection)); + QVERIFY(!QObject::connect(&obj, &VirtualSlotsObjectBase::signal1, &obj, slot, Qt::UniqueConnection)); + + emit obj.signal1(); + QCOMPARE(obj.base_counter1, 0); + QCOMPARE(obj.derived_counter1, 0); + QCOMPARE(obj.lastCalled, QByteArray("virtualBaseSlot")); + obj.lastCalled.clear(); + + QVERIFY( QObject::disconnect(&obj, &VirtualSlotsObjectBase::signal1, &obj, slot)); + QVERIFY(!QObject::disconnect(&obj, &VirtualSlotsObjectBase::signal1, &obj, slot)); + + emit obj.signal1(); + QCOMPARE(obj.base_counter1, 0); + QCOMPARE(obj.derived_counter1, 0); + QCOMPARE(obj.lastCalled, QByteArray()); + } + + // test connecting a slot that is not virtual within the second base + { + ObjectWithMultiInheritance obj; + void (ObjectWithMultiInheritance::*slot)() = &ObjectWithMultiInheritance::normalBaseSlot; + QVERIFY( QObject::connect(&obj, &VirtualSlotsObjectBase::signal1, &obj, slot, Qt::UniqueConnection)); + QVERIFY(!QObject::connect(&obj, &VirtualSlotsObjectBase::signal1, &obj, slot, Qt::UniqueConnection)); + + emit obj.signal1(); + QCOMPARE(obj.base_counter1, 0); + QCOMPARE(obj.derived_counter1, 0); + QCOMPARE(obj.lastCalled, QByteArray("normalBaseSlot")); + obj.lastCalled.clear(); + + QVERIFY( QObject::disconnect(&obj, &VirtualSlotsObjectBase::signal1, &obj, slot)); + QVERIFY(!QObject::disconnect(&obj, &VirtualSlotsObjectBase::signal1, &obj, slot)); + + emit obj.signal1(); + QCOMPARE(obj.base_counter1, 0); + QCOMPARE(obj.derived_counter1, 0); + QCOMPARE(obj.lastCalled, QByteArray()); + } + + // test connecting a slot within the first non-QObject base + { + ObjectWithMultiInheritance2 obj; + void (ObjectWithMultiInheritance2::*slot)() = &ObjectWithMultiInheritance2::normalBaseSlot; + QVERIFY( QObject::connect(&obj, &VirtualSlotsObjectBase::signal1, &obj, slot, Qt::UniqueConnection)); + QVERIFY(!QObject::connect(&obj, &VirtualSlotsObjectBase::signal1, &obj, slot, Qt::UniqueConnection)); + + emit obj.signal1(); + QCOMPARE(obj.base_counter1, 0); + QCOMPARE(obj.derived_counter1, 0); + QCOMPARE(obj.lastCalled, QByteArray("normalBaseSlot")); + obj.lastCalled.clear(); + + QVERIFY( QObject::disconnect(&obj, &VirtualSlotsObjectBase::signal1, &obj, slot)); + QVERIFY(!QObject::disconnect(&obj, &VirtualSlotsObjectBase::signal1, &obj, slot)); + + emit obj.signal1(); + QCOMPARE(obj.base_counter1, 0); + QCOMPARE(obj.derived_counter1, 0); + QCOMPARE(obj.lastCalled, QByteArray()); + } + + // test connecting a slot within the second QObject base + { + ObjectWithMultiInheritance2 obj; + void (ObjectWithMultiInheritance2::*slot)() = &ObjectWithMultiInheritance2::slot1; + QVERIFY( QObject::connect(&obj, &VirtualSlotsObjectBase::signal1, &obj, slot, Qt::UniqueConnection)); + QVERIFY(!QObject::connect(&obj, &VirtualSlotsObjectBase::signal1, &obj, slot, Qt::UniqueConnection)); + + emit obj.signal1(); + QCOMPARE(obj.base_counter1, 0); + QCOMPARE(obj.derived_counter1, 1); + QCOMPARE(obj.lastCalled, QByteArray()); + + QVERIFY( QObject::disconnect(&obj, &VirtualSlotsObjectBase::signal1, &obj, slot)); + QVERIFY(!QObject::disconnect(&obj, &VirtualSlotsObjectBase::signal1, &obj, slot)); + + emit obj.signal1(); + QCOMPARE(obj.base_counter1, 0); + QCOMPARE(obj.derived_counter1, 1); + QCOMPARE(obj.lastCalled, QByteArray()); + } } #ifndef QT_BUILD_INTERNAL diff --git a/tests/auto/corelib/kernel/qsharedmemory/test/test.pro b/tests/auto/corelib/kernel/qsharedmemory/test/test.pro index fabd2cf7a3..61124c27ee 100644 --- a/tests/auto/corelib/kernel/qsharedmemory/test/test.pro +++ b/tests/auto/corelib/kernel/qsharedmemory/test/test.pro @@ -2,7 +2,6 @@ CONFIG += testcase QT = core-private testlib -mac:CONFIG -= app_bundle linux:LIBS += -lrt SOURCES += tst_qsharedmemory.cpp diff --git a/tests/auto/corelib/kernel/qsystemsemaphore/test/test.pro b/tests/auto/corelib/kernel/qsystemsemaphore/test/test.pro index a0f63741d3..f60207eb01 100644 --- a/tests/auto/corelib/kernel/qsystemsemaphore/test/test.pro +++ b/tests/auto/corelib/kernel/qsystemsemaphore/test/test.pro @@ -2,7 +2,6 @@ CONFIG += testcase QT = core testlib win32: CONFIG += console -mac:CONFIG -= app_bundle SOURCES += tst_qsystemsemaphore.cpp TARGET = tst_qsystemsemaphore diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp index 442f7e80d1..ac1e1c6b45 100644 --- a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp +++ b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp @@ -80,7 +80,7 @@ public: enum MetaEnumTest_Enum1 { MetaEnumTest_Enum1_value = 42, MetaEnumTest_Enum1_bigValue = (Q_INT64_C(1) << 33) + 50 }; Q_ENUM(MetaEnumTest_Enum1) - enum MetaEnumTest_Enum3 ENUM_SIZE(qint64) { MetaEnumTest_Enum3_value = -47, MetaEnumTest_Enum3_bigValue = (Q_INT64_C(1) << 56) + 5 }; + enum MetaEnumTest_Enum3 ENUM_SIZE(qint64) { MetaEnumTest_Enum3_value = -47, MetaEnumTest_Enum3_bigValue = (Q_INT64_C(1) << 56) + 5, MetaEnumTest_Enum3_bigNegValue = -(Q_INT64_C(1) << 56) - 3 }; Q_ENUM(MetaEnumTest_Enum3) enum MetaEnumTest_Enum4 ENUM_SIZE(quint64) { MetaEnumTest_Enum4_value = 47, MetaEnumTest_Enum4_bigValue = (Q_INT64_C(1) << 52) + 45 }; Q_ENUM(MetaEnumTest_Enum4) @@ -1512,10 +1512,11 @@ void tst_QVariant::operator_eq_eq_data() // ### many other combinations missing { - // QUuid can convert to QString, but not the opposite QUuid uuid(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10); QTest::newRow("uuidstring") << QVariant(uuid) << QVariant(uuid.toString()) << true; QTest::newRow("stringuuid") << QVariant(uuid.toString()) << QVariant(uuid) << true; + QTest::newRow("uuidbytearray") << QVariant(uuid) << QVariant(uuid.toByteArray()) << true; + QTest::newRow("bytearrayuuid") << QVariant(uuid.toByteArray()) << QVariant(uuid) << true; } { @@ -4682,7 +4683,7 @@ template<typename Enum> void testVariant(Enum value, bool *ok) QVERIFY(var2.convert(QMetaType::Int)); QCOMPARE(var2.value<int>(), static_cast<int>(value)); - if (static_cast<qint64>(value) <= INT_MAX) { + if ((static_cast<qint64>(value) <= INT_MAX) && (static_cast<qint64>(value) >= INT_MIN)) { int intValue = static_cast<int>(value); QVariant intVar = intValue; QVERIFY(intVar.canConvert<Enum>()); @@ -4743,7 +4744,7 @@ template<typename Enum> void testVariantMeta(Enum value, bool *ok, const char *s QVariant strVar = QString::fromLatin1(string); QVERIFY(strVar.canConvert<Enum>()); - if (value > INT_MAX) { + if ((static_cast<qint64>(value) > INT_MAX) || (static_cast<qint64>(value) < INT_MIN)) { QEXPECT_FAIL("", "QMetaEnum api uses 'int' as return type QTBUG-27451", Abort); *ok = true; } @@ -4765,6 +4766,7 @@ void tst_QVariant::metaEnums() METAENUMS_TEST(MetaEnumTest_Enum1_bigValue); METAENUMS_TEST(MetaEnumTest_Enum3_value); METAENUMS_TEST(MetaEnumTest_Enum3_bigValue); + METAENUMS_TEST(MetaEnumTest_Enum3_bigNegValue); METAENUMS_TEST(MetaEnumTest_Enum4_value); METAENUMS_TEST(MetaEnumTest_Enum4_bigValue); METAENUMS_TEST(MetaEnumTest_Enum5_value); diff --git a/tests/auto/corelib/plugin/qfactoryloader/test/test.pro b/tests/auto/corelib/plugin/qfactoryloader/test/test.pro index 3345651730..9338f4ecc9 100644 --- a/tests/auto/corelib/plugin/qfactoryloader/test/test.pro +++ b/tests/auto/corelib/plugin/qfactoryloader/test/test.pro @@ -17,8 +17,6 @@ win32 { } } -mac: CONFIG -= app_bundle - !qtConfig(library) { LIBS += -L ../bin/ -lplugin1 -lplugin2 } diff --git a/tests/auto/corelib/plugin/qlibrary/tst/tst.pro b/tests/auto/corelib/plugin/qlibrary/tst/tst.pro index d59cd738bf..6e71ec8ff9 100644 --- a/tests/auto/corelib/plugin/qlibrary/tst/tst.pro +++ b/tests/auto/corelib/plugin/qlibrary/tst/tst.pro @@ -1,5 +1,4 @@ CONFIG += testcase -CONFIG -= app_bundle TARGET = ../tst_qlibrary QT = core testlib SOURCES = ../tst_qlibrary.cpp diff --git a/tests/auto/corelib/plugin/qpluginloader/machtest/machtest.pro b/tests/auto/corelib/plugin/qpluginloader/machtest/machtest.pro index e3d5bff5ff..7f7caa7f76 100644 --- a/tests/auto/corelib/plugin/qpluginloader/machtest/machtest.pro +++ b/tests/auto/corelib/plugin/qpluginloader/machtest/machtest.pro @@ -6,11 +6,16 @@ OTHER_FILES += \ # Needs explicit load()ing due to aux template. Relies on QT being non-empty. load(qt) +i386_d.target = good.i386.dylib +i386_d.depends = EXPORT_VALID_ARCHS=i386 i386.target = good.i386.dylib -i386.commands = $(CXX) $(CXXFLAGS) -shared -arch i386 -o $@ -I$(INCPATH) $< +i386.commands = $(CXX) $(CXXFLAGS) -shared -o $@ -I$(INCPATH) $< i386.depends += $$PWD/../fakeplugin.cpp + +x86_64_d.target = good.x86_64.dylib +x86_64_d.depends = EXPORT_VALID_ARCHS=x86_64 x86_64.target = good.x86_64.dylib -x86_64.commands = $(CXX) $(CXXFLAGS) -shared -arch x86_64 -o $@ -I$(INCPATH) $< +x86_64.commands = $(CXX) $(CXXFLAGS) -shared -o $@ -I$(INCPATH) $< x86_64.depends += $$PWD/../fakeplugin.cpp # Current Mac OS X toolchains have no compiler for PPC anymore @@ -49,7 +54,7 @@ bad.depends += $$PWD/generate-bad.pl MYTARGETS = $$fat_all.depends fat_all fat_no_x86_64 fat_no_i386 \ fat_stub_i386 fat_stub_x86_64 bad all.depends += $$MYTARGETS -QMAKE_EXTRA_TARGETS += $$MYTARGETS all +QMAKE_EXTRA_TARGETS += i386_d x86_64_d $$MYTARGETS all QMAKE_CLEAN += $$i386.target $$x86_64.target $$ppc64.target $$fat_all.target \ $$fat_no_i386.target $$fat_no_x86_64.target \ diff --git a/tests/auto/corelib/plugin/qpluginloader/tst/tst.pro b/tests/auto/corelib/plugin/qpluginloader/tst/tst.pro index 5f9fa6664b..c20e56ba4c 100644 --- a/tests/auto/corelib/plugin/qpluginloader/tst/tst.pro +++ b/tests/auto/corelib/plugin/qpluginloader/tst/tst.pro @@ -4,7 +4,6 @@ QT = core testlib qtConfig(private_tests): QT += core-private SOURCES = ../tst_qpluginloader.cpp ../fakeplugin.cpp HEADERS = ../theplugin/plugininterface.h -CONFIG -= app_bundle win32 { CONFIG(debug, debug|release) { diff --git a/tests/auto/corelib/plugin/quuid/tst_quuid.cpp b/tests/auto/corelib/plugin/quuid/tst_quuid.cpp index cb45336d4c..d3102c7ee5 100644 --- a/tests/auto/corelib/plugin/quuid/tst_quuid.cpp +++ b/tests/auto/corelib/plugin/quuid/tst_quuid.cpp @@ -392,9 +392,16 @@ void tst_QUuid::qvariant_conversion() QUuid uuid = QUuid::createUuid(); QVariant v = QVariant::fromValue(uuid); + // QUuid -> QString QVERIFY(v.canConvert<QString>()); QCOMPARE(v.toString(), uuid.toString()); QCOMPARE(v.value<QString>(), uuid.toString()); + + // QUuid -> QByteArray + QVERIFY(v.canConvert<QByteArray>()); + QCOMPARE(v.toByteArray(), uuid.toByteArray()); + QCOMPARE(v.value<QByteArray>(), uuid.toByteArray()); + QVERIFY(!v.canConvert<int>()); QVERIFY(!v.canConvert<QStringList>()); @@ -403,6 +410,14 @@ void tst_QUuid::qvariant_conversion() QCOMPARE(sv.type(), QVariant::String); QVERIFY(sv.canConvert<QUuid>()); QCOMPARE(sv.value<QUuid>(), uuid); + + // QString -> QUuid + { + QVariant sv = QVariant::fromValue(uuid.toByteArray()); + QCOMPARE(sv.type(), QVariant::ByteArray); + QVERIFY(sv.canConvert<QUuid>()); + QCOMPARE(sv.value<QUuid>(), uuid); + } } void tst_QUuid::darwinTypes() diff --git a/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp b/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp index 3e4a6eb7e7..0962001741 100644 --- a/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp +++ b/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp @@ -102,7 +102,7 @@ void tst_QMutex::convertToMilliseconds_data() auto add = [](TimeUnit unit, double d, long long i, qint64 expected) { const QScopedArrayPointer<char> enumName(QTest::toString(unit)); - QTest::newRow(qPrintable(QString::asprintf("%s:%f:%lld", enumName.data(), d, i))) + QTest::addRow("%s:%f:%lld", enumName.data(), d, i) << unit << d << qint64(i) << expected; }; diff --git a/tests/auto/corelib/thread/qsemaphore/BLACKLIST b/tests/auto/corelib/thread/qsemaphore/BLACKLIST index 9f6f6e3ba6..06ae815f29 100644 --- a/tests/auto/corelib/thread/qsemaphore/BLACKLIST +++ b/tests/auto/corelib/thread/qsemaphore/BLACKLIST @@ -1,3 +1,4 @@ -# Times out randomly on linux, windows, osx -[tryAcquireWithTimeout] -* +[tryAcquireWithTimeout:0.2s] +windows +[tryAcquireWithTimeout:2s] +windows diff --git a/tests/auto/corelib/thread/qsemaphore/tst_qsemaphore.cpp b/tests/auto/corelib/thread/qsemaphore/tst_qsemaphore.cpp index e984618bdb..2970b2e118 100644 --- a/tests/auto/corelib/thread/qsemaphore/tst_qsemaphore.cpp +++ b/tests/auto/corelib/thread/qsemaphore/tst_qsemaphore.cpp @@ -202,8 +202,8 @@ void tst_QSemaphore::tryAcquireWithTimeout_data() { QTest::addColumn<int>("timeout"); - QTest::newRow("1s") << 1000; - QTest::newRow("10s") << 10000; + QTest::newRow("0.2s") << 200; + QTest::newRow("2s") << 2000; } void tst_QSemaphore::tryAcquireWithTimeout() @@ -212,7 +212,7 @@ void tst_QSemaphore::tryAcquireWithTimeout() // timers are not guaranteed to be accurate down to the last millisecond, // so we permit the elapsed times to be up to this far from the expected value. - int fuzz = 50; + int fuzz = 50 + (timeout / 20); QSemaphore semaphore; QElapsedTimer time; diff --git a/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp b/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp index 5b7242fddb..fdc4ecb5c8 100644 --- a/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp +++ b/tests/auto/corelib/thread/qthreadpool/tst_qthreadpool.cpp @@ -89,6 +89,7 @@ private slots: void waitForDone(); void clear(); void cancel(); + void tryTake(); void waitForDoneTimeout(); void destroyingWaitsForTasksToFinish(); void stressTest(); @@ -1042,6 +1043,97 @@ void tst_QThreadPool::cancel() delete runnables[runs-1]; } +void tst_QThreadPool::tryTake() +{ + QSemaphore sem(0); + QSemaphore startedThreads(0); + + class SemaphoreReleaser + { + QSemaphore &sem; + int n; + Q_DISABLE_COPY(SemaphoreReleaser) + public: + explicit SemaphoreReleaser(QSemaphore &sem, int n) + : sem(sem), n(n) {} + + ~SemaphoreReleaser() + { + sem.release(n); + } + }; + + class BlockingRunnable : public QRunnable + { + public: + QSemaphore &sem; + QSemaphore &startedThreads; + QAtomicInt &dtorCounter; + QAtomicInt &runCounter; + int dummy; + + explicit BlockingRunnable(QSemaphore &s, QSemaphore &started, QAtomicInt &c, QAtomicInt &r) + : sem(s), startedThreads(started), dtorCounter(c), runCounter(r) {} + + ~BlockingRunnable() + { + dtorCounter.fetchAndAddRelaxed(1); + } + + void run() override + { + startedThreads.release(); + runCounter.fetchAndAddRelaxed(1); + sem.acquire(); + count.ref(); + } + }; + + enum { + MaxThreadCount = 3, + OverProvisioning = 2, + Runs = MaxThreadCount * OverProvisioning + }; + + QThreadPool threadPool; + threadPool.setMaxThreadCount(MaxThreadCount); + BlockingRunnable *runnables[Runs]; + + // ensure that the QThreadPool doesn't deadlock if any of the checks fail + // and cause an early return: + const SemaphoreReleaser semReleaser(sem, Runs); + + count.store(0); + QAtomicInt dtorCounter = 0; + QAtomicInt runCounter = 0; + for (int i = 0; i < Runs; i++) { + runnables[i] = new BlockingRunnable(sem, startedThreads, dtorCounter, runCounter); + runnables[i]->setAutoDelete(i != 0 && i != Runs - 1); // one which will run and one which will not + QVERIFY(!threadPool.tryTake(runnables[i])); // verify NOOP for jobs not in the queue + threadPool.start(runnables[i]); + } + // wait for all worker threads to have started up: + QVERIFY(startedThreads.tryAcquire(MaxThreadCount, 60*1000 /* 1min */)); + + for (int i = 0; i < MaxThreadCount; ++i) { + // check taking runnables doesn't work once they were started: + QVERIFY(!threadPool.tryTake(runnables[i])); + } + for (int i = MaxThreadCount; i < Runs ; ++i) { + QVERIFY(threadPool.tryTake(runnables[i])); + delete runnables[i]; + } + + runnables[0]->dummy = 0; // valgrind will catch this if tryTake() is crazy enough to delete currently running jobs + QCOMPARE(dtorCounter.load(), int(Runs - MaxThreadCount)); + sem.release(MaxThreadCount); + threadPool.waitForDone(); + QCOMPARE(runCounter.load(), int(MaxThreadCount)); + QCOMPARE(count.load(), int(MaxThreadCount)); + QCOMPARE(dtorCounter.load(), int(Runs - 1)); + delete runnables[0]; // if the pool deletes them then we'll get double-free crash +} + void tst_QThreadPool::destroyingWaitsForTasksToFinish() { QTime total, pass; diff --git a/tests/auto/corelib/thread/qthreadstorage/test/test.pro b/tests/auto/corelib/thread/qthreadstorage/test/test.pro index b9d661a9af..1a1fede186 100644 --- a/tests/auto/corelib/thread/qthreadstorage/test/test.pro +++ b/tests/auto/corelib/thread/qthreadstorage/test/test.pro @@ -1,6 +1,6 @@ CONFIG += testcase TARGET = ../tst_qthreadstorage -CONFIG -= app_bundle debug_and_release_target +CONFIG -= debug_and_release_target CONFIG += console QT = core testlib SOURCES = ../tst_qthreadstorage.cpp diff --git a/tests/auto/corelib/tools/collections/tst_collections.cpp b/tests/auto/corelib/tools/collections/tst_collections.cpp index af270ded98..38366e86ff 100644 --- a/tests/auto/corelib/tools/collections/tst_collections.cpp +++ b/tests/auto/corelib/tools/collections/tst_collections.cpp @@ -3208,19 +3208,31 @@ public: }; Q_STATIC_ASSERT(Q_ALIGNOF(Aligned4) % 4 == 0); -class Q_DECL_ALIGN(128) Aligned128 +#if defined(Q_PROCESSOR_ARM) +# if defined(Q_COMPILER_ALIGNAS) && defined(__BIGGEST_ALIGNMENT__) + // On ARM __BIGGEST_ALIGNMENT__ must be multiplied by 8 to + // get the same limit as enforced by alignas() +# define BIGGEST_ALIGNMENT_TO_TEST (__BIGGEST_ALIGNMENT__ << 3) +# endif +#endif + +#if !defined(BIGGEST_ALIGNMENT_TO_TEST) +# define BIGGEST_ALIGNMENT_TO_TEST 128 +#endif + +class Q_DECL_ALIGN(BIGGEST_ALIGNMENT_TO_TEST) AlignedBiggest { char i; public: - Aligned128(int i = 0) : i(i) {} + AlignedBiggest(int i = 0) : i(i) {} - enum { PreferredAlignment = 128 }; + enum { PreferredAlignment = BIGGEST_ALIGNMENT_TO_TEST }; - inline bool operator==(const Aligned128 &other) const { return i == other.i; } - inline bool operator<(const Aligned128 &other) const { return i < other.i; } - friend inline int qHash(const Aligned128 &a) { return qHash(a.i); } + inline bool operator==(const AlignedBiggest &other) const { return i == other.i; } + inline bool operator<(const AlignedBiggest &other) const { return i < other.i; } + friend inline int qHash(const AlignedBiggest &a) { return qHash(a.i); } }; -Q_STATIC_ASSERT(Q_ALIGNOF(Aligned128) % 128 == 0); +Q_STATIC_ASSERT(Q_ALIGNOF(AlignedBiggest) % BIGGEST_ALIGNMENT_TO_TEST == 0); template<typename C> void testVectorAlignment() @@ -3278,17 +3290,17 @@ void testAssociativeContainerAlignment() void tst_Collections::alignment() { testVectorAlignment<QVector<Aligned4> >(); - testVectorAlignment<QVector<Aligned128> >(); + testVectorAlignment<QVector<AlignedBiggest> >(); testContiguousCacheAlignment<QContiguousCache<Aligned4> >(); - testContiguousCacheAlignment<QContiguousCache<Aligned128> >(); + testContiguousCacheAlignment<QContiguousCache<AlignedBiggest> >(); testAssociativeContainerAlignment<QMap<Aligned4, Aligned4> >(); - testAssociativeContainerAlignment<QMap<Aligned4, Aligned128> >(); - testAssociativeContainerAlignment<QMap<Aligned128, Aligned4> >(); - testAssociativeContainerAlignment<QMap<Aligned128, Aligned128> >(); + testAssociativeContainerAlignment<QMap<Aligned4, AlignedBiggest> >(); + testAssociativeContainerAlignment<QMap<AlignedBiggest, Aligned4> >(); + testAssociativeContainerAlignment<QMap<AlignedBiggest, AlignedBiggest> >(); testAssociativeContainerAlignment<QHash<Aligned4, Aligned4> >(); - testAssociativeContainerAlignment<QHash<Aligned4, Aligned128> >(); - testAssociativeContainerAlignment<QHash<Aligned128, Aligned4> >(); - testAssociativeContainerAlignment<QHash<Aligned128, Aligned128> >(); + testAssociativeContainerAlignment<QHash<Aligned4, AlignedBiggest> >(); + testAssociativeContainerAlignment<QHash<AlignedBiggest, Aligned4> >(); + testAssociativeContainerAlignment<QHash<AlignedBiggest, AlignedBiggest> >(); } #else diff --git a/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp b/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp index c14e9fadf7..e13c2894af 100644 --- a/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp +++ b/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp @@ -1076,22 +1076,22 @@ void tst_QAlgorithms::popCount_data_impl(size_t sizeof_T_Int) const uint bits = bitsSetInByte(byte); const quint64 value = static_cast<quint64>(byte); const quint64 input = value << ((i % sizeof_T_Int) * 8U); - newRow(qPrintable(QString::asprintf("0x%016llx", input))) << input << bits; + QTest::addRow("0x%016llx", input) << input << bits; } // and some random ones: if (sizeof_T_Int >= 8) for (size_t i = 0; i < 1000; ++i) { const quint64 input = quint64(qrand()) << 32 | quint32(qrand()); - newRow(qPrintable(QString::asprintf("0x%016llx", input))) << input << bitsSetInInt64(input); + QTest::addRow("0x%016llx", input) << input << bitsSetInInt64(input); } else if (sizeof_T_Int >= 2) for (size_t i = 0; i < 1000 ; ++i) { const quint32 input = qrand(); if (sizeof_T_Int >= 4) - newRow(qPrintable(QString::asprintf("0x%08x", input))) << quint64(input) << bitsSetInInt(input); + QTest::addRow("0x%08x", input) << quint64(input) << bitsSetInInt(input); else - newRow(qPrintable(QString::asprintf("0x%04x", quint16(input & 0xFFFF)))) << quint64(input & 0xFFFF) << bitsSetInShort(input & 0xFFFF); + QTest::addRow("0x%04x", quint16(input & 0xFFFF)) << quint64(input & 0xFFFF) << bitsSetInShort(input & 0xFFFF); } } diff --git a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp index 3be8379d29..a00c962510 100644 --- a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp +++ b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp @@ -65,6 +65,8 @@ private slots: void simpleVectorReserve(); void allocate_data(); void allocate(); + void reallocate_data() { allocate_data(); } + void reallocate(); void alignment_data(); void alignment(); void typedData(); @@ -742,6 +744,53 @@ void tst_QArrayData::allocate() } } +void tst_QArrayData::reallocate() +{ + QFETCH(size_t, objectSize); + QFETCH(size_t, alignment); + QFETCH(QArrayData::AllocationOptions, allocateOptions); + QFETCH(bool, isCapacityReserved); + + // Maximum alignment that can be requested is that of QArrayData, + // otherwise, we can't use reallocate(). + Q_ASSERT(alignment <= Q_ALIGNOF(QArrayData)); + + // Minimum alignment that can be requested is that of QArrayData. + // Typically, this alignment is sizeof(void *) and ensured by malloc. + size_t minAlignment = qMax(alignment, Q_ALIGNOF(QArrayData)); + + int capacity = 10; + Deallocator keeper(objectSize, minAlignment); + QArrayData *data = QArrayData::allocate(objectSize, minAlignment, capacity, + QArrayData::AllocationOptions(allocateOptions) & ~QArrayData::Grow); + keeper.headers.append(data); + + memset(data->data(), 'A', objectSize * capacity); + data->size = capacity; + + // now try to reallocate + int newCapacity = 40; + data = QArrayData::reallocateUnaligned(data, objectSize, newCapacity, + QArrayData::AllocationOptions(allocateOptions)); + QVERIFY(data); + keeper.headers.clear(); + keeper.headers.append(data); + + QCOMPARE(data->size, capacity); + if (allocateOptions & QArrayData::Grow) + QVERIFY(data->alloc > uint(newCapacity)); + else + QCOMPARE(data->alloc, uint(newCapacity)); + QCOMPARE(data->capacityReserved, uint(isCapacityReserved)); +#if !defined(QT_NO_UNSHARABLE_CONTAINERS) + QFETCH(bool, isSharable); + QCOMPARE(data->ref.isSharable(), isSharable); +#endif + + for (int i = 0; i < capacity; ++i) + QCOMPARE(static_cast<char *>(data->data())[i], 'A'); +} + class Unaligned { char dummy[8]; diff --git a/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp b/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp index 310c5f6fd3..16a9c03351 100644 --- a/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp +++ b/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp @@ -43,6 +43,8 @@ public: tst_QByteArray(); private slots: void swap(); + void qChecksum_data(); + void qChecksum(); void qCompress_data(); #ifndef QT_NO_COMPRESS void qCompress(); @@ -239,6 +241,34 @@ tst_QByteArray::tst_QByteArray() { } +void tst_QByteArray::qChecksum_data() +{ + QTest::addColumn<QByteArray>("data"); + QTest::addColumn<uint>("len"); + QTest::addColumn<Qt::ChecksumType>("standard"); + QTest::addColumn<uint>("checksum"); + + // Examples from ISO 14443-3 + QTest::newRow("1") << QByteArray("\x00\x00") << 2U << Qt::ChecksumItuV41 << 0x1EA0U; + QTest::newRow("2") << QByteArray("\x12\x34") << 2U << Qt::ChecksumItuV41 << 0xCF26U; + QTest::newRow("3") << QByteArray("\x00\x00\x00") << 3U << Qt::ChecksumIso3309 << 0xC6CCU; + QTest::newRow("4") << QByteArray("\x0F\xAA\xFF") << 3U << Qt::ChecksumIso3309 << 0xD1FCU; + QTest::newRow("5") << QByteArray("\x0A\x12\x34\x56") << 4U << Qt::ChecksumIso3309 << 0xF62CU; +} + +void tst_QByteArray::qChecksum() +{ + QFETCH(QByteArray, data); + QFETCH(uint, len); + QFETCH(Qt::ChecksumType, standard); + QFETCH(uint, checksum); + + if (standard == Qt::ChecksumIso3309) { + QCOMPARE(::qChecksum(data.constData(), len), static_cast<quint16>(checksum)); + } + QCOMPARE(::qChecksum(data.constData(), len, standard), static_cast<quint16>(checksum)); +} + void tst_QByteArray::qCompress_data() { QTest::addColumn<QByteArray>("ba"); @@ -1443,61 +1473,97 @@ void tst_QByteArray::appendAfterFromRawData() void tst_QByteArray::toFromHex_data() { QTest::addColumn<QByteArray>("str"); + QTest::addColumn<char>("sep"); QTest::addColumn<QByteArray>("hex"); QTest::addColumn<QByteArray>("hex_alt1"); - QTest::newRow("Qt is great!") + QTest::newRow("Qt is great! (default)") << QByteArray("Qt is great!") + << '\0' << QByteArray("517420697320677265617421") << QByteArray("51 74 20 69 73 20 67 72 65 61 74 21"); + QTest::newRow("Qt is great! (with space)") + << QByteArray("Qt is great!") + << ' ' + << QByteArray("51 74 20 69 73 20 67 72 65 61 74 21") + << QByteArray("51 74 20 69 73 20 67 72 65 61 74 21"); + + QTest::newRow("Qt is great! (with minus)") + << QByteArray("Qt is great!") + << '-' + << QByteArray("51-74-20-69-73-20-67-72-65-61-74-21") + << QByteArray("51-74-20-69-73-20-67-72-65-61-74-21"); + QTest::newRow("Qt is so great!") << QByteArray("Qt is so great!") + << '\0' << QByteArray("517420697320736f20677265617421") << QByteArray("51 74 20 69 73 20 73 6f 20 67 72 65 61 74 21"); QTest::newRow("default-constructed") << QByteArray() + << '\0' + << QByteArray() + << QByteArray(); + + QTest::newRow("default-constructed (with space)") + << QByteArray() + << ' ' << QByteArray() << QByteArray(); QTest::newRow("empty") << QByteArray("") + << '\0' + << QByteArray("") + << QByteArray(""); + + QTest::newRow("empty (with space)") + << QByteArray("") + << ' ' << QByteArray("") << QByteArray(""); QTest::newRow("array-of-null") << QByteArray("\0", 1) + << '\0' << QByteArray("00") << QByteArray("0"); QTest::newRow("no-leading-zero") << QByteArray("\xf") + << '\0' << QByteArray("0f") << QByteArray("f"); QTest::newRow("single-byte") << QByteArray("\xaf") + << '\0' << QByteArray("af") << QByteArray("xaf"); QTest::newRow("no-leading-zero") << QByteArray("\xd\xde\xad\xc0\xde") + << '\0' << QByteArray("0ddeadc0de") << QByteArray("ddeadc0de"); QTest::newRow("garbage") << QByteArray("\xC\xde\xeC\xea\xee\xDe\xee\xee") + << '\0' << QByteArray("0cdeeceaeedeeeee") << QByteArray("Code less. Create more. Deploy everywhere."); QTest::newRow("under-defined-1") << QByteArray("\x1\x23") + << '\0' << QByteArray("0123") << QByteArray("x123"); QTest::newRow("under-defined-2") << QByteArray("\x12\x34") + << '\0' << QByteArray("1234") << QByteArray("x1234"); } @@ -1505,16 +1571,23 @@ void tst_QByteArray::toFromHex_data() void tst_QByteArray::toFromHex() { QFETCH(QByteArray, str); + QFETCH(char, sep); QFETCH(QByteArray, hex); QFETCH(QByteArray, hex_alt1); - { + if (sep == 0) { const QByteArray th = str.toHex(); QCOMPARE(th.size(), hex.size()); QCOMPARE(th, hex); } { + const QByteArray th = str.toHex(sep); + QCOMPARE(th.size(), hex.size()); + QCOMPARE(th, hex); + } + + { const QByteArray fh = QByteArray::fromHex(hex); QCOMPARE(fh.size(), str.size()); QCOMPARE(fh, str); diff --git a/tests/auto/corelib/tools/qbytearraymatcher/qbytearraymatcher.pro b/tests/auto/corelib/tools/qbytearraymatcher/qbytearraymatcher.pro index 0624e1886c..9d4d5964c9 100644 --- a/tests/auto/corelib/tools/qbytearraymatcher/qbytearraymatcher.pro +++ b/tests/auto/corelib/tools/qbytearraymatcher/qbytearraymatcher.pro @@ -2,3 +2,4 @@ CONFIG += testcase TARGET = tst_qbytearraymatcher QT = core testlib SOURCES = tst_qbytearraymatcher.cpp +contains(QT_CONFIG, c++14):CONFIG += c++14 diff --git a/tests/auto/corelib/tools/qbytearraymatcher/tst_qbytearraymatcher.cpp b/tests/auto/corelib/tools/qbytearraymatcher/tst_qbytearraymatcher.cpp index 82cc432d55..647a3ae379 100644 --- a/tests/auto/corelib/tools/qbytearraymatcher/tst_qbytearraymatcher.cpp +++ b/tests/auto/corelib/tools/qbytearraymatcher/tst_qbytearraymatcher.cpp @@ -43,10 +43,9 @@ class tst_QByteArrayMatcher : public QObject private slots: void interface(); void indexIn(); + void staticByteArrayMatcher(); }; -static QByteArrayMatcher matcher1; - void tst_QByteArrayMatcher::interface() { const char needle[] = "abc123"; @@ -56,6 +55,8 @@ void tst_QByteArrayMatcher::interface() haystack.insert(42, "abc123"); haystack.insert(84, "abc123"); + QByteArrayMatcher matcher1; + matcher1 = QByteArrayMatcher(QByteArray(needle)); QByteArrayMatcher matcher2; matcher2.setPattern(QByteArray(needle)); @@ -90,8 +91,10 @@ void tst_QByteArrayMatcher::interface() QCOMPARE(matcher7.indexIn(haystack), 42); } - -static QByteArrayMatcher matcher; +#define LONG_STRING__32 "abcdefghijklmnopqrstuvwxyz012345" +#define LONG_STRING__64 LONG_STRING__32 LONG_STRING__32 +#define LONG_STRING_128 LONG_STRING__64 LONG_STRING__64 +#define LONG_STRING_256 LONG_STRING_128 LONG_STRING_128 void tst_QByteArrayMatcher::indexIn() { @@ -101,6 +104,8 @@ void tst_QByteArrayMatcher::indexIn() QByteArray haystack(8, '\0'); haystack[7] = 0x1; + QByteArrayMatcher matcher; + matcher = QByteArrayMatcher(pattern); QCOMPARE(matcher.indexIn(haystack, 0), 5); QCOMPARE(matcher.indexIn(haystack, 1), 5); @@ -110,7 +115,103 @@ void tst_QByteArrayMatcher::indexIn() QCOMPARE(matcher.indexIn(haystack, 0), 5); QCOMPARE(matcher.indexIn(haystack, 1), 5); QCOMPARE(matcher.indexIn(haystack, 2), 5); + + QByteArray allChars(256, Qt::Uninitialized); + for (int i = 0; i < 256; ++i) + allChars[i] = char(i); + + matcher = QByteArrayMatcher(allChars); + haystack = LONG_STRING__32 "x" + matcher.pattern(); + QCOMPARE(matcher.indexIn(haystack, 0), 33); + QCOMPARE(matcher.indexIn(haystack, 1), 33); + QCOMPARE(matcher.indexIn(haystack, 2), 33); + QCOMPARE(matcher.indexIn(haystack, 33), 33); + QCOMPARE(matcher.indexIn(haystack, 34), -1); + + matcher = QByteArrayMatcher(LONG_STRING_256); + haystack = LONG_STRING__32 "x" + matcher.pattern(); + QCOMPARE(matcher.indexIn(haystack, 0), 33); + QCOMPARE(matcher.indexIn(haystack, 1), 33); + QCOMPARE(matcher.indexIn(haystack, 2), 33); + QCOMPARE(matcher.indexIn(haystack, 33), 33); + QCOMPARE(matcher.indexIn(haystack, 34), -1); } +void tst_QByteArrayMatcher::staticByteArrayMatcher() +{ + { + static Q_RELAXED_CONSTEXPR auto smatcher = qMakeStaticByteArrayMatcher("Hello"); + QCOMPARE(smatcher.pattern(), QByteArrayLiteral("Hello")); + + QCOMPARE(smatcher.indexIn(QByteArray("Hello, World!")), 0); + QCOMPARE(smatcher.indexIn(QByteArray("Hello, World!"), 0), 0); + QCOMPARE(smatcher.indexIn(QByteArray("Hello, World!"), 1), -1); + QCOMPARE(smatcher.indexIn(QByteArray("aHello, World!")), 1); + QCOMPARE(smatcher.indexIn(QByteArray("aaHello, World!")), 2); + QCOMPARE(smatcher.indexIn(QByteArray("aaaHello, World!")), 3); + QCOMPARE(smatcher.indexIn(QByteArray("aaaaHello, World!")), 4); + QCOMPARE(smatcher.indexIn(QByteArray("aaaaaHello, World!")), 5); + QCOMPARE(smatcher.indexIn(QByteArray("aaaaaaHello, World!")), 6); + QCOMPARE(smatcher.indexIn(QByteArray("HHello, World!")), 1); + QCOMPARE(smatcher.indexIn(QByteArray("HeHello, World!")), 2); + QCOMPARE(smatcher.indexIn(QByteArray("HelHello, World!")), 3); + QCOMPARE(smatcher.indexIn(QByteArray("HellHello, World!")), 4); + QCOMPARE(smatcher.indexIn(QByteArray("HellaHello, World!")), 5); + QCOMPARE(smatcher.indexIn(QByteArray("HellauHello, World!")), 6); + QCOMPARE(smatcher.indexIn(QByteArray("aHella, World!")), -1); + QCOMPARE(smatcher.indexIn(QByteArray("aaHella, World!")), -1); + QCOMPARE(smatcher.indexIn(QByteArray("aaaHella, World!")), -1); + QCOMPARE(smatcher.indexIn(QByteArray("aaaaHella, World!")), -1); + QCOMPARE(smatcher.indexIn(QByteArray("aaaaaHella, World!")), -1); + QCOMPARE(smatcher.indexIn(QByteArray("aaaaaaHella, World!")), -1); + + QCOMPARE(smatcher.indexIn(QByteArray("aHello")), 1); + QCOMPARE(smatcher.indexIn(QByteArray("aaHello")), 2); + QCOMPARE(smatcher.indexIn(QByteArray("aaaHello")), 3); + QCOMPARE(smatcher.indexIn(QByteArray("aaaaHello")), 4); + QCOMPARE(smatcher.indexIn(QByteArray("aaaaaHello")), 5); + QCOMPARE(smatcher.indexIn(QByteArray("aaaaaaHello")), 6); + QCOMPARE(smatcher.indexIn(QByteArray("HHello")), 1); + QCOMPARE(smatcher.indexIn(QByteArray("HeHello")), 2); + QCOMPARE(smatcher.indexIn(QByteArray("HelHello")), 3); + QCOMPARE(smatcher.indexIn(QByteArray("HellHello")), 4); + QCOMPARE(smatcher.indexIn(QByteArray("HellaHello")), 5); + QCOMPARE(smatcher.indexIn(QByteArray("HellauHello")), 6); + QCOMPARE(smatcher.indexIn(QByteArray("aHella")), -1); + QCOMPARE(smatcher.indexIn(QByteArray("aaHella")), -1); + QCOMPARE(smatcher.indexIn(QByteArray("aaaHella")), -1); + QCOMPARE(smatcher.indexIn(QByteArray("aaaaHella")), -1); + QCOMPARE(smatcher.indexIn(QByteArray("aaaaaHella")), -1); + QCOMPARE(smatcher.indexIn(QByteArray("aaaaaaHella")), -1); + } + + { + static Q_RELAXED_CONSTEXPR auto smatcher = qMakeStaticByteArrayMatcher(LONG_STRING_256); + QCOMPARE(smatcher.pattern(), QByteArrayLiteral(LONG_STRING_256)); + + QCOMPARE(smatcher.indexIn(QByteArray("a" LONG_STRING_256)), 1); + QCOMPARE(smatcher.indexIn(QByteArray("aa" LONG_STRING_256)), 2); + QCOMPARE(smatcher.indexIn(QByteArray("aaa" LONG_STRING_256)), 3); + QCOMPARE(smatcher.indexIn(QByteArray("aaaa" LONG_STRING_256)), 4); + QCOMPARE(smatcher.indexIn(QByteArray("aaaaa" LONG_STRING_256)), 5); + QCOMPARE(smatcher.indexIn(QByteArray("aaaaaa" LONG_STRING_256)), 6); + QCOMPARE(smatcher.indexIn(QByteArray("a" LONG_STRING_256 "a")), 1); + QCOMPARE(smatcher.indexIn(QByteArray("aa" LONG_STRING_256 "a")), 2); + QCOMPARE(smatcher.indexIn(QByteArray("aaa" LONG_STRING_256 "a")), 3); + QCOMPARE(smatcher.indexIn(QByteArray("aaaa" LONG_STRING_256 "a")), 4); + QCOMPARE(smatcher.indexIn(QByteArray("aaaaa" LONG_STRING_256 "a")), 5); + QCOMPARE(smatcher.indexIn(QByteArray("aaaaaa" LONG_STRING_256 "a")), 6); + QCOMPARE(smatcher.indexIn(QByteArray(LONG_STRING__32 "x" LONG_STRING_256)), 33); + QCOMPARE(smatcher.indexIn(QByteArray(LONG_STRING__64 "x" LONG_STRING_256)), 65); + QCOMPARE(smatcher.indexIn(QByteArray(LONG_STRING_128 "x" LONG_STRING_256)), 129); + } + +} + +#undef LONG_STRING_256 +#undef LONG_STRING_128 +#undef LONG_STRING__64 +#undef LONG_STRING__32 + QTEST_APPLESS_MAIN(tst_QByteArrayMatcher) #include "tst_qbytearraymatcher.moc" diff --git a/tests/auto/corelib/tools/qchar/tst_qchar.cpp b/tests/auto/corelib/tools/qchar/tst_qchar.cpp index b42be94da3..e5a6e953d3 100644 --- a/tests/auto/corelib/tools/qchar/tst_qchar.cpp +++ b/tests/auto/corelib/tools/qchar/tst_qchar.cpp @@ -127,7 +127,7 @@ void tst_QChar::operators_data() for (int i = 0; i < 3; ++i) { for (int j = 0; j < 3; ++j) - QTest::newRow(qPrintable(QString::asprintf("'\\%d' (op) '\\%d'", i, j))) + QTest::addRow("'\\%d' (op) '\\%d'", i, j) << QChar(ushort(i)) << QChar(ushort(j)); } } diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp index b6c740998e..28ad2d193c 100644 --- a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp @@ -80,8 +80,10 @@ private slots: void fromMSecsSinceEpoch(); void toString_isoDate_data(); void toString_isoDate(); + void toString_isoDate_extra(); void toString_textDate_data(); void toString_textDate(); + void toString_textDate_extra(); void toString_rfcDate_data(); void toString_rfcDate(); void toString_enumformat(); @@ -158,8 +160,6 @@ private: QDateTime invalidDateTime() const { return QDateTime(invalidDate(), invalidTime()); } QDate invalidDate() const { return QDate(); } QTime invalidTime() const { return QTime(-1, -1, -1); } - qint64 minJd() const { return QDateTimePrivate::minJd(); } - qint64 maxJd() const { return QDateTimePrivate::maxJd(); } class TimeZoneRollback { @@ -642,10 +642,8 @@ void tst_QDateTime::setMSecsSinceEpoch_data() << QDateTime(QDate::fromJulianDay(0x7fffffff), QTime(21, 59, 59, 999), Qt::UTC) << QDateTime(QDate::fromJulianDay(0x7fffffff), QTime(23, 59, 59, 999)); QTest::newRow("min") - // + 1 because, in the reference check below, calling addMSecs(qint64min) - // will internally apply unary minus to -qint64min, resulting in a - // positive value 1 too big for qint64max, causing an overflow. - << std::numeric_limits<qint64>::min() + 1 + // Use -max(), which is min() + 1, to simplify filtering out overflow cases: + << -std::numeric_limits<qint64>::max() << QDateTime(QDate(-292275056, 5, 16), QTime(16, 47, 4, 193), Qt::UTC) << QDateTime(QDate(-292275056, 5, 16), QTime(17, 47, 4, 193), Qt::LocalTime); QTest::newRow("max") @@ -746,8 +744,8 @@ void tst_QDateTime::fromMSecsSinceEpoch() QDateTime dtUtc = QDateTime::fromMSecsSinceEpoch(msecs, Qt::UTC); QDateTime dtOffset = QDateTime::fromMSecsSinceEpoch(msecs, Qt::OffsetFromUTC, 60*60); - // LocalTime will overflow for min or max, depending on whether you're - // East or West of Greenwich. The test passes at GMT. + // LocalTime will overflow for "min" or "max" tests, depending on whether + // you're East or West of Greenwich. In UTC, we won't overflow. if (localTimeType == LocalTimeIsUtc || msecs != std::numeric_limits<qint64>::max() * localTimeType) QCOMPARE(dtLocal, utc); @@ -853,6 +851,28 @@ void tst_QDateTime::toString_isoDate() QLocale::setDefault(oldLocale); } +void tst_QDateTime::toString_isoDate_extra() +{ + QDateTime dt = QDateTime::fromMSecsSinceEpoch(0, Qt::UTC); + QCOMPARE(dt.toString(Qt::ISODate), QLatin1String("1970-01-01T00:00:00Z")); +#if QT_CONFIG(timezone) + QTimeZone PST("America/Vancouver"); + if (PST.isValid()) { + dt = QDateTime::fromMSecsSinceEpoch(0, PST); + QCOMPARE(dt.toString(Qt::ISODate), QLatin1String("1969-12-31T16:00:00-08:00")); + } else { + qDebug("Missed zone test: no America/Vancouver zone available"); + } + QTimeZone CET("Europe/Berlin"); + if (CET.isValid()) { + dt = QDateTime::fromMSecsSinceEpoch(0, CET); + QCOMPARE(dt.toString(Qt::ISODate), QLatin1String("1970-01-01T01:00:00+01:00")); + } else { + qDebug("Missed zone test: no Europe/Berlin zone available"); + } +#endif // timezone +} + void tst_QDateTime::toString_textDate_data() { QTest::addColumn<QDateTime>("datetime"); @@ -890,6 +910,49 @@ void tst_QDateTime::toString_textDate() QCOMPARE(resultDatetime.utcOffset(), datetime.utcOffset()); } +void tst_QDateTime::toString_textDate_extra() +{ + QLatin1String GMT("GMT"); + QDateTime dt = QDateTime::fromMSecsSinceEpoch(0, Qt::LocalTime); + QVERIFY(!dt.toString().endsWith(GMT)); + dt = QDateTime::fromMSecsSinceEpoch(0, Qt::UTC).toLocalTime(); + QVERIFY(!dt.toString().endsWith(GMT)); + if (QTimeZone::systemTimeZone().offsetFromUtc(dt)) + QVERIFY(dt.toString() != QLatin1String("Thu Jan 1 00:00:00 1970")); + else + QCOMPARE(dt.toString(), QLatin1String("Thu Jan 1 00:00:00 1970")); +#if QT_CONFIG(timezone) + QTimeZone PST("America/Vancouver"); + if (PST.isValid()) { + dt = QDateTime::fromMSecsSinceEpoch(0, PST); +# if defined Q_OS_UNIX && !defined Q_OS_DARWIN + QCOMPARE(dt.toString(), QLatin1String("Wed Dec 31 16:00:00 1969 PST")); +# else // QTBUG-57320, QTBUG-57298 + QVERIFY(dt.toString().startsWith(QLatin1String("Wed Dec 31 16:00:00 1969 "))); +# endif + dt = dt.toLocalTime(); + QVERIFY(!dt.toString().endsWith(GMT)); + } else { + qDebug("Missed zone test: no America/Vancouver zone available"); + } + QTimeZone CET("Europe/Berlin"); + if (CET.isValid()) { + dt = QDateTime::fromMSecsSinceEpoch(0, CET); +# if defined Q_OS_UNIX && !defined Q_OS_DARWIN + QCOMPARE(dt.toString(), QLatin1String("Thu Jan 1 01:00:00 1970 CET")); +# else // QTBUG-57320, QTBUG-57298 + QVERIFY(dt.toString().startsWith(QLatin1String("Thu Jan 1 01:00:00 1970 "))); +# endif + dt = dt.toLocalTime(); + QVERIFY(!dt.toString().endsWith(GMT)); + } else { + qDebug("Missed zone test: no Europe/Berlin zone available"); + } +#endif // timezone + dt = QDateTime::fromMSecsSinceEpoch(0, Qt::UTC); + QVERIFY(dt.toString().endsWith(GMT)); +} + void tst_QDateTime::toString_rfcDate_data() { QTest::addColumn<QDateTime>("dt"); @@ -3232,17 +3295,17 @@ void tst_QDateTime::timeZones() const // Test local to MSecs // - Test first occurrence 02:00:00 = 1 hour before tran hourBeforeStd = QDateTime(QDate(2013, 10, 27), QTime(2, 0, 0), cet); + QEXPECT_FAIL("", "QDateTime doesn't properly support Daylight Transitions", Continue); QCOMPARE(hourBeforeStd.toMSecsSinceEpoch(), dstToStdMSecs - 3600000); // - Test first occurrence 02:59:59.999 = 1 msec before tran msecBeforeStd = QDateTime(QDate(2013, 10, 27), QTime(2, 59, 59, 999), cet); + QEXPECT_FAIL("", "QDateTime doesn't properly support Daylight Transitions", Continue); QCOMPARE(msecBeforeStd.toMSecsSinceEpoch(), dstToStdMSecs - 1); // - Test second occurrence 02:00:00 = at tran atStd = QDateTime(QDate(2013, 10, 27), QTime(2, 0, 0), cet); - QEXPECT_FAIL("", "QDateTime doesn't properly support Daylight Transitions", Continue); QCOMPARE(atStd.toMSecsSinceEpoch(), dstToStdMSecs); // - Test second occurrence 03:00:00 = 59 mins after tran afterStd = QDateTime(QDate(2013, 10, 27), QTime(2, 59, 59, 999), cet); - QEXPECT_FAIL("", "QDateTime doesn't properly support Daylight Transitions", Continue); QCOMPARE(afterStd.toMSecsSinceEpoch(), dstToStdMSecs + 3600000 - 1); // - Test 03:00:00 = 1 hour after tran hourAfterStd = QDateTime(QDate(2013, 10, 27), QTime(3, 0, 0), cet); diff --git a/tests/auto/corelib/tools/qhash/tst_qhash.cpp b/tests/auto/corelib/tools/qhash/tst_qhash.cpp index 0b864e71d4..0c5f1a7afb 100644 --- a/tests/auto/corelib/tools/qhash/tst_qhash.cpp +++ b/tests/auto/corelib/tools/qhash/tst_qhash.cpp @@ -1053,6 +1053,10 @@ void tst_QHash::keyIterator() QCOMPARE(*(--key_it), (--it).key()); QCOMPARE(std::count(hash.keyBegin(), hash.keyEnd(), 99), 1); + + // DefaultConstructible test + typedef QHash<int, int>::key_iterator keyIterator; + Q_STATIC_ASSERT(std::is_default_constructible<keyIterator>::value); } void tst_QHash::rehash_isnt_quadratic() diff --git a/tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp b/tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp index 0c890eafbc..4a81adf9fe 100644 --- a/tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp +++ b/tests/auto/corelib/tools/qhashfunctions/tst_qhashfunctions.cpp @@ -37,11 +37,22 @@ class tst_QHashFunctions : public QObject { Q_OBJECT +public: + enum { + // random value + RandomSeed = 1045982819 + }; + uint seed; + +public slots: + void initTestCase(); + void init(); + private Q_SLOTS: void qhash(); void qhash_of_empty_and_null_qstring(); void qhash_of_empty_and_null_qbytearray(); - void fp_qhash_of_zero_is_zero(); + void fp_qhash_of_zero_is_seed(); void qthash_data(); void qthash(); void range(); @@ -50,12 +61,27 @@ private Q_SLOTS: void setGlobalQHashSeed(); }; +void tst_QHashFunctions::initTestCase() +{ + Q_STATIC_ASSERT(int(RandomSeed) > 0); + + QTest::addColumn<uint>("seedValue"); + QTest::newRow("zero-seed") << 0U; + QTest::newRow("non-zero-seed") << uint(RandomSeed); +} + +void tst_QHashFunctions::init() +{ + QFETCH_GLOBAL(uint, seedValue); + seed = seedValue; +} + void tst_QHashFunctions::qhash() { { QBitArray a1; QBitArray a2; - QVERIFY(qHash(a1) == 0); + QCOMPARE(qHash(a1, seed), seed); a1.resize(1); a1.setBit(0, true); @@ -63,53 +89,53 @@ void tst_QHashFunctions::qhash() a2.resize(1); a2.setBit(0, false); - uint h1 = qHash(a1); - uint h2 = qHash(a2); + uint h1 = qHash(a1, seed); + uint h2 = qHash(a2, seed); - QVERIFY(h1 != h2); + QVERIFY(h1 != h2); // not guaranteed a2.setBit(0, true); - QVERIFY(h1 == qHash(a2)); + QVERIFY(h1 == qHash(a2, seed)); a1.fill(true, 8); a1.resize(7); - h1 = qHash(a1); + h1 = qHash(a1, seed); a2.fill(true, 7); - h2 = qHash(a2); + h2 = qHash(a2, seed); QVERIFY(h1 == h2); a2.setBit(0, false); - uint h3 = qHash(a2); - QVERIFY(h2 != h3); + uint h3 = qHash(a2, seed); + QVERIFY(h2 != h3); // not guaranteed a2.setBit(0, true); - QVERIFY(h2 == qHash(a2)); + QVERIFY(h2 == qHash(a2, seed)); a2.setBit(6, false); - uint h4 = qHash(a2); - QVERIFY(h2 != h4); + uint h4 = qHash(a2, seed); + QVERIFY(h2 != h4); // not guaranteed a2.setBit(6, true); - QVERIFY(h2 == qHash(a2)); + QVERIFY(h2 == qHash(a2, seed)); - QVERIFY(h3 != h4); + QVERIFY(h3 != h4); // not guaranteed } { QPair<int, int> p12(1, 2); QPair<int, int> p21(2, 1); - QVERIFY(qHash(p12) == qHash(p12)); - QVERIFY(qHash(p21) == qHash(p21)); - QVERIFY(qHash(p12) != qHash(p21)); + QVERIFY(qHash(p12, seed) == qHash(p12, seed)); + QVERIFY(qHash(p21, seed) == qHash(p21, seed)); + QVERIFY(qHash(p12, seed) != qHash(p21, seed)); // not guaranteed QPair<int, int> pA(0x12345678, 0x12345678); QPair<int, int> pB(0x12345675, 0x12345675); - QVERIFY(qHash(pA) != qHash(pB)); + QVERIFY(qHash(pA, seed) != qHash(pB, seed)); // not guaranteed } { @@ -118,14 +144,14 @@ void tst_QHashFunctions::qhash() using QT_PREPEND_NAMESPACE(qHash); - QVERIFY(qHash(p12) == qHash(p12)); - QVERIFY(qHash(p21) == qHash(p21)); - QVERIFY(qHash(p12) != qHash(p21)); + QVERIFY(qHash(p12, seed) == qHash(p12, seed)); + QVERIFY(qHash(p21, seed) == qHash(p21, seed)); + QVERIFY(qHash(p12, seed) != qHash(p21, seed)); // not guaranteed std::pair<int, int> pA(0x12345678, 0x12345678); std::pair<int, int> pB(0x12345675, 0x12345675); - QVERIFY(qHash(pA) != qHash(pB)); + QVERIFY(qHash(pA, seed) != qHash(pB, seed)); // not guaranteed } } @@ -133,27 +159,27 @@ void tst_QHashFunctions::qhash_of_empty_and_null_qstring() { QString null, empty(""); QCOMPARE(null, empty); - QCOMPARE(qHash(null), qHash(empty)); + QCOMPARE(qHash(null, seed), qHash(empty, seed)); } void tst_QHashFunctions::qhash_of_empty_and_null_qbytearray() { QByteArray null, empty(""); QCOMPARE(null, empty); - QCOMPARE(qHash(null), qHash(empty)); + QCOMPARE(qHash(null, seed), qHash(empty, seed)); } -void tst_QHashFunctions::fp_qhash_of_zero_is_zero() +void tst_QHashFunctions::fp_qhash_of_zero_is_seed() { - QCOMPARE(qHash(-0.0f), 0U); - QCOMPARE(qHash( 0.0f), 0U); + QCOMPARE(qHash(-0.0f, seed), seed); + QCOMPARE(qHash( 0.0f, seed), seed); - QCOMPARE(qHash(-0.0 ), 0U); - QCOMPARE(qHash( 0.0 ), 0U); + QCOMPARE(qHash(-0.0 , seed), seed); + QCOMPARE(qHash( 0.0 , seed), seed); #ifndef Q_OS_DARWIN - QCOMPARE(qHash(-0.0L), 0U); - QCOMPARE(qHash( 0.0L), 0U); + QCOMPARE(qHash(-0.0L, seed), seed); + QCOMPARE(qHash( 0.0L, seed), seed); #endif } @@ -188,10 +214,10 @@ void tst_QHashFunctions::range() static const size_t numInts = sizeof ints / sizeof *ints; // empty range just gives the seed: - QCOMPARE(qHashRange(ints, ints, 0xdeadbeefU), 0xdeadbeefU); - // verify that order matters: - QVERIFY(qHashRange(ints, ints + numInts) != - qHashRange(std::reverse_iterator<const int*>(ints + numInts), std::reverse_iterator<const int*>(ints))); + QCOMPARE(qHashRange(ints, ints, seed), seed); + // verify that order matters (test not guaranteed): + QVERIFY(qHashRange(ints, ints + numInts, seed) != + qHashRange(std::reverse_iterator<const int*>(ints + numInts), std::reverse_iterator<const int*>(ints), seed)); { // verify that the input iterator category suffices: @@ -200,13 +226,13 @@ void tst_QHashFunctions::range() std::copy(ints, ints + numInts, std::ostream_iterator<int>(sstream, " ")); sstream.seekg(0); std::istream_iterator<int> it(sstream), end; - QCOMPARE(qHashRange(ints, ints + numInts), qHashRange(it, end)); + QCOMPARE(qHashRange(ints, ints + numInts, seed), qHashRange(it, end, seed)); } SomeNamespace::Hashable hashables[] = {{0}, {1}, {2}, {3}, {4}, {5}}; static const size_t numHashables = sizeof hashables / sizeof *hashables; // compile check: is qHash() found using ADL? - (void)qHashRange(hashables, hashables + numHashables); + (void)qHashRange(hashables, hashables + numHashables, seed); } void tst_QHashFunctions::rangeCommutative() @@ -215,10 +241,10 @@ void tst_QHashFunctions::rangeCommutative() static const size_t numInts = sizeof ints / sizeof *ints; // empty range just gives the seed: - QCOMPARE(qHashRangeCommutative(ints, ints, 0xdeadbeefU), 0xdeadbeefU); - // verify that order doesn't matter: - QCOMPARE(qHashRangeCommutative(ints, ints + numInts), - qHashRangeCommutative(std::reverse_iterator<int*>(ints + numInts), std::reverse_iterator<int*>(ints))); + QCOMPARE(qHashRangeCommutative(ints, ints, seed), seed); + // verify that order doesn't matter (test not guaranteed): + QCOMPARE(qHashRangeCommutative(ints, ints + numInts, seed), + qHashRangeCommutative(std::reverse_iterator<int*>(ints + numInts), std::reverse_iterator<int*>(ints), seed)); { // verify that the input iterator category suffices: @@ -226,13 +252,13 @@ void tst_QHashFunctions::rangeCommutative() std::copy(ints, ints + numInts, std::ostream_iterator<int>(sstream, " ")); sstream.seekg(0); std::istream_iterator<int> it(sstream), end; - QCOMPARE(qHashRangeCommutative(ints, ints + numInts), qHashRangeCommutative(it, end)); + QCOMPARE(qHashRangeCommutative(ints, ints + numInts, seed), qHashRangeCommutative(it, end, seed)); } SomeNamespace::Hashable hashables[] = {{0}, {1}, {2}, {3}, {4}, {5}}; static const size_t numHashables = sizeof hashables / sizeof *hashables; // compile check: is qHash() found using ADL? - (void)qHashRangeCommutative(hashables, hashables + numHashables); + (void)qHashRangeCommutative(hashables, hashables + numHashables, seed); } void tst_QHashFunctions::setGlobalQHashSeed() diff --git a/tests/auto/corelib/tools/qlatin1string/tst_qlatin1string.cpp b/tests/auto/corelib/tools/qlatin1string/tst_qlatin1string.cpp index 06e2e1cc45..a68671d899 100644 --- a/tests/auto/corelib/tools/qlatin1string/tst_qlatin1string.cpp +++ b/tests/auto/corelib/tools/qlatin1string/tst_qlatin1string.cpp @@ -176,9 +176,9 @@ void tst_QLatin1String::relationalOperators_data() for (Data *lhs = data; lhs != data + sizeof data / sizeof *data; ++lhs) { for (Data *rhs = data; rhs != data + sizeof data / sizeof *data; ++rhs) { QLatin1StringContainer l = { lhs->l1 }, r = { rhs->l1 }; - QTest::newRow(qPrintable(QString::asprintf("\"%s\" <> \"%s\"", - lhs->l1.data() ? lhs->l1.data() : "nullptr", - rhs->l1.data() ? rhs->l1.data() : "nullptr"))) + QTest::addRow("\"%s\" <> \"%s\"", + lhs->l1.data() ? lhs->l1.data() : "nullptr", + rhs->l1.data() ? rhs->l1.data() : "nullptr") << l << lhs->order << r << rhs->order; } } diff --git a/tests/auto/corelib/tools/qlocale/test/test.pro b/tests/auto/corelib/tools/qlocale/test/test.pro index 595ee258e7..c87e29e764 100644 --- a/tests/auto/corelib/tools/qlocale/test/test.pro +++ b/tests/auto/corelib/tools/qlocale/test/test.pro @@ -1,5 +1,4 @@ CONFIG += console testcase -CONFIG -= app_bundle QT = core testlib core-private embedded: QT += gui SOURCES = ../tst_qlocale.cpp diff --git a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp index d18af71e20..5d13d9e454 100644 --- a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp +++ b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp @@ -1601,9 +1601,7 @@ void tst_QLocale::macDefaultLocale() // To run this test make sure "Curreny" is US Dollar in System Preferences->Language & Region->Advanced. if (locale.currencySymbol() == QString("$")) { QCOMPARE(locale.toCurrencyString(qulonglong(1234)), systemLocaleFormatNumber(QString("$1,234.00"))); - QCOMPARE(locale.toCurrencyString(qlonglong(-1234)), systemLocaleFormatNumber(QString("($1,234.00)"))); QCOMPARE(locale.toCurrencyString(double(1234.56)), systemLocaleFormatNumber(QString("$1,234.56"))); - QCOMPARE(locale.toCurrencyString(double(-1234.56)), systemLocaleFormatNumber(QString("($1,234.56)"))); } // Depending on the configured time zone, the time string might not @@ -1803,6 +1801,30 @@ void tst_QLocale::numberOptions() QVERIFY(ok); locale.toDouble(QString("1.24e+01"), &ok); QVERIFY(!ok); + + QCOMPARE(locale.toString(12.4, 'g', 5), QString("12.4")); + locale.setNumberOptions(QLocale::IncludeTrailingZeroesAfterDot); + QCOMPARE(locale.numberOptions(), QLocale::IncludeTrailingZeroesAfterDot); + QCOMPARE(locale.toString(12.4, 'g', 5), QString("12.400")); + + locale.toDouble(QString("1.24e+01"), &ok); + QVERIFY(ok); + locale.toDouble(QString("1.2400e+01"), &ok); + QVERIFY(ok); + locale.toDouble(QString("12.4"), &ok); + QVERIFY(ok); + locale.toDouble(QString("12.400"), &ok); + QVERIFY(ok); + locale.setNumberOptions(QLocale::RejectTrailingZeroesAfterDot); + QCOMPARE(locale.numberOptions(), QLocale::RejectTrailingZeroesAfterDot); + locale.toDouble(QString("1.24e+01"), &ok); + QVERIFY(ok); + locale.toDouble(QString("1.2400e+01"), &ok); + QVERIFY(!ok); + locale.toDouble(QString("12.4"), &ok); + QVERIFY(ok); + locale.toDouble(QString("12.400"), &ok); + QVERIFY(!ok); } void tst_QLocale::negativeNumbers() diff --git a/tests/auto/corelib/tools/qmap/tst_qmap.cpp b/tests/auto/corelib/tools/qmap/tst_qmap.cpp index 8aa7a3e518..f42ffc0471 100644 --- a/tests/auto/corelib/tools/qmap/tst_qmap.cpp +++ b/tests/auto/corelib/tools/qmap/tst_qmap.cpp @@ -857,6 +857,10 @@ void tst_QMap::keyIterator() QCOMPARE(*(--key_it), (--it).key()); QCOMPARE(std::count(map.keyBegin(), map.keyEnd(), 99), 1); + + // DefaultConstructible test + typedef QMap<int, int>::key_iterator keyIterator; + Q_STATIC_ASSERT(std::is_default_constructible<keyIterator>::value); } void tst_QMap::keys_values_uniqueKeys() diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp index 414ba2d8cf..03436375dd 100644 --- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp @@ -1066,6 +1066,7 @@ void tst_QString::acc_01() QT_WARNING_PUSH QT_WARNING_DISABLE_GCC("-Wformat-security") +QT_WARNING_DISABLE_CLANG("-Wformat-security") void tst_QString::isNull() { @@ -3817,7 +3818,7 @@ void tst_QString::startsWith() QVERIFY( !a.startsWith(QLatin1Char('x')) ); QVERIFY( !a.startsWith(QChar()) ); - a = QString::null; + a = QString(); QVERIFY( !a.startsWith("") ); QVERIFY( a.startsWith(QString::null) ); QVERIFY( !a.startsWith("ABC") ); @@ -3927,7 +3928,7 @@ void tst_QString::endsWith() QVERIFY( a.endsWith(QLatin1String(0)) ); QVERIFY( !a.endsWith(QLatin1String("ABC")) ); - a = QString::null; + a = QString(); QVERIFY( !a.endsWith("") ); QVERIFY( a.endsWith(QString::null) ); QVERIFY( !a.endsWith("ABC") ); @@ -4272,11 +4273,7 @@ void tst_QString::local8Bit_data() QTest::addColumn<QString>("local8Bit"); QTest::addColumn<QByteArray>("result"); -/* - QString::local8Bit() called on a null QString returns an _empty_ - QByteArray. -*/ - QTest::newRow("nullString") << QString() << QByteArray(""); + QTest::newRow("nullString") << QString() << QByteArray(); QTest::newRow("emptyString") << QString("") << QByteArray(""); QTest::newRow("string") << QString("test") << QByteArray("test"); @@ -6070,6 +6067,14 @@ void tst_QString::compare_data() lower += QChar(QChar::lowSurrogate(0x10428)); QTest::newRow("data8") << upper << lower << -1 << 0; + QTest::newRow("vectorized-boundaries-7") << QString("1234567") << QString("abcdefg") << -1 << -1; + QTest::newRow("vectorized-boundaries-8") << QString("12345678") << QString("abcdefgh") << -1 << -1; + QTest::newRow("vectorized-boundaries-9") << QString("123456789") << QString("abcdefghi") << -1 << -1; + + QTest::newRow("vectorized-boundaries-15") << QString("123456789012345") << QString("abcdefghiklmnop") << -1 << -1; + QTest::newRow("vectorized-boundaries-16") << QString("1234567890123456") << QString("abcdefghiklmnopq") << -1 << -1; + QTest::newRow("vectorized-boundaries-17") << QString("12345678901234567") << QString("abcdefghiklmnopqr") << -1 << -1; + // embedded nulls // These don't work as of now. It's OK that these don't work since \0 is not a valid unicode /*QTest::newRow("data10") << QString(QByteArray("\0", 1)) << QString(QByteArray("\0", 1)) << 0 << 0; @@ -6337,7 +6342,7 @@ void tst_QString::repeatedSignature() const { /* repated() should be a const member. */ const QString string; - string.repeated(3); + (void) string.repeated(3); } void tst_QString::repeated() const diff --git a/tests/auto/corelib/tools/qstringapisymmetry/tst_qstringapisymmetry.cpp b/tests/auto/corelib/tools/qstringapisymmetry/tst_qstringapisymmetry.cpp index 7305a00d94..9d9b47b61e 100644 --- a/tests/auto/corelib/tools/qstringapisymmetry/tst_qstringapisymmetry.cpp +++ b/tests/auto/corelib/tools/qstringapisymmetry/tst_qstringapisymmetry.cpp @@ -34,6 +34,7 @@ #include <QChar> #include <QStringRef> #include <QLatin1String> +#include <QVector> #include <QTest> @@ -71,6 +72,10 @@ class tst_QStringApiSymmetry : public QObject { Q_OBJECT + // + // Mixed UTF-16, UTF-8, Latin-1 checks: + // + void compare_data(bool hasConceptOfNullAndEmpty=true); template <typename LHS, typename RHS> void compare_impl() const; @@ -155,6 +160,44 @@ private Q_SLOTS: //void compare_const_char_star_const_char_star_data() { compare_data(); } //void compare_const_char_star_const_char_star() { compare_impl<const char *, const char *>(); } + // + // UTF-16-only checks: + // +private: + + void toLocal8Bit_data(); + template <typename String> void toLocal8Bit_impl(); + + void toLatin1_data(); + template <typename String> void toLatin1_impl(); + + void toUtf8_data(); + template <typename String> void toUtf8_impl(); + + void toUcs4_data(); + template <typename String> void toUcs4_impl(); + +private Q_SLOTS: + + void toLocal8Bit_QString_data() { toLocal8Bit_data(); } + void toLocal8Bit_QString() { toLocal8Bit_impl<QString>(); } + void toLocal8Bit_QStringRef_data() { toLocal8Bit_data(); } + void toLocal8Bit_QStringRef() { toLocal8Bit_impl<QStringRef>(); } + + void toLatin1_QString_data() { toLatin1_data(); } + void toLatin1_QString() { toLatin1_impl<QString>(); } + void toLatin1_QStringRef_data() { toLatin1_data(); } + void toLatin1_QStringRef() { toLatin1_impl<QStringRef>(); } + + void toUtf8_QString_data() { toUtf8_data(); } + void toUtf8_QString() { toUtf8_impl<QString>(); } + void toUtf8_QStringRef_data() { toUtf8_data(); } + void toUtf8_QStringRef() { toUtf8_impl<QStringRef>(); } + + void toUcs4_QString_data() { toUcs4_data(); } + void toUcs4_QString() { toUcs4_impl<QString>(); } + void toUcs4_QStringRef_data() { toUcs4_data(); } + void toUcs4_QStringRef() { toUcs4_impl<QStringRef>(); } }; void tst_QStringApiSymmetry::compare_data(bool hasConceptOfNullAndEmpty) @@ -257,6 +300,159 @@ void tst_QStringApiSymmetry::compare_impl() const #undef CHECK } +// +// +// UTF-16-only checks: +// +// + +template <class Str> Str make(const QString &s); +template <> QStringRef make(const QString &s) { return QStringRef(&s); } +template <> QString make(const QString &s) { return s; } + +#define REPEAT_16X(X) X X X X X X X X X X X X X X X X +#define LONG_STRING_256 REPEAT_16X("0123456789abcdef") + +void tst_QStringApiSymmetry::toLocal8Bit_data() +{ + QTest::addColumn<QString>("unicode"); + QTest::addColumn<QByteArray>("local"); + + auto add = [](const char *local) { + const QByteArray ba(local); + QString s; + for (char c : ba) + s += QLatin1Char(c); + QTest::addRow("\"%s\" (%d)", ba.left(16).constData(), ba.size()) << s << ba; + }; + + QTest::addRow("null") << QString() << QByteArray(); + QTest::addRow("empty") << QString("") << QByteArray(""); + + add("Moebius"); + add(LONG_STRING_256); +} + +template <typename String> +void tst_QStringApiSymmetry::toLocal8Bit_impl() +{ + QFETCH(const QString, unicode); + QFETCH(const QByteArray, local); + + const auto str = make<String>(unicode); + + const auto result = str.toLocal8Bit(); + + QCOMPARE(result, local); + QCOMPARE(unicode.isEmpty(), result.isEmpty()); + QCOMPARE(unicode.isNull(), result.isNull()); +} + +void tst_QStringApiSymmetry::toLatin1_data() +{ + QTest::addColumn<QString>("unicode"); + QTest::addColumn<QByteArray>("latin1"); + + auto add = [](const char *l1) { + const QByteArray ba(l1); + QString s; + for (char c : ba) + s += QLatin1Char(c); + QTest::addRow("\"%s\" (%d)", ba.left(16).constData(), ba.size()) << s << ba; + }; + + QTest::addRow("null") << QString() << QByteArray(); + QTest::addRow("empty") << QString("") << QByteArray(""); + + add("M\xF6" "bius"); + add(LONG_STRING_256); +} + +template <typename String> +void tst_QStringApiSymmetry::toLatin1_impl() +{ + QFETCH(const QString, unicode); + QFETCH(const QByteArray, latin1); + + const auto str = make<String>(unicode); + + const auto result = str.toLatin1(); + + QCOMPARE(result, latin1); + QCOMPARE(unicode.isEmpty(), result.isEmpty()); + QCOMPARE(unicode.isNull(), result.isNull()); +} + +void tst_QStringApiSymmetry::toUtf8_data() +{ + QTest::addColumn<QString>("unicode"); + QTest::addColumn<QByteArray>("utf8"); + + auto add = [](const char *u8) { + QByteArray ba(u8); + QString s = ba; + QTest::addRow("\"%s\" (%d)", ba.left(16).constData(), ba.size()) << s << ba; + }; + + QTest::addRow("null") << QString() << QByteArray(); + QTest::addRow("empty") << QString("") << QByteArray(""); + + add("M\xC3\xB6" "bius"); + add(LONG_STRING_256); +} + +template <typename String> +void tst_QStringApiSymmetry::toUtf8_impl() +{ + QFETCH(const QString, unicode); + QFETCH(const QByteArray, utf8); + + const auto str = make<String>(unicode); + + const auto result = str.toUtf8(); + + QCOMPARE(result, utf8); + QCOMPARE(unicode.isEmpty(), result.isEmpty()); + QCOMPARE(unicode.isNull(), result.isNull()); +} + +void tst_QStringApiSymmetry::toUcs4_data() +{ + QTest::addColumn<QString>("unicode"); + QTest::addColumn<QVector<uint>>("ucs4"); + + auto add = [](const char *l1) { + const QByteArray ba(l1); + QString s; + QVector<uint> ucs4; + for (char c : ba) { + s += QLatin1Char(c); + ucs4.append(uint(uchar(c))); + } + QTest::addRow("\"%s\" (%d)", ba.left(16).constData(), ba.size()) << s << ucs4; + }; + + QTest::addRow("null") << QString() << QVector<uint>(); + QTest::addRow("empty") << QString("") << QVector<uint>(); + + add("M\xF6" "bius"); + add(LONG_STRING_256); +} + +template <typename String> +void tst_QStringApiSymmetry::toUcs4_impl() +{ + QFETCH(const QString, unicode); + QFETCH(const QVector<uint>, ucs4); + + const auto str = make<String>(unicode); + + const auto result = str.toUcs4(); + + QCOMPARE(result, ucs4); + QCOMPARE(unicode.isEmpty(), ucs4.isEmpty()); +} + QTEST_APPLESS_MAIN(tst_QStringApiSymmetry) #include "tst_qstringapisymmetry.moc" diff --git a/tests/auto/corelib/tools/qtimezone/qtimezone.pro b/tests/auto/corelib/tools/qtimezone/qtimezone.pro index afc4c59dfe..19ebc13306 100644 --- a/tests/auto/corelib/tools/qtimezone/qtimezone.pro +++ b/tests/auto/corelib/tools/qtimezone/qtimezone.pro @@ -5,3 +5,8 @@ SOURCES = tst_qtimezone.cpp qtConfig(icu) { DEFINES += QT_USE_ICU } + +darwin { + OBJECTIVE_SOURCES += tst_qtimezone_darwin.mm + LIBS += -framework Foundation +} diff --git a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp index c631b395f8..c1f2822b74 100644 --- a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp +++ b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp @@ -45,6 +45,8 @@ private slots: void dataStreamTest(); void isTimeZoneIdAvailable(); void availableTimeZoneIds(); + void transitionEachZone_data(); + void transitionEachZone(); void stressTest(); void windowsId(); void isValidId_data(); @@ -54,23 +56,24 @@ private slots: void icuTest(); void tzTest(); void macTest(); + void darwinTypes(); void winTest(); private: - void printTimeZone(const QTimeZone tz); + void printTimeZone(const QTimeZone &tz); #ifdef QT_BUILD_INTERNAL void testCetPrivate(const QTimeZonePrivate &tzp); #endif // QT_BUILD_INTERNAL - bool debug; + const bool debug; }; tst_QTimeZone::tst_QTimeZone() -{ // Set to true to print debug output, test Display Names and run long stress tests - debug = false; + : debug(false) +{ } -void tst_QTimeZone::printTimeZone(const QTimeZone tz) +void tst_QTimeZone::printTimeZone(const QTimeZone &tz) { QDateTime now = QDateTime::currentDateTime(); QDateTime jan = QDateTime(QDate(2012, 1, 1), QTime(0, 0, 0), Qt::UTC); @@ -343,6 +346,7 @@ void tst_QTimeZone::isTimeZoneIdAvailable() foreach (const QByteArray &id, available) QVERIFY(QTimeZone::isTimeZoneIdAvailable(id)); +#ifdef QT_BUILD_INTERNAL // a-z, A-Z, 0-9, '.', '-', '_' are valid chars // Can't start with '-' // Parts separated by '/', each part min 1 and max of 14 chars @@ -365,6 +369,57 @@ void tst_QTimeZone::isTimeZoneIdAvailable() QCOMPARE(QTimeZonePrivate::isValidId("123456789012345"), false); QCOMPARE(QTimeZonePrivate::isValidId("123456789012345/12345678901234"), false); QCOMPARE(QTimeZonePrivate::isValidId("12345678901234/123456789012345"), false); +#endif // QT_BUILD_INTERNAL +} + +void tst_QTimeZone::transitionEachZone_data() +{ + QTest::addColumn<QByteArray>("zone"); + QTest::addColumn<qint64>("secs"); + QTest::addColumn<int>("start"); + QTest::addColumn<int>("stop"); + + struct { + qint64 baseSecs; + int start, stop; + int year; + } table[] = { + { 25666200, 3, 12, 1970 }, // 1970-10-25 01:30 UTC; North America + { 1288488600, -4, 8, 2010 } // 2010-10-31 01:30 UTC; Europe, Russia + }; + + QString name; + for (int k = sizeof(table) / sizeof(table[0]); k-- > 0; ) { + foreach (QByteArray zone, QTimeZone::availableTimeZoneIds()) { + name.sprintf("%s@%d", zone.constData(), table[k].year); + QTest::newRow(name.toUtf8().constData()) + << zone + << table[k].baseSecs + << table[k].start + << table[k].stop; + } + } +} + +void tst_QTimeZone::transitionEachZone() +{ + // Regression test: round-trip fromMsecs/toMSecs should be idempotent; but + // various zones failed during fall-back transitions. + QFETCH(QByteArray, zone); + QFETCH(qint64, secs); + QFETCH(int, start); + QFETCH(int, stop); + QTimeZone named(zone); + + for (int i = start; i < stop; i++) { + qint64 here = secs + i * 3600; + QDateTime when = QDateTime::fromMSecsSinceEpoch(here * 1000, named); + qint64 stamp = when.toMSecsSinceEpoch(); + if (here * 1000 != stamp) // (The +1 is due to using *1*:30 as baseSecs.) + qDebug() << "Failing for" << zone << "at half past" << (i + 1) << "UTC"; + QCOMPARE(stamp % 1000, 0); + QCOMPARE(here - stamp / 1000, 0); + } } void tst_QTimeZone::availableTimeZoneIds() @@ -704,9 +759,9 @@ void tst_QTimeZone::tzTest() // Test display names by type, either ICU or abbreviation only QLocale enUS("en_US"); -#ifdef QT_USE_ICU // Only test names in debug mode, names used can vary by ICU version installed if (debug) { +#ifdef QT_USE_ICU QCOMPARE(tzp.displayName(QTimeZone::StandardTime, QTimeZone::LongName, enUS), QString("Central European Standard Time")); QCOMPARE(tzp.displayName(QTimeZone::StandardTime, QTimeZone::ShortName, enUS), @@ -726,9 +781,7 @@ void tst_QTimeZone::tzTest() QString("GMT+01:00")); QCOMPARE(tzp.displayName(QTimeZone::GenericTime, QTimeZone::OffsetName, enUS), QString("UTC+01:00")); - } #else - if (debug) { QCOMPARE(tzp.displayName(QTimeZone::StandardTime, QTimeZone::LongName, enUS), QString("CET")); QCOMPARE(tzp.displayName(QTimeZone::StandardTime, QTimeZone::ShortName, enUS), @@ -747,10 +800,8 @@ void tst_QTimeZone::tzTest() QString("CET")); QCOMPARE(tzp.displayName(QTimeZone::GenericTime, QTimeZone::OffsetName, enUS), QString("CET")); - } #endif // QT_USE_ICU - if (debug) { // Test Abbreviations QCOMPARE(tzp.abbreviation(std), QString("CET")); QCOMPARE(tzp.abbreviation(dst), QString("CEST")); @@ -907,6 +958,16 @@ void tst_QTimeZone::macTest() #endif // Q_OS_MAC } +void tst_QTimeZone::darwinTypes() +{ +#ifndef Q_OS_DARWIN + QSKIP("This is an Apple-only test"); +#else + extern void tst_QTimeZone_darwinTypes(); // in tst_qtimezone_darwin.mm + tst_QTimeZone_darwinTypes(); +#endif +} + void tst_QTimeZone::winTest() { #if defined(QT_BUILD_INTERNAL) && defined(Q_OS_WIN) diff --git a/tests/auto/corelib/tools/qtimezone/tst_qtimezone_darwin.mm b/tests/auto/corelib/tools/qtimezone/tst_qtimezone_darwin.mm new file mode 100644 index 0000000000..de801e55d0 --- /dev/null +++ b/tests/auto/corelib/tools/qtimezone/tst_qtimezone_darwin.mm @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtCore/QTimeZone> +#include <QtTest/QtTest> + +#include <CoreFoundation/CoreFoundation.h> +#include <Foundation/Foundation.h> + +void tst_QTimeZone_darwinTypes() +{ +#if !defined(QT_NO_SYSTEMLOCALE) + // QTimeZone <-> CFTimeZone + { + QTimeZone qtTimeZone("America/Los_Angeles"); + const CFTimeZoneRef cfTimeZone = qtTimeZone.toCFTimeZone(); + QCOMPARE(QTimeZone::fromCFTimeZone(cfTimeZone), qtTimeZone); + CFRelease(cfTimeZone); + } + { + CFTimeZoneRef cfTimeZone = CFTimeZoneCreateWithName(kCFAllocatorDefault, + CFSTR("America/Los_Angeles"), false); + const QTimeZone qtTimeZone = QTimeZone::fromCFTimeZone(cfTimeZone); + QVERIFY(CFEqual(qtTimeZone.toCFTimeZone(), cfTimeZone)); + CFRelease(cfTimeZone); + } + // QTimeZone <-> NSTimeZone + { + NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init]; + QTimeZone qtTimeZone("America/Los_Angeles"); + const NSTimeZone *nsTimeZone = qtTimeZone.toNSTimeZone(); + QCOMPARE(QTimeZone::fromNSTimeZone(nsTimeZone), qtTimeZone); + [autoreleasepool release]; + } + { + NSAutoreleasePool *autoreleasepool = [[NSAutoreleasePool alloc] init]; + NSTimeZone *nsTimeZone = [NSTimeZone timeZoneWithName:@"America/Los_Angeles"]; + const QTimeZone qtTimeZone = QTimeZone::fromNSTimeZone(nsTimeZone); + QVERIFY([qtTimeZone.toNSTimeZone() isEqual:nsTimeZone]); + [autoreleasepool release]; + } +#endif +} diff --git a/tests/auto/dbus/qdbusconnection_spyhook/tst_qdbusconnection_spyhook.cpp b/tests/auto/dbus/qdbusconnection_spyhook/tst_qdbusconnection_spyhook.cpp index fa1c19920a..92bbbe1ef3 100644 --- a/tests/auto/dbus/qdbusconnection_spyhook/tst_qdbusconnection_spyhook.cpp +++ b/tests/auto/dbus/qdbusconnection_spyhook/tst_qdbusconnection_spyhook.cpp @@ -1,31 +1,26 @@ /**************************************************************************** ** ** Copyright (C) 2016 Intel Corporation. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** 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$ ** diff --git a/tests/auto/gui/image/image.pro b/tests/auto/gui/image/image.pro index 5a74df4c78..f4e2ab20ba 100644 --- a/tests/auto/gui/image/image.pro +++ b/tests/auto/gui/image/image.pro @@ -10,6 +10,7 @@ SUBDIRS=\ qmovie \ qpicture \ qicon \ + qiconhighdpi !qtHaveModule(network): SUBDIRS -= \ qimagereader diff --git a/tests/auto/gui/image/qiconhighdpi/icons/testtheme/16x16/actions/appointment-new.png b/tests/auto/gui/image/qiconhighdpi/icons/testtheme/16x16/actions/appointment-new.png Binary files differnew file mode 100644 index 0000000000..18b7c6781e --- /dev/null +++ b/tests/auto/gui/image/qiconhighdpi/icons/testtheme/16x16/actions/appointment-new.png diff --git a/tests/auto/gui/image/qiconhighdpi/icons/testtheme/22x22/actions/appointment-new.png b/tests/auto/gui/image/qiconhighdpi/icons/testtheme/22x22/actions/appointment-new.png Binary files differnew file mode 100644 index 0000000000..d676ffd463 --- /dev/null +++ b/tests/auto/gui/image/qiconhighdpi/icons/testtheme/22x22/actions/appointment-new.png diff --git a/tests/auto/gui/image/qiconhighdpi/icons/testtheme/22x22@2/actions/appointment-new.png b/tests/auto/gui/image/qiconhighdpi/icons/testtheme/22x22@2/actions/appointment-new.png Binary files differnew file mode 100644 index 0000000000..6d094d7b54 --- /dev/null +++ b/tests/auto/gui/image/qiconhighdpi/icons/testtheme/22x22@2/actions/appointment-new.png diff --git a/tests/auto/gui/image/qiconhighdpi/icons/testtheme/index.theme b/tests/auto/gui/image/qiconhighdpi/icons/testtheme/index.theme new file mode 100644 index 0000000000..6ab6c15c42 --- /dev/null +++ b/tests/auto/gui/image/qiconhighdpi/icons/testtheme/index.theme @@ -0,0 +1,21 @@ +[Icon Theme] +Name=Test +Comment=Test Theme + +Directories=16x16/actions,22x22/actions,22x22@2/actions + +[16x16/actions] +Size=16 +Context=Actions +Type=Fixed + +[22x22/actions] +Size=22 +Context=Actions +Type=Fixed + +[22x22@2/actions] +Size=22 +Context=Actions +Scale=2 +Type=Fixed diff --git a/tests/auto/gui/image/qiconhighdpi/qiconhighdpi.pro b/tests/auto/gui/image/qiconhighdpi/qiconhighdpi.pro new file mode 100644 index 0000000000..17553158bc --- /dev/null +++ b/tests/auto/gui/image/qiconhighdpi/qiconhighdpi.pro @@ -0,0 +1,8 @@ +CONFIG += testcase +TARGET = tst_qicon + +QT += testlib +SOURCES += tst_qiconhighdpi.cpp +RESOURCES = tst_qiconhighdpi.qrc + +TESTDATA += icons/* diff --git a/tests/auto/gui/image/qiconhighdpi/tst_qiconhighdpi.cpp b/tests/auto/gui/image/qiconhighdpi/tst_qiconhighdpi.cpp new file mode 100644 index 0000000000..ce7f68a0a6 --- /dev/null +++ b/tests/auto/gui/image/qiconhighdpi/tst_qiconhighdpi.cpp @@ -0,0 +1,195 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include <qicon.h> + +class tst_QIconHighDpi : public QObject +{ + Q_OBJECT +public: + tst_QIconHighDpi(); + +private slots: + void initTestCase(); + void fromTheme_data(); + void fromTheme(); +}; + +tst_QIconHighDpi::tst_QIconHighDpi() +{ +} + +void tst_QIconHighDpi::initTestCase() +{ +} + +void tst_QIconHighDpi::fromTheme_data() +{ + QTest::addColumn<int>("requestedSize"); + QTest::addColumn<int>("expectedSize"); + QTest::addColumn<qreal>("expectedDpr"); + + // The pixmaps that we have available can be found in tst_qiconhighdpi.qrc. + // Currently we only have @1 and @2 icons available. + const int dpr = qCeil(qApp->devicePixelRatio()); + + // We have an @2 high DPI version of the 22x22 size of this icon. + switch (dpr) { + case 1: QTest::newRow("22x22,dpr=1") << 22 << 22 << 1.0; break; + case 2: QTest::newRow("22x22,dpr=2") << 22 << 44 << 2.0; break; + case 3: QTest::newRow("22x22,dpr=3") << 22 << 44 << 2.0; break; + } + + // We don't have a high DPI version of the 16x16 size of this icon, + // so directoryMatchesSize() will return false for all directories. + // directorySizeDistance() is then called to find the best match. + // The table below illustrates the results for our available images at various DPRs: + // Available size | Available scale | Requested size | Requested scale | Distance + // 22 * 2 - 16 * 1 = 28 + // 22 * 1 - 16 * 1 = 6 + // 16 * 1 - 16 * 1 = 0 < (16x16) + // Available size | Available scale | Requested size | Requested scale | Distance + // 22 * 2 - 16 * 2 = 12 + // 22 * 1 - 16 * 2 = 10 < (22x22) + // 16 * 1 - 16 * 2 = 16 + // Available size | Available scale | Requested size | Requested scale | Distance + // 22 * 2 - 16 * 3 = 4 < (22x22@2) + // 22 * 1 - 16 * 3 = 26 + // 16 * 1 - 16 * 3 = 32 + // Both of these functions are implementations of the freedesktop icon theme spec, + // which dictates that if there is no matching scale, directorySizeDistance() determines + // the winner, regardless of whether or not the scale is too low for the requested scale. + switch (dpr) { + case 1: QTest::newRow("16x16,dpr=1") << 16 << 16 << 1.0; break; + // PixmapEntry::pixmap() will only downscale the pixmap if actualSize.width() > size.width(). + // In this case, 22 > 32 is false, so a 22x22 pixmap is returned. + case 2: QTest::newRow("16x16,dpr=2") << 16 << 22 << 1.375; break; + case 3: QTest::newRow("16x16,dpr=3") << 16 << 44 << 2.75; break; + } + + // We don't have an 8x8 size of this icon, so: + // Available size | Available scale | Requested size | Requested scale | Distance + // 22 * 2 - 8 * 1 = 36 + // 22 * 1 - 8 * 1 = 14 + // 16 * 1 - 8 * 1 = 8 < (16x16) + // Available size | Available scale | Requested size | Requested scale | Distance + // 22 * 2 - 8 * 2 = 28 + // 22 * 1 - 8 * 2 = 6 + // 16 * 1 - 8 * 2 = 0 < (16x16) + // Available size | Available scale | Requested size | Requested scale | Distance + // 22 * 2 - 8 * 3 = 20 + // 22 * 1 - 8 * 3 = 2 < (22x22) + // 16 * 1 - 8 * 3 = 8 + switch (dpr) { + case 1: QTest::newRow("8x8,dpr=1") << 8 << 8 << 1.0; break; + case 2: QTest::newRow("8x8,dpr=2") << 8 << 16 << 2.0; break; + case 3: QTest::newRow("8x8,dpr=3") << 8 << 22 << 2.75; break; + } + + // We don't have a 44x44 size of this icon, so: + // Available size | Available scale | Requested size | Requested scale | Distance + // 22 * 2 - 44 * 1 = 0 < (22x22@2) + // 22 * 1 - 44 * 1 = 22 + // 16 * 1 - 44 * 1 = 28 + // Available size | Available scale | Requested size | Requested scale | Distance + // 22 * 2 - 44 * 2 = 44 < (22x22@2) + // 22 * 1 - 44 * 2 = 66 + // 16 * 1 - 44 * 2 = 72 + // Available size | Available scale | Requested size | Requested scale | Distance + // 22 * 2 - 44 * 3 = 88 < (22x22@2) + // 22 * 1 - 44 * 3 = 110 + // 16 * 1 - 44 * 3 = 116 + switch (dpr) { + case 1: QTest::newRow("44x44,dpr=1") << 44 << 44 << 1.0; break; + case 2: QTest::newRow("44x44,dpr=2") << 44 << 44 << 1.0; break; + case 3: QTest::newRow("44x44,dpr=3") << 44 << 44 << 1.0; break; + } + + // We don't have a 20x20 size of this icon, so: + // Available size | Available scale | Requested size | Requested scale | Distance + // 22 * 2 - 20 * 1 = 24 + // 22 * 1 - 20 * 1 = 2 < (22x22) + // 16 * 1 - 20 * 1 = 4 + // Available size | Available scale | Requested size | Requested scale | Distance + // 22 * 2 - 20 * 2 = 4 < (22x22@2) + // 22 * 1 - 20 * 2 = 18 + // 16 * 1 - 20 * 2 = 24 + // Available size | Available scale | Requested size | Requested scale | Distance + // 22 * 2 - 20 * 3 = 16 < (22x22@2) + // 22 * 1 - 20 * 3 = 38 + // 16 * 1 - 20 * 3 = 44 + switch (dpr) { + case 1: QTest::newRow("20x20,dpr=1") << 20 << 20 << 1.0; break; + // PixmapEntry::pixmap() will only downscale the pixmap if actualSize.width() > size.width(). + // In this case, 44 > 40 is true, so the 44x44 pixmap is downscaled to 40x40. + case 2: QTest::newRow("20x20,dpr=2") << 20 << 40 << 2.0; break; + case 3: QTest::newRow("20x20,dpr=3") << 20 << 44 << 2.2; break; + } +} + +void tst_QIconHighDpi::fromTheme() +{ + QFETCH(int, requestedSize); + QFETCH(int, expectedSize); + QFETCH(qreal, expectedDpr); + + QString searchPath = QLatin1String(":/icons"); + QIcon::setThemeSearchPaths(QStringList() << searchPath); + QCOMPARE(QIcon::themeSearchPaths().size(), 1); + QCOMPARE(searchPath, QIcon::themeSearchPaths()[0]); + + QString themeName("testtheme"); + QIcon::setThemeName(themeName); + QCOMPARE(QIcon::themeName(), themeName); + + QIcon appointmentIcon = QIcon::fromTheme("appointment-new"); + QVERIFY(!appointmentIcon.isNull()); + QVERIFY(!appointmentIcon.availableSizes(QIcon::Normal, QIcon::Off).isEmpty()); + QVERIFY(appointmentIcon.availableSizes().contains(QSize(16, 16))); + QVERIFY(appointmentIcon.availableSizes().contains(QSize(22, 22))); + + const QPixmap pixmap = appointmentIcon.pixmap(requestedSize); + QCOMPARE(pixmap.size(), QSize(expectedSize, expectedSize)); + // We should get the high DPI version of an image if it exists in the correct directory. + // Note that we didn't pass the QWindow to QIcon::pixmap(), + // because QGuiApplication::devicePixelRatio() will be used if no window was given. + QCOMPARE(pixmap.devicePixelRatio(), expectedDpr); +} + +int main(int argc, char *argv[]) +{ + QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); + QGuiApplication app(argc, argv); + Q_UNUSED(app); + tst_QIconHighDpi test; + QTEST_SET_MAIN_SOURCE_PATH + return QTest::qExec(&test, argc, argv); +} + +#include "tst_qiconhighdpi.moc" diff --git a/tests/auto/gui/image/qiconhighdpi/tst_qiconhighdpi.qrc b/tests/auto/gui/image/qiconhighdpi/tst_qiconhighdpi.qrc new file mode 100644 index 0000000000..80b5e38ee6 --- /dev/null +++ b/tests/auto/gui/image/qiconhighdpi/tst_qiconhighdpi.qrc @@ -0,0 +1,8 @@ +<RCC> + <qresource prefix="/"> + <file>icons/testtheme/16x16/actions/appointment-new.png</file> + <file>icons/testtheme/22x22/actions/appointment-new.png</file> + <file>icons/testtheme/index.theme</file> + <file>icons/testtheme/22x22@2/actions/appointment-new.png</file> + </qresource> +</RCC> diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp index 2433fa4115..21481e374d 100644 --- a/tests/auto/gui/image/qimage/tst_qimage.cpp +++ b/tests/auto/gui/image/qimage/tst_qimage.cpp @@ -206,6 +206,11 @@ private slots: void ditherGradient_data(); void ditherGradient(); + void reinterpretAsFormat_data(); + void reinterpretAsFormat(); + + void reinterpretAsFormat2(); + #ifdef Q_OS_DARWIN void toCGImage_data(); void toCGImage(); @@ -1088,35 +1093,11 @@ void tst_QImage::rotate_data() degrees << 0 << 90 << 180 << 270; foreach (int d, degrees) { - const QByteArray dB = QByteArray::number(d); - QTest::newRow((dB + " Format_RGB32").constData()) - << QImage::Format_RGB32 << d; - QTest::newRow((dB + " Format_ARGB32").constData()) - << QImage::Format_ARGB32 << d; - QTest::newRow((dB + " Format_ARGB32_Premultiplied").constData()) - << QImage::Format_ARGB32_Premultiplied << d; - QTest::newRow((dB + " Format_RGB16").constData()) - << QImage::Format_RGB16 << d; - QTest::newRow((dB + " Format_ARGB8565_Premultiplied").constData()) - << QImage::Format_ARGB8565_Premultiplied << d; - QTest::newRow((dB + " Format_RGB666").constData()) - << QImage::Format_RGB666 << d; - QTest::newRow((dB + " Format_RGB555").constData()) - << QImage::Format_RGB555 << d; - QTest::newRow((dB + " Format_ARGB8555_Premultiplied").constData()) - << QImage::Format_ARGB8555_Premultiplied << d; - QTest::newRow((dB + " Format_RGB888").constData()) - << QImage::Format_RGB888 << d; - QTest::newRow((dB + " Format_Indexed8").constData()) - << QImage::Format_Indexed8 << d; - QTest::newRow((dB + " Format_RGBX8888").constData()) - << QImage::Format_RGBX8888 << d; - QTest::newRow((dB + " Format_RGBA8888_Premultiplied").constData()) - << QImage::Format_RGBA8888_Premultiplied << d; - QTest::newRow((dB + " Format_Alpha8").constData()) - << QImage::Format_Alpha8 << d; - QTest::newRow((dB + " Format_Grayscale8").constData()) - << QImage::Format_Grayscale8 << d; + const QString dB = QString::number(d); + for (int i = QImage::Format_Indexed8; i < QImage::NImageFormats; i++) { + QImage::Format format = static_cast<QImage::Format>(i); + QTest::newRow(qPrintable(dB + " " + formatToString(format))) << format << d; + } } } @@ -3327,6 +3308,64 @@ void tst_QImage::ditherGradient() QVERIFY(observedGradientSteps >= minimumExpectedGradient); } +void tst_QImage::reinterpretAsFormat_data() +{ + QTest::addColumn<QImage::Format>("in_format"); + QTest::addColumn<QImage::Format>("out_format"); + QTest::addColumn<QColor>("in_color"); + QTest::addColumn<QColor>("out_color"); + +#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN + QTest::newRow("rgb32 -> rgbx8888") << QImage::Format_RGB32 << QImage::Format_RGBX8888 << QColor(Qt::red) << QColor(Qt::blue); + QTest::newRow("rgba8888 -> argb32") << QImage::Format_RGBA8888 << QImage::Format_ARGB32 << QColor(Qt::red) << QColor(Qt::blue); + QTest::newRow("argb32pm -> rgba8888pm") << QImage::Format_RGBA8888_Premultiplied << QImage::Format_ARGB32_Premultiplied << QColor(Qt::green) << QColor(Qt::green); +#endif + QTest::newRow("rgb32 -> argb32") << QImage::Format_RGB32 << QImage::Format_ARGB32 << QColor(Qt::cyan) << QColor(Qt::cyan); + QTest::newRow("argb32pm -> rgb32") << QImage::Format_ARGB32_Premultiplied << QImage::Format_RGB32 << QColor(Qt::transparent) << QColor(Qt::black); + QTest::newRow("argb32 -> rgb32") << QImage::Format_ARGB32 << QImage::Format_RGB32 << QColor(255, 0, 0, 127) << QColor(255, 0, 0); + QTest::newRow("argb32pm -> rgb32") << QImage::Format_ARGB32_Premultiplied << QImage::Format_RGB32 << QColor(255, 0, 0, 127) << QColor(127, 0, 0); +} + +void tst_QImage::reinterpretAsFormat() +{ + QFETCH(QImage::Format, in_format); + QFETCH(QImage::Format, out_format); + QFETCH(QColor, in_color); + QFETCH(QColor, out_color); + + QImage image(1, 1, in_format); + image.setPixelColor(0, 0, in_color); + QVERIFY(image.reinterpretAsFormat(out_format)); + QCOMPARE(image.pixelColor(0, 0), out_color); +} + +void tst_QImage::reinterpretAsFormat2() +{ + const uint imageData[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; + + { + QImage image(reinterpret_cast<const uchar*>(imageData), 4, 2, QImage::Format_RGB32); + QCOMPARE(image.pixelColor(0, 0), QColor(Qt::black)); + QVERIFY(image.isDetached()); + QVERIFY(image.reinterpretAsFormat(QImage::Format_ARGB32_Premultiplied)); + QCOMPARE(image.constBits(), reinterpret_cast<const uchar*>(imageData)); + QCOMPARE(image.pixelColor(0, 0), QColor(Qt::transparent)); + + QVERIFY(!image.reinterpretAsFormat(QImage::Format_Grayscale8)); + } + { + QImage image(reinterpret_cast<const uchar*>(imageData), 8, 4, QImage::Format_Indexed8); + image.setColor(0, qRgb(255, 255, 255)); + QCOMPARE(image.pixelColor(0, 0), QColor(Qt::white)); + QVERIFY(image.reinterpretAsFormat(QImage::Format_Grayscale8)); + QCOMPARE(image.pixelColor(0, 0), QColor(Qt::black)); + QVERIFY(image.reinterpretAsFormat(QImage::Format_Alpha8)); + QCOMPARE(image.pixelColor(0, 0), QColor(Qt::transparent)); + + QVERIFY(!image.reinterpretAsFormat(QImage::Format_RGB16)); + } +} + #ifdef Q_OS_DARWIN void tst_QImage::toCGImage_data() diff --git a/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp b/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp index bd02dc6255..18649b3de5 100644 --- a/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp +++ b/tests/auto/gui/image/qimagereader/tst_qimagereader.cpp @@ -133,6 +133,9 @@ private slots: void gifImageCount(); void gifLoopCount(); + void ppmMaxval_data(); + void ppmMaxval(); + void readCorruptImage_data(); void readCorruptImage(); void readCorruptBmp(); @@ -956,6 +959,79 @@ void tst_QImageReader::gifLoopCount() } } +void tst_QImageReader::ppmMaxval_data() +{ + QTest::addColumn<bool>("hasColor"); + QTest::addColumn<QByteArray>("bytes"); + + QTest::newRow("PGM plain 8bit full") << false << QByteArray("P2 3 1 255 255 0 127\n"); + QTest::newRow("PGM plain 8bit lim.") << false << QByteArray("P2 3 1 50 50 0 25\n"); + QTest::newRow("PGM plain 16bit full") << false << QByteArray("P2 3 1 65535 65535 0 32767\n"); + QTest::newRow("PGM plain 16bit lim.") << false << QByteArray("P2 3 1 5000 5000 0 2500\n"); + QTest::newRow("PGM raw 8bit full") << false << QByteArray("P5 3 1 255 \xff\x00\x7f", 13 + 3); + QTest::newRow("PGM raw 8bit lim.") << false << QByteArray("P5 3 1 50 \x32\x00\x19", 13 + 3); + QTest::newRow("PGM raw 16bit full") << false << QByteArray("P5 3 1 65535 \xff\xff\x00\x00\x7f\xff", 13 + 3 * 2); + QTest::newRow("PGM raw 16bit lim.") << false << QByteArray("P5 3 1 5000 \x13\x88\x00\x00\x09\xc4", 13 + 3 * 2); + + QTest::newRow("PPM plain 8bit full") << true << QByteArray("P3 3 2 255 " + "255 255 255 0 0 0 127 127 127 " + "255 0 0 0 255 0 0 0 255\n"); + + QTest::newRow("PPM plain 8bit lim.") << true << QByteArray("P3 3 2 50 " + " 50 50 50 0 0 0 25 25 25 " + " 50 0 0 0 50 0 0 0 50\n"); + + QTest::newRow("PPM plain 16bit full") << true << QByteArray("P3 3 2 65535 " + "65535 65535 65535 0 0 0 32767 32767 32767 " + "65535 0 0 0 65535 0 0 0 65535\n"); + + QTest::newRow("PPM plain 16bit lim.") << true << QByteArray("P3 3 2 5000 " + " 5000 5000 5000 0 0 0 2500 2500 2500 " + " 5000 0 0 0 5000 0 0 0 5000\n"); + + QTest::newRow("PPM raw 8bit full") << true << QByteArray("P6 3 2 255 " + "\xff\xff\xff\x00\x00\x00\x7f\x7f\x7f" + "\xff\x00\x00\x00\xff\x00\x00\x00\xff", 13 + 6 * 3); + + QTest::newRow("PPM raw 8bit lim.") << true << QByteArray("P6 3 2 50 " + "\x32\x32\x32\x00\x00\x00\x19\x19\x19" + "\x32\x00\x00\x00\x32\x00\x00\x00\x32", 13 + 6 * 3); + + QTest::newRow("PPM raw 16bit full") << true << QByteArray("P6 3 2 65535 " + "\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x7f\xff\x7f\xff\x7f\xff" + "\xff\xff\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00\x00\x00\x00\x00\xff\xff", 13 + 6 * 3 * 2); + + QTest::newRow("PPM raw 16bit lim.") << true << QByteArray("P6 3 2 5000 " + "\x13\x88\x13\x88\x13\x88\x00\x00\x00\x00\x00\x00\x09\xc4\x09\xc4\x09\xc4" + "\x13\x88\x00\x00\x00\x00\x00\x00\x13\x88\x00\x00\x00\x00\x00\x00\x13\x88", 13 + 6 * 3 * 2); +} + +void tst_QImageReader::ppmMaxval() +{ + SKIP_IF_UNSUPPORTED("ppm"); + + QFETCH(bool, hasColor); + QFETCH(QByteArray, bytes); + + QImage img; + img.loadFromData(bytes); + QVERIFY(!img.isNull()); + QCOMPARE(img.width(), 3); + QCOMPARE(img.height(), hasColor ? 2 : 1); + + QCOMPARE(img.pixel(0,0), qRgb(0xff, 0xff, 0xff)); + QCOMPARE(img.pixel(1,0), qRgb(0, 0, 0)); + QRgb gray = img.pixel(2,0); + QVERIFY(qIsGray(gray)); + QVERIFY(qRed(gray) > 0x70 && qRed(gray) < 0x90 ); + + if (hasColor) { + QCOMPARE(img.pixel(0,1), qRgb(0xff, 0, 0)); + QCOMPARE(img.pixel(1,1), qRgb(0, 0xff, 0)); + QCOMPARE(img.pixel(2,1), qRgb(0, 0, 0xff)); + } +} + class Server : public QObject { Q_OBJECT diff --git a/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp b/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp index 191aabdf6a..d5c624833c 100644 --- a/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp +++ b/tests/auto/gui/image/qimagewriter/tst_qimagewriter.cpp @@ -47,7 +47,7 @@ #include <algorithm> typedef QMap<QString, QString> QStringMap; -typedef QList<int> QIntList; +typedef QVector<int> QIntList; Q_DECLARE_METATYPE(QImageWriter::ImageWriterError) Q_DECLARE_METATYPE(QImage::Format) @@ -227,8 +227,15 @@ void tst_QImageWriter::writeImage2_data() QTest::addColumn<QByteArray>("format"); QTest::addColumn<QImage>("image"); - const QStringList formats = QStringList() << "bmp" << "xpm" << "png" - << "ppm" << "ico"; //<< "jpeg"; + static const QLatin1String formats[] = { + QLatin1String("bmp"), + QLatin1String("xpm"), + QLatin1String("png"), + QLatin1String("ppm"), + QLatin1String("ico"), + // QLatin1String("jpeg"), + }; + QImage image0(70, 70, QImage::Format_ARGB32); image0.fill(QColor(Qt::red).rgb()); @@ -236,11 +243,11 @@ void tst_QImageWriter::writeImage2_data() while (imgFormat != QImage::NImageFormats) { QImage image = image0.convertToFormat(imgFormat); initializePadding(&image); - foreach (const QString format, formats) { + for (QLatin1String format : formats) { const QString fileName = QLatin1String("solidcolor_") + QString::number(imgFormat) + QLatin1Char('.') + format; QTest::newRow(fileName.toLatin1()) << writePrefix + fileName - << format.toLatin1() + << QByteArray(format.data(), format.size()) << image; } imgFormat = QImage::Format(int(imgFormat) + 1); @@ -304,41 +311,38 @@ void tst_QImageWriter::writeImage2() QVERIFY(QFile::remove(fileName)); } +namespace { +// C++98-library version of C++11 std::is_sorted +template <typename C> +bool is_sorted(const C &c) +{ + return std::adjacent_find(c.begin(), c.end(), std::greater_equal<typename C::value_type>()) == c.end(); +} +} + void tst_QImageWriter::supportedFormats() { QList<QByteArray> formats = QImageWriter::supportedImageFormats(); - QList<QByteArray> sortedFormats = formats; - std::sort(sortedFormats.begin(), sortedFormats.end()); // check that the list is sorted - QCOMPARE(formats, sortedFormats); - - QSet<QByteArray> formatSet; - foreach (QByteArray format, formats) - formatSet << format; + QVERIFY(is_sorted(formats)); // check that the list does not contain duplicates - QCOMPARE(formatSet.size(), formats.size()); + QVERIFY(std::unique(formats.begin(), formats.end()) == formats.end()); } void tst_QImageWriter::supportedMimeTypes() { QList<QByteArray> mimeTypes = QImageWriter::supportedMimeTypes(); - QList<QByteArray> sortedMimeTypes = mimeTypes; - std::sort(sortedMimeTypes.begin(), sortedMimeTypes.end()); // check that the list is sorted - QCOMPARE(mimeTypes, sortedMimeTypes); - - QSet<QByteArray> mimeTypeSet; - foreach (QByteArray mimeType, mimeTypes) - mimeTypeSet << mimeType; + QVERIFY(is_sorted(mimeTypes)); // check the list as a minimum contains image/bmp - QVERIFY(mimeTypeSet.contains("image/bmp")); + QVERIFY(mimeTypes.contains("image/bmp")); // check that the list does not contain duplicates - QCOMPARE(mimeTypeSet.size(), mimeTypes.size()); + QVERIFY(std::unique(mimeTypes.begin(), mimeTypes.end()) == mimeTypes.end()); } void tst_QImageWriter::writeToInvalidDevice() @@ -412,30 +416,27 @@ void tst_QImageWriter::supportsOption() QFETCH(QString, fileName); QFETCH(QIntList, options); - QSet<QImageIOHandler::ImageOption> allOptions; - allOptions << QImageIOHandler::Size - << QImageIOHandler::ClipRect - << QImageIOHandler::Description - << QImageIOHandler::ScaledClipRect - << QImageIOHandler::ScaledSize - << QImageIOHandler::CompressionRatio - << QImageIOHandler::Gamma - << QImageIOHandler::Quality - << QImageIOHandler::Name - << QImageIOHandler::SubType - << QImageIOHandler::IncrementalReading - << QImageIOHandler::Endianness - << QImageIOHandler::Animation - << QImageIOHandler::BackgroundColor; + static Q_CONSTEXPR QImageIOHandler::ImageOption allOptions[] = { + QImageIOHandler::Size, + QImageIOHandler::ClipRect, + QImageIOHandler::Description, + QImageIOHandler::ScaledClipRect, + QImageIOHandler::ScaledSize, + QImageIOHandler::CompressionRatio, + QImageIOHandler::Gamma, + QImageIOHandler::Quality, + QImageIOHandler::Name, + QImageIOHandler::SubType, + QImageIOHandler::IncrementalReading, + QImageIOHandler::Endianness, + QImageIOHandler::Animation, + QImageIOHandler::BackgroundColor, + }; QImageWriter writer(writePrefix + fileName); - for (int i = 0; i < options.size(); ++i) { - QVERIFY(writer.supportsOption(QImageIOHandler::ImageOption(options.at(i)))); - allOptions.remove(QImageIOHandler::ImageOption(options.at(i))); + for (auto option : allOptions) { + QCOMPARE(writer.supportsOption(option), options.contains(option)); } - - foreach (QImageIOHandler::ImageOption option, allOptions) - QVERIFY(!writer.supportsOption(option)); } void tst_QImageWriter::saveWithNoFormat_data() diff --git a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp index ad7de09c48..e3bda6c2df 100644 --- a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp +++ b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp @@ -99,6 +99,7 @@ private slots: void task_51271(); void convertFromImageNoDetach(); + void convertFromImageNoDetach2(); void convertFromImageDetach(); void convertFromImageCacheKey(); @@ -118,6 +119,7 @@ private slots: void refUnref(); void copy(); + void deepCopyPreservesDpr(); void depthOfNullObjects(); void transformed(); @@ -766,6 +768,33 @@ void tst_QPixmap::convertFromImageNoDetach() QCOMPARE(constOrig.bits(), constCopy.bits()); } +void tst_QPixmap::convertFromImageNoDetach2() +{ + QPixmap randomPixmap(10, 10); + if (randomPixmap.handle()->classId() != QPlatformPixmap::RasterClass) + QSKIP("Test only valid for raster pixmaps"); + + //first get the screen format + QImage::Format screenFormat = randomPixmap.toImage().format(); + QVERIFY(screenFormat != QImage::Format_Invalid); + if (screenFormat != QImage::Format_RGB32 && + screenFormat != QImage::Format_ARGB32_Premultiplied) + QSKIP("Test only valid for platforms with RGB32 pixmaps"); + + QImage orig(100,100, QImage::Format_ARGB32_Premultiplied); + orig.fill(Qt::white); + + const uchar *origBits = orig.constBits(); + + QPixmap pix = QPixmap::fromImage(std::move(orig)); + QImage copy = pix.toImage(); + + QVERIFY(!copy.hasAlphaChannel()); + QCOMPARE(copy.format(), QImage::Format_RGB32); + + QCOMPARE(origBits, copy.constBits()); +} + void tst_QPixmap::convertFromImageDetach() { QImage img(10,10, QImage::Format_RGB32); @@ -1105,6 +1134,19 @@ void tst_QPixmap::copy() QCOMPARE(trans, transCopy); } +// QTBUG-58653: Force a deep copy of a pixmap by +// having a QPainter and check whether DevicePixelRatio is preserved +void tst_QPixmap::deepCopyPreservesDpr() +{ + const qreal dpr = 2; + QPixmap src(32, 32); + src.setDevicePixelRatio(dpr); + src.fill(Qt::red); + QPainter painter(&src); + const QPixmap dest = src.copy(); + QCOMPARE(dest.devicePixelRatio(), dpr); +} + void tst_QPixmap::depthOfNullObjects() { QBitmap b1; diff --git a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp index f8bcb14ab3..a935258fb8 100644 --- a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp +++ b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp @@ -70,6 +70,8 @@ private slots: void palette(); void modalWindow(); void quitOnLastWindowClosed(); + void quitOnLastWindowClosedMulti(); + void dontQuitOnLastWindowClosed(); void genericPluginsAndWindowSystemEvents(); void layoutDirection(); void globalShareContext(); @@ -791,107 +793,111 @@ void tst_QGuiApplication::modalWindow() void tst_QGuiApplication::quitOnLastWindowClosed() { - { - int argc = 0; - QGuiApplication app(argc, 0); - const QRect screenGeometry = QGuiApplication::primaryScreen()->availableVirtualGeometry(); + int argc = 0; + QGuiApplication app(argc, 0); + const QRect screenGeometry = QGuiApplication::primaryScreen()->availableVirtualGeometry(); - QTimer timer; - timer.setInterval(100); + QTimer timer; + timer.setInterval(100); - QSignalSpy spy(&app, SIGNAL(aboutToQuit())); - QSignalSpy spy2(&timer, SIGNAL(timeout())); + QSignalSpy spyAboutToQuit(&app, &QCoreApplication::aboutToQuit); + QSignalSpy spyTimeout(&timer, &QTimer::timeout); - QWindow mainWindow; - mainWindow.setTitle(QStringLiteral("quitOnLastWindowClosedMainWindow")); - mainWindow.resize(windowSize, windowSize); - mainWindow.setFramePosition(QPoint(screenGeometry.left() + spacing, screenGeometry.top() + spacing)); + QWindow mainWindow; + mainWindow.setTitle(QStringLiteral("quitOnLastWindowClosedMainWindow")); + mainWindow.resize(windowSize, windowSize); + mainWindow.setFramePosition(QPoint(screenGeometry.left() + spacing, screenGeometry.top() + spacing)); - QWindow dialog; - dialog.setTransientParent(&mainWindow); - dialog.setTitle(QStringLiteral("quitOnLastWindowClosedDialog")); - dialog.resize(windowSize, windowSize); - dialog.setFramePosition(QPoint(screenGeometry.left() + 2 * spacing + windowSize, screenGeometry.top() + spacing)); + QWindow dialog; + dialog.setTransientParent(&mainWindow); + dialog.setTitle(QStringLiteral("quitOnLastWindowClosedDialog")); + dialog.resize(windowSize, windowSize); + dialog.setFramePosition(QPoint(screenGeometry.left() + 2 * spacing + windowSize, screenGeometry.top() + spacing)); - QVERIFY(app.quitOnLastWindowClosed()); + QVERIFY(app.quitOnLastWindowClosed()); - mainWindow.show(); - dialog.show(); - QVERIFY(QTest::qWaitForWindowExposed(&dialog)); + mainWindow.show(); + dialog.show(); + QVERIFY(QTest::qWaitForWindowExposed(&dialog)); - timer.start(); - QTimer::singleShot(1000, &mainWindow, SLOT(close())); // This should quit the application - QTimer::singleShot(2000, &app, SLOT(quit())); // This makes sure we quit even if it didn't + timer.start(); + QTimer::singleShot(1000, &mainWindow, &QWindow::close); // This should quit the application + QTimer::singleShot(2000, &app, QCoreApplication::quit); // This makes sure we quit even if it didn't - app.exec(); + app.exec(); - QCOMPARE(spy.count(), 1); - QVERIFY(spy2.count() < 15); // Should be around 10 if closing caused the quit - } - { - int argc = 0; - QGuiApplication app(argc, 0); - const QRect screenGeometry = QGuiApplication::primaryScreen()->availableVirtualGeometry(); + QCOMPARE(spyAboutToQuit.count(), 1); + // Should be around 10 if closing caused the quit + QVERIFY2(spyTimeout.count() < 15, QByteArray::number(spyTimeout.count()).constData()); +} - QTimer timer; - timer.setInterval(100); +void tst_QGuiApplication::quitOnLastWindowClosedMulti() +{ + int argc = 0; + QGuiApplication app(argc, 0); + const QRect screenGeometry = QGuiApplication::primaryScreen()->availableVirtualGeometry(); - QSignalSpy spy(&app, SIGNAL(aboutToQuit())); - QSignalSpy spy2(&timer, SIGNAL(timeout())); + QTimer timer; + timer.setInterval(100); - QWindow mainWindow; - mainWindow.setTitle(QStringLiteral("quitOnLastWindowClosedMainWindow")); - mainWindow.resize(windowSize, windowSize); - mainWindow.setFramePosition(QPoint(screenGeometry.left() + spacing, screenGeometry.top() + spacing)); + QSignalSpy spyAboutToQuit(&app, &QCoreApplication::aboutToQuit); + QSignalSpy spyTimeout(&timer, &QTimer::timeout); - QWindow dialog; - dialog.setTitle(QStringLiteral("quitOnLastWindowClosedDialog")); - dialog.resize(windowSize, windowSize); - dialog.setFramePosition(QPoint(screenGeometry.left() + 2 * spacing + windowSize, screenGeometry.top() + spacing)); + QWindow mainWindow; + mainWindow.setTitle(QStringLiteral("quitOnLastWindowClosedMultiMainWindow")); + mainWindow.resize(windowSize, windowSize); + mainWindow.setFramePosition(QPoint(screenGeometry.left() + spacing, screenGeometry.top() + spacing)); - QVERIFY(!dialog.transientParent()); - QVERIFY(app.quitOnLastWindowClosed()); + QWindow dialog; + dialog.setTitle(QStringLiteral("quitOnLastWindowClosedMultiDialog")); + dialog.resize(windowSize, windowSize); + dialog.setFramePosition(QPoint(screenGeometry.left() + 2 * spacing + windowSize, screenGeometry.top() + spacing)); - mainWindow.show(); - dialog.show(); - QVERIFY(QTest::qWaitForWindowExposed(&dialog)); + QVERIFY(!dialog.transientParent()); + QVERIFY(app.quitOnLastWindowClosed()); - timer.start(); - QTimer::singleShot(1000, &mainWindow, SLOT(close())); // This should not quit the application - QTimer::singleShot(2000, &app, SLOT(quit())); + mainWindow.show(); + dialog.show(); + QVERIFY(QTest::qWaitForWindowExposed(&dialog)); - app.exec(); + timer.start(); + QTimer::singleShot(1000, &mainWindow, &QWindow::close); // This should not quit the application + QTimer::singleShot(2000, &app, &QCoreApplication::quit); - QCOMPARE(spy.count(), 1); - QVERIFY(spy2.count() > 15); // Should be around 20 if closing did not cause the quit - } - { - int argc = 0; - QGuiApplication app(argc, 0); - app.setQuitOnLastWindowClosed(false); + app.exec(); + + QCOMPARE(spyAboutToQuit.count(), 1); + // Should be around 20 if closing did not cause the quit + QVERIFY2(spyTimeout.count() > 15, QByteArray::number(spyTimeout.count()).constData()); +} + +void tst_QGuiApplication::dontQuitOnLastWindowClosed() +{ + int argc = 0; + QGuiApplication app(argc, 0); + app.setQuitOnLastWindowClosed(false); - QTimer timer; - timer.setInterval(2000); - timer.setSingleShot(true); - QObject::connect(&timer, SIGNAL(timeout()), &app, SLOT(quit())); + QTimer timer; + timer.setInterval(2000); + timer.setSingleShot(true); + QObject::connect(&timer, &QTimer::timeout, &app, &QCoreApplication::quit); - QSignalSpy spy(&app, SIGNAL(lastWindowClosed())); - QSignalSpy spy2(&timer, SIGNAL(timeout())); + QSignalSpy spyLastWindowClosed(&app, &QGuiApplication::lastWindowClosed); + QSignalSpy spyTimeout(&timer, &QTimer::timeout); - QPointer<QWindow> mainWindow = new QWindow; + QScopedPointer<QWindow> mainWindow(new QWindow); - mainWindow->show(); + mainWindow->show(); - QTimer::singleShot(1000, mainWindow, SLOT(close())); // This should not quit the application - timer.start(); + QTimer::singleShot(1000, mainWindow.data(), &QWindow::close); // This should not quit the application + timer.start(); - app.exec(); + app.exec(); - QCOMPARE(spy2.count(), 1); // quit timer fired - QCOMPARE(spy.count(), 1); // lastWindowClosed emitted + app.setQuitOnLastWindowClosed(true); // restore underlying static to default value - app.setQuitOnLastWindowClosed(true); // restore underlying static to default value - } + QCOMPARE(spyTimeout.count(), 1); // quit timer fired + QCOMPARE(spyLastWindowClosed.count(), 1); // lastWindowClosed emitted } static Qt::ScreenOrientation testOrientationToSend = Qt::PrimaryOrientation; diff --git a/tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp b/tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp index 811a6d111f..bad021c3b0 100644 --- a/tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp +++ b/tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp @@ -1,31 +1,26 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** 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$ ** diff --git a/tests/auto/gui/kernel/qopenglwindow/tst_qopenglwindow.cpp b/tests/auto/gui/kernel/qopenglwindow/tst_qopenglwindow.cpp index b130210447..58dee6f6ca 100644 --- a/tests/auto/gui/kernel/qopenglwindow/tst_qopenglwindow.cpp +++ b/tests/auto/gui/kernel/qopenglwindow/tst_qopenglwindow.cpp @@ -31,12 +31,15 @@ #include <QtGui/QOpenGLFunctions> #include <QtGui/QOpenGLContext> #include <QtGui/QPainter> +#include <private/qguiapplication_p.h> +#include <qpa/qplatformintegration.h> class tst_QOpenGLWindow : public QObject { Q_OBJECT private slots: + void initTestCase(); void create(); void basic(); void painter(); @@ -45,6 +48,12 @@ private slots: void underOver(); }; +void tst_QOpenGLWindow::initTestCase() +{ + if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL)) + QSKIP("OpenGL is not supported on this platform."); +} + void tst_QOpenGLWindow::create() { QOpenGLWindow w; diff --git a/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp b/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp index 364b9332af..ec143896ab 100644 --- a/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp +++ b/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp @@ -36,6 +36,7 @@ #include <qpa/qwindowsysteminterface.h> #include <qpa/qwindowsysteminterface_p.h> #include <private/qhighdpiscaling_p.h> +#include <private/qtouchdevice_p.h> class tst_QTouchEventWidget : public QWidget { @@ -200,6 +201,7 @@ private slots: void touchBeginPropagatesWhenIgnored(); void touchUpdateAndEndNeverPropagate(); void basicRawEventTranslation(); + void basicRawEventTranslationOfIds(); void multiPointRawEventTranslationOnTouchScreen(); void multiPointRawEventTranslationOnTouchPad(); void deleteInEventHandler(); @@ -641,7 +643,8 @@ void tst_QTouchEvent::basicRawEventTranslation() QCOMPARE(touchWidget.touchBeginPoints.count(), 1); QCOMPARE(touchWidget.timestamp, timestamp); QTouchEvent::TouchPoint touchBeginPoint = touchWidget.touchBeginPoints.first(); - QCOMPARE(touchBeginPoint.id(), rawTouchPoint.id()); + const int touchPointId = (QTouchDevicePrivate::get(touchScreenDevice)->id << 24) + 1; + QCOMPARE(touchBeginPoint.id(), touchPointId); QCOMPARE(touchBeginPoint.state(), rawTouchPoint.state()); QCOMPARE(touchBeginPoint.pos(), pos); QCOMPARE(touchBeginPoint.startPos(), pos); @@ -676,7 +679,7 @@ void tst_QTouchEvent::basicRawEventTranslation() QVERIFY(!touchWidget.seenTouchEnd); QCOMPARE(touchWidget.touchUpdatePoints.count(), 1); QTouchEvent::TouchPoint touchUpdatePoint = touchWidget.touchUpdatePoints.first(); - QCOMPARE(touchUpdatePoint.id(), rawTouchPoint.id()); + QCOMPARE(touchUpdatePoint.id(), touchPointId); QCOMPARE(touchUpdatePoint.state(), rawTouchPoint.state()); QCOMPARE(touchUpdatePoint.pos(), pos + delta); QCOMPARE(touchUpdatePoint.startPos(), pos); @@ -708,7 +711,7 @@ void tst_QTouchEvent::basicRawEventTranslation() QVERIFY(touchWidget.seenTouchEnd); QCOMPARE(touchWidget.touchEndPoints.count(), 1); QTouchEvent::TouchPoint touchEndPoint = touchWidget.touchEndPoints.first(); - QCOMPARE(touchEndPoint.id(), rawTouchPoint.id()); + QCOMPARE(touchEndPoint.id(), touchPointId); QCOMPARE(touchEndPoint.state(), rawTouchPoint.state()); QCOMPARE(touchEndPoint.pos(), pos + delta + delta); QCOMPARE(touchEndPoint.startPos(), pos); @@ -784,9 +787,11 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen() QVERIFY(!rightWidget.seenTouchEnd); QCOMPARE(leftWidget.touchBeginPoints.count(), 1); QCOMPARE(rightWidget.touchBeginPoints.count(), 1); + const int touchPointId0 = (QTouchDevicePrivate::get(touchScreenDevice)->id << 24) + 1; + const int touchPointId1 = touchPointId0 + 1; { QTouchEvent::TouchPoint leftTouchPoint = leftWidget.touchBeginPoints.first(); - QCOMPARE(leftTouchPoint.id(), rawTouchPoints[0].id()); + QCOMPARE(leftTouchPoint.id(), touchPointId0); QCOMPARE(leftTouchPoint.state(), rawTouchPoints[0].state()); QCOMPARE(leftTouchPoint.pos(), leftPos); QCOMPARE(leftTouchPoint.startPos(), leftPos); @@ -806,7 +811,7 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen() QCOMPARE(leftTouchPoint.pressure(), qreal(1.)); QTouchEvent::TouchPoint rightTouchPoint = rightWidget.touchBeginPoints.first(); - QCOMPARE(rightTouchPoint.id(), rawTouchPoints[1].id()); + QCOMPARE(rightTouchPoint.id(), touchPointId1); QCOMPARE(rightTouchPoint.state(), rawTouchPoints[1].state()); QCOMPARE(rightTouchPoint.pos(), rightPos); QCOMPARE(rightTouchPoint.startPos(), rightPos); @@ -850,7 +855,7 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen() QCOMPARE(rightWidget.touchUpdatePoints.count(), 1); { QTouchEvent::TouchPoint leftTouchPoint = leftWidget.touchUpdatePoints.first(); - QCOMPARE(leftTouchPoint.id(), rawTouchPoints[0].id()); + QCOMPARE(leftTouchPoint.id(), touchPointId0); QCOMPARE(leftTouchPoint.state(), rawTouchPoints[0].state()); QCOMPARE(leftTouchPoint.pos(), QPointF(leftWidget.mapFromParent(centerPos.toPoint()))); QCOMPARE(leftTouchPoint.startPos(), leftPos); @@ -870,7 +875,7 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen() QCOMPARE(leftTouchPoint.pressure(), qreal(1.)); QTouchEvent::TouchPoint rightTouchPoint = rightWidget.touchUpdatePoints.first(); - QCOMPARE(rightTouchPoint.id(), rawTouchPoints[1].id()); + QCOMPARE(rightTouchPoint.id(), touchPointId1); QCOMPARE(rightTouchPoint.state(), rawTouchPoints[1].state()); QCOMPARE(rightTouchPoint.pos(), QPointF(rightWidget.mapFromParent(centerPos.toPoint()))); QCOMPARE(rightTouchPoint.startPos(), rightPos); @@ -914,7 +919,7 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen() QCOMPARE(rightWidget.touchEndPoints.count(), 1); { QTouchEvent::TouchPoint leftTouchPoint = leftWidget.touchEndPoints.first(); - QCOMPARE(leftTouchPoint.id(), rawTouchPoints[0].id()); + QCOMPARE(leftTouchPoint.id(), touchPointId0); QCOMPARE(leftTouchPoint.state(), rawTouchPoints[0].state()); QCOMPARE(leftTouchPoint.pos(), QPointF(leftWidget.mapFromParent(centerPos.toPoint()))); QCOMPARE(leftTouchPoint.startPos(), leftPos); @@ -934,7 +939,7 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen() QCOMPARE(leftTouchPoint.pressure(), qreal(0.)); QTouchEvent::TouchPoint rightTouchPoint = rightWidget.touchEndPoints.first(); - QCOMPARE(rightTouchPoint.id(), rawTouchPoints[1].id()); + QCOMPARE(rightTouchPoint.id(), touchPointId1); QCOMPARE(rightTouchPoint.state(), rawTouchPoints[1].state()); QCOMPARE(rightTouchPoint.pos(), QPointF(rightWidget.mapFromParent(centerPos.toPoint()))); QCOMPARE(rightTouchPoint.startPos(), rightPos); @@ -1184,6 +1189,126 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad() } } +void tst_QTouchEvent::basicRawEventTranslationOfIds() +{ + if (!QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive)) + QSKIP("Wayland: This fails. Figure out why."); + + tst_QTouchEventWidget touchWidget; + touchWidget.setWindowTitle(QTest::currentTestFunction()); + touchWidget.setAttribute(Qt::WA_AcceptTouchEvents); + touchWidget.setGeometry(100, 100, 400, 300); + touchWidget.show(); + QVERIFY(QTest::qWaitForWindowActive(&touchWidget)); + + QVarLengthArray<QPointF, 2> pos; + QVarLengthArray<QPointF, 2> screenPos; + for (int i = 0; i < 2; ++i) { + pos << touchWidget.rect().center() + QPointF(20*i, 20*i); + screenPos << touchWidget.mapToGlobal(pos[i].toPoint()); + } + QPointF delta(10, 10); + QRectF screenGeometry = QApplication::desktop()->screenGeometry(&touchWidget); + + QVector<QPointF> rawPosList; + rawPosList << QPointF(12, 34) << QPointF(56, 78); + + QList<QTouchEvent::TouchPoint> rawTouchPoints; + + // Press both points, this should be translated to a TouchBegin + for (int i = 0; i < 2; ++i) { + QTouchEvent::TouchPoint rawTouchPoint; + rawTouchPoint.setId(i); + rawTouchPoint.setState(Qt::TouchPointPressed); + rawTouchPoint.setScreenPos(screenPos[i]); + rawTouchPoint.setNormalizedPos(normalized(rawTouchPoint.pos(), screenGeometry)); + rawTouchPoint.setRawScreenPositions(rawPosList); + rawTouchPoints << rawTouchPoint; + } + QTouchEvent::TouchPoint &p0 = rawTouchPoints[0]; + QTouchEvent::TouchPoint &p1 = rawTouchPoints[1]; + + const ulong timestamp = 1234; + QWindow *window = touchWidget.windowHandle(); + QList<QWindowSystemInterface::TouchPoint> nativeTouchPoints = + QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window); + QWindowSystemInterface::handleTouchEvent(window, timestamp, touchScreenDevice, nativeTouchPoints); + QCoreApplication::processEvents(); + QVERIFY(touchWidget.seenTouchBegin); + QVERIFY(!touchWidget.seenTouchUpdate); + QVERIFY(!touchWidget.seenTouchEnd); + QCOMPARE(touchWidget.touchBeginPoints.count(), 2); + + const int initialTouchPointId = (QTouchDevicePrivate::get(touchScreenDevice)->id << 24) + 1; + + for (int i = 0; i < touchWidget.touchBeginPoints.count(); ++i) { + QTouchEvent::TouchPoint touchBeginPoint = touchWidget.touchBeginPoints.at(i); + QCOMPARE(touchBeginPoint.id(), initialTouchPointId + i); + QCOMPARE(touchBeginPoint.state(), rawTouchPoints[i].state()); + } + + // moving the point should translate to TouchUpdate + for (int i = 0; i < rawTouchPoints.count(); ++i) { + QTouchEvent::TouchPoint &p = rawTouchPoints[i]; + p.setState(Qt::TouchPointMoved); + p.setScreenPos(p.screenPos() + delta); + p.setNormalizedPos(normalized(p.pos(), screenGeometry)); + } + nativeTouchPoints = + QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window); + QWindowSystemInterface::handleTouchEvent(window, 0, touchScreenDevice, nativeTouchPoints); + QCoreApplication::processEvents(); + QVERIFY(touchWidget.seenTouchBegin); + QVERIFY(touchWidget.seenTouchUpdate); + QVERIFY(!touchWidget.seenTouchEnd); + QCOMPARE(touchWidget.touchUpdatePoints.count(), 2); + QCOMPARE(touchWidget.touchUpdatePoints.at(0).id(), initialTouchPointId); + QCOMPARE(touchWidget.touchUpdatePoints.at(1).id(), initialTouchPointId + 1); + + // release last point + p0.setState(Qt::TouchPointStationary); + p1.setState(Qt::TouchPointReleased); + + nativeTouchPoints = + QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window); + QWindowSystemInterface::handleTouchEvent(window, 0, touchScreenDevice, nativeTouchPoints); + QCoreApplication::processEvents(); + QVERIFY(touchWidget.seenTouchBegin); + QVERIFY(touchWidget.seenTouchUpdate); + QVERIFY(!touchWidget.seenTouchEnd); + QCOMPARE(touchWidget.touchUpdatePoints.count(), 2); + QCOMPARE(touchWidget.touchUpdatePoints[0].id(), initialTouchPointId); + QCOMPARE(touchWidget.touchUpdatePoints[1].id(), initialTouchPointId + 1); + + // Press last point again, id should increase + p1.setState(Qt::TouchPointPressed); + p1.setId(42); // new id + nativeTouchPoints = + QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window); + QWindowSystemInterface::handleTouchEvent(window, 0, touchScreenDevice, nativeTouchPoints); + QCoreApplication::processEvents(); + QVERIFY(touchWidget.seenTouchBegin); + QVERIFY(touchWidget.seenTouchUpdate); + QVERIFY(!touchWidget.seenTouchEnd); + QCOMPARE(touchWidget.touchUpdatePoints.count(), 2); + QCOMPARE(touchWidget.touchUpdatePoints[0].id(), initialTouchPointId); + QCOMPARE(touchWidget.touchUpdatePoints[1].id(), initialTouchPointId + 2); + + // release everything + p0.setState(Qt::TouchPointReleased); + p1.setState(Qt::TouchPointReleased); + nativeTouchPoints = + QWindowSystemInterfacePrivate::toNativeTouchPoints(rawTouchPoints, window); + QWindowSystemInterface::handleTouchEvent(window, 0, touchScreenDevice, nativeTouchPoints); + QCoreApplication::processEvents(); + QVERIFY(touchWidget.seenTouchBegin); + QVERIFY(touchWidget.seenTouchUpdate); + QVERIFY(touchWidget.seenTouchEnd); + QCOMPARE(touchWidget.touchUpdatePoints.count(), 2); + QCOMPARE(touchWidget.touchUpdatePoints[0].id(), initialTouchPointId); + QCOMPARE(touchWidget.touchUpdatePoints[1].id(), initialTouchPointId + 2); +} + void tst_QTouchEvent::deleteInEventHandler() { if (!QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive)) diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index 6ec0268d96..36ec28de8d 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -56,6 +56,7 @@ private slots: void create(); void setParent(); void setVisible(); + void setVisibleFalseDoesNotCreateWindow(); void eventOrderOnShow(); void resizeEventAfterResize(); void exposeEventOnShrink_QTBUG54040(); @@ -65,6 +66,7 @@ private slots: void positioningDuringMinimized(); void childWindowPositioning_data(); void childWindowPositioning(); + void childWindowLevel(); void platformSurface(); void isExposed(); void isActive(); @@ -101,6 +103,7 @@ private slots: void initTestCase(); void stateChange_data(); void stateChange(); + void flags(); void cleanup(); private: @@ -232,6 +235,16 @@ void tst_QWindow::setVisible() QVERIFY(QTest::qWaitForWindowExposed(&i)); } +void tst_QWindow::setVisibleFalseDoesNotCreateWindow() +{ + QWindow w; + QVERIFY(!w.handle()); + w.setVisible(false); + QVERIFY2(!w.handle(), "Hiding a non-created window doesn't create it"); + w.setVisible(true); + QVERIFY2(w.handle(), "Showing a non-created window creates it"); +} + void tst_QWindow::mapGlobal() { QWindow a; @@ -596,6 +609,29 @@ void tst_QWindow::childWindowPositioning() QCOMPARE(childWindowAfter.framePosition(), topLeftOrigin); } +void tst_QWindow::childWindowLevel() +{ + ColoredWindow topLevel(Qt::green); + topLevel.setObjectName("topLevel"); + ColoredWindow yellowChild(Qt::yellow, &topLevel); + yellowChild.setObjectName("yellowChild"); + ColoredWindow redChild(Qt::red, &topLevel); + redChild.setObjectName("redChild"); + ColoredWindow blueChild(Qt::blue, &topLevel); + blueChild.setObjectName("blueChild"); + + const QObjectList &siblings = topLevel.children(); + + QCOMPARE(siblings.constFirst(), &yellowChild); + QCOMPARE(siblings.constLast(), &blueChild); + + yellowChild.raise(); + QCOMPARE(siblings.constLast(), &yellowChild); + + blueChild.lower(); + QCOMPARE(siblings.constFirst(), &blueChild); +} + // QTBUG-49709: Verify that the normal geometry is correctly restored // when executing a sequence of window state changes. So far, Windows // only where state changes have immediate effect. @@ -2170,6 +2206,18 @@ void tst_QWindow::requestUpdate() QTRY_COMPARE(window.received(QEvent::UpdateRequest), 2); } +void tst_QWindow::flags() +{ + Window window; + const auto baseFlags = window.flags(); + window.setFlags(window.flags() | Qt::FramelessWindowHint); + QCOMPARE(window.flags(), baseFlags | Qt::FramelessWindowHint); + window.setFlag(Qt::WindowStaysOnTopHint, true); + QCOMPARE(window.flags(), baseFlags | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint); + window.setFlag(Qt::FramelessWindowHint, false); + QCOMPARE(window.flags(), baseFlags | Qt::WindowStaysOnTopHint); +} + #include <tst_qwindow.moc> QTEST_MAIN(tst_QWindow) diff --git a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp index 9dd9ab05e8..1ce7e797fc 100644 --- a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp +++ b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp @@ -33,6 +33,7 @@ #include <qcolor.h> #include <qdebug.h> +#include <private/qcolorprofile_p.h> #include <private/qdrawingprimitive_sse2_p.h> #include <qrgba64.h> @@ -107,6 +108,9 @@ private slots: void qrgba64Premultiply(); void qrgba64Equivalence(); + void qcolorprofile_data(); + void qcolorprofile(); + #if 0 // Used to be included in Qt4 for Q_WS_X11 void setallowX11ColorNames(); #endif @@ -1587,5 +1591,36 @@ void tst_QColor::qrgba64Equivalence() } } +void tst_QColor::qcolorprofile_data() +{ + QTest::addColumn<qreal>("gammaC"); + QTest::addColumn<int>("tolerance"); + + QTest::newRow("gamma=1.0") << qreal(1.0) << 0; + QTest::newRow("gamma=1.5") << qreal(1.5) << 1; + QTest::newRow("gamma=1.7") << qreal(1.7) << 2; + QTest::newRow("gamma=2.0") << qreal(2.0) << 8; + QTest::newRow("gamma=2.31") << qreal(2.31) << 33; + QTest::newRow("SRgb") << qreal(0.0) << 7; +} + +void tst_QColor::qcolorprofile() +{ + QFETCH(qreal, gammaC); + QFETCH(int, tolerance); + QColorProfile *cp = (gammaC == 0) ? QColorProfile::fromSRgb(): QColorProfile::fromGamma(gammaC); + + // Test we are accurate for most values after converting through gamma-correction. + int error = 0; + for (uint i = 0; i < 256; i++) { + QRgb cin = qRgb(i, i, i); + QRgba64 tmp = cp->toLinear64(cin); + QRgb cout = cp->fromLinear64(tmp); + error += qAbs(qRed(cin) - qRed(cout)); + } + QVERIFY(error <= tolerance); + delete cp; +} + QTEST_MAIN(tst_QColor) #include "tst_qcolor.moc" diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp index cf4979e291..3562bc63f4 100644 --- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp +++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp @@ -4843,6 +4843,18 @@ void tst_QPainter::blendARGBonRGB_data() << QPainter::CompositionMode_SourceIn << qRgba(255, 0, 0, 127) << 127; QTest::newRow("ARGB_PM source-in RGBx8888") << QImage::Format_RGBX8888 << QImage::Format_ARGB32_Premultiplied << QPainter::CompositionMode_SourceIn << qRgba(127, 0, 0, 127) << 127; + QTest::newRow("ARGB over RGBA8888") << QImage::Format_RGBA8888 << QImage::Format_ARGB32 + << QPainter::CompositionMode_SourceOver << qRgba(255, 0, 0, 127) << 127; + QTest::newRow("ARGB_PM over RGBA8888") << QImage::Format_RGBA8888 << QImage::Format_ARGB32_Premultiplied + << QPainter::CompositionMode_SourceOver << qRgba(127, 0, 0, 127) << 127; + QTest::newRow("ARGB source RGBA8888") << QImage::Format_RGBA8888 << QImage::Format_ARGB32 + << QPainter::CompositionMode_Source << qRgba(255, 0, 0, 127) << 255; + QTest::newRow("ARGB_PM source RGBA8888") << QImage::Format_RGBA8888 << QImage::Format_ARGB32_Premultiplied + << QPainter::CompositionMode_Source << qRgba(127, 0, 0, 127) << 255; + QTest::newRow("ARGB source-in RGBA8888") << QImage::Format_RGBA8888 << QImage::Format_ARGB32 + << QPainter::CompositionMode_SourceIn << qRgba(255, 0, 0, 127) << 255; + QTest::newRow("ARGB_PM source-in RGBA8888") << QImage::Format_RGBA8888 << QImage::Format_ARGB32_Premultiplied + << QPainter::CompositionMode_SourceIn << qRgba(127, 0, 0, 127) << 255; QTest::newRow("ARGB over RGB16") << QImage::Format_RGB16 << QImage::Format_ARGB32 << QPainter::CompositionMode_SourceOver << qRgba(255, 0, 0, 127) << 123; QTest::newRow("ARGB_PM over RGB16") << QImage::Format_RGB16 << QImage::Format_ARGB32_Premultiplied @@ -4905,7 +4917,7 @@ void tst_QPainter::blendARGBonRGB() painter.drawImage(0, 0, imageArgb); painter.end(); - QCOMPARE(qRed(imageRgb.pixel(0,0)), expected_red); + QCOMPARE(imageRgb.pixelColor(0,0).red(), expected_red); } enum CosmeticStrokerPaint diff --git a/tests/auto/gui/qopengl/qopengl.pro b/tests/auto/gui/qopengl/qopengl.pro index aaef6e5125..d744d37280 100644 --- a/tests/auto/gui/qopengl/qopengl.pro +++ b/tests/auto/gui/qopengl/qopengl.pro @@ -8,4 +8,4 @@ QT += gui-private core-private testlib SOURCES += tst_qopengl.cpp -linux:qtConfig(xcb-glx):qtConfig(xcb-xlib):!qtConfig(egl): DEFINES += USE_GLX +linux:qtConfig(xcb):qtConfig(xcb-glx):qtConfig(xcb-xlib):!qtConfig(egl): DEFINES += USE_GLX diff --git a/tests/auto/gui/qopengl/tst_qopengl.cpp b/tests/auto/gui/qopengl/tst_qopengl.cpp index 4cdd8202e9..6d9456fa69 100644 --- a/tests/auto/gui/qopengl/tst_qopengl.cpp +++ b/tests/auto/gui/qopengl/tst_qopengl.cpp @@ -67,6 +67,7 @@ class tst_QOpenGL : public QObject Q_OBJECT private slots: + void initTestCase(); void sharedResourceCleanup_data(); void sharedResourceCleanup(); void multiGroupSharedResourceCleanup_data(); @@ -86,6 +87,7 @@ private slots: void fboMRT_differentFormats(); void openGLPaintDevice_data(); void openGLPaintDevice(); + void openGLPaintDeviceWithChangingContext(); void aboutToBeDestroyed(); void sizeLessWindow(); void QTBUG15621_triangulatingStrokerDivZero(); @@ -204,6 +206,12 @@ static QSurface *createSurface(int surfaceClass) return 0; } +void tst_QOpenGL::initTestCase() +{ + if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL)) + QSKIP("OpenGL is not supported on this platform."); +} + static void common_data() { QTest::addColumn<int>("surfaceClass"); @@ -949,6 +957,14 @@ void tst_QOpenGL::openGLPaintDevice_data() QTest::newRow("Using QOffscreenSurface - RGB16") << int(QSurface::Offscreen) << QImage::Format_RGB16; } +static void drawColoredRects(QPainter *p, const QSize &size) +{ + p->fillRect(0, 0, size.width() / 2, size.height() / 2, Qt::red); + p->fillRect(size.width() / 2, 0, size.width() / 2, size.height() / 2, Qt::green); + p->fillRect(size.width() / 2, size.height() / 2, size.width() / 2, size.height() / 2, Qt::blue); + p->fillRect(0, size.height() / 2, size.width() / 2, size.height() / 2, Qt::white); +} + void tst_QOpenGL::openGLPaintDevice() { #if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(__x86_64__) @@ -971,10 +987,7 @@ void tst_QOpenGL::openGLPaintDevice() QImage image(size, imageFormat); QPainter p(&image); - p.fillRect(0, 0, image.width() / 2, image.height() / 2, Qt::red); - p.fillRect(image.width() / 2, 0, image.width() / 2, image.height() / 2, Qt::green); - p.fillRect(image.width() / 2, image.height() / 2, image.width() / 2, image.height() / 2, Qt::blue); - p.fillRect(0, image.height() / 2, image.width() / 2, image.height() / 2, Qt::white); + drawColoredRects(&p, image.size()); p.end(); QOpenGLFramebufferObject fbo(size); @@ -982,10 +995,7 @@ void tst_QOpenGL::openGLPaintDevice() QOpenGLPaintDevice device(size); QVERIFY(p.begin(&device)); - p.fillRect(0, 0, image.width() / 2, image.height() / 2, Qt::red); - p.fillRect(image.width() / 2, 0, image.width() / 2, image.height() / 2, Qt::green); - p.fillRect(image.width() / 2, image.height() / 2, image.width() / 2, image.height() / 2, Qt::blue); - p.fillRect(0, image.height() / 2, image.width() / 2, image.height() / 2, Qt::white); + drawColoredRects(&p, image.size()); p.end(); QImage actual = fbo.toImage().convertToFormat(imageFormat); @@ -1011,6 +1021,59 @@ void tst_QOpenGL::openGLPaintDevice() QCOMPARE(image, actual); } +void tst_QOpenGL::openGLPaintDeviceWithChangingContext() +{ + QScopedPointer<QSurface> surface(createSurface(QSurface::Window)); + const QSize size(512, 512); + + // QOpenGLPaintDevice has a thread-local paint engine. Therefore render + // twice, with a different context and device. Under the hood it will + // still use the same paint engine! + + QOpenGLContext ctx; + QVERIFY(ctx.create()); + QVERIFY(ctx.makeCurrent(surface.data())); + + QOpenGLFramebufferObject fbo(size); + QVERIFY(fbo.bind()); + + QOpenGLPaintDevice device(size); + + QPainter p; + QVERIFY(p.begin(&device)); + drawColoredRects(&p, size); + p.end(); + + QImage img1 = fbo.toImage(); + + QOpenGLContext ctx2; + // When supported, test the special case, where the second context is + // totally incompatible due to being a core profile one. + QSurfaceFormat coreFormat; + coreFormat.setVersion(3, 2); + coreFormat.setProfile(QSurfaceFormat::CoreProfile); + ctx2.setFormat(coreFormat); + if (!ctx2.create() || !ctx2.makeCurrent(surface.data())) { + ctx2.setFormat(QSurfaceFormat()); + QVERIFY(ctx2.create()); + } + + QVERIFY(ctx2.makeCurrent(surface.data())); + + QOpenGLFramebufferObject fbo2(size); + QVERIFY(fbo2.bind()); + + QOpenGLPaintDevice device2(size); + + QVERIFY(p.begin(&device2)); + drawColoredRects(&p, size); + p.end(); + + QImage img2 = fbo2.toImage(); + + QFUZZY_COMPARE_IMAGES(img1, img2); +} + void tst_QOpenGL::aboutToBeDestroyed() { QWindow window; diff --git a/tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp b/tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp index 39f7beca6f..f8dfdbd3b0 100644 --- a/tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp +++ b/tests/auto/gui/qopenglconfig/tst_qopenglconfig.cpp @@ -100,6 +100,7 @@ class tst_QOpenGlConfig : public QObject Q_OBJECT private slots: + void initTestCase(); void testConfiguration(); void testGlConfiguration(); void testBugList(); @@ -162,6 +163,12 @@ static void dumpConfiguration(QTextStream &str) } } +void tst_QOpenGlConfig::initTestCase() +{ + if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL)) + QSKIP("OpenGL is not supported on this platform."); +} + void tst_QOpenGlConfig::testConfiguration() { QString result; diff --git a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp index e8244a0e5d..e52cb63384 100644 --- a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp +++ b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp @@ -244,8 +244,13 @@ void tst_QFontDatabase::addAppFont() QVERIFY(!newFamilies.isEmpty()); QVERIFY(newFamilies.count() >= oldFamilies.count()); - for (int i = 0; i < addedFamilies.count(); ++i) - QVERIFY(newFamilies.contains(addedFamilies.at(i))); + for (int i = 0; i < addedFamilies.count(); ++i) { + QString family = addedFamilies.at(i); + QVERIFY(newFamilies.contains(family)); + QFont qfont(family); + QFontInfo fi(qfont); + QCOMPARE(fi.family(), family); + } QVERIFY(QFontDatabase::removeApplicationFont(id)); QCOMPARE(fontDbChangedSpy.count(), 2); diff --git a/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp b/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp index 6192e3cd8d..8667caa1ef 100644 --- a/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp +++ b/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp @@ -202,36 +202,36 @@ void tst_QFontMetrics::bypassShaping() QCOMPARE(textWidth, charsWidth); } -template<class FontMetrics> void elidedMultiLength_helper() +template<class FontMetrics, typename PrimitiveType> void elidedMultiLength_helper() { QString text1 = QLatin1String("Long Text 1\x9cShorter\x9csmall"); QString text1_long = "Long Text 1"; QString text1_short = "Shorter"; QString text1_small = "small"; FontMetrics fm = FontMetrics(QFont()); - int width_long = fm.size(0, text1_long).width(); + PrimitiveType width_long = fm.size(0, text1_long).width(); QCOMPARE(fm.elidedText(text1,Qt::ElideRight, 8000), text1_long); QCOMPARE(fm.elidedText(text1,Qt::ElideRight, width_long + 1), text1_long); QCOMPARE(fm.elidedText(text1,Qt::ElideRight, width_long - 1), text1_short); - int width_short = fm.size(0, text1_short).width(); + PrimitiveType width_short = fm.size(0, text1_short).width(); QCOMPARE(fm.elidedText(text1,Qt::ElideRight, width_short + 1), text1_short); QCOMPARE(fm.elidedText(text1,Qt::ElideRight, width_short - 1), text1_small); // Not even wide enough for "small" - should use ellipsis QChar ellipsisChar(0x2026); QString text1_el = QString::fromLatin1("s") + ellipsisChar; - int width_small = fm.width(text1_el); + PrimitiveType width_small = fm.width(text1_el); QCOMPARE(fm.elidedText(text1,Qt::ElideRight, width_small + 1), text1_el); } void tst_QFontMetrics::elidedMultiLength() { - elidedMultiLength_helper<QFontMetrics>(); + elidedMultiLength_helper<QFontMetrics, int>(); } void tst_QFontMetrics::elidedMultiLengthF() { - elidedMultiLength_helper<QFontMetricsF>(); + elidedMultiLength_helper<QFontMetricsF, qreal>(); } void tst_QFontMetrics::inFontUcs4() diff --git a/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp b/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp index 7c60c8c9f8..21b2697b90 100644 --- a/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp +++ b/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp @@ -527,6 +527,7 @@ void tst_QGlyphRun::drawStruckOutText() QFont font; font.setStrikeOut(true); + font.setStyleStrategy(QFont::ForceIntegerMetrics); QTextLayout layout(s); layout.setFont(font); @@ -569,6 +570,7 @@ void tst_QGlyphRun::drawOverlinedText() QFont font; font.setOverline(true); + font.setStyleStrategy(QFont::ForceIntegerMetrics); QTextLayout layout(s); layout.setFont(font); @@ -611,6 +613,7 @@ void tst_QGlyphRun::drawUnderlinedText() QFont font; font.setUnderline(true); + font.setStyleStrategy(QFont::ForceIntegerMetrics); QTextLayout layout(s); layout.setFont(font); diff --git a/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp b/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp index 9f84f64ee9..f4e3356ad0 100644 --- a/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp +++ b/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp @@ -716,6 +716,7 @@ void tst_QStaticText::drawStruckOutText() QFont font; font.setStrikeOut(true); + font.setStyleStrategy(QFont::ForceIntegerMetrics); { QPainter p(&imageDrawText); @@ -751,6 +752,7 @@ void tst_QStaticText::drawOverlinedText() QFont font; font.setOverline(true); + font.setStyleStrategy(QFont::ForceIntegerMetrics); { QPainter p(&imageDrawText); @@ -786,6 +788,7 @@ void tst_QStaticText::drawUnderlinedText() QFont font; font.setUnderline(true); + font.setStyleStrategy(QFont::ForceIntegerMetrics); { QPainter p(&imageDrawText); diff --git a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp index de5b2a8676..764b99646b 100644 --- a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp +++ b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp @@ -134,7 +134,9 @@ private slots: void clearResources(); void setPlainText(); + void toPlainText_data(); void toPlainText(); + void toRawText(); void deleteTextObjectsOnClear(); @@ -2390,12 +2392,39 @@ void tst_QTextDocument::setPlainText() QCOMPARE(doc->toPlainText(), s); } +void tst_QTextDocument::toPlainText_data() +{ + QTest::addColumn<QString>("html"); + QTest::addColumn<QString>("expectedPlainText"); + + QTest::newRow("nbsp") << "Hello World" << "Hello World"; + QTest::newRow("empty_div") << "<div></div>hello" << "hello"; + QTest::newRow("br_and_p") << "<p>first<br></p><p>second<br></p>" << "first\n\nsecond\n"; + QTest::newRow("div") << "first<div>second<br>third</div>fourth" << "first\nsecond\nthird\nfourth"; // <div> and </div> become newlines... + QTest::newRow("br_text_end_of_div") << "<div><div>first<br>moretext</div>second<br></div>" << "first\nmoretext\nsecond\n"; // ... when there is text before <div> + QTest::newRow("br_end_of_div_like_gmail") << "<div><div><div>first<br></div>second<br></div>third<br></div>" << "first\nsecond\nthird\n"; // ... and when there is text before </div> + QTest::newRow("p_and_div") << "<div><div>first<p>second</p></div>third</div>" << "first\nsecond\nthird"; +} + void tst_QTextDocument::toPlainText() { - doc->setHtml("Hello World"); - QCOMPARE(doc->toPlainText(), QLatin1String("Hello World")); + QFETCH(QString, html); + QFETCH(QString, expectedPlainText); + + doc->setHtml(html); + QCOMPARE(doc->toPlainText(), expectedPlainText); } +void tst_QTextDocument::toRawText() +{ + doc->setHtml(" "); + + QString rawText = doc->toRawText(); + QCOMPARE(rawText.size(), 1); + QCOMPARE(rawText.at(0).unicode(), ushort(QChar::Nbsp)); +} + + void tst_QTextDocument::deleteTextObjectsOnClear() { QPointer<QTextTable> table = cursor.insertTable(2, 2); diff --git a/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp b/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp index 36907b9258..ee50b98733 100644 --- a/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp +++ b/tests/auto/gui/text/qtextscriptengine/tst_qtextscriptengine.cpp @@ -1104,7 +1104,7 @@ void tst_QTextScriptEngine::controlInSyllable_qtbug14204() const ushort *log_clusters = e->logClusters(&e->layoutData->items[0]); QCOMPARE(log_clusters[0], ushort(0)); QCOMPARE(log_clusters[1], ushort(0)); - QCOMPARE(log_clusters[2], ushort(1)); + QCOMPARE(log_clusters[2], ushort(0)); QCOMPARE(log_clusters[3], ushort(2)); } @@ -1214,6 +1214,9 @@ void tst_QTextScriptEngine::thaiWithZWJ() QFont font(QStringLiteral("Waree")); font.setStyleStrategy(QFont::NoFontMerging); + if (QFontInfo(font).styleName() != QStringLiteral("Book")) + QSKIP("couldn't find 'Waree Book' font"); + QString s(QString::fromUtf8("\xe0\xb8\xa3\xe2\x80\x8d\xe0\xb8\xa3\xe2\x80" "\x8c\x2e\xe0\xb8\xa3\x2e\xe2\x80\x9c\xe0\xb8" "\xa3\xe2\x80\xa6\xe0\xb8\xa3\xe2\x80\x9d\xe0" @@ -1233,20 +1236,22 @@ void tst_QTextScriptEngine::thaiWithZWJ() QCOMPARE(e->layoutData->items[2].num_glyphs, ushort(2)); // Thai: Thai character followed by superscript "a" which is of inherited type //A quick sanity check - check all the characters are individual clusters + // A thai implementation could either remove the ZWJ and ZWNJ characters, or hide them. + // The current implementation hides them, so we test for that. unsigned short *logClusters = e->layoutData->logClustersPtr; - for (int i = 0; i < 15; i++) + QCOMPARE(logClusters[0], ushort(0)); + QCOMPARE(logClusters[1], ushort(0)); + QCOMPARE(logClusters[2], ushort(2)); + QCOMPARE(logClusters[3], ushort(2)); + for (int i = 4; i < 15; i++) QCOMPARE(logClusters[i], ushort(i)); for (int i = 0; i < 3; i++) QCOMPARE(logClusters[i+15], ushort(0)); - // A thai implementation could either remove the ZWJ and ZWNJ characters, or hide them. - // The current implementation hides them, so we test for that. // The only characters that we should be hiding are the ZWJ and ZWNJ characters in position 1 and 3. const QGlyphLayout glyphLayout = e->layoutData->glyphLayout; for (int i = 0; i < 18; i++) { - if (i == 17) - QCOMPARE(glyphLayout.advances[i].toInt(), 0); - else if (i == 1 || i == 3) + if (i == 1 || i == 3) QCOMPARE(glyphLayout.advances[i].toInt(), 0); else QVERIFY(glyphLayout.advances[i].toInt() != 0); diff --git a/tests/auto/network/access/access.pro b/tests/auto/network/access/access.pro index 1d78cf253b..b140b5e9f2 100644 --- a/tests/auto/network/access/access.pro +++ b/tests/auto/network/access/access.pro @@ -13,11 +13,13 @@ SUBDIRS=\ qhttpnetworkreply \ qabstractnetworkcache \ hpack \ - http2 + http2 \ + hsts !qtConfig(private_tests): SUBDIRS -= \ qhttpnetworkconnection \ qhttpnetworkreply \ qftp \ hpack \ - http2 + http2 \ + hsts diff --git a/tests/auto/network/access/hsts/hsts.pro b/tests/auto/network/access/hsts/hsts.pro new file mode 100644 index 0000000000..07bdea5f62 --- /dev/null +++ b/tests/auto/network/access/hsts/hsts.pro @@ -0,0 +1,6 @@ +QT += core core-private network network-private testlib +CONFIG += testcase parallel_test c++11 +TEMPLATE = app +TARGET = tst_qhsts + +SOURCES += tst_qhsts.cpp diff --git a/tests/auto/network/access/hsts/tst_qhsts.cpp b/tests/auto/network/access/hsts/tst_qhsts.cpp new file mode 100644 index 0000000000..656516f46b --- /dev/null +++ b/tests/auto/network/access/hsts/tst_qhsts.cpp @@ -0,0 +1,318 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +#include <QtTest/QtTest> + +#include <QtCore/qdatetime.h> +#include <QtCore/qvector.h> +#include <QtCore/qpair.h> +#include <QtCore/qurl.h> + +#include <QtNetwork/private/qhsts_p.h> + +QT_USE_NAMESPACE + +class tst_QHsts : public QObject +{ + Q_OBJECT +private Q_SLOTS: + void testSingleKnownHost_data(); + void testSingleKnownHost(); + void testMultilpeKnownHosts(); + void testPolicyExpiration(); + void testSTSHeaderParser(); +}; + +void tst_QHsts::testSingleKnownHost_data() +{ + QTest::addColumn<QUrl>("knownHost"); + QTest::addColumn<QDateTime>("policyExpires"); + QTest::addColumn<bool>("includeSubDomains"); + QTest::addColumn<QUrl>("hostToTest"); + QTest::addColumn<bool>("isKnown"); + + const QDateTime currentUTC = QDateTime::currentDateTimeUtc(); + const QUrl knownHost(QLatin1String("http://example.com")); + const QUrl validSubdomain(QLatin1String("https://sub.example.com/ohoho")); + const QUrl unknownDomain(QLatin1String("http://example.org")); + const QUrl subSubdomain(QLatin1String("https://level3.level2.example.com")); + + const QDateTime validDate(currentUTC.addSecs(1000)); + QTest::newRow("same-known") << knownHost << validDate << false << knownHost << true; + QTest::newRow("subexcluded") << knownHost << validDate << false << validSubdomain << false; + QTest::newRow("subincluded") << knownHost << validDate << true << validSubdomain << true; + QTest::newRow("unknown-subexcluded") << knownHost << validDate << false << unknownDomain << false; + QTest::newRow("unknown-subincluded") << knownHost << validDate << true << unknownDomain << false; + QTest::newRow("sub-subdomain-subincluded") << knownHost << validDate << true << subSubdomain << true; + QTest::newRow("sub-subdomain-subexcluded") << knownHost << validDate << false << subSubdomain << false; + + const QDateTime invalidDate; + QTest::newRow("invalid-time") << knownHost << invalidDate << false << knownHost << false; + QTest::newRow("invalid-time-subexcluded") << knownHost << invalidDate << false + << validSubdomain << false; + QTest::newRow("invalid-time-subincluded") << knownHost << invalidDate << true + << validSubdomain << false; + + const QDateTime expiredDate(currentUTC.addSecs(-1000)); + QTest::newRow("expired-time") << knownHost << expiredDate << false << knownHost << false; + QTest::newRow("expired-time-subexcluded") << knownHost << expiredDate << false + << validSubdomain << false; + QTest::newRow("expired-time-subincluded") << knownHost << expiredDate << true + << validSubdomain << false; + const QUrl ipAsHost(QLatin1String("http://127.0.0.1")); + QTest::newRow("ip-address-in-hostname") << ipAsHost << validDate << false + << ipAsHost << false; + + const QUrl anyIPv4AsHost(QLatin1String("http://0.0.0.0")); + QTest::newRow("anyip4-address-in-hostname") << anyIPv4AsHost << validDate + << false << anyIPv4AsHost << false; + const QUrl anyIPv6AsHost(QLatin1String("http://[::]")); + QTest::newRow("anyip6-address-in-hostname") << anyIPv6AsHost << validDate + << false << anyIPv6AsHost << false; + +} + +void tst_QHsts::testSingleKnownHost() +{ + QFETCH(const QUrl, knownHost); + QFETCH(const QDateTime, policyExpires); + QFETCH(const bool, includeSubDomains); + QFETCH(const QUrl, hostToTest); + QFETCH(const bool, isKnown); + + QHstsCache cache; + cache.updateKnownHost(knownHost, policyExpires, includeSubDomains); + QCOMPARE(cache.isKnownHost(hostToTest), isKnown); +} + +void tst_QHsts::testMultilpeKnownHosts() +{ + const QDateTime currentUTC = QDateTime::currentDateTimeUtc(); + const QDateTime validDate(currentUTC.addSecs(10000)); + const QDateTime expiredDate(currentUTC.addSecs(-10000)); + const QUrl exampleCom(QLatin1String("https://example.com")); + const QUrl subExampleCom(QLatin1String("https://sub.example.com")); + + QHstsCache cache; + // example.com is HSTS and includes subdomains: + cache.updateKnownHost(exampleCom, validDate, true); + QVERIFY(cache.isKnownHost(exampleCom)); + QVERIFY(cache.isKnownHost(subExampleCom)); + // example.com can set its policy not to include subdomains: + cache.updateKnownHost(exampleCom, validDate, false); + QVERIFY(!cache.isKnownHost(subExampleCom)); + // but sub.example.com can set its own policy: + cache.updateKnownHost(subExampleCom, validDate, false); + QVERIFY(cache.isKnownHost(subExampleCom)); + // let's say example.com's policy has expired: + cache.updateKnownHost(exampleCom, expiredDate, false); + QVERIFY(!cache.isKnownHost(exampleCom)); + // it should not affect sub.example.com's policy: + QVERIFY(cache.isKnownHost(subExampleCom)); + + // clear cache and invalidate all policies: + cache.clear(); + QVERIFY(!cache.isKnownHost(exampleCom)); + QVERIFY(!cache.isKnownHost(subExampleCom)); + + // siblings: + const QUrl anotherSub(QLatin1String("https://sub2.example.com")); + cache.updateKnownHost(subExampleCom, validDate, true); + cache.updateKnownHost(anotherSub, validDate, true); + QVERIFY(cache.isKnownHost(subExampleCom)); + QVERIFY(cache.isKnownHost(anotherSub)); + // they cannot set superdomain's policy: + QVERIFY(!cache.isKnownHost(exampleCom)); + // a sibling cannot set another sibling's policy: + cache.updateKnownHost(anotherSub, expiredDate, false); + QVERIFY(cache.isKnownHost(subExampleCom)); + QVERIFY(!cache.isKnownHost(anotherSub)); + QVERIFY(!cache.isKnownHost(exampleCom)); + // let's make example.com known again: + cache.updateKnownHost(exampleCom, validDate, true); + // a subdomain cannot affect its superdomain's policy: + cache.updateKnownHost(subExampleCom, expiredDate, true); + QVERIFY(cache.isKnownHost(exampleCom)); + // and this superdomain includes subdomains in its HSTS policy: + QVERIFY(cache.isKnownHost(subExampleCom)); + QVERIFY(cache.isKnownHost(anotherSub)); + + // a subdomain (with its subdomains) cannot affect its superdomain's policy: + cache.updateKnownHost(exampleCom, expiredDate, true); + cache.updateKnownHost(subExampleCom, validDate, true); + QVERIFY(cache.isKnownHost(subExampleCom)); + QVERIFY(!cache.isKnownHost(exampleCom)); +} + +void tst_QHsts::testPolicyExpiration() +{ + QDateTime currentUTC = QDateTime::currentDateTimeUtc(); + const QUrl exampleCom(QLatin1String("http://example.com")); + const QUrl subdomain(QLatin1String("http://subdomain.example.com")); + const qint64 lifeTimeMS = 50; + + QHstsCache cache; + // start with 'includeSubDomains' and 5 s. lifetime: + cache.updateKnownHost(exampleCom, currentUTC.addMSecs(lifeTimeMS), true); + QVERIFY(cache.isKnownHost(exampleCom)); + QVERIFY(cache.isKnownHost(subdomain)); + // wait for approx. a half of lifetime: + QTest::qWait(lifeTimeMS / 2); + + if (QDateTime::currentDateTimeUtc() < currentUTC.addMSecs(lifeTimeMS)) { + // Should still be valid: + QVERIFY(cache.isKnownHost(exampleCom)); + QVERIFY(cache.isKnownHost(subdomain)); + } + + QTest::qWait(lifeTimeMS); + // expired: + QVERIFY(!cache.isKnownHost(exampleCom)); + QVERIFY(!cache.isKnownHost(subdomain)); + + // now check that superdomain's policy expires, but not subdomain's policy: + currentUTC = QDateTime::currentDateTimeUtc(); + cache.updateKnownHost(exampleCom, currentUTC.addMSecs(lifeTimeMS / 5), true); + cache.updateKnownHost(subdomain, currentUTC.addMSecs(lifeTimeMS), true); + QVERIFY(cache.isKnownHost(exampleCom)); + QVERIFY(cache.isKnownHost(subdomain)); + QTest::qWait(lifeTimeMS / 2); + if (QDateTime::currentDateTimeUtc() < currentUTC.addMSecs(lifeTimeMS)) { + QVERIFY(!cache.isKnownHost(exampleCom)); + QVERIFY(cache.isKnownHost(subdomain)); + } +} + +void tst_QHsts::testSTSHeaderParser() +{ + QHstsHeaderParser parser; + using Header = QPair<QByteArray, QByteArray>; + using Headers = QList<Header>; + + QVERIFY(!parser.includeSubDomains()); + QVERIFY(!parser.expirationDate().isValid()); + Headers list; + QVERIFY(!parser.parse(list)); + QVERIFY(!parser.includeSubDomains()); + QVERIFY(!parser.expirationDate().isValid()); + + list << Header("Strict-Transport-security", "200"); + QVERIFY(!parser.parse(list)); + QVERIFY(!parser.includeSubDomains()); + QVERIFY(!parser.expirationDate().isValid()); + + // This header is missing REQUIRED max-age directive, so we'll ignore it: + list << Header("Strict-Transport-Security", "includeSubDomains"); + QVERIFY(!parser.parse(list)); + QVERIFY(!parser.includeSubDomains()); + QVERIFY(!parser.expirationDate().isValid()); + + list.pop_back(); + list << Header("Strict-Transport-Security", "includeSubDomains;max-age=1000"); + QVERIFY(parser.parse(list)); + QVERIFY(parser.expirationDate() > QDateTime::currentDateTimeUtc()); + QVERIFY(parser.includeSubDomains()); + + list.pop_back(); + // Invalid (includeSubDomains twice): + list << Header("Strict-Transport-Security", "max-age = 1000 ; includeSubDomains;includeSubDomains"); + QVERIFY(!parser.parse(list)); + QVERIFY(!parser.includeSubDomains()); + QVERIFY(!parser.expirationDate().isValid()); + + list.pop_back(); + // Invalid (weird number of seconds): + list << Header("Strict-Transport-Security", "max-age=-1000 ; includeSubDomains"); + QVERIFY(!parser.parse(list)); + QVERIFY(!parser.includeSubDomains()); + QVERIFY(!parser.expirationDate().isValid()); + + list.pop_back(); + // Note, directives are case-insensitive + we should ignore unknown directive. + list << Header("Strict-Transport-Security", ";max-age=1000 ;includesubdomains;;" + "nowsomeunknownheader=\"somevaluewithescapes\\;\""); + QVERIFY(parser.parse(list)); + QVERIFY(parser.includeSubDomains()); + QVERIFY(parser.expirationDate().isValid()); + + list.pop_back(); + // Check that we know how to unescape max-age: + list << Header("Strict-Transport-Security", "max-age=\"1000\""); + QVERIFY(parser.parse(list)); + QVERIFY(!parser.includeSubDomains()); + QVERIFY(parser.expirationDate().isValid()); + + list.pop_back(); + // The only STS header, with invalid syntax though, to be ignored: + list << Header("Strict-Transport-Security", "max-age; max-age=15768000"); + QVERIFY(!parser.parse(list)); + QVERIFY(!parser.includeSubDomains()); + QVERIFY(!parser.expirationDate().isValid()); + + // Now we check that our parse chosses the first valid STS header and ignores + // others: + list.clear(); + list << Header("Strict-Transport-Security", "includeSubdomains; max-age=\"hehehe\";"); + list << Header("Strict-Transport-Security", "max-age=10101"); + QVERIFY(parser.parse(list)); + QVERIFY(!parser.includeSubDomains()); + QVERIFY(parser.expirationDate().isValid()); + + + list.clear(); + list << Header("Strict-Transport-Security", "max-age=0"); + QVERIFY(parser.parse(list)); + QVERIFY(!parser.includeSubDomains()); + QVERIFY(parser.expirationDate() <= QDateTime::currentDateTimeUtc()); + + // Parsing is case-insensitive: + list.pop_back(); + list << Header("Strict-Transport-Security", "Max-aGE=1000; InclUdesUbdomains"); + QVERIFY(parser.parse(list)); + QVERIFY(parser.includeSubDomains()); + QVERIFY(parser.expirationDate().isValid()); + + // Grammar of STS header is quite permissive, let's check we can parse + // some weird but valid header: + list.pop_back(); + list << Header("Strict-Transport-Security", ";;; max-age = 17; ; ; ; ;;; ;;" + ";;; ; includeSubdomains ;;thisIsUnknownDirective;;;;"); + QVERIFY(parser.parse(list)); + QVERIFY(parser.includeSubDomains()); + QVERIFY(parser.expirationDate().isValid()); + + list.pop_back(); + list << Header("Strict-Transport-Security", "max-age=1000; includeSubDomains bogon"); + QVERIFY(!parser.parse(list)); + QVERIFY(!parser.includeSubDomains()); + QVERIFY(!parser.expirationDate().isValid()); +} + +QTEST_MAIN(tst_QHsts) + +#include "tst_qhsts.moc" diff --git a/tests/auto/network/access/http2/http2srv.cpp b/tests/auto/network/access/http2/http2srv.cpp index 9d68b5c798..9f77419461 100644 --- a/tests/auto/network/access/http2/http2srv.cpp +++ b/tests/auto/network/access/http2/http2srv.cpp @@ -41,6 +41,7 @@ #include <QtNetwork/qtcpsocket.h> +#include <QtCore/qtimer.h> #include <QtCore/qdebug.h> #include <QtCore/qlist.h> #include <QtCore/qfile.h> @@ -117,6 +118,13 @@ void Http2Server::setResponseBody(const QByteArray &body) responseBody = body; } +void Http2Server::emulateGOAWAY(int timeout) +{ + Q_ASSERT(timeout >= 0); + testingGOAWAY = true; + goawayTimeout = timeout; +} + void Http2Server::startServer() { #ifdef QT_NO_SSL @@ -271,6 +279,16 @@ void Http2Server::connectionEstablished() { using namespace Http2; + if (testingGOAWAY) { + auto timer = new QTimer(this); + timer->setSingleShot(true); + connect(timer, &QTimer::timeout, [this]() { + sendGOAWAY(quint32(connectionStreamID), quint32(INTERNAL_ERROR), 0); + }); + timer->start(goawayTimeout); + return; + } + connect(socket.data(), SIGNAL(readyRead()), this, SLOT(readReady())); diff --git a/tests/auto/network/access/http2/http2srv.h b/tests/auto/network/access/http2/http2srv.h index 15a4f212c9..63a4a4c8e9 100644 --- a/tests/auto/network/access/http2/http2srv.h +++ b/tests/auto/network/access/http2/http2srv.h @@ -70,6 +70,7 @@ public: // To be called before server started: void enablePushPromise(bool enabled, const QByteArray &path = QByteArray()); void setResponseBody(const QByteArray &body); + void emulateGOAWAY(int timeout); // Invokables, since we can call them from the main thread, // but server (can) work on its own thread. @@ -162,6 +163,9 @@ private: quint32 lastPromisedStream = 0; QByteArray pushPath; + bool testingGOAWAY = false; + int goawayTimeout = 0; + protected slots: void ignoreErrorSlot(); }; diff --git a/tests/auto/network/access/http2/tst_http2.cpp b/tests/auto/network/access/http2/tst_http2.cpp index 771ddb01be..d7a57f5e26 100644 --- a/tests/auto/network/access/http2/tst_http2.cpp +++ b/tests/auto/network/access/http2/tst_http2.cpp @@ -69,6 +69,8 @@ private slots: void flowControlClientSide(); void flowControlServerSide(); void pushPromise(); + void goaway_data(); + void goaway(); protected slots: // Slots to listen to our in-process server: @@ -83,6 +85,7 @@ protected slots: void receivedData(quint32 streamID); void windowUpdated(quint32 streamID); void replyFinished(); + void replyFinishedWithError(); private: void clearHTTP2State(); @@ -97,6 +100,7 @@ private: void sendRequest(int streamNumber, QNetworkRequest::Priority priority = QNetworkRequest::NormalPriority, const QByteArray &payload = QByteArray()); + QUrl requestUrl() const; quint16 serverPort = 0; QThread *workerThread = nullptr; @@ -196,9 +200,8 @@ void tst_Http2::singleRequest() QVERIFY(serverPort != 0); - const QString urlAsString(clearTextHTTP2 ? QString("http://127.0.0.1:%1/index.html") - : QString("https://127.0.0.1:%1/index.html")); - const QUrl url(urlAsString.arg(serverPort)); + auto url = requestUrl(); + url.setPath("/index.html"); QNetworkRequest request(url); request.setAttribute(QNetworkRequest::HTTP2AllowedAttribute, QVariant(true)); @@ -347,11 +350,10 @@ void tst_Http2::pushPromise() QVERIFY(serverPort != 0); - const QString urlAsString((clearTextHTTP2 ? QString("http://127.0.0.1:%1/") - : QString("https://127.0.0.1:%1/")).arg(serverPort)); - const QUrl requestUrl(urlAsString + "index.html"); + auto url = requestUrl(); + url.setPath("/index.html"); - QNetworkRequest request(requestUrl); + QNetworkRequest request(url); request.setAttribute(QNetworkRequest::HTTP2AllowedAttribute, QVariant(true)); auto reply = manager.get(request); @@ -374,8 +376,8 @@ void tst_Http2::pushPromise() // Create an additional request (let's say, we parsed reply and realized we // need another resource): - const QUrl promisedUrl(urlAsString + "script.js"); - QNetworkRequest promisedRequest(promisedUrl); + url.setPath("/script.js"); + QNetworkRequest promisedRequest(url); promisedRequest.setAttribute(QNetworkRequest::HTTP2AllowedAttribute, QVariant(true)); reply = manager.get(promisedRequest); connect(reply, &QNetworkReply::finished, this, &tst_Http2::replyFinished); @@ -391,6 +393,61 @@ void tst_Http2::pushPromise() QVERIFY(reply->isFinished()); } +void tst_Http2::goaway_data() +{ + // For now we test only basic things in two very simple scenarios: + // - server sends GOAWAY immediately or + // - server waits for some time (enough for ur to init several streams on a + // client side); then suddenly it replies with GOAWAY, never processing any + // request. + QTest::addColumn<int>("responseTimeoutMS"); + QTest::newRow("ImmediateGOAWAY") << 0; + QTest::newRow("DelayedGOAWAY") << 1000; +} + +void tst_Http2::goaway() +{ + using namespace Http2; + + QFETCH(const int, responseTimeoutMS); + + clearHTTP2State(); + + serverPort = 0; + nRequests = 3; + + ServerPtr srv(newServer(defaultServerSettings, defaultClientSettings)); + srv->emulateGOAWAY(responseTimeoutMS); + QMetaObject::invokeMethod(srv.data(), "startServer", Qt::QueuedConnection); + runEventLoop(); + + QVERIFY(serverPort != 0); + + auto url = requestUrl(); + // We have to store these replies, so that we can check errors later. + std::vector<QNetworkReply *> replies(nRequests); + for (int i = 0; i < nRequests; ++i) { + url.setPath(QString("/%1").arg(i)); + QNetworkRequest request(url); + request.setAttribute(QNetworkRequest::HTTP2AllowedAttribute, QVariant(true)); + replies[i] = manager.get(request); + QCOMPARE(replies[i]->error(), QNetworkReply::NoError); + void (QNetworkReply::*errorSignal)(QNetworkReply::NetworkError) = + &QNetworkReply::error; + connect(replies[i], errorSignal, this, &tst_Http2::replyFinishedWithError); + // Since we're using self-signed certificates, ignore SSL errors: + replies[i]->ignoreSslErrors(); + } + + runEventLoop(5000 + responseTimeoutMS); + + // No request processed, no 'replyFinished' slot calls: + QCOMPARE(nRequests, 0); + // Our server did not bother to send anything except a single GOAWAY frame: + QVERIFY(!prefaceOK); + QVERIFY(!serverGotSettingsACK); +} + void tst_Http2::serverStarted(quint16 port) { serverPort = port; @@ -445,10 +502,9 @@ void tst_Http2::sendRequest(int streamNumber, QNetworkRequest::Priority priority, const QByteArray &payload) { - static const QString urlAsString(clearTextHTTP2 ? "http://127.0.0.1:%1/stream%2.html" - : "https://127.0.0.1:%1/stream%2.html"); + auto url = requestUrl(); + url.setPath(QString("/stream%1.html").arg(streamNumber)); - const QUrl url(urlAsString.arg(serverPort).arg(streamNumber)); QNetworkRequest request(url); request.setAttribute(QNetworkRequest::HTTP2AllowedAttribute, QVariant(true)); request.setPriority(priority); @@ -463,6 +519,14 @@ void tst_Http2::sendRequest(int streamNumber, connect(reply, &QNetworkReply::finished, this, &tst_Http2::replyFinished); } +QUrl tst_Http2::requestUrl() const +{ + static auto url = QUrl(QLatin1String(clearTextHTTP2 ? "http://127.0.0.1" : "https://127.0.0.1")); + url.setPort(serverPort); + + return url; +} + void tst_Http2::clientPrefaceOK() { prefaceOK = true; @@ -476,6 +540,8 @@ void tst_Http2::clientPrefaceError() void tst_Http2::serverSettingsAcked() { serverGotSettingsACK = true; + if (!nRequests) + stopEventLoop(); } void tst_Http2::invalidFrame() @@ -524,8 +590,30 @@ void tst_Http2::replyFinished() { QVERIFY(nRequests); - if (const auto reply = qobject_cast<QNetworkReply *>(sender())) + if (const auto reply = qobject_cast<QNetworkReply *>(sender())) { QCOMPARE(reply->error(), QNetworkReply::NoError); + const QVariant http2Used(reply->attribute(QNetworkRequest::HTTP2WasUsedAttribute)); + QVERIFY(http2Used.isValid()); + QVERIFY(http2Used.toBool()); + const QVariant spdyUsed(reply->attribute(QNetworkRequest::SpdyWasUsedAttribute)); + QVERIFY(spdyUsed.isValid()); + QVERIFY(!spdyUsed.toBool()); + } + + --nRequests; + if (!nRequests && serverGotSettingsACK) + stopEventLoop(); +} + +void tst_Http2::replyFinishedWithError() +{ + QVERIFY(nRequests); + + if (const auto reply = qobject_cast<QNetworkReply *>(sender())) { + // For now this is a 'generic' code, it just verifies some error was + // reported without testing its type. + QVERIFY(reply->error() != QNetworkReply::NoError); + } --nRequests; if (!nRequests) diff --git a/tests/auto/network/access/qftp/tst_qftp.cpp b/tests/auto/network/access/qftp/tst_qftp.cpp index a13fa86405..a1c8399a26 100644 --- a/tests/auto/network/access/qftp/tst_qftp.cpp +++ b/tests/auto/network/access/qftp/tst_qftp.cpp @@ -124,7 +124,7 @@ protected slots: private: QFtp *newFtp(); void addCommand( QFtp::Command, int ); - bool fileExists( const QString &host, quint16 port, const QString &user, const QString &password, const QString &file, const QString &cdDir = QString::null ); + bool fileExists( const QString &host, quint16 port, const QString &user, const QString &password, const QString &file, const QString &cdDir = QString() ); bool dirExists( const QString &host, quint16 port, const QString &user, const QString &password, const QString &cdDir, const QString &dirToCreate ); void renameInit( const QString &host, const QString &user, const QString &password, const QString &createFile ); diff --git a/tests/auto/network/access/qnetworkreply/test/test.pro b/tests/auto/network/access/qnetworkreply/test/test.pro index 45a5734305..8aeec88fd2 100644 --- a/tests/auto/network/access/qnetworkreply/test/test.pro +++ b/tests/auto/network/access/qnetworkreply/test/test.pro @@ -1,6 +1,6 @@ CONFIG += testcase testcase.timeout = 600 # this test is slow -CONFIG -= app_bundle debug_and_release_target +CONFIG -= debug_and_release_target SOURCES += ../tst_qnetworkreply.cpp TARGET = ../tst_qnetworkreply diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index a7f6a9058a..fbd8f5a780 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -104,10 +104,10 @@ class tst_QNetworkReply: public QObject Q_OBJECT #ifndef QT_NO_NETWORKPROXY - struct ProxyData { + struct ProxyData + { ProxyData(const QNetworkProxy &p, const QByteArray &t, bool auth) - : tag(t), proxy(p), requiresAuthentication(auth) - { } + : tag(t), proxy(p), requiresAuthentication(auth) {} QByteArray tag; QNetworkProxy proxy; bool requiresAuthentication; @@ -115,7 +115,8 @@ class tst_QNetworkReply: public QObject #endif // !QT_NO_NETWORKPROXY static bool seedCreated; - static QString createUniqueExtension() { + static QString createUniqueExtension() + { if (!seedCreated) { qsrand(QTime(0,0,0).msecsTo(QTime::currentTime()) + QCoreApplication::applicationPid()); seedCreated = true; // not thread-safe, but who cares @@ -131,7 +132,9 @@ class tst_QNetworkReply: public QObject "location: %1\r\n" "\r\n"; return s; - }; + } + + static const QByteArray httpEmpty200Response; QEventLoop *loop; enum RunSimpleRequestReturn { Timeout = 0, Success, Failure }; @@ -475,6 +478,12 @@ private Q_SLOTS: void ioHttpChangeMaxRedirects(); void ioHttpRedirectErrors_data(); void ioHttpRedirectErrors(); + void ioHttpRedirectPolicy_data(); + void ioHttpRedirectPolicy(); + void ioHttpRedirectPolicyErrors_data(); + void ioHttpRedirectPolicyErrors(); + void ioHttpUserVerifiedRedirect_data(); + void ioHttpUserVerifiedRedirect(); #ifndef QT_NO_SSL void putWithServerClosingConnectionImmediately(); #endif @@ -488,6 +497,8 @@ private: bool notEnoughDataForFastSender; }; +const QByteArray tst_QNetworkReply::httpEmpty200Response = + "HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n"; bool tst_QNetworkReply::seedCreated = false; #define RUN_REQUEST(call) \ @@ -495,7 +506,7 @@ bool tst_QNetworkReply::seedCreated = false; QString errorMsg = call; \ if (!errorMsg.isEmpty()) \ QFAIL(qPrintable(errorMsg)); \ - } while (0); + } while (0) #ifndef QT_NO_SSL static void setupSslServer(QSslSocket* serverSocket) @@ -507,6 +518,7 @@ static void setupSslServer(QSslSocket* serverSocket) serverSocket->setProtocol(QSsl::AnyProtocol); serverSocket->setLocalCertificate(testDataDir + "/certs/server.pem"); serverSocket->setPrivateKey(testDataDir + "/certs/server.key"); + serverSocket->startServerEncryption(); } #endif @@ -553,31 +565,30 @@ protected: void incomingConnection(qintptr socketDescriptor) { //qDebug() << "incomingConnection" << socketDescriptor << "doSsl:" << doSsl << "ipv6:" << ipv6; - if (!doSsl) { - client = new QTcpSocket; - client->setSocketDescriptor(socketDescriptor); - connectSocketSignals(); - } else { #ifndef QT_NO_SSL - QSslSocket *serverSocket = new QSslSocket; - serverSocket->setParent(this); - if (serverSocket->setSocketDescriptor(socketDescriptor)) { - connect(serverSocket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(slotSslErrors(QList<QSslError>))); - setupSslServer(serverSocket); - serverSocket->startServerEncryption(); - client = serverSocket; - connectSocketSignals(); - } else { + if (doSsl) { + QSslSocket *serverSocket = new QSslSocket(this); + if (!serverSocket->setSocketDescriptor(socketDescriptor)) { delete serverSocket; return; } + connect(serverSocket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(slotSslErrors(QList<QSslError>))); + // connect(serverSocket, &QSslSocket::encrypted, this, &SslServer::ready); ? + setupSslServer(serverSocket); + client = serverSocket; + } else #endif + { + client = new QTcpSocket; + client->setSocketDescriptor(socketDescriptor); } + connectSocketSignals(); client->setParent(this); ++totalConnections; } - virtual void reply() { + virtual void reply() + { Q_ASSERT(!client.isNull()); // we need to emulate the bytesWrittenSlot call if the data is empty. if (dataToTransmit.size() == 0) { @@ -634,7 +645,8 @@ public slots: } } - void bytesWrittenSlot() { + void bytesWrittenSlot() + { Q_ASSERT(!client.isNull()); // Disconnect and delete in next cycle (else Windows clients will fail with RemoteHostClosedError). if (doClose && client->bytesToWrite() == 0) { @@ -879,7 +891,8 @@ class BlockingTcpServer : public QTcpServer public: BlockingTcpServer(bool ssl) : doSsl(ssl), sslSocket(0) {} - QTcpSocket* waitForNextConnectionSocket() { + QTcpSocket* waitForNextConnectionSocket() + { waitForNewConnection(-1); if (doSsl) { if (!sslSocket) @@ -900,7 +913,6 @@ public: serverSocket->setSocketDescriptor(socketDescriptor); connect(serverSocket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(slotSslErrors(QList<QSslError>))); setupSslServer(serverSocket); - serverSocket->startServerEncryption(); sslSocket = serverSocket; } else #endif @@ -1381,14 +1393,12 @@ static QByteArray msgWaitForFinished(QNetworkReplyPtr &reply) QString result; QDebug debug(&result); debug << reply->url(); - if (reply->isFinished()) { - if (reply->error() == QNetworkReply::NoError) - debug << "finished."; - else - debug << "failed: #" << reply->error() << reply->errorString(); - } else { + if (!reply->isFinished()) debug << "timed out."; - } + else if (reply->error() == QNetworkReply::NoError) + debug << "finished."; + else + debug << "failed: #" << reply->error() << reply->errorString(); return result.toLocal8Bit(); } @@ -1403,7 +1413,7 @@ int tst_QNetworkReply::waitForFinish(QNetworkReplyPtr &reply) QSignalSpy spy(reply.data(), SIGNAL(downloadProgress(qint64,qint64))); while (!reply->isFinished()) { QTimer::singleShot(5000, loop, SLOT(quit())); - if ( loop->exec() == Timeout && count == spy.count() && !reply->isFinished()) { + if (loop->exec() == Timeout && count == spy.count() && !reply->isFinished()) { returnCode = Timeout; break; } @@ -1417,12 +1427,14 @@ int tst_QNetworkReply::waitForFinish(QNetworkReplyPtr &reply) void tst_QNetworkReply::finished() { - loop->exit(returnCode = Success); + if (loop) + loop->exit(returnCode = Success); } void tst_QNetworkReply::gotError() { - loop->exit(returnCode = Failure); + if (loop) + loop->exit(returnCode = Failure); disconnect(QObject::sender(), SIGNAL(finished()), this, 0); } @@ -4725,11 +4737,13 @@ void tst_QNetworkReply::ioPostToHttpNoBufferFlag() } #ifndef QT_NO_SSL -class SslServer : public QTcpServer { +class SslServer : public QTcpServer +{ Q_OBJECT public: SslServer() : socket(0), m_ssl(true) {} - void incomingConnection(qintptr socketDescriptor) { + void incomingConnection(qintptr socketDescriptor) + { QSslSocket *serverSocket = new QSslSocket; serverSocket->setParent(this); @@ -4739,16 +4753,9 @@ public: emit newPlainConnection(serverSocket); return; } - QString testDataDir = QFileInfo(QFINDTESTDATA("rfc3252.txt")).absolutePath(); - if (testDataDir.isEmpty()) - testDataDir = QCoreApplication::applicationDirPath(); - connect(serverSocket, SIGNAL(encrypted()), this, SLOT(encryptedSlot())); - serverSocket->setProtocol(QSsl::AnyProtocol); connect(serverSocket, SIGNAL(sslErrors(QList<QSslError>)), serverSocket, SLOT(ignoreSslErrors())); - serverSocket->setLocalCertificate(testDataDir + "/certs/server.pem"); - serverSocket->setPrivateKey(testDataDir + "/certs/server.key"); - serverSocket->startServerEncryption(); + setupSslServer(serverSocket); } else { delete serverSocket; } @@ -4757,11 +4764,13 @@ signals: void newEncryptedConnection(QSslSocket *s); void newPlainConnection(QSslSocket *s); public slots: - void encryptedSlot() { + void encryptedSlot() + { socket = (QSslSocket*) sender(); emit newEncryptedConnection(socket); } - void readyReadSlot() { + void readyReadSlot() + { // for the incoming sockets, not the server socket //qDebug() << static_cast<QSslSocket*>(sender())->bytesAvailable() << static_cast<QSslSocket*>(sender())->encryptedBytesAvailable(); } @@ -4807,7 +4816,7 @@ void tst_QNetworkReply::ioPostToHttpsUploadProgress() disconnect(&server, SIGNAL(newEncryptedConnection(QSslSocket*)), &QTestEventLoop::instance(), SLOT(exitLoop())); - incomingSocket->setReadBufferSize(1*1024); + incomingSocket->setReadBufferSize(1024); // some progress should have been made QTRY_VERIFY(!spy.isEmpty()); QList<QVariant> args = spy.last(); @@ -4911,7 +4920,7 @@ void tst_QNetworkReply::ioGetFromBuiltinHttp() QCOMPARE(reply->header(QNetworkRequest::ContentLengthHeader).toLongLong(), (qint64)testData.size()); if (reader.data.size() < testData.size()) { // oops? - QCOMPARE(reader.data, testData.mid(0, reader.data.size())); + QCOMPARE(reader.data, testData.left(reader.data.size())); qDebug() << "The data is incomplete, the last" << testData.size() - reader.data.size() << "bytes are missing"; } QCOMPARE(reader.data.size(), testData.size()); @@ -4958,7 +4967,7 @@ void tst_QNetworkReply::ioPostToHttpUploadProgress() QVERIFY(incomingSocket); disconnect(&server, SIGNAL(newConnection()), &QTestEventLoop::instance(), SLOT(exitLoop())); - incomingSocket->setReadBufferSize(1*1024); + incomingSocket->setReadBufferSize(1024); QTestEventLoop::instance().enterLoop(5); // some progress should have been made QVERIFY(!spy.isEmpty()); @@ -5660,12 +5669,14 @@ void tst_QNetworkReply::httpProxyCommands() QCOMPARE(uaheader, QByteArray("User-Agent: QNetworkReplyAutoTest/1.0")); } -class ProxyChangeHelper : public QObject { +class ProxyChangeHelper : public QObject +{ Q_OBJECT public: ProxyChangeHelper() : QObject(), signalCount(0) {}; public slots: - void finishedSlot() { + void finishedSlot() + { signalCount++; if (signalCount == 2) QMetaObject::invokeMethod(&QTestEventLoop::instance(), "exitLoop", Qt::QueuedConnection); @@ -5911,7 +5922,8 @@ void tst_QNetworkReply::httpReUsingConnectionSequential() reply2->deleteLater(); } -class HttpReUsingConnectionFromFinishedSlot : public QObject { +class HttpReUsingConnectionFromFinishedSlot : public QObject +{ Q_OBJECT public: QNetworkReply* reply1; @@ -5919,7 +5931,8 @@ public: QUrl url; QNetworkAccessManager manager; public slots: - void finishedSlot() { + void finishedSlot() + { QVERIFY(!reply1->error()); QFETCH(bool, doDeleteLater); @@ -5967,7 +5980,8 @@ void tst_QNetworkReply::httpReUsingConnectionFromFinishedSlot() QCOMPARE(server.totalConnections, 1); } -class HttpRecursiveCreationHelper : public QObject { +class HttpRecursiveCreationHelper : public QObject +{ Q_OBJECT public: @@ -5983,7 +5997,8 @@ public: int requestsStartedCount_readyRead; int requestsFinishedCount; public slots: - void finishedSlot() { + void finishedSlot() + { requestsFinishedCount++; QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender()); @@ -6002,7 +6017,8 @@ public slots: reply->deleteLater(); } - void readyReadSlot() { + void readyReadSlot() + { QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender()); QVERIFY(!reply->error()); @@ -6011,7 +6027,8 @@ public slots: requestsStartedCount_readyRead++; } } - void startOne() { + void startOne() + { QUrl url = "http://" + QtNetworkSettings::serverName() + "/qtest/fluke.gif"; QNetworkRequest request(url); QNetworkReply *reply = manager.get(request); @@ -6380,7 +6397,8 @@ void tst_QNetworkReply::getFromHttpIntoBuffer() } // FIXME we really need to consolidate all those server implementations -class GetFromHttpIntoBuffer2Server : QObject { +class GetFromHttpIntoBuffer2Server : QObject +{ Q_OBJECT qint64 dataSize; qint64 dataSent; @@ -6390,26 +6408,28 @@ class GetFromHttpIntoBuffer2Server : QObject { bool chunkedEncoding; public: - GetFromHttpIntoBuffer2Server (qint64 ds, bool sscl, bool ce) : dataSize(ds), dataSent(0), - client(0), serverSendsContentLength(sscl), chunkedEncoding(ce) { + GetFromHttpIntoBuffer2Server (qint64 ds, bool sscl, bool ce) + : dataSize(ds), dataSent(0), client(0), + serverSendsContentLength(sscl), chunkedEncoding(ce) + { server.listen(); connect(&server, SIGNAL(newConnection()), this, SLOT(newConnectionSlot())); } - int serverPort() { - return server.serverPort(); - } + int serverPort() { return server.serverPort(); } public slots: - void newConnectionSlot() { + void newConnectionSlot() + { client = server.nextPendingConnection(); client->setParent(this); connect(client, SIGNAL(readyRead()), this, SLOT(readyReadSlot())); connect(client, SIGNAL(bytesWritten(qint64)), this, SLOT(bytesWrittenSlot(qint64))); } - void readyReadSlot() { + void readyReadSlot() + { client->readAll(); client->write("HTTP/1.0 200 OK\n"); if (serverSendsContentLength) @@ -6419,7 +6439,8 @@ public slots: client->write("Connection: close\n\n"); } - void bytesWrittenSlot(qint64 amount) { + void bytesWrittenSlot(qint64 amount) + { Q_UNUSED(amount); if (dataSent == dataSize && client) { // close eventually @@ -6453,7 +6474,8 @@ public slots: } }; -class GetFromHttpIntoBuffer2Client : QObject { +class GetFromHttpIntoBuffer2Client : QObject +{ Q_OBJECT private: bool useDownloadBuffer; @@ -6470,7 +6492,8 @@ public: } public slots: - void metaDataChangedSlot() { + void metaDataChangedSlot() + { if (useDownloadBuffer) { QSharedPointer<char> sharedPointer = qvariant_cast<QSharedPointer<char> >(reply->attribute(QNetworkRequest::DownloadBufferAttribute)); QVERIFY(!sharedPointer.isNull()); // It will be 0 if it failed @@ -6480,7 +6503,8 @@ public: QVERIFY(bytesAvailableList.isEmpty()); } - void readyReadSlot() { + void readyReadSlot() + { QVERIFY(!reply->isFinished()); qint64 bytesAvailable = reply->bytesAvailable(); @@ -6502,7 +6526,8 @@ public: // Add bytesAvailable to a list an parse } - void finishedSlot() { + void finishedSlot() + { // We should have already received all readyRead QVERIFY(!bytesAvailableList.isEmpty()); QCOMPARE(bytesAvailableList.last(), uploadSize); @@ -6797,7 +6822,8 @@ void tst_QNetworkReply::authenticationCacheAfterCancel() // QTBUG-23136 workaround (needed even with danted v1.1.19): if (proxy.port() == 1081) { #ifdef QT_BUILD_INTERNAL - QNetworkAccessManagerPrivate::clearCache(&manager); + QNetworkAccessManagerPrivate::clearAuthenticationCache(&manager); + QNetworkAccessManagerPrivate::clearConnectionCache(&manager); #else return; #endif @@ -6908,17 +6934,17 @@ void tst_QNetworkReply::authenticationWithDifferentRealm() } #endif // !QT_NO_NETWORKPROXY -class QtBug13431Helper : public QObject { +class QtBug13431Helper : public QObject +{ Q_OBJECT public: QNetworkReply* m_reply; QTimer m_dlTimer; public slots: - void replyFinished(QNetworkReply*) { - QTestEventLoop::instance().exitLoop(); - } + void replyFinished(QNetworkReply*) { QTestEventLoop::instance().exitLoop(); } - void onReadAndReschedule() { + void onReadAndReschedule() + { const qint64 bytesReceived = m_reply->bytesAvailable(); if (bytesReceived && m_reply->readBufferSize()) { QByteArray data = m_reply->read(bytesReceived); @@ -7066,7 +7092,8 @@ void tst_QNetworkReply::qtbug22660gzipNoContentLengthEmptyContent() QCOMPARE(reply->readAll(), QByteArray()); } -class QtBug27161Helper : public QObject { +class QtBug27161Helper : public QObject +{ Q_OBJECT public: QtBug27161Helper(MiniHttpServer & server, const QByteArray & data): @@ -7076,16 +7103,19 @@ public: connect(&m_server, SIGNAL(newConnection()), this, SLOT(newConnectionSlot())); } public slots: - void newConnectionSlot(){ + void newConnectionSlot() + { connect(m_server.client, SIGNAL(bytesWritten(qint64)), this, SLOT(bytesWrittenSlot())); } - void bytesWrittenSlot(){ + void bytesWrittenSlot() + { disconnect(m_server.client, SIGNAL(bytesWritten(qint64)), this, SLOT(bytesWrittenSlot())); m_Timer.singleShot(100, this, SLOT(timeoutSlot())); } - void timeoutSlot(){ + void timeoutSlot() + { m_server.doClose = true; // we need to emulate the bytesWrittenSlot call if the data is empty. if (m_data.size() == 0) @@ -7514,10 +7544,12 @@ void tst_QNetworkReply::httpUserAgent() void tst_QNetworkReply::synchronousAuthenticationCache() { - class MiniAuthServer : public MiniHttpServer { + class MiniAuthServer : public MiniHttpServer + { public: - MiniAuthServer(QThread *thread) : MiniHttpServer(QByteArray(), false, thread) {}; - virtual void reply() { + MiniAuthServer(QThread *thread) : MiniHttpServer(QByteArray(), false, thread) {} + virtual void reply() + { dataToTransmit = "HTTP/1.0 401 Unauthorized\r\n" @@ -7929,7 +7961,8 @@ public: qint64 bandwidthQuota; QTimer timer; - RateLimitedUploadDevice(QByteArray d) : QIODevice(),data(d),read(0),bandwidthQuota(0) { + RateLimitedUploadDevice(QByteArray d) : QIODevice(),data(d),read(0),bandwidthQuota(0) + { buffer.setData(data); buffer.open(QIODevice::ReadOnly); timer.setInterval(200); @@ -7937,12 +7970,14 @@ public: timer.start(); } - virtual qint64 writeData(const char* , qint64 ) { + virtual qint64 writeData(const char* , qint64 ) + { Q_ASSERT(false); return 0; } - virtual qint64 readData(char* data, qint64 maxlen) { + virtual qint64 readData(char* data, qint64 maxlen) + { //qDebug() << Q_FUNC_INFO << maxlen << bandwidthQuota; maxlen = qMin(maxlen, buffer.bytesAvailable()); maxlen = qMin(maxlen, bandwidthQuota); @@ -7959,24 +7994,17 @@ public: //qDebug() << Q_FUNC_INFO << maxlen << bandwidthQuota << read << ret << buffer.bytesAvailable(); return ret; } - virtual bool atEnd() const { - return buffer.atEnd(); - } - virtual qint64 size() const{ - return data.length(); - } + virtual bool atEnd() const { return buffer.atEnd(); } + virtual qint64 size() const { return data.length(); } qint64 bytesAvailable() const { return buffer.bytesAvailable() + QIODevice::bytesAvailable(); } - virtual bool isSequential() const{ // random access, we can seek - return false; - } - virtual bool seek ( qint64 pos ) { - return buffer.seek(pos); - } + virtual bool isSequential() const { return false; } // random access, we can seek + virtual bool seek (qint64 pos) { return buffer.seek(pos); } protected slots: - void timeoutSlot() { + void timeoutSlot() + { //qDebug() << Q_FUNC_INFO; bandwidthQuota = 8*1024; // fill quota emit readyRead(); @@ -8012,10 +8040,9 @@ void tst_QNetworkReply::putWithRateLimiting() void tst_QNetworkReply::ioHttpSingleRedirect() { QUrl localhost = QUrl("http://localhost"); - QByteArray http200Reply = "HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n"; // Setup server to which the second server will redirect to - MiniHttpServer server2(http200Reply); + MiniHttpServer server2(httpEmpty200Response); QUrl redirectUrl = QUrl(localhost); redirectUrl.setPort(server2.serverPort()); @@ -8057,11 +8084,9 @@ void tst_QNetworkReply::ioHttpChangeMaxRedirects() { QUrl localhost = QUrl("http://localhost"); - QByteArray http200Reply = "HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n"; - MiniHttpServer server1(""); MiniHttpServer server2(""); - MiniHttpServer server3(http200Reply); + MiniHttpServer server3(httpEmpty200Response); QUrl server2Url(localhost); server2Url.setPort(server2.serverPort()); @@ -8145,6 +8170,221 @@ void tst_QNetworkReply::ioHttpRedirectErrors() QCOMPARE(spy.count(), 1); QCOMPARE(reply->error(), error); } + +struct SameOriginRedirector : MiniHttpServer +{ + SameOriginRedirector(const QByteArray &data, bool ssl = false) + : MiniHttpServer(data, ssl) + { } + + std::vector<QByteArray> responses; + + void reply() override + { + if (responses.empty()) { + dataToTransmit.clear(); + } else { + dataToTransmit = responses.back(); + responses.pop_back(); + } + + MiniHttpServer::reply(); + } +}; + +void tst_QNetworkReply::ioHttpRedirectPolicy_data() +{ + QTest::addColumn<QNetworkRequest::RedirectPolicy>("policy"); + QTest::addColumn<bool>("ssl"); + QTest::addColumn<int>("redirectCount"); + QTest::addColumn<int>("statusCode"); + + QTest::newRow("manual-nossl") << QNetworkRequest::ManualRedirectPolicy << false << 0 << 307; + QTest::newRow("manual-ssl") << QNetworkRequest::ManualRedirectPolicy << true << 0 << 307; + QTest::newRow("nolesssafe-nossl") << QNetworkRequest::NoLessSafeRedirectPolicy << false << 1 << 200; + QTest::newRow("nolesssafe-ssl") << QNetworkRequest::NoLessSafeRedirectPolicy << true << 1 << 200; + QTest::newRow("same-origin-nossl") << QNetworkRequest::SameOriginRedirectPolicy << false << 1 << 200; + QTest::newRow("same-origin-ssl") << QNetworkRequest::SameOriginRedirectPolicy << true << 1 << 200; +} + +void tst_QNetworkReply::ioHttpRedirectPolicy() +{ + QFETCH(const QNetworkRequest::RedirectPolicy, policy); + + QFETCH(const bool, ssl); +#ifdef QT_NO_SSL + if (ssl) + QSKIP("SSL is not supported"); +#endif + + QFETCH(const int, redirectCount); + QFETCH(const int, statusCode); + + // Setup HTTP server. + SameOriginRedirector redirectServer("", ssl); + + QUrl url(QLatin1String( +#ifndef QT_NO_SSL + ssl ? "https://localhost" : +#endif + "http://localhost")); + + url.setPort(redirectServer.serverPort()); + redirectServer.responses.push_back(httpEmpty200Response); + redirectServer.responses.push_back(tempRedirectReplyStr().arg(QString(url.toEncoded())).toLatin1()); + + // This is the default one we preserve between tests. + QCOMPARE(manager.redirectPolicy(), QNetworkRequest::ManualRedirectPolicy); + + manager.setRedirectPolicy(policy); + QCOMPARE(manager.redirectPolicy(), policy); + QNetworkReplyPtr reply(manager.get(QNetworkRequest(url))); + if (ssl) + reply->ignoreSslErrors(); + + // Restore default: + manager.setRedirectPolicy(QNetworkRequest::ManualRedirectPolicy); + QSignalSpy redirectSpy(reply.data(), SIGNAL(redirected(QUrl))); + QSignalSpy finishedSpy(reply.data(), SIGNAL(finished())); + QVERIFY2(waitForFinish(reply) == Success, msgWaitForFinished(reply)); + QCOMPARE(finishedSpy.count(), 1); + QCOMPARE(redirectSpy.count(), redirectCount); + QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), statusCode); +} + +void tst_QNetworkReply::ioHttpRedirectPolicyErrors_data() +{ + QTest::addColumn<QNetworkRequest::RedirectPolicy>("policy"); + QTest::addColumn<bool>("ssl"); + QTest::addColumn<QString>("location"); + QTest::addColumn<int>("maxRedirects"); + QTest::addColumn<QNetworkReply::NetworkError>("expectedError"); + + // 1. NoLessSafeRedirectsPolicy + QTest::newRow("nolesssafe-nossl-nossl-too-many") << QNetworkRequest::NoLessSafeRedirectPolicy + << false << QString("http://localhost:%1") << 0 << QNetworkReply::TooManyRedirectsError; + QTest::newRow("nolesssafe-ssl-ssl-too-many") << QNetworkRequest::NoLessSafeRedirectPolicy + << true << QString("https:/localhost:%1") << 0 << QNetworkReply::TooManyRedirectsError; + QTest::newRow("nolesssafe-ssl-nossl-insecure-redirect") << QNetworkRequest::NoLessSafeRedirectPolicy + << true << QString("http://localhost:%1") << 50 << QNetworkReply::InsecureRedirectError; + // 2. SameOriginRedirectsPolicy + QTest::newRow("same-origin-nossl-nossl-too-many") << QNetworkRequest::SameOriginRedirectPolicy + << false << QString("http://localhost:%1") << 0 << QNetworkReply::TooManyRedirectsError; + QTest::newRow("same-origin-ssl-ssl-too-many") << QNetworkRequest::SameOriginRedirectPolicy + << true << QString("https://localhost:%1") << 0 << QNetworkReply::TooManyRedirectsError; + QTest::newRow("same-origin-https-http-wrong-protocol") << QNetworkRequest::SameOriginRedirectPolicy + << true << QString("http://localhost:%1") << 50 << QNetworkReply::InsecureRedirectError; + QTest::newRow("same-origin-http-https-wrong-protocol") << QNetworkRequest::SameOriginRedirectPolicy + << false << QString("https://localhost:%1") << 50 << QNetworkReply::InsecureRedirectError; + QTest::newRow("same-origin-http-http-wrong-host") << QNetworkRequest::SameOriginRedirectPolicy + << false << QString("http://not-so-localhost:%1") << 50 << QNetworkReply::InsecureRedirectError; + QTest::newRow("same-origin-https-https-wrong-host") << QNetworkRequest::SameOriginRedirectPolicy + << true << QString("https://not-so-localhost:%1") << 50 << QNetworkReply::InsecureRedirectError; + QTest::newRow("same-origin-http-http-wrong-port") << QNetworkRequest::SameOriginRedirectPolicy + << false << QString("http://localhost/%1") << 50 << QNetworkReply::InsecureRedirectError; + QTest::newRow("same-origin-https-https-wrong-port") << QNetworkRequest::SameOriginRedirectPolicy + << true << QString("https://localhost/%1") << 50 << QNetworkReply::InsecureRedirectError; +} + +void tst_QNetworkReply::ioHttpRedirectPolicyErrors() +{ + QFETCH(const QNetworkRequest::RedirectPolicy, policy); + // This should never happen: + QVERIFY(policy != QNetworkRequest::ManualRedirectPolicy); + + QFETCH(const bool, ssl); + QFETCH(const QString, location); + QFETCH(const int, maxRedirects); + QFETCH(const QNetworkReply::NetworkError, expectedError); + +#ifdef QT_NO_SSL + if (ssl || location.contains("https")) + QSKIP("SSL required to run this test"); +#endif + + // Setup the server. + MiniHttpServer server("", ssl); + server.setDataToTransmit(tempRedirectReplyStr().arg(location.arg(server.serverPort())).toLatin1()); + + QUrl url(QLatin1String( +#ifndef QT_NO_SSL + ssl ? "https://localhost" : +#endif + "http://localhost")); + url.setPort(server.serverPort()); + + QNetworkRequest request(url); + request.setMaximumRedirectsAllowed(maxRedirects); + // We always reset the policy to the default one ('Manual') after any related + // test is finished: + QCOMPARE(manager.redirectPolicy(), QNetworkRequest::ManualRedirectPolicy); + manager.setRedirectPolicy(policy); + QCOMPARE(manager.redirectPolicy(), policy); + + QNetworkReplyPtr reply(manager.get(request)); + // Set it back to default: + manager.setRedirectPolicy(QNetworkRequest::ManualRedirectPolicy); + + if (ssl) + reply->ignoreSslErrors(); + + QSignalSpy spy(reply.data(), SIGNAL(error(QNetworkReply::NetworkError))); + + QCOMPARE(waitForFinish(reply), int(Failure)); + QCOMPARE(spy.count(), 1); + QCOMPARE(reply->error(), expectedError); +} + +void tst_QNetworkReply::ioHttpUserVerifiedRedirect_data() +{ + QTest::addColumn<bool>("followRedirect"); + QTest::addColumn<int>("statusCode"); + + QTest::newRow("allow-redirect") << true << 200; + QTest::newRow("reject-redirect") << false << 307; +} + +void tst_QNetworkReply::ioHttpUserVerifiedRedirect() +{ + QFETCH(const bool, followRedirect); + QFETCH(const int, statusCode); + + // Setup HTTP server. + MiniHttpServer target(httpEmpty200Response, false); + QUrl url("http://localhost"); + url.setPort(target.serverPort()); + + MiniHttpServer redirectServer("", false); + redirectServer.setDataToTransmit(tempRedirectReplyStr().arg(QString(url.toEncoded())).toLatin1()); + url.setPort(redirectServer.serverPort()); + + QCOMPARE(manager.redirectPolicy(), QNetworkRequest::ManualRedirectPolicy); + manager.setRedirectPolicy(QNetworkRequest::UserVerifiedRedirectPolicy); + QCOMPARE(manager.redirectPolicy(), QNetworkRequest::UserVerifiedRedirectPolicy); + + QNetworkReplyPtr reply(manager.get(QNetworkRequest(url))); + reply->connect(reply.data(), &QNetworkReply::redirected, + [&](const QUrl &redirectUrl) { + qDebug() << "redirect to:" << redirectUrl; + if (followRedirect) { + qDebug() << "confirmed."; + emit reply->redirectAllowed(); + } else{ + qDebug() << "rejected."; + emit reply->abort(); + } + }); + + // Before any test failed, reset the policy to default: + manager.setRedirectPolicy(QNetworkRequest::ManualRedirectPolicy); + QCOMPARE(manager.redirectPolicy(), QNetworkRequest::ManualRedirectPolicy); + + QSignalSpy finishedSpy(reply.data(), SIGNAL(finished())); + waitForFinish(reply); + QCOMPARE(finishedSpy.count(), 1); + QCOMPARE(reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(), statusCode); +} + #ifndef QT_NO_SSL class PutWithServerClosingConnectionImmediatelyHandler: public QObject @@ -8166,9 +8406,7 @@ signals: void corruptFileUploadReceived(); public slots: - void closeDelayed() { - m_socket->close(); - } + void closeDelayed() { m_socket->close(); } void readyReadSlot() { @@ -8193,17 +8431,18 @@ public slots: // We had received some data but it is corrupt! qDebug() << "CORRUPT" << m_receivedData.count(); - // Use this to track down the pattern of the corruption and conclude the source -// QFile a("/tmp/corrupt"); -// a.open(QIODevice::WriteOnly); -// a.write(m_receivedData); -// a.close(); +#if 0 // Use this to track down the pattern of the corruption and conclude the source + QFile a("/tmp/corrupt"); + a.open(QIODevice::WriteOnly); + a.write(m_receivedData); + a.close(); -// QFile b("/tmp/correct"); -// b.open(QIODevice::WriteOnly); -// b.write(m_expectedData); -// b.close(); + QFile b("/tmp/correct"); + b.open(QIODevice::WriteOnly); + b.write(m_expectedData); + b.close(); //exit(1); +#endif emit corruptFileUploadReceived(); } else { emit correctFileUploadReceived(); @@ -8220,26 +8459,26 @@ public: int m_repliesFinished; int m_expectedReplies; QByteArray m_expectedData; - PutWithServerClosingConnectionImmediatelyServer() : SslServer(), m_correctUploads(0), m_corruptUploads(0), m_repliesFinished(0), m_expectedReplies(0) + PutWithServerClosingConnectionImmediatelyServer() + : SslServer(), m_correctUploads(0), m_corruptUploads(0), + m_repliesFinished(0), m_expectedReplies(0) { QObject::connect(this, SIGNAL(newEncryptedConnection(QSslSocket*)), this, SLOT(createHandlerForConnection(QSslSocket*))); QObject::connect(this, SIGNAL(newPlainConnection(QSslSocket*)), this, SLOT(createHandlerForConnection(QSslSocket*))); } public slots: - void createHandlerForConnection(QSslSocket* s) { + void createHandlerForConnection(QSslSocket* s) + { PutWithServerClosingConnectionImmediatelyHandler *handler = new PutWithServerClosingConnectionImmediatelyHandler(s, m_expectedData); handler->setParent(this); QObject::connect(handler, SIGNAL(correctFileUploadReceived()), this, SLOT(increaseCorrect())); QObject::connect(handler, SIGNAL(corruptFileUploadReceived()), this, SLOT(increaseCorrupt())); } - void increaseCorrect() { - m_correctUploads++; - } - void increaseCorrupt() { - m_corruptUploads++; - } - void replyFinished() { + void increaseCorrect() { m_correctUploads++; } + void increaseCorrupt() { m_corruptUploads++; } + void replyFinished() + { m_repliesFinished++; if (m_repliesFinished == m_expectedReplies) { QTestEventLoop::instance().exitLoop(); diff --git a/tests/auto/network/bearer/qnetworkconfiguration/tst_qnetworkconfiguration.cpp b/tests/auto/network/bearer/qnetworkconfiguration/tst_qnetworkconfiguration.cpp index 82fa5cab9c..9c49e0c173 100644 --- a/tests/auto/network/bearer/qnetworkconfiguration/tst_qnetworkconfiguration.cpp +++ b/tests/auto/network/bearer/qnetworkconfiguration/tst_qnetworkconfiguration.cpp @@ -53,6 +53,7 @@ private slots: void comparison(); void children(); void isRoamingAvailable(); + void connectTimeout(); #endif }; @@ -181,6 +182,21 @@ void tst_QNetworkConfiguration::isRoamingAvailable() } } } + +void tst_QNetworkConfiguration::connectTimeout() +{ + QNetworkConfigurationManager manager; + QList<QNetworkConfiguration> configs = manager.allConfigurations(); + + foreach (QNetworkConfiguration networkConfiguration, configs) { + QCOMPARE(networkConfiguration.connectTimeout(), 30000); + + bool result = networkConfiguration.setConnectTimeout(100); + QVERIFY(result); + + QCOMPARE(networkConfiguration.connectTimeout(), 100); + } +} #endif QTEST_MAIN(tst_QNetworkConfiguration) diff --git a/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp b/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp index a715c38f32..bc3f5650ba 100644 --- a/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp +++ b/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp @@ -274,6 +274,7 @@ void tst_QHostAddress::specialAddresses() QVERIFY(address == QHostAddress(address)); QVERIFY(!(QHostAddress(address) != QHostAddress(address))); QVERIFY(!(QHostAddress(address) != address)); + QVERIFY(!(address != QHostAddress(address))); { QHostAddress ha; diff --git a/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp b/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp index 0c01657956..2671c253cb 100644 --- a/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp +++ b/tests/auto/network/kernel/qhostinfo/tst_qhostinfo.cpp @@ -92,6 +92,10 @@ private slots: void lookupIPv4(); void lookupIPv6_data(); void lookupIPv6(); + void lookupConnectToFunctionPointer_data(); + void lookupConnectToFunctionPointer(); + void lookupConnectToLambda_data(); + void lookupConnectToLambda(); void reverseLookup_data(); void reverseLookup(); @@ -306,6 +310,74 @@ void tst_QHostInfo::lookupIPv6() QCOMPARE(tmp.join(' ').toLower(), expected.join(' ').toLower()); } +void tst_QHostInfo::lookupConnectToFunctionPointer_data() +{ + lookupIPv4_data(); +} + +void tst_QHostInfo::lookupConnectToFunctionPointer() +{ + QFETCH(QString, hostname); + QFETCH(int, err); + QFETCH(QString, addresses); + + lookupDone = false; + QHostInfo::lookupHost(hostname, this, &tst_QHostInfo::resultsReady); + + QTestEventLoop::instance().enterLoop(10); + QVERIFY(!QTestEventLoop::instance().timeout()); + QVERIFY(lookupDone); + + if (int(lookupResults.error()) != int(err)) + qWarning() << hostname << "=>" << lookupResults.errorString(); + QCOMPARE(int(lookupResults.error()), int(err)); + + QStringList tmp; + for (const auto &result : lookupResults.addresses()) + tmp.append(result.toString()); + tmp.sort(); + + QStringList expected = addresses.split(' '); + expected.sort(); + + QCOMPARE(tmp.join(' '), expected.join(' ')); +} + +void tst_QHostInfo::lookupConnectToLambda_data() +{ + lookupIPv4_data(); +} + +void tst_QHostInfo::lookupConnectToLambda() +{ + QFETCH(QString, hostname); + QFETCH(int, err); + QFETCH(QString, addresses); + + lookupDone = false; + QHostInfo::lookupHost(hostname, [=](const QHostInfo &hostInfo) { + resultsReady(hostInfo); + }); + + QTestEventLoop::instance().enterLoop(10); + QVERIFY(!QTestEventLoop::instance().timeout()); + QVERIFY(lookupDone); + + if (int(lookupResults.error()) != int(err)) + qWarning() << hostname << "=>" << lookupResults.errorString(); + QCOMPARE(int(lookupResults.error()), int(err)); + + QStringList tmp; + for (int i = 0; i < lookupResults.addresses().count(); ++i) + tmp.append(lookupResults.addresses().at(i).toString()); + tmp.sort(); + + QStringList expected = addresses.split(' '); + expected.sort(); + + QCOMPARE(tmp.join(' '), expected.join(' ')); +} + void tst_QHostInfo::reverseLookup_data() { QTest::addColumn<QString>("address"); diff --git a/tests/auto/network/kernel/qnetworkdatagram/qnetworkdatagram.pro b/tests/auto/network/kernel/qnetworkdatagram/qnetworkdatagram.pro index a2fe44060e..23d57f3fbf 100644 --- a/tests/auto/network/kernel/qnetworkdatagram/qnetworkdatagram.pro +++ b/tests/auto/network/kernel/qnetworkdatagram/qnetworkdatagram.pro @@ -1,5 +1,4 @@ CONFIG += testcase console -CONFIG -= app_bundle TARGET = tst_qnetworkdatagram SOURCES += tst_qnetworkdatagram.cpp QT = core network testlib diff --git a/tests/auto/network/kernel/qnetworkdatagram/tst_qnetworkdatagram.cpp b/tests/auto/network/kernel/qnetworkdatagram/tst_qnetworkdatagram.cpp index 3295580432..5eedd1043b 100644 --- a/tests/auto/network/kernel/qnetworkdatagram/tst_qnetworkdatagram.cpp +++ b/tests/auto/network/kernel/qnetworkdatagram/tst_qnetworkdatagram.cpp @@ -1,9 +1,9 @@ /**************************************************************************** ** ** Copyright (C) 2016 Intel Corporation. -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the QtNetwork module of the Qt Toolkit. +** This file is part of the test suite of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:GPL-EXCEPT$ ** Commercial License Usage diff --git a/tests/auto/network/kernel/qnetworkinterface/qnetworkinterface.pro b/tests/auto/network/kernel/qnetworkinterface/qnetworkinterface.pro index 694dec2ed7..bbcf60b828 100644 --- a/tests/auto/network/kernel/qnetworkinterface/qnetworkinterface.pro +++ b/tests/auto/network/kernel/qnetworkinterface/qnetworkinterface.pro @@ -1,5 +1,7 @@ CONFIG += testcase TARGET = tst_qnetworkinterface SOURCES += tst_qnetworkinterface.cpp +INCLUDEPATH += ../../../../shared/ +HEADERS += ../../../../shared/emulationdetector.h QT = core network testlib diff --git a/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp b/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp index 594b791938..5695f90c53 100644 --- a/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp +++ b/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp @@ -38,6 +38,7 @@ #include <QNetworkSession> #endif #include "../../../network-settings.h" +#include "emulationdetector.h" class tst_QNetworkInterface : public QObject { @@ -220,6 +221,8 @@ void tst_QNetworkInterface::interfaceFromXXX() QVERIFY(QNetworkInterface::interfaceFromName(iface.name()).isValid()); if (int idx = iface.index()) { QVERIFY(QNetworkInterface::interfaceFromIndex(idx).isValid()); + if (EmulationDetector::isRunningArmOnX86()) + QEXPECT_FAIL("", "SIOCGIFNAME fails on QEMU", Continue); QCOMPARE(QNetworkInterface::interfaceNameFromIndex(idx), iface.name()); QCOMPARE(QNetworkInterface::interfaceIndexFromName(iface.name()), idx); } diff --git a/tests/auto/network/socket/qsctpsocket/tst_qsctpsocket.cpp b/tests/auto/network/socket/qsctpsocket/tst_qsctpsocket.cpp index cf15e60531..89a1430948 100644 --- a/tests/auto/network/socket/qsctpsocket/tst_qsctpsocket.cpp +++ b/tests/auto/network/socket/qsctpsocket/tst_qsctpsocket.cpp @@ -1,31 +1,26 @@ /**************************************************************************** ** ** Copyright (C) 2016 Alex Trotsenko <alex1973tr@gmail.com> -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** 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$ ** diff --git a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp index 1133a80820..9a604e5d04 100644 --- a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp +++ b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp @@ -52,6 +52,13 @@ #include <QtNetwork/qnetworksession.h> #endif +#if defined(Q_OS_LINUX) +#define SHOULD_CHECK_SYSCALL_SUPPORT +#include <netinet/in.h> +#include <sys/socket.h> +#include <errno.h> +#endif + Q_DECLARE_METATYPE(QHostAddress) QT_FORWARD_DECLARE_CLASS(QUdpSocket) @@ -115,6 +122,12 @@ protected slots: void async_readDatagramSlot(); private: + bool shouldSkipIpv6TestsForBrokenSetsockopt(); +#ifdef SHOULD_CHECK_SYSCALL_SUPPORT + bool ipv6SetsockoptionMissing(int level, int optname); +#endif + + bool m_skipUnsupportedIPv6Tests; QList<QHostAddress> allAddresses; #ifndef QT_NO_BEARERMANAGEMENT QNetworkConfigurationManager *netConfMan; @@ -125,6 +138,43 @@ private: QUdpSocket *m_asyncReceiver; }; +#ifdef SHOULD_CHECK_SYSCALL_SUPPORT +bool tst_QUdpSocket::ipv6SetsockoptionMissing(int level, int optname) +{ + int testSocket; + + testSocket = socket(PF_INET6, SOCK_DGRAM, 0); + + // If we can't test here, assume it's not missing + if (testSocket == -1) + return false; + + bool result = false; + if (setsockopt(testSocket, level, optname, nullptr, 0) == -1) + if (errno == ENOPROTOOPT) + result = true; + + close(testSocket); + return result; +} +#endif //SHOULD_CHECK_SYSCALL_SUPPORT + +bool tst_QUdpSocket::shouldSkipIpv6TestsForBrokenSetsockopt() +{ +#ifdef SHOULD_CHECK_SYSCALL_SUPPORT + // Following parameters for setsockopt are not supported by all QEMU versions: + if (ipv6SetsockoptionMissing(SOL_IPV6, IPV6_JOIN_GROUP) + || ipv6SetsockoptionMissing(SOL_IPV6, IPV6_MULTICAST_HOPS) + || ipv6SetsockoptionMissing(SOL_IPV6, IPV6_MULTICAST_IF) + || ipv6SetsockoptionMissing(SOL_IPV6, IPV6_MULTICAST_LOOP) + || ipv6SetsockoptionMissing(SOL_IPV6, IPV6_RECVHOPLIMIT)) { + return true; + } +#endif //SHOULD_CHECK_SYSCALL_SUPPORT + + return false; +} + static QHostAddress makeNonAny(const QHostAddress &address, QHostAddress::SpecialAddress preferForAny = QHostAddress::LocalHost) { if (address == QHostAddress::Any) @@ -176,6 +226,7 @@ void tst_QUdpSocket::initTestCase() if (!QtNetworkSettings::verifyTestNetworkSettings()) QSKIP("No network test server available"); allAddresses = QNetworkInterface::allAddresses(); + m_skipUnsupportedIPv6Tests = shouldSkipIpv6TestsForBrokenSetsockopt(); } void tst_QUdpSocket::init() @@ -1140,6 +1191,13 @@ void tst_QUdpSocket::multicastTtlOption() expected = 0; } + // Some syscalls needed for ipv6 udp multicasting are not functional + if (m_skipUnsupportedIPv6Tests) { + if (bindAddress.protocol() == QAbstractSocket::IPv6Protocol) { + QSKIP("Syscalls needed for ipv6 udp multicasting missing functionality"); + } + } + QUdpSocket udpSocket; #ifdef FORCE_SESSION udpSocket.setProperty("_q_networksession", QVariant::fromValue(networkSession)); @@ -1186,6 +1244,13 @@ void tst_QUdpSocket::multicastLoopbackOption() expected = 0; } + // Some syscalls needed for ipv6 udp multicasting are not functional + if (m_skipUnsupportedIPv6Tests) { + if (bindAddress.protocol() == QAbstractSocket::IPv6Protocol) { + QSKIP("Syscalls needed for ipv6 udp multicasting missing functionality"); + } + } + QUdpSocket udpSocket; #ifdef FORCE_SESSION udpSocket.setProperty("_q_networksession", QVariant::fromValue(networkSession)); @@ -1240,6 +1305,13 @@ void tst_QUdpSocket::multicastLeaveAfterClose() if (!QtNetworkSettings::hasIPv6() && groupAddress.protocol() == QAbstractSocket::IPv6Protocol) QSKIP("system doesn't support ipv6!"); + // Some syscalls needed for ipv6 udp multicasting are not functional + if (m_skipUnsupportedIPv6Tests) { + if (groupAddress.protocol() == QAbstractSocket::IPv6Protocol) { + QSKIP("Syscalls needed for ipv6 udp multicasting missing functionality"); + } + } + QUdpSocket udpSocket; #ifdef FORCE_SESSION udpSocket.setProperty("_q_networksession", QVariant::fromValue(networkSession)); @@ -1280,6 +1352,11 @@ void tst_QUdpSocket::setMulticastInterface() QFETCH(QNetworkInterface, iface); QFETCH(QHostAddress, address); + // Some syscalls needed for udp multicasting are not functional + if (m_skipUnsupportedIPv6Tests) { + QSKIP("Syscalls needed for udp multicasting missing functionality"); + } + QUdpSocket udpSocket; // bind initializes the socket bool bound = udpSocket.bind((address.protocol() == QAbstractSocket::IPv6Protocol @@ -1339,6 +1416,13 @@ void tst_QUdpSocket::multicast() return; } + // Some syscalls needed for ipv6 udp multicasting are not functional + if (m_skipUnsupportedIPv6Tests) { + if (groupAddress.protocol() == QAbstractSocket::IPv6Protocol) { + QSKIP("Syscalls needed for ipv6 udp multicasting missing functionality"); + } + } + QUdpSocket receiver; #ifdef FORCE_SESSION receiver.setProperty("_q_networksession", QVariant::fromValue(networkSession)); diff --git a/tests/auto/network/ssl/qssldiffiehellmanparameters/tst_qssldiffiehellmanparameters.cpp b/tests/auto/network/ssl/qssldiffiehellmanparameters/tst_qssldiffiehellmanparameters.cpp index ddf503eed6..60add4a51c 100644 --- a/tests/auto/network/ssl/qssldiffiehellmanparameters/tst_qssldiffiehellmanparameters.cpp +++ b/tests/auto/network/ssl/qssldiffiehellmanparameters/tst_qssldiffiehellmanparameters.cpp @@ -1,11 +1,11 @@ /**************************************************************************** ** ** Copyright (C) 2015 Mikkel Krautz <mikkel@krautz.dk> -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the QtNetwork module of the Qt Toolkit. +** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL$ +** $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 @@ -14,24 +14,13 @@ ** 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 +** 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-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. +** be met: https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** diff --git a/tests/auto/network/ssl/qsslsocket/BLACKLIST b/tests/auto/network/ssl/qsslsocket/BLACKLIST index 52c023b78f..cfab0b7eb0 100644 --- a/tests/auto/network/ssl/qsslsocket/BLACKLIST +++ b/tests/auto/network/ssl/qsslsocket/BLACKLIST @@ -5,3 +5,5 @@ windows rhel-7.2 [protocolServerSide:tls1.0-any] rhel-7.2 +[protocolServerSide] +osx-10.11 diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp index 8a8522760c..f9ca119d1b 100644 --- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp @@ -29,6 +29,7 @@ #include <QtCore/qglobal.h> #include <QtCore/qthread.h> +#include <QtCore/qoperatingsystemversion.h> #include <QtNetwork/qhostaddress.h> #include <QtNetwork/qhostinfo.h> #include <QtNetwork/qnetworkproxy.h> @@ -1166,6 +1167,19 @@ void tst_QSslSocket::protocolServerSide_data() QTest::addColumn<QSsl::SslProtocol>("clientProtocol"); QTest::addColumn<bool>("works"); + // On macOS 10.11 with SecureTransport backend some tests are failing for no + // obvious reason (so no bug in our code): QTBUG-48860 - an error can be + // errSSLInternal or cipher negotiation failure. This problem does not exist + // on macOS before 10.11 and after 10.11, so we adjust these tests only for 10.11. + +#if defined(QT_SECURETRANSPORT) + using OSVersion = QOperatingSystemVersion; + const bool testWorks = OSVersion::current() < OSVersion::OSXElCapitan + || OSVersion::current() > OSVersion::OSXElCapitan; +#else + const bool testWorks = true; +#endif + #if !defined(OPENSSL_NO_SSL2) && !defined(QT_SECURETRANSPORT) QTest::newRow("ssl2-ssl2") << QSsl::SslV2 << QSsl::SslV2 << false; // no idea why it does not work, but we don't care about SSL 2 #endif @@ -1190,14 +1204,14 @@ void tst_QSslSocket::protocolServerSide_data() #endif #if !defined(OPENSSL_NO_SSL3) QTest::newRow("ssl3-tls1.0") << QSsl::SslV3 << QSsl::TlsV1_0 << false; - QTest::newRow("ssl3-tls1ssl3") << QSsl::SslV3 << QSsl::TlsV1SslV3 << true; + QTest::newRow("ssl3-tls1ssl3") << QSsl::SslV3 << QSsl::TlsV1SslV3 << testWorks; QTest::newRow("ssl3-secure") << QSsl::SslV3 << QSsl::SecureProtocols << false; #endif #if !defined(OPENSSL_NO_SSL2) && !defined(QT_SECURETRANSPORT) && !defined(OPENSSL_NO_SSL3) QTest::newRow("ssl3-any") << QSsl::SslV3 << QSsl::AnyProtocol << false; // we won't set a SNI header here because we connect to a // numerical IP, so OpenSSL will send a SSL 2 handshake #elif !defined(OPENSSL_NO_SSL3) - QTest::newRow("ssl3-any") << QSsl::SslV3 << QSsl::AnyProtocol << true; + QTest::newRow("ssl3-any") << QSsl::SslV3 << QSsl::AnyProtocol << testWorks; #endif #if !defined(OPENSSL_NO_SSL2) && !defined(QT_SECURETRANSPORT) diff --git a/tests/auto/opengl/qgl/tst_qgl.cpp b/tests/auto/opengl/qgl/tst_qgl.cpp index af0248b432..7dfa8e4e22 100644 --- a/tests/auto/opengl/qgl/tst_qgl.cpp +++ b/tests/auto/opengl/qgl/tst_qgl.cpp @@ -1169,6 +1169,10 @@ void tst_QGL::currentFboSync() QGLWidget glw; glw.makeCurrent(); + // For some reason we offer inter-operatibility between QGL and QOpenGL + // paint engines. (?!) Let's check if the two engines can be used to perform + // drawing in turns on different targets within the same context. + { QGLFramebufferObject fbo1(256, 256, QGLFramebufferObject::CombinedDepthStencil); @@ -1191,7 +1195,9 @@ void tst_QGL::currentFboSync() QGLFramebufferObject::bindDefault(); - QCOMPARE(fbo1.toImage(), fbo2Image); + // Convert the QGLFBO's result since QOpenGLFBO uses a wider + // variety of possible return formats. + QCOMPARE(fbo1.toImage().convertToFormat(fbo2Image.format()), fbo2Image); } { diff --git a/tests/auto/other/atwrapper/.gitignore b/tests/auto/other/atwrapper/.gitignore deleted file mode 100644 index 162ad53af6..0000000000 --- a/tests/auto/other/atwrapper/.gitignore +++ /dev/null @@ -1 +0,0 @@ -tst_atwrapper diff --git a/tests/auto/other/atwrapper/TODO b/tests/auto/other/atwrapper/TODO deleted file mode 100644 index 23a70c3c9e..0000000000 --- a/tests/auto/other/atwrapper/TODO +++ /dev/null @@ -1,17 +0,0 @@ -* Get rid of "Keep baseline" on test failure page (Lars) !! DONE !! -* Make to autotest (Simon) !! DONE !! -* Add visual diff (Everyone ;)) !! DONE !! -* Add flicker (Simon/Jesper) !! DONE !! -* Add third image -- base-baseline (Lars) !! DONE !! -* Add "view baselines" gallery, including the "base base line" (Lars) !! DONE !! -* Add PS printer driver engine test thingy (Eskil) !! DONE !! -* Add platform by platform comparison perl script. (Morton) -* Fix the QDateTime.fromString() weirdness on win32 in xmldata.cpp (Jesper) -* Have one result per page view (Lars) !! DONE !! -* Have "platform - hostname" on test overview (Lars) !! DONE !! -* Have the links on the overview page only show failures for that host.(All)!! DONE !! -* "onion skin" diff. (Jesper) -* Promote all to baseline -* Switch all to flicker/onion/whatever -* Add javascript confirmation for "make baseline" -* Make "single view" more stable diff --git a/tests/auto/other/atwrapper/atWrapper.cpp b/tests/auto/other/atwrapper/atWrapper.cpp deleted file mode 100644 index 8f623538f9..0000000000 --- a/tests/auto/other/atwrapper/atWrapper.cpp +++ /dev/null @@ -1,636 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ - - -#include <atWrapper.h> -#include <datagenerator/datagenerator.h> - -#include <QString> -#include <QHash> -#include <QFile> -#include <QFtp> -#include <QObject> -#include <QHostInfo> -#include <QWidget> -#include <QImage> -#include <QtTest/QSignalSpy> -#include <QLibraryInfo> - -static const char *ArthurDir = "../../arthur"; - -#include <string.h> - -atWrapper::atWrapper() -{ - - // initTests(); - -} - -bool atWrapper::initTests(bool *haveBaseline) -{ - qDebug() << "Running test on buildkey:" << QLibraryInfo::buildKey() << " qt version:" << qVersion(); - - qDebug( "Initializing tests..." ); - - if (!loadConfig( QHostInfo::localHostName().split( "." ).first() + ".ini" )) - return false; - - //Reset the FTP environment where the results are stored - *haveBaseline = setupFTP(); - - // Retrieve the latest test result baseline from the FTP server. - downloadBaseline(); - return true; -} - -void atWrapper::downloadBaseline() -{ - - qDebug() << "Now downloading baseline..."; - - QFtp ftp; - - QObject::connect( &ftp, SIGNAL(listInfo(QUrlInfo)), this, SLOT(ftpMgetAddToList(QUrlInfo)) ); - - //Making sure that the needed local directories exist. - - QHashIterator<QString, QString> j(enginesToTest); - - while ( j.hasNext() ) - { - j.next(); - - QDir dir( output ); - - if ( !dir.cd( j.key() + ".baseline" ) ) - dir.mkdir( j.key() + ".baseline" ); - - } - - //FTP to the host specified in the config file, and retrieve the test result baseline. - ftp.connectToHost( ftpHost ); - ftp.login( ftpUser, ftpPass ); - - ftp.cd( ftpBaseDir ); - - QHashIterator<QString, QString> i(enginesToTest); - while ( i.hasNext() ) - { - i.next(); - mgetDirList.clear(); - mgetDirList << i.key() + ".baseline"; - ftp.cd( i.key() + ".baseline" ); - ftp.list(); - ftp.cd( ".." ); - - while ( ftp.hasPendingCommands() ) - QCoreApplication::instance()->processEvents(); - - ftpMgetDone( true ); - } - - ftp.close(); - ftp.close(); - - while ( ftp.hasPendingCommands() ) - QCoreApplication::instance()->processEvents(); - -} - -void atWrapper::ftpMgetAddToList( const QUrlInfo &urlInfo ) -{ - //Simply adding to the list of files to download. - mgetDirList << urlInfo.name(); - -} - -void atWrapper::ftpMgetDone( bool error) -{ - Q_UNUSED( error ); - - //Downloading the files listed in mgetDirList... - QFtp ftp; - ftp.connectToHost( ftpHost ); - ftp.login( ftpUser, ftpPass ); - - QFile* file; - - if ( mgetDirList.size() > 1 ) - for ( int i = 1; i < mgetDirList.size(); ++i ) - { - file = new QFile( QString( output ) + QLatin1Char('/') + mgetDirList.at( 0 ) - + QLatin1Char('/') + mgetDirList.at( i ) ); - if (file->open(QIODevice::WriteOnly)) { - ftp.get( ftpBaseDir + QLatin1Char('/') + mgetDirList.at( 0 ) + QLatin1Char('/') + mgetDirList.at( i ), file ); - ftp.list(); //Only there to fill up a slot in the pendingCommands queue. - while ( ftp.hasPendingCommands() ) - QCoreApplication::instance()->processEvents(); - file->close(); - } else { - qDebug() << "Couldn't open file for writing: " << file->fileName(); - } - } - - - while ( ftp.hasPendingCommands() ) - QCoreApplication::instance()->processEvents(); -} - -void atWrapper::uploadFailed( QString dir, QString filename, QByteArray filedata ) -{ - //Upload a failed test case image to the FTP server. - QFtp ftp; - ftp.connectToHost( ftpHost ); - ftp.login( ftpUser, ftpPass ); - - ftp.cd( ftpBaseDir ); - ftp.cd( dir ); - - ftp.put( filedata, filename, QFtp::Binary ); - - ftp.close(); - - while ( ftp.hasPendingCommands() ) - QCoreApplication::instance()->processEvents(); -} - -// returns false if no baseline exists -bool atWrapper::setupFTP() -{ - qDebug( "Setting up FTP environment" ); - - QString dir = ""; - ftpMkDir( ftpBaseDir ); - - ftpBaseDir += QLatin1Char('/') + QLibraryInfo::buildKey(); - - ftpMkDir( ftpBaseDir ); - - ftpBaseDir += QLatin1Char('/') + QString( qVersion() ); - - ftpMkDir( ftpBaseDir ); - - QHashIterator<QString, QString> i(enginesToTest); - QHashIterator<QString, QString> j(enginesToTest); - - bool haveBaseline = true; - //Creating the baseline directories for each engine - while ( i.hasNext() ) - { - i.next(); - //qDebug() << "Creating dir with key:" << i.key(); - ftpMkDir( ftpBaseDir + QLatin1Char('/') + QString( i.key() ) + ".failed" ); - ftpMkDir( ftpBaseDir + QLatin1Char('/') + QString( i.key() ) + ".diff" ); - if (!ftpMkDir( ftpBaseDir + QLatin1Char('/') + QString( i.key() ) + ".baseline" )) - haveBaseline = false; - } - - - QFtp ftp; - ftp.connectToHost( ftpHost ); - ftp.login( ftpUser, ftpPass ); - - ftp.cd( ftpBaseDir ); - //Deleting previous failed directory and all the files in it, then recreating it. - while ( j.hasNext() ) - { - j.next(); - rmDirList.clear(); - rmDirList << ftpBaseDir + QLatin1Char('/') + j.key() + ".failed/"; - ftpRmDir( j.key() + ".failed" ); - ftp.rmdir( j.key() + ".failed" ); - ftp.mkdir( j.key() + ".failed" ); - ftp.list(); - - while ( ftp.hasPendingCommands() ) - QCoreApplication::instance()->processEvents(); - - rmDirList.clear(); - rmDirList << ftpBaseDir + QLatin1Char('/') + j.key() + ".diff/"; - ftpRmDir( j.key() + ".diff" ); - ftp.rmdir( j.key() + ".diff" ); - ftp.mkdir( j.key() + ".diff" ); - ftp.list(); - - while ( ftp.hasPendingCommands() ) - QCoreApplication::instance()->processEvents(); - - } - - ftp.close(); - - while ( ftp.hasPendingCommands() ) - QCoreApplication::instance()->processEvents(); - - return haveBaseline; -} - -void atWrapper::ftpRmDir( QString dir ) -{ - //Hack to remove a populated directory. (caveat: containing only files and empty dirs, not recursive!) - qDebug() << "Now removing directory: " << dir; - QFtp ftp; - QObject::connect( &ftp, SIGNAL(listInfo(QUrlInfo)), this, SLOT(ftpRmDirAddToList(QUrlInfo)) ); - QObject::connect( &ftp, SIGNAL(done(bool)), this, SLOT(ftpRmDirDone(bool)) ); - - ftp.connectToHost( ftpHost ); - ftp.login( ftpUser, ftpPass ); - - ftp.list( ftpBaseDir + "/" + dir ); - ftp.close(); - ftp.close(); - - while ( ftp.hasPendingCommands() ) - QCoreApplication::instance()->processEvents(); -} - -void atWrapper::ftpRmDirDone( bool error ) -{ - //Deleting each file in the directory listning, rmDirList. - Q_UNUSED( error ); - - QFtp ftp; - ftp.connectToHost( ftpHost ); - ftp.login( ftpUser, ftpPass ); - - if ( rmDirList.size() > 1 ) - for (int i = 1; i < rmDirList.size(); ++i) - ftp.remove( rmDirList.at(0) + rmDirList.at( i ) ); - - ftp.close(); - - while ( ftp.hasPendingCommands() ) - QCoreApplication::instance()->processEvents(); -} - -// returns false if the directory already exists -bool atWrapper::ftpMkDir( QString dir ) -{ - //Simply used to avoid QFTP from bailing out and loosing a queue of commands. - // IE: conveniance. - QFtp ftp; - - QSignalSpy commandSpy(&ftp, SIGNAL(commandFinished(int,bool))); - - ftp.connectToHost( ftpHost ); - ftp.login( ftpUser, ftpPass ); - const int command = ftp.mkdir( dir ); - ftp.close(); - - while ( ftp.hasPendingCommands() ) - QCoreApplication::instance()->processEvents(); - - for (int i = 0; i < commandSpy.count(); ++i) - if (commandSpy.at(i).at(0) == command) - return commandSpy.at(i).at(1).toBool(); - - return false; -} - - -void atWrapper::ftpRmDirAddToList( const QUrlInfo &urlInfo ) -{ - //Just adding the file to the list for deletion - rmDirList << urlInfo.name(); -} - - -bool atWrapper::executeTests() -{ - qDebug("Executing the tests..."); - - QHashIterator<QString, QString> i(enginesToTest); - - DataGenerator generator; - - //Running datagenerator against all the frameworks specified in the config file. - while ( i.hasNext() ) - { - - i.next(); - - qDebug( "Now testing: " + i.key().toLatin1() ); - - char* params[13]; - //./bin/datagenerator -framework data/framework.ini -engine OpenGL -suite 1.1 -output outtest - - - QByteArray eng = i.key().toLatin1(); - QByteArray fwk = framework.toLatin1(); - QByteArray sut = suite.toLatin1(); - QByteArray out = output.toLatin1(); - QByteArray siz = size.toLatin1(); - QByteArray fill = fillColor.toLatin1(); - - params[1] = "-framework"; - params[2] = fwk.data(); - params[3] = "-engine"; - params[4] = eng.data(); - params[5] = "-suite"; - params[6] = sut.data(); - params[7] = "-output"; - params[8] = out.data(); - params[9] = "-size"; - params[10] = siz.data(); - params[11] = "-fill"; - params[12] = fill.data(); - - generator.run( 13, params ); - } - - return true; -} - -void atWrapper::createBaseline() -{ - qDebug( "Now uploading a baseline of only the latest test values" ); - - QHashIterator<QString, QString> i(enginesToTest); - - QDir dir( output ); - QFtp ftp; - ftp.connectToHost( ftpHost ); - ftp.login( ftpUser, ftpPass ); - ftp.cd( ftpBaseDir ); - //Upload all the latest test results to the FTP server's baseline directory. - while ( i.hasNext() ) - { - - i.next(); - dir.cd( i.key() ); - ftp.cd( i.key() + ".baseline" ); - dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks); - dir.setNameFilters( QStringList() << "*.png" ); - QFileInfoList list = dir.entryInfoList(); - dir.cd( ".." ); - for (int n = 0; n < list.size(); n++) - { - QFileInfo fileInfo = list.at( n ); - QFile file( QString( output ) + QLatin1Char('/') + i.key() + QLatin1Char('/') + fileInfo.fileName() ); - file.open( QIODevice::ReadOnly ); - QByteArray fileData = file.readAll(); - //qDebug() << "Sending up:" << fileInfo.fileName() << "with file size" << fileData.size(); - file.close(); - ftp.put( fileData, fileInfo.fileName(), QFtp::Binary ); - } - - ftp.cd( ".." ); - } - - ftp.close(); - - while ( ftp.hasPendingCommands() ) - QCoreApplication::instance()->processEvents(); -} - -bool atWrapper::compare() -{ - qDebug( "Now comparing the results to the baseline" ); - - QHashIterator<QString, QString> i(enginesToTest); - - while ( i.hasNext() ) - { - i.next(); - - compareDirs( output , i.key() ); - - } - - return true; -} - -void atWrapper::compareDirs( QString basedir, QString target ) -{ - - QDir dir( basedir ); - - /* The following should be redundant now. - - if ( !dir.cd( target + ".failed" ) ) - dir.mkdir( target + ".failed" ); - else - dir.cdUp(); - - */ - - if ( !dir.cd( target + ".diff" ) ) - dir.mkdir( target + ".diff" ); - else - dir.cdUp(); - - - - //Perform comparisons between the two directories. - - dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks); - dir.setNameFilters( QStringList() << "*.png" ); - dir.cd( target + ".baseline" ); - QFileInfoList list = dir.entryInfoList(); - - for (int i = 0; i < list.size(); ++i) - { - QFileInfo fileInfo = list.at(i); - diff ( basedir, target, fileInfo.fileName() ); - } -} - -bool atWrapper::diff( QString basedir, QString dir, QString target ) -{ - //Comparing the two specified files, and then uploading them to - //the ftp server if they differ - - basedir += QLatin1Char('/') + dir; - QString one = basedir + ".baseline/" + target; - QString two = basedir + QLatin1Char('/') + target; - - QFile file( one ); - - file.open( QIODevice::ReadOnly ); - QByteArray contentsOfOne = file.readAll(); - file.close(); - - file.setFileName( two ); - - file.open( QIODevice::ReadOnly ); - QByteArray contentsOfTwo = file.readAll(); - file.close(); - - if ( contentsOfTwo.size() == 0 ) - { - qDebug() << "No test result found for baseline: " << one; - file.setFileName( one ); - file.open( QIODevice::ReadOnly ); - file.copy( basedir + ".failed/" + target + "_missing" ); - uploadFailed( dir + ".failed", target + "_missing", contentsOfTwo ); - return false; - } - - - if ( ( memcmp( contentsOfOne, contentsOfTwo, contentsOfOne.size() ) ) == 0 ) - return true; - else - { - qDebug() << "Sorry, the result did not match: " << one; - file.setFileName( two ); - file.open( QIODevice::ReadOnly ); - file.copy( basedir + ".failed/" + target ); - file.close(); - uploadFailed( dir + ".failed", target, contentsOfTwo ); - uploadDiff( basedir, dir, target ); - return false; - } -} - -void atWrapper::uploadDiff( QString basedir, QString dir, QString filename ) -{ - - qDebug() << basedir; - QImage im1( basedir + ".baseline/" + filename ); - QImage im2( basedir + QLatin1Char('/') + filename ); - - QImage im3(im1.size(), QImage::Format_ARGB32); - - im1 = im1.convertToFormat(QImage::Format_ARGB32); - im2 = im2.convertToFormat(QImage::Format_ARGB32); - - for ( int y=0; y<im1.height(); ++y ) - { - uint *s = (uint *) im1.scanLine(y); - uint *d = (uint *) im2.scanLine(y); - uint *w = (uint *) im3.scanLine(y); - - for ( int x=0; x<im1.width(); ++x ) - { - if (*s != *d) - *w = 0xff000000; - else - *w = 0xffffffff; - w++; - s++; - d++; - } - } - - im3.save( basedir + ".diff/" + filename ,"PNG"); - - QFile file( basedir + ".diff/" + filename ); - file.open( QIODevice::ReadOnly ); - QByteArray contents = file.readAll(); - file.close(); - - uploadFailed( dir + ".diff", filename, contents ); - -} - -bool atWrapper::loadConfig( QString path ) -{ - qDebug() << "Loading config file from ... " << path; - configPath = path; - //If there is no config file, don't proceed; - if ( !QFile::exists( path ) ) - { - return false; - } - - - QSettings settings( path, QSettings::IniFormat, this ); - - - //FIXME: Switch to QStringList or something, hash is not needed! - int numEngines = settings.beginReadArray("engines"); - - for ( int i = 0; i < numEngines; ++i ) - { - settings.setArrayIndex(i); - enginesToTest.insert( settings.value( "engine" ).toString(), "Info here please :p" ); - } - - settings.endArray(); - - framework = QString(ArthurDir) + QDir::separator() + settings.value( "framework" ).toString(); - suite = settings.value( "suite" ).toString(); - output = settings.value( "output" ).toString(); - size = settings.value( "size", "480,360" ).toString(); - fillColor = settings.value( "fill", "white" ).toString(); - ftpUser = settings.value( "ftpUser" ).toString(); - ftpPass = settings.value( "ftpPass" ).toString(); - ftpHost = settings.value( "ftpHost" ).toString(); - ftpBaseDir = settings.value( "ftpBaseDir" ).toString(); - - - QDir::current().mkdir( output ); - - output += QLatin1Char('/') + QLibraryInfo::buildKey(); - - QDir::current().mkdir( output ); - - output += QLatin1Char('/') + QString( qVersion() ); - - QDir::current().mkdir( output ); - - - ftpBaseDir += QLatin1Char('/') + QHostInfo::localHostName().split( QLatin1Char('.') ).first(); - - -/* - framework = "data/framework.ini"; - suite = "1.1"; - output = "testresults"; - ftpUser = "anonymous"; - ftpPass = "anonymouspass"; - ftpHost = "kramer.troll.no"; - ftpBaseDir = "/arthurtest"; -*/ - return true; -} - -bool atWrapper::runAutoTests() -{ - //SVG needs this widget... - QWidget dummy; - - bool haveBaseline = false; - - if (!initTests(&haveBaseline)) - return false; - executeTests(); - - if ( !haveBaseline ) - { - qDebug( " First run! Creating baseline..." ); - createBaseline(); - } - else - { - qDebug( " Comparing results..." ); - compare(); - } - return true; -} diff --git a/tests/auto/other/atwrapper/atWrapper.h b/tests/auto/other/atwrapper/atWrapper.h deleted file mode 100644 index dab2b579e3..0000000000 --- a/tests/auto/other/atwrapper/atWrapper.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ -#ifndef ATWRAPPER_H -#define ATWRAPPER_H - -#include <QHash> -#include <QString> -#include <QUrlInfo> -#include <QColor> - -class atWrapper : public QObject -{ - Q_OBJECT - - public: - atWrapper(); - bool runAutoTests(); - - private: - bool executeTests(); - bool initTests(bool *haveBaseline); - bool compare(); - void createBaseline(); - bool loadConfig( QString ); - void compareDirs( QString, QString ); - bool diff( QString, QString, QString ); - void downloadBaseline(); - void uploadFailed( QString, QString, QByteArray ); - bool ftpMkDir( QString ); - void ftpRmDir( QString ); - bool setupFTP(); - void uploadDiff( QString, QString, QString ); - - QHash<QString, QString> enginesToTest; - QString framework; - QString suite; - QString output; - QString size; - QString ftpUser; - QString ftpPass; - QString ftpHost; - QString ftpBaseDir; - QList<QString> rmDirList; - QList<QString> mgetDirList; - QString configPath; - QString fillColor; - - private slots: - void ftpRmDirAddToList( const QUrlInfo &urlInfo ); - void ftpRmDirDone( bool ); - void ftpMgetAddToList( const QUrlInfo &urlInfo ); - void ftpMgetDone( bool ); -}; - -#endif diff --git a/tests/auto/other/atwrapper/atWrapper.pro b/tests/auto/other/atwrapper/atWrapper.pro deleted file mode 100644 index 1617ae89d1..0000000000 --- a/tests/auto/other/atwrapper/atWrapper.pro +++ /dev/null @@ -1,21 +0,0 @@ -ARTHUR=$$QT_SOURCE_TREE/tests/arthur -COMMON_FOLDER = $$ARTHUR/common -include($$ARTHUR/arthurtester.pri) -INCLUDEPATH += $$ARTHUR -DEFINES += SRCDIR=\\\"$$PWD\\\" - -QT += xml svg network testlib - -qtHaveModule(opengl): QT += opengl - -include($$ARTHUR/datagenerator/datagenerator.pri) - -CONFIG += testcase - -HEADERS += atWrapper.h -SOURCES += atWrapperAutotest.cpp atWrapper.cpp - -TARGET = tst_atwrapper - -#include($$COMMON_FOLDER/common.pri) -DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/other/atwrapper/desert.ini b/tests/auto/other/atwrapper/desert.ini deleted file mode 100644 index 6d8605252d..0000000000 --- a/tests/auto/other/atwrapper/desert.ini +++ /dev/null @@ -1,14 +0,0 @@ -[General] -framework=data/framework.ini -ftpBaseDir=/arthurtest -ftpHost=kramer.troll.no -ftpPass=anonymouspass -ftpUser=anonymous -output=testresults -suite=1.1 - -[engines] -1\engine=NativeXRender -2\engine=PDF -3\engine=Raster -size=3 diff --git a/tests/auto/other/atwrapper/ephron.ini b/tests/auto/other/atwrapper/ephron.ini deleted file mode 100644 index eeccb3b6ef..0000000000 --- a/tests/auto/other/atwrapper/ephron.ini +++ /dev/null @@ -1,14 +0,0 @@ -[General] -framework=data/framework.ini -ftpBaseDir=/arthurtest -ftpHost=kramer.troll.no -ftpPass=anonymouspass -ftpUser=anonymous -output=testresults -suite=oxygen -size=256 -fill=transparent - -[engines] -1\engine=Raster -size=1 diff --git a/tests/auto/other/atwrapper/gullgubben.ini b/tests/auto/other/atwrapper/gullgubben.ini deleted file mode 100644 index 3a664dddd5..0000000000 --- a/tests/auto/other/atwrapper/gullgubben.ini +++ /dev/null @@ -1,12 +0,0 @@ -[General] -framework=data/framework.ini -ftpBaseDir=/arthurtest -ftpHost=kramer.troll.no -ftpPass=anonymouspass -ftpUser=anonymous -output=testresults -suite=1.1 - -[engines] -1\engine=OpenGL -size=1 diff --git a/tests/auto/other/atwrapper/honshu.ini b/tests/auto/other/atwrapper/honshu.ini deleted file mode 100644 index 3b7751a128..0000000000 --- a/tests/auto/other/atwrapper/honshu.ini +++ /dev/null @@ -1,16 +0,0 @@ -[General] -framework=data/framework.ini -ftpBaseDir=/arthurtest -ftpHost=kramer.troll.no -ftpPass=anonymouspass -ftpUser=anonymous -output=testresults -suite=1.1 - -[engines] -1\engine=NativeWin32 -2\engine=PDF -3\engine=Raster -4\engine=OpenGL -5\engine=WinPrint -size=5 diff --git a/tests/auto/other/atwrapper/kramer.ini b/tests/auto/other/atwrapper/kramer.ini deleted file mode 100644 index 289d8a8b7e..0000000000 --- a/tests/auto/other/atwrapper/kramer.ini +++ /dev/null @@ -1,12 +0,0 @@ -[General] -framework=data/framework.ini -ftpBaseDir=/arthurtest -ftpHost=kramer.troll.no -ftpPass=anonymouspass -ftpUser=anonymous -output=testresults -suite=1.1 - -[engines] -1\engine=Raster -size=1 diff --git a/tests/auto/other/atwrapper/scruffy.ini b/tests/auto/other/atwrapper/scruffy.ini deleted file mode 100644 index 329f537e6f..0000000000 --- a/tests/auto/other/atwrapper/scruffy.ini +++ /dev/null @@ -1,15 +0,0 @@ -[General] -framework=data/framework.ini -ftpBaseDir=/arthurtest -ftpHost=kramer.nokia.troll.no -ftpPass=anonymouspass -ftpUser=anonymous -output=testresults -suite=1.1 - -[engines] -1\engine=NativeMac -2\engine=PDF -3\engine=Raster -4\engine=OpenGL -size=4 diff --git a/tests/auto/other/atwrapper/spareribs.ini b/tests/auto/other/atwrapper/spareribs.ini deleted file mode 100644 index 78ff9e985f..0000000000 --- a/tests/auto/other/atwrapper/spareribs.ini +++ /dev/null @@ -1,14 +0,0 @@ -[General] -framework=data/framework.ini -ftpBaseDir=/arthurtest -ftpHost=kramer.troll.no -ftpPass=anonymouspass -ftpUser=anonymous -output=testresults -suite=1.1 - -[engines] -1\engine=NativeWin32 -2\engine=PDF -3\engine=Raster -size=3 diff --git a/tests/auto/other/atwrapper/titan.ini b/tests/auto/other/atwrapper/titan.ini deleted file mode 100644 index 3a0b0dfd31..0000000000 --- a/tests/auto/other/atwrapper/titan.ini +++ /dev/null @@ -1,13 +0,0 @@ -[General] -framework=data/framework.ini -ftpBaseDir=/arthurtest -ftpHost=kramer.troll.no -ftpPass=anonymouspass -ftpUser=anonymous -output=testresults -suite=1.1 - -[engines] -1\engine=NativeXRender -2\engine=OpenGL -size=2 diff --git a/tests/auto/other/lancelot/lancelot.pro b/tests/auto/other/lancelot/lancelot.pro index b492611ca7..73c12e67a2 100644 --- a/tests/auto/other/lancelot/lancelot.pro +++ b/tests/auto/other/lancelot/lancelot.pro @@ -1,5 +1,4 @@ CONFIG += testcase -CONFIG -= app_bundle TARGET = tst_lancelot QT += testlib diff --git a/tests/auto/other/lancelot/paintcommands.cpp b/tests/auto/other/lancelot/paintcommands.cpp index 2e6cb09aa5..c28812e120 100644 --- a/tests/auto/other/lancelot/paintcommands.cpp +++ b/tests/auto/other/lancelot/paintcommands.cpp @@ -263,7 +263,7 @@ void PaintCommands::staticInit() "path_setFillRule pathName Winding"); DECL_PAINTCOMMAND("setBrush", command_setBrush, "^setBrush\\s+(#?[\\w.:\\/]*)\\s*(\\w*)?$", - "setBrush <pixmapFileName>\nsetBrush noBrush\nsetBrush <color> <brush style enum>", + "setBrush <imageFileName>\nsetBrush noBrush\nsetBrush <color> <brush style enum>", "setBrush white SolidPattern"); DECL_PAINTCOMMAND("setBrushOrigin", command_setBrushOrigin, "^setBrushOrigin\\s*(-?\\w*)\\s+(-?\\w*)$", @@ -1752,13 +1752,13 @@ void PaintCommands::command_setBrush(QRegExp re) { QStringList caps = re.capturedTexts(); - QPixmap pm = image_load<QPixmap>(caps.at(1)); - if (!pm.isNull()) { // Assume pixmap + QImage img = image_load<QImage>(caps.at(1)); + if (!img.isNull()) { // Assume image brush if (m_verboseMode) - printf(" -(lance) setBrush(pixmap=%s, width=%d, height=%d)\n", - qPrintable(caps.at(1)), pm.width(), pm.height()); + printf(" -(lance) setBrush(image=%s, width=%d, height=%d)\n", + qPrintable(caps.at(1)), img.width(), img.height()); - m_painter->setBrush(QBrush(pm)); + m_painter->setBrush(QBrush(img)); } else if (caps.at(1).toLower() == "nobrush") { m_painter->setBrush(Qt::NoBrush); if (m_verboseMode) @@ -2378,6 +2378,8 @@ void PaintCommands::command_surface_begin(QRegExp re) #ifndef QT_NO_OPENGL m_default_glcontext = QOpenGLContext::currentContext(); m_surface_glcontext = new QOpenGLContext(); + // Pick up the format from the current context; this is especially + // important in order to pick the right version/profile to test. m_surface_glcontext->setFormat(m_default_glcontext->format()); m_surface_glcontext->create(); m_surface_glcontext->makeCurrent(m_default_glcontext->surface()); diff --git a/tests/auto/other/lancelot/scripts/brushes.qps b/tests/auto/other/lancelot/scripts/brushes.qps index 82cbff48b9..43a7843601 100644 --- a/tests/auto/other/lancelot/scripts/brushes.qps +++ b/tests/auto/other/lancelot/scripts/brushes.qps @@ -77,3 +77,12 @@ drawRect 0 250 50 50 setBrushOrigin 50 250 drawRect 50 250 50 50 + +setBrush dome_indexed.png +setPen nopen +brushScale 0.7 0.7 +drawRect 20 320 600 200 + +setBrush dome_argb32.png +brushScale 1.5 1.5 +drawRect 20 540 600 200 diff --git a/tests/auto/other/lancelot/tst_lancelot.cpp b/tests/auto/other/lancelot/tst_lancelot.cpp index 8fc0521102..63c62bab86 100644 --- a/tests/auto/other/lancelot/tst_lancelot.cpp +++ b/tests/auto/other/lancelot/tst_lancelot.cpp @@ -53,7 +53,7 @@ private: }; void setupTestSuite(const QStringList& blacklist = QStringList()); - void runTestSuite(GraphicsEngine engine, QImage::Format format); + void runTestSuite(GraphicsEngine engine, QImage::Format format, const QSurfaceFormat &contextFormat = QSurfaceFormat()); void paint(QPaintDevice *device, GraphicsEngine engine, const QStringList &script, const QString &filePath); QStringList qpsFiles; @@ -69,6 +69,8 @@ private slots: void testRasterARGB32PM(); void testRasterRGB32_data(); void testRasterRGB32(); + void testRasterARGB32_data(); + void testRasterARGB32(); void testRasterRGB16_data(); void testRasterRGB16(); void testRasterA2RGB30PM_data(); @@ -83,8 +85,11 @@ private slots: #ifndef QT_NO_OPENGL void testOpenGL_data(); void testOpenGL(); + void testCoreOpenGL_data(); + void testCoreOpenGL(); private: bool checkSystemGLSupport(); + bool checkSystemCoreGLSupport(); #endif }; @@ -134,6 +139,17 @@ void tst_Lancelot::testRasterARGB32PM() } +void tst_Lancelot::testRasterARGB32_data() +{ + setupTestSuite(); +} + +void tst_Lancelot::testRasterARGB32() +{ + runTestSuite(Raster, QImage::Format_ARGB32); +} + + void tst_Lancelot::testRasterRGB32_data() { setupTestSuite(); @@ -223,6 +239,32 @@ bool tst_Lancelot::checkSystemGLSupport() return true; } +bool tst_Lancelot::checkSystemCoreGLSupport() +{ + if (QOpenGLContext::openGLModuleType() != QOpenGLContext::LibGL) + return false; + + QSurfaceFormat coreFormat; + coreFormat.setVersion(3, 2); + coreFormat.setProfile(QSurfaceFormat::CoreProfile); + QWindow win; + win.setSurfaceType(QSurface::OpenGLSurface); + win.setFormat(coreFormat); + win.create(); + QOpenGLFramebufferObjectFormat fmt; + fmt.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil); + fmt.setSamples(4); + QOpenGLContext ctx; + ctx.setFormat(coreFormat); + if (!ctx.create() || !ctx.makeCurrent(&win)) + return false; + QOpenGLFramebufferObject fbo(800, 800, fmt); + if (!fbo.isValid() || !fbo.bind()) + return false; + + return true; +} + void tst_Lancelot::testOpenGL_data() { if (!checkSystemGLSupport()) @@ -236,6 +278,22 @@ void tst_Lancelot::testOpenGL() { runTestSuite(OpenGL, QImage::Format_RGB32); } + +void tst_Lancelot::testCoreOpenGL_data() +{ + if (!checkSystemCoreGLSupport()) + QSKIP("System under test does not meet preconditions for Core Profile GL testing. Skipping."); + QStringList localBlacklist = QStringList() << QLatin1String("rasterops.qps"); + setupTestSuite(localBlacklist); +} + +void tst_Lancelot::testCoreOpenGL() +{ + QSurfaceFormat coreFormat; + coreFormat.setVersion(3, 2); + coreFormat.setProfile(QSurfaceFormat::CoreProfile); + runTestSuite(OpenGL, QImage::Format_RGB32, coreFormat); +} #endif @@ -250,7 +308,7 @@ void tst_Lancelot::setupTestSuite(const QStringList& blacklist) } -void tst_Lancelot::runTestSuite(GraphicsEngine engine, QImage::Format format) +void tst_Lancelot::runTestSuite(GraphicsEngine engine, QImage::Format format, const QSurfaceFormat &contextFormat) { QFETCH(QString, qpsFile); @@ -266,11 +324,13 @@ void tst_Lancelot::runTestSuite(GraphicsEngine engine, QImage::Format format) } else if (engine == OpenGL) { QWindow win; win.setSurfaceType(QSurface::OpenGLSurface); + win.setFormat(contextFormat); win.create(); QOpenGLFramebufferObjectFormat fmt; fmt.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil); fmt.setSamples(4); QOpenGLContext ctx; + ctx.setFormat(contextFormat); QVERIFY(ctx.create()); QVERIFY(ctx.makeCurrent(&win)); QOpenGLFramebufferObject fbo(800, 800, fmt); @@ -291,7 +351,7 @@ void tst_Lancelot::paint(QPaintDevice *device, GraphicsEngine engine, const QStr //pcmd.setShouldDrawText(false); switch (engine) { case OpenGL: - pcmd.setType(OpenGLBufferType); + pcmd.setType(OpenGLBufferType); // version/profile is communicated through the context's format() break; case Raster: // fallthrough default: diff --git a/tests/auto/other/macnativeevents/tst_macnativeevents.cpp b/tests/auto/other/macnativeevents/tst_macnativeevents.cpp index 1624b3065b..5edff7aabe 100644 --- a/tests/auto/other/macnativeevents/tst_macnativeevents.cpp +++ b/tests/auto/other/macnativeevents/tst_macnativeevents.cpp @@ -280,6 +280,8 @@ void tst_MacNativeEvents::testMouseEnter() void tst_MacNativeEvents::testChildDialogInFrontOfModalParent() { + QSKIP("Modal dialog causes later tests to fail, see QTBUG-58474"); + // Test that a child dialog of a modal parent dialog is // in front of the parent, and active: QDialog parent; diff --git a/tests/auto/other/macplist/tst_macplist.cpp b/tests/auto/other/macplist/tst_macplist.cpp index 0f07095b67..755cc462f5 100644 --- a/tests/auto/other/macplist/tst_macplist.cpp +++ b/tests/auto/other/macplist/tst_macplist.cpp @@ -155,9 +155,12 @@ void tst_MacPlist::test_plist() QString infoPlist = QLatin1String("Info.plist"); QDir dir(QCoreApplication::applicationDirPath()); +#ifndef Q_OS_MACOS + // macOS builds tests as single executables, iOS/tvOS/watchOS does not QVERIFY(dir.cdUp()); QVERIFY(dir.cdUp()); QVERIFY(dir.cdUp()); +#endif QVERIFY(dir.cd(QLatin1String("app"))); QVERIFY(dir.cd(QLatin1String("app.app"))); QVERIFY(dir.cd(QLatin1String("Contents"))); diff --git a/tests/auto/other/modeltest/modeltest.cpp b/tests/auto/other/modeltest/modeltest.cpp index c1784c2edc..4da00bda4d 100644 --- a/tests/auto/other/modeltest/modeltest.cpp +++ b/tests/auto/other/modeltest/modeltest.cpp @@ -104,10 +104,10 @@ void ModelTest::runAllTests() */ void ModelTest::nonDestructiveBasicTest() { - QVERIFY( model->buddy ( QModelIndex() ) == QModelIndex() ); + QVERIFY(!model->buddy(QModelIndex()).isValid()); model->canFetchMore ( QModelIndex() ); QVERIFY( model->columnCount ( QModelIndex() ) >= 0 ); - QVERIFY( model->data ( QModelIndex() ) == QVariant() ); + QCOMPARE(model->data(QModelIndex()), QVariant()); fetchingMore = true; model->fetchMore ( QModelIndex() ); fetchingMore = false; @@ -121,7 +121,7 @@ void ModelTest::nonDestructiveBasicTest() QVariant cache; model->match ( QModelIndex(), -1, cache ); model->mimeTypes(); - QVERIFY( model->parent ( QModelIndex() ) == QModelIndex() ); + QVERIFY(!model->parent(QModelIndex()).isValid()); QVERIFY( model->rowCount() >= 0 ); QVariant variant; model->setData ( QModelIndex(), variant, -1 ); @@ -211,9 +211,9 @@ void ModelTest::index() { // qDebug() << "i"; // Make sure that invalid values returns an invalid index - QVERIFY( model->index ( -2, -2 ) == QModelIndex() ); - QVERIFY( model->index ( -2, 0 ) == QModelIndex() ); - QVERIFY( model->index ( 0, -2 ) == QModelIndex() ); + QVERIFY(!model->index(-2, -2).isValid()); + QVERIFY(!model->index(-2, 0).isValid()); + QVERIFY(!model->index(0, -2).isValid()); int rows = model->rowCount(); int columns = model->columnCount(); @@ -222,13 +222,13 @@ void ModelTest::index() return; // Catch off by one errors - QVERIFY( model->index ( rows, columns ) == QModelIndex() ); - QVERIFY( model->index ( 0, 0 ).isValid() ); + QVERIFY(!model->index(rows, columns).isValid()); + QVERIFY(model->index(0, 0).isValid()); // Make sure that the same index is *always* returned QModelIndex a = model->index ( 0, 0 ); QModelIndex b = model->index ( 0, 0 ); - QVERIFY( a == b ); + QCOMPARE(a, b); // index() is tested more extensively in checkChildren(), // but this catches the big mistakes @@ -242,7 +242,7 @@ void ModelTest::parent() // qDebug() << "p"; // Make sure the model won't crash and will return an invalid QModelIndex // when asked for the parent of an invalid index. - QVERIFY( model->parent ( QModelIndex() ) == QModelIndex() ); + QVERIFY(!model->parent(QModelIndex()).isValid()); if ( model->rowCount() == 0 ) return; @@ -255,13 +255,13 @@ void ModelTest::parent() // Common error test #1, make sure that a top level index has a parent // that is a invalid QModelIndex. QModelIndex topIndex = model->index ( 0, 0, QModelIndex() ); - QVERIFY( model->parent ( topIndex ) == QModelIndex() ); + QVERIFY(!model->parent(topIndex).isValid()); // Common error test #2, make sure that a second level index has a parent // that is the first level index. if ( model->rowCount ( topIndex ) > 0 ) { QModelIndex childIndex = model->index ( 0, 0, topIndex ); - QVERIFY( model->parent ( childIndex ) == topIndex ); + QCOMPARE(model->parent(childIndex), topIndex); } // Common error test #3, the second column should NOT have the same children @@ -336,28 +336,28 @@ void ModelTest::checkChildren ( const QModelIndex &parent, int currentDepth ) QVERIFY( model->hasIndex ( r, c, parent ) ); QModelIndex index = model->index ( r, c, parent ); // rowCount() and columnCount() said that it existed... - QVERIFY( index.isValid() ); + QVERIFY(index.isValid()); // index() should always return the same index when called twice in a row QModelIndex modifiedIndex = model->index ( r, c, parent ); - QVERIFY( index == modifiedIndex ); + QCOMPARE(index, modifiedIndex); // Make sure we get the same index if we request it twice in a row QModelIndex a = model->index ( r, c, parent ); QModelIndex b = model->index ( r, c, parent ); - QVERIFY( a == b ); + QCOMPARE(a, b); { const QModelIndex sibling = model->sibling( r, c, topLeftChild ); - QVERIFY( index == sibling ); + QCOMPARE(index, sibling); } { const QModelIndex sibling = topLeftChild.sibling( r, c ); - QVERIFY( index == sibling ); + QCOMPARE(index, sibling); } // Some basic checking on the index that is returned - QVERIFY( index.model() == model ); + QCOMPARE(index.model(), model); QCOMPARE( index.row(), r ); QCOMPARE( index.column(), c ); // While you can technically return a QVariant usually this is a sign @@ -387,7 +387,7 @@ void ModelTest::checkChildren ( const QModelIndex &parent, int currentDepth ) // make sure that after testing the children that the index doesn't change. QModelIndex newerIndex = model->index ( r, c, parent ); - QVERIFY( index == newerIndex ); + QCOMPARE(index, newerIndex); } } } @@ -438,7 +438,7 @@ void ModelTest::data() // Check that the alignment is one we know about QVariant textAlignmentVariant = model->data ( model->index ( 0, 0 ), Qt::TextAlignmentRole ); if ( textAlignmentVariant.isValid() ) { - int alignment = textAlignmentVariant.toInt(); + Qt::Alignment alignment = textAlignmentVariant.value<Qt::Alignment>(); QCOMPARE( alignment, ( alignment & ( Qt::AlignHorizontal_Mask | Qt::AlignVertical_Mask ) ) ); } @@ -490,7 +490,7 @@ void ModelTest::rowsAboutToBeInserted ( const QModelIndex &parent, int start, in void ModelTest::rowsInserted ( const QModelIndex & parent, int start, int end ) { Changing c = insert.pop(); - QVERIFY( c.parent == parent ); + QCOMPARE(c.parent, parent); // qDebug() << "rowsInserted" << "start=" << start << "end=" << end << "oldsize=" << c.oldSize // << "parent=" << model->data ( parent ).toString() << "current rowcount of parent=" << model->rowCount ( parent ); @@ -500,8 +500,8 @@ void ModelTest::rowsInserted ( const QModelIndex & parent, int start, int end ) // } // qDebug(); - QVERIFY( c.oldSize + ( end - start + 1 ) == model->rowCount ( parent ) ); - QVERIFY( c.last == model->data ( model->index ( start - 1, 0, c.parent ) ) ); + QCOMPARE(c.oldSize + (end - start + 1), model->rowCount(parent)); + QCOMPARE(c.last, model->data(model->index(start - 1, 0, c.parent))); if (c.next != model->data(model->index(end + 1, 0, c.parent))) { qDebug() << start << end; @@ -510,7 +510,7 @@ void ModelTest::rowsInserted ( const QModelIndex & parent, int start, int end ) qDebug() << c.next << model->data(model->index(end + 1, 0, c.parent)); } - QVERIFY( c.next == model->data ( model->index ( end + 1, 0, c.parent ) ) ); + QCOMPARE(c.next, model->data(model->index(end + 1, 0, c.parent))); } void ModelTest::layoutAboutToBeChanged() @@ -523,7 +523,7 @@ void ModelTest::layoutChanged() { for ( int i = 0; i < changing.count(); ++i ) { QPersistentModelIndex p = changing[i]; - QVERIFY( p == model->index ( p.row(), p.column(), p.parent() ) ); + QCOMPARE(QModelIndex(p), model->index(p.row(), p.column(), p.parent())); } changing.clear(); } @@ -553,10 +553,10 @@ void ModelTest::rowsRemoved ( const QModelIndex & parent, int start, int end ) { qDebug() << "rr" << parent << start << end; Changing c = remove.pop(); - QVERIFY( c.parent == parent ); - QVERIFY( c.oldSize - ( end - start + 1 ) == model->rowCount ( parent ) ); - QVERIFY( c.last == model->data ( model->index ( start - 1, 0, c.parent ) ) ); - QVERIFY( c.next == model->data ( model->index ( start, 0, c.parent ) ) ); + QCOMPARE(c.parent, parent); + QCOMPARE(c.oldSize - (end - start + 1), model->rowCount(parent)); + QCOMPARE(c.last, model->data(model->index(start - 1, 0, c.parent))); + QCOMPARE(c.next, model->data(model->index(start, 0, c.parent))); } void ModelTest::dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) diff --git a/tests/auto/other/other.pro b/tests/auto/other/other.pro index ab42a814eb..0e84b187fa 100644 --- a/tests/auto/other/other.pro +++ b/tests/auto/other/other.pro @@ -2,7 +2,6 @@ TEMPLATE=subdirs QT_FOR_CONFIG += gui-private SUBDIRS=\ - # atwrapper \ # QTBUG-19452 compiler \ gestures \ lancelot \ diff --git a/tests/auto/other/qaccessibility/qaccessibility.pro b/tests/auto/other/qaccessibility/qaccessibility.pro index fb9de6f450..727d5fe0d7 100644 --- a/tests/auto/other/qaccessibility/qaccessibility.pro +++ b/tests/auto/other/qaccessibility/qaccessibility.pro @@ -12,6 +12,5 @@ win32 { include(../../../../src/3rdparty/iaccessible2/iaccessible2.pri) DEFINES += QT_SUPPORTS_IACCESSIBLE2 } - LIBS += -luuid - !winphone: LIBS += -loleacc -loleaut32 -lole32 + LIBS += -luuid -loleacc -loleaut32 -lole32 } diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index 11baee7335..4f60fe3d96 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -3001,11 +3001,11 @@ void tst_QAccessibility::treeTest() QVERIFY(table2); QCOMPARE(table2->columnCount(), 2); QCOMPARE(table2->rowCount(), 2); - QAccessibleInterface *cell1; - QVERIFY(cell1 = table2->cellAt(0,0)); + QAccessibleInterface *cell1 = table2->cellAt(0,0); + QVERIFY(cell1); QCOMPARE(cell1->text(QAccessible::Name), QString("Spain")); - QAccessibleInterface *cell2; - QVERIFY(cell2 = table2->cellAt(1,0)); + QAccessibleInterface *cell2 = table2->cellAt(1,0); + QVERIFY(cell2); QCOMPARE(cell2->text(QAccessible::Name), QString("Austria")); QCOMPARE(cell2->role(), QAccessible::TreeItem); QCOMPARE(cell2->tableCellInterface()->rowIndex(), 1); @@ -3129,8 +3129,8 @@ void tst_QAccessibility::tableTest() QVERIFY(table2); QCOMPARE(table2->columnCount(), 3); QCOMPARE(table2->rowCount(), 3); - QAccessibleInterface *cell1; - QVERIFY(cell1 = table2->cellAt(0,0)); + QAccessibleInterface *cell1 = table2->cellAt(0,0); + QVERIFY(cell1); QCOMPARE(cell1->text(QAccessible::Name), QString("0.0")); QCOMPARE(iface->indexOfChild(cell1), 5); diff --git a/tests/auto/other/qfocusevent/tst_qfocusevent.cpp b/tests/auto/other/qfocusevent/tst_qfocusevent.cpp index 5137ba0c57..5bf39b3953 100644 --- a/tests/auto/other/qfocusevent/tst_qfocusevent.cpp +++ b/tests/auto/other/qfocusevent/tst_qfocusevent.cpp @@ -340,6 +340,14 @@ void tst_QFocusEvent::checkReason_ActiveWindow() #if defined(Q_OS_IRIX) QEXPECT_FAIL("", "IRIX requires explicit activateWindow(), so this test does not make any sense.", Abort); #endif + + if (!QGuiApplication::platformName().compare(QLatin1String("offscreen"), Qt::CaseInsensitive) + || !QGuiApplication::platformName().compare(QLatin1String("minimal"), Qt::CaseInsensitive)) { + // Activate window of testFocusWidget, focus in that window goes to childFocusWidgetOne + QWARN("Platforms offscreen and minimal require explicit activateWindow()"); + testFocusWidget->activateWindow(); + } + QTRY_VERIFY(childFocusWidgetOne->focusInEventRecieved); QVERIFY(childFocusWidgetOne->focusInEventGotFocus); diff --git a/tests/auto/other/qtokenautomaton/tokenizers/boilerplate/boilerplate.xml b/tests/auto/other/qtokenautomaton/tokenizers/boilerplate/boilerplate.xml index a36c5e74f0..a07f2e321e 100644 --- a/tests/auto/other/qtokenautomaton/tokenizers/boilerplate/boilerplate.xml +++ b/tests/auto/other/qtokenautomaton/tokenizers/boilerplate/boilerplate.xml @@ -23,32 +23,27 @@ <boilerplate> <prolog>/**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** 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$ ** diff --git a/tests/auto/other/toolsupport/tst_toolsupport.cpp b/tests/auto/other/toolsupport/tst_toolsupport.cpp index f93c8f825b..a78bdc34f1 100644 --- a/tests/auto/other/toolsupport/tst_toolsupport.cpp +++ b/tests/auto/other/toolsupport/tst_toolsupport.cpp @@ -124,7 +124,13 @@ void tst_toolsupport::offsets_data() { QTestData &data = QTest::newRow("QFilePrivate::fileName") << pmm_to_offsetof(&QFilePrivate::fileName); +#ifdef Q_PROCESSOR_X86 + // x86 32-bit has weird alignment rules. Refer to QtPrivate::AlignOf in + // qglobal.h for more details. data << 168 << 248; +#else + data << 172 << 248; +#endif } #endif diff --git a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp index 8126e72ad2..d7772f5c34 100644 --- a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp +++ b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp @@ -2191,7 +2191,7 @@ void tst_QSqlDatabase::sqlStatementUseIsNull_189093() CHECK_DATABASE(db); // select a record with NULL value - QSqlQuery q(QString::null, db); + QSqlQuery q(QString(), db); QVERIFY_SQL(q, exec("select * from " + qTableName("qtest", __FILE__, db) + " where id = 4")); QVERIFY_SQL(q, next()); diff --git a/tests/auto/test.pl b/tests/auto/test.pl deleted file mode 100755 index 4df8c40e9e..0000000000 --- a/tests/auto/test.pl +++ /dev/null @@ -1,223 +0,0 @@ -#!/usr/bin/env perl -############################################################################# -## -## 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$ -## -############################################################################# - -use strict; -use Cwd; -use warnings; - -# Usage: test.pl <SearchPath> <ExecutionMode> <TestResults> <Timeout [Default 300 seconds]> -# Variable declarations to keep strict happy -our $SEARCH_PATH; -our $EXEC_MODE; -our $EXE_PREFIX; -our $EXE_SUFFIX; -our $TIMEOUT; -our $REPORTDIR; -our $buryChildren; -our $timeoutChildren; -our $totalExecuted; -our $totalStarted; -our $totalTimedOut; -our $currentDirectory; -our $testRoot; - -# Where do we run this script? What directory? -$SEARCH_PATH=$ARGV[0]; -if(!$SEARCH_PATH) -{ - print "Please specify the search directory! \n"; - exit(0); -} - -# We have four options: -# 'U': Unix -# 'W': Windows -# 'M': Mac -# 'E': Embedded -$EXEC_MODE=$ARGV[1]; -if($EXEC_MODE =~ /^U$/) -{ - print "Using Unix execution mode\n"; - $EXE_PREFIX="./"; - $EXE_SUFFIX=""; -} elsif($EXEC_MODE =~ /^W$/) -{ - print "Using Windows execution mode\n"; - $EXE_PREFIX=""; - $EXE_SUFFIX=".exe"; -} elsif($EXEC_MODE =~ /^M$/) -{ - print "Using OSX execution mode\n"; - $EXE_PREFIX="/Contents/MacOS/"; - $EXE_SUFFIX=".app"; -} elsif($EXEC_MODE =~ /^E$/) -{ - print "Using embedded execution mode\n"; - $EXE_PREFIX="./"; - $EXE_SUFFIX=""; -} else { - print "Unknown execution mode: $EXEC_MODE \n"; - print "Use: 'U' (Unix), 'W' (Windows), 'M' (MacOSX)\n"; - exit(0); -} -# We get the current directory, we 'll need it afterwards -$currentDirectory = getcwd(); - -$testRoot = Cwd::abs_path($SEARCH_PATH); - -# We assume that by default goes to "reports" unless the user specifies it. -$REPORTDIR = $ARGV[2]; -if(!$REPORTDIR) -{ - $REPORTDIR = $testRoot."/reports"; - mkdir $REPORTDIR; -} else { - mkdir $REPORTDIR; - $REPORTDIR = Cwd::abs_path($REPORTDIR); -} - -# If given we use it, otherwise we default to 300 seconds. -$TIMEOUT = $ARGV[3]; -if(!$TIMEOUT) -{ - $TIMEOUT=300; -} -print "Timeout value: $TIMEOUT\n"; - -# Initialize 'global' variables -$buryChildren = 0; -$timeoutChildren = 0; -$totalExecuted = 0; -$totalStarted = 0; -$totalTimedOut = 0; - -# Install signal handlers and pray for the best -$SIG{'CHLD'} = 'handleDeath'; -$SIG{'ALRM'} = 'handleTimeout'; - -handleDir($testRoot); - -print " ** Statistics ** \n"; -print " Tests started: $totalStarted \n"; -print " Tests executed: $totalExecuted \n"; -print " Tests timed out: $totalTimedOut \n"; - -sub handleDir { - - my ($dir) = @_; - my $currentDir = getcwd(); - - opendir(DIR, $dir); - my @files = readdir(DIR); - closedir DIR; - my $file; - foreach $file (@files) { - #skip hidden files - next if (substr($file,0,1) eq "."); - - if ( -d $dir."/".$file) { - handleDir($dir."/".$file) - } elsif ( $file =~ /^tst_/ and -x $dir."/".$file ) { - chdir($dir) || die("Could not chdir to $dir"); - executeTestCurrentDir($file); - chdir($currentDir); - } - } -} - -sub executeTestCurrentDir { - my ($command) = @_; - print "Executing $command \n"; - my $myPid; - $myPid = fork(); - if($myPid == 0) - { - my $realCommand; - if($EXEC_MODE =~/^M$/) - { - $realCommand = "./".$command.$EXE_SUFFIX.$EXE_PREFIX.$command; - } else { - $realCommand = $EXE_PREFIX.$command.$EXE_SUFFIX; - } - my $outputRedirection = $REPORTDIR."/".$command.$EXE_SUFFIX.".xml"; - - if($EXEC_MODE =~ /^E$/) - { - exec($realCommand, "-qws", "-xml", "-o", $outputRedirection); - } else { - exec($realCommand, "-xml", "-o", $outputRedirection); - } - exit(0); - } elsif($myPid > 0 ) - { - $totalStarted++; - alarm($TIMEOUT); - while(!$buryChildren && !$timeoutChildren) - { - sleep 10; - } - if($buryChildren) - { - my $value; - $value = waitpid($myPid , 0); - $buryChildren = 0; - $totalExecuted++; - } elsif($timeoutChildren) - { - kill 'INT', $myPid; - $timeoutChildren = 0; - $totalTimedOut++; - } else { - # What?? If we get here we need to abort, this is totally unexpected - print "Wrong condition evaluated, aborting to avoid damages\n"; - exit(0); - } - # We need to handle children killed because of timeout - if($buryChildren) - { - my $value; - $value = waitpid($myPid , 0); - $buryChildren = 0; - } - } else { - print "Problems trying to execute $command"; - } - -} - -# This procedure takes care of handling dead children on due time -sub handleDeath { - $buryChildren = 1; -} - -# This takes care of timeouts -sub handleTimeout { - $timeoutChildren = 1; -} - diff --git a/tests/auto/testlib/selftests/selftests.pri b/tests/auto/testlib/selftests/selftests.pri index 7404a1c49b..66c7e06760 100644 --- a/tests/auto/testlib/selftests/selftests.pri +++ b/tests/auto/testlib/selftests/selftests.pri @@ -45,3 +45,6 @@ SUBPROGRAMS = \ verifyexceptionthrown \ warnings \ xunit + +INCLUDEPATH += ../../../../shared/ +HEADERS += ../../../../shared/emulationdetector.h diff --git a/tests/auto/testlib/selftests/tst_selftests.cpp b/tests/auto/testlib/selftests/tst_selftests.cpp index 0c078127b4..e7123fc059 100644 --- a/tests/auto/testlib/selftests/tst_selftests.cpp +++ b/tests/auto/testlib/selftests/tst_selftests.cpp @@ -36,6 +36,8 @@ #include <private/cycle_p.h> +#include "emulationdetector.h" + struct LoggerSet; class tst_Selftests: public QObject @@ -550,6 +552,7 @@ static QProcessEnvironment processEnvironment() || key == QLatin1String("GRAPHICS_ROOT") || key == QLatin1String("TZ") #elif defined(Q_OS_UNIX) || key == QLatin1String("HOME") || key == QLatin1String("USER") // Required for X11 on openSUSE + || key == QLatin1String("QEMU_SET_ENV") || key == QLatin1String("QEMU_LD_PREFIX") // Required for QEMU # if !defined(Q_OS_MAC) || key == QLatin1String("DISPLAY") || key == QLatin1String("XAUTHLOCALHOSTNAME") || key.startsWith(QLatin1String("XDG_")) @@ -642,6 +645,16 @@ void tst_Selftests::doRunSubTest(QString const& subdir, QStringList const& logge && subdir != QLatin1String("blacklisted") // calls qFatal() && subdir != QLatin1String("silent") // calls qFatal() #endif +#ifdef Q_OS_LINUX + // QEMU outputs to stderr about uncaught signals + && (!EmulationDetector::isRunningArmOnX86() || + (subdir != QLatin1String("blacklisted") + && subdir != QLatin1String("silent") + && subdir != QLatin1String("assert") + && subdir != QLatin1String("crashes") + ) + ) +#endif && subdir != QLatin1String("benchlibcallgrind")) QVERIFY2(err.isEmpty(), err.constData()); diff --git a/tests/auto/tools/moc/cxx17-namespaces.h b/tests/auto/tools/moc/cxx17-namespaces.h new file mode 100644 index 0000000000..97f534c697 --- /dev/null +++ b/tests/auto/tools/moc/cxx17-namespaces.h @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2011 Olivier Goffart. +** 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$ +** +****************************************************************************/ + +#ifndef CXX17_NAMESPACES_H +#define CXX17_NAMESPACES_H +#include <QtCore/QObject> + +#if defined(__cpp_nested_namespace_definitions) || defined(Q_MOC_RUN) +namespace CXX17Namespace::A::B { +namespace C::D { +namespace E::F::G { } // don't confuse moc +#else +namespace CXX17Namespace { namespace A { namespace B { +namespace C { namespace D { +#endif + +Q_NAMESPACE + +class ClassInNamespace +{ + Q_GADGET +public: + enum GadEn { Value = 3 }; + Q_ENUM(GadEn) +}; + +enum NamEn { Value = 4 }; +Q_ENUM_NS(NamEn); + + +#if defined(__cpp_nested_namespace_definitions) || defined(Q_MOC_RUN) +} +} +#else +} } } +} } +#endif + +#endif diff --git a/tests/auto/tools/moc/moc.pro b/tests/auto/tools/moc/moc.pro index d2b750bdc5..b7151f9c16 100644 --- a/tests/auto/tools/moc/moc.pro +++ b/tests/auto/tools/moc/moc.pro @@ -29,7 +29,7 @@ HEADERS += using-namespaces.h no-keywords.h task87883.h c-comments.h backslash-n non-gadget-parent-class.h grand-parent-gadget-class.h \ related-metaobjects-in-gadget.h \ related-metaobjects-name-conflict.h \ - namespace.h + namespace.h cxx17-namespaces.h if(*-g++*|*-icc*|*-clang*|*-llvm):!irix-*:!win32-*: HEADERS += os9-newlines.h win-newlines.h diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index e746800c9f..8189227cbe 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -70,6 +70,7 @@ #include "non-gadget-parent-class.h" #include "grand-parent-gadget-class.h" #include "namespace.h" +#include "cxx17-namespaces.h" #ifdef Q_MOC_RUN // check that moc can parse these constructs, they are being used in Windows winsock2.h header @@ -521,6 +522,10 @@ public slots: private: myNS::Points m_points; +#ifdef Q_MOC_RUN + int xx = 11'11; // digit separator must not confuse moc (QTBUG-59351) +#endif + private slots: inline virtual void blub1() {} virtual inline void blub2() {} @@ -696,6 +701,7 @@ private slots: void optionsFileError_data(); void optionsFileError(); void testQNamespace(); + void cxx17Namespaces(); signals: void sigWithUnsignedArg(unsigned foo); @@ -2145,6 +2151,22 @@ void tst_Moc::warnings_data() << 0 << QString() << QString("standard input:1: Note: No relevant classes found. No output generated."); + + QTest::newRow("Q_PLUGIN_METADATA: invalid file") + << QByteArray("class X { \n Q_PLUGIN_METADATA(FILE \"does.not.exists\") \n };") + << QStringList() + << 1 + << QString() + << QString("standard input:2: Error: Plugin Metadata file \"does.not.exists\" does not exist. Declaration will be ignored"); + +#ifdef Q_OS_LINUX // Limit to Linux because the error message is platform-dependent + QTest::newRow("Q_PLUGIN_METADATA: unreadable file") + << QByteArray("class X { \n Q_PLUGIN_METADATA(FILE \".\") \n };") + << QStringList() + << 1 + << QString() + << QString("standard input:2: Error: Plugin Metadata file \".\" could not be opened: file to open is a directory"); +#endif } void tst_Moc::warnings() @@ -2819,6 +2841,21 @@ void tst_Moc::privateSignalConnection() // We can't use function pointer connections to private signals which are overloaded because we would have to cast in this case to: // static_cast<void (ClassWithPrivateSignals::*)(int, ClassWithPrivateSignals::QPrivateSignal)>(&ClassWithPrivateSignals::overloadedMaybePrivate) // Which doesn't work as ClassWithPrivateSignals::QPrivateSignal is private. + + // Connecting from one private signal to another + { + ClassWithPrivateSignals classWithPrivateSignals1; + ClassWithPrivateSignals classWithPrivateSignals2; + SignalConnectionTester tester; + QObject::connect(&classWithPrivateSignals1, &ClassWithPrivateSignals::privateSignal1, + &classWithPrivateSignals2, &ClassWithPrivateSignals::privateSignal1); + QObject::connect(&classWithPrivateSignals2, &ClassWithPrivateSignals::privateSignal1, + &tester, &SignalConnectionTester::testSlot); + + QVERIFY(!tester.testPassed); + classWithPrivateSignals1.emitPrivateSignals(); + QVERIFY(tester.testPassed); + } } void tst_Moc::finalClasses_data() @@ -3787,6 +3824,25 @@ void tst_Moc::testQNamespace() QCOMPARE(FooNamespace::FooNestedNamespace::FooMoreNestedNamespace::staticMetaObject.enumeratorCount(), 1); } +void tst_Moc::cxx17Namespaces() +{ + QCOMPARE(CXX17Namespace::A::B::C::D::staticMetaObject.className(), + "CXX17Namespace::A::B::C::D"); + QCOMPARE(CXX17Namespace::A::B::C::D::staticMetaObject.enumeratorCount(), 1); + QCOMPARE(CXX17Namespace::A::B::C::D::staticMetaObject.enumerator(0).name(), "NamEn"); + QCOMPARE(QMetaEnum::fromType<CXX17Namespace::A::B::C::D::NamEn>().name(), "NamEn"); + QCOMPARE(QMetaEnum::fromType<CXX17Namespace::A::B::C::D::NamEn>().keyCount(), 1); + QCOMPARE(QMetaEnum::fromType<CXX17Namespace::A::B::C::D::NamEn>().value(0), 4); + + QCOMPARE(CXX17Namespace::A::B::C::D::ClassInNamespace::staticMetaObject.className(), + "CXX17Namespace::A::B::C::D::ClassInNamespace"); + QCOMPARE(CXX17Namespace::A::B::C::D::ClassInNamespace::staticMetaObject.enumeratorCount(), 1); + QCOMPARE(CXX17Namespace::A::B::C::D::ClassInNamespace::staticMetaObject.enumerator(0).name(), "GadEn"); + QCOMPARE(QMetaEnum::fromType<CXX17Namespace::A::B::C::D::ClassInNamespace::GadEn>().name(), "GadEn"); + QCOMPARE(QMetaEnum::fromType<CXX17Namespace::A::B::C::D::ClassInNamespace::GadEn>().keyCount(), 1); + QCOMPARE(QMetaEnum::fromType<CXX17Namespace::A::B::C::D::ClassInNamespace::GadEn>().value(0), 3); +} + QTEST_MAIN(tst_Moc) // the generated code must compile with QT_NO_KEYWORDS diff --git a/tests/auto/tools/qmake/tst_qmake.cpp b/tests/auto/tools/qmake/tst_qmake.cpp index eed1fe1a56..10aabcf196 100644 --- a/tests/auto/tools/qmake/tst_qmake.cpp +++ b/tests/auto/tools/qmake/tst_qmake.cpp @@ -286,6 +286,7 @@ void tst_qmake::install_files() QVERIFY( test_compiler.make( workDir, "install" )); QVERIFY( test_compiler.exists( workDir + "/dist", "foo", Exe, "1.0.0" )); QVERIFY( test_compiler.exists( workDir + "/dist", "test.txt", Plain, "1.0.0" )); + QCOMPARE(QFileInfo(workDir + "/test.txt").lastModified(), QFileInfo(workDir + "/dist/test.txt").lastModified()); QVERIFY( test_compiler.make( workDir, "uninstall" )); QVERIFY( test_compiler.makeDistClean( workDir )); diff --git a/tests/auto/tools/uic/baseline/chatmainwindow.ui.h b/tests/auto/tools/uic/baseline/chatmainwindow.ui.h index 8cfd9b4851..7f8b026ba5 100644 --- a/tests/auto/tools/uic/baseline/chatmainwindow.ui.h +++ b/tests/auto/tools/uic/baseline/chatmainwindow.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'chatmainwindow.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.9.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ @@ -151,10 +151,14 @@ public: { ChatMainWindow->setWindowTitle(QApplication::translate("ChatMainWindow", "Qt D-Bus Chat", Q_NULLPTR)); actionQuit->setText(QApplication::translate("ChatMainWindow", "Quit", Q_NULLPTR)); +#ifndef QT_NO_SHORTCUT actionQuit->setShortcut(QApplication::translate("ChatMainWindow", "Ctrl+Q", Q_NULLPTR)); +#endif // QT_NO_SHORTCUT actionAboutQt->setText(QApplication::translate("ChatMainWindow", "About Qt...", Q_NULLPTR)); actionChangeNickname->setText(QApplication::translate("ChatMainWindow", "Change nickname...", Q_NULLPTR)); +#ifndef QT_NO_SHORTCUT actionChangeNickname->setShortcut(QApplication::translate("ChatMainWindow", "Ctrl+N", Q_NULLPTR)); +#endif // QT_NO_SHORTCUT #ifndef QT_NO_TOOLTIP chatHistory->setToolTip(QApplication::translate("ChatMainWindow", "Messages sent and received from other users", Q_NULLPTR)); #endif // QT_NO_TOOLTIP diff --git a/tests/auto/tools/uic/baseline/mydialog.ui.h b/tests/auto/tools/uic/baseline/mydialog.ui.h index 061b476f63..279dd0e9bf 100644 --- a/tests/auto/tools/uic/baseline/mydialog.ui.h +++ b/tests/auto/tools/uic/baseline/mydialog.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'mydialog.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.9.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ @@ -62,7 +62,9 @@ public: MyDialog->setWindowTitle(QApplication::translate("MyDialog", "Mach 2!", Q_NULLPTR)); aLabel->setText(QApplication::translate("MyDialog", "Join the life in the fastlane; - PCH enable your project today! -", Q_NULLPTR)); aButton->setText(QApplication::translate("MyDialog", "&Quit", Q_NULLPTR)); +#ifndef QT_NO_SHORTCUT aButton->setShortcut(QApplication::translate("MyDialog", "Alt+Q", Q_NULLPTR)); +#endif // QT_NO_SHORTCUT } // retranslateUi }; diff --git a/tests/auto/tools/uic/baseline/trpreviewtool.ui.h b/tests/auto/tools/uic/baseline/trpreviewtool.ui.h index d694ae5a8d..7545b4c803 100644 --- a/tests/auto/tools/uic/baseline/trpreviewtool.ui.h +++ b/tests/auto/tools/uic/baseline/trpreviewtool.ui.h @@ -31,7 +31,7 @@ /******************************************************************************** ** Form generated from reading UI file 'trpreviewtool.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.9.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ @@ -168,7 +168,9 @@ public: actionOpenForm->setText(QApplication::translate("TrPreviewToolClass", "&Open Form...", Q_NULLPTR)); actionLoadTranslation->setText(QApplication::translate("TrPreviewToolClass", "&Load Translation...", Q_NULLPTR)); actionReloadTranslations->setText(QApplication::translate("TrPreviewToolClass", "&Reload Translations", Q_NULLPTR)); +#ifndef QT_NO_SHORTCUT actionReloadTranslations->setShortcut(QApplication::translate("TrPreviewToolClass", "F5", Q_NULLPTR)); +#endif // QT_NO_SHORTCUT actionClose->setText(QApplication::translate("TrPreviewToolClass", "&Close", Q_NULLPTR)); actionAbout->setText(QApplication::translate("TrPreviewToolClass", "About", Q_NULLPTR)); actionAbout_Qt->setText(QApplication::translate("TrPreviewToolClass", "About Qt", Q_NULLPTR)); diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp index c9aef497af..44cb5a5bf8 100644 --- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp +++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp @@ -119,6 +119,8 @@ private slots: void selectFilter(); void viewMode(); void proxymodel(); + void setMimeTypeFilters_data(); + void setMimeTypeFilters(); void setNameFilter_data(); void setNameFilter(); void setEmptyNameFilter(); @@ -1039,6 +1041,34 @@ void tst_QFiledialog::proxymodel() QCOMPARE(fd.proxyModel(), nullptr); } +void tst_QFiledialog::setMimeTypeFilters_data() +{ + QTest::addColumn<QStringList>("mimeTypeFilters"); + QTest::addColumn<QString>("targetMimeTypeFilter"); + QTest::addColumn<QString>("expectedSelectedMimeTypeFilter"); + + const auto headerMime = QStringLiteral("text/x-chdr"); + const auto jsonMime = QStringLiteral("application/json"); + const auto zipMime = QStringLiteral("application/zip"); + + QTest::newRow("single mime filter (C header file)") << QStringList {headerMime} << headerMime << headerMime; + QTest::newRow("single mime filter (JSON file)") << QStringList {jsonMime} << jsonMime << jsonMime; + QTest::newRow("multiple mime filters") << QStringList {jsonMime, zipMime} << jsonMime << jsonMime; +} + +void tst_QFiledialog::setMimeTypeFilters() +{ + QFETCH(QStringList, mimeTypeFilters); + QFETCH(QString, targetMimeTypeFilter); + QFETCH(QString, expectedSelectedMimeTypeFilter); + + QFileDialog fd; + fd.setMimeTypeFilters(mimeTypeFilters); + fd.selectMimeTypeFilter(targetMimeTypeFilter); + + QCOMPARE(fd.selectedMimeTypeFilter(), expectedSelectedMimeTypeFilter); +} + void tst_QFiledialog::setEmptyNameFilter() { QFileDialog fd; diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp index c8bdcbde09..76b25cdb52 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp @@ -56,6 +56,8 @@ #include <private/qgraphicsview_p.h> #include "../../../shared/platforminputcontext.h" #include <private/qinputmethod_p.h> +#include <private/qguiapplication_p.h> +#include <qpa/qplatformintegration.h> #include "tst_qgraphicsview.h" @@ -664,6 +666,9 @@ void tst_QGraphicsView::viewport() #ifndef QT_NO_OPENGL void tst_QGraphicsView::openGLViewport() { + if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL)) + QSKIP("QOpenGL is not supported on this platform."); + QGraphicsScene scene; scene.setBackgroundBrush(Qt::white); scene.addText("GraphicsView"); @@ -2885,7 +2890,7 @@ public: void tst_QGraphicsView::scrollBarRanges() { - QFETCH(QString, style); + QFETCH(QByteArray, style); QFETCH(QSize, viewportSize); QFETCH(QRectF, sceneRect); QFETCH(ScrollBarCount, sceneRectOffsetFactors); @@ -2898,7 +2903,7 @@ void tst_QGraphicsView::scrollBarRanges() QFETCH(ExpectedValueDescription, vmax); QFETCH(bool, useStyledPanel); - if (useStyledPanel && style == QStringLiteral("Macintosh") && platformName == QStringLiteral("cocoa")) + if (useStyledPanel && style == "Macintosh" && platformName == QStringLiteral("cocoa")) QSKIP("Insignificant on OSX"); QScopedPointer<QStyle> stylePtr; @@ -2909,10 +2914,10 @@ void tst_QGraphicsView::scrollBarRanges() view.setTransform(transform); view.setFrameStyle(useStyledPanel ? QFrame::StyledPanel : QFrame::NoFrame); - if (style == QString("motif")) + if (style == "motif") stylePtr.reset(new FauxMotifStyle); else - stylePtr.reset(QStyleFactory::create(style)); + stylePtr.reset(QStyleFactory::create(QLatin1String(style))); view.setStyle(stylePtr.data()); view.setStyleSheet(" "); // enables style propagation ;-) diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview_2.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview_2.cpp index 875f671e76..9550655868 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview_2.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview_2.cpp @@ -44,9 +44,8 @@ Q_DECLARE_METATYPE(QPainterPath) Q_DECLARE_METATYPE(Qt::ScrollBarPolicy) Q_DECLARE_METATYPE(ScrollBarCount) -static void _scrollBarRanges_addTestData(const QString &style, bool styled) +static void _scrollBarRanges_addTestData(const QByteArray &style, bool styled) { - const QString styleString = styled ? style + ", Styled" : style; const int viewWidth = 250; const int viewHeight = 100; @@ -59,7 +58,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription hmin, hmax, vmin, vmax; } data [] = { { - ", 1", + "1", QRectF(0, 0, viewWidth, viewHeight), ScrollBarCount(0, 0, 0, 0), 1, @@ -71,7 +70,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(), }, { - ", 2", + "2", QRectF(0, 0, viewWidth + 50, viewHeight), ScrollBarCount(0, 0, 0, 0), 1, @@ -83,7 +82,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(0, 1, 1), }, { - ", 3", + "3", QRectF(0, 0, viewWidth + 50, viewHeight + 100), ScrollBarCount(0, 0, 0, 0), 1, @@ -95,7 +94,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(100, 1, 1), }, { - ", 4", + "4", QRectF(-100, -100, viewWidth, viewHeight), ScrollBarCount(0, 0, 0, 0), 1, @@ -107,7 +106,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(), }, { - ", 5", + "5", QRectF(-100, -100, viewWidth + 50, viewHeight), ScrollBarCount(0, 0, 0, 0), 1, @@ -119,7 +118,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(-100, 1, 1), }, { - ", 6", + "6", QRectF(-100, -100, viewWidth + 50, viewHeight + 100), ScrollBarCount(0, 0, 0, 0), 1, @@ -131,7 +130,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(0, 1, 1), }, { - ", 7", + "7", QRectF(0, 0, viewWidth + 1, viewHeight + 1), ScrollBarCount(0, 0, 0, 0), 1, @@ -143,7 +142,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(1, 1, 1), }, { - ", 8", + "8", QRectF(0, 0, viewWidth + 51, viewHeight + 1), ScrollBarCount(0, 0, 0, 0), 1, @@ -155,7 +154,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(1, 1, 1), }, { - ", 9", + "9", QRectF(0, 0, viewWidth + 51, viewHeight + 101), ScrollBarCount(0, 0, 0, 0), 1, @@ -167,7 +166,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(101, 1, 1), }, { - ", 10", + "10", QRectF(-101, -101, viewWidth + 1, viewHeight + 1), ScrollBarCount(0, 0, 0, 0), 1, @@ -179,7 +178,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(-100, 1, 1), }, { - ", 11", + "11", QRectF(-101, -101, viewWidth + 51, viewHeight + 1), ScrollBarCount(0, 0, 0, 0), 1, @@ -191,7 +190,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(-100, 1, 1), }, { - ", 12", + "12", QRectF(-101, -101, viewWidth + 51, viewHeight + 101), ScrollBarCount(0, 0, 0, 0), 1, @@ -203,7 +202,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(0, 1, 1), }, { - ", 13", + "13", QRectF(0, 0, viewWidth, viewHeight), ScrollBarCount(0, 0, 1, 1), 1, @@ -215,7 +214,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(0, 2, 1), }, { - ", 14", + "14", QRectF(0, 0, viewWidth + 50, viewHeight), ScrollBarCount(0, 0, 1, 1), 1, @@ -227,7 +226,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(0, 2, 1), }, { - ", 15", + "15", QRectF(0, 0, viewWidth + 50, viewHeight + 100), ScrollBarCount(0, 0, 1, 1), 1, @@ -239,7 +238,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(100, 2, 1), }, { - ", 16", + "16", QRectF(-100, -100, viewWidth, viewHeight), ScrollBarCount(-1, -1, 1, 1), 1, @@ -251,7 +250,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(-100, 1, 1), }, { - ", 17", + "17", QRectF(-100, -100, viewWidth + 50, viewHeight), ScrollBarCount(-1, -1, 1, 1), 1, @@ -263,7 +262,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(-100, 1, 1), }, { - ", 18", + "18", QRectF(-100, -100, viewWidth + 50, viewHeight + 100), ScrollBarCount(-1, -1, 1, 1), 1, @@ -275,7 +274,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(0, 1, 1), }, { - ", 1 x2", + "1 x2", QRectF(0, 0, viewWidth, viewHeight), ScrollBarCount(0, 0, 0, 0), 2, @@ -287,7 +286,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(viewHeight, 1, 1), }, { - ", 2 x2", + "2 x2", QRectF(0, 0, viewWidth + 50, viewHeight), ScrollBarCount(0, 0, 0, 0), 2, @@ -299,7 +298,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(viewHeight, 1, 1), }, { - ", 3 x2", + "3 x2", QRectF(0, 0, viewWidth + 50, viewHeight + 100), ScrollBarCount(0, 0, 0, 0), 2, @@ -311,7 +310,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(viewHeight + 200, 1, 1), }, { - ", 4 x2", + "4 x2", QRectF(-100, -100, viewWidth, viewHeight), ScrollBarCount(0, 0, 0, 0), 2, @@ -323,7 +322,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(viewHeight - 200, 1, 1), }, { - ", 5 x2", + "5 x2", QRectF(-100, -100, viewWidth + 50, viewHeight), ScrollBarCount(0, 0, 0, 0), 2, @@ -335,7 +334,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(viewHeight - 200, 1, 1), }, { - ", 6 x2", + "6 x2", QRectF(-100, -100, viewWidth + 50, viewHeight + 100), ScrollBarCount(0, 0, 0, 0), 2, @@ -347,7 +346,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(viewHeight, 1, 1), }, { - ", 1 No ScrollBars", + "1 No ScrollBars", QRectF(0, 0, viewWidth, viewHeight), ScrollBarCount(0, 0, 0, 0), 1, @@ -359,7 +358,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(), }, { - ", 2 No ScrollBars", + "2 No ScrollBars", QRectF(0, 0, viewWidth + 50, viewHeight), ScrollBarCount(0, 0, 0, 0), 1, @@ -371,7 +370,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(), }, { - ", 3 No ScrollBars", + "3 No ScrollBars", QRectF(0, 0, viewWidth + 50, viewHeight + 100), ScrollBarCount(0, 0, 0, 0), 1, @@ -383,7 +382,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(100), }, { - ", 4 No ScrollBars", + "4 No ScrollBars", QRectF(-100, -100, viewWidth, viewHeight), ScrollBarCount(0, 0, 0, 0), 1, @@ -395,7 +394,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(), }, { - ", 5 No ScrollBars", + "5 No ScrollBars", QRectF(-100, -100, viewWidth + 50, viewHeight), ScrollBarCount(0, 0, 0, 0), 1, @@ -407,7 +406,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(), }, { - ", 6 No ScrollBars", + "6 No ScrollBars", QRectF(-100, -100, viewWidth + 50, viewHeight + 100), ScrollBarCount(0, 0, 0, 0), 1, @@ -419,7 +418,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(), }, { - ", 7 No ScrollBars", + "7 No ScrollBars", QRectF(0, 0, viewWidth + 1, viewHeight + 1), ScrollBarCount(0, 0, 0, 0), 1, @@ -431,7 +430,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(1), }, { - ", 8 No ScrollBars", + "8 No ScrollBars", QRectF(0, 0, viewWidth + 51, viewHeight + 1), ScrollBarCount(0, 0, 0, 0), 1, @@ -443,7 +442,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(1), }, { - ", 9 No ScrollBars", + "9 No ScrollBars", QRectF(0, 0, viewWidth + 51, viewHeight + 101), ScrollBarCount(0, 0, 0, 0), 1, @@ -455,7 +454,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(101), }, { - ", 10 No ScrollBars", + "10 No ScrollBars", QRectF(-101, -101, viewWidth + 1, viewHeight + 1), ScrollBarCount(0, 0, 0, 0), 1, @@ -467,7 +466,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(-100), }, { - ", 11 No ScrollBars", + "11 No ScrollBars", QRectF(-101, -101, viewWidth + 51, viewHeight + 1), ScrollBarCount(0, 0, 0, 0), 1, @@ -479,7 +478,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(-100), }, { - ", 12 No ScrollBars", + "12 No ScrollBars", QRectF(-101, -101, viewWidth + 51, viewHeight + 101), ScrollBarCount(0, 0, 0, 0), 1, @@ -491,7 +490,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(), }, { - ", 13 No ScrollBars", + "13 No ScrollBars", QRectF(0, 0, viewWidth, viewHeight), ScrollBarCount(0, 0, 1, 1), 1, @@ -503,7 +502,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(0, 1), }, { - ", 14 No ScrollBars", + "14 No ScrollBars", QRectF(0, 0, viewWidth + 50, viewHeight), ScrollBarCount(0, 0, 1, 1), 1, @@ -515,7 +514,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(0, 1), }, { - ", 15 No ScrollBars", + "15 No ScrollBars", QRectF(0, 0, viewWidth + 50, viewHeight + 100), ScrollBarCount(0, 0, 1, 1), 1, @@ -527,7 +526,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(100, 1), }, { - ", 16 No ScrollBars", + "16 No ScrollBars", QRectF(-100, -100, viewWidth, viewHeight), ScrollBarCount(-1, -1, 1, 1), 1, @@ -539,7 +538,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(-100), }, { - ", 17 No ScrollBars", + "17 No ScrollBars", QRectF(-100, -100, viewWidth + 50, viewHeight), ScrollBarCount(-1, -1, 1, 1), 1, @@ -551,7 +550,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(-100), }, { - ", 18 No ScrollBars", + "18 No ScrollBars", QRectF(-100, -100, viewWidth + 50, viewHeight + 100), ScrollBarCount(-1, -1, 1, 1), 1, @@ -563,7 +562,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(), }, { - ", 1 x2 No ScrollBars", + "1 x2 No ScrollBars", QRectF(0, 0, viewWidth, viewHeight), ScrollBarCount(0, 0, 0, 0), 2, @@ -575,7 +574,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(viewHeight), }, { - ", 2 x2 No ScrollBars", + "2 x2 No ScrollBars", QRectF(0, 0, viewWidth + 50, viewHeight), ScrollBarCount(0, 0, 0, 0), 2, @@ -587,7 +586,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(viewHeight), }, { - ", 3 x2 No ScrollBars", + "3 x2 No ScrollBars", QRectF(0, 0, viewWidth + 50, viewHeight + 100), ScrollBarCount(0, 0, 0, 0), 2, @@ -599,7 +598,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(viewHeight + 200), }, { - ", 4 x2 No ScrollBars", + "4 x2 No ScrollBars", QRectF(-100, -100, viewWidth, viewHeight), ScrollBarCount(0, 0, 0, 0), 2, @@ -611,7 +610,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(viewHeight - 200), }, { - ", 5 x2 No ScrollBars", + "5 x2 No ScrollBars", QRectF(-100, -100, viewWidth + 50, viewHeight), ScrollBarCount(0, 0, 0, 0), 2, @@ -623,7 +622,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(viewHeight - 200), }, { - ", 6 x2 No ScrollBars", + "6 x2 No ScrollBars", QRectF(-100, -100, viewWidth + 50, viewHeight + 100), ScrollBarCount(0, 0, 0, 0), 2, @@ -635,7 +634,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(viewHeight), }, { - ", 1 Always ScrollBars", + "1 Always ScrollBars", QRectF(0, 0, viewWidth, viewHeight), ScrollBarCount(0, 0, 0, 0), 1, @@ -647,7 +646,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(0, 1, 1), }, { - ", 2 Always ScrollBars", + "2 Always ScrollBars", QRectF(0, 0, viewWidth + 50, viewHeight), ScrollBarCount(0, 0, 0, 0), 1, @@ -659,7 +658,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(0, 1, 1), }, { - ", 3 Always ScrollBars", + "3 Always ScrollBars", QRectF(0, 0, viewWidth + 50, viewHeight + 100), ScrollBarCount(0, 0, 0, 0), 1, @@ -671,7 +670,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(100, 1, 1), }, { - ", 4 Always ScrollBars", + "4 Always ScrollBars", QRectF(-100, -100, viewWidth, viewHeight), ScrollBarCount(0, 0, 0, 0), 1, @@ -683,7 +682,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(-100, 1, 1), }, { - ", 5 Always ScrollBars", + "5 Always ScrollBars", QRectF(-100, -100, viewWidth + 50, viewHeight), ScrollBarCount(0, 0, 0, 0), 1, @@ -695,7 +694,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(-100, 1, 1), }, { - ", 6 Always ScrollBars", + "6 Always ScrollBars", QRectF(-100, -100, viewWidth + 50, viewHeight + 100), ScrollBarCount(0, 0, 0, 0), 1, @@ -707,7 +706,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(0, 1, 1), }, { - ", 7 Always ScrollBars", + "7 Always ScrollBars", QRectF(0, 0, viewWidth + 1, viewHeight + 1), ScrollBarCount(0, 0, 0, 0), 1, @@ -719,7 +718,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(1, 1, 1), }, { - ", 8 Always ScrollBars", + "8 Always ScrollBars", QRectF(0, 0, viewWidth + 51, viewHeight + 1), ScrollBarCount(0, 0, 0, 0), 1, @@ -731,7 +730,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(1, 1, 1), }, { - ", 9 Always ScrollBars", + "9 Always ScrollBars", QRectF(0, 0, viewWidth + 51, viewHeight + 101), ScrollBarCount(0, 0, 0, 0), 1, @@ -743,7 +742,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(101, 1, 1), }, { - ", 10 Always ScrollBars", + "10 Always ScrollBars", QRectF(-101, -101, viewWidth + 1, viewHeight + 1), ScrollBarCount(0, 0, 0, 0), 1, @@ -755,7 +754,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(-100, 1, 1), }, { - ", 11 Always ScrollBars", + "11 Always ScrollBars", QRectF(-101, -101, viewWidth + 51, viewHeight + 1), ScrollBarCount(0, 0, 0, 0), 1, @@ -767,7 +766,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(-100, 1, 1), }, { - ", 12 Always ScrollBars", + "12 Always ScrollBars", QRectF(-101, -101, viewWidth + 51, viewHeight + 101), ScrollBarCount(0, 0, 0, 0), 1, @@ -779,7 +778,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(0, 1, 1), }, { - ", 13 Always ScrollBars", + "13 Always ScrollBars", QRectF(0, 0, viewWidth, viewHeight), ScrollBarCount(0, 0, 1, 1), 1, @@ -791,7 +790,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(0, 2, 1), }, { - ", 14 Always ScrollBars", + "14 Always ScrollBars", QRectF(0, 0, viewWidth + 50, viewHeight), ScrollBarCount(0, 0, 1, 1), 1, @@ -803,7 +802,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(0, 2, 1), }, { - ", 15 Always ScrollBars", + "15 Always ScrollBars", QRectF(0, 0, viewWidth + 50, viewHeight + 100), ScrollBarCount(0, 0, 1, 1), 1, @@ -815,7 +814,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(100, 2, 1), }, { - ", 16 Always ScrollBars", + "16 Always ScrollBars", QRectF(-100, -100, viewWidth, viewHeight), ScrollBarCount(-1, -1, 1, 1), 1, @@ -827,7 +826,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(-100, 1, 1), }, { - ", 17 Always ScrollBars", + "17 Always ScrollBars", QRectF(-100, -100, viewWidth + 50, viewHeight), ScrollBarCount(-1, -1, 1, 1), 1, @@ -839,7 +838,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(-100, 1, 1), }, { - ", 18 Always ScrollBars", + "18 Always ScrollBars", QRectF(-100, -100, viewWidth + 50, viewHeight + 100), ScrollBarCount(-1, -1, 1, 1), 1, @@ -851,7 +850,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(0, 1, 1), }, { - ", 1 x2 Always ScrollBars", + "1 x2 Always ScrollBars", QRectF(0, 0, viewWidth, viewHeight), ScrollBarCount(0, 0, 0, 0), 2, @@ -863,7 +862,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(viewHeight, 1, 1), }, { - ", 2 x2 Always ScrollBars", + "2 x2 Always ScrollBars", QRectF(0, 0, viewWidth + 50, viewHeight), ScrollBarCount(0, 0, 0, 0), 2, @@ -875,7 +874,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(viewHeight, 1, 1), }, { - ", 3 x2 Always ScrollBars", + "3 x2 Always ScrollBars", QRectF(0, 0, viewWidth + 50, viewHeight + 100), ScrollBarCount(0, 0, 0, 0), 2, @@ -887,7 +886,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(viewHeight + 200, 1, 1), }, { - ", 4 x2 Always ScrollBars", + "4 x2 Always ScrollBars", QRectF(-100, -100, viewWidth, viewHeight), ScrollBarCount(0, 0, 0, 0), 2, @@ -899,7 +898,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(viewHeight - 200, 1, 1), }, { - ", 5 x2 Always ScrollBars", + "5 x2 Always ScrollBars", QRectF(-100, -100, viewWidth + 50, viewHeight), ScrollBarCount(0, 0, 0, 0), 2, @@ -911,7 +910,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(viewHeight - 200, 1, 1), }, { - ", 6 x2 Always ScrollBars", + "6 x2 Always ScrollBars", QRectF(-100, -100, viewWidth + 50, viewHeight + 100), ScrollBarCount(0, 0, 0, 0), 2, @@ -923,7 +922,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(viewHeight, 1, 1), }, { - ", 1 Vertical Only", + "1 Vertical Only", QRectF(0, 0, viewWidth, viewHeight), ScrollBarCount(0, 0, 0, 0), 1, @@ -935,7 +934,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(), }, { - ", 2 Vertical Only", + "2 Vertical Only", QRectF(0, 0, viewWidth + 50, viewHeight), ScrollBarCount(0, 0, 0, 0), 1, @@ -947,7 +946,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(), }, { - ", 3 Vertical Only", + "3 Vertical Only", QRectF(0, 0, viewWidth + 50, viewHeight + 100), ScrollBarCount(0, 0, 0, 0), 1, @@ -959,7 +958,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(100), }, { - ", 4 Vertical Only", + "4 Vertical Only", QRectF(-100, -100, viewWidth, viewHeight), ScrollBarCount(0, 0, 0, 0), 1, @@ -971,7 +970,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(), }, { - ", 5 Vertical Only", + "5 Vertical Only", QRectF(-100, -100, viewWidth + 50, viewHeight), ScrollBarCount(0, 0, 0, 0), 1, @@ -983,7 +982,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(), }, { - ", 6 Vertical Only", + "6 Vertical Only", QRectF(-100, -100, viewWidth + 50, viewHeight + 100), ScrollBarCount(0, 0, 0, 0), 1, @@ -995,7 +994,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(), }, { - ", 7 Vertical Only", + "7 Vertical Only", QRectF(0, 0, viewWidth + 1, viewHeight + 1), ScrollBarCount(0, 0, 0, 0), 1, @@ -1007,7 +1006,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(1), }, { - ", 8 Vertical Only", + "8 Vertical Only", QRectF(0, 0, viewWidth + 51, viewHeight + 1), ScrollBarCount(0, 0, 0, 0), 1, @@ -1019,7 +1018,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(1), }, { - ", 9 Vertical Only", + "9 Vertical Only", QRectF(0, 0, viewWidth + 51, viewHeight + 101), ScrollBarCount(0, 0, 0, 0), 1, @@ -1031,7 +1030,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(101), }, { - ", 10 Vertical Only", + "10 Vertical Only", QRectF(-101, -101, viewWidth + 1, viewHeight +1), ScrollBarCount(0, 0, 0, 0), 1, @@ -1043,7 +1042,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(-100), }, { - ", 11 Vertical Only", + "11 Vertical Only", QRectF(-101, -101, viewWidth + 51, viewHeight + 1), ScrollBarCount(0, 0, 0, 0), 1, @@ -1055,7 +1054,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(-100), }, { - ", 12 Vertical Only", + "12 Vertical Only", QRectF(-101, -101, viewWidth + 51, viewHeight + 101), ScrollBarCount(0, 0, 0, 0), 1, @@ -1067,7 +1066,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(), }, { - ", 13 Vertical Only", + "13 Vertical Only", QRectF(0, 0, viewWidth, viewHeight), ScrollBarCount(0, 0, 1, 1), 1, @@ -1079,7 +1078,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(0, 1), }, { - ", 14 Vertical Only", + "14 Vertical Only", QRectF(0, 0, viewWidth + 50, viewHeight), ScrollBarCount(0, 0, 1, 1), 1, @@ -1091,7 +1090,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(0, 1), }, { - ", 15 Vertical Only", + "15 Vertical Only", QRectF(0, 0, viewWidth + 50, viewHeight + 100), ScrollBarCount(0, 0, 1, 1), 1, @@ -1103,7 +1102,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(100, 1), }, { - ", 16 Vertical Only", + "16 Vertical Only", QRectF(-100, -100, viewWidth, viewHeight), ScrollBarCount(-1, -1, 1, 1), 1, @@ -1115,7 +1114,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(-100), }, { - ", 17 Vertical Only", + "17 Vertical Only", QRectF(-100, -100, viewWidth + 50, viewHeight), ScrollBarCount(-1, -1, 1, 1), 1, @@ -1127,7 +1126,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(-100), }, { - ", 18 Vertical Only", + "18 Vertical Only", QRectF(-100, -100, viewWidth + 50, viewHeight + 100), ScrollBarCount(-1, -1, 1, 1), 1, @@ -1139,7 +1138,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(), }, { - ", 1 x2 Vertical Only", + "1 x2 Vertical Only", QRectF(0, 0, viewWidth, viewHeight), ScrollBarCount(0, 0, 0, 0), 2, @@ -1151,7 +1150,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(viewHeight), }, { - ", 2 x2 Vertical Only", + "2 x2 Vertical Only", QRectF(0, 0, viewWidth + 50, viewHeight), ScrollBarCount(0, 0, 0, 0), 2, @@ -1163,7 +1162,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(viewHeight), }, { - ", 3 x2 Vertical Only", + "3 x2 Vertical Only", QRectF(0, 0, viewWidth + 50, viewHeight + 100), ScrollBarCount(0, 0, 0, 0), 2, @@ -1175,7 +1174,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(viewHeight + 200), }, { - ", 4 x2 Vertical Only", + "4 x2 Vertical Only", QRectF(-100, -100, viewWidth, viewHeight), ScrollBarCount(0, 0, 0, 0), 2, @@ -1187,7 +1186,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(viewHeight - 200), }, { - ", 5 x2 Vertical Only", + "5 x2 Vertical Only", QRectF(-100, -100, viewWidth + 50, viewHeight), ScrollBarCount(0, 0, 0, 0), 2, @@ -1199,7 +1198,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) ExpectedValueDescription(viewHeight - 200), }, { - ", 6 x2 Vertical Only", + "6 x2 Vertical Only", QRectF(-100, -100, viewWidth + 50, viewHeight + 100), ScrollBarCount(0, 0, 0, 0), 2, @@ -1215,7 +1214,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) const QSize viewSize(viewWidth, viewHeight); for (const Data &e : data) { - QTest::newRow(qPrintable(styleString + QLatin1String(e.name))) + QTest::addRow("%s%s, %s", style.data(), styled ? ", Styled" : "", e.name) << style << viewSize << e.sceneRect << e.sceneRectOffsetFactors @@ -1229,7 +1228,7 @@ static void _scrollBarRanges_addTestData(const QString &style, bool styled) void _scrollBarRanges_data() { - QTest::addColumn<QString>("style"); + QTest::addColumn<QByteArray>("style"); QTest::addColumn<QSize>("viewportSize"); QTest::addColumn<QRectF>("sceneRect"); QTest::addColumn<ScrollBarCount>("sceneRectOffsetFactors"); @@ -1242,14 +1241,15 @@ void _scrollBarRanges_data() QTest::addColumn<ExpectedValueDescription>("vmax"); QTest::addColumn<bool>("useStyledPanel"); - foreach (const QString &style, QStyleFactory::keys()) { - _scrollBarRanges_addTestData(style, false); - _scrollBarRanges_addTestData(style, true); + const auto styles = QStyleFactory::keys(); + for (const QString &style : styles) { + _scrollBarRanges_addTestData(style.toLatin1(), false); + _scrollBarRanges_addTestData(style.toLatin1(), true); } const QScreen *screen = QGuiApplication::primaryScreen(); if (screen && qFuzzyCompare((double)screen->logicalDotsPerInchX(), 96.0)) { - _scrollBarRanges_addTestData(QString("motif"), false); - _scrollBarRanges_addTestData(QString("motif"), true); + _scrollBarRanges_addTestData("motif", false); + _scrollBarRanges_addTestData("motif", true); } } diff --git a/tests/auto/widgets/itemviews/qdirmodel/qdirmodel.pro b/tests/auto/widgets/itemviews/qdirmodel/qdirmodel.pro index ea4e9d4620..61939983e6 100644 --- a/tests/auto/widgets/itemviews/qdirmodel/qdirmodel.pro +++ b/tests/auto/widgets/itemviews/qdirmodel/qdirmodel.pro @@ -3,6 +3,9 @@ TARGET = tst_qdirmodel QT += widgets testlib SOURCES += tst_qdirmodel.cpp +INCLUDEPATH += ../../../../shared/ +HEADERS += ../../../../shared/emulationdetector.h + wince* { addit.files = dirtest\\test1\\* addit.path = dirtest\\test1 diff --git a/tests/auto/widgets/itemviews/qdirmodel/tst_qdirmodel.cpp b/tests/auto/widgets/itemviews/qdirmodel/tst_qdirmodel.cpp index 30109952c7..2044704e76 100644 --- a/tests/auto/widgets/itemviews/qdirmodel/tst_qdirmodel.cpp +++ b/tests/auto/widgets/itemviews/qdirmodel/tst_qdirmodel.cpp @@ -32,6 +32,7 @@ #include <qtreeview.h> #include <qdir.h> #include <qdebug.h> +#include "emulationdetector.h" class tst_QDirModel : public QObject { @@ -615,6 +616,9 @@ void tst_QDirModel::task196768_sorting() #if defined(Q_OS_ANDROID) QEXPECT_FAIL("", "QTBUG-43818", Continue); +#else + if (EmulationDetector::isRunningArmOnX86()) + QEXPECT_FAIL("", "QTBUG-43818", Continue); #endif QCOMPARE(index.data(), index2.data()); diff --git a/tests/auto/widgets/kernel/qapplication/test/test.pro b/tests/auto/widgets/kernel/qapplication/test/test.pro index 92409e4bfe..7f75501474 100644 --- a/tests/auto/widgets/kernel/qapplication/test/test.pro +++ b/tests/auto/widgets/kernel/qapplication/test/test.pro @@ -1,5 +1,5 @@ CONFIG += testcase -CONFIG -= app_bundle debug_and_release_target +CONFIG -= debug_and_release_target QT += widgets widgets-private testlib QT += core-private gui-private diff --git a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp index 62c75cadf3..9d0c939d84 100644 --- a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp +++ b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp @@ -701,14 +701,14 @@ void tst_QShortcut::disabledItems() sendKeyEvents( Qt::CTRL+Qt::Key_M, 0 ); QCOMPARE( currentResult, NoResult ); if (over_330) - QCOMPARE( sbText, QString::null ); + QCOMPARE( sbText, QString() ); currentResult = NoResult; sendKeyEvents( Qt::CTRL+Qt::Key_K, 0 ); sendKeyEvents( Qt::CTRL+Qt::Key_L, 0 ); QCOMPARE( currentResult, Slot1Triggered ); if (over_330) - QCOMPARE( sbText, QString::null ); + QCOMPARE( sbText, QString() ); #endif clearAllShortcuts(); cut1 = 0; diff --git a/tests/auto/widgets/kernel/qsizepolicy/qsizepolicy.pro b/tests/auto/widgets/kernel/qsizepolicy/qsizepolicy.pro index 84629c7c0a..d325bc4aeb 100644 --- a/tests/auto/widgets/kernel/qsizepolicy/qsizepolicy.pro +++ b/tests/auto/widgets/kernel/qsizepolicy/qsizepolicy.pro @@ -1,4 +1,5 @@ CONFIG += testcase +contains(QT_CONFIG, c++14): CONFIG += c++14 TARGET = tst_qsizepolicy QT += widgets widgets-private testlib diff --git a/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp b/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp index 9e5fc55379..d50f46cc16 100644 --- a/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp +++ b/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp @@ -41,9 +41,12 @@ class tst_QSizePolicy : public QObject private Q_SLOTS: void cleanup() { QVERIFY(QApplication::topLevelWidgets().isEmpty()); } void qtest(); + void constExpr(); void defaultValues(); void getSetCheck_data() { data(); } void getSetCheck(); + void transposed_data() { data(); } + void transposed(); void dataStream(); void horizontalStretch(); void verticalStretch(); @@ -102,6 +105,24 @@ void tst_QSizePolicy::qtest() #undef CHECK2 } +void tst_QSizePolicy::constExpr() +{ +/* gcc < 4.8.0 has problems with init'ing variant members in constexpr ctors */ +/* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54922 */ +#if !defined(Q_CC_GNU) || defined(Q_CC_INTEL) || defined(Q_CC_CLANG) || Q_CC_GNU >= 408 + // check that certain ctors are constexpr (compile-only): + { Q_CONSTEXPR QSizePolicy sp; Q_UNUSED(sp); } + { Q_CONSTEXPR QSizePolicy sp = QSizePolicy(); Q_UNUSED(sp); } + { Q_CONSTEXPR QSizePolicy sp = QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); Q_UNUSED(sp); } + { Q_CONSTEXPR QSizePolicy sp = QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding, QSizePolicy::DefaultType); + Q_CONSTEXPR QSizePolicy tp = sp.transposed(); Q_UNUSED(tp); } + { Q_RELAXED_CONSTEXPR auto sp = QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed, QSizePolicy::CheckBox); + Q_RELAXED_CONSTEXPR auto tp = sp.transposed(); Q_UNUSED(tp); } +#else + QSKIP("QSizePolicy cannot be constexpr with this version of the compiler."); +#endif +} + void tst_QSizePolicy::defaultValues() { { @@ -147,14 +168,34 @@ void tst_QSizePolicy::getSetCheck() QCOMPARE(sp.expandingDirections(), ed); } +void tst_QSizePolicy::transposed() +{ + FETCH_TEST_DATA; + + const QSizePolicy tr = sp.transposed(); + + QCOMPARE(tr.horizontalPolicy(), vp); // swapped + QCOMPARE(tr.verticalPolicy(), hp); // swapped + QCOMPARE(tr.horizontalStretch(), vst); // swapped + QCOMPARE(tr.verticalStretch(), hst); // swapped + QCOMPARE(tr.controlType(), ct); // not swapped + QCOMPARE(tr.hasHeightForWidth(), hfw); // not swapped (historic behavior) + QCOMPARE(tr.hasWidthForHeight(), wfh); // not swapped (historic behavior) + QCOMPARE(tr.expandingDirections(), ed); // swapped + + // destructive test - keep last: + sp.transpose(); + QCOMPARE(sp, tr); +} + static void makeRow(QSizePolicy sp, QSizePolicy::Policy hp, QSizePolicy::Policy vp, int hst, int vst, QSizePolicy::ControlType ct, bool hfw, bool wfh, Qt::Orientations orients) { - QTest::newRow(qPrintable(QString::asprintf("%s-%s-%d-%d-%s-%s-%s", - PrettyPrint(hp).s(), PrettyPrint(vp).s(), hst, vst, - PrettyPrint(ct).s(), - hfw ? "true" : "false", wfh ? "true" : "false"))) + QTest::addRow("%s-%s-%d-%d-%s-%s-%s", + PrettyPrint(hp).s(), PrettyPrint(vp).s(), hst, vst, + PrettyPrint(ct).s(), + hfw ? "true" : "false", wfh ? "true" : "false") << sp << hp << vp << hst << vst << ct << hfw << wfh << orients; } diff --git a/tests/auto/widgets/kernel/qwidget/BLACKLIST b/tests/auto/widgets/kernel/qwidget/BLACKLIST index 6fe6bd2f67..9981fd3447 100644 --- a/tests/auto/widgets/kernel/qwidget/BLACKLIST +++ b/tests/auto/widgets/kernel/qwidget/BLACKLIST @@ -1,6 +1,7 @@ # OSX QTBUG-25300 QTBUG-45502 [normalGeometry] ubuntu-14.04 +ubuntu-16.04 [saveRestoreGeometry] ubuntu-14.04 ubuntu-16.04 @@ -9,6 +10,7 @@ ubuntu-14.04 osx [updateWhileMinimized] ubuntu-14.04 +ubuntu-16.04 rhel-7.1 rhel-7.2 osx diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 2698777ac8..ace2013740 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -408,6 +408,8 @@ private slots: void testForOutsideWSRangeFlag(); + void tabletTracking(); + private: bool ensureScreenSize(int width, int height); @@ -4271,12 +4273,14 @@ void tst_QWidget::update() } } +#ifndef Q_OS_OSX static inline bool isOpaque(QWidget *widget) { if (!widget) return false; return qt_widget_private(widget)->isOpaque; } +#endif void tst_QWidget::isOpaque() { @@ -5242,16 +5246,40 @@ protected: widgetDuringFocusAboutToChange = qApp->focusWidget(); return QWidget::event(ev); } + virtual void focusInEvent(QFocusEvent *) + { + foucsObjectDuringFocusIn = qApp->focusObject(); + detectedBadEventOrdering = foucsObjectDuringFocusIn != mostRecentFocusObjectChange; + } virtual void focusOutEvent(QFocusEvent *) { + foucsObjectDuringFocusOut = qApp->focusObject(); widgetDuringFocusOut = qApp->focusWidget(); + detectedBadEventOrdering = foucsObjectDuringFocusOut != mostRecentFocusObjectChange; + } + + void focusObjectChanged(QObject *focusObject) + { + mostRecentFocusObjectChange = focusObject; } public: - FocusWidget(QWidget *parent) : QWidget(parent), widgetDuringFocusAboutToChange(0), widgetDuringFocusOut(0) {} + FocusWidget(QWidget *parent) : QWidget(parent), + widgetDuringFocusAboutToChange(0), widgetDuringFocusOut(0), + foucsObjectDuringFocusIn(0), foucsObjectDuringFocusOut(0), + mostRecentFocusObjectChange(0), detectedBadEventOrdering(false) + { + connect(qGuiApp, &QGuiApplication::focusObjectChanged, this, &FocusWidget::focusObjectChanged); + } QWidget *widgetDuringFocusAboutToChange; QWidget *widgetDuringFocusOut; + + QObject *foucsObjectDuringFocusIn; + QObject *foucsObjectDuringFocusOut; + + QObject *mostRecentFocusObjectChange; + bool detectedBadEventOrdering; }; void tst_QWidget::setFocus() @@ -5452,6 +5480,40 @@ void tst_QWidget::setFocus() QCOMPARE(window.focusWidget(), nullptr); QCOMPARE(QApplication::focusWidget(), nullptr); } + + { + QWidget window; + window.resize(m_testWidgetSize); + window.move(windowPos); + + FocusWidget child1(&window); + QWidget child2(&window); + + window.show(); + window.activateWindow(); + QVERIFY(QTest::qWaitForWindowExposed(&window)); + QTRY_VERIFY(QApplication::focusWindow()); + + QCOMPARE(QApplication::focusObject(), &window); + + child1.setFocus(); + QTRY_VERIFY(child1.hasFocus()); + QCOMPARE(window.focusWidget(), &child1); + QCOMPARE(QApplication::focusWidget(), &child1); + QCOMPARE(QApplication::focusObject(), &child1); + QCOMPARE(child1.foucsObjectDuringFocusIn, &child1); + QVERIFY2(!child1.detectedBadEventOrdering, + "focusObjectChanged should be delivered before widget focus events on setFocus"); + + child1.clearFocus(); + QTRY_VERIFY(!child1.hasFocus()); + QCOMPARE(window.focusWidget(), nullptr); + QCOMPARE(QApplication::focusWidget(), nullptr); + QCOMPARE(QApplication::focusObject(), &window); + QVERIFY(child1.foucsObjectDuringFocusOut != &child1); + QVERIFY2(!child1.detectedBadEventOrdering, + "focusObjectChanged should be delivered before widget focus events on clearFocus"); + } } template<class T> class EventSpy : public QObject @@ -8147,7 +8209,7 @@ void tst_QWidget::customDpi() custom->logicalDpiX(); QCOMPARE(custom->metricCallCount, 1); child->logicalDpiX(); - QCOMPARE(custom->metricCallCount, 2); + QCOMPARE(custom->metricCallCount, 1); } void tst_QWidget::customDpiProperty() @@ -8985,8 +9047,13 @@ void tst_QWidget::taskQTBUG_4055_sendSyntheticEnterLeave() void tst_QWidget::windowFlags() { QWidget w; + const auto baseFlags = w.windowFlags(); w.setWindowFlags(w.windowFlags() | Qt::FramelessWindowHint); QVERIFY(w.windowFlags() & Qt::FramelessWindowHint); + w.setWindowFlag(Qt::WindowStaysOnTopHint, true); + QCOMPARE(w.windowFlags(), baseFlags | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint); + w.setWindowFlag(Qt::FramelessWindowHint, false); + QCOMPARE(w.windowFlags(), baseFlags | Qt::WindowStaysOnTopHint); } void tst_QWidget::initialPosForDontShowOnScreenWidgets() @@ -10492,5 +10559,109 @@ void tst_QWidget::testForOutsideWSRangeFlag() } } +class TabletWidget : public QWidget +{ +public: + TabletWidget(QWidget *parent) : QWidget(parent) { } + + int tabletEventCount = 0; + int pressEventCount = 0; + int moveEventCount = 0; + int releaseEventCount = 0; + int trackingChangeEventCount = 0; + qint64 uid = -1; + +protected: + void tabletEvent(QTabletEvent *event) override { + ++tabletEventCount; + uid = event->uniqueId(); + switch (event->type()) { + case QEvent::TabletMove: + ++moveEventCount; + break; + case QEvent::TabletPress: + ++pressEventCount; + break; + case QEvent::TabletRelease: + ++releaseEventCount; + break; + default: + break; + } + } + + bool event(QEvent *ev) override { + if (ev->type() == QEvent::TabletTrackingChange) + ++trackingChangeEventCount; + return QWidget::event(ev); + } +}; + +void tst_QWidget::tabletTracking() +{ + QWidget parent; + parent.resize(200,200); + // QWidgetWindow::handleTabletEvent doesn't deliver tablet events to the window's widget, only to a child. + // So it doesn't do any good to show a TabletWidget directly: it needs a parent. + TabletWidget widget(&parent); + widget.resize(200,200); + parent.showNormal(); + QVERIFY(QTest::qWaitForWindowExposed(&parent)); + widget.setAttribute(Qt::WA_TabletTracking); + QTRY_COMPARE(widget.trackingChangeEventCount, 1); + QVERIFY(widget.hasTabletTracking()); + + QWindow *window = parent.windowHandle(); + QPointF local(10, 10); + QPointF global = window->mapToGlobal(local.toPoint()); + QPointF deviceLocal = QHighDpi::toNativeLocalPosition(local, window); + QPointF deviceGlobal = QHighDpi::toNativePixels(global, window->screen()); + qint64 uid = 1234UL; + + QWindowSystemInterface::handleTabletEvent(window, QDateTime::currentMSecsSinceEpoch(), deviceLocal, deviceGlobal, + QTabletEvent::Stylus, QTabletEvent::Pen, Qt::NoButton, 0, 0, 0, 0, 0, 0, uid, Qt::NoModifier); + QCoreApplication::processEvents(); + QTRY_COMPARE(widget.moveEventCount, 1); + QCOMPARE(widget.uid, uid); + + local += QPoint(10, 10); + deviceLocal += QPoint(10, 10); + deviceGlobal += QPoint(10, 10); + QWindowSystemInterface::handleTabletEvent(window, QDateTime::currentMSecsSinceEpoch(), deviceLocal, deviceGlobal, + QTabletEvent::Stylus, QTabletEvent::Pen, Qt::NoButton, 0, 0, 0, 0, 0, 0, uid, Qt::NoModifier); + QCoreApplication::processEvents(); + QTRY_COMPARE(widget.moveEventCount, 2); + + widget.setTabletTracking(false); + QCoreApplication::processEvents(); + QTRY_COMPARE(widget.trackingChangeEventCount, 2); + + QWindowSystemInterface::handleTabletEvent(window, QDateTime::currentMSecsSinceEpoch(), deviceLocal, deviceGlobal, + QTabletEvent::Stylus, QTabletEvent::Pen, Qt::LeftButton, 0, 0, 0, 0, 0, 0, uid, Qt::NoModifier); + QCoreApplication::processEvents(); + QTRY_COMPARE(widget.pressEventCount, 1); + + local += QPoint(10, 10); + deviceLocal += QPoint(10, 10); + deviceGlobal += QPoint(10, 10); + QWindowSystemInterface::handleTabletEvent(window, QDateTime::currentMSecsSinceEpoch(), deviceLocal, deviceGlobal, + QTabletEvent::Stylus, QTabletEvent::Pen, Qt::LeftButton, 0, 0, 0, 0, 0, 0, uid, Qt::NoModifier); + QCoreApplication::processEvents(); + QTRY_COMPARE(widget.moveEventCount, 3); + + QWindowSystemInterface::handleTabletEvent(window, QDateTime::currentMSecsSinceEpoch(), deviceLocal, deviceGlobal, + QTabletEvent::Stylus, QTabletEvent::Pen, Qt::NoButton, 0, 0, 0, 0, 0, 0, uid, Qt::NoModifier); + QCoreApplication::processEvents(); + QTRY_COMPARE(widget.releaseEventCount, 1); + + local += QPoint(10, 10); + deviceLocal += QPoint(10, 10); + deviceGlobal += QPoint(10, 10); + QWindowSystemInterface::handleTabletEvent(window, QDateTime::currentMSecsSinceEpoch(), deviceLocal, deviceGlobal, + QTabletEvent::Stylus, QTabletEvent::Pen, Qt::NoButton, 0, 0, 0, 0, 0, 0, uid, Qt::NoModifier); + QCoreApplication::processEvents(); + QTRY_COMPARE(widget.moveEventCount, 3); +} + QTEST_MAIN(tst_QWidget) #include "tst_qwidget.moc" diff --git a/tests/auto/widgets/kernel/qwindowcontainer/qwindowcontainer.pro b/tests/auto/widgets/kernel/qwindowcontainer/qwindowcontainer.pro index 17fc1d28b5..50069b7e3e 100644 --- a/tests/auto/widgets/kernel/qwindowcontainer/qwindowcontainer.pro +++ b/tests/auto/widgets/kernel/qwindowcontainer/qwindowcontainer.pro @@ -1,5 +1,4 @@ CONFIG += testcase -mac:CONFIG -= app_bundle TARGET = tst_qwindowcontainer QT += widgets testlib SOURCES += tst_qwindowcontainer.cpp diff --git a/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp b/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp index 5e3868ea8f..6ec1b754d0 100644 --- a/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp +++ b/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp @@ -37,6 +37,7 @@ #include <qmainwindow.h> #include <qscreen.h> #include <qscopedpointer.h> +#include <qevent.h> class Window : public QWindow @@ -77,6 +78,7 @@ private slots: void testAncestorChange(); void testDockWidget(); void testNativeContainerParent(); + void testPlatformSurfaceEvent(); void cleanup(); private: @@ -343,6 +345,41 @@ void tst_QWindowContainer::testNativeContainerParent() QTRY_COMPARE(window->parent(), container->windowHandle()); } +class EventWindow : public QWindow +{ +public: + EventWindow(bool *surfaceDestroyFlag) : m_surfaceDestroyFlag(surfaceDestroyFlag) { } + bool event(QEvent *e) override; + +private: + bool *m_surfaceDestroyFlag; +}; + +bool EventWindow::event(QEvent *e) +{ + if (e->type() == QEvent::PlatformSurface) { + if (static_cast<QPlatformSurfaceEvent *>(e)->surfaceEventType() == QPlatformSurfaceEvent::SurfaceAboutToBeDestroyed) + *m_surfaceDestroyFlag = true; + } + return QWindow::event(e); +} + +void tst_QWindowContainer::testPlatformSurfaceEvent() +{ + // Verify that SurfaceAboutToBeDestroyed is delivered and the + // window subclass still gets a chance to process it. + + bool ok = false; + QPointer<EventWindow> window(new EventWindow(&ok)); + window->create(); + QWidget *container = QWidget::createWindowContainer(window); + + delete container; + + QCOMPARE(window.data(), nullptr); + QVERIFY(ok); +} + QTEST_MAIN(tst_QWindowContainer) #include "tst_qwindowcontainer.moc" diff --git a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp index 92a8dff218..937be944a1 100644 --- a/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp +++ b/tests/auto/widgets/util/qcompleter/tst_qcompleter.cpp @@ -1193,7 +1193,7 @@ void tst_QCompleter::disabledItems() model->appendRow(suggestions); model->appendRow(new QStandardItem("suggestions Enabled")); QCompleter *completer = new QCompleter(model, &lineEdit); - QSignalSpy spy(completer, SIGNAL(activated(QString))); + QSignalSpy spy(completer, QOverload<const QString &>::of(&QCompleter::activated)); lineEdit.setCompleter(completer); lineEdit.move(200, 200); lineEdit.show(); @@ -1219,7 +1219,7 @@ void tst_QCompleter::task178797_activatedOnReturn() setFrameless(&ledit); QCompleter *completer = new QCompleter(words, &ledit); ledit.setCompleter(completer); - QSignalSpy spy(completer, SIGNAL(activated(QString))); + QSignalSpy spy(completer, QOverload<const QString &>::of(&QCompleter::activated)); QCOMPARE(spy.count(), 0); ledit.move(200, 200); ledit.show(); @@ -1287,7 +1287,7 @@ public: if (completer()) { completer()->setCompletionMode(QCompleter::PopupCompletion); completer()->setCompletionRole(Qt::DisplayRole); - connect(lineEdit(), SIGNAL(editingFinished()), SLOT(setCompletionPrefix())); + connect(lineEdit(), &QLineEdit::editingFinished, this, &task246056_ComboBox::setCompletionPrefix); } } private slots: @@ -1306,7 +1306,7 @@ void tst_QCompleter::task246056_setCompletionPrefix() comboBox.show(); QApplication::setActiveWindow(&comboBox); QVERIFY(QTest::qWaitForWindowActive(&comboBox)); - QSignalSpy spy(comboBox.completer(), SIGNAL(activated(QModelIndex))); + QSignalSpy spy(comboBox.completer(), QOverload<const QModelIndex &>::of(&QCompleter::activated)); QTest::keyPress(&comboBox, 'a'); QTest::keyPress(comboBox.completer()->popup(), Qt::Key_Down); QTest::keyPress(comboBox.completer()->popup(), Qt::Key_Down); diff --git a/tests/auto/widgets/util/qsystemtrayicon/tst_qsystemtrayicon.cpp b/tests/auto/widgets/util/qsystemtrayicon/tst_qsystemtrayicon.cpp index 616898c4c5..5acaf49e6c 100644 --- a/tests/auto/widgets/util/qsystemtrayicon/tst_qsystemtrayicon.cpp +++ b/tests/auto/widgets/util/qsystemtrayicon/tst_qsystemtrayicon.cpp @@ -118,7 +118,7 @@ void tst_QSystemTrayIcon::supportsMessages() void tst_QSystemTrayIcon::lastWindowClosed() { - QSignalSpy spy(qApp, SIGNAL(lastWindowClosed())); + QSignalSpy spy(qApp, &QApplication::lastWindowClosed); QWidget window; QSystemTrayIcon icon; icon.setIcon(QIcon("whatever.png")); diff --git a/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp b/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp index 2c3eb66384..62c3469447 100644 --- a/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp +++ b/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp @@ -379,12 +379,12 @@ void tst_QUndoGroup::checkSignals() QUndoGroup group; const QScopedPointer<QAction> undo_action(group.createUndoAction(0, QString("foo"))); const QScopedPointer<QAction> redo_action(group.createRedoAction(0, QString("bar"))); - QSignalSpy indexChangedSpy(&group, SIGNAL(indexChanged(int))); - QSignalSpy cleanChangedSpy(&group, SIGNAL(cleanChanged(bool))); - QSignalSpy canUndoChangedSpy(&group, SIGNAL(canUndoChanged(bool))); - QSignalSpy undoTextChangedSpy(&group, SIGNAL(undoTextChanged(QString))); - QSignalSpy canRedoChangedSpy(&group, SIGNAL(canRedoChanged(bool))); - QSignalSpy redoTextChangedSpy(&group, SIGNAL(redoTextChanged(QString))); + QSignalSpy indexChangedSpy(&group, &QUndoGroup::indexChanged); + QSignalSpy cleanChangedSpy(&group, &QUndoGroup::cleanChanged); + QSignalSpy canUndoChangedSpy(&group, &QUndoGroup::canUndoChanged); + QSignalSpy undoTextChangedSpy(&group, &QUndoGroup::undoTextChanged); + QSignalSpy canRedoChangedSpy(&group, &QUndoGroup::canRedoChanged); + QSignalSpy redoTextChangedSpy(&group, &QUndoGroup::redoTextChanged); QString str; diff --git a/tests/auto/widgets/util/qundostack/tst_qundostack.cpp b/tests/auto/widgets/util/qundostack/tst_qundostack.cpp index ba3d80bbe4..f3185086b8 100644 --- a/tests/auto/widgets/util/qundostack/tst_qundostack.cpp +++ b/tests/auto/widgets/util/qundostack/tst_qundostack.cpp @@ -95,6 +95,23 @@ public: virtual void redo(); }; +class MoveMouseCommand : public QUndoCommand +{ +public: + MoveMouseCommand(QPoint *mouse, QPoint oldPoint, QPoint newPoint, QUndoCommand *parent = 0); + ~MoveMouseCommand(); + + virtual void undo(); + virtual void redo(); + virtual int id() const; + virtual bool mergeWith(const QUndoCommand *other); + +private: + QPoint *m_mouse; + QPoint m_oldPoint; + QPoint m_newPoint; +}; + InsertCommand::InsertCommand(QString *str, int idx, const QString &text, QUndoCommand *parent) : QUndoCommand(parent) @@ -215,6 +232,48 @@ void IdleCommand::undo() { } +MoveMouseCommand::MoveMouseCommand(QPoint *mouse, QPoint oldPoint, QPoint newPoint, QUndoCommand *parent) + : QUndoCommand(parent) +{ + setText("move mouse"); + + m_mouse = mouse; + m_oldPoint = oldPoint; + m_newPoint = newPoint; + + if (m_oldPoint == m_newPoint) + setObsolete(true); +} + +MoveMouseCommand::~MoveMouseCommand() +{ +} + +void MoveMouseCommand::redo() +{ + *m_mouse = m_newPoint; +} + +void MoveMouseCommand::undo() +{ + *m_mouse = m_oldPoint; +} + +int MoveMouseCommand::id() const +{ + return 2; +} + +bool MoveMouseCommand::mergeWith(const QUndoCommand *other) +{ + m_newPoint = static_cast<const MoveMouseCommand*>(other)->m_newPoint; + + if (m_newPoint == m_oldPoint) + setObsolete(true); + + return true; +} + /****************************************************************************** ** tst_QUndoStack */ @@ -233,6 +292,7 @@ private slots: void childCommand(); void macroBeginEnd(); void compression(); + void obsolete(); void undoLimit(); void commandTextFormat(); void separateUndoText(); @@ -329,12 +389,12 @@ void tst_QUndoStack::undoRedo() QUndoStack stack; const QScopedPointer<QAction> undoAction(stack.createUndoAction(0, QString("foo"))); const QScopedPointer<QAction> redoAction(stack.createRedoAction(0, QString("bar"))); - QSignalSpy indexChangedSpy(&stack, SIGNAL(indexChanged(int))); - QSignalSpy cleanChangedSpy(&stack, SIGNAL(cleanChanged(bool))); - QSignalSpy canUndoChangedSpy(&stack, SIGNAL(canUndoChanged(bool))); - QSignalSpy undoTextChangedSpy(&stack, SIGNAL(undoTextChanged(QString))); - QSignalSpy canRedoChangedSpy(&stack, SIGNAL(canRedoChanged(bool))); - QSignalSpy redoTextChangedSpy(&stack, SIGNAL(redoTextChanged(QString))); + QSignalSpy indexChangedSpy(&stack, &QUndoStack::indexChanged); + QSignalSpy cleanChangedSpy(&stack, &QUndoStack::cleanChanged); + QSignalSpy canUndoChangedSpy(&stack, &QUndoStack::canUndoChanged); + QSignalSpy undoTextChangedSpy(&stack, &QUndoStack::undoTextChanged); + QSignalSpy canRedoChangedSpy(&stack, &QUndoStack::canRedoChanged); + QSignalSpy redoTextChangedSpy(&stack, &QUndoStack::redoTextChanged); QString str; // push, undo, redo @@ -690,12 +750,12 @@ void tst_QUndoStack::setIndex() QUndoStack stack; const QScopedPointer<QAction> undoAction(stack.createUndoAction(0, QString("foo"))); const QScopedPointer<QAction> redoAction(stack.createRedoAction(0, QString("bar"))); - QSignalSpy indexChangedSpy(&stack, SIGNAL(indexChanged(int))); - QSignalSpy cleanChangedSpy(&stack, SIGNAL(cleanChanged(bool))); - QSignalSpy canUndoChangedSpy(&stack, SIGNAL(canUndoChanged(bool))); - QSignalSpy undoTextChangedSpy(&stack, SIGNAL(undoTextChanged(QString))); - QSignalSpy canRedoChangedSpy(&stack, SIGNAL(canRedoChanged(bool))); - QSignalSpy redoTextChangedSpy(&stack, SIGNAL(redoTextChanged(QString))); + QSignalSpy indexChangedSpy(&stack, &QUndoStack::indexChanged); + QSignalSpy cleanChangedSpy(&stack, &QUndoStack::cleanChanged); + QSignalSpy canUndoChangedSpy(&stack, &QUndoStack::canUndoChanged); + QSignalSpy undoTextChangedSpy(&stack, &QUndoStack::undoTextChanged); + QSignalSpy canRedoChangedSpy(&stack, &QUndoStack::canRedoChanged); + QSignalSpy redoTextChangedSpy(&stack, &QUndoStack::redoTextChanged); QString str; stack.setIndex(10); // should do nothing @@ -954,12 +1014,12 @@ void tst_QUndoStack::setClean() QUndoStack stack; const QScopedPointer<QAction> undoAction(stack.createUndoAction(0, QString("foo"))); const QScopedPointer<QAction> redoAction(stack.createRedoAction(0, QString("bar"))); - QSignalSpy indexChangedSpy(&stack, SIGNAL(indexChanged(int))); - QSignalSpy cleanChangedSpy(&stack, SIGNAL(cleanChanged(bool))); - QSignalSpy canUndoChangedSpy(&stack, SIGNAL(canUndoChanged(bool))); - QSignalSpy undoTextChangedSpy(&stack, SIGNAL(undoTextChanged(QString))); - QSignalSpy canRedoChangedSpy(&stack, SIGNAL(canRedoChanged(bool))); - QSignalSpy redoTextChangedSpy(&stack, SIGNAL(redoTextChanged(QString))); + QSignalSpy indexChangedSpy(&stack, &QUndoStack::indexChanged); + QSignalSpy cleanChangedSpy(&stack, &QUndoStack::cleanChanged); + QSignalSpy canUndoChangedSpy(&stack, &QUndoStack::canUndoChanged); + QSignalSpy undoTextChangedSpy(&stack, &QUndoStack::undoTextChanged); + QSignalSpy canRedoChangedSpy(&stack, &QUndoStack::canRedoChanged); + QSignalSpy redoTextChangedSpy(&stack, &QUndoStack::redoTextChanged); QString str; QCOMPARE(stack.cleanIndex(), 0); @@ -1351,12 +1411,12 @@ void tst_QUndoStack::clear() QUndoStack stack; const QScopedPointer<QAction> undoAction(stack.createUndoAction(0, QString("foo"))); const QScopedPointer<QAction> redoAction(stack.createRedoAction(0, QString("bar"))); - QSignalSpy indexChangedSpy(&stack, SIGNAL(indexChanged(int))); - QSignalSpy cleanChangedSpy(&stack, SIGNAL(cleanChanged(bool))); - QSignalSpy canUndoChangedSpy(&stack, SIGNAL(canUndoChanged(bool))); - QSignalSpy undoTextChangedSpy(&stack, SIGNAL(undoTextChanged(QString))); - QSignalSpy canRedoChangedSpy(&stack, SIGNAL(canRedoChanged(bool))); - QSignalSpy redoTextChangedSpy(&stack, SIGNAL(redoTextChanged(QString))); + QSignalSpy indexChangedSpy(&stack, &QUndoStack::indexChanged); + QSignalSpy cleanChangedSpy(&stack, &QUndoStack::cleanChanged); + QSignalSpy canUndoChangedSpy(&stack, &QUndoStack::canUndoChanged); + QSignalSpy undoTextChangedSpy(&stack, &QUndoStack::undoTextChanged); + QSignalSpy canRedoChangedSpy(&stack, &QUndoStack::canRedoChanged); + QSignalSpy redoTextChangedSpy(&stack, &QUndoStack::redoTextChanged); QString str; stack.clear(); @@ -1549,12 +1609,12 @@ void tst_QUndoStack::childCommand() QUndoStack stack; const QScopedPointer<QAction> undoAction(stack.createUndoAction(0, QString("foo"))); const QScopedPointer<QAction> redoAction(stack.createRedoAction(0, QString("bar"))); - QSignalSpy indexChangedSpy(&stack, SIGNAL(indexChanged(int))); - QSignalSpy cleanChangedSpy(&stack, SIGNAL(cleanChanged(bool))); - QSignalSpy canUndoChangedSpy(&stack, SIGNAL(canUndoChanged(bool))); - QSignalSpy undoTextChangedSpy(&stack, SIGNAL(undoTextChanged(QString))); - QSignalSpy canRedoChangedSpy(&stack, SIGNAL(canRedoChanged(bool))); - QSignalSpy redoTextChangedSpy(&stack, SIGNAL(redoTextChanged(QString))); + QSignalSpy indexChangedSpy(&stack, &QUndoStack::indexChanged); + QSignalSpy cleanChangedSpy(&stack, &QUndoStack::cleanChanged); + QSignalSpy canUndoChangedSpy(&stack, &QUndoStack::canUndoChanged); + QSignalSpy undoTextChangedSpy(&stack, &QUndoStack::undoTextChanged); + QSignalSpy canRedoChangedSpy(&stack, &QUndoStack::canRedoChanged); + QSignalSpy redoTextChangedSpy(&stack, &QUndoStack::redoTextChanged); QString str; stack.push(new InsertCommand(&str, 0, "hello")); @@ -1659,12 +1719,12 @@ void tst_QUndoStack::macroBeginEnd() QUndoStack stack; const QScopedPointer<QAction> undoAction(stack.createUndoAction(0, QString("foo"))); const QScopedPointer<QAction> redoAction(stack.createRedoAction(0, QString("bar"))); - QSignalSpy indexChangedSpy(&stack, SIGNAL(indexChanged(int))); - QSignalSpy cleanChangedSpy(&stack, SIGNAL(cleanChanged(bool))); - QSignalSpy canUndoChangedSpy(&stack, SIGNAL(canUndoChanged(bool))); - QSignalSpy undoTextChangedSpy(&stack, SIGNAL(undoTextChanged(QString))); - QSignalSpy canRedoChangedSpy(&stack, SIGNAL(canRedoChanged(bool))); - QSignalSpy redoTextChangedSpy(&stack, SIGNAL(redoTextChanged(QString))); + QSignalSpy indexChangedSpy(&stack, &QUndoStack::indexChanged); + QSignalSpy cleanChangedSpy(&stack, &QUndoStack::cleanChanged); + QSignalSpy canUndoChangedSpy(&stack, &QUndoStack::canUndoChanged); + QSignalSpy undoTextChangedSpy(&stack, &QUndoStack::undoTextChanged); + QSignalSpy canRedoChangedSpy(&stack, &QUndoStack::canRedoChanged); + QSignalSpy redoTextChangedSpy(&stack, &QUndoStack::redoTextChanged); QString str; stack.beginMacro("ding"); @@ -2126,12 +2186,12 @@ void tst_QUndoStack::compression() QUndoStack stack; const QScopedPointer<QAction> undoAction(stack.createUndoAction(0, QString("foo"))); const QScopedPointer<QAction> redoAction(stack.createRedoAction(0, QString("bar"))); - QSignalSpy indexChangedSpy(&stack, SIGNAL(indexChanged(int))); - QSignalSpy cleanChangedSpy(&stack, SIGNAL(cleanChanged(bool))); - QSignalSpy canUndoChangedSpy(&stack, SIGNAL(canUndoChanged(bool))); - QSignalSpy undoTextChangedSpy(&stack, SIGNAL(undoTextChanged(QString))); - QSignalSpy canRedoChangedSpy(&stack, SIGNAL(canRedoChanged(bool))); - QSignalSpy redoTextChangedSpy(&stack, SIGNAL(redoTextChanged(QString))); + QSignalSpy indexChangedSpy(&stack, &QUndoStack::indexChanged); + QSignalSpy cleanChangedSpy(&stack, &QUndoStack::cleanChanged); + QSignalSpy canUndoChangedSpy(&stack, &QUndoStack::canUndoChanged); + QSignalSpy undoTextChangedSpy(&stack, &QUndoStack::undoTextChanged); + QSignalSpy canRedoChangedSpy(&stack, &QUndoStack::canRedoChanged); + QSignalSpy redoTextChangedSpy(&stack, &QUndoStack::redoTextChanged); QString str; AppendCommand::delete_cnt = 0; @@ -2563,17 +2623,722 @@ void tst_QUndoStack::compression() true); // redoChanged } +void tst_QUndoStack::obsolete() +{ + QUndoStack stack; + const QScopedPointer<QAction> undoAction(stack.createUndoAction(0, QString("foo"))); + const QScopedPointer<QAction> redoAction(stack.createRedoAction(0, QString("bar"))); + QSignalSpy indexChangedSpy(&stack, &QUndoStack::indexChanged); + QSignalSpy cleanChangedSpy(&stack, &QUndoStack::cleanChanged); + QSignalSpy canUndoChangedSpy(&stack, &QUndoStack::canUndoChanged); + QSignalSpy undoTextChangedSpy(&stack, &QUndoStack::undoTextChanged); + QSignalSpy canRedoChangedSpy(&stack, &QUndoStack::canRedoChanged); + QSignalSpy redoTextChangedSpy(&stack, &QUndoStack::redoTextChanged); + QPoint mouse(0, 0); + QString str; + MoveMouseCommand *cmd1 = 0; + MoveMouseCommand *cmd2 = 0; + + stack.resetClean(); + checkState(redoTextChangedSpy, + canRedoChangedSpy, + undoTextChangedSpy, + redoAction, + undoAction, + canUndoChangedSpy, + cleanChangedSpy, + indexChangedSpy, + stack, + false, // clean + 0, // count + 0, // index + false, // canUndo + "", // undoText + false, // canRedo + "", // redoText + true, // cleanChanged + false, // indexChanged + false, // undoChanged + false); // redoChanged + + stack.push(new MoveMouseCommand(&mouse, mouse, QPoint(0, 0))); // #1 should not merge but will be deleted (b/c oldPoint == newPoint) + QCOMPARE(mouse, QPoint(0, 0)); + checkState(redoTextChangedSpy, + canRedoChangedSpy, + undoTextChangedSpy, + redoAction, + undoAction, + canUndoChangedSpy, + cleanChangedSpy, + indexChangedSpy, + stack, + false, // clean + 0, // count + 0, // index + false, // canUndo + "", // undoText + false, // canRedo + "", // redoText + false, // cleanChanged + false, // indexChanged + false, // undoChanged + false); // redoChanged + + stack.push(new MoveMouseCommand(&mouse, mouse, QPoint(12, 0))); // #2 should not merge or be deleted (b/c oldPoint != newPoint) + QCOMPARE(mouse, QPoint(12, 0)); + checkState(redoTextChangedSpy, + canRedoChangedSpy, + undoTextChangedSpy, + redoAction, + undoAction, + canUndoChangedSpy, + cleanChangedSpy, + indexChangedSpy, + stack, + false, // clean + 1, // count + 1, // index + true, // canUndo + "move mouse", // undoText + false, // canRedo + "", // redoText + false, // cleanChanged + true, // indexChanged + true, // undoChanged + true); // redoChanged + + stack.push(new MoveMouseCommand(&mouse, mouse, QPoint(8, 2))); // #3 should merge and not be deleted (b/c oldPoint != newPoint) + QCOMPARE(mouse, QPoint(8, 2)); + checkState(redoTextChangedSpy, + canRedoChangedSpy, + undoTextChangedSpy, + redoAction, + undoAction, + canUndoChangedSpy, + cleanChangedSpy, + indexChangedSpy, + stack, + false, // clean + 1, // count + 1, // index + true, // canUndo + "move mouse", // undoText + false, // canRedo + "", // redoText + false, // cleanChanged + true, // indexChanged + true, // undoChanged + true); // redoChanged + + stack.push(new MoveMouseCommand(&mouse, mouse, QPoint(0, 0))); // #4 should merge and be deleted (b/c oldPoint == newPoint) + QCOMPARE(mouse, QPoint(0, 0)); + checkState(redoTextChangedSpy, + canRedoChangedSpy, + undoTextChangedSpy, + redoAction, + undoAction, + canUndoChangedSpy, + cleanChangedSpy, + indexChangedSpy, + stack, + false, // clean + 0, // count + 0, // index + false, // canUndo + "", // undoText + false, // canRedo + "", // redoText + false, // cleanChanged + true, // indexChanged + true, // undoChanged + true); // redoChanged + + + + + stack.push(new InsertCommand(&str, 0, "ene")); // #5 should not merge or be deleted + QCOMPARE(str, QString("ene")); + checkState(redoTextChangedSpy, + canRedoChangedSpy, + undoTextChangedSpy, + redoAction, + undoAction, + canUndoChangedSpy, + cleanChangedSpy, + indexChangedSpy, + stack, + false, // clean + 1, // count + 1, // index + true, // canUndo + "insert", // undoText + false, // canRedo + "", // redoText + false, // cleanChanged + true, // indexChanged + true, // undoChanged + true); // redoChanged + + cmd1 = new MoveMouseCommand(&mouse, mouse, QPoint(6, 5)); + stack.push(cmd1); // #6 should not merge or be deleted (b/c oldPoint != newPoint) + QCOMPARE(mouse, QPoint(6, 5)); + checkState(redoTextChangedSpy, + canRedoChangedSpy, + undoTextChangedSpy, + redoAction, + undoAction, + canUndoChangedSpy, + cleanChangedSpy, + indexChangedSpy, + stack, + false, // clean + 2, // count + 2, // index + true, // canUndo + "move mouse", // undoText + false, // canRedo + "", // redoText + false, // cleanChanged + true, // indexChanged + true, // undoChanged + true); // redoChanged + + stack.push(new InsertCommand(&str, 3, "ma")); // #7 should not merge or be deleted + QCOMPARE(str, QString("enema")); + checkState(redoTextChangedSpy, + canRedoChangedSpy, + undoTextChangedSpy, + redoAction, + undoAction, + canUndoChangedSpy, + cleanChangedSpy, + indexChangedSpy, + stack, + false, // clean + 3, // count + 3, // index + true, // canUndo + "insert", // undoText + false, // canRedo + "", // redoText + false, // cleanChanged + true, // indexChanged + true, // undoChanged + true); // redoChanged + + cmd2 = new MoveMouseCommand(&mouse, mouse, QPoint(12, 4)); + stack.push(cmd2); // #8 should not merge or be deleted (b/c oldPoint != newPoint) + QCOMPARE(mouse, QPoint(12, 4)); + checkState(redoTextChangedSpy, + canRedoChangedSpy, + undoTextChangedSpy, + redoAction, + undoAction, + canUndoChangedSpy, + cleanChangedSpy, + indexChangedSpy, + stack, + false, // clean + 4, // count + 4, // index + true, // canUndo + "move mouse", // undoText + false, // canRedo + "", // redoText + false, // cleanChanged + true, // indexChanged + true, // undoChanged + true); // redoChanged + + stack.setClean(); + checkState(redoTextChangedSpy, + canRedoChangedSpy, + undoTextChangedSpy, + redoAction, + undoAction, + canUndoChangedSpy, + cleanChangedSpy, + indexChangedSpy, + stack, + true, // clean + 4, // count + 4, // index + true, // canUndo + "move mouse", // undoText + false, // canRedo + "", // redoText + true, // cleanChanged + false, // indexChanged + false, // undoChanged + false); // redoChanged + QCOMPARE(stack.cleanIndex(), 4); + + cmd2->setObsolete(true); + checkState(redoTextChangedSpy, + canRedoChangedSpy, + undoTextChangedSpy, + redoAction, + undoAction, + canUndoChangedSpy, + cleanChangedSpy, + indexChangedSpy, + stack, + true, // clean + 4, // count + 4, // index + true, // canUndo + "move mouse", // undoText + false, // canRedo + "", // redoText + false, // cleanChanged + false, // indexChanged + false, // undoChanged + false); // redoChanged + + stack.undo(); + checkState(redoTextChangedSpy, + canRedoChangedSpy, + undoTextChangedSpy, + redoAction, + undoAction, + canUndoChangedSpy, + cleanChangedSpy, + indexChangedSpy, + stack, + false, // clean + 3, // count + 3, // index + true, // canUndo + "insert", // undoText + false, // canRedo + "", // redoText + true, // cleanChanged + true, // indexChanged + true, // undoChanged + true); // redoChanged + QCOMPARE(stack.cleanIndex(), -1); + + stack.undo(); + checkState(redoTextChangedSpy, + canRedoChangedSpy, + undoTextChangedSpy, + redoAction, + undoAction, + canUndoChangedSpy, + cleanChangedSpy, + indexChangedSpy, + stack, + false, // clean + 3, // count + 2, // index + true, // canUndo + "move mouse", // undoText + true, // canRedo + "insert", // redoText + false, // cleanChanged + true, // indexChanged + true, // undoChanged + true); // redoChanged + + stack.setClean(); + checkState(redoTextChangedSpy, + canRedoChangedSpy, + undoTextChangedSpy, + redoAction, + undoAction, + canUndoChangedSpy, + cleanChangedSpy, + indexChangedSpy, + stack, + true, // clean + 3, // count + 2, // index + true, // canUndo + "move mouse", // undoText + true, // canRedo + "insert", // redoText + true, // cleanChanged + false, // indexChanged + false, // undoChanged + false); // redoChanged + QCOMPARE(stack.cleanIndex(), 2); + + stack.undo(); + checkState(redoTextChangedSpy, + canRedoChangedSpy, + undoTextChangedSpy, + redoAction, + undoAction, + canUndoChangedSpy, + cleanChangedSpy, + indexChangedSpy, + stack, + false, // clean + 3, // count + 1, // index + true, // canUndo + "insert", // undoText + true, // canRedo + "move mouse", // redoText + true, // cleanChanged + true, // indexChanged + true, // undoChanged + true); // redoChanged + + cmd1->setObsolete(true); + checkState(redoTextChangedSpy, + canRedoChangedSpy, + undoTextChangedSpy, + redoAction, + undoAction, + canUndoChangedSpy, + cleanChangedSpy, + indexChangedSpy, + stack, + false, // clean + 3, // count + 1, // index + true, // canUndo + "insert", // undoText + true, // canRedo + "move mouse", // redoText + false, // cleanChanged + false, // indexChanged + false, // undoChanged + false); // redoChanged + + stack.redo(); + checkState(redoTextChangedSpy, + canRedoChangedSpy, + undoTextChangedSpy, + redoAction, + undoAction, + canUndoChangedSpy, + cleanChangedSpy, + indexChangedSpy, + stack, + false, // clean + 2, // count + 1, // index + true, // canUndo + "insert", // undoText + true, // canRedo + "insert", // redoText + false, // cleanChanged + false, // indexChanged + false, // undoChanged + false); // redoChanged + QCOMPARE(stack.cleanIndex(), -1); + + stack.redo(); + checkState(redoTextChangedSpy, + canRedoChangedSpy, + undoTextChangedSpy, + redoAction, + undoAction, + canUndoChangedSpy, + cleanChangedSpy, + indexChangedSpy, + stack, + false, // clean + 2, // count + 2, // index + true, // canUndo + "insert", // undoText + false, // canRedo + "", // redoText + false, // cleanChanged + true, // indexChanged + true, // undoChanged + true); // redoChanged + QCOMPARE(stack.cleanIndex(), -1); + + cmd1 = new MoveMouseCommand(&mouse, mouse, QPoint(13, 2)); + stack.push(cmd1); // #9 should not merge or be deleted (b/c oldPoint != newPoint) + QCOMPARE(mouse, QPoint(13, 2)); + checkState(redoTextChangedSpy, + canRedoChangedSpy, + undoTextChangedSpy, + redoAction, + undoAction, + canUndoChangedSpy, + cleanChangedSpy, + indexChangedSpy, + stack, + false, // clean + 3, // count + 3, // index + true, // canUndo + "move mouse", // undoText + false, // canRedo + "", // redoText + false, // cleanChanged + true, // indexChanged + true, // undoChanged + true); // redoChanged + + stack.push(new InsertCommand(&str, 3, "ma")); // #10 should not merge or be deleted + QCOMPARE(str, QString("enemama")); + checkState(redoTextChangedSpy, + canRedoChangedSpy, + undoTextChangedSpy, + redoAction, + undoAction, + canUndoChangedSpy, + cleanChangedSpy, + indexChangedSpy, + stack, + false, // clean + 4, // count + 4, // index + true, // canUndo + "insert", // undoText + false, // canRedo + "", // redoText + false, // cleanChanged + true, // indexChanged + true, // undoChanged + true); // redoChanged + + cmd2 = new MoveMouseCommand(&mouse, mouse, QPoint(6, 20)); + stack.push(cmd2); // #11 should not merge or be deleted (b/c oldPoint != newPoint) + QCOMPARE(mouse, QPoint(6, 20)); + checkState(redoTextChangedSpy, + canRedoChangedSpy, + undoTextChangedSpy, + redoAction, + undoAction, + canUndoChangedSpy, + cleanChangedSpy, + indexChangedSpy, + stack, + false, // clean + 5, // count + 5, // index + true, // canUndo + "move mouse", // undoText + false, // canRedo + "", // redoText + false, // cleanChanged + true, // indexChanged + true, // undoChanged + true); // redoChanged + + cmd1->setObsolete(true); + checkState(redoTextChangedSpy, + canRedoChangedSpy, + undoTextChangedSpy, + redoAction, + undoAction, + canUndoChangedSpy, + cleanChangedSpy, + indexChangedSpy, + stack, + false, // clean + 5, // count + 5, // index + true, // canUndo + "move mouse", // undoText + false, // canRedo + "", // redoText + false, // cleanChanged + false, // indexChanged + false, // undoChanged + false); // redoChanged + + stack.setClean(); + checkState(redoTextChangedSpy, + canRedoChangedSpy, + undoTextChangedSpy, + redoAction, + undoAction, + canUndoChangedSpy, + cleanChangedSpy, + indexChangedSpy, + stack, + true, // clean + 5, // count + 5, // index + true, // canUndo + "move mouse", // undoText + false, // canRedo + "", // redoText + true, // cleanChanged + false, // indexChanged + false, // undoChanged + false); // redoChanged + QCOMPARE(stack.cleanIndex(), 5); + + stack.setIndex(0); + checkState(redoTextChangedSpy, + canRedoChangedSpy, + undoTextChangedSpy, + redoAction, + undoAction, + canUndoChangedSpy, + cleanChangedSpy, + indexChangedSpy, + stack, + false, // clean + 4, // count + 0, // index + false, // canUndo + "", // undoText + true, // canRedo + "insert", // redoText + true, // cleanChanged + true, // indexChanged + true, // undoChanged + true); // redoChanged + QCOMPARE(stack.cleanIndex(), -1); + + cmd2->setObsolete(true); + checkState(redoTextChangedSpy, + canRedoChangedSpy, + undoTextChangedSpy, + redoAction, + undoAction, + canUndoChangedSpy, + cleanChangedSpy, + indexChangedSpy, + stack, + false, // clean + 4, // count + 0, // index + false, // canUndo + "", // undoText + true, // canRedo + "insert", // redoText + false, // cleanChanged + false, // indexChanged + false, // undoChanged + false); // redoChanged + + stack.setIndex(stack.count()); + checkState(redoTextChangedSpy, + canRedoChangedSpy, + undoTextChangedSpy, + redoAction, + undoAction, + canUndoChangedSpy, + cleanChangedSpy, + indexChangedSpy, + stack, + false, // clean + 3, // count + 3, // index + true, // canUndo + "insert", // undoText + false, // canRedo + "", // redoText + false, // cleanChanged + true, // indexChanged + true, // undoChanged + true); // redoChanged + + mouse = QPoint(0, 0); // Reset mouse position + stack.beginMacro("ding"); + checkState(redoTextChangedSpy, + canRedoChangedSpy, + undoTextChangedSpy, + redoAction, + undoAction, + canUndoChangedSpy, + cleanChangedSpy, + indexChangedSpy, + stack, + false, // clean + 4, // count + 3, // index + false, // canUndo + "", // undoText + false, // canRedo + "", // redoText + false, // cleanChanged + false, // indexChanged + true, // undoChanged + true); // redoChanged + + stack.push(new MoveMouseCommand(&mouse, mouse, QPoint(7, 7))); // #12 should not merge or be deleted (b/c oldPoint != newPoint & in macro) + QCOMPARE(mouse, QPoint(7, 7)); + checkState(redoTextChangedSpy, + canRedoChangedSpy, + undoTextChangedSpy, + redoAction, + undoAction, + canUndoChangedSpy, + cleanChangedSpy, + indexChangedSpy, + stack, + false, // clean + 4, // count + 3, // index + false, // canUndo + "", // undoText + false, // canRedo + "", // redoText + false, // cleanChanged + false, // indexChanged + false, // undoChanged + false); // redoChanged + + stack.push(new MoveMouseCommand(&mouse, mouse, QPoint(0, 0))); // #13 should merge and be deleted (b/c oldPoint = newPoint) + QCOMPARE(mouse, QPoint(0, 0)); + checkState(redoTextChangedSpy, + canRedoChangedSpy, + undoTextChangedSpy, + redoAction, + undoAction, + canUndoChangedSpy, + cleanChangedSpy, + indexChangedSpy, + stack, + false, // clean + 4, // count + 3, // index + false, // canUndo + "", // undoText + false, // canRedo + "", // redoText + false, // cleanChanged + false, // indexChanged + false, // undoChanged + false); // redoChanged + + stack.endMacro(); + checkState(redoTextChangedSpy, + canRedoChangedSpy, + undoTextChangedSpy, + redoAction, + undoAction, + canUndoChangedSpy, + cleanChangedSpy, + indexChangedSpy, + stack, + false, // clean + 4, // count + 4, // index + true, // canUndo + "ding", // undoText + false, // canRedo + "", // redoText + false, // cleanChanged + true, // indexChanged + true, // undoChanged + true); // redoChanged +} + void tst_QUndoStack::undoLimit() { QUndoStack stack; const QScopedPointer<QAction> undoAction(stack.createUndoAction(0, QString("foo"))); const QScopedPointer<QAction> redoAction(stack.createRedoAction(0, QString("bar"))); - QSignalSpy indexChangedSpy(&stack, SIGNAL(indexChanged(int))); - QSignalSpy cleanChangedSpy(&stack, SIGNAL(cleanChanged(bool))); - QSignalSpy canUndoChangedSpy(&stack, SIGNAL(canUndoChanged(bool))); - QSignalSpy undoTextChangedSpy(&stack, SIGNAL(undoTextChanged(QString))); - QSignalSpy canRedoChangedSpy(&stack, SIGNAL(canRedoChanged(bool))); - QSignalSpy redoTextChangedSpy(&stack, SIGNAL(redoTextChanged(QString))); + QSignalSpy indexChangedSpy(&stack, &QUndoStack::indexChanged); + QSignalSpy cleanChangedSpy(&stack, &QUndoStack::cleanChanged); + QSignalSpy canUndoChangedSpy(&stack, &QUndoStack::canUndoChanged); + QSignalSpy undoTextChangedSpy(&stack, &QUndoStack::undoTextChanged); + QSignalSpy canRedoChangedSpy(&stack, &QUndoStack::canRedoChanged); + QSignalSpy redoTextChangedSpy(&stack, &QUndoStack::redoTextChanged); AppendCommand::delete_cnt = 0; QString str; diff --git a/tests/auto/widgets/widgets/qabstractspinbox/qabstractspinbox.pro b/tests/auto/widgets/widgets/qabstractspinbox/qabstractspinbox.pro index f9b601228e..be758a8bdd 100644 --- a/tests/auto/widgets/widgets/qabstractspinbox/qabstractspinbox.pro +++ b/tests/auto/widgets/widgets/qabstractspinbox/qabstractspinbox.pro @@ -4,7 +4,7 @@ CONFIG += testcase TARGET = tst_qabstractspinbox -QT += widgets testlib +QT += widgets gui-private core-private testlib SOURCES += tst_qabstractspinbox.cpp diff --git a/tests/auto/widgets/widgets/qabstractspinbox/tst_qabstractspinbox.cpp b/tests/auto/widgets/widgets/qabstractspinbox/tst_qabstractspinbox.cpp index 36f5df4649..3fb4863b0e 100644 --- a/tests/auto/widgets/widgets/qabstractspinbox/tst_qabstractspinbox.cpp +++ b/tests/auto/widgets/widgets/qabstractspinbox/tst_qabstractspinbox.cpp @@ -35,6 +35,20 @@ #include <qlineedit.h> #include <qspinbox.h> +#include "../../../shared/platforminputcontext.h" +#include <private/qinputmethod_p.h> + +static inline void centerOnScreen(QWidget *w, const QSize &size) +{ + const QPoint offset = QPoint(size.width() / 2, size.height() / 2); + w->move(QGuiApplication::primaryScreen()->availableGeometry().center() - offset); +} + +static inline void centerOnScreen(QWidget *w) +{ + centerOnScreen(w, w->geometry().size()); +} + class tst_QAbstractSpinBox : public QObject { Q_OBJECT @@ -44,11 +58,19 @@ public: virtual ~tst_QAbstractSpinBox(); private slots: + void initTestCase(); + void cleanupTestCase(); + void getSetCheck(); // task-specific tests below me: void task183108_clear(); void task228728_cssselector(); + + void inputMethodUpdate(); + +private: + PlatformInputContext m_platformInputContext; }; tst_QAbstractSpinBox::tst_QAbstractSpinBox() @@ -67,6 +89,18 @@ public: void setLineEdit(QLineEdit *le) { QAbstractSpinBox::setLineEdit(le); } }; +void tst_QAbstractSpinBox::initTestCase() +{ + QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod()); + inputMethodPrivate->testContext = &m_platformInputContext; +} + +void tst_QAbstractSpinBox::cleanupTestCase() +{ + QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod()); + inputMethodPrivate->testContext = 0; +} + // Testing get/set functions void tst_QAbstractSpinBox::getSetCheck() { @@ -141,6 +175,60 @@ void tst_QAbstractSpinBox::task228728_cssselector() QSpinBox box; } +void tst_QAbstractSpinBox::inputMethodUpdate() +{ + QSpinBox box; + + QSpinBox *testWidget = &box; + testWidget->setRange(0, 1); + + centerOnScreen(testWidget); + testWidget->clear(); + testWidget->show(); + QVERIFY(QTest::qWaitForWindowExposed(testWidget)); + + testWidget->activateWindow(); + testWidget->setFocus(); + QTRY_VERIFY(testWidget->hasFocus()); + QTRY_COMPARE(qApp->focusObject(), testWidget); + + m_platformInputContext.m_updateCallCount = 0; + { + QList<QInputMethodEvent::Attribute> attributes; + QInputMethodEvent event("1", attributes); + QApplication::sendEvent(testWidget, &event); + } + QVERIFY(m_platformInputContext.m_updateCallCount >= 1); + + m_platformInputContext.m_updateCallCount = 0; + { + QList<QInputMethodEvent::Attribute> attributes; + attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 1, QVariant()); + QInputMethodEvent event("1", attributes); + QApplication::sendEvent(testWidget, &event); + } + QVERIFY(m_platformInputContext.m_updateCallCount >= 1); + + m_platformInputContext.m_updateCallCount = 0; + { + QList<QInputMethodEvent::Attribute> attributes; + QInputMethodEvent event("", attributes); + event.setCommitString("1"); + QApplication::sendEvent(testWidget, &event); + } + QVERIFY(m_platformInputContext.m_updateCallCount >= 1); + QCOMPARE(testWidget->value(), 1); + + m_platformInputContext.m_updateCallCount = 0; + { + QList<QInputMethodEvent::Attribute> attributes; + attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 0, 0, QVariant()); + QInputMethodEvent event("", attributes); + QApplication::sendEvent(testWidget, &event); + } + QVERIFY(m_platformInputContext.m_updateCallCount >= 1); +} + QTEST_MAIN(tst_QAbstractSpinBox) #include "tst_qabstractspinbox.moc" diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp index 3afdc0a12a..b882055888 100644 --- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp +++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp @@ -64,6 +64,9 @@ #include <qproxystyle.h> #include <qfont.h> +#include "../../../shared/platforminputcontext.h" +#include <private/qinputmethod_p.h> + static inline void setFrameless(QWidget *w) { Qt::WindowFlags flags = w->windowFlags(); @@ -80,6 +83,8 @@ public: tst_QComboBox() {} private slots: + void initTestCase(); + void cleanupTestCase(); void getSetCheck(); void ensureReturnIsIgnored(); void setEditable(); @@ -162,6 +167,10 @@ private slots: void task_QTBUG_39088_inputMethodHints(); void task_QTBUG_49831_scrollerNotActivated(); void task_QTBUG_56693_itemFontFromModel(); + void inputMethodUpdate(); + +private: + PlatformInputContext m_platformInputContext; }; class MyAbstractItemDelegate : public QAbstractItemDelegate @@ -207,6 +216,18 @@ protected: QRegion visualRegionForSelection(const QItemSelection &) const { return QRegion(); } }; +void tst_QComboBox::initTestCase() +{ + QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod()); + inputMethodPrivate->testContext = &m_platformInputContext; +} + +void tst_QComboBox::cleanupTestCase() +{ + QInputMethodPrivate *inputMethodPrivate = QInputMethodPrivate::get(qApp->inputMethod()); + inputMethodPrivate->testContext = 0; +} + // Testing get/set functions void tst_QComboBox::getSetCheck() { @@ -3324,5 +3345,59 @@ void tst_QComboBox::task_QTBUG_56693_itemFontFromModel() box.hidePopup(); } +void tst_QComboBox::inputMethodUpdate() +{ + TestWidget topLevel; + topLevel.show(); + QVERIFY(QTest::qWaitForWindowExposed(&topLevel)); + QComboBox *testWidget = topLevel.comboBox(); + // make sure we have no lineedit + QVERIFY(!testWidget->lineEdit()); + // test setEditable(true) + testWidget->setEditable(true); + QVERIFY(testWidget->lineEdit()); + + testWidget->activateWindow(); + testWidget->setFocus(); + QTRY_VERIFY(testWidget->hasFocus()); + QTRY_COMPARE(qApp->focusObject(), testWidget); + + m_platformInputContext.m_updateCallCount = 0; + { + QList<QInputMethodEvent::Attribute> attributes; + QInputMethodEvent event("preedit text", attributes); + QApplication::sendEvent(testWidget, &event); + } + QVERIFY(m_platformInputContext.m_updateCallCount >= 1); + + m_platformInputContext.m_updateCallCount = 0; + { + QList<QInputMethodEvent::Attribute> attributes; + attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 1, QVariant()); + QInputMethodEvent event("preedit text", attributes); + QApplication::sendEvent(testWidget, &event); + } + QVERIFY(m_platformInputContext.m_updateCallCount >= 1); + + m_platformInputContext.m_updateCallCount = 0; + { + QList<QInputMethodEvent::Attribute> attributes; + QInputMethodEvent event("", attributes); + event.setCommitString("preedit text"); + QApplication::sendEvent(testWidget, &event); + } + QVERIFY(m_platformInputContext.m_updateCallCount >= 1); + QCOMPARE(testWidget->lineEdit()->text(), QString("preedit text")); + + m_platformInputContext.m_updateCallCount = 0; + { + QList<QInputMethodEvent::Attribute> attributes; + attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 0, 0, QVariant()); + QInputMethodEvent event("", attributes); + QApplication::sendEvent(testWidget, &event); + } + QVERIFY(m_platformInputContext.m_updateCallCount >= 1); +} + QTEST_MAIN(tst_QComboBox) #include "tst_qcombobox.moc" diff --git a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp index a4614d0a9d..330ce3a836 100644 --- a/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp +++ b/tests/auto/widgets/widgets/qlineedit/tst_qlineedit.cpp @@ -294,6 +294,8 @@ private slots: void inputMethodQueryImHints_data(); void inputMethodQueryImHints(); + void inputMethodUpdate(); + void undoRedoAndEchoModes_data(); void undoRedoAndEchoModes(); @@ -711,8 +713,8 @@ void tst_QLineEdit::clearInputMask() { QLineEdit *testWidget = ensureTestWidget(); testWidget->setInputMask("000.000.000.000"); - QVERIFY(testWidget->inputMask() != QString::null); - testWidget->setInputMask(QString::null); + QVERIFY(!testWidget->inputMask().isNull()); + testWidget->setInputMask(QString()); QCOMPARE(testWidget->inputMask(), QString()); } @@ -2275,7 +2277,7 @@ void tst_QLineEdit::textChangedAndTextEdited() changed_count = 0; edited_count = 0; - changed_string = QString::null; + changed_string.clear(); testWidget->setText("foo"); QCOMPARE(changed_count, 1); @@ -2284,7 +2286,7 @@ void tst_QLineEdit::textChangedAndTextEdited() changed_count = 0; edited_count = 0; - changed_string = QString::null; + changed_string.clear(); testWidget->setText(""); QCOMPARE(changed_count, 1); @@ -3106,7 +3108,7 @@ void tst_QLineEdit::maxLengthAndInputMask() QVERIFY(testWidget->inputMask().isNull()); testWidget->setMaxLength(10); QCOMPARE(testWidget->maxLength(), 10); - testWidget->setInputMask(QString::null); + testWidget->setInputMask(QString()); QVERIFY(testWidget->inputMask().isNull()); QCOMPARE(testWidget->maxLength(), 10); } @@ -4184,6 +4186,57 @@ void tst_QLineEdit::inputMethodQueryImHints() QCOMPARE(static_cast<Qt::InputMethodHints>(value.toInt()), hints); } +void tst_QLineEdit::inputMethodUpdate() +{ + QLineEdit *testWidget = ensureTestWidget(); + + centerOnScreen(testWidget); + testWidget->show(); + QVERIFY(QTest::qWaitForWindowExposed(testWidget)); + + testWidget->setText(""); + testWidget->activateWindow(); + testWidget->setFocus(); + QTRY_VERIFY(testWidget->hasFocus()); + QTRY_COMPARE(qApp->focusObject(), testWidget); + + m_platformInputContext.m_updateCallCount = 0; + { + QList<QInputMethodEvent::Attribute> attributes; + QInputMethodEvent event("preedit text", attributes); + QApplication::sendEvent(testWidget, &event); + } + QVERIFY(m_platformInputContext.m_updateCallCount >= 1); + + m_platformInputContext.m_updateCallCount = 0; + { + QList<QInputMethodEvent::Attribute> attributes; + attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Cursor, 0, 1, QVariant()); + QInputMethodEvent event("preedit text", attributes); + QApplication::sendEvent(testWidget, &event); + } + QVERIFY(m_platformInputContext.m_updateCallCount >= 1); + + m_platformInputContext.m_updateCallCount = 0; + { + QList<QInputMethodEvent::Attribute> attributes; + QInputMethodEvent event("", attributes); + event.setCommitString("preedit text"); + QApplication::sendEvent(testWidget, &event); + } + QVERIFY(m_platformInputContext.m_updateCallCount >= 1); + QCOMPARE(testWidget->text(), QString("preedit text")); + + m_platformInputContext.m_updateCallCount = 0; + { + QList<QInputMethodEvent::Attribute> attributes; + attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, 0, 0, QVariant()); + QInputMethodEvent event("", attributes); + QApplication::sendEvent(testWidget, &event); + } + QVERIFY(m_platformInputContext.m_updateCallCount >= 1); +} + void tst_QLineEdit::undoRedoAndEchoModes_data() { QTest::addColumn<int>("echoMode"); diff --git a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp index 52d7a39406..ceef88338a 100644 --- a/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp +++ b/tests/auto/widgets/widgets/qmdiarea/tst_qmdiarea.cpp @@ -106,7 +106,8 @@ static bool tabBetweenSubWindowsIn(QMdiArea *mdiArea, int tabCount = -1, bool re } QMdiSubWindow *subWindow = subWindows.at(reverse ? subWindows.size() -1 - i : i); if (rubberBand->geometry() != subWindow->geometry()) { - qWarning("Rubber band has different geometry"); + qWarning().nospace() << "Rubber band of tab " << i << " has different geometry: " + << rubberBand->geometry() << " (sub window: " << subWindow->geometry() << ")."; return false; } } diff --git a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp index b037cc2141..e5e2e157c5 100644 --- a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp +++ b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp @@ -55,6 +55,20 @@ static inline void centerOnScreen(QWidget *w, const QSize &size) w->move(QGuiApplication::primaryScreen()->availableGeometry().center() - offset); } +struct MenuMetrics { + int fw; + int hmargin; + int vmargin; + int tearOffHeight; + + MenuMetrics(const QMenu *menu) { + fw = menu->style()->pixelMetric(QStyle::PM_MenuPanelWidth, nullptr, menu); + hmargin = menu->style()->pixelMetric(QStyle::PM_MenuHMargin, nullptr, menu); + vmargin = menu->style()->pixelMetric(QStyle::PM_MenuVMargin, nullptr, menu); + tearOffHeight = menu->style()->pixelMetric(QStyle::PM_MenuTearoffHeight, nullptr, menu); + } +}; + static inline void centerOnScreen(QWidget *w) { centerOnScreen(w, w->geometry().size()); @@ -114,6 +128,10 @@ private slots: void QTBUG_56917_wideMenuSize(); void QTBUG_56917_wideMenuScreenNumber(); void QTBUG_56917_wideSubmenuScreenNumber(); + void menuSize_Scrolling_data(); + void menuSize_Scrolling(); + void tearOffMenuNotDisplayed(); + protected slots: void onActivated(QAction*); void onHighlighted(QAction*); @@ -617,7 +635,10 @@ void tst_QMenu::tearOff() QVERIFY(QTest::qWaitForWindowActive(menu.data())); QVERIFY(!menu->isTearOffMenuVisible()); - QTest::mouseClick(menu.data(), Qt::LeftButton, 0, QPoint(3, 3), 10); + MenuMetrics mm(menu.data()); + const int tearOffOffset = mm.fw + mm.vmargin + mm.tearOffHeight / 2; + + QTest::mouseClick(menu.data(), Qt::LeftButton, 0, QPoint(10, tearOffOffset), 10); QTRY_VERIFY(menu->isTearOffMenuVisible()); QPointer<QMenu> torn = getTornOffMenu(); QVERIFY(torn); @@ -1373,5 +1394,204 @@ void tst_QMenu::QTBUG_56917_wideSubmenuScreenNumber() } } +void tst_QMenu::menuSize_Scrolling_data() +{ + QTest::addColumn<int>("numItems"); + QTest::addColumn<int>("topMargin"); + QTest::addColumn<int>("bottomMargin"); + QTest::addColumn<int>("leftMargin"); + QTest::addColumn<int>("rightMargin"); + QTest::addColumn<int>("topPadding"); + QTest::addColumn<int>("bottomPadding"); + QTest::addColumn<int>("leftPadding"); + QTest::addColumn<int>("rightPadding"); + QTest::addColumn<int>("border"); + QTest::addColumn<bool>("scrollable"); + QTest::addColumn<bool>("tearOff"); + + // test data + // a single column and non-scrollable menu with contents margins + border + QTest::newRow("data0") << 5 << 2 << 2 << 2 << 2 << 0 << 0 << 0 << 0 << 2 << false << false; + // a single column and non-scrollable menu with paddings + border + QTest::newRow("data1") << 5 << 0 << 0 << 0 << 0 << 2 << 2 << 2 << 2 << 2 << false << false; + // a single column and non-scrollable menu with contents margins + paddings + border + QTest::newRow("data2") << 5 << 2 << 2 << 2 << 2 << 2 << 2 << 2 << 2 << 2 << false << false; + // a single column and non-scrollable menu with contents margins + paddings + border + tear-off + QTest::newRow("data3") << 5 << 2 << 2 << 2 << 2 << 2 << 2 << 2 << 2 << 2 << false << true; + // a multi-column menu with contents margins + border + QTest::newRow("data4") << 80 << 2 << 2 << 2 << 2 << 0 << 0 << 0 << 0 << 2 << false << false; + // a multi-column menu with paddings + border + QTest::newRow("data5") << 80 << 0 << 0 << 0 << 0 << 2 << 2 << 2 << 2 << 2 << false << false; + // a multi-column menu with contents margins + paddings + border + QTest::newRow("data6") << 80 << 2 << 2 << 2 << 2 << 2 << 2 << 2 << 2 << 2 << false << false; + // a multi-column menu with contents margins + paddings + border + tear-off + QTest::newRow("data7") << 80 << 2 << 2 << 2 << 2 << 2 << 2 << 2 << 2 << 2 << false << true; + // a scrollable menu with contents margins + border + QTest::newRow("data8") << 80 << 2 << 2 << 2 << 2 << 0 << 0 << 0 << 0 << 2 << true << false; + // a scrollable menu with paddings + border + QTest::newRow("data9") << 80 << 0 << 0 << 0 << 0 << 2 << 2 << 2 << 2 << 2 << true << false; + // a scrollable menu with contents margins + paddings + border + QTest::newRow("data10") << 80 << 2 << 2 << 2 << 2 << 2 << 2 << 2 << 2 << 2 << true << false; + // a scrollable menu with contents margins + paddings + border + tear-off + QTest::newRow("data11") << 80 << 2 << 2 << 2 << 2 << 2 << 2 << 2 << 2 << 2 << true << true; +} + +void tst_QMenu::menuSize_Scrolling() +{ + class TestMenu : public QMenu + { + public: + struct ContentsMargins + { + ContentsMargins(int l, int t, int r, int b) + : left(l), top(t), right(r), bottom(b) {} + int left; + int top; + int right; + int bottom; + }; + + struct MenuPaddings + { + MenuPaddings(int l, int t, int r, int b) + : left(l), top(t), right(r), bottom(b) {} + int left; + int top; + int right; + int bottom; + }; + + TestMenu(int numItems, const ContentsMargins &margins, const MenuPaddings &paddings, + int border, bool scrollable, bool tearOff) + : QMenu("Test Menu"), + m_numItems(numItems), + m_scrollable(scrollable), + m_tearOff(tearOff) + { + init(margins, paddings, border); + } + + ~TestMenu() {} + + private: + void showEvent(QShowEvent *e) Q_DECL_OVERRIDE + { + QVERIFY(actions().length() == m_numItems); + + int hmargin = style()->pixelMetric(QStyle::PM_MenuHMargin, nullptr, this); + int fw = style()->pixelMetric(QStyle::PM_MenuPanelWidth, nullptr, this); + int leftMargin, topMargin, rightMargin, bottomMargin; + getContentsMargins(&leftMargin, &topMargin, &rightMargin, &bottomMargin); + QRect lastItem = actionGeometry(actions().at(actions().length() - 1)); + QSize s = size(); + QCOMPARE( s.width(), lastItem.right() + fw + hmargin + rightMargin + 1); + QMenu::showEvent(e); + } + + void init(const ContentsMargins &margins, const MenuPaddings &paddings, int border) + { + setLayoutDirection(Qt::LeftToRight); + + setTearOffEnabled(m_tearOff); + setContentsMargins(margins.left, margins.top, margins.right, margins.bottom); + QString cssStyle("QMenu {menu-scrollable: "); + cssStyle += (m_scrollable ? QString::number(1) : QString::number(0)); + cssStyle += "; border: "; + cssStyle += QString::number(border); + cssStyle += "px solid black; padding: "; + cssStyle += QString::number(paddings.top); + cssStyle += "px "; + cssStyle += QString::number(paddings.right); + cssStyle += "px "; + cssStyle += QString::number(paddings.bottom); + cssStyle += "px "; + cssStyle += QString::number(paddings.left); + cssStyle += "px;}"; + setStyleSheet(cssStyle); + for (int i = 1; i <= m_numItems; i++) + addAction("MenuItem " + QString::number(i)); + } + + private: + int m_numItems; + bool m_scrollable; + bool m_tearOff; + }; + + QFETCH(int, numItems); + QFETCH(int, topMargin); + QFETCH(int, bottomMargin); + QFETCH(int, leftMargin); + QFETCH(int, rightMargin); + QFETCH(int, topPadding); + QFETCH(int, bottomPadding); + QFETCH(int, leftPadding); + QFETCH(int, rightPadding); + QFETCH(int, border); + QFETCH(bool, scrollable); + QFETCH(bool, tearOff); + + qApp->setAttribute(Qt::AA_DontUseNativeMenuBar); + + TestMenu::ContentsMargins margins(leftMargin, topMargin, rightMargin, bottomMargin); + TestMenu::MenuPaddings paddings(leftPadding, topPadding, rightPadding, bottomPadding); + TestMenu menu(numItems, margins, paddings, border, scrollable, tearOff); + menu.popup(QPoint(0,0)); + centerOnScreen(&menu); + QVERIFY(QTest::qWaitForWindowExposed(&menu)); + + QList<QAction *> actions = menu.actions(); + QCOMPARE(actions.length(), numItems); + + MenuMetrics mm(&menu); + QTest::keyClick(&menu, Qt::Key_Home); + QTRY_COMPARE(menu.actionGeometry(actions.first()).y(), mm.fw + mm.vmargin + topMargin + (tearOff ? mm.tearOffHeight : 0)); + QCOMPARE(menu.actionGeometry(actions.first()).x(), mm.fw + mm.hmargin + leftMargin); + + if (!scrollable) + return; + + QTest::keyClick(&menu, Qt::Key_End); + QTRY_COMPARE(menu.actionGeometry(actions.last()).right(), + menu.width() - mm.fw - mm.hmargin - leftMargin - 1); + QCOMPARE(menu.actionGeometry(actions.last()).bottom(), + menu.height() - mm.fw - mm.vmargin - bottomMargin - 1); +} + +void tst_QMenu::tearOffMenuNotDisplayed() +{ + QWidget widget; + QScopedPointer<QMenu> menu(new QMenu(&widget)); + menu->setTearOffEnabled(true); + QVERIFY(menu->isTearOffEnabled()); + + menu->setStyleSheet("QMenu { menu-scrollable: 1 }"); + for (int i = 0; i < 80; i++) + menu->addAction(QString::number(i)); + + widget.resize(300, 200); + centerOnScreen(&widget); + widget.show(); + widget.activateWindow(); + QVERIFY(QTest::qWaitForWindowActive(&widget)); + menu->popup(widget.geometry().topRight() + QPoint(50, 0)); + QVERIFY(QTest::qWaitForWindowActive(menu.data())); + QVERIFY(!menu->isTearOffMenuVisible()); + + MenuMetrics mm(menu.data()); + const int tearOffOffset = mm.fw + mm.vmargin + mm.tearOffHeight / 2; + + QTest::mouseClick(menu.data(), Qt::LeftButton, 0, QPoint(10, tearOffOffset), 10); + QTRY_VERIFY(menu->isTearOffMenuVisible()); + QPointer<QMenu> torn = getTornOffMenu(); + QVERIFY(torn); + QVERIFY(torn->isVisible()); + QVERIFY(torn->minimumWidth() >=0 && torn->minimumWidth() < QWIDGETSIZE_MAX); + + menu->hideTearOffMenu(); + QVERIFY(!menu->isTearOffMenuVisible()); + QVERIFY(!torn->isVisible()); +} + QTEST_MAIN(tst_QMenu) #include "tst_qmenu.moc" diff --git a/tests/auto/widgets/widgets/qmenubar/BLACKLIST b/tests/auto/widgets/widgets/qmenubar/BLACKLIST index 4f9508266c..06776d961d 100644 --- a/tests/auto/widgets/widgets/qmenubar/BLACKLIST +++ b/tests/auto/widgets/widgets/qmenubar/BLACKLIST @@ -1,7 +1,9 @@ [check_menuPosition] ubuntu-14.04 +ubuntu-16.04 [taskQTBUG4965_escapeEaten] ubuntu-14.04 +ubuntu-16.04 redhatenterpriselinuxworkstation-6.6 [task256322_highlight] osx diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp index e3af0135e7..4d57b85f9a 100644 --- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp +++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp @@ -119,6 +119,7 @@ private slots: #if !defined(Q_OS_DARWIN) void check_shortcutPress(); void check_menuPosition(); + void taskQTBUG46812_doNotLeaveMenubarHighlighted(); #endif void task223138_triggered(); void task256322_highlight(); @@ -231,9 +232,14 @@ TestMenu tst_QMenuBar::initSimpleMenuBar(QMenuBar *mb, bool forceNonNative) { menu = mb->addMenu(QStringLiteral("accel1")); action = menu->addAction(QStringLiteral("&Open...") ); action->setShortcut(Qt::Key_O); + result.actions << action; + + action = menu->addAction(QStringLiteral("action")); + action->setShortcut(QKeySequence(Qt::ALT + Qt::Key_Z)); + result.actions << action; + result.menus << menu; connect(menu, SIGNAL(triggered(QAction*)), this, SLOT(onSimpleActivated(QAction*))); - result.actions << action; m_lastSimpleAcceleratorId = 0; m_simpleActivatedCount = 0; @@ -319,7 +325,7 @@ inline TestMenu tst_QMenuBar::initWindowWithComplexMenuBar(QMainWindow &w) return initComplexMenuBar(w.menuBar()); } -// On Mac/WinCE, native key events are needed to test menu action activation +// On Mac native key events are needed to test menu action activation #if !defined(Q_OS_DARWIN) void tst_QMenuBar::accel() { @@ -337,7 +343,7 @@ void tst_QMenuBar::accel() } #endif -// On Mac/WinCE, native key events are needed to test menu action activation +// On Mac native key events are needed to test menu action activation #if !defined(Q_OS_DARWIN) void tst_QMenuBar::activatedCount() { @@ -536,7 +542,7 @@ void tst_QMenuBar::insertItem_QString_QObject() QVERIFY(actions.size() < 4); // there is no menu 4! } -// On Mac/WinCE, native key events are needed to test menu action activation +// On Mac native key events are needed to test menu action activation #if !defined(Q_OS_DARWIN) void tst_QMenuBar::check_accelKeys() { @@ -609,7 +615,7 @@ void tst_QMenuBar::check_accelKeys() } #endif -// On Mac/WinCE, native key events are needed to test menu action activation +// On Mac native key events are needed to test menu action activation #if !defined(Q_OS_DARWIN) void tst_QMenuBar::check_cursorKeys1() { @@ -643,7 +649,7 @@ void tst_QMenuBar::check_cursorKeys1() } #endif -// Qt/Mac,WinCE does not use the native popups/menubar +// Qt/Mac does not use the native popups/menubar #if !defined(Q_OS_DARWIN) void tst_QMenuBar::check_cursorKeys2() { @@ -676,7 +682,7 @@ void tst_QMenuBar::check_cursorKeys2() /*! If a popupmenu is active you can use Left to move to the menu to the left of it. */ -// Qt/Mac,WinCE does not use the native popups/menubar +// Qt/Mac does not use the native popups/menubar #if !defined(Q_OS_DARWIN) void tst_QMenuBar::check_cursorKeys3() { @@ -791,7 +797,7 @@ void tst_QMenuBar::check_endKey() If Down is pressed next the popup is activated again. */ -// Qt/Mac,WinCE does not use the native popups/menubar +// Qt/Mac does not use the native popups/menubar #if !defined(Q_OS_DARWIN) void tst_QMenuBar::check_escKey() { @@ -1025,7 +1031,7 @@ void tst_QMenuBar::check_altClosePress() QTRY_VERIFY(!w.menuBar()->activeAction()); } -// Qt/Mac,WinCE does not use the native popups/menubar +// Qt/Mac does not use the native popups/menubar #if !defined(Q_OS_DARWIN) void tst_QMenuBar::check_shortcutPress() { @@ -1068,7 +1074,7 @@ private: const Qt::LayoutDirection m_oldDirection; }; -// Qt/Mac,WinCE does not use the native popups/menubar +// Qt/Mac does not use the native popups/menubar #if !defined(Q_OS_DARWIN) void tst_QMenuBar::check_menuPosition() { @@ -1530,6 +1536,41 @@ void tst_QMenuBar::slotForTaskQTBUG53205() taskQTBUG53205MenuBar->setParent(parent); } +// Qt/Mac does not use the native popups/menubar +#if !defined(Q_OS_DARWIN) +void tst_QMenuBar::taskQTBUG46812_doNotLeaveMenubarHighlighted() +{ + QMainWindow mainWindow; + QWidget *centralWidget = new QWidget; + centralWidget->setFocusPolicy(Qt::StrongFocus); + mainWindow.setCentralWidget(centralWidget); + initWindowWithSimpleMenuBar(mainWindow); + + mainWindow.show(); + QApplication::setActiveWindow(&mainWindow); + QVERIFY(QTest::qWaitForWindowActive(&mainWindow)); + + QVERIFY(!mainWindow.menuBar()->hasFocus()); + QCOMPARE(m_simpleActivatedCount, 0); + + QTest::keyPress(&mainWindow, Qt::Key_Alt, Qt::AltModifier); + QVERIFY(!mainWindow.menuBar()->hasFocus()); + QCOMPARE(m_simpleActivatedCount, 0); + + QTest::keyPress(&mainWindow, Qt::Key_Z, Qt::AltModifier); + QVERIFY(!mainWindow.menuBar()->hasFocus()); + QCOMPARE(m_simpleActivatedCount, 2); // the action AND the menu will activate + + QTest::keyRelease(&mainWindow, Qt::Key_Alt, Qt::NoModifier); + QVERIFY(!mainWindow.menuBar()->hasFocus()); + QCOMPARE(m_simpleActivatedCount, 2); + + QTest::keyRelease(&mainWindow, Qt::Key_Z, Qt::NoModifier); + QVERIFY(!mainWindow.menuBar()->hasFocus()); + QCOMPARE(m_simpleActivatedCount, 2); +} +#endif + #ifdef Q_OS_MACOS extern bool tst_qmenubar_taskQTBUG56275(QMenuBar *); diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar_mac.mm b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar_mac.mm index 4645de4d7a..823ca7edfa 100644 --- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar_mac.mm +++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar_mac.mm @@ -1,31 +1,26 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** 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$ ** diff --git a/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp b/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp index e3e26d612f..5980cb95d0 100644 --- a/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp +++ b/tests/auto/widgets/widgets/qopenglwidget/tst_qopenglwidget.cpp @@ -39,12 +39,15 @@ #include <QtWidgets/QStackedWidget> #include <QtTest/QtTest> #include <QSignalSpy> +#include <private/qguiapplication_p.h> +#include <qpa/qplatformintegration.h> class tst_QOpenGLWidget : public QObject { Q_OBJECT private slots: + void initTestCase(); void create(); void clearAndGrab(); void clearAndResizeAndGrab(); @@ -60,6 +63,13 @@ private slots: void stackWidgetOpaqueChildIsVisible(); }; +void tst_QOpenGLWidget::initTestCase() +{ + // See QOpenGLWidget constructor + if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::RasterGLSurface)) + QSKIP("QOpenGLWidget is not supported on this platform."); +} + void tst_QOpenGLWidget::create() { QScopedPointer<QOpenGLWidget> w(new QOpenGLWidget); @@ -282,6 +292,13 @@ protected: void CountingGraphicsView::drawForeground(QPainter *, const QRectF &) { ++m_count; + + // QTBUG-59318: verify that the context's internal default fbo redirection + // is active also when using the QOpenGLWidget as a viewport. + GLint currentFbo = -1; + QOpenGLContext::currentContext()->functions()->glGetIntegerv(GL_FRAMEBUFFER_BINDING, ¤tFbo); + GLuint defFbo = QOpenGLContext::currentContext()->defaultFramebufferObject(); + QCOMPARE(GLuint(currentFbo), defFbo); } void tst_QOpenGLWidget::asViewport() diff --git a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp index 31bbcf9c7f..af0ad1a601 100644 --- a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp +++ b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp @@ -362,7 +362,7 @@ void tst_QPlainTextEdit::emptyAppend() { ed->appendPlainText("Blah"); QCOMPARE(blockCount(), 1); - ed->appendPlainText(QString::null); + ed->appendPlainText(QString()); QCOMPARE(blockCount(), 2); ed->appendPlainText(QString(" ")); QCOMPARE(blockCount(), 3); diff --git a/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp b/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp index f490446c8a..72e6ffdeb5 100644 --- a/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp +++ b/tests/auto/widgets/widgets/qsplitter/tst_qsplitter.cpp @@ -77,6 +77,11 @@ private slots: void rubberBandNotInSplitter(); void saveAndRestoreStateOfNotYetShownSplitter(); void saveAndRestoreHandleWidth(); + void replaceWidget_data(); + void replaceWidget(); + void replaceWidgetWithSplitterChild_data(); + void replaceWidgetWithSplitterChild(); + void handleMinimumWidth(); // task-specific tests below me: void task187373_addAbstractScrollAreas(); @@ -645,9 +650,200 @@ public: MyFriendlySplitter(QWidget *parent = 0) : QSplitter(parent) {} void setRubberBand(int pos) { QSplitter::setRubberBand(pos); } + void moveSplitter(int pos, int index) { QSplitter::moveSplitter(pos, index); } + friend class tst_QSplitter; }; +class EventCounterSpy : public QObject +{ +public: + EventCounterSpy(QWidget *parentWidget) : QObject(parentWidget) + { } + + bool eventFilter(QObject *watched, QEvent *event) override + { + // Watch for events in the parent widget and all its children + if (watched == parent() || watched->parent() == parent()) { + if (event->type() == QEvent::Resize) + resizeCount++; + else if (event->type() == QEvent::Paint) + paintCount++; + } + + return QObject::eventFilter(watched, event); + } + + int resizeCount = 0; + int paintCount = 0; +}; + +void tst_QSplitter::replaceWidget_data() +{ + QTest::addColumn<int>("index"); + QTest::addColumn<bool>("visible"); + QTest::addColumn<bool>("collapsed"); + + QTest::newRow("negative index") << -1 << true << false; + QTest::newRow("index too large") << 80 << true << false; + QTest::newRow("visible, not collapsed") << 3 << true << false; + QTest::newRow("visible, collapsed") << 3 << true << true; + QTest::newRow("not visible, not collapsed") << 3 << false << false; + QTest::newRow("not visible, collapsed") << 3 << false << true; +} + +void tst_QSplitter::replaceWidget() +{ + QFETCH(int, index); + QFETCH(bool, visible); + QFETCH(bool, collapsed); + + // Setup + MyFriendlySplitter sp; + const int count = 7; + for (int i = 0; i < count; i++) { + // We use labels instead of plain widgets to + // make it easier to fix eventual regressions. + QLabel *w = new QLabel(QString::asprintf("WIDGET #%d", i)); + sp.addWidget(w); + } + sp.setWindowTitle(QString::asprintf("index %d, visible %d, collapsed %d", index, visible, collapsed)); + sp.show(); + QVERIFY(QTest::qWaitForWindowExposed(&sp)); + + // Configure splitter + QWidget *oldWidget = sp.widget(index); + const QRect oldGeom = oldWidget ? oldWidget->geometry() : QRect(); + if (oldWidget) { + // Collapse first, then hide, if necessary + if (collapsed) { + sp.setCollapsible(index, true); + sp.moveSplitter(oldWidget->x() + 1, index + 1); + } + if (!visible) + oldWidget->hide(); + } + + // Replace widget + QTest::qWait(100); // Flush event queue + const QList<int> sizes = sp.sizes(); + // Shorter label: The important thing is to ensure we can set + // the same size on the new widget. Because of QLabel's sizing + // constraints (they can expand but not shrink) the easiest is + // to set a shorter label. + QLabel *newWidget = new QLabel(QLatin1String("<b>NEW</b>")); + + EventCounterSpy *ef = new EventCounterSpy(&sp); + qApp->installEventFilter(ef); + const QWidget *res = sp.replaceWidget(index, newWidget); + QTest::qWait(100); // Give visibility and resizing some time + qApp->removeEventFilter(ef); + + // Check + if (index < 0 || index >= count) { + QVERIFY(!res); + QVERIFY(!newWidget->parentWidget()); + QCOMPARE(ef->resizeCount, 0); + QCOMPARE(ef->paintCount, 0); + } else { + QCOMPARE(res, oldWidget); + QVERIFY(!res->parentWidget()); + QVERIFY(!res->isVisible()); + QCOMPARE(newWidget->parentWidget(), &sp); + QCOMPARE(newWidget->isVisible(), visible); + if (visible && !collapsed) + QCOMPARE(newWidget->geometry(), oldGeom); + QCOMPARE(newWidget->size().isEmpty(), !visible || collapsed); + const int expectedResizeCount = visible ? 1 : 0; // new widget only + const int expectedPaintCount = visible && !collapsed ? 2 : 0; // splitter and new widget + QCOMPARE(ef->resizeCount, expectedResizeCount); + QCOMPARE(ef->paintCount, expectedPaintCount); + delete res; + } + QCOMPARE(sp.count(), count); + QCOMPARE(sp.sizes(), sizes); +} + +void tst_QSplitter::replaceWidgetWithSplitterChild_data() +{ + QTest::addColumn<int>("srcIndex"); + QTest::addColumn<int>("dstIndex"); + + QTest::newRow("replace with null widget") << -2 << 3; + QTest::newRow("replace with itself") << 3 << 3; + QTest::newRow("replace with sibling, after recalc") << 1 << 4; + QTest::newRow("replace with sibling, before recalc") << -1 << 4; +} + +void tst_QSplitter::replaceWidgetWithSplitterChild() +{ + QFETCH(int, srcIndex); + QFETCH(int, dstIndex); + + // Setup + MyFriendlySplitter sp; + const int count = 7; + for (int i = 0; i < count; i++) { + // We use labels instead of plain widgets to + // make it easier to fix eventual regressions. + QLabel *w = new QLabel(QString::asprintf("WIDGET #%d", i)); + sp.addWidget(w); + } + sp.setWindowTitle(QLatin1String(QTest::currentTestFunction()) + QLatin1Char(' ') + QLatin1String(QTest::currentDataTag())); + sp.show(); + QVERIFY(QTest::qWaitForWindowExposed(&sp)); + + QTest::qWait(100); // Flush event queue before new widget creation + const QList<int> sizes = sp.sizes(); + QWidget *sibling = srcIndex == -1 ? (new QLabel("<b>NEW</b>", &sp)) : sp.widget(srcIndex); + + EventCounterSpy *ef = new EventCounterSpy(&sp); + qApp->installEventFilter(ef); + const QWidget *res = sp.replaceWidget(dstIndex, sibling); + QTest::qWait(100); // Give visibility and resizing some time + qApp->removeEventFilter(ef); + + QVERIFY(!res); + if (srcIndex == -1) { + // Create and replace before recalc. The sibling is scheduled to be + // added after replaceWidget(), when QSplitter receives a child event. + QVERIFY(ef->resizeCount > 0); + QVERIFY(ef->paintCount > 0); + QCOMPARE(sp.count(), count + 1); + QCOMPARE(sp.sizes().mid(0, count), sizes); + QCOMPARE(sp.sizes().last(), sibling->width()); + } else { + // No-op for the rest + QCOMPARE(ef->resizeCount, 0); + QCOMPARE(ef->paintCount, 0); + QCOMPARE(sp.count(), count); + QCOMPARE(sp.sizes(), sizes); + } +} + +void tst_QSplitter::handleMinimumWidth() +{ + MyFriendlySplitter split; + split.addWidget(new QLabel("Number Wan")); + split.addWidget(new QLabel("Number Too")); + + split.show(); + QTest::qWaitForWindowExposed(&split); + for (int i = 0; i < 10; i++) { + split.setHandleWidth(i); + QTest::qWait(100); // resizing + QCOMPARE(split.handle(1)->width(), qMax(4 + (i & 1), i)); + } + + split.setOrientation(Qt::Vertical); + QTest::qWait(100); + for (int i = 0; i < 10; i++) { + split.setHandleWidth(i); + QTest::qWait(100); // resizing + QCOMPARE(split.handle(1)->height(), qMax(4 + (i & 1), i)); + } +} + void tst_QSplitter::rubberBandNotInSplitter() { MyFriendlySplitter split; diff --git a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp index 101f7d2d12..bc94e2a05b 100644 --- a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp +++ b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp @@ -682,7 +682,7 @@ void tst_QTextEdit::emptyAppend() { ed->append("Blah"); QCOMPARE(blockCount(), 1); - ed->append(QString::null); + ed->append(QString()); QCOMPARE(blockCount(), 2); ed->append(QString(" ")); QCOMPARE(blockCount(), 3); diff --git a/tests/auto/widgets/widgets/widgets.pro b/tests/auto/widgets/widgets/widgets.pro index a8e8f6d865..c098108edc 100644 --- a/tests/auto/widgets/widgets/widgets.pro +++ b/tests/auto/widgets/widgets/widgets.pro @@ -49,6 +49,7 @@ SUBDIRS=\ # The following tests depend on private API: !qtConfig(private_tests): SUBDIRS -= \ + qabstractspinbox \ qcombobox \ qmainwindow \ qtextedit \ diff --git a/tests/baselineserver/shared/baselineprotocol.cpp b/tests/baselineserver/shared/baselineprotocol.cpp index 35ef255255..1e4d8846c8 100644 --- a/tests/baselineserver/shared/baselineprotocol.cpp +++ b/tests/baselineserver/shared/baselineprotocol.cpp @@ -92,19 +92,14 @@ PlatformInfo PlatformInfo::localHostInfo() #endif #if defined(Q_OS_LINUX) && QT_CONFIG(process) pi.insert(PI_OSName, QLS("Linux")); - QProcess uname; - uname.start(QLS("uname"), QStringList() << QLS("-r")); - if (uname.waitForFinished(3000)) - pi.insert(PI_OSVersion, QString::fromLocal8Bit(uname.readAllStandardOutput().constData()).simplified()); #elif defined(Q_OS_WIN) pi.insert(PI_OSName, QLS("Windows")); - pi.insert(PI_OSVersion, QString::number(QSysInfo::windowsVersion())); -#elif defined(Q_OS_MAC) - pi.insert(PI_OSName, QLS("MacOS")); - pi.insert(PI_OSVersion, QString::number(QSysInfo::macVersion())); +#elif defined(Q_OS_DARWIN) + pi.insert(PI_OSName, QLS("Darwin")); #else pi.insert(PI_OSName, QLS("Other")); #endif + pi.insert(PI_OSVersion, QSysInfo::kernelVersion()); #if QT_CONFIG(process) QProcess git; diff --git a/tests/benchmarks/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp b/tests/benchmarks/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp index bdec6c3a0a..fcf600a059 100644 --- a/tests/benchmarks/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp +++ b/tests/benchmarks/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2016 Olivier Goffart <ogoffart@woboq.com> -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** diff --git a/tests/benchmarks/gui/painting/qcolor/tst_qcolor.cpp b/tests/benchmarks/gui/painting/qcolor/tst_qcolor.cpp index b67fa450d7..52a7673c0c 100644 --- a/tests/benchmarks/gui/painting/qcolor/tst_qcolor.cpp +++ b/tests/benchmarks/gui/painting/qcolor/tst_qcolor.cpp @@ -5,27 +5,22 @@ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** 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$ ** diff --git a/tests/manual/cocoa/menurama/main.cpp b/tests/manual/cocoa/menurama/main.cpp index 98d96b1491..00594b6d1f 100644 --- a/tests/manual/cocoa/menurama/main.cpp +++ b/tests/manual/cocoa/menurama/main.cpp @@ -1,38 +1,26 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the qtbase module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** diff --git a/tests/manual/cocoa/menurama/mainwindow.cpp b/tests/manual/cocoa/menurama/mainwindow.cpp index f7762f57f5..5cccc16974 100644 --- a/tests/manual/cocoa/menurama/mainwindow.cpp +++ b/tests/manual/cocoa/menurama/mainwindow.cpp @@ -1,38 +1,26 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the qtbase module of the Qt Toolkit. +** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** $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. ** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** 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$ ** diff --git a/tests/manual/cocoa/menurama/mainwindow.h b/tests/manual/cocoa/menurama/mainwindow.h index b9cb52d908..a7afa770be 100644 --- a/tests/manual/cocoa/menurama/mainwindow.h +++ b/tests/manual/cocoa/menurama/mainwindow.h @@ -1,38 +1,26 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the qtbase module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** diff --git a/tests/manual/cocoa/menurama/menuramaapplication.cpp b/tests/manual/cocoa/menurama/menuramaapplication.cpp index 13e457d7dd..acd44565eb 100644 --- a/tests/manual/cocoa/menurama/menuramaapplication.cpp +++ b/tests/manual/cocoa/menurama/menuramaapplication.cpp @@ -1,38 +1,26 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the qtbase module of the Qt Toolkit. +** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** $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. ** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** 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$ ** diff --git a/tests/manual/cocoa/menurama/menuramaapplication.h b/tests/manual/cocoa/menurama/menuramaapplication.h index b0670cc53b..1a5a55e0ff 100644 --- a/tests/manual/cocoa/menurama/menuramaapplication.h +++ b/tests/manual/cocoa/menurama/menuramaapplication.h @@ -1,38 +1,26 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the qtbase module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** diff --git a/tests/manual/diaglib/diaglib.pri b/tests/manual/diaglib/diaglib.pri index e3e7c3757c..9f10167136 100644 --- a/tests/manual/diaglib/diaglib.pri +++ b/tests/manual/diaglib/diaglib.pri @@ -10,7 +10,7 @@ HEADERS += \ $$PWD/qwindowdump.h \ $$PWD/nativewindowdump.h -win32 { +win32:!winrt: { SOURCES += $$PWD/nativewindowdump_win.cpp LIBS *= -luser32 } else { diff --git a/tests/manual/diaglib/logwidget.cpp b/tests/manual/diaglib/logwidget.cpp index 5dbefd8da9..8e4844fab2 100644 --- a/tests/manual/diaglib/logwidget.cpp +++ b/tests/manual/diaglib/logwidget.cpp @@ -1,31 +1,26 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** 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$ ** diff --git a/tests/manual/diaglib/logwidget.h b/tests/manual/diaglib/logwidget.h index 1a85cc143d..55324e3100 100644 --- a/tests/manual/diaglib/logwidget.h +++ b/tests/manual/diaglib/logwidget.h @@ -1,31 +1,26 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** 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$ ** diff --git a/tests/manual/diaglib/qwidgetdump.cpp b/tests/manual/diaglib/qwidgetdump.cpp index 10cfde510d..6c1e7d8f79 100644 --- a/tests/manual/diaglib/qwidgetdump.cpp +++ b/tests/manual/diaglib/qwidgetdump.cpp @@ -96,6 +96,12 @@ static void dumpWidgetRecursion(QTextStream &str, const QWidget *w, str << "windowState=" << hex << showbase << states << dec << noshowbase << ' '; formatRect(str, w->geometry()); if (w->isWindow()) { + str << ' ' << w->logicalDpiX() << "DPI"; +#if QT_VERSION > 0x050600 + const qreal dpr = w->devicePixelRatioF(); + if (!qFuzzyCompare(dpr, qreal(1))) + str << " dpr=" << dpr; +#endif // Qt 5.6 const QRect normalGeometry = w->normalGeometry(); if (normalGeometry.isValid() && !normalGeometry.isEmpty() && normalGeometry != w->geometry()) { str << " normal="; diff --git a/tests/manual/diaglib/qwindowdump.cpp b/tests/manual/diaglib/qwindowdump.cpp index 4adb1da5f1..0e613753ef 100644 --- a/tests/manual/diaglib/qwindowdump.cpp +++ b/tests/manual/diaglib/qwindowdump.cpp @@ -138,7 +138,7 @@ void formatWindow(QTextStream &str, const QWindow *w, FormatWindowOptions option str << " \"" << w->screen()->name() << "\" "; #if QT_VERSION >= 0x050600 if (QHighDpiScaling::isActive()) - str << "factor=" << QHighDpiScaling::factor(w) << ' '; + str << "factor=" << QHighDpiScaling::factor(w) << " dpr=" << w->devicePixelRatio(); #endif } if (!(options & DontPrintWindowFlags)) { @@ -161,7 +161,7 @@ static void dumpWindowRecursion(QTextStream &str, const QWindow *w, FormatWindowOptions options = 0, int depth = 0) { indentStream(str, 2 * depth); - formatWindow(str, w); + formatWindow(str, w, options); foreach (const QObject *co, w->children()) { if (co->isWindowType()) dumpWindowRecursion(str, static_cast<const QWindow *>(co), options, depth + 1); diff --git a/tests/manual/embeddedintoforeignwindow/itemwindow.cpp b/tests/manual/embeddedintoforeignwindow/itemwindow.cpp index 32a2e6557c..15edc88325 100644 --- a/tests/manual/embeddedintoforeignwindow/itemwindow.cpp +++ b/tests/manual/embeddedintoforeignwindow/itemwindow.cpp @@ -1,31 +1,26 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** 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$ ** diff --git a/tests/manual/embeddedintoforeignwindow/itemwindow.h b/tests/manual/embeddedintoforeignwindow/itemwindow.h index 8ea9adaa16..096051061a 100644 --- a/tests/manual/embeddedintoforeignwindow/itemwindow.h +++ b/tests/manual/embeddedintoforeignwindow/itemwindow.h @@ -1,31 +1,26 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** 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$ ** diff --git a/tests/manual/embeddedintoforeignwindow/main.cpp b/tests/manual/embeddedintoforeignwindow/main.cpp index d7b33683a7..8edb3a3e9b 100644 --- a/tests/manual/embeddedintoforeignwindow/main.cpp +++ b/tests/manual/embeddedintoforeignwindow/main.cpp @@ -1,31 +1,26 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** 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$ ** diff --git a/tests/manual/foreignwindows/main.cpp b/tests/manual/foreignwindows/main.cpp index 6c722a3f6f..cda7e7207e 100644 --- a/tests/manual/foreignwindows/main.cpp +++ b/tests/manual/foreignwindows/main.cpp @@ -1,31 +1,26 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** 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$ ** diff --git a/tests/manual/lance/main.cpp b/tests/manual/lance/main.cpp index c1ace138f9..a8fa6bd402 100644 --- a/tests/manual/lance/main.cpp +++ b/tests/manual/lance/main.cpp @@ -91,6 +91,7 @@ static void printHelp() #ifndef QT_NO_OPENGL " -opengl Paints the files to a QGLWidget (Qt4 style) on screen\n" " -glbuffer Paints the files to a QOpenGLFrameBufferObject (Qt5 style) \n" + " -coreglbuffer Paints the files to a Core Profile context QOpenGLFrameBufferObject\n" #endif #ifdef USE_CUSTOM_DEVICE " -customdevice Paints the files to the custom paint device\n" @@ -213,6 +214,7 @@ int main(int argc, char **argv) #endif DeviceType type = WidgetType; + QSurfaceFormat contextFormat; bool checkers_background = true; QImage::Format imageFormat = QImage::Format_ARGB32_Premultiplied; @@ -281,6 +283,11 @@ int main(int argc, char **argv) type = OpenGLType; else if (option == "glbuffer") type = OpenGLBufferType; + else if (option == "coreglbuffer") { + type = OpenGLBufferType; + contextFormat.setVersion(3, 2); + contextFormat.setProfile(QSurfaceFormat::CoreProfile); + } #endif #ifdef USE_CUSTOM_DEVICE else if (option == "customdevice") @@ -423,11 +430,13 @@ int main(int argc, char **argv) { QWindow win; win.setSurfaceType(QSurface::OpenGLSurface); + win.setFormat(contextFormat); win.create(); QOpenGLFramebufferObjectFormat fmt; fmt.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil); fmt.setSamples(4); QOpenGLContext ctx; + ctx.setFormat(contextFormat); ctx.create(); ctx.makeCurrent(&win); QOpenGLFramebufferObject fbo(width, height, fmt); diff --git a/tests/manual/manual.pro b/tests/manual/manual.pro index a93a003dff..a9d27fa488 100644 --- a/tests/manual/manual.pro +++ b/tests/manual/manual.pro @@ -52,7 +52,8 @@ xembed-widgets \ shortcuts \ dialogs \ windowtransparency \ -unc +unc \ +qtabbar !qtConfig(openssl): SUBDIRS -= qssloptions diff --git a/tests/manual/network_remote_stresstest/tst_network_remote_stresstest.cpp b/tests/manual/network_remote_stresstest/tst_network_remote_stresstest.cpp index 05ede9da99..99e3d148df 100644 --- a/tests/manual/network_remote_stresstest/tst_network_remote_stresstest.cpp +++ b/tests/manual/network_remote_stresstest/tst_network_remote_stresstest.cpp @@ -147,7 +147,8 @@ void tst_NetworkRemoteStressTest::init() void tst_NetworkRemoteStressTest::clearManager() { #ifdef QT_BUILD_INTERNAL - QNetworkAccessManagerPrivate::clearCache(&manager); + QNetworkAccessManagerPrivate::clearAuthenticationCache(&manager); + QNetworkAccessManagerPrivate::clearConnectionCache(&manager); manager.setProxy(QNetworkProxy()); manager.setCache(0); #endif diff --git a/tests/manual/network_stresstest/tst_network_stresstest.cpp b/tests/manual/network_stresstest/tst_network_stresstest.cpp index e3c76ea11b..d46703c671 100644 --- a/tests/manual/network_stresstest/tst_network_stresstest.cpp +++ b/tests/manual/network_stresstest/tst_network_stresstest.cpp @@ -138,7 +138,8 @@ void tst_NetworkStressTest::init() void tst_NetworkStressTest::clearManager() { #ifdef QT_BUILD_INTERNAL - QNetworkAccessManagerPrivate::clearCache(&manager); + QNetworkAccessManagerPrivate::clearAuthenticationCache(&manager); + QNetworkAccessManagerPrivate::clearConnectionCache(&manager); manager.setProxy(QNetworkProxy()); manager.setCache(0); #endif diff --git a/tests/manual/qcursor/childwidget/main.cpp b/tests/manual/qcursor/childwidget/main.cpp index 4447c87210..39d52a97e8 100644 --- a/tests/manual/qcursor/childwidget/main.cpp +++ b/tests/manual/qcursor/childwidget/main.cpp @@ -1,35 +1,31 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** 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 <QtWidgets> class CursorWidget : public QWidget diff --git a/tests/manual/qcursor/childwindow/main.cpp b/tests/manual/qcursor/childwindow/main.cpp index 5fc293dfcf..c6b8faca4d 100644 --- a/tests/manual/qcursor/childwindow/main.cpp +++ b/tests/manual/qcursor/childwindow/main.cpp @@ -1,35 +1,31 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** 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 <QtGui> class CursorWindow : public QRasterWindow diff --git a/tests/manual/qcursor/childwindowcontainer/main.cpp b/tests/manual/qcursor/childwindowcontainer/main.cpp index d440133a42..e9bf927929 100644 --- a/tests/manual/qcursor/childwindowcontainer/main.cpp +++ b/tests/manual/qcursor/childwindowcontainer/main.cpp @@ -1,35 +1,31 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** 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 <QtWidgets> class CursorWindow : public QRasterWindow diff --git a/tests/manual/qlocale/calendar.cpp b/tests/manual/qlocale/calendar.cpp index 8405660f84..4295e13342 100644 --- a/tests/manual/qlocale/calendar.cpp +++ b/tests/manual/qlocale/calendar.cpp @@ -1,11 +1,11 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:BSD$ +** $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 @@ -14,35 +14,13 @@ ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** 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$ ** diff --git a/tests/manual/qlocale/calendar.h b/tests/manual/qlocale/calendar.h index 02f9f48886..aee73ef82a 100644 --- a/tests/manual/qlocale/calendar.h +++ b/tests/manual/qlocale/calendar.h @@ -1,11 +1,11 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:BSD$ +** $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 @@ -14,35 +14,13 @@ ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** 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$ ** diff --git a/tests/manual/qlocale/currency.cpp b/tests/manual/qlocale/currency.cpp index 35f6a70d3e..7ea435d9bb 100644 --- a/tests/manual/qlocale/currency.cpp +++ b/tests/manual/qlocale/currency.cpp @@ -1,11 +1,11 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:BSD$ +** $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 @@ -14,35 +14,13 @@ ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** 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$ ** diff --git a/tests/manual/qlocale/currency.h b/tests/manual/qlocale/currency.h index cbb5e7ee44..6a53667cd9 100644 --- a/tests/manual/qlocale/currency.h +++ b/tests/manual/qlocale/currency.h @@ -1,11 +1,11 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:BSD$ +** $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 @@ -14,35 +14,13 @@ ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** 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$ ** diff --git a/tests/manual/qlocale/dateformats.cpp b/tests/manual/qlocale/dateformats.cpp index 9e70fd4e26..3cac1d2479 100644 --- a/tests/manual/qlocale/dateformats.cpp +++ b/tests/manual/qlocale/dateformats.cpp @@ -1,11 +1,11 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:BSD$ +** $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 @@ -14,35 +14,13 @@ ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** 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$ ** diff --git a/tests/manual/qlocale/dateformats.h b/tests/manual/qlocale/dateformats.h index 228e0e4848..f82333b3d5 100644 --- a/tests/manual/qlocale/dateformats.h +++ b/tests/manual/qlocale/dateformats.h @@ -1,11 +1,11 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:BSD$ +** $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 @@ -14,35 +14,13 @@ ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** 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$ ** diff --git a/tests/manual/qlocale/info.cpp b/tests/manual/qlocale/info.cpp index c2a2b12dbe..4d082577d4 100644 --- a/tests/manual/qlocale/info.cpp +++ b/tests/manual/qlocale/info.cpp @@ -1,11 +1,11 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:BSD$ +** $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 @@ -14,35 +14,13 @@ ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** 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$ ** diff --git a/tests/manual/qlocale/info.h b/tests/manual/qlocale/info.h index a6a4a6f34c..1003f84c4f 100644 --- a/tests/manual/qlocale/info.h +++ b/tests/manual/qlocale/info.h @@ -1,11 +1,11 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:BSD$ +** $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 @@ -14,35 +14,13 @@ ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** 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$ ** diff --git a/tests/manual/qlocale/languages.cpp b/tests/manual/qlocale/languages.cpp index 0c4a699b41..6a750b9f7b 100644 --- a/tests/manual/qlocale/languages.cpp +++ b/tests/manual/qlocale/languages.cpp @@ -1,11 +1,11 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:BSD$ +** $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 @@ -14,35 +14,13 @@ ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** 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$ ** diff --git a/tests/manual/qlocale/languages.h b/tests/manual/qlocale/languages.h index ccf6e5face..e0b9420a56 100644 --- a/tests/manual/qlocale/languages.h +++ b/tests/manual/qlocale/languages.h @@ -1,11 +1,11 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:BSD$ +** $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 @@ -14,35 +14,13 @@ ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** 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$ ** diff --git a/tests/manual/qlocale/main.cpp b/tests/manual/qlocale/main.cpp index 36d84d6a48..19fe8604bb 100644 --- a/tests/manual/qlocale/main.cpp +++ b/tests/manual/qlocale/main.cpp @@ -1,11 +1,11 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:BSD$ +** $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 @@ -14,35 +14,13 @@ ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** 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$ ** diff --git a/tests/manual/qlocale/miscellaneous.cpp b/tests/manual/qlocale/miscellaneous.cpp index 1cf33b3a68..636378b70c 100644 --- a/tests/manual/qlocale/miscellaneous.cpp +++ b/tests/manual/qlocale/miscellaneous.cpp @@ -1,11 +1,11 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:BSD$ +** $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 @@ -14,35 +14,13 @@ ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** 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$ ** diff --git a/tests/manual/qlocale/miscellaneous.h b/tests/manual/qlocale/miscellaneous.h index 8b42c3d37d..bffffe8399 100644 --- a/tests/manual/qlocale/miscellaneous.h +++ b/tests/manual/qlocale/miscellaneous.h @@ -1,11 +1,11 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:BSD$ +** $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 @@ -14,35 +14,13 @@ ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** 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$ ** diff --git a/tests/manual/qlocale/numberformats.cpp b/tests/manual/qlocale/numberformats.cpp index 61ff38427d..6f09b3dc7a 100644 --- a/tests/manual/qlocale/numberformats.cpp +++ b/tests/manual/qlocale/numberformats.cpp @@ -1,11 +1,11 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:BSD$ +** $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 @@ -14,35 +14,13 @@ ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** 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$ ** diff --git a/tests/manual/qlocale/numberformats.h b/tests/manual/qlocale/numberformats.h index a28d2f244a..e822ea9240 100644 --- a/tests/manual/qlocale/numberformats.h +++ b/tests/manual/qlocale/numberformats.h @@ -1,11 +1,11 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:BSD$ +** $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 @@ -14,35 +14,13 @@ ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** 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$ ** diff --git a/tests/manual/qlocale/window.cpp b/tests/manual/qlocale/window.cpp index 49919523e8..059192492c 100644 --- a/tests/manual/qlocale/window.cpp +++ b/tests/manual/qlocale/window.cpp @@ -1,11 +1,11 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:BSD$ +** $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 @@ -14,35 +14,13 @@ ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** 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$ ** diff --git a/tests/manual/qlocale/window.h b/tests/manual/qlocale/window.h index ea8e9d94aa..b45545d477 100644 --- a/tests/manual/qlocale/window.h +++ b/tests/manual/qlocale/window.h @@ -1,11 +1,11 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:BSD$ +** $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 @@ -14,35 +14,13 @@ ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** 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$ ** diff --git a/tests/manual/qstorageinfo/main.cpp b/tests/manual/qstorageinfo/main.cpp index 61cdd55922..12e767baf4 100644 --- a/tests/manual/qstorageinfo/main.cpp +++ b/tests/manual/qstorageinfo/main.cpp @@ -1,31 +1,26 @@ /**************************************************************************** ** ** Copyright (C) 2016 Intel Corporation -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** 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$ ** diff --git a/tests/manual/qstorageinfo/printvolumes.cpp b/tests/manual/qstorageinfo/printvolumes.cpp index 6089d5120a..b56e871109 100644 --- a/tests/manual/qstorageinfo/printvolumes.cpp +++ b/tests/manual/qstorageinfo/printvolumes.cpp @@ -1,31 +1,26 @@ /**************************************************************************** ** ** Copyright (C) 2016 Intel Corporation -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** 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$ ** @@ -53,6 +48,10 @@ void printVolumes(const QList<QStorageInfo> &volumes, int (*printer)(const char printer("\n%23s", ""); printer("%10llu %10llu %5u ", info.bytesTotal() / 1024, info.bytesFree() / 1024, info.blockSize()); - printer("%-16s %s\n", qPrintable(info.name()), qPrintable(info.rootPath())); + if (!info.subvolume().isEmpty()) + printer("subvol=%-18s ", qPrintable(info.subvolume())); + else + printer("%-25s ", qPrintable(info.name())); + printer("%s\n", qPrintable(info.rootPath())); } } diff --git a/tests/manual/qsysinfo/main.cpp b/tests/manual/qsysinfo/main.cpp index 5add1e4f74..5b391e5dfd 100644 --- a/tests/manual/qsysinfo/main.cpp +++ b/tests/manual/qsysinfo/main.cpp @@ -27,11 +27,12 @@ ****************************************************************************/ #include <QCoreApplication> +#include <QOperatingSystemVersion> #include <QSysInfo> #include <stdio.h> -// I'm lazy +#if QT_DEPRECATED_SINCE(5, 9) #define CASE_VERSION(v) case QSysInfo::v: return QT_STRINGIFY(v) QByteArray windowsVersionToString(QSysInfo::WinVersion v) @@ -108,6 +109,7 @@ QByteArray macVersionToString(QSysInfo::MacVersion v) } return "MacVersion(Q_MV_OSX(10, " + QByteArray::number(v - 2) + "))"; } +#endif int main(int argc, char *argv[]) { @@ -116,10 +118,12 @@ int main(int argc, char *argv[]) printf("QSysInfo::WordSize = %d\n", QSysInfo::WordSize); printf("QSysInfo::ByteOrder = QSysInfo::%sEndian\n", QSysInfo::ByteOrder == QSysInfo::LittleEndian ? "Little" : "Big"); +#if QT_DEPRECATED_SINCE(5, 9) printf("QSysInfo::WindowsVersion = QSysInfo::%s\n", windowsVersionToString(QSysInfo::WindowsVersion).constData()); printf("QSysInfo::MacintoshVersion = QSysInfo::%s\n", macVersionToString(QSysInfo::MacintoshVersion).constData()); +#endif printf("QSysInfo::buildCpuArchitecture() = %s\n", qPrintable(QSysInfo::buildCpuArchitecture())); printf("QSysInfo::currentCpuArchitecture() = %s\n", qPrintable(QSysInfo::currentCpuArchitecture())); printf("QSysInfo::buildAbi() = %s\n", qPrintable(QSysInfo::buildAbi())); @@ -130,5 +134,12 @@ int main(int argc, char *argv[]) printf("QSysInfo::prettyProductName() = %s\n", qPrintable(QSysInfo::prettyProductName())); printf("QSysInfo::machineHostName() = %s\n", qPrintable(QSysInfo::machineHostName())); + const auto osv = QOperatingSystemVersion::current(); + printf("QOperatingSystemVersion::current() = %s %d.%d.%d\n", + qPrintable(osv.name()), + osv.majorVersion(), + osv.minorVersion(), + osv.microVersion()); + return 0; } diff --git a/tests/manual/qtabbar/main.cpp b/tests/manual/qtabbar/main.cpp new file mode 100644 index 0000000000..b1ef0df100 --- /dev/null +++ b/tests/manual/qtabbar/main.cpp @@ -0,0 +1,153 @@ +/**************************************************************************** +** +** 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:BSD$ +** 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. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QApplication> +#include <QWidget> +#include <QStackedWidget> +#include <QTabBar> +#include <QLabel> +#include <QLayout> +#include <QDesktopWidget> +#include <QTabWidget> + +const int TabCount = 5; + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + QWidget widget; + QStackedWidget stackedWidget; + QTabBar tabBar; + tabBar.setDocumentMode(true); + tabBar.setTabsClosable(true); + tabBar.setMovable(true); + tabBar.setExpanding(true); + + // top + tabBar.setShape(QTabBar::RoundedNorth); + // bottom +// tabBar.setShape(QTabBar::RoundedSouth); + // left +// tabBar.setShape(QTabBar::RoundedWest); + // right +// tabBar.setShape(QTabBar::RoundedEast); + + QMap<int, QWidget*> tabs; + for (int i = 0; i < TabCount; i++) { + QString tabNumberString = QString::number(i); + QLabel *label = new QLabel(QStringLiteral("Tab %1 content").arg(tabNumberString)); + tabs[i] = label; + label->setAlignment(Qt::AlignCenter); + stackedWidget.addWidget(label); + tabBar.addTab(QStringLiteral("Tab %1").arg(tabNumberString)); + } + + QObject::connect(&tabBar, &QTabBar::tabMoved, [&tabs](int from, int to) { + QWidget *thisWidget = tabs[from]; + QWidget *thatWidget = tabs[to]; + tabs[from] = thatWidget; + tabs[to] = thisWidget; + }); + + QObject::connect(&tabBar, &QTabBar::currentChanged, [&stackedWidget, &tabs](int index) { + if (index >= 0) + stackedWidget.setCurrentWidget(tabs[index]); + }); + + QObject::connect(&tabBar, &QTabBar::tabCloseRequested, [&stackedWidget, &tabBar, &tabs](int index) { + QWidget *widget = tabs[index]; + tabBar.removeTab(index); + for (int i = index + 1; i < TabCount; i++) + tabs[i-1] = tabs[i]; + int currentIndex = tabBar.currentIndex(); + if (currentIndex >= 0) + stackedWidget.setCurrentWidget(tabs[currentIndex]); + delete widget; + }); + + QLayout *layout; + switch (tabBar.shape()) { + case QTabBar::RoundedEast: + case QTabBar::TriangularEast: + tabBar.setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding); + layout = new QHBoxLayout(&widget); + layout->addWidget(&stackedWidget); + layout->addWidget(&tabBar); + break; + case QTabBar::RoundedWest: + case QTabBar::TriangularWest: + tabBar.setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding); + layout = new QHBoxLayout(&widget); + layout->addWidget(&tabBar); + layout->addWidget(&stackedWidget); + break; + case QTabBar::RoundedNorth: + case QTabBar::TriangularNorth: + tabBar.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); + layout = new QVBoxLayout(&widget); + layout->addWidget(&tabBar); + layout->addWidget(&stackedWidget); + break; + case QTabBar::RoundedSouth: + case QTabBar::TriangularSouth: + tabBar.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); + layout = new QVBoxLayout(&widget); + layout->addWidget(&stackedWidget); + layout->addWidget(&tabBar); + break; + } + + layout->setMargin(0); + widget.resize(QApplication::desktop()->screenGeometry(&widget).size() * 0.5); + widget.show(); + + return app.exec(); +} diff --git a/tests/manual/qtabbar/qtabbar.pro b/tests/manual/qtabbar/qtabbar.pro new file mode 100644 index 0000000000..a63da72158 --- /dev/null +++ b/tests/manual/qtabbar/qtabbar.pro @@ -0,0 +1,4 @@ +TARGET = qtabbar +TEMPLATE = app +QT = core gui widgets +SOURCES = main.cpp diff --git a/tests/manual/qtabletevent/device_information/tabletwidget.cpp b/tests/manual/qtabletevent/device_information/tabletwidget.cpp index b4273bde8e..14d059abc1 100644 --- a/tests/manual/qtabletevent/device_information/tabletwidget.cpp +++ b/tests/manual/qtabletevent/device_information/tabletwidget.cpp @@ -33,7 +33,7 @@ #include <QMetaObject> #include <QMetaEnum> -TabletWidget::TabletWidget(bool mouseToo) : mMouseToo(mouseToo), mWheelEventCount(0) +TabletWidget::TabletWidget(bool mouseToo) : mMouseToo(mouseToo), mWheelEventCount(0), mQuitShortcut(QKeySequence::Quit, this) { QPalette newPalette = palette(); newPalette.setColor(QPalette::Window, Qt::white); @@ -41,6 +41,7 @@ TabletWidget::TabletWidget(bool mouseToo) : mMouseToo(mouseToo), mWheelEventCoun setPalette(newPalette); qApp->installEventFilter(this); resetAttributes(); + connect(&mQuitShortcut, SIGNAL(activated()), qApp, SLOT(quit())); } bool TabletWidget::eventFilter(QObject *, QEvent *ev) @@ -68,6 +69,7 @@ bool TabletWidget::eventFilter(QObject *, QEvent *ev) mRot = event->rotation(); mButton = event->button(); mButtons = event->buttons(); + mModifiers = event->modifiers(); mTimestamp = event->timestamp(); if (isVisible()) update(); @@ -172,6 +174,7 @@ void TabletWidget::paintEvent(QPaintEvent *) eventInfo << QString("Button: %1 (0x%2)").arg(buttonToString(mButton)).arg(mButton, 0, 16); eventInfo << QString("Buttons currently pressed: %1 (0x%2)").arg(buttonsToString(mButtons)).arg(mButtons, 0, 16); + eventInfo << QString("Keyboard modifiers: %1 (0x%2)").arg(modifiersToString(mModifiers)).arg(mModifiers, 0, 16); eventInfo << QString("Pressure: %1").arg(QString::number(mPress)); eventInfo << QString("Tangential pressure: %1").arg(QString::number(mTangential)); eventInfo << QString("Rotation: %1").arg(QString::number(mRot)); @@ -205,6 +208,24 @@ QString TabletWidget::buttonsToString(Qt::MouseButtons bs) return ret.join(QLatin1Char('|')); } +QString TabletWidget::modifiersToString(Qt::KeyboardModifiers m) +{ + QStringList ret; + if (m & Qt::ShiftModifier) + ret << QLatin1String("Shift"); + if (m & Qt::ControlModifier) + ret << QLatin1String("Control"); + if (m & Qt::AltModifier) + ret << QLatin1String("Alt"); + if (m & Qt::MetaModifier) + ret << QLatin1String("Meta"); + if (m & Qt::KeypadModifier) + ret << QLatin1String("Keypad"); + if (m & Qt::GroupSwitchModifier) + ret << QLatin1String("GroupSwitch"); + return ret.join(QLatin1Char('|')); +} + void TabletWidget::tabletEvent(QTabletEvent *event) { event->accept(); diff --git a/tests/manual/qtabletevent/device_information/tabletwidget.h b/tests/manual/qtabletevent/device_information/tabletwidget.h index 2b014a213a..404be1289f 100644 --- a/tests/manual/qtabletevent/device_information/tabletwidget.h +++ b/tests/manual/qtabletevent/device_information/tabletwidget.h @@ -31,6 +31,7 @@ #include <QWidget> #include <QTabletEvent> +#include <QShortcut> // a widget showing the information of the last tablet event class TabletWidget : public QWidget @@ -43,6 +44,7 @@ protected: void paintEvent(QPaintEvent *event); const char *buttonToString(Qt::MouseButton b); QString buttonsToString(Qt::MouseButtons bs); + QString modifiersToString(Qt::KeyboardModifiers m); private: void resetAttributes() { mType = mDev = mPointerType = mXT = mYT = mZ = 0; @@ -57,11 +59,13 @@ private: int mDev, mPointerType, mXT, mYT, mZ; Qt::MouseButton mButton; Qt::MouseButtons mButtons; + Qt::KeyboardModifiers mModifiers; qreal mPress, mTangential, mRot; qint64 mUnique; bool mMouseToo; ulong mTimestamp; int mWheelEventCount; + QShortcut mQuitShortcut; }; #endif // TABLETWIDGET_H diff --git a/tests/manual/qtbug-52641/main.cpp b/tests/manual/qtbug-52641/main.cpp index 33ebd8584c..513b6d6291 100644 --- a/tests/manual/qtbug-52641/main.cpp +++ b/tests/manual/qtbug-52641/main.cpp @@ -1,38 +1,26 @@ /**************************************************************************** ** ** Copyright (C) 2016 Kai Pastor -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: +** $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. ** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** 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$ ** diff --git a/tests/manual/touch/main.cpp b/tests/manual/touch/main.cpp index 66ad02f78b..1d00ea5db5 100644 --- a/tests/manual/touch/main.cpp +++ b/tests/manual/touch/main.cpp @@ -50,20 +50,20 @@ bool optIgnoreTouch = false; QVector<Qt::GestureType> optGestures; -static inline void drawCircle(const QPointF ¢er, qreal radius, const QColor &color, QPainter &painter) +static inline void drawEllipse(const QPointF ¢er, qreal hDiameter, qreal vDiameter, const QColor &color, QPainter &painter) { const QPen oldPen = painter.pen(); QPen pen = oldPen; pen.setColor(color); painter.setPen(pen); - painter.drawEllipse(center, radius, radius); + painter.drawEllipse(center, hDiameter / 2, vDiameter / 2); painter.setPen(oldPen); } -static inline void fillCircle(const QPointF ¢er, qreal radius, const QColor &color, QPainter &painter) +static inline void fillEllipse(const QPointF ¢er, qreal hDiameter, qreal vDiameter, const QColor &color, QPainter &painter) { QPainterPath painterPath; - painterPath.addEllipse(center, radius, radius); + painterPath.addEllipse(center, hDiameter / 2, vDiameter / 2); painter.fillPath(painterPath, color); } @@ -236,11 +236,15 @@ enum PointType { struct Point { Point(const QPointF &p = QPoint(), PointType t = TouchPoint, - Qt::MouseEventSource s = Qt::MouseEventNotSynthesized) : pos(p), type(t), source(s) {} + Qt::MouseEventSource s = Qt::MouseEventNotSynthesized, QSizeF diameters = QSizeF(4, 4)) : + pos(p), horizontalDiameter(qMax(2., diameters.width())), + verticalDiameter(qMax(2., diameters.height())), type(t), source(s) {} QColor color() const; QPointF pos; + qreal horizontalDiameter; + qreal verticalDiameter; PointType type; Qt::MouseEventSource source; }; @@ -334,7 +338,7 @@ bool TouchTestWidget::event(QEvent *event) case QEvent::TouchUpdate: if (m_drawPoints) { foreach (const QTouchEvent::TouchPoint &p, static_cast<const QTouchEvent *>(event)->touchPoints()) - m_points.append(Point(p.pos(), TouchPoint)); + m_points.append(Point(p.pos(), TouchPoint, Qt::MouseEventNotSynthesized, p.ellipseDiameters())); update(); } case QEvent::TouchEnd: @@ -387,11 +391,10 @@ void TouchTestWidget::paintEvent(QPaintEvent *) painter.drawRect(QRectF(geom.topLeft(), geom.bottomRight() - QPointF(1, 1))); foreach (const Point &point, m_points) { if (geom.contains(point.pos)) { - const qreal radius = point.type == TouchPoint ? 1 : 4; - if (point.type == MouseRelease) { - drawCircle(point.pos, radius, point.color(), painter); - } else - fillCircle(point.pos, radius, point.color(), painter); + if (point.type == MouseRelease) + drawEllipse(point.pos, point.horizontalDiameter, point.verticalDiameter, point.color(), painter); + else + fillEllipse(point.pos, point.horizontalDiameter, point.verticalDiameter, point.color(), painter); } } foreach (const GesturePtr &gp, m_gestures) diff --git a/tests/auto/other/atwrapper/atWrapperAutotest.cpp b/tests/manual/triangulator/main.cpp index ea40cc92b9..066c9f374e 100644 --- a/tests/auto/other/atwrapper/atWrapperAutotest.cpp +++ b/tests/manual/triangulator/main.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. @@ -26,40 +26,18 @@ ** ****************************************************************************/ - -#include <QtTest/QtTest> -#include "atWrapper.h" #include <QApplication> +#include <QMainWindow> +#include "triviswidget.h" -class atWrapperAutotest: public QObject -{ - -Q_OBJECT - -public slots: - void init(); - -private slots: - void runTest(); -}; - -void atWrapperAutotest::init() +int main(int argc, char *argv[]) { -#ifndef Q_OS_IRIX - QDir::setCurrent(SRCDIR); -#endif -} + QApplication app(argc, argv); -void atWrapperAutotest::runTest() -{ + QMainWindow wnd; + wnd.resize(1280, 800); + wnd.setCentralWidget(new TriangulationVisualizer); + wnd.show(); - //QApplication app(argc, argv); - - atWrapper wrapper; - if (!wrapper.runAutoTests()) - QSKIP("Arthur not tested on this machine"); - QVERIFY(true); + return app.exec(); } - -QTEST_MAIN(atWrapperAutotest) -#include "atWrapperAutotest.moc" diff --git a/tests/manual/triangulator/triangulator.pro b/tests/manual/triangulator/triangulator.pro new file mode 100644 index 0000000000..95c0b15ee4 --- /dev/null +++ b/tests/manual/triangulator/triangulator.pro @@ -0,0 +1,9 @@ +TEMPLATE = app +TARGET = triangulator + +QT += gui-private widgets + +SOURCES += main.cpp \ + triviswidget.cpp + +HEADERS += triviswidget.h diff --git a/tests/manual/triangulator/triviswidget.cpp b/tests/manual/triangulator/triviswidget.cpp new file mode 100644 index 0000000000..de1efdb4a0 --- /dev/null +++ b/tests/manual/triangulator/triviswidget.cpp @@ -0,0 +1,418 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "triviswidget.h" +#include <QVBoxLayout> +#include <QHBoxLayout> +#include <QGroupBox> +#include <QWheelEvent> +#include <QScrollBar> +#include <QPainter> +#include <QPainterPath> +#include <QTimer> +#include <QtGui/private/qtriangulator_p.h> +#include <QtGui/private/qtriangulatingstroker_p.h> +#include <QDebug> + +static const int W = 100; +static const int H = 100; +static const int MAX_ZOOM = 512; + +class ScrollArea : public QScrollArea { +protected: + void wheelEvent(QWheelEvent *event) override { + if (!event->modifiers().testFlag(Qt::ControlModifier)) + QScrollArea::wheelEvent(event); + } +}; + +TriangulationVisualizer::TriangulationVisualizer(QWidget *parent) + : QWidget(parent) +{ + QVBoxLayout *mainLayout = new QVBoxLayout; + + QHBoxLayout *headerLayout = new QHBoxLayout; + + QGroupBox *cbBox = new QGroupBox(QLatin1String("Shape")); + m_cbShape = new QComboBox; + QVBoxLayout *cbBoxLayout = new QVBoxLayout; + cbBoxLayout->addWidget(m_cbShape); + cbBox->setLayout(cbBoxLayout); + headerLayout->addWidget(cbBox); + + m_lbPreview = new QLabel; + m_lbPreview->setFixedSize(W, H); + headerLayout->addWidget(m_lbPreview); + + QGroupBox *typeBox = new QGroupBox(QLatin1String("Type")); + m_rdStroke = new QRadioButton(QLatin1String("Stroke")); + m_rdStroke->setChecked(true); + m_rdFill = new QRadioButton(QLatin1String("Fill")); + QVBoxLayout *typeBoxLayout = new QVBoxLayout; + typeBoxLayout->addWidget(m_rdStroke); + typeBoxLayout->addWidget(m_rdFill); + typeBox->setLayout(typeBoxLayout); + headerLayout->addWidget(typeBox); + + QGroupBox *paramBox = new QGroupBox(QLatin1String("Stroke params")); + QVBoxLayout *paramBoxLayout = new QVBoxLayout; + m_spStrokeWidth = new QSpinBox; + m_spStrokeWidth->setPrefix(QLatin1String("Stroke width: ")); + m_spStrokeWidth->setMinimum(1); + m_spStrokeWidth->setMaximum(32); + m_spStrokeWidth->setValue(1); + m_chDash = new QCheckBox(QLatin1String("Dash stroke")); + paramBoxLayout->addWidget(m_spStrokeWidth); + paramBoxLayout->addWidget(m_chDash); + paramBox->setLayout(paramBoxLayout); + headerLayout->addWidget(paramBox); + + m_lbInfo = new QLabel; + headerLayout->addWidget(m_lbInfo); + + QGroupBox *animBox = new QGroupBox(QLatin1String("Step through")); + QVBoxLayout *animBoxLayout = new QVBoxLayout; + m_chStepEnable = new QCheckBox(QLatin1String("Enable")); + m_spStepStroke = new QSpinBox; + m_spStepStroke->setPrefix(QLatin1String("Stroke steps: ")); + m_spStepStroke->setMinimum(3); + m_spStepStroke->setMaximum(INT_MAX); + m_spStepStroke->setEnabled(false); + m_spStepFill = new QSpinBox; + m_spStepFill->setPrefix(QLatin1String("Fill steps: ")); + m_spStepFill->setMinimum(3); + m_spStepFill->setMaximum(INT_MAX); + m_spStepFill->setEnabled(false); + animBoxLayout->addWidget(m_chStepEnable); + animBoxLayout->addWidget(m_spStepStroke); + animBoxLayout->addWidget(m_spStepFill); + animBox->setLayout(animBoxLayout); + headerLayout->addWidget(animBox); + + m_canvas = new TriVisCanvas; + m_scrollArea = new ScrollArea; + m_scrollArea->setWidget(m_canvas); + m_scrollArea->setMinimumSize(W, H); + + mainLayout->addLayout(headerLayout); + mainLayout->addWidget(m_scrollArea); + mainLayout->setStretchFactor(m_scrollArea, 9); + + setLayout(mainLayout); + + for (const QString &shapeName : m_canvas->shapes()) + m_cbShape->addItem(shapeName); + + connect(m_cbShape, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), [this]() { + m_canvas->setIndex(m_cbShape->currentIndex()); + m_canvas->retriangulate(); + }); + connect(m_rdFill, &QRadioButton::toggled, [this]() { + m_canvas->setType(TriVisCanvas::Fill); + m_canvas->retriangulate(); + }); + connect(m_rdStroke, &QRadioButton::toggled, [this]() { + m_canvas->setType(TriVisCanvas::Stroke); + m_canvas->retriangulate(); + }); + + connect(m_spStrokeWidth, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), [this]() { + m_canvas->setStrokeWidth(m_spStrokeWidth->value()); + m_canvas->regeneratePreviews(); + m_canvas->retriangulate(); + }); + + connect(m_chDash, &QCheckBox::toggled, [this]() { + m_canvas->setDashStroke(m_chDash->isChecked()); + m_canvas->regeneratePreviews(); + m_canvas->retriangulate(); + }); + + connect(m_chStepEnable, &QCheckBox::toggled, [this]() { + bool enable = m_chStepEnable->isChecked(); + m_spStepStroke->setEnabled(enable); + m_spStepFill->setEnabled(enable); + if (enable) + m_canvas->setStepLimits(m_spStepStroke->value(), m_spStepFill->value()); + else + m_canvas->setStepLimits(0, 0); + }); + + connect(m_spStepStroke, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), [this]() { + m_canvas->setStepLimits(m_spStepStroke->value(), m_spStepFill->value()); + }); + + connect(m_spStepFill, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), [this]() { + m_canvas->setStepLimits(m_spStepStroke->value(), m_spStepFill->value()); + }); + + connect(m_canvas, &TriVisCanvas::retriangulated, [this]() { + updateInfoLabel(); + updatePreviewLabel(); + }); + + connect(m_canvas, &TriVisCanvas::zoomChanged, [this](float oldZoom, float newZoom) { + QScrollBar *sb = m_scrollArea->horizontalScrollBar(); + float x = sb->value() / oldZoom; + sb->setValue(x * newZoom); + sb = m_scrollArea->verticalScrollBar(); + float y = sb->value() / oldZoom; + sb->setValue(y * newZoom); + updateInfoLabel(); + + }); + + m_canvas->retriangulate(); +} + +void TriangulationVisualizer::updateInfoLabel() +{ + m_lbInfo->setText(QString(QStringLiteral("Type: %1\n%2 vertices (x, y)\n%3 indices\nzoom: %4\nUSE CTRL+WHEEL TO ZOOM")) + .arg(m_canvas->geomType() == TriVisCanvas::Triangles ? QLatin1String("Triangles") : QLatin1String("Triangle strips")) + .arg(m_canvas->vertexCount()) + .arg(m_canvas->indexCount()) + .arg(m_canvas->zoomLevel())); +} + +void TriangulationVisualizer::updatePreviewLabel() +{ + m_lbPreview->setPixmap(QPixmap::fromImage(m_canvas->preview()).scaled(m_lbPreview->size())); +} + +const int TLX = 10; +const int TLY = 10; + +TriVisCanvas::TriVisCanvas(QWidget *parent) + : QWidget(parent) +{ + resize(W * m_zoom, H * m_zoom); + + QPainterPath linePath; + linePath.moveTo(TLX, TLY); + linePath.lineTo(TLX + 30, TLY + 30); + m_paths << linePath; + + QPainterPath rectPath; + rectPath.moveTo(TLX, TLY); + rectPath.lineTo(TLX + 30, TLY); + rectPath.lineTo(TLX + 30, TLY + 30); + rectPath.lineTo(TLX, TLY + 30); + rectPath.lineTo(TLX, TLY); + m_paths << rectPath; + + QPainterPath roundRectPath; + roundRectPath.addRoundedRect(TLX, TLY, TLX + 29, TLY + 29, 5, 5); + m_paths << roundRectPath; + + QPainterPath ellipsePath; + ellipsePath.addEllipse(TLX, TLY, 40, 20); + m_paths << ellipsePath; + + QPainterPath cubicPath; + cubicPath.moveTo(TLX, TLY + 30); + cubicPath.cubicTo(15, 2, 40, 40, 30, 10); + m_paths << cubicPath; + + QPainterPath cubicPath2; + cubicPath2.moveTo(TLX, TLY + 20); + cubicPath2.cubicTo(15, 2, 30, 30, 30, 35); + m_paths << cubicPath2; + + regeneratePreviews(); +} + +QStringList TriVisCanvas::shapes() const +{ + return QStringList() + << "line" + << "rect" + << "roundedrect" + << "ellipse" + << "cubic curve 1" + << "cubic curve 2"; +} + +void TriVisCanvas::regeneratePreviews() +{ + m_strokePreviews.clear(); + m_fillPreviews.clear(); + for (int i = 0; i < m_paths.count(); ++i) + addPreview(i); +} + +void TriVisCanvas::addPreview(int idx) +{ + QPen pen(Qt::black); + pen.setWidthF(m_strokeWidth); + if (m_dashStroke) + pen.setStyle(Qt::DashLine); + + QImage img(W, H, QImage::Format_RGB32); + img.fill(Qt::white); + QPainter p(&img); + p.translate(-TLX, -TLY); + p.scale(2, 2); + p.strokePath(m_paths[idx], pen); + p.end(); + m_strokePreviews.append(img); + + img = QImage(W, H, QImage::Format_RGB32); + img.fill(Qt::white); + p.begin(&img); + p.translate(-TLX, -TLY); + p.scale(2, 2); + p.fillPath(m_paths[idx], QBrush(Qt::gray)); + p.end(); + m_fillPreviews.append(img); +} + +QImage TriVisCanvas::preview() const +{ + if (m_type == Stroke) + return m_strokePreviews[m_idx]; + else + return m_fillPreviews[m_idx]; +} + +static const qreal SCALE = 100; + +void TriVisCanvas::retriangulate() +{ + const QPainterPath &path(m_paths[m_idx]); + + if (m_type == Stroke) { + const QVectorPath &vp = qtVectorPathForPath(path); + const QSize clipSize(W, H); + const QRectF clip(QPointF(0, 0), clipSize); + const qreal inverseScale = 1.0 / SCALE; + + QTriangulatingStroker stroker; + stroker.setInvScale(inverseScale); + + QPen pen; + pen.setWidthF(m_strokeWidth); + if (m_dashStroke) + pen.setStyle(Qt::DashLine); + + if (pen.style() == Qt::SolidLine) { + stroker.process(vp, pen, clip, 0); + } else { + QDashedStrokeProcessor dashStroker; + dashStroker.setInvScale(inverseScale); + dashStroker.process(vp, pen, clip, 0); + QVectorPath dashStroke(dashStroker.points(), dashStroker.elementCount(), + dashStroker.elementTypes(), 0); + stroker.process(dashStroke, pen, clip, 0); + } + + m_strokeVertices.resize(stroker.vertexCount() / 2); + if (!m_strokeVertices.isEmpty()) { + const float *vsrc = stroker.vertices(); + for (int i = 0; i < m_strokeVertices.count(); ++i) + m_strokeVertices[i].set(vsrc[i * 2], vsrc[i * 2 + 1]); + } + } else { + const QVectorPath &vp = qtVectorPathForPath(path); + QTriangleSet ts = qTriangulate(vp, QTransform::fromScale(SCALE, SCALE), 1, true); + const int vertexCount = ts.vertices.count() / 2; + m_fillVertices.resize(vertexCount); + Vertex *vdst = reinterpret_cast<Vertex *>(m_fillVertices.data()); + const qreal *vsrc = ts.vertices.constData(); + for (int i = 0; i < vertexCount; ++i) + vdst[i].set(vsrc[i * 2] / SCALE, vsrc[i * 2 + 1] / SCALE); + + m_fillIndices.resize(ts.indices.size()); + if (ts.indices.type() == QVertexIndexVector::UnsignedShort) { + const quint16 *shortD = static_cast<const quint16 *>(ts.indices.data()); + for (int i = 0; i < m_fillIndices.count(); ++i) + m_fillIndices[i] = shortD[i]; + } else { + memcpy(m_fillIndices.data(), ts.indices.data(), ts.indices.size() * sizeof(quint32)); + } + } + + emit retriangulated(); + update(); +} + +void TriVisCanvas::paintEvent(QPaintEvent *) +{ + QPainter p(this); + p.fillRect(rect(), Qt::white); + + if (m_type == Stroke) { + QPointF prevPt[3]; + int cnt = 0; + for (int i = 0; i < m_strokeVertices.count() && (!m_strokeStepLimit || i < m_strokeStepLimit); ++i) { + auto &v = m_strokeVertices[i]; + QPointF pt(v.x, v.y); + pt *= m_zoom; + if (cnt == 1 || cnt == 2) + p.drawLine(prevPt[cnt - 1], pt); + prevPt[cnt] = pt; + cnt = (cnt + 1) % 3; + if (!cnt) { + p.drawLine(pt, prevPt[cnt]); + i -= 2; + } + } + } else { + QPointF prevPt[3]; + int cnt = 0; + for (int i = 0; i < m_fillIndices.count() && (!m_fillStepLimit || i < m_fillStepLimit); ++i) { + auto &v = m_fillVertices[m_fillIndices[i]]; + QPointF pt(v.x, v.y); + pt *= m_zoom; + if (cnt == 1 || cnt == 2) + p.drawLine(prevPt[cnt - 1], pt); + prevPt[cnt] = pt; + cnt = (cnt + 1) % 3; + if (!cnt) + p.drawLine(pt, prevPt[cnt]); + } + } +} + +void TriVisCanvas::wheelEvent(QWheelEvent *event) +{ + int change = 0; + + if (event->modifiers().testFlag(Qt::ControlModifier)) { + if (event->delta() > 0 && m_zoom < MAX_ZOOM) { + m_zoom += 1; + change = 1; + } else if (event->delta() < 0 && m_zoom > 1) { + m_zoom -= 1; + change = -1; + } + } + + resize(W * m_zoom, H * m_zoom); + emit zoomChanged(m_zoom - change, m_zoom); + update(); +} diff --git a/tests/manual/triangulator/triviswidget.h b/tests/manual/triangulator/triviswidget.h new file mode 100644 index 0000000000..aee80c6cad --- /dev/null +++ b/tests/manual/triangulator/triviswidget.h @@ -0,0 +1,139 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef TRIVISWIDGET_H +#define TRIVISWIDGET_H + +#include <QWidget> +#include <QComboBox> +#include <QRadioButton> +#include <QLabel> +#include <QSpinBox> +#include <QCheckBox> +#include <QScrollArea> + +class TriVisCanvas : public QWidget +{ + Q_OBJECT + +public: + TriVisCanvas(QWidget *parent = nullptr); + + QStringList shapes() const; + + enum Type { + Stroke, + Fill + }; + + void setType(Type t) { m_type = t; } + void setIndex(int idx) { m_idx = idx; } + + void setStrokeWidth(float w) { m_strokeWidth = w; } + void setDashStroke(bool d) { m_dashStroke = d; } + + void setStepLimits(int strokeLimit, int fillLimit) { + m_strokeStepLimit = strokeLimit; + m_fillStepLimit = fillLimit; + update(); + } + + enum GeomType { + Triangles, + TriangleStrips + }; + + QImage preview() const; + GeomType geomType() const { return m_type == Stroke ? TriangleStrips : Triangles; } + int vertexCount() const { return m_type == Stroke ? m_strokeVertices.count() : m_fillVertices.count(); } + int indexCount() const { return m_type == Stroke ? 0 : m_fillIndices.count(); } + float zoomLevel() const { return m_zoom; } + + void retriangulate(); + void regeneratePreviews(); + +protected: + void paintEvent(QPaintEvent *event) override; + void wheelEvent(QWheelEvent *event) override; + +signals: + void retriangulated(); + void zoomChanged(float oldZoom, float newZoom); + +private: + void addPreview(int idx); + + Type m_type = Stroke; + int m_idx = 0; + float m_strokeWidth = 1; + bool m_dashStroke = false; + + QVector<QPainterPath> m_paths; + QVector<QImage> m_strokePreviews; + QVector<QImage> m_fillPreviews; + + struct Vertex { + float x, y; + void set(float vx, float vy) { x = vx; y = vy; } + }; + QVector<Vertex> m_fillVertices; + QVector<quint32> m_fillIndices; + QVector<Vertex> m_strokeVertices; + + float m_zoom = 1; + + int m_fillStepLimit = 0; + int m_strokeStepLimit = 0; +}; + +class TriangulationVisualizer : public QWidget +{ + Q_OBJECT + +public: + TriangulationVisualizer(QWidget *parent = nullptr); + +private: + void updateInfoLabel(); + void updatePreviewLabel(); + + QComboBox *m_cbShape; + QLabel *m_lbPreview; + QRadioButton *m_rdStroke; + QRadioButton *m_rdFill; + QScrollArea *m_scrollArea; + TriVisCanvas *m_canvas; + QLabel *m_lbInfo; + QSpinBox *m_spStrokeWidth; + QCheckBox *m_chDash; + QCheckBox *m_chStepEnable; + QSpinBox *m_spStepStroke; + QSpinBox *m_spStepFill; +}; + +#endif diff --git a/tests/manual/widgets/styles/main.cpp b/tests/manual/widgets/styles/main.cpp index add9afd5b2..7c840dc9ae 100644 --- a/tests/manual/widgets/styles/main.cpp +++ b/tests/manual/widgets/styles/main.cpp @@ -1,31 +1,26 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** -** This file is part of the test suite module of the Qt Toolkit. +** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** 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$ ** diff --git a/tests/manual/windowchildgeometry/controllerwidget.cpp b/tests/manual/windowchildgeometry/controllerwidget.cpp index afea71f171..1d18c5d51b 100644 --- a/tests/manual/windowchildgeometry/controllerwidget.cpp +++ b/tests/manual/windowchildgeometry/controllerwidget.cpp @@ -284,7 +284,7 @@ public: { setObjectName(QStringLiteral("window")); setTitle(tr("TestWindow")); - setFlags(flags() | Qt::MacUseNSWindow); + setProperty("_q_platform_MacUseNSWindow", QVariant(true)); } protected: @@ -317,7 +317,7 @@ void Window::mousePressEvent(QMouseEvent * ev) m_mouseDownPosition = ev->pos(); } -void Window::mouseReleaseEvent(QMouseEvent * e) +void Window::mouseReleaseEvent(QMouseEvent *) { m_mouseDownPosition = QPoint(); } @@ -408,7 +408,6 @@ WindowControl::WindowControl(QWindow *w ) void WindowControl::refresh() { - const QWindow *w = static_cast<const QWindow *>(m_object); BaseWindowControl::refresh(); } diff --git a/tests/manual/windowflags/controllerwindow.cpp b/tests/manual/windowflags/controllerwindow.cpp index d02f64c27b..9a12c8b2c9 100644 --- a/tests/manual/windowflags/controllerwindow.cpp +++ b/tests/manual/windowflags/controllerwindow.cpp @@ -70,7 +70,7 @@ ControllerWidget::ControllerWidget(QWidget *parent) hintsControl->setHints(previewWindow->windowFlags()); connect(hintsControl, SIGNAL(changed(Qt::WindowFlags)), this, SLOT(updatePreview())); - statesControl = new WindowStatesControl(WindowStatesControl::WantVisibleCheckBox|WindowStatesControl::WantActiveCheckBox); + statesControl = new WindowStatesControl; statesControl->setStates(previewWindow->windowState()); statesControl->setVisibleValue(true); connect(statesControl, SIGNAL(changed()), this, SLOT(updatePreview())); @@ -106,13 +106,13 @@ void ControllerWidget::updatePreview() { const Qt::WindowFlags flags = typeControl->type() | hintsControl->hints(); - previewWindow->hide(); - previewDialog->hide(); - - if (previewWidgetButton->isChecked()) + if (previewWidgetButton->isChecked()) { previewWidget = previewWindow; - else + previewDialog->hide(); + } else { previewWidget = previewDialog; + previewWindow->hide(); + } if (modalWindowCheckBox->isChecked()) { parentWindow->show(); @@ -191,12 +191,12 @@ static bool isTopLevel(const QObject *o) return false; } -static Qt::WindowState windowState(const QObject *o) +static Qt::WindowStates windowState(const QObject *o) { if (o->isWidgetType()) { Qt::WindowStates states = static_cast<const QWidget *>(o)->windowState(); states &= ~Qt::WindowActive; - return static_cast<Qt::WindowState>(int(states)); + return states; } #if QT_VERSION >= 0x050000 if (o->isWindowType()) diff --git a/tests/manual/windowflags/controls.cpp b/tests/manual/windowflags/controls.cpp index 319f6aac8e..c167e5f8bf 100644 --- a/tests/manual/windowflags/controls.cpp +++ b/tests/manual/windowflags/controls.cpp @@ -161,97 +161,71 @@ void HintControl::slotCheckBoxChanged() emit changed(hints()); } -WindowStateControl::WindowStateControl(unsigned flags, QWidget *parent) +WindowStateControl::WindowStateControl(QWidget *parent) : QWidget(parent) , group(new QButtonGroup) - , visibleCheckBox(0) - , restoreButton(new QRadioButton(tr("Normal"))) - , minimizeButton(0) - , maximizeButton(new QRadioButton(tr("Maximized"))) - , fullscreenButton(new QRadioButton(tr("Fullscreen"))) + , restoreButton(new QCheckBox(tr("Normal"))) + , minimizeButton(new QCheckBox(tr("Minimized"))) + , maximizeButton(new QCheckBox(tr("Maximized"))) + , fullscreenButton(new QCheckBox(tr("Fullscreen"))) { QHBoxLayout *layout = new QHBoxLayout(this); - layout->setSpacing(0); + group->setExclusive(false); layout->setMargin(ControlLayoutMargin); - if (flags & WantVisibleCheckBox) { - visibleCheckBox = new QCheckBox(tr("Visible")); - connect(visibleCheckBox, SIGNAL(toggled(bool)), this, SIGNAL(changed())); - layout->addWidget(visibleCheckBox); - } - - group->setExclusive(true); - if (flags & WantMinimizeRadioButton) { - minimizeButton = new QRadioButton(tr("Minimized")); - group->addButton(minimizeButton, Qt::WindowMinimized); - layout->addWidget(minimizeButton); - } group->addButton(restoreButton, Qt::WindowNoState); + restoreButton->setEnabled(false); layout->addWidget(restoreButton); + group->addButton(minimizeButton, Qt::WindowMinimized); + layout->addWidget(minimizeButton); group->addButton(maximizeButton, Qt::WindowMaximized); layout->addWidget(maximizeButton); group->addButton(fullscreenButton, Qt::WindowFullScreen); layout->addWidget(fullscreenButton); - connect(group, SIGNAL(buttonReleased(int)), this, SIGNAL(changed())); + connect(group, SIGNAL(buttonReleased(int)), this, SIGNAL(stateChanged(int))); } -Qt::WindowState WindowStateControl::state() const +Qt::WindowStates WindowStateControl::state() const { - return Qt::WindowState(group->checkedId()); + Qt::WindowStates states; + foreach (QAbstractButton *button, group->buttons()) { + if (button->isChecked()) + states |= Qt::WindowState(group->id(button)); + } + return states; } -void WindowStateControl::setState(Qt::WindowState s) +void WindowStateControl::setState(Qt::WindowStates s) { group->blockSignals(true); - if (QAbstractButton *b = group->button(s)) - b->setChecked(true); - group->blockSignals(false); -} + foreach (QAbstractButton *button, group->buttons()) + button->setChecked(s & Qt::WindowState(group->id(button))); -bool WindowStateControl::visibleValue() const -{ - return visibleCheckBox && visibleCheckBox->isChecked(); -} + if (!(s & (Qt::WindowMaximized | Qt::WindowFullScreen))) + restoreButton->setChecked(true); -void WindowStateControl::setVisibleValue(bool v) -{ - if (visibleCheckBox) { - visibleCheckBox->blockSignals(true); - visibleCheckBox->setChecked(v); - visibleCheckBox->blockSignals(false); - } + group->blockSignals(false); } -WindowStatesControl::WindowStatesControl(unsigned flags, QWidget *parent) +WindowStatesControl::WindowStatesControl(QWidget *parent) : QGroupBox(tr("States"), parent) - , visibleCheckBox(0) - , activeCheckBox(0) - , minimizeCheckBox(new QCheckBox(tr("Minimized"))) - , stateControl(new WindowStateControl(0)) + , visibleCheckBox(new QCheckBox(tr("Visible"))) + , activeCheckBox(new QCheckBox(tr("Active"))) + , stateControl(new WindowStateControl) { QHBoxLayout *layout = new QHBoxLayout(this); layout->setSpacing(0); layout->setMargin(ControlLayoutMargin); - if (flags & WantVisibleCheckBox) { - visibleCheckBox = new QCheckBox(tr("Visible")); - connect(visibleCheckBox, SIGNAL(toggled(bool)), this, SIGNAL(changed())); - layout->addWidget(visibleCheckBox); - } - if (flags & WantActiveCheckBox) { - activeCheckBox = new QCheckBox(tr("Active")); - connect(activeCheckBox, SIGNAL(toggled(bool)), this, SIGNAL(changed())); - layout->addWidget(activeCheckBox); - } - layout->addWidget(minimizeCheckBox); + connect(visibleCheckBox, SIGNAL(toggled(bool)), this, SIGNAL(changed())); + layout->addWidget(visibleCheckBox); + connect(activeCheckBox, SIGNAL(toggled(bool)), this, SIGNAL(changed())); + layout->addWidget(activeCheckBox); layout->addWidget(stateControl); - connect(stateControl, SIGNAL(changed()), this, SIGNAL(changed())); - connect(minimizeCheckBox, SIGNAL(clicked()), this, SIGNAL(changed())); + connect(stateControl, SIGNAL(stateChanged(int)), this, SIGNAL(changed())); } Qt::WindowStates WindowStatesControl::states() const { Qt::WindowStates s = stateControl->state(); - if (minimizeCheckBox->isChecked()) - s |= Qt::WindowMinimized; if (activeValue()) s |= Qt::WindowActive; return s; @@ -259,11 +233,7 @@ Qt::WindowStates WindowStatesControl::states() const void WindowStatesControl::setStates(Qt::WindowStates s) { - minimizeCheckBox->blockSignals(true); - minimizeCheckBox->setChecked(s & Qt::WindowMinimized); - minimizeCheckBox->blockSignals(false); - s &= ~Qt::WindowMinimized; - stateControl->setState(Qt::WindowState(int(s))); + stateControl->setState(s); setActiveValue(s & Qt::WindowActive); } diff --git a/tests/manual/windowflags/controls.h b/tests/manual/windowflags/controls.h index 79faaaa9c3..e140d813cc 100644 --- a/tests/manual/windowflags/controls.h +++ b/tests/manual/windowflags/controls.h @@ -77,29 +77,20 @@ private: class WindowStateControl : public QWidget { Q_OBJECT public: - enum Flags { - WantVisibleCheckBox = 0x1, - WantMinimizeRadioButton = 0x2 - }; + explicit WindowStateControl(QWidget *parent= 0); - explicit WindowStateControl(unsigned flags, QWidget *parent= 0); - - Qt::WindowState state() const; - void setState(Qt::WindowState s); - - bool visibleValue() const; - void setVisibleValue(bool); + Qt::WindowStates state() const; + void setState(Qt::WindowStates s); signals: - void changed(); + void stateChanged(int); private: QButtonGroup *group; - QCheckBox *visibleCheckBox; - QRadioButton *restoreButton; - QRadioButton *minimizeButton; - QRadioButton *maximizeButton; - QRadioButton *fullscreenButton; + QCheckBox *restoreButton; + QCheckBox *minimizeButton; + QCheckBox *maximizeButton; + QCheckBox *fullscreenButton; }; // Control for the Qt::WindowStates flags (normal, maximized, fullscreen exclusively @@ -108,12 +99,7 @@ class WindowStatesControl : public QGroupBox { Q_OBJECT public: - enum Flags { - WantVisibleCheckBox = 0x1, - WantActiveCheckBox = 0x2 - }; - - explicit WindowStatesControl(unsigned flags, QWidget *parent= 0); + explicit WindowStatesControl(QWidget *parent= 0); Qt::WindowStates states() const; void setStates(Qt::WindowStates s); @@ -129,7 +115,6 @@ signals: private: QCheckBox *visibleCheckBox; QCheckBox *activeCheckBox; - QCheckBox *minimizeCheckBox; WindowStateControl *stateControl; }; diff --git a/tests/manual/windowflags/previewwindow.cpp b/tests/manual/windowflags/previewwindow.cpp index 54084fd1bc..65a287f788 100644 --- a/tests/manual/windowflags/previewwindow.cpp +++ b/tests/manual/windowflags/previewwindow.cpp @@ -202,16 +202,21 @@ PreviewWindow::PreviewWindow(QWidget *parent) setWindowTitle(tr("Preview <QWidget> Qt %1").arg(QLatin1String(QT_VERSION_STR))); } -void PreviewWindow::resizeEvent(QResizeEvent *e) +bool PreviewWindow::event(QEvent *event) { - QWidget::resizeEvent(e); - updateInfo(); -} + const bool ret = QWidget::event(event); -void PreviewWindow::moveEvent(QMoveEvent *e) -{ - QWidget::moveEvent(e); - updateInfo(); + switch (event->type()) { + case QEvent::Move: + case QEvent::Resize: + case QEvent::WindowStateChange: + updateInfo(); + break; + default: + break; + } + + return ret; } void PreviewWindow::setWindowFlags(Qt::WindowFlags flags) @@ -234,16 +239,21 @@ PreviewDialog::PreviewDialog(QWidget *parent) setWindowTitle(tr("Preview <QDialog> Qt %1").arg(QLatin1String(QT_VERSION_STR))); } -void PreviewDialog::resizeEvent(QResizeEvent *e) +bool PreviewDialog::event(QEvent *event) { - QDialog::resizeEvent(e); - updateInfo(); -} + const bool ret = QDialog::event(event); -void PreviewDialog::moveEvent(QMoveEvent *e) -{ - QDialog::moveEvent(e); - updateInfo(); + switch (event->type()) { + case QEvent::Move: + case QEvent::Resize: + case QEvent::WindowStateChange: + updateInfo(); + break; + default: + break; + } + + return ret; } void PreviewDialog::setWindowFlags(Qt::WindowFlags flags) diff --git a/tests/manual/windowflags/previewwindow.h b/tests/manual/windowflags/previewwindow.h index acd79735ad..9730e7a3f9 100644 --- a/tests/manual/windowflags/previewwindow.h +++ b/tests/manual/windowflags/previewwindow.h @@ -48,8 +48,7 @@ public slots: void updateInfo(); protected: - void resizeEvent(QResizeEvent *); - void moveEvent(QMoveEvent *); + bool event(QEvent *) override; private: QPlainTextEdit *textEdit; @@ -68,8 +67,7 @@ public slots: void updateInfo(); protected: - void resizeEvent(QResizeEvent *); - void moveEvent(QMoveEvent *); + bool event(QEvent *) override; private: QPlainTextEdit *textEdit; diff --git a/tests/manual/windowtransparency/windowtransparency.cpp b/tests/manual/windowtransparency/windowtransparency.cpp index 79b855d3e5..8eb44f881c 100644 --- a/tests/manual/windowtransparency/windowtransparency.cpp +++ b/tests/manual/windowtransparency/windowtransparency.cpp @@ -1,11 +1,11 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:BSD$ +** $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 @@ -14,35 +14,13 @@ ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** 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$ ** diff --git a/tests/manual/xembed-raster/main.cpp b/tests/manual/xembed-raster/main.cpp index 995b1f0bdb..9b13b88047 100644 --- a/tests/manual/xembed-raster/main.cpp +++ b/tests/manual/xembed-raster/main.cpp @@ -1,11 +1,11 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:BSD$ +** $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 @@ -14,35 +14,13 @@ ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** 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$ ** diff --git a/tests/manual/xembed-raster/rasterwindow.cpp b/tests/manual/xembed-raster/rasterwindow.cpp index a3a39d5810..0da33add8a 100644 --- a/tests/manual/xembed-raster/rasterwindow.cpp +++ b/tests/manual/xembed-raster/rasterwindow.cpp @@ -1,11 +1,11 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:BSD$ +** $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 @@ -14,35 +14,13 @@ ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** 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$ ** diff --git a/tests/manual/xembed-raster/rasterwindow.h b/tests/manual/xembed-raster/rasterwindow.h index ee5bbfa82c..b1a556023b 100644 --- a/tests/manual/xembed-raster/rasterwindow.h +++ b/tests/manual/xembed-raster/rasterwindow.h @@ -1,11 +1,11 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:BSD$ +** $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 @@ -14,35 +14,13 @@ ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** 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$ ** diff --git a/tests/manual/xembed-widgets/main.cpp b/tests/manual/xembed-widgets/main.cpp index 1813a11b18..01a53b3957 100644 --- a/tests/manual/xembed-widgets/main.cpp +++ b/tests/manual/xembed-widgets/main.cpp @@ -1,11 +1,11 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:BSD$ +** $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 @@ -14,35 +14,13 @@ ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** 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$ ** diff --git a/tests/manual/xembed-widgets/window.cpp b/tests/manual/xembed-widgets/window.cpp index 6bec696d9d..6bfbb0f800 100644 --- a/tests/manual/xembed-widgets/window.cpp +++ b/tests/manual/xembed-widgets/window.cpp @@ -1,11 +1,11 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:BSD$ +** $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 @@ -14,35 +14,13 @@ ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** 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$ ** diff --git a/tests/manual/xembed-widgets/window.h b/tests/manual/xembed-widgets/window.h index ced50666e8..6166f16d80 100644 --- a/tests/manual/xembed-widgets/window.h +++ b/tests/manual/xembed-widgets/window.h @@ -1,11 +1,11 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2017 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:BSD$ +** $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 @@ -14,35 +14,13 @@ ** and conditions see https://www.qt.io/terms-conditions. For further ** information use the contact form at https://www.qt.io/contact-us. ** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** 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$ ** diff --git a/tests/shared/emulationdetector.h b/tests/shared/emulationdetector.h new file mode 100644 index 0000000000..bf1192a0b2 --- /dev/null +++ b/tests/shared/emulationdetector.h @@ -0,0 +1,119 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef EMULATIONDETECTOR_H +#define EMULATIONDETECTOR_H + +#if defined(Q_OS_LINUX) && defined(Q_PROCESSOR_ARM) +#define SHOULD_CHECK_ARM_ON_X86 + +#if QT_CONFIG(process) && !defined(QT_NO_REGULAREXPRESSION) +#include <QProcess> +#include <QRegularExpression> +#endif + +#endif + +QT_BEGIN_NAMESPACE + +// Helper functions for detecting if running emulated +namespace EmulationDetector { + +#ifdef SHOULD_CHECK_ARM_ON_X86 +static bool isX86SpecificFileAvailable(void); +static bool isReportedArchitectureX86(void); +#endif + +/* + * Check if we are running Arm binary on x86 machine. + * + * Currently this is only able to check on Linux. If not able to + * detect, return false. + */ +static bool isRunningArmOnX86() +{ +#ifdef SHOULD_CHECK_ARM_ON_X86 + if (isX86SpecificFileAvailable()) + return true; + + if (isReportedArchitectureX86()) + return true; +#endif + return false; +} + +#ifdef SHOULD_CHECK_ARM_ON_X86 +/* + * Check if we can find a file that's only available on x86 + */ +static bool isX86SpecificFileAvailable() +{ + // MTRR (Memory Type Range Registers) are a feature of the x86 architecture + // and /proc/mtrr is only present (on Linux) for that family. + // However, it's an optional kernel feature, so the absence of the file is + // not sufficient to conclude we're on real hardware. + QFileInfo mtrr("/proc/mtrr"); + if (mtrr.exists()) + return true; + return false; +} + +/* + * Check if architecture reported by the OS is x86 + */ +static bool isReportedArchitectureX86(void) +{ +#if QT_CONFIG(process) && !defined(QT_NO_REGULAREXPRESSION) + QProcess unamer; + QString machineString; + + // Using syscall "uname" is not possible since that would be captured by + // QEMU and result would be the architecture being emulated (e.g. armv7l). + // By using QProcess we get the architecture used by the host. + unamer.start("uname -a"); + if (!unamer.waitForFinished()) { + return false; + } + machineString = unamer.readAll(); + + // Is our current host cpu x86? + if (machineString.contains(QRegularExpression("i386|i686|x86"))) { + return true; + } +#endif + + return false; +} +#endif // SHOULD_CHECK_ARM_ON_X86 + +} // EmulationDetector namespace + +QT_END_NAMESPACE + +#endif + |