summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@qt.io>2017-02-01 21:00:55 +0100
committerOswald Buddenhagen <oswald.buddenhagen@qt.io>2017-02-01 21:00:55 +0100
commitdcd5cb973622d059818dba1a2c7b9a7b7601a14c (patch)
treefbda1c8c6d36cae42b084f7298cf5b1904e21e9f /tests
parentf299b565b5904e39a47b6133643448e46810f0ed (diff)
parentff68e5d667cc62141f177d01f747a62c95f08d3e (diff)
Merge remote-tracking branch 'gerrit/dev' into HEAD
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp3
-rw-r--r--tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.cpp64
-rw-r--r--tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp18
-rw-r--r--tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp2
-rw-r--r--tests/auto/corelib/codecs/utf8/tst_utf8.cpp33
-rw-r--r--tests/auto/corelib/global/global.pro1
-rw-r--r--tests/auto/corelib/global/qfloat16/qfloat16.pro4
-rw-r--r--tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp266
-rw-r--r--tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp76
-rw-r--r--tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp172
-rw-r--r--tests/auto/corelib/kernel/qobject/test/test.pro3
-rw-r--r--tests/auto/corelib/kernel/qobject/tst_qobject.cpp35
-rw-r--r--tests/auto/corelib/kernel/qsharedmemory/qsharedmemory.pro7
-rw-r--r--tests/auto/corelib/kernel/qtimer/qtimer.pro3
-rw-r--r--tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp8
-rw-r--r--tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp18
-rw-r--r--tests/auto/corelib/thread/qfuture/qfuture.pro2
-rw-r--r--tests/auto/corelib/thread/qfuturesynchronizer/qfuturesynchronizer.pro2
-rw-r--r--tests/auto/corelib/thread/qresultstore/qresultstore.pro2
-rw-r--r--tests/auto/corelib/tools/qlocale/tst_qlocale.cpp39
-rw-r--r--tests/auto/corelib/tools/qstring/tst_qstring.cpp11
-rw-r--r--tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp2
-rw-r--r--tests/auto/dbus/qdbusmetaobject/tst_qdbusmetaobject.cpp3
-rw-r--r--tests/auto/gui/image/qpixmap/tst_qpixmap.cpp28
-rw-r--r--tests/auto/gui/text/qfont/tst_qfont.cpp16
-rw-r--r--tests/auto/gui/text/qinputcontrol/tst_qinputcontrol.cpp22
-rw-r--r--tests/auto/network/bearer/qnetworkconfiguration/tst_qnetworkconfiguration.cpp4
-rw-r--r--tests/auto/network/bearer/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp10
-rw-r--r--tests/auto/network/bearer/qnetworksession/test/tst_qnetworksession.cpp6
-rw-r--r--tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp2
-rw-r--r--tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp140
-rw-r--r--tests/auto/network/ssl/qssldiffiehellmanparameters/tst_qssldiffiehellmanparameters.cpp35
-rw-r--r--tests/auto/other/lancelot/lancelot.pro2
-rw-r--r--tests/auto/printsupport/kernel/qprintdevice/qprintdevice.pro2
-rw-r--r--tests/auto/printsupport/kernel/qprinterinfo/qprinterinfo.pro2
-rw-r--r--tests/auto/testlib/selftests/test/test.pro2
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp8
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview_2.cpp210
-rw-r--r--tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp8
-rw-r--r--tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp88
-rw-r--r--tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp2
-rw-r--r--tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp16
-rw-r--r--tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp2
-rw-r--r--tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp9
-rw-r--r--tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp41
-rw-r--r--tests/auto/widgets/kernel/qsizepolicy/qsizepolicy.pro1
-rw-r--r--tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp36
-rw-r--r--tests/auto/widgets/kernel/qstackedlayout/tst_qstackedlayout.cpp2
-rw-r--r--tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp35
-rw-r--r--tests/benchmarks/corelib/tools/qdatetime/main.cpp5
50 files changed, 1146 insertions, 362 deletions
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/qpauseanimation/tst_qpauseanimation.cpp b/tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.cpp
index 25b6216075..290c2abc98 100644
--- a/tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.cpp
+++ b/tests/auto/corelib/animation/qpauseanimation/tst_qpauseanimation.cpp
@@ -40,6 +40,16 @@
#ifdef BAD_TIMER_RESOLUTION
static const char timerError[] = "On this platform, consistent timing is not working properly due to bad timer resolution";
+
+# define WAIT_FOR_STOPPED(animation, duration) \
+ QTest::qWait(duration); \
+ if (animation.state() != QAbstractAnimation::Stopped) \
+ QEXPECT_FAIL("", timerError, Abort); \
+ QCOMPARE(animation.state(), QAbstractAnimation::Stopped)
+#else
+// Use QTRY_COMPARE with one additional timer tick
+# define WAIT_FOR_STOPPED(animation, duration) \
+ QTRY_COMPARE_WITH_TIMEOUT(animation.state(), QAbstractAnimation::Stopped, (duration))
#endif
class TestablePauseAnimation : public QPauseAnimation
@@ -108,11 +118,10 @@ void tst_QPauseAnimation::changeDirectionWhileRunning()
TestablePauseAnimation animation;
animation.setDuration(400);
animation.start();
- QTest::qWait(100);
- QCOMPARE(animation.state(), QAbstractAnimation::Running);
+ QTRY_COMPARE(animation.state(), QAbstractAnimation::Running);
animation.setDirection(QAbstractAnimation::Backward);
- QTest::qWait(animation.totalDuration() + 50);
- QCOMPARE(animation.state(), QAbstractAnimation::Stopped);
+ const int expectedDuration = animation.totalDuration() + 100;
+ WAIT_FOR_STOPPED(animation, expectedDuration);
}
void tst_QPauseAnimation::noTimerUpdates_data()
@@ -137,14 +146,9 @@ void tst_QPauseAnimation::noTimerUpdates()
animation.setDuration(duration);
animation.setLoopCount(loopCount);
animation.start();
- QTest::qWait(animation.totalDuration() + 100);
-
-#ifdef BAD_TIMER_RESOLUTION
- if (animation.state() != QAbstractAnimation::Stopped)
- QEXPECT_FAIL("", timerError, Abort);
-#endif
+ const int expectedDuration = animation.totalDuration() + 150;
+ WAIT_FOR_STOPPED(animation, expectedDuration);
- QCOMPARE(animation.state(), QAbstractAnimation::Stopped);
const int expectedLoopCount = 1 + loopCount;
#ifdef BAD_TIMER_RESOLUTION
@@ -166,13 +170,9 @@ void tst_QPauseAnimation::multiplePauseAnimations()
animation.start();
animation2.start();
- QTest::qWait(animation.totalDuration() + 100);
-#ifdef BAD_TIMER_RESOLUTION
- if (animation.state() != QAbstractAnimation::Stopped)
- QEXPECT_FAIL("", timerError, Abort);
-#endif
- QCOMPARE(animation.state(), QAbstractAnimation::Stopped);
+ const int expectedDuration = animation.totalDuration() + 150;
+ WAIT_FOR_STOPPED(animation, expectedDuration);
#ifdef BAD_TIMER_RESOLUTION
if (animation2.state() != QAbstractAnimation::Running)
@@ -192,13 +192,7 @@ void tst_QPauseAnimation::multiplePauseAnimations()
#endif
QCOMPARE(animation2.m_updateCurrentTimeCount, 2);
- QTest::qWait(550);
-
-#ifdef BAD_TIMER_RESOLUTION
- if (animation2.state() != QAbstractAnimation::Stopped)
- QEXPECT_FAIL("", timerError, Abort);
-#endif
- QCOMPARE(animation2.state(), QAbstractAnimation::Stopped);
+ WAIT_FOR_STOPPED(animation2, 600);
#ifdef BAD_TIMER_RESOLUTION
if (animation2.m_updateCurrentTimeCount != 3)
@@ -229,13 +223,9 @@ void tst_QPauseAnimation::pauseAndPropertyAnimations()
QCOMPARE(pause.state(), QAbstractAnimation::Running);
QCOMPARE(pause.m_updateCurrentTimeCount, 2);
- QTest::qWait(animation.totalDuration() + 100);
+ const int expectedDuration = animation.totalDuration() + 150;
+ WAIT_FOR_STOPPED(animation, expectedDuration);
-#ifdef BAD_TIMER_RESOLUTION
- if (animation.state() != QAbstractAnimation::Stopped)
- QEXPECT_FAIL("", timerError, Abort);
-#endif
- QCOMPARE(animation.state(), QAbstractAnimation::Stopped);
QCOMPARE(pause.state(), QAbstractAnimation::Stopped);
QVERIFY(pause.m_updateCurrentTimeCount > 3);
}
@@ -405,13 +395,8 @@ void tst_QPauseAnimation::multipleSequentialGroups()
// This is a pretty long animation so it tends to get rather out of sync
// when using the consistent timer, so run for an extra half second for good
// measure...
- QTest::qWait(group.totalDuration() + 500);
-
-#ifdef BAD_TIMER_RESOLUTION
- if (group.state() != QAbstractAnimation::Stopped)
- QEXPECT_FAIL("", timerError, Abort);
-#endif
- QCOMPARE(group.state(), QAbstractAnimation::Stopped);
+ const int expectedDuration = group.totalDuration() + 550;
+ WAIT_FOR_STOPPED(group, expectedDuration);
#ifdef BAD_TIMER_RESOLUTION
if (subgroup1.state() != QAbstractAnimation::Stopped)
@@ -449,8 +434,9 @@ void tst_QPauseAnimation::zeroDuration()
TestablePauseAnimation animation;
animation.setDuration(0);
animation.start();
- QTest::qWait(animation.totalDuration() + 100);
- QCOMPARE(animation.state(), QAbstractAnimation::Stopped);
+ const int expectedDuration = animation.totalDuration() + 150;
+ WAIT_FOR_STOPPED(animation, expectedDuration);
+
QCOMPARE(animation.m_updateCurrentTimeCount, 1);
}
diff --git a/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp
index c1a8fde504..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()
@@ -441,10 +441,8 @@ void tst_QPropertyAnimation::noStartValue()
a.setDuration(250);
a.start();
- QTest::qWait(300);
-
- QTRY_COMPARE(o.values.first(), 42);
- QCOMPARE(o.values.last(), 420);
+ QTRY_COMPARE(o.values.value(o.values.size() - 1, -1), 420);
+ QCOMPARE(o.values.first(), 42);
}
void tst_QPropertyAnimation::noStartValueWithLoop()
@@ -674,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/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/codecs/utf8/tst_utf8.cpp b/tests/auto/corelib/codecs/utf8/tst_utf8.cpp
index 5666726a8c..8f78aa937c 100644
--- a/tests/auto/corelib/codecs/utf8/tst_utf8.cpp
+++ b/tests/auto/corelib/codecs/utf8/tst_utf8.cpp
@@ -237,39 +237,6 @@ void tst_Utf8::nonCharacters_data()
QTest::addColumn<QByteArray>("utf8");
QTest::addColumn<QString>("utf16");
- // Unicode has a couple of "non-characters" that one can use internally
- // These characters may be used for interchange;
- // see: http://www.unicode.org/versions/corrigendum9.html
- //
- // Those are the last two entries each Unicode Plane (U+FFFE, U+FFFF,
- // U+1FFFE, U+1FFFF, etc.) as well as the entries between U+FDD0 and
- // U+FDEF (inclusive)
-
- // U+FDD0 through U+FDEF
- for (int i = 0; i < 32; ++i) {
- char utf8[] = { char(0357), char(0267), char(0220 + i), 0 };
- QString utf16 = QChar(0xfdd0 + i);
- QTest::newRow(qPrintable(QString::number(0xfdd0 + i, 16))) << QByteArray(utf8) << utf16;
- }
-
- // the last two in Planes 1 through 16
- for (uint plane = 1; plane <= 16; ++plane) {
- for (uint lower = 0xfffe; lower < 0x10000; ++lower) {
- uint ucs4 = (plane << 16) | lower;
- char utf8[] = { char(0xf0 | uchar(ucs4 >> 18)),
- char(0x80 | (uchar(ucs4 >> 12) & 0x3f)),
- char(0x80 | (uchar(ucs4 >> 6) & 0x3f)),
- char(0x80 | (uchar(ucs4) & 0x3f)),
- 0 };
- ushort utf16[] = { QChar::highSurrogate(ucs4), QChar::lowSurrogate(ucs4), 0 };
-
- QTest::newRow(qPrintable(QString::number(ucs4, 16))) << QByteArray(utf8) << QString::fromUtf16(utf16);
- }
- }
-
- QTest::newRow("fffe") << QByteArray("\xEF\xBF\xBE") << QString(QChar(0xfffe));
- QTest::newRow("ffff") << QByteArray("\xEF\xBF\xBF") << QString(QChar(0xffff));
-
extern void loadNonCharactersRows();
loadNonCharactersRows();
}
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/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..c894a9c897
--- /dev/null
+++ b/tests/auto/corelib/global/qfloat16/tst_qfloat16.cpp
@@ -0,0 +1,266 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 by Southwest Research Institute (R)
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#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/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp b/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp
index e946f3104a..564b8547b1 100644
--- a/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp
+++ b/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp
@@ -68,6 +68,8 @@ private slots:
void itemData();
+ void persistIndexOnLayoutChange();
+
protected:
void verifyIdentity(QAbstractItemModel *model, const QModelIndex &parent = QModelIndex());
@@ -377,5 +379,79 @@ void tst_QIdentityProxyModel::itemData()
QCOMPARE(proxy.itemData(topIndex).value(Qt::DisplayRole).toString(), QStringLiteral("Monday_appended"));
}
+void dump(QAbstractItemModel* model, QString const& indent = " - ", QModelIndex const& parent = {})
+{
+ for (auto row = 0; row < model->rowCount(parent); ++row)
+ {
+ auto idx = model->index(row, 0, parent);
+ qDebug() << (indent + idx.data().toString());
+ dump(model, indent + "- ", idx);
+ }
+}
+
+void tst_QIdentityProxyModel::persistIndexOnLayoutChange()
+{
+ DynamicTreeModel model;
+
+ QList<int> ancestors;
+ for (auto i = 0; i < 3; ++i)
+ {
+ Q_UNUSED(i);
+ ModelInsertCommand insertCommand(&model);
+ insertCommand.setAncestorRowNumbers(ancestors);
+ insertCommand.setStartRow(0);
+ insertCommand.setEndRow(0);
+ insertCommand.doCommand();
+ ancestors.push_back(0);
+ }
+ ModelInsertCommand insertCommand(&model);
+ insertCommand.setAncestorRowNumbers(ancestors);
+ insertCommand.setStartRow(0);
+ insertCommand.setEndRow(1);
+ insertCommand.doCommand();
+
+ // dump(&model);
+ // " - 1"
+ // " - - 2"
+ // " - - - 3"
+ // " - - - - 4"
+ // " - - - - 5"
+
+ QIdentityProxyModel proxy;
+ proxy.setSourceModel(&model);
+
+ QPersistentModelIndex persistentIndex;
+
+ QPersistentModelIndex sourcePersistentIndex = model.match(model.index(0, 0), Qt::DisplayRole, "5", 1, Qt::MatchRecursive).first();
+
+ QCOMPARE(sourcePersistentIndex.data().toString(), QStringLiteral("5"));
+
+ bool gotLayoutAboutToBeChanged = false;
+ bool gotLayoutChanged = false;
+
+ QObject::connect(&proxy, &QAbstractItemModel::layoutAboutToBeChanged, &proxy, [&proxy, &persistentIndex, &gotLayoutAboutToBeChanged]
+ {
+ gotLayoutAboutToBeChanged = true;
+ persistentIndex = proxy.match(proxy.index(0, 0), Qt::DisplayRole, "5", 1, Qt::MatchRecursive).first();
+ });
+
+ QObject::connect(&proxy, &QAbstractItemModel::layoutChanged, &proxy, [&proxy, &persistentIndex, &sourcePersistentIndex, &gotLayoutChanged]
+ {
+ gotLayoutChanged = true;
+ QCOMPARE(QModelIndex(persistentIndex), proxy.mapFromSource(sourcePersistentIndex));
+ });
+
+ ModelChangeChildrenLayoutsCommand layoutChangeCommand(&model, 0);
+
+ layoutChangeCommand.setAncestorRowNumbers(QList<int>{0, 0, 0});
+ layoutChangeCommand.setSecondAncestorRowNumbers(QList<int>{0, 0});
+
+ layoutChangeCommand.doCommand();
+
+ QVERIFY(gotLayoutAboutToBeChanged);
+ QVERIFY(gotLayoutChanged);
+ QVERIFY(persistentIndex.isValid());
+}
+
QTEST_MAIN(tst_QIdentityProxyModel)
#include "tst_qidentityproxymodel.moc"
diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
index 38e3c6890d..7b6c470dc4 100644
--- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
+++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
@@ -145,6 +145,9 @@ private slots:
void canDropMimeData();
void filterHint();
+ void sourceLayoutChangeLeavesValidPersistentIndexes();
+ void rowMoveLeavesValidPersistentIndexes();
+
protected:
void buildHierarchy(const QStringList &data, QAbstractItemModel *model);
void checkHierarchy(const QStringList &data, const QAbstractItemModel *model);
@@ -4181,5 +4184,174 @@ void tst_QSortFilterProxyModel::filterHint()
QAbstractItemModel::NoLayoutChangeHint);
}
+/**
+
+ Creates a model where each item has one child, to a set depth,
+ and the last item has no children. For a model created with
+ setDepth(4):
+
+ - 1
+ - - 2
+ - - - 3
+ - - - - 4
+*/
+class StepTreeModel : public QAbstractItemModel
+{
+ Q_OBJECT
+public:
+ StepTreeModel(QObject * parent = 0)
+ : QAbstractItemModel(parent), m_depth(0) {}
+
+ int columnCount(const QModelIndex& = QModelIndex()) const override { return 1; }
+
+ int rowCount(const QModelIndex& parent = QModelIndex()) const override
+ {
+ quintptr parentId = (parent.isValid()) ? parent.internalId() : 0;
+ return (parentId < m_depth) ? 1 : 0;
+ }
+
+ QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const override
+ {
+ if (role != Qt::DisplayRole)
+ return QVariant();
+
+ return QString::number(index.internalId());
+ }
+
+ QModelIndex index(int, int, const QModelIndex& parent = QModelIndex()) const override
+ {
+ quintptr parentId = (parent.isValid()) ? parent.internalId() : 0;
+ if (parentId >= m_depth)
+ return QModelIndex();
+
+ return createIndex(0, 0, parentId + 1);
+ }
+
+ QModelIndex parent(const QModelIndex& index) const override
+ {
+ if (index.internalId() == 0)
+ return QModelIndex();
+
+ return createIndex(0, 0, index.internalId() - 1);
+ }
+
+ void setDepth(quintptr depth)
+ {
+ int parentIdWithLayoutChange = (m_depth < depth) ? m_depth : depth;
+
+ QList<QPersistentModelIndex> parentsOfLayoutChange;
+ parentsOfLayoutChange.push_back(createIndex(0, 0, parentIdWithLayoutChange));
+
+ layoutAboutToBeChanged(parentsOfLayoutChange);
+
+ auto existing = persistentIndexList();
+
+ QList<QModelIndex> updated;
+
+ for (auto idx : existing) {
+ if (indexDepth(idx) <= depth)
+ updated.push_back(idx);
+ else
+ updated.push_back({});
+ }
+
+ m_depth = depth;
+
+ changePersistentIndexList(existing, updated);
+
+ layoutChanged(parentsOfLayoutChange);
+ }
+
+private:
+ static quintptr indexDepth(QModelIndex const& index)
+ {
+ return (index.isValid()) ? 1 + indexDepth(index.parent()) : 0;
+ }
+
+private:
+ quintptr m_depth;
+};
+
+void tst_QSortFilterProxyModel::sourceLayoutChangeLeavesValidPersistentIndexes()
+{
+ StepTreeModel model;
+ Q_SET_OBJECT_NAME(model);
+ model.setDepth(4);
+
+ QSortFilterProxyModel proxy1;
+ proxy1.setSourceModel(&model);
+ Q_SET_OBJECT_NAME(proxy1);
+
+ proxy1.setFilterRegExp("1|2");
+
+ // The current state of things:
+ // model proxy
+ // - 1 - 1
+ // - - 2 - - 2
+ // - - - 3
+ // - - - - 4
+
+ // The setDepth call below removes '4' with a layoutChanged call.
+ // Because the proxy filters that out anyway, the proxy doesn't need
+ // to emit any signals or update persistent indexes.
+
+ QPersistentModelIndex persistentIndex = proxy1.index(0, 0, proxy1.index(0, 0));
+
+ model.setDepth(3);
+
+ // Calling parent() causes the internalPointer to be used.
+ // Before fixing QTBUG-47711, that could be a dangling pointer.
+ // The use of qDebug here makes sufficient use of the heap to
+ // cause corruption at runtime with normal use on linux (before
+ // the fix). valgrind confirms the fix.
+ qDebug() << persistentIndex.parent();
+ QVERIFY(persistentIndex.parent().isValid());
+}
+
+void tst_QSortFilterProxyModel::rowMoveLeavesValidPersistentIndexes()
+{
+ DynamicTreeModel model;
+ Q_SET_OBJECT_NAME(model);
+
+ QList<int> ancestors;
+ for (auto i = 0; i < 5; ++i)
+ {
+ Q_UNUSED(i);
+ ModelInsertCommand insertCommand(&model);
+ insertCommand.setAncestorRowNumbers(ancestors);
+ insertCommand.setStartRow(0);
+ insertCommand.setEndRow(0);
+ insertCommand.doCommand();
+ ancestors.push_back(0);
+ }
+
+ QSortFilterProxyModel proxy1;
+ proxy1.setSourceModel(&model);
+ Q_SET_OBJECT_NAME(proxy1);
+
+ proxy1.setFilterRegExp("1|2");
+
+ auto item5 = model.match(model.index(0, 0), Qt::DisplayRole, "5", 1, Qt::MatchRecursive).first();
+ auto item3 = model.match(model.index(0, 0), Qt::DisplayRole, "3", 1, Qt::MatchRecursive).first();
+
+ Q_ASSERT(item5.isValid());
+ Q_ASSERT(item3.isValid());
+
+ QPersistentModelIndex persistentIndex = proxy1.match(proxy1.index(0, 0), Qt::DisplayRole, "2", 1, Qt::MatchRecursive).first();
+
+ ModelMoveCommand moveCommand(&model, 0);
+ moveCommand.setAncestorRowNumbers(QList<int>{0, 0, 0, 0});
+ moveCommand.setStartRow(0);
+ moveCommand.setEndRow(0);
+ moveCommand.setDestRow(0);
+ moveCommand.setDestAncestors(QList<int>{0, 0, 0});
+ moveCommand.doCommand();
+
+ // Calling parent() causes the internalPointer to be used.
+ // Before fixing QTBUG-47711 (moveRows case), that could be
+ // a dangling pointer.
+ QVERIFY(persistentIndex.parent().isValid());
+}
+
QTEST_MAIN(tst_QSortFilterProxyModel)
#include "tst_qsortfilterproxymodel.moc"
diff --git a/tests/auto/corelib/kernel/qobject/test/test.pro b/tests/auto/corelib/kernel/qobject/test/test.pro
index f3bc045455..4e77cb48c5 100644
--- a/tests/auto/corelib/kernel/qobject/test/test.pro
+++ b/tests/auto/corelib/kernel/qobject/test/test.pro
@@ -3,5 +3,8 @@ TARGET = ../tst_qobject
QT = core-private network testlib
SOURCES = ../tst_qobject.cpp
+# Force C++17 if available (needed due to P0012R1)
+contains(QT_CONFIG, c++1z): CONFIG += c++1z
+
!winrt: TEST_HELPER_INSTALLS = ../signalbug/signalbug
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
index 5eea858107..f44c40c27f 100644
--- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
@@ -120,6 +120,7 @@ private slots:
void connectCxx0x();
void connectToStaticCxx0x();
void connectCxx0xTypeMatching();
+ void connectCxx17Noexcept();
void connectConvert();
void connectWithReference();
void connectManyArguments();
@@ -4755,10 +4756,13 @@ class LotsOfSignalsAndSlots: public QObject
public slots:
void slot_v() {}
+ void slot_v_noexcept() Q_DECL_NOTHROW {}
void slot_vi(int) {}
+ void slot_vi_noexcept() Q_DECL_NOTHROW {}
void slot_vii(int, int) {}
void slot_viii(int, int, int) {}
int slot_i() { return 0; }
+ int slot_i_noexcept() Q_DECL_NOTHROW { return 0; }
int slot_ii(int) { return 0; }
int slot_iii(int, int) { return 0; }
int slot_iiii(int, int, int) { return 0; }
@@ -4772,13 +4776,18 @@ class LotsOfSignalsAndSlots: public QObject
void slot_vPFvvE(fptr) {}
void const_slot_v() const {};
+ void const_slot_v_noexcept() const Q_DECL_NOTHROW {}
void const_slot_vi(int) const {};
+ void const_slot_vi_noexcept(int) const Q_DECL_NOTHROW {}
static void static_slot_v() {}
+ static void static_slot_v_noexcept() Q_DECL_NOTHROW {}
static void static_slot_vi(int) {}
+ static void static_slot_vi_noexcept(int) Q_DECL_NOTHROW {}
static void static_slot_vii(int, int) {}
static void static_slot_viii(int, int, int) {}
static int static_slot_i() { return 0; }
+ static int static_slot_i_noexcept() Q_DECL_NOTHROW { return 0; }
static int static_slot_ii(int) { return 0; }
static int static_slot_iii(int, int) { return 0; }
static int static_slot_iiii(int, int, int) { return 0; }
@@ -4941,6 +4950,32 @@ void tst_QObject::connectCxx0xTypeMatching()
}
+void receiverFunction_noexcept() Q_DECL_NOTHROW {}
+struct Functor_noexcept { void operator()() Q_DECL_NOTHROW {} };
+void tst_QObject::connectCxx17Noexcept()
+{
+ // this is about connecting signals to slots with the Q_DECL_NOTHROW qualifier
+ // as semantics changed due to http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0012r1.html
+ typedef LotsOfSignalsAndSlots Foo;
+ Foo obj;
+
+ QObject::connect(&obj, &Foo::signal_v, &obj, &Foo::slot_v_noexcept);
+ QObject::connect(&obj, &Foo::signal_v, &obj, &Foo::slot_i_noexcept);
+ QObject::connect(&obj, &Foo::signal_v, &obj, &Foo::slot_vi_noexcept);
+
+ QObject::connect(&obj, &Foo::signal_vii, &Foo::static_slot_v_noexcept);
+ QObject::connect(&obj, &Foo::signal_vii, &Foo::static_slot_i_noexcept);
+ QObject::connect(&obj, &Foo::signal_vii, &Foo::static_slot_vi_noexcept);
+
+ QVERIFY(QObject::connect(&obj, &Foo::signal_vi, &obj, &Foo::const_slot_vi_noexcept));
+ QVERIFY(QObject::connect(&obj, &Foo::signal_vi, &obj, &Foo::const_slot_v_noexcept));
+
+ QObject::connect(&obj, &Foo::signal_v, receiverFunction_noexcept);
+
+ Functor_noexcept fn;
+ QObject::connect(&obj, &Foo::signal_v, fn);
+}
+
class StringVariant : public QObject
{ Q_OBJECT
signals:
diff --git a/tests/auto/corelib/kernel/qsharedmemory/qsharedmemory.pro b/tests/auto/corelib/kernel/qsharedmemory/qsharedmemory.pro
index 69062a9741..3a4697750e 100644
--- a/tests/auto/corelib/kernel/qsharedmemory/qsharedmemory.pro
+++ b/tests/auto/corelib/kernel/qsharedmemory/qsharedmemory.pro
@@ -1,5 +1,6 @@
TEMPLATE = subdirs
-!winrt: SUBDIRS = sharedmemoryhelper
-
-SUBDIRS += test
+qtConfig(sharedmemory) {
+ !winrt: SUBDIRS = sharedmemoryhelper
+ SUBDIRS += test
+}
diff --git a/tests/auto/corelib/kernel/qtimer/qtimer.pro b/tests/auto/corelib/kernel/qtimer/qtimer.pro
index 8afdbb148e..b27d862bc5 100644
--- a/tests/auto/corelib/kernel/qtimer/qtimer.pro
+++ b/tests/auto/corelib/kernel/qtimer/qtimer.pro
@@ -2,3 +2,6 @@ CONFIG += testcase
TARGET = tst_qtimer
QT = core testlib
SOURCES = tst_qtimer.cpp
+
+# Force C++17 if available
+contains(QT_CONFIG, c++1z): CONFIG += c++1z
diff --git a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
index fe97695d19..29ff552f6a 100644
--- a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
+++ b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
@@ -767,6 +767,11 @@ class StaticEventLoop
public:
static void quitEventLoop()
{
+ quitEventLoop_noexcept();
+ }
+
+ static void quitEventLoop_noexcept() Q_DECL_NOTHROW
+ {
QVERIFY(!_e.isNull());
_e->quit();
if (_t)
@@ -787,6 +792,9 @@ void tst_QTimer::singleShotToFunctors()
QTimer::singleShot(0, &StaticEventLoop::quitEventLoop);
QCOMPARE(_e->exec(), 0);
+ QTimer::singleShot(0, &StaticEventLoop::quitEventLoop_noexcept);
+ QCOMPARE(_e->exec(), 0);
+
QThread t1;
QObject c1;
c1.moveToThread(&t1);
diff --git a/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp b/tests/auto/corelib/kernel/qvariant/tst_qvariant.cpp
index 75fa424ab1..2a9b9c0a7f 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)
@@ -400,6 +400,17 @@ void tst_QVariant::isNull()
QVERIFY( !varLL.isNull() );
QVariant var7(QString::null);
QVERIFY(var7.isNull());
+ var7 = QVariant::fromValue<QString>(QString::null);
+ QVERIFY(var7.isNull());
+
+ QVariant var8(QMetaType::Nullptr, nullptr);
+ QVERIFY(var8.isNull());
+ var8 = QVariant::fromValue<std::nullptr_t>(nullptr);
+ QVERIFY(var8.isNull());
+ QVariant var9 = QVariant(QJsonValue(QJsonValue::Null));
+ QVERIFY(var9.isNull());
+ var9 = QVariant::fromValue<QJsonValue>(QJsonValue(QJsonValue::Null));
+ QVERIFY(var9.isNull());
}
void tst_QVariant::swap()
@@ -4660,7 +4671,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>());
@@ -4721,7 +4732,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;
}
@@ -4743,6 +4754,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/thread/qfuture/qfuture.pro b/tests/auto/corelib/thread/qfuture/qfuture.pro
index ed9e189668..b1667760d6 100644
--- a/tests/auto/corelib/thread/qfuture/qfuture.pro
+++ b/tests/auto/corelib/thread/qfuture/qfuture.pro
@@ -1,5 +1,5 @@
CONFIG += testcase
TARGET = tst_qfuture
-QT = core core-private testlib concurrent
+QT = core core-private testlib
SOURCES = tst_qfuture.cpp
DEFINES += QT_STRICT_ITERATORS
diff --git a/tests/auto/corelib/thread/qfuturesynchronizer/qfuturesynchronizer.pro b/tests/auto/corelib/thread/qfuturesynchronizer/qfuturesynchronizer.pro
index 5eebd12deb..0d20117ed0 100644
--- a/tests/auto/corelib/thread/qfuturesynchronizer/qfuturesynchronizer.pro
+++ b/tests/auto/corelib/thread/qfuturesynchronizer/qfuturesynchronizer.pro
@@ -1,4 +1,4 @@
CONFIG += testcase
TARGET = tst_qfuturesynchronizer
-QT = core testlib concurrent
+QT = core testlib
SOURCES = tst_qfuturesynchronizer.cpp
diff --git a/tests/auto/corelib/thread/qresultstore/qresultstore.pro b/tests/auto/corelib/thread/qresultstore/qresultstore.pro
index 2f6c18f64c..bbebe0976b 100644
--- a/tests/auto/corelib/thread/qresultstore/qresultstore.pro
+++ b/tests/auto/corelib/thread/qresultstore/qresultstore.pro
@@ -1,5 +1,5 @@
CONFIG += testcase
TARGET = tst_qresultstore
-QT = core-private testlib concurrent
+QT = core-private testlib
SOURCES = tst_qresultstore.cpp
DEFINES += QT_STRICT_ITERATORS
diff --git a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
index 7681f4755c..f56cff4d29 100644
--- a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
+++ b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp
@@ -186,12 +186,50 @@ void tst_QLocale::ctor()
QVERIFY(l.country() == default_country);
}
+#define TEST_CTOR(req_lang, req_script, req_country, exp_lang, exp_script, exp_country) \
+ { \
+ QLocale l(QLocale::req_lang, QLocale::req_script, QLocale::req_country); \
+ QCOMPARE((int)l.language(), (int)exp_lang); \
+ QCOMPARE((int)l.script(), (int)exp_script); \
+ QCOMPARE((int)l.country(), (int)exp_country); \
+ }
+
+ // Exact matches
+ TEST_CTOR(Chinese, SimplifiedHanScript, China, QLocale::Chinese, QLocale::SimplifiedHanScript, QLocale::China);
+ TEST_CTOR(Chinese, TraditionalHanScript, Taiwan, QLocale::Chinese, QLocale::TraditionalHanScript, QLocale::Taiwan);
+ TEST_CTOR(Chinese, TraditionalHanScript, HongKong, QLocale::Chinese, QLocale::TraditionalHanScript, QLocale::HongKong);
+
+ // Best match for AnyCountry
+ TEST_CTOR(Chinese, SimplifiedHanScript, AnyCountry, QLocale::Chinese, QLocale::SimplifiedHanScript, QLocale::China);
+ TEST_CTOR(Chinese, TraditionalHanScript, AnyCountry, QLocale::Chinese, QLocale::TraditionalHanScript, QLocale::Taiwan);
+
+ // Best match for AnyScript (and change country to supported one, if necessary)
+ TEST_CTOR(Chinese, AnyScript, China, QLocale::Chinese, QLocale::SimplifiedHanScript, QLocale::China);
+ TEST_CTOR(Chinese, AnyScript, Taiwan, QLocale::Chinese, QLocale::TraditionalHanScript, QLocale::Taiwan);
+ TEST_CTOR(Chinese, AnyScript, HongKong, QLocale::Chinese, QLocale::TraditionalHanScript, QLocale::HongKong);
+ TEST_CTOR(Chinese, AnyScript, UnitedStates, QLocale::Chinese, QLocale::SimplifiedHanScript, QLocale::China);
+
+ // Fully-specified not found; find best alternate country
+ TEST_CTOR(Chinese, SimplifiedHanScript, Taiwan, QLocale::Chinese, QLocale::SimplifiedHanScript, QLocale::China);
+ TEST_CTOR(Chinese, SimplifiedHanScript, UnitedStates, QLocale::Chinese, QLocale::SimplifiedHanScript, QLocale::China);
+ TEST_CTOR(Chinese, TraditionalHanScript, China, QLocale::Chinese, QLocale::TraditionalHanScript, QLocale::Taiwan);
+ TEST_CTOR(Chinese, TraditionalHanScript, UnitedStates, QLocale::Chinese, QLocale::TraditionalHanScript, QLocale::Taiwan);
+
+ // Fully-specified not found; find best alternate script
+ TEST_CTOR(Chinese, LatinScript, China, QLocale::Chinese, QLocale::SimplifiedHanScript, QLocale::China);
+ TEST_CTOR(Chinese, LatinScript, Taiwan, QLocale::Chinese, QLocale::TraditionalHanScript, QLocale::Taiwan);
+
+ // Fully-specified not found; find best alternate country and script
+ TEST_CTOR(Chinese, LatinScript, UnitedStates, QLocale::Chinese, QLocale::SimplifiedHanScript, QLocale::China);
+
+#undef TEST_CTOR
#define TEST_CTOR(req_lang, req_country, exp_lang, exp_country) \
{ \
QLocale l(QLocale::req_lang, QLocale::req_country); \
QCOMPARE((int)l.language(), (int)exp_lang); \
QCOMPARE((int)l.country(), (int)exp_country); \
}
+
{
QLocale l(QLocale::C, QLocale::AnyCountry);
QCOMPARE(l.language(), QLocale::C);
@@ -295,7 +333,6 @@ void tst_QLocale::ctor()
TEST_CTOR(Uzbek, AnyCountry, QLocale::Uzbek, QLocale::Uzbekistan)
#undef TEST_CTOR
-
#define TEST_CTOR(req_lc, exp_lang, exp_country) \
{ \
QLocale l(req_lc); \
diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
index 414ba2d8cf..727eda7456 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()
{
@@ -6070,6 +6071,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 +6346,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/qtimeline/tst_qtimeline.cpp b/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp
index 383f357206..b68c582732 100644
--- a/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp
+++ b/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp
@@ -189,7 +189,7 @@ void tst_QTimeLine::frameRate()
void tst_QTimeLine::value()
{
- QTimeLine timeLine(5000);
+ QTimeLine timeLine(4500); // Should be at least 5% under 5000ms
QCOMPARE(timeLine.currentValue(), 0.0);
// Default speed
diff --git a/tests/auto/dbus/qdbusmetaobject/tst_qdbusmetaobject.cpp b/tests/auto/dbus/qdbusmetaobject/tst_qdbusmetaobject.cpp
index cb1c9401ba..a4afae4b46 100644
--- a/tests/auto/dbus/qdbusmetaobject/tst_qdbusmetaobject.cpp
+++ b/tests/auto/dbus/qdbusmetaobject/tst_qdbusmetaobject.cpp
@@ -370,8 +370,7 @@ void tst_QDBusMetaObject::types()
QDBusError error;
- QMetaObject *result = QDBusMetaObject::createMetaObject("local.Interface", xml,
- map, error);
+ const QScopedPointer<QDBusMetaObject> result(QDBusMetaObject::createMetaObject("local.Interface", xml, map, error));
QVERIFY2(result, qPrintable(error.message()));
QCOMPARE(result->enumeratorCount(), 0);
diff --git a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
index ad7de09c48..72609d4095 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();
@@ -766,6 +767,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);
diff --git a/tests/auto/gui/text/qfont/tst_qfont.cpp b/tests/auto/gui/text/qfont/tst_qfont.cpp
index a6d8944656..2603206ab0 100644
--- a/tests/auto/gui/text/qfont/tst_qfont.cpp
+++ b/tests/auto/gui/text/qfont/tst_qfont.cpp
@@ -63,6 +63,7 @@ private slots:
void defaultFamily_data();
void defaultFamily();
void toAndFromString();
+ void fromStringWithoutStyleName();
void sharing();
};
@@ -358,6 +359,8 @@ void tst_QFont::serialize_data()
// Versions <= Qt 2.1 had broken point size serialization,
// so we set an integer point size.
basicFont.setPointSize(9);
+ // Versions <= Qt 5.4 didn't serialize styleName, so clear it
+ basicFont.setStyleName(QString());
QFont font = basicFont;
QTest::newRow("defaultConstructed") << font << QDataStream::Qt_1_0;
@@ -559,6 +562,19 @@ void tst_QFont::toAndFromString()
}
}
+void tst_QFont::fromStringWithoutStyleName()
+{
+ QFont font1;
+ font1.fromString("Noto Sans,12,-1,5,50,0,0,0,0,0,Regular");
+
+ QFont font2 = font1;
+ const QString str = "Times,16,-1,5,50,0,0,0,0,0";
+ font2.fromString(str);
+
+ QCOMPARE(font2.toString(), str);
+}
+
+
void tst_QFont::sharing()
{
// QFontCache references the engineData
diff --git a/tests/auto/gui/text/qinputcontrol/tst_qinputcontrol.cpp b/tests/auto/gui/text/qinputcontrol/tst_qinputcontrol.cpp
index ad5ba6affb..173e137d17 100644
--- a/tests/auto/gui/text/qinputcontrol/tst_qinputcontrol.cpp
+++ b/tests/auto/gui/text/qinputcontrol/tst_qinputcontrol.cpp
@@ -59,6 +59,28 @@ void tst_QInputControl::isAcceptableInput_data()
QTest::newRow("printable-hebrew") << QString(QChar(0x2135)) << Qt::KeyboardModifiers() << true;
QTest::newRow("private-use-area") << QString(QChar(0xE832)) << Qt::KeyboardModifiers() << true;
QTest::newRow("multiple-printable") << QStringLiteral("foobar") << Qt::KeyboardModifiers() << true;
+ QTest::newRow("rlm") << QString(QChar(0x200F)) << Qt::KeyboardModifiers() << true;
+ QTest::newRow("rlm-with-ctrl") << QString(QChar(0x200F)) << Qt::KeyboardModifiers(Qt::ControlModifier) << true;
+ QTest::newRow("rlm-with-ctrl-shift") << QString(QChar(0x200F)) << Qt::KeyboardModifiers(Qt::ControlModifier | Qt::ShiftModifier) << true;
+ QTest::newRow("lrm") << QString(QChar(0x200E)) << Qt::KeyboardModifiers() << true;
+ QTest::newRow("lrm-with-ctrl") << QString(QChar(0x200E)) << Qt::KeyboardModifiers(Qt::ControlModifier) << true;
+ QTest::newRow("lrm-with-ctrl-shift") << QString(QChar(0x200E)) << Qt::KeyboardModifiers(Qt::ControlModifier | Qt::ShiftModifier) << true;
+ QTest::newRow("rlo") << QString(QChar(0x202E)) << Qt::KeyboardModifiers() << true;
+ QTest::newRow("rlo-with-ctrl") << QString(QChar(0x202E)) << Qt::KeyboardModifiers(Qt::ControlModifier) << true;
+ QTest::newRow("rlo-with-ctrl-shift") << QString(QChar(0x202E)) << Qt::KeyboardModifiers(Qt::ControlModifier | Qt::ShiftModifier) << true;
+ QTest::newRow("lro") << QString(QChar(0x202D)) << Qt::KeyboardModifiers() << true;
+ QTest::newRow("lro-with-ctrl") << QString(QChar(0x202D)) << Qt::KeyboardModifiers(Qt::ControlModifier) << true;
+ QTest::newRow("lro-with-ctrl-shift") << QString(QChar(0x202D)) << Qt::KeyboardModifiers(Qt::ControlModifier | Qt::ShiftModifier) << true;
+ QTest::newRow("lre") << QString(QChar(0x202B)) << Qt::KeyboardModifiers() << true;
+ QTest::newRow("lre-with-ctrl") << QString(QChar(0x202B)) << Qt::KeyboardModifiers(Qt::ControlModifier) << true;
+ QTest::newRow("lre-with-ctrl-shift") << QString(QChar(0x202B)) << Qt::KeyboardModifiers(Qt::ControlModifier | Qt::ShiftModifier) << true;
+ QTest::newRow("rle") << QString(QChar(0x202A)) << Qt::KeyboardModifiers() << true;
+ QTest::newRow("rle-with-ctrl") << QString(QChar(0x202A)) << Qt::KeyboardModifiers(Qt::ControlModifier) << true;
+ QTest::newRow("rle-with-ctrl-shift") << QString(QChar(0x202A)) << Qt::KeyboardModifiers(Qt::ControlModifier | Qt::ShiftModifier) << true;
+ QTest::newRow("pdf") << QString(QChar(0x202C)) << Qt::KeyboardModifiers() << true;
+ QTest::newRow("pdf-with-ctrl") << QString(QChar(0x202C)) << Qt::KeyboardModifiers(Qt::ControlModifier) << true;
+ QTest::newRow("pdf-with-ctrl-shift") << QString(QChar(0x202C)) << Qt::KeyboardModifiers(Qt::ControlModifier | Qt::ShiftModifier) << true;
+
}
void tst_QInputControl::isAcceptableInput()
diff --git a/tests/auto/network/bearer/qnetworkconfiguration/tst_qnetworkconfiguration.cpp b/tests/auto/network/bearer/qnetworkconfiguration/tst_qnetworkconfiguration.cpp
index 6ca881d38a..9c49e0c173 100644
--- a/tests/auto/network/bearer/qnetworkconfiguration/tst_qnetworkconfiguration.cpp
+++ b/tests/auto/network/bearer/qnetworkconfiguration/tst_qnetworkconfiguration.cpp
@@ -115,7 +115,7 @@ void tst_QNetworkConfiguration::comparison()
QSignalSpy spy(&manager, SIGNAL(updateCompleted()));
manager.updateConfigurations(); //initiate scans
- QTRY_VERIFY_WITH_TIMEOUT(spy.count() == 1, TestTimeOut); //wait for scan to complete
+ QTRY_VERIFY_WITH_TIMEOUT(spy.count() >= 1, TestTimeOut); //wait for scan to complete
QList<QNetworkConfiguration> configs = manager.allConfigurations(QNetworkConfiguration::Discovered);
QVERIFY(configs.count());
@@ -162,7 +162,7 @@ void tst_QNetworkConfiguration::isRoamingAvailable()
//force update to get maximum list
QSignalSpy spy(&manager, SIGNAL(updateCompleted()));
manager.updateConfigurations(); //initiate scans
- QTRY_VERIFY_WITH_TIMEOUT(spy.count() == 1, TestTimeOut); //wait for scan to complete
+ QTRY_VERIFY_WITH_TIMEOUT(spy.count() >= 1, TestTimeOut); //wait for scan to complete
foreach(QNetworkConfiguration c, configs)
{
diff --git a/tests/auto/network/bearer/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp b/tests/auto/network/bearer/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp
index 838612f638..b251a65420 100644
--- a/tests/auto/network/bearer/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp
+++ b/tests/auto/network/bearer/qnetworkconfigurationmanager/tst_qnetworkconfigurationmanager.cpp
@@ -68,7 +68,7 @@ void tst_QNetworkConfigurationManager::allConfigurations()
QSignalSpy spy(&manager, SIGNAL(updateCompleted()));
manager.updateConfigurations(); //initiate scans
- QTRY_VERIFY_WITH_TIMEOUT(spy.count() == 1, TestTimeOut); //wait for scan to complete
+ QTRY_VERIFY_WITH_TIMEOUT(spy.count() >= 1, TestTimeOut); //wait for scan to complete
QList<QNetworkConfiguration> configs = manager.allConfigurations();
@@ -145,7 +145,7 @@ void tst_QNetworkConfigurationManager::defaultConfiguration()
QNetworkConfigurationManager manager;
QSignalSpy spy(&manager, SIGNAL(updateCompleted()));
manager.updateConfigurations(); //initiate scans
- QTRY_VERIFY_WITH_TIMEOUT(spy.count() == 1, TestTimeOut); //wait for scan to complete
+ QTRY_VERIFY_WITH_TIMEOUT(spy.count() >= 1, TestTimeOut); //wait for scan to complete
QList<QNetworkConfiguration> configs = manager.allConfigurations();
QNetworkConfiguration defaultConfig = manager.defaultConfiguration();
@@ -175,7 +175,7 @@ void tst_QNetworkConfigurationManager::configurationFromIdentifier()
//force an update to get maximum number of configs
QSignalSpy spy(&manager, SIGNAL(updateCompleted()));
manager.updateConfigurations(); //initiate scans
- QTRY_VERIFY_WITH_TIMEOUT(spy.count() == 1, TestTimeOut); //wait for scan to complete
+ QTRY_VERIFY_WITH_TIMEOUT(spy.count() >= 1, TestTimeOut); //wait for scan to complete
QList<QNetworkConfiguration> configs = manager.allConfigurations();
@@ -203,7 +203,7 @@ protected:
preScanConfigs = manager.allConfigurations();
QSignalSpy spy(&manager, SIGNAL(updateCompleted()));
manager.updateConfigurations(); //initiate scans
- QTRY_VERIFY_WITH_TIMEOUT(spy.count() == 1, TestTimeOut); //wait for scan to complete
+ QTRY_VERIFY_WITH_TIMEOUT(spy.count() >= 1, TestTimeOut); //wait for scan to complete
configs = manager.allConfigurations();
}
public:
@@ -229,7 +229,7 @@ void tst_QNetworkConfigurationManager::usedInThread()
QList<QNetworkConfiguration> preScanConfigs = manager.allConfigurations();
QSignalSpy spy(&manager, SIGNAL(updateCompleted()));
manager.updateConfigurations(); //initiate scans
- QTRY_VERIFY_WITH_TIMEOUT(spy.count() == 1, TestTimeOut); //wait for scan to complete
+ QTRY_VERIFY_WITH_TIMEOUT(spy.count() >= 1, TestTimeOut); //wait for scan to complete
QList<QNetworkConfiguration> configs = manager.allConfigurations();
QCOMPARE(thread.configs, configs);
//Don't compare pre scan configs, because these may be cached and therefore give different results
diff --git a/tests/auto/network/bearer/qnetworksession/test/tst_qnetworksession.cpp b/tests/auto/network/bearer/qnetworksession/test/tst_qnetworksession.cpp
index 4ae511cf54..138a0859cd 100644
--- a/tests/auto/network/bearer/qnetworksession/test/tst_qnetworksession.cpp
+++ b/tests/auto/network/bearer/qnetworksession/test/tst_qnetworksession.cpp
@@ -106,7 +106,7 @@ void tst_QNetworkSession::initTestCase()
QSignalSpy spy(&manager, SIGNAL(updateCompleted()));
manager.updateConfigurations();
- QTRY_VERIFY_WITH_TIMEOUT(spy.count() == 1, TestTimeOut);
+ QTRY_VERIFY_WITH_TIMEOUT(spy.count() >= 1, TestTimeOut);
lackeyDir = QFINDTESTDATA("lackey");
QVERIFY2(!lackeyDir.isEmpty(), qPrintable(
@@ -1007,7 +1007,7 @@ QNetworkConfiguration suitableConfiguration(QString bearerType, QNetworkConfigur
QSignalSpy updateSpy(&mgr, SIGNAL(updateCompleted()));
mgr.updateConfigurations();
- QTRY_NOOP(updateSpy.count() == 1);
+ QTRY_NOOP(updateSpy.count() >= 1);
if (updateSpy.count() != 1) {
qDebug("tst_QNetworkSession::suitableConfiguration() failure: unable to update configurations");
return QNetworkConfiguration();
@@ -1052,7 +1052,7 @@ void updateConfigurations()
QNetworkConfigurationManager mgr;
QSignalSpy updateSpy(&mgr, SIGNAL(updateCompleted()));
mgr.updateConfigurations();
- QTRY_NOOP(updateSpy.count() == 1);
+ QTRY_NOOP(updateSpy.count() >= 1);
}
// A convenience-function: updates and prints all available confiurations and their states
diff --git a/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp b/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp
index 364e435d3d..bc3f5650ba 100644
--- a/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp
+++ b/tests/auto/network/kernel/qhostaddress/tst_qhostaddress.cpp
@@ -271,8 +271,10 @@ void tst_QHostAddress::specialAddresses()
//check special address equal to itself (QTBUG-22898), note two overloads of operator==
QVERIFY(QHostAddress(address) == QHostAddress(address));
QVERIFY(QHostAddress(address) == address);
+ 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/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp b/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp
index c945d77cda..18da122000 100644
--- a/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp
+++ b/tests/auto/network/socket/qsocks5socketengine/tst_qsocks5socketengine.cpp
@@ -54,7 +54,6 @@ class tst_QSocks5SocketEngine : public QObject, public QAbstractSocketEngineRece
private slots:
void initTestCase();
- void init();
void construction();
void errorTest_data();
void errorTest();
@@ -74,13 +73,6 @@ private slots:
void incomplete();
protected slots:
- void tcpSocketNonBlocking_hostFound();
- void tcpSocketNonBlocking_connected();
- void tcpSocketNonBlocking_closed();
- void tcpSocketNonBlocking_readyRead();
- void tcpSocketNonBlocking_bytesWritten(qint64);
- void exitLoopSlot();
- void downloadBigFileSlot();
void proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *auth);
private:
@@ -89,11 +81,6 @@ private:
void closeNotification() { }
void exceptionNotification() { }
void connectionNotification() { }
- QTcpSocket *tcpSocketNonBlocking_socket;
- QStringList tcpSocketNonBlocking_data;
- qint64 tcpSocketNonBlocking_totalWritten;
- QTcpSocket *tmpSocket;
- qint64 bytesAvailable;
};
class MiniSocks5ResponseHandler : public QObject
@@ -153,12 +140,6 @@ void tst_QSocks5SocketEngine::initTestCase()
QVERIFY(QtNetworkSettings::verifyTestNetworkSettings());
}
-void tst_QSocks5SocketEngine::init()
-{
- tmpSocket = 0;
- bytesAvailable = 0;
-}
-
//---------------------------------------------------------------------------
void tst_QSocks5SocketEngine::construction()
{
@@ -631,13 +612,27 @@ void tst_QSocks5SocketEngine::tcpSocketNonBlockingTest()
{
QSocks5SocketEngineHandler socks5;
+ qint64 tcpSocketNonBlocking_totalWritten = 0;
+ QStringList tcpSocketNonBlocking_data;
QTcpSocket socket;
- connect(&socket, SIGNAL(hostFound()), SLOT(tcpSocketNonBlocking_hostFound()));
- connect(&socket, SIGNAL(connected()), SLOT(tcpSocketNonBlocking_connected()));
- connect(&socket, SIGNAL(disconnected()), SLOT(tcpSocketNonBlocking_closed()));
- connect(&socket, SIGNAL(bytesWritten(qint64)), SLOT(tcpSocketNonBlocking_bytesWritten(qint64)));
- connect(&socket, SIGNAL(readyRead()), SLOT(tcpSocketNonBlocking_readyRead()));
- tcpSocketNonBlocking_socket = &socket;
+ connect(&socket, &QAbstractSocket::hostFound,
+ &QTestEventLoop::instance(), &QTestEventLoop::exitLoop);
+ connect(&socket, &QAbstractSocket::connected,
+ &QTestEventLoop::instance(), &QTestEventLoop::exitLoop);
+ connect(&socket, &QIODevice::bytesWritten,
+ [&tcpSocketNonBlocking_totalWritten] (qint64 written)
+ {
+ tcpSocketNonBlocking_totalWritten += written;
+ QTestEventLoop::instance().exitLoop();
+ });
+
+ connect(&socket, &QIODevice::readyRead,
+ [&tcpSocketNonBlocking_data, &socket] ()
+ {
+ while (socket.canReadLine())
+ tcpSocketNonBlocking_data.append(socket.readLine());
+ QTestEventLoop::instance().exitLoop();
+ });
// Connect
socket.connectToHost(QtNetworkSettings::serverName(), 143);
@@ -725,62 +720,50 @@ void tst_QSocks5SocketEngine::tcpSocketNonBlockingTest()
QCOMPARE(socket.state(), QTcpSocket::UnconnectedState);
}
-void tst_QSocks5SocketEngine::tcpSocketNonBlocking_hostFound()
-{
- QTestEventLoop::instance().exitLoop();
-}
-
-void tst_QSocks5SocketEngine::tcpSocketNonBlocking_connected()
-{
- QTestEventLoop::instance().exitLoop();
-}
-
-void tst_QSocks5SocketEngine::tcpSocketNonBlocking_readyRead()
-{
- while (tcpSocketNonBlocking_socket->canReadLine())
- tcpSocketNonBlocking_data.append(tcpSocketNonBlocking_socket->readLine());
-
- QTestEventLoop::instance().exitLoop();
-}
-
-void tst_QSocks5SocketEngine::tcpSocketNonBlocking_bytesWritten(qint64 written)
-{
- tcpSocketNonBlocking_totalWritten += written;
- QTestEventLoop::instance().exitLoop();
-}
-
-void tst_QSocks5SocketEngine::tcpSocketNonBlocking_closed()
-{
-}
-
//----------------------------------------------------------------------------------
void tst_QSocks5SocketEngine::downloadBigFile()
{
QSocks5SocketEngineHandler socks5;
- if (tmpSocket)
- delete tmpSocket;
- tmpSocket = new QTcpSocket;
-
- connect(tmpSocket, SIGNAL(connected()), SLOT(exitLoopSlot()));
- connect(tmpSocket, SIGNAL(readyRead()), SLOT(downloadBigFileSlot()));
-
- tmpSocket->connectToHost(QtNetworkSettings::serverName(), 80);
+ QTcpSocket socket;
+ qint64 bytesAvailable = 0;
+ connect(&socket, &QAbstractSocket::connected,
+ &QTestEventLoop::instance(), &QTestEventLoop::exitLoop);
+ connect(&socket, &QIODevice::readyRead,
+ [&socket, &bytesAvailable] ()
+ {
+ const QByteArray tmp = socket.readAll();
+ int correction = tmp.indexOf(char(0), 0); //skip header
+ if (correction == -1)
+ correction = 0;
+ bytesAvailable += (tmp.size() - correction);
+ if (bytesAvailable >= 10000000)
+ QTestEventLoop::instance().exitLoop();
+ });
+
+ connect(&socket, QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::error),
+ [&socket] (QAbstractSocket::SocketError errorCode)
+ {
+ qWarning().noquote().nospace() << QTest::currentTestFunction()
+ << ": error " << errorCode << ": " << socket.errorString();
+ });
+
+ socket.connectToHost(QtNetworkSettings::serverName(), 80);
QTestEventLoop::instance().enterLoop(30);
if (QTestEventLoop::instance().timeout())
QFAIL("Network operation timed out");
QByteArray hostName = QtNetworkSettings::serverName().toLatin1();
- QCOMPARE(tmpSocket->state(), QAbstractSocket::ConnectedState);
- QVERIFY(tmpSocket->write("GET /qtest/mediumfile HTTP/1.0\r\n") > 0);
- QVERIFY(tmpSocket->write("HOST: ") > 0);
- QVERIFY(tmpSocket->write(hostName.data()) > 0);
- QVERIFY(tmpSocket->write("\r\n") > 0);
- QVERIFY(tmpSocket->write("\r\n") > 0);
+ QCOMPARE(socket.state(), QAbstractSocket::ConnectedState);
+ QVERIFY(socket.write("GET /qtest/mediumfile HTTP/1.0\r\n") > 0);
+ QVERIFY(socket.write("HOST: ") > 0);
+ QVERIFY(socket.write(hostName.data()) > 0);
+ QVERIFY(socket.write("\r\n") > 0);
+ QVERIFY(socket.write("\r\n") > 0);
+
- bytesAvailable = 0;
QTime stopWatch;
stopWatch.start();
@@ -791,31 +774,12 @@ void tst_QSocks5SocketEngine::downloadBigFile()
QCOMPARE(bytesAvailable, qint64(10000000));
- QCOMPARE(tmpSocket->state(), QAbstractSocket::ConnectedState);
+ QCOMPARE(socket.state(), QAbstractSocket::ConnectedState);
/*qDebug("\t\t%.1fMB/%.1fs: %.1fMB/s",
bytesAvailable / (1024.0 * 1024.0),
stopWatch.elapsed() / 1024.0,
(bytesAvailable / (stopWatch.elapsed() / 1000.0)) / (1024 * 1024));*/
-
- delete tmpSocket;
- tmpSocket = 0;
-}
-
-void tst_QSocks5SocketEngine::exitLoopSlot()
-{
- QTestEventLoop::instance().exitLoop();
-}
-
-
-void tst_QSocks5SocketEngine::downloadBigFileSlot()
-{
- QByteArray tmp=tmpSocket->readAll();
- int correction=tmp.indexOf((char)0,0); //skip header
- if (correction==-1) correction=0;
- bytesAvailable += (tmp.size()-correction);
- if (bytesAvailable >= 10000000)
- QTestEventLoop::instance().exitLoop();
}
void tst_QSocks5SocketEngine::passwordAuth()
diff --git a/tests/auto/network/ssl/qssldiffiehellmanparameters/tst_qssldiffiehellmanparameters.cpp b/tests/auto/network/ssl/qssldiffiehellmanparameters/tst_qssldiffiehellmanparameters.cpp
index f3b9003fbb..ddf503eed6 100644
--- a/tests/auto/network/ssl/qssldiffiehellmanparameters/tst_qssldiffiehellmanparameters.cpp
+++ b/tests/auto/network/ssl/qssldiffiehellmanparameters/tst_qssldiffiehellmanparameters.cpp
@@ -42,6 +42,13 @@
#include <QSslSocket>
#include <QByteArray>
+// Default DH parameters, exported by qssldiffiehellmanparameters.cpp.
+QT_BEGIN_NAMESPACE
+extern Q_AUTOTEST_EXPORT const char *qssl_dhparams_default_base64;
+QT_END_NAMESPACE
+
+QT_USE_NAMESPACE
+
class tst_QSslDiffieHellmanParameters : public QObject
{
Q_OBJECT
@@ -54,6 +61,7 @@ private Q_SLOTS:
void constructionPEM();
void unsafe512Bits();
void unsafeNonPrime();
+ void defaultIsValid();
#endif
};
@@ -157,6 +165,33 @@ void tst_QSslDiffieHellmanParameters::unsafeNonPrime()
#endif
}
+void tst_QSslDiffieHellmanParameters::defaultIsValid()
+{
+ // The QSslDiffieHellmanParameters::defaultParameters() method takes a shortcut,
+ // by not verifying the passed-in parameters. Instead, it simply assigns the default
+ // DH parameters to the derData field of QSslDiffieHellmanParametersPrivate.
+ //
+ // This test ensures that our default parameters pass the internal verification tests
+ // by constructing, using fromEncoded(), a QSslDiffieHellmanParameters instance that
+ // we expect to be equivalent to the one returned by defaultParameters(). By using
+ // fromEncoded() we go through the internal verification mechanisms. Finally, to ensure
+ // the two instances are equivalent, we compare them.
+
+ const auto dh = QSslDiffieHellmanParameters::fromEncoded(
+ QByteArray::fromBase64(QByteArray(qssl_dhparams_default_base64)),
+ QSsl::Der
+ );
+
+ const auto defaultdh = QSslDiffieHellmanParameters::defaultParameters();
+
+#ifndef QT_NO_OPENSSL
+ QCOMPARE(dh.isEmpty(), false);
+ QCOMPARE(dh.isValid(), true);
+ QCOMPARE(dh.error(), QSslDiffieHellmanParameters::NoError);
+ QCOMPARE(dh, defaultdh);
+#endif
+}
+
#endif // QT_NO_SSL
QTEST_MAIN(tst_QSslDiffieHellmanParameters)
diff --git a/tests/auto/other/lancelot/lancelot.pro b/tests/auto/other/lancelot/lancelot.pro
index 798482f02c..73c12e67a2 100644
--- a/tests/auto/other/lancelot/lancelot.pro
+++ b/tests/auto/other/lancelot/lancelot.pro
@@ -1,6 +1,6 @@
CONFIG += testcase
TARGET = tst_lancelot
-QT += xml testlib
+QT += testlib
SOURCES += tst_lancelot.cpp \
paintcommands.cpp
diff --git a/tests/auto/printsupport/kernel/qprintdevice/qprintdevice.pro b/tests/auto/printsupport/kernel/qprintdevice/qprintdevice.pro
index 56c1b60d94..a859f15fbb 100644
--- a/tests/auto/printsupport/kernel/qprintdevice/qprintdevice.pro
+++ b/tests/auto/printsupport/kernel/qprintdevice/qprintdevice.pro
@@ -2,6 +2,6 @@ CONFIG += testcase
TARGET = tst_qprintdevice
SOURCES += tst_qprintdevice.cpp
-QT += printsupport-private network testlib
+QT += printsupport-private testlib
DEFINES += QT_USE_USING_NAMESPACE
diff --git a/tests/auto/printsupport/kernel/qprinterinfo/qprinterinfo.pro b/tests/auto/printsupport/kernel/qprinterinfo/qprinterinfo.pro
index f397f48bb8..36261780fd 100644
--- a/tests/auto/printsupport/kernel/qprinterinfo/qprinterinfo.pro
+++ b/tests/auto/printsupport/kernel/qprinterinfo/qprinterinfo.pro
@@ -2,6 +2,6 @@ CONFIG += testcase
TARGET = tst_qprinterinfo
SOURCES += tst_qprinterinfo.cpp
-QT += printsupport network testlib
+QT += printsupport testlib
DEFINES += QT_USE_USING_NAMESPACE
diff --git a/tests/auto/testlib/selftests/test/test.pro b/tests/auto/testlib/selftests/test/test.pro
index a2a1dd3f0b..a7487736b3 100644
--- a/tests/auto/testlib/selftests/test/test.pro
+++ b/tests/auto/testlib/selftests/test/test.pro
@@ -1,6 +1,6 @@
CONFIG += testcase
SOURCES += ../tst_selftests.cpp
-QT = core xml testlib-private
+QT = core testlib-private
TARGET = ../tst_selftests
diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
index c8bdcbde09..5ab24d6878 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
@@ -2885,7 +2885,7 @@ public:
void tst_QGraphicsView::scrollBarRanges()
{
- QFETCH(QString, style);
+ QFETCH(QByteArray, style);
QFETCH(QSize, viewportSize);
QFETCH(QRectF, sceneRect);
QFETCH(ScrollBarCount, sceneRectOffsetFactors);
@@ -2898,7 +2898,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 +2909,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/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
index bd6733e2d0..426db265ae 100644
--- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
+++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
@@ -1567,7 +1567,7 @@ void tst_QAbstractItemView::testChangeEditorState()
QTableView view;
view.setEditTriggers(QAbstractItemView::CurrentChanged);
- view.setItemDelegate(new StateChangeDelegate);
+ view.setItemDelegate(new StateChangeDelegate(&view));
view.setModel(&model);
centerOnScreen(&view);
moveCursorAway(&view);
@@ -1941,7 +1941,8 @@ void tst_QAbstractItemView::QTBUG50102_SH_ItemView_ScrollMode()
QCOMPARE(view.horizontalScrollMode(), styleScrollMode);
// Change style, get new value
- view.setStyle(new ScrollModeProxyStyle(styleScrollMode));
+ ScrollModeProxyStyle proxyStyle1(styleScrollMode);
+ view.setStyle(&proxyStyle1);
auto proxyScrollMode = static_cast<QAbstractItemView::ScrollMode>(view.style()->styleHint(QStyle::SH_ItemView_ScrollMode, 0, &view, 0));
QVERIFY(styleScrollMode != proxyScrollMode);
QCOMPARE(view.verticalScrollMode(), proxyScrollMode);
@@ -1953,7 +1954,8 @@ void tst_QAbstractItemView::QTBUG50102_SH_ItemView_ScrollMode()
QCOMPARE(view.horizontalScrollMode(), proxyScrollMode);
// Change style, won't change value for vertical, will change for horizontal
- view.setStyle(new ScrollModeProxyStyle(proxyScrollMode));
+ ScrollModeProxyStyle proxyStyle2(proxyScrollMode);
+ view.setStyle(&proxyStyle2);
QCOMPARE(view.verticalScrollMode(), proxyScrollMode);
QCOMPARE(view.horizontalScrollMode(), styleScrollMode);
}
diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
index 32a324b888..7bfec2831d 100644
--- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
@@ -169,6 +169,9 @@ private slots:
void moveSectionAndReset();
void moveSectionAndRemove();
void saveRestore();
+ void restoreQt4State();
+ void restoreToMoreColumns();
+ void restoreBeforeSetModel();
void defaultSectionSizeTest();
void defaultSectionSizeTestStyles();
@@ -1523,11 +1526,11 @@ public:
{
return hasIndex(row, column, parent) ? createIndex(row, column) : QModelIndex();
}
- int rowCount(const QModelIndex & /* parent */) const
+ int rowCount(const QModelIndex & /*parent*/ = QModelIndex()) const
{
return 8;
}
- int columnCount(const QModelIndex &/*parent= QModelIndex()*/) const
+ int columnCount(const QModelIndex &/*parent*/ = QModelIndex()) const
{
return m_col_count;
}
@@ -1588,41 +1591,56 @@ void tst_QHeaderView::moveSectionAndRemove()
QCOMPARE(v.count(), 0);
}
-void tst_QHeaderView::saveRestore()
+static QByteArray savedState()
{
- SimpleModel m;
+ QStandardItemModel m(4, 4);
QHeaderView h1(Qt::Horizontal);
h1.setModel(&m);
h1.swapSections(0, 2);
h1.resizeSection(1, 10);
h1.setSortIndicatorShown(true);
- h1.setSortIndicator(1,Qt::DescendingOrder);
- QByteArray s1 = h1.saveState();
+ h1.setSortIndicator(2, Qt::DescendingOrder);
+ h1.setSectionHidden(3, true);
+ return h1.saveState();
+}
+
+void tst_QHeaderView::saveRestore()
+{
+ QStandardItemModel m(4, 4);
+ const QByteArray s1 = savedState();
QHeaderView h2(Qt::Vertical);
QSignalSpy spy(&h2, SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)));
h2.setModel(&m);
- h2.restoreState(s1);
+ QVERIFY(h2.restoreState(s1));
QCOMPARE(spy.count(), 1);
- QCOMPARE(spy.at(0).at(0).toInt(), 1);
+ QCOMPARE(spy.at(0).at(0).toInt(), 2);
QCOMPARE(h2.logicalIndex(0), 2);
QCOMPARE(h2.logicalIndex(2), 0);
QCOMPARE(h2.sectionSize(1), 10);
- QCOMPARE(h2.sortIndicatorSection(), 1);
+ QCOMPARE(h2.sortIndicatorSection(), 2);
QCOMPARE(h2.sortIndicatorOrder(), Qt::DescendingOrder);
QCOMPARE(h2.isSortIndicatorShown(), true);
+ QVERIFY(!h2.isSectionHidden(2));
+ QVERIFY(h2.isSectionHidden(3));
+ QCOMPARE(h2.hiddenSectionCount(), 1);
QByteArray s2 = h2.saveState();
-
QCOMPARE(s1, s2);
+
QVERIFY(!h2.restoreState(QByteArrayLiteral("Garbage")));
+}
+void tst_QHeaderView::restoreQt4State()
+{
// QTBUG-40462
// Setting from Qt4, where information about multiple sections were grouped together in one
// sectionItem object
+ QStandardItemModel m(4, 10);
+ QHeaderView h2(Qt::Vertical);
QByteArray settings_qt4 =
QByteArray::fromHex("000000ff00000000000000010000000100000000010000000000000000000000000000"
"0000000003e80000000a0101000100000000000000000000000064ffffffff00000081"
@@ -1652,6 +1670,50 @@ void tst_QHeaderView::saveRestore()
QCOMPARE(h2.saveState(), old_state);
}
+void tst_QHeaderView::restoreToMoreColumns()
+{
+ // Restore state onto a model with more columns
+ const QByteArray s1 = savedState();
+ QHeaderView h4(Qt::Horizontal);
+ QStandardItemModel fiveColumnsModel(1, 5);
+ h4.setModel(&fiveColumnsModel);
+ QCOMPARE(fiveColumnsModel.columnCount(), 5);
+ QCOMPARE(h4.count(), 5);
+ QVERIFY(h4.restoreState(s1));
+ QCOMPARE(fiveColumnsModel.columnCount(), 5);
+ QCOMPARE(h4.count(), 5);
+ QCOMPARE(h4.sectionSize(1), 10);
+ for (int i = 0; i < h4.count(); ++i)
+ QVERIFY(h4.sectionSize(i) > 0 || h4.isSectionHidden(i));
+ QVERIFY(!h4.isSectionHidden(2));
+ QVERIFY(h4.isSectionHidden(3));
+ QCOMPARE(h4.hiddenSectionCount(), 1);
+ QCOMPARE(h4.sortIndicatorSection(), 2);
+ QCOMPARE(h4.sortIndicatorOrder(), Qt::DescendingOrder);
+}
+
+void tst_QHeaderView::restoreBeforeSetModel()
+{
+ QHeaderView h2(Qt::Horizontal);
+ const QByteArray s1 = savedState();
+ // First restore
+ QVERIFY(h2.restoreState(s1));
+ // Then setModel
+ QStandardItemModel model(4, 4);
+ h2.setModel(&model);
+
+ // Check the result
+ QCOMPARE(h2.logicalIndex(0), 2);
+ QCOMPARE(h2.logicalIndex(2), 0);
+ QCOMPARE(h2.sectionSize(1), 10);
+ QCOMPARE(h2.sortIndicatorSection(), 2);
+ QCOMPARE(h2.sortIndicatorOrder(), Qt::DescendingOrder);
+ QCOMPARE(h2.isSortIndicatorShown(), true);
+ QVERIFY(!h2.isSectionHidden(2));
+ QVERIFY(h2.isSectionHidden(3));
+ QCOMPARE(h2.hiddenSectionCount(), 1);
+}
+
void tst_QHeaderView::defaultSectionSizeTest()
{
// Setup
@@ -2461,7 +2523,8 @@ void tst_QHeaderView::calculateAndCheck(int cppline, const int precalced_compare
const bool sanity_checks = true;
if (sanity_checks) {
QString msg = QString("sanity problem at ") + sline;
- char *verifytext = QTest::toString(msg);
+ const QScopedArrayPointer<char> holder(QTest::toString(msg));
+ const auto verifytext = holder.data();
QVERIFY2(m_tableview->model()->rowCount() == view->count() , verifytext);
QVERIFY2(view->visualIndex(lastindex + 1) <= 0, verifytext); // there is no such index in model
@@ -2493,7 +2556,8 @@ void tst_QHeaderView::calculateAndCheck(int cppline, const int precalced_compare
msg += istr(chk_visual) + istr(chk_logical) + istr(chk_sizes) + istr(chk_hidden_size)
+ istr(chk_lookup_visual) + istr(chk_lookup_logical) + istr(header_lenght, false) + "};";
- char *verifytext = QTest::toString(msg);
+ const QScopedArrayPointer<char> holder(QTest::toString(msg));
+ const auto verifytext = holder.data();
QVERIFY2(chk_visual == x[0], verifytext);
QVERIFY2(chk_logical == x[1], verifytext);
diff --git a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
index 0720a4f766..5b353bb2ae 100644
--- a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
+++ b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp
@@ -1350,7 +1350,7 @@ void tst_QItemDelegate::QTBUG4435_keepSelectionOnCheck()
}
QTableView view;
view.setModel(&model);
- view.setItemDelegate(new TestItemDelegate);
+ view.setItemDelegate(new TestItemDelegate(&view));
view.show();
view.selectAll();
QVERIFY(QTest::qWaitForWindowExposed(&view));
diff --git a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
index e5e9b87df4..29e4bbfe29 100644
--- a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
+++ b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp
@@ -151,6 +151,7 @@ private slots:
void taskQTBUG_7232_AllowUserToControlSingleStep();
void taskQTBUG_51086_skippingIndexesInSelectedIndexes();
void expandingListItems();
+ void taskQTBUG_47694_indexOutOfBoundBatchLayout();
};
// Testing get/set functions
@@ -1488,7 +1489,7 @@ void tst_QListView::task203585_selectAll()
//we make sure that "select all" doesn't select the hidden items
QListView view;
view.setSelectionMode(QAbstractItemView::ExtendedSelection);
- view.setModel(new QStringListModel( QStringList() << "foo"));
+ view.setModel(new QStringListModel(QStringList() << "foo", &view));
view.setRowHidden(0, true);
view.selectAll();
QVERIFY(view.selectionModel()->selectedIndexes().isEmpty());
@@ -2510,5 +2511,18 @@ void tst_QListView::expandingListItems()
QVERIFY(w.visualRect(item1->index()).width() < w.visualRect(item2->index()).width());
}
+void tst_QListView::taskQTBUG_47694_indexOutOfBoundBatchLayout()
+{
+ QListView view;
+ view.setLayoutMode(QListView::Batched);
+ int batchSize = view.batchSize();
+
+ QStandardItemModel model(batchSize + 1, 1);
+
+ view.setModel(&model);
+
+ view.scrollTo(model.index(batchSize - 1, 0));
+}
+
QTEST_MAIN(tst_QListView)
#include "tst_qlistview.moc"
diff --git a/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp b/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp
index eb93e4c167..6547bb8985 100644
--- a/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp
+++ b/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp
@@ -1629,7 +1629,7 @@ void tst_QListWidget::QTBUG14363_completerWithAnyKeyPressedEditTriggers()
{
QListWidget listWidget;
listWidget.setEditTriggers(QAbstractItemView::AnyKeyPressed);
- listWidget.setItemDelegate(new ItemDelegate);
+ listWidget.setItemDelegate(new ItemDelegate(&listWidget));
QListWidgetItem *item = new QListWidgetItem(QLatin1String("select an item (don't start editing)"), &listWidget);
item->setFlags(Qt::ItemIsEnabled|Qt::ItemIsSelectable|Qt::ItemIsEditable);
new QListWidgetItem(QLatin1String("try to type the letter 'c'"), &listWidget);
diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
index 80ef0879cc..e2886cfcfe 100644
--- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
+++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
@@ -3796,25 +3796,24 @@ void tst_QTreeView::task248022_changeSelection()
void tst_QTreeView::task245654_changeModelAndExpandAll()
{
QTreeView view;
- QStandardItemModel *model = new QStandardItemModel;
+ QScopedPointer<QStandardItemModel> model(new QStandardItemModel);
QStandardItem *top = new QStandardItem("top");
QStandardItem *sub = new QStandardItem("sub");
top->appendRow(sub);
model->appendRow(top);
- view.setModel(model);
+ view.setModel(model.data());
view.expandAll();
QApplication::processEvents();
QVERIFY(view.isExpanded(top->index()));
//now let's try to delete the model
//then repopulate and expand again
- delete model;
- model = new QStandardItemModel;
+ model.reset(new QStandardItemModel);
top = new QStandardItem("top");
sub = new QStandardItem("sub");
top->appendRow(sub);
model->appendRow(top);
- view.setModel(model);
+ view.setModel(model.data());
view.expandAll();
QApplication::processEvents();
QVERIFY(view.isExpanded(top->index()));
diff --git a/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp b/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp
index fcffaa0eb9..f20805f97e 100644
--- a/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp
+++ b/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp
@@ -554,16 +554,16 @@ void tst_QTreeWidget::removeChild()
QFETCH(int, childCount);
QFETCH(int, removeAt);
- QTreeWidgetItem *root = new QTreeWidgetItem;
+ const QScopedPointer<QTreeWidgetItem> root(new QTreeWidgetItem);
for (int i = 0; i < childCount; ++i)
- new QTreeWidgetItem(root, QStringList(QString::number(i)));
+ new QTreeWidgetItem(root.data(), QStringList(QString::number(i)));
QCOMPARE(root->childCount(), childCount);
for (int j = 0; j < childCount; ++j)
QCOMPARE(root->child(j)->text(0), QString::number(j));
- QTreeWidgetItem *remove = root->child(removeAt);
- root->removeChild(remove);
+ const QScopedPointer<QTreeWidgetItem> remove(root->child(removeAt));
+ root->removeChild(remove.data());
QCOMPARE(root->childCount(), childCount - 1);
for (int k = 0; k < childCount; ++k) {
@@ -574,7 +574,6 @@ void tst_QTreeWidget::removeChild()
else if (k > removeAt)
QCOMPARE(root->child(k - 1)->text(0), QString::number(k));
}
- delete root;
}
void tst_QTreeWidget::setItemHidden()
@@ -1954,9 +1953,9 @@ void tst_QTreeWidget::itemData()
void tst_QTreeWidget::enableDisable()
{
- QTreeWidgetItem *itm = new QTreeWidgetItem();
+ const QScopedPointer<QTreeWidgetItem> itm(new QTreeWidgetItem);
for (int i = 0; i < 10; ++i)
- new QTreeWidgetItem(itm);
+ new QTreeWidgetItem(itm.data());
// make sure all items are enabled
QVERIFY(itm->flags() & Qt::ItemIsEnabled);
@@ -2720,7 +2719,10 @@ void tst_QTreeWidget::setDisabled()
children.append(new QTreeWidgetItem());
children.append(new QTreeWidgetItem());
children.append(new QTreeWidgetItem());
- i1 = top->takeChild(0);
+ {
+ const QScopedPointer<QTreeWidgetItem> taken(top->takeChild(0));
+ QCOMPARE(taken.data(), i1);
+ }
top->addChildren(children);
QCOMPARE(top->child(0)->isDisabled(), false);
@@ -2732,16 +2734,21 @@ void tst_QTreeWidget::setDisabled()
QCOMPARE(top->child(1)->isDisabled(), true);
QCOMPARE(top->child(1)->isDisabled(), true);
- children = top->takeChildren();
- QCOMPARE(children.at(0)->isDisabled(), false);
- QCOMPARE(children.at(1)->isDisabled(), false);
- QCOMPARE(children.at(1)->isDisabled(), false);
+ struct Deleter {
+ QList<QTreeWidgetItem *> items;
+ explicit Deleter(QList<QTreeWidgetItem *> items) : items(std::move(items)) {}
+ ~Deleter() { qDeleteAll(items); }
+ };
+ const Deleter takenChildren(top->takeChildren());
+ QCOMPARE(takenChildren.items[0]->isDisabled(), false);
+ QCOMPARE(takenChildren.items[1]->isDisabled(), false);
+ QCOMPARE(takenChildren.items[1]->isDisabled(), false);
}
void tst_QTreeWidget::removeSelectedItem()
{
- QTreeWidget *w = new QTreeWidget();
+ const QScopedPointer <QTreeWidget> w(new QTreeWidget);
w->setSortingEnabled(true);
QTreeWidgetItem *first = new QTreeWidgetItem();
@@ -2767,15 +2774,13 @@ void tst_QTreeWidget::removeSelectedItem()
QCOMPARE(selModel->hasSelection(), true);
QCOMPARE(selModel->selectedRows().count(), 1);
- QTreeWidgetItem *taken = w->takeTopLevelItem(2);
+ const QScopedPointer<QTreeWidgetItem> taken(w->takeTopLevelItem(2));
QCOMPARE(taken->text(0), QLatin1String("C"));
QCOMPARE(selModel->hasSelection(), false);
QCOMPARE(selModel->selectedRows().count(), 0);
QItemSelection sel = selModel->selection();
QCOMPARE(selModel->isSelected(w->model()->index(0,0)), false);
-
- delete w;
}
class AnotherTreeWidget : public QTreeWidget
@@ -2934,11 +2939,11 @@ void tst_QTreeWidget::sortAndSelect()
void tst_QTreeWidget::defaultRowSizes()
{
- QTreeWidget *tw = new QTreeWidget();
+ const QScopedPointer<QTreeWidget> tw(new QTreeWidget);
tw->setIconSize(QSize(50, 50));
tw->setColumnCount(6);
for (int i=0; i<10; ++i) {
- QTreeWidgetItem *it = new QTreeWidgetItem(tw);
+ auto it = new QTreeWidgetItem(tw.data());
for (int j=0; j<tw->columnCount() - 1; ++j) {
it->setText(j, "This is a test");
}
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 cd5aa03689..98b765a6c6 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,19 @@ 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); }
+#else
+ QSKIP("QSizePolicy cannot be constexpr with this version of the compiler.");
+#endif
+}
+
void tst_QSizePolicy::defaultValues()
{
{
@@ -147,6 +163,26 @@ 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)
diff --git a/tests/auto/widgets/kernel/qstackedlayout/tst_qstackedlayout.cpp b/tests/auto/widgets/kernel/qstackedlayout/tst_qstackedlayout.cpp
index 835b6ca799..5be4846b3e 100644
--- a/tests/auto/widgets/kernel/qstackedlayout/tst_qstackedlayout.cpp
+++ b/tests/auto/widgets/kernel/qstackedlayout/tst_qstackedlayout.cpp
@@ -377,7 +377,7 @@ void tst_QStackedLayout::replaceWidget()
QCOMPARE(stackLayout->indexOf(replaceFrom), 1);
QCOMPARE(stackLayout->indexOf(replaceTo), -1);
- stackLayout->replaceWidget(replaceFrom, replaceTo);
+ delete stackLayout->replaceWidget(replaceFrom, replaceTo);
QCOMPARE(stackLayout->indexOf(replaceFrom), -1);
QCOMPARE(stackLayout->indexOf(replaceTo), 1);
diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
index 434876eb3c..4d57b85f9a 100644
--- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
+++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
@@ -93,6 +93,7 @@ private slots:
#if !defined(Q_OS_DARWIN)
void accel();
void activatedCount();
+ void activatedCount_data();
void check_accelKeys();
void check_cursorKeys1();
@@ -136,6 +137,7 @@ private slots:
void QTBUG_57404_existingMenuItemException();
#endif
void taskQTBUG55966_subMenuRemoved();
+ void QTBUG_58344_invalidIcon();
void platformMenu();
@@ -145,8 +147,8 @@ protected slots:
void slotForTaskQTBUG53205();
private:
- TestMenu initSimpleMenuBar(QMenuBar *mb);
- TestMenu initWindowWithSimpleMenuBar(QMainWindow &w);
+ TestMenu initSimpleMenuBar(QMenuBar *mb, bool forceNonNative = true);
+ TestMenu initWindowWithSimpleMenuBar(QMainWindow &w, bool forceNonNative = true);
QAction *createCharacterAction(QMenu *menu, char lowerAscii);
QMenu *addNumberedMenu(QMenuBar *mb, int n);
TestMenu initComplexMenuBar(QMenuBar *mb);
@@ -214,10 +216,10 @@ void tst_QMenuBar::cleanup()
// Create a simple menu bar and connect its actions to onSimpleActivated().
-TestMenu tst_QMenuBar::initSimpleMenuBar(QMenuBar *mb)
-{
+TestMenu tst_QMenuBar::initSimpleMenuBar(QMenuBar *mb, bool forceNonNative) {
TestMenu result;
- mb->setNativeMenuBar(false);
+ if (forceNonNative)
+ mb->setNativeMenuBar(false);
connect(mb, SIGNAL(triggered(QAction*)), this, SLOT(onSimpleActivated(QAction*)));
QMenu *menu = mb->addMenu(QStringLiteral("&accel"));
QAction *action = menu->addAction(QStringLiteral("menu1") );
@@ -245,11 +247,11 @@ TestMenu tst_QMenuBar::initSimpleMenuBar(QMenuBar *mb)
return result;
}
-inline TestMenu tst_QMenuBar::initWindowWithSimpleMenuBar(QMainWindow &w)
+inline TestMenu tst_QMenuBar::initWindowWithSimpleMenuBar(QMainWindow &w, bool forceNonNative)
{
w.resize(200, 200);
centerOnScreen(&w);
- return initSimpleMenuBar(w.menuBar());
+ return initSimpleMenuBar(w.menuBar(), forceNonNative);
}
// add a menu with number n, set number as data.
@@ -347,7 +349,8 @@ void tst_QMenuBar::activatedCount()
{
// create a popup menu with menu items set the accelerators later...
QMainWindow w;
- initWindowWithSimpleMenuBar(w);
+ QFETCH( bool, forceNonNative );
+ initWindowWithSimpleMenuBar(w, forceNonNative);
w.show();
QApplication::setActiveWindow(&w);
QVERIFY(QTest::qWaitForWindowActive(&w));
@@ -356,6 +359,13 @@ void tst_QMenuBar::activatedCount()
//wait(5000);
QCOMPARE( m_simpleActivatedCount, 2 ); //1 from the popupmenu and 1 from the menubar
}
+
+void tst_QMenuBar::activatedCount_data()
+{
+ QTest::addColumn<bool>("forceNonNative");
+ QTest::newRow( "forcing non-native menubar" ) << true;
+ QTest::newRow( "not forcing non-native menubar" ) << false;
+}
#endif
void tst_QMenuBar::clear()
@@ -1626,5 +1636,14 @@ void tst_QMenuBar::taskQTBUG55966_subMenuRemoved()
QTest::qWait(500);
}
+void tst_QMenuBar::QTBUG_58344_invalidIcon()
+{
+ QMenuBar menuBar;
+ QMenu menu("menu");
+ menu.addAction(QIcon("crash.png"), "crash");
+ menuBar.addMenu(&menu);
+ // No crash, all fine.
+}
+
QTEST_MAIN(tst_QMenuBar)
#include "tst_qmenubar.moc"
diff --git a/tests/benchmarks/corelib/tools/qdatetime/main.cpp b/tests/benchmarks/corelib/tools/qdatetime/main.cpp
index 8f43a412b7..2c1e3d97ae 100644
--- a/tests/benchmarks/corelib/tools/qdatetime/main.cpp
+++ b/tests/benchmarks/corelib/tools/qdatetime/main.cpp
@@ -547,8 +547,9 @@ void tst_QDateTime::currentMSecsSinceEpoch()
void tst_QDateTime::fromString()
{
- QString format = "yyy-MM-dd hh:mm:ss.zzz t";
- QString input = "2010-01-01 13:12:11.999 UTC";
+ QString format = "yyyy-MM-dd hh:mm:ss.zzz";
+ QString input = "2010-01-01 13:12:11.999";
+ QVERIFY(QDateTime::fromString(input, format).isValid());
QBENCHMARK {
for (int i = 0; i < 1000; ++i)
QDateTime::fromString(input, format);