summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/global/qhooks/tst_qhooks.cpp70
-rw-r--r--tests/auto/corelib/io/qdir/tst_qdir.cpp23
-rw-r--r--tests/auto/corelib/io/qfile/tst_qfile.cpp8
-rw-r--r--tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp15
-rw-r--r--tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp14
-rw-r--r--tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp20
-rw-r--r--tests/auto/corelib/io/qurl/tst_qurl.cpp50
-rw-r--r--tests/auto/corelib/kernel/qobject/tst_qobject.cpp40
-rw-r--r--tests/auto/corelib/thread/qmutex/tst_qmutex.cpp114
-rw-r--r--tests/auto/corelib/thread/qthread/tst_qthread.cpp4
-rw-r--r--tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp4
-rw-r--r--tests/auto/corelib/tools/qchar/tst_qchar.cpp5
-rw-r--r--tests/auto/corelib/tools/qstring/tst_qstring.cpp17
-rw-r--r--tests/auto/gui/painting/qpainter/tst_qpainter.cpp36
-rw-r--r--tests/auto/gui/text/qfont/tst_qfont.cpp1
-rw-r--r--tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp4
-rw-r--r--tests/auto/gui/text/qinputcontrol/qinputcontrol.pro7
-rw-r--r--tests/auto/gui/text/qinputcontrol/tst_qinputcontrol.cpp100
-rw-r--r--tests/auto/gui/text/qstatictext/tst_qstatictext.cpp2
-rw-r--r--tests/auto/gui/text/text.pro3
-rw-r--r--tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp2
-rw-r--r--tests/auto/network/socket/qsctpsocket/tst_qsctpsocket.cpp16
-rw-r--r--tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp7
-rw-r--r--tests/auto/network/socket/qtcpsocket/stressTest/Test.cpp3
-rw-r--r--tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp7
-rw-r--r--tests/auto/other/lancelot/scripts/pixmap_rotation.qps5
-rw-r--r--tests/auto/other/lancelot/scripts/pixmap_rotation2.qps8
-rw-r--r--tests/auto/other/qaccessibility/tst_qaccessibility.cpp5
-rw-r--r--tests/auto/other/qprocess_and_guieventloop/write-read-write/main.cpp4
-rw-r--r--tests/auto/sql/kernel/qsql/tst_qsql.cpp1
-rw-r--r--tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp44
-rw-r--r--tests/auto/testlib/selftests/tst_selftests.cpp4
-rw-r--r--tests/auto/tools/rcc/data/images/images.expected10
-rw-r--r--tests/auto/tools/rcc/tst_rcc.cpp17
-rw-r--r--tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp6
-rw-r--r--tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp10
-rw-r--r--tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp2
-rw-r--r--tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp2
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp4
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp214
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsitemanimation/tst_qgraphicsitemanimation.cpp6
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp6
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicslayoutitem/tst_qgraphicslayoutitem.cpp2
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp2
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp4
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp24
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp8
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp34
-rw-r--r--tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp2
-rw-r--r--tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp6
-rw-r--r--tests/auto/widgets/itemviews/qdatawidgetmapper/tst_qdatawidgetmapper.cpp10
-rw-r--r--tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp20
-rw-r--r--tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp12
-rw-r--r--tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp14
-rw-r--r--tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp18
-rw-r--r--tests/auto/widgets/itemviews/qtreewidgetitemiterator/tst_qtreewidgetitemiterator.cpp4
-rw-r--r--tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp42
-rw-r--r--tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp2
-rw-r--r--tests/auto/widgets/kernel/qstackedlayout/tst_qstackedlayout.cpp6
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp56
-rw-r--r--tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp2
-rw-r--r--tests/auto/widgets/styles/qstyleoption/tst_qstyleoption.cpp2
-rw-r--r--tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp14
-rw-r--r--tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp6
-rw-r--r--tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp2
-rw-r--r--tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp4
-rw-r--r--tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp4
-rw-r--r--tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp18
-rw-r--r--tests/manual/qstorageinfo/printvolumes.cpp2
-rw-r--r--tests/manual/windowflags/controllerwindow.cpp237
-rw-r--r--tests/manual/windowflags/controllerwindow.h39
-rw-r--r--tests/manual/windowflags/main.cpp8
-rw-r--r--tests/manual/windowflags/previewwindow.cpp271
-rw-r--r--tests/manual/windowflags/previewwindow.h31
74 files changed, 1308 insertions, 518 deletions
diff --git a/tests/auto/corelib/global/qhooks/tst_qhooks.cpp b/tests/auto/corelib/global/qhooks/tst_qhooks.cpp
index f0685d64c5..5fa7566e86 100644
--- a/tests/auto/corelib/global/qhooks/tst_qhooks.cpp
+++ b/tests/auto/corelib/global/qhooks/tst_qhooks.cpp
@@ -35,10 +35,18 @@ class tst_QHooks: public QObject
Q_OBJECT
private slots:
+ void cleanup();
void testVersion();
void testAddRemoveObject();
+ void testChaining();
};
+void tst_QHooks::cleanup()
+{
+ qtHookData[QHooks::AddQObject] = 0;
+ qtHookData[QHooks::RemoveQObject] = 0;
+}
+
void tst_QHooks::testVersion()
{
QVERIFY(qtHookData[QHooks::HookDataVersion] >= 3);
@@ -73,5 +81,67 @@ void tst_QHooks::testAddRemoveObject()
QCOMPARE(objectCount, 0);
}
+static QVector<QString> hookOrder;
+
+static QHooks::AddQObjectCallback existingAddHook = 0;
+static QHooks::RemoveQObjectCallback existingRemoveHook = 0;
+
+static void firstAddHook(QObject *)
+{
+ hookOrder.append(QLatin1String("firstAddHook"));
+}
+
+static void firstRemoveHook(QObject *)
+{
+ hookOrder.append(QLatin1String("firstRemoveHook"));
+}
+
+static void secondAddHook(QObject *object)
+{
+ if (existingAddHook)
+ existingAddHook(object);
+
+ hookOrder.append(QLatin1String("secondAddHook"));
+}
+
+static void secondRemoveHook(QObject *object)
+{
+ if (existingRemoveHook)
+ existingRemoveHook(object);
+
+ hookOrder.append(QLatin1String("secondRemoveHook"));
+}
+
+// Tests that it's possible to "chain" hooks together (i.e. have multiple hooks)
+void tst_QHooks::testChaining()
+{
+ QCOMPARE(qtHookData[QHooks::AddQObject], (quintptr)0);
+ QCOMPARE(qtHookData[QHooks::RemoveQObject], (quintptr)0);
+
+ // Set the add and remove hooks (could just skip this and go straight to the next step,
+ // but it's for illustrative purposes).
+ qtHookData[QHooks::AddQObject] = (quintptr)&firstAddHook;
+ qtHookData[QHooks::RemoveQObject] = (quintptr)&firstRemoveHook;
+
+ // Store them so that we can call them later.
+ existingAddHook = reinterpret_cast<QHooks::AddQObjectCallback>(qtHookData[QHooks::AddQObject]);
+ existingRemoveHook = reinterpret_cast<QHooks::RemoveQObjectCallback>(qtHookData[QHooks::RemoveQObject]);
+
+ // Overide them with hooks that call them first.
+ qtHookData[QHooks::AddQObject] = (quintptr)&secondAddHook;
+ qtHookData[QHooks::RemoveQObject] = (quintptr)&secondRemoveHook;
+
+ QObject *obj = new QObject;
+ QCOMPARE(hookOrder.size(), 2);
+ QCOMPARE(hookOrder.at(0), QLatin1String("firstAddHook"));
+ QCOMPARE(hookOrder.at(1), QLatin1String("secondAddHook"));
+ delete obj;
+ QCOMPARE(hookOrder.size(), 4);
+ QCOMPARE(hookOrder.at(2), QLatin1String("firstRemoveHook"));
+ QCOMPARE(hookOrder.at(3), QLatin1String("secondRemoveHook"));
+
+ hookOrder.clear();
+}
+
QTEST_APPLESS_MAIN(tst_QHooks)
#include "tst_qhooks.moc"
diff --git a/tests/auto/corelib/io/qdir/tst_qdir.cpp b/tests/auto/corelib/io/qdir/tst_qdir.cpp
index 294a53645e..b86c6e4dfa 100644
--- a/tests/auto/corelib/io/qdir/tst_qdir.cpp
+++ b/tests/auto/corelib/io/qdir/tst_qdir.cpp
@@ -58,7 +58,8 @@
#ifdef QT_BUILD_INTERNAL
QT_BEGIN_NAMESPACE
-extern Q_AUTOTEST_EXPORT QString qt_normalizePathSegments(const QString &, bool);
+extern Q_AUTOTEST_EXPORT QString
+ qt_normalizePathSegments(const QString &path, bool allowUncPaths, bool *ok = nullptr);
QT_END_NAMESPACE
#endif
@@ -1149,6 +1150,8 @@ tst_QDir::cleanPath_data()
QTest::newRow("data0") << "/Users/sam/troll/qt4.0//.." << "/Users/sam/troll";
QTest::newRow("data1") << "/Users/sam////troll/qt4.0//.." << "/Users/sam/troll";
QTest::newRow("data2") << "/" << "/";
+ QTest::newRow("data2-up") << "/path/.." << "/";
+ QTest::newRow("data2-above-root") << "/.." << "/..";
QTest::newRow("data3") << QDir::cleanPath("../.") << "..";
QTest::newRow("data4") << QDir::cleanPath("../..") << "../..";
#if defined(Q_OS_WIN)
@@ -1178,13 +1181,19 @@ tst_QDir::cleanPath_data()
QTest::newRow("data14") << "c://foo" << "c:/foo";
// Drive letters and unc path in one string
-#ifndef Q_OS_WINRT
-#ifdef Q_OS_WIN
+#if defined(Q_OS_WINRT)
+ const QString root = QDir::rootPath(); // has trailing slash
+ QTest::newRow("root-up") << (root + "path/..") << root;
+ QTest::newRow("above-root") << (root + "..") << (root + "..");
+#elif defined(Q_OS_WIN)
QTest::newRow("data15") << "//c:/foo" << "//c:/foo";
+ QTest::newRow("drive-up") << "A:/path/.." << "A:/";
+ QTest::newRow("drive-above-root") << "A:/.." << "A:/..";
+ QTest::newRow("unc-server-up") << "//server/path/.." << "//server";
+ QTest::newRow("unc-server-above-root") << "//server/.." << "//server/..";
#else
QTest::newRow("data15") << "//c:/foo" << "/c:/foo";
-#endif
-#endif // !Q_OS_WINRT
+#endif // non-windows
QTest::newRow("QTBUG-23892_0") << "foo/.." << ".";
QTest::newRow("QTBUG-23892_1") << "foo/../" << ".";
@@ -2238,6 +2247,10 @@ void tst_QDir::cdBelowRoot_data()
const QString systemRoot = QString::fromLocal8Bit(qgetenv("SystemRoot"));
QTest::newRow("windows-drive")
<< systemDrive << systemRoot.mid(3) << QDir::cleanPath(systemRoot);
+ const QString uncRoot = QStringLiteral("//") + QtNetworkSettings::winServerName();
+ const QString testDirectory = QStringLiteral("testshare");
+ QTest::newRow("windows-share")
+ << uncRoot << testDirectory << QDir::cleanPath(uncRoot + QLatin1Char('/') + testDirectory);
#endif // Windows
}
diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp
index eeba882c70..2ef4c2c6a1 100644
--- a/tests/auto/corelib/io/qfile/tst_qfile.cpp
+++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp
@@ -2618,9 +2618,10 @@ void tst_QFile::appendAndRead()
// Write blocks and read them back
for (int j = 0; j < 18; ++j) {
- writeFile.write(QByteArray(1 << j, '@'));
+ const int size = 1 << j;
+ writeFile.write(QByteArray(size, '@'));
writeFile.flush();
- QCOMPARE(readFile.read(1 << j).size(), 1 << j);
+ QCOMPARE(readFile.read(size).size(), size);
}
readFile.close();
@@ -2658,7 +2659,8 @@ void tst_QFile::handle()
QVERIFY(fd > 2);
QCOMPARE(int(file.handle()), fd);
char c = '\0';
- QT_READ(int(file.handle()), &c, 1);
+ const auto readResult = QT_READ(int(file.handle()), &c, 1);
+ QCOMPARE(readResult, static_cast<decltype(readResult)>(1));
QCOMPARE(c, '/');
// test if the QFile and the handle remain in sync
diff --git a/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp b/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp
index 561ab193c6..7fdd00876f 100644
--- a/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp
+++ b/tests/auto/corelib/io/qresourceengine/tst_qresourceengine.cpp
@@ -55,6 +55,7 @@ private slots:
void searchPath();
void doubleSlashInRoot();
void setLocale();
+ void lastModified();
private:
const QString m_runtimeResourceRcc;
@@ -489,6 +490,20 @@ void tst_QResourceEngine::setLocale()
QLocale::setDefault(QLocale::system());
}
+void tst_QResourceEngine::lastModified()
+{
+ {
+ QFileInfo fi(":/");
+ QVERIFY(fi.exists());
+ QVERIFY2(!fi.lastModified().isValid(), qPrintable(fi.lastModified().toString()));
+ }
+ {
+ QFileInfo fi(":/search_file.txt");
+ QVERIFY(fi.exists());
+ QVERIFY(fi.lastModified().isValid());
+ }
+}
+
QTEST_MAIN(tst_QResourceEngine)
#include "tst_qresourceengine.moc"
diff --git a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
index 0b536f26de..0a00e00d83 100644
--- a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
+++ b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
@@ -33,6 +33,9 @@
#include <qfileinfo.h>
#include <qsysinfo.h>
#include <qregexp.h>
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) && !defined(Q_OS_WINCE)
+# include <qt_windows.h>
+#endif
#ifdef Q_OS_UNIX
#include <unistd.h>
@@ -126,6 +129,16 @@ static const char * const enumNames[MaxStandardLocation + 1 - int(QStandardPaths
void tst_qstandardpaths::initTestCase()
{
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) && !defined(Q_OS_WINCE)
+ // Disable WOW64 redirection, see testFindExecutable()
+ if (QSysInfo::buildCpuArchitecture() != QSysInfo::currentCpuArchitecture()) {
+ void *oldMode;
+ const bool disabledDisableWow64FsRedirection = Wow64DisableWow64FsRedirection(&oldMode) == TRUE;
+ if (!disabledDisableWow64FsRedirection)
+ qErrnoWarning("Wow64DisableWow64FsRedirection() failed");
+ QVERIFY(disabledDisableWow64FsRedirection);
+ }
+#endif // Q_OS_WIN && !Q_OS_WINRT && !Q_OS_WINCE
QVERIFY2(m_localConfigTempDir.isValid(), qPrintable(m_localConfigTempDir.errorString()));
QVERIFY2(m_globalConfigTempDir.isValid(), qPrintable(m_globalConfigTempDir.errorString()));
QVERIFY2(m_localAppTempDir.isValid(), qPrintable(m_localAppTempDir.errorString()));
@@ -375,6 +388,7 @@ void tst_qstandardpaths::testFindExecutable_data()
if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows8) {
// The logo executable on Windows 8 is perfectly suited for testing that the
// suffix mechanism is not thrown off by dots in the name.
+ // Note: Requires disabling WOW64 redirection, see initTestCase()
const QString logo = QLatin1String("microsoft.windows.softwarelogo.showdesktop");
const QString logoPath = cmdFi.absolutePath() + QLatin1Char('/') + logo + QLatin1String(".exe");
QTest::newRow("win8-logo")
diff --git a/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp b/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp
index 9533989b9d..7f29e2a7d7 100644
--- a/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp
+++ b/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp
@@ -2023,13 +2023,13 @@ void tst_QTextStream::generateNaturalNumbersData(bool for_QString)
QTest::newRow("2147483648") << QByteArray("2147483648") << Q_UINT64_C(2147483648);
QTest::newRow("-2147483646") << QByteArray("-2147483646") << qulonglong(-2147483646);
QTest::newRow("-2147483647") << QByteArray("-2147483647") << qulonglong(-2147483647);
- QTest::newRow("-2147483648") << QByteArray("-2147483648") << Q_UINT64_C(-2147483648);
+ QTest::newRow("-2147483648") << QByteArray("-2147483648") << quint64(-2147483648LL);
QTest::newRow("4294967296") << QByteArray("4294967296") << Q_UINT64_C(4294967296);
QTest::newRow("4294967297") << QByteArray("4294967297") << Q_UINT64_C(4294967297);
QTest::newRow("4294967298") << QByteArray("4294967298") << Q_UINT64_C(4294967298);
- QTest::newRow("-4294967296") << QByteArray("-4294967296") << Q_UINT64_C(-4294967296);
- QTest::newRow("-4294967297") << QByteArray("-4294967297") << Q_UINT64_C(-4294967297);
- QTest::newRow("-4294967298") << QByteArray("-4294967298") << Q_UINT64_C(-4294967298);
+ QTest::newRow("-4294967296") << QByteArray("-4294967296") << quint64(-4294967296);
+ QTest::newRow("-4294967297") << QByteArray("-4294967297") << quint64(-4294967297);
+ QTest::newRow("-4294967298") << QByteArray("-4294967298") << quint64(-4294967298);
QTest::newRow("9223372036854775807") << QByteArray("9223372036854775807") << Q_UINT64_C(9223372036854775807);
QTest::newRow("9223372036854775808") << QByteArray("9223372036854775808") << Q_UINT64_C(9223372036854775808);
QTest::newRow("9223372036854775809") << QByteArray("9223372036854775809") << Q_UINT64_C(9223372036854775809);
@@ -2286,7 +2286,7 @@ void tst_QTextStream::signedShort_write_operator_ToDevice_data()
QTest::newRow("0") << Q_UINT64_C(0) << QByteArray("0") << QByteArray("0");
QTest::newRow("1") << Q_UINT64_C(1) << QByteArray("1") << QByteArray("1");
- QTest::newRow("-1") << Q_UINT64_C(-1) << QByteArray("-1") << QByteArray("-1");
+ QTest::newRow("-1") << quint64(-1) << QByteArray("-1") << QByteArray("-1");
QTest::newRow("32767") << Q_UINT64_C(32767) << QByteArray("32767") << QByteArray("32,767");
QTest::newRow("32768") << Q_UINT64_C(32768) << QByteArray("-32768") << QByteArray("-32,768");
QTest::newRow("32769") << Q_UINT64_C(32769) << QByteArray("-32767") << QByteArray("-32,767");
@@ -2306,7 +2306,7 @@ void tst_QTextStream::unsignedShort_write_operator_ToDevice_data()
QTest::newRow("0") << Q_UINT64_C(0) << QByteArray("0") << QByteArray("0");
QTest::newRow("1") << Q_UINT64_C(1) << QByteArray("1") << QByteArray("1");
- QTest::newRow("-1") << Q_UINT64_C(-1) << QByteArray("65535") << QByteArray("65,535");
+ QTest::newRow("-1") << quint64(-1) << QByteArray("65535") << QByteArray("65,535");
QTest::newRow("32767") << Q_UINT64_C(32767) << QByteArray("32767") << QByteArray("32,767");
QTest::newRow("32768") << Q_UINT64_C(32768) << QByteArray("32768") << QByteArray("32,768");
QTest::newRow("32769") << Q_UINT64_C(32769) << QByteArray("32769") << QByteArray("32,769");
@@ -2326,7 +2326,7 @@ void tst_QTextStream::signedInt_write_operator_ToDevice_data()
QTest::newRow("0") << Q_UINT64_C(0) << QByteArray("0") << QByteArray("0");
QTest::newRow("1") << Q_UINT64_C(1) << QByteArray("1") << QByteArray("1");
- QTest::newRow("-1") << Q_UINT64_C(-1) << QByteArray("-1") << QByteArray("-1");
+ QTest::newRow("-1") << quint64(-1) << QByteArray("-1") << QByteArray("-1");
QTest::newRow("32767") << Q_UINT64_C(32767) << QByteArray("32767") << QByteArray("32,767");
QTest::newRow("32768") << Q_UINT64_C(32768) << QByteArray("32768") << QByteArray("32,768");
QTest::newRow("32769") << Q_UINT64_C(32769) << QByteArray("32769") << QByteArray("32,769");
@@ -2352,7 +2352,7 @@ void tst_QTextStream::unsignedInt_write_operator_ToDevice_data()
QTest::newRow("0") << Q_UINT64_C(0) << QByteArray("0") << QByteArray("0");
QTest::newRow("1") << Q_UINT64_C(1) << QByteArray("1") << QByteArray("1");
- QTest::newRow("-1") << Q_UINT64_C(-1) << QByteArray("4294967295") << QByteArray("4,294,967,295");
+ QTest::newRow("-1") << quint64(-1) << QByteArray("4294967295") << QByteArray("4,294,967,295");
QTest::newRow("32767") << Q_UINT64_C(32767) << QByteArray("32767") << QByteArray("32,767");
QTest::newRow("32768") << Q_UINT64_C(32768) << QByteArray("32768") << QByteArray("32,768");
QTest::newRow("32769") << Q_UINT64_C(32769) << QByteArray("32769") << QByteArray("32,769");
@@ -2378,7 +2378,7 @@ void tst_QTextStream::qlonglong_write_operator_ToDevice_data()
QTest::newRow("0") << Q_UINT64_C(0) << QByteArray("0") << QByteArray("0");
QTest::newRow("1") << Q_UINT64_C(1) << QByteArray("1") << QByteArray("1");
- QTest::newRow("-1") << Q_UINT64_C(-1) << QByteArray("-1") << QByteArray("-1");
+ QTest::newRow("-1") << quint64(-1) << QByteArray("-1") << QByteArray("-1");
QTest::newRow("32767") << Q_UINT64_C(32767) << QByteArray("32767") << QByteArray("32,767");
QTest::newRow("32768") << Q_UINT64_C(32768) << QByteArray("32768") << QByteArray("32,768");
QTest::newRow("32769") << Q_UINT64_C(32769) << QByteArray("32769") << QByteArray("32,769");
@@ -2408,7 +2408,7 @@ void tst_QTextStream::qulonglong_write_operator_ToDevice_data()
QTest::newRow("0") << Q_UINT64_C(0) << QByteArray("0") << QByteArray("0");
QTest::newRow("1") << Q_UINT64_C(1) << QByteArray("1") << QByteArray("1");
- QTest::newRow("-1") << Q_UINT64_C(-1) << QByteArray("18446744073709551615") << QByteArray("18,446,744,073,709,551,615");
+ QTest::newRow("-1") << quint64(-1) << QByteArray("18446744073709551615") << QByteArray("18,446,744,073,709,551,615");
QTest::newRow("32767") << Q_UINT64_C(32767) << QByteArray("32767") << QByteArray("32,767");
QTest::newRow("32768") << Q_UINT64_C(32768) << QByteArray("32768") << QByteArray("32,768");
QTest::newRow("32769") << Q_UINT64_C(32769) << QByteArray("32769") << QByteArray("32,769");
diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp
index f589fe1d6d..a4461a12d3 100644
--- a/tests/auto/corelib/io/qurl/tst_qurl.cpp
+++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp
@@ -177,6 +177,8 @@ private slots:
void streaming();
void detach();
void testThreading();
+ void matches_data();
+ void matches();
private:
void testThreadingHelper();
@@ -4020,6 +4022,54 @@ void tst_QUrl::testThreading()
delete s_urlStorage;
}
+void tst_QUrl::matches_data()
+{
+ QTest::addColumn<QString>("urlStrOne");
+ QTest::addColumn<QString>("urlStrTwo");
+ QTest::addColumn<uint>("options");
+ QTest::addColumn<bool>("matches");
+
+ QTest::newRow("matchingString-none") << "http://www.website.com/directory/?#ref"
+ << "http://www.website.com/directory/?#ref"
+ << uint(QUrl::None) << true;
+ QTest::newRow("nonMatchingString-none") << "http://www.website.com/directory/?#ref"
+ << "http://www.nomatch.com/directory/?#ref"
+ << uint(QUrl::None) << false;
+ QTest::newRow("matchingHost-removePath") << "http://www.website.com/directory"
+ << "http://www.website.com/differentdir"
+ << uint(QUrl::RemovePath) << true;
+ QTest::newRow("nonMatchingHost-removePath") << "http://www.website.com/directory"
+ << "http://www.different.com/differentdir"
+ << uint(QUrl::RemovePath) << false;
+ QTest::newRow("matchingHost-removePathAuthority") << "http://user:pass@www.website.com/directory"
+ << "http://www.website.com/differentdir"
+ << uint(QUrl::RemovePath | QUrl::RemoveAuthority)
+ << true;
+ QTest::newRow("nonMatchingHost-removePathAuthority") << "http://user:pass@www.website.com/directory"
+ << "http://user:pass@www.different.com/differentdir"
+ << uint(QUrl::RemovePath | QUrl::RemoveAuthority)
+ << true;
+ QTest::newRow("matchingHostAuthority-removePathAuthority")
+ << "http://user:pass@www.website.com/directory" << "http://www.website.com/differentdir"
+ << uint(QUrl::RemovePath | QUrl::RemoveAuthority) << true;
+ QTest::newRow("nonMatchingAuthority-removePathAuthority")
+ << "http://user:pass@www.website.com/directory"
+ << "http://otheruser:otherpass@www.website.com/directory"
+ << uint(QUrl::RemovePath | QUrl::RemoveAuthority) << true;
+}
+
+void tst_QUrl::matches()
+{
+ QFETCH(QString, urlStrOne);
+ QFETCH(QString, urlStrTwo);
+ QFETCH(uint, options);
+ QFETCH(bool, matches);
+
+ QUrl urlOne(urlStrOne);
+ QUrl urlTwo(urlStrTwo);
+ QCOMPARE(urlOne.matches(urlTwo, QUrl::FormattingOptions(options)), matches);
+}
+
QTEST_MAIN(tst_QUrl)
#include "tst_qurl.moc"
diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
index fea185c48f..5eea858107 100644
--- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
@@ -6967,10 +6967,10 @@ void tst_QObject::checkArgumentsForNarrowing()
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<signed char, unsigned long long>::value));
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned char, signed char>::value));
- QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned char, short>::value));
- QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned char, int>::value));
- QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned char, long>::value));
- QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned char, long long>::value));
+ QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<unsigned char, short>::value));
+ QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<unsigned char, int>::value));
+ QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<unsigned char, long>::value));
+ QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<unsigned char, long long>::value));
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<short, unsigned short>::value));
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<short, unsigned int>::value));
@@ -6978,23 +6978,23 @@ void tst_QObject::checkArgumentsForNarrowing()
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<short, unsigned long long>::value));
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned short, short>::value));
- QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned short, int>::value));
- QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned short, long>::value));
- QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned short, long long>::value));
+ QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<unsigned short, int>::value));
+ QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<unsigned short, long>::value));
+ QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<unsigned short, long long>::value));
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<int, unsigned int>::value));
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<int, unsigned long>::value));
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<int, unsigned long long>::value));
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned int, int>::value));
- QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned int, long>::value));
- QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned int, long long>::value));
+ QCOMPARE((QtPrivate::AreArgumentsNarrowedBase<unsigned int, long>::value), sizeof(int) >= sizeof(long));
+ QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<unsigned int, long long>::value));
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<long, unsigned long>::value));
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<long, unsigned long long>::value));
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned long, long>::value));
- QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned long, long long>::value));
+ QCOMPARE((QtPrivate::AreArgumentsNarrowedBase<unsigned long, long long>::value), sizeof(long) >= sizeof(long long));
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<long long, unsigned long long>::value));
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<unsigned long long, long long>::value));
@@ -7204,28 +7204,28 @@ void tst_QObject::checkArgumentsForNarrowing()
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByLongLong, unsigned long long>::value));
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUChar, signed char>::value));
- QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUChar, short>::value));
- QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUChar, int>::value));
- QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUChar, long>::value));
- QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUChar, long long>::value));
+ QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUChar, short>::value));
+ QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUChar, int>::value));
+ QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUChar, long>::value));
+ QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUChar, long long>::value));
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUShort, signed char>::value));
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUShort, short>::value));
- QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUShort, int>::value));
- QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUShort, long>::value));
- QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUShort, long long>::value));
+ QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUShort, int>::value));
+ QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUShort, long>::value));
+ QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUShort, long long>::value));
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUInt, signed char>::value));
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUInt, short>::value));
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUInt, int>::value));
- QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUInt, long>::value));
- QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUInt, long long>::value));
+ QCOMPARE((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUInt, long>::value), sizeof(ScopedEnumBackedByUInt) >= sizeof(long));
+ QVERIFY((!QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByUInt, long long>::value));
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByULong, signed char>::value));
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByULong, short>::value));
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByULong, int>::value));
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByULong, long>::value));
- QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByULong, long long>::value));
+ QCOMPARE((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByULong, long long>::value), sizeof(ScopedEnumBackedByULong) >= sizeof(long long));
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByULongLong, signed char>::value));
QVERIFY((QtPrivate::AreArgumentsNarrowedBase<ScopedEnumBackedByULongLong, short>::value));
diff --git a/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp b/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp
index b24ecfcd43..bf778e9fd1 100644
--- a/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp
+++ b/tests/auto/corelib/thread/qmutex/tst_qmutex.cpp
@@ -44,8 +44,19 @@
class tst_QMutex : public QObject
{
Q_OBJECT
+public:
+ enum class TimeUnit {
+ Nanoseconds,
+ Microseconds,
+ Milliseconds,
+ Seconds,
+ };
+ Q_ENUM(TimeUnit);
+
private slots:
void initTestCase();
+ void convertToMilliseconds_data();
+ void convertToMilliseconds();
void tryLock_non_recursive();
void try_lock_for_non_recursive();
void try_lock_until_non_recursive();
@@ -122,6 +133,109 @@ void tst_QMutex::initTestCase()
initializeSystemTimersResolution();
}
+void tst_QMutex::convertToMilliseconds_data()
+{
+ QTest::addColumn<TimeUnit>("unit");
+ QTest::addColumn<double>("doubleValue");
+ QTest::addColumn<qint64>("intValue");
+ QTest::addColumn<qint64>("expected");
+
+
+ auto add = [](TimeUnit unit, double d, long long i, qint64 expected) {
+ const QScopedArrayPointer<char> enumName(QTest::toString(unit));
+ QTest::newRow(qPrintable(QString::asprintf("%s:%f:%lld", enumName.data(), d, i)))
+ << unit << d << qint64(i) << expected;
+ };
+
+ auto forAllUnitsAdd = [=](double d, long long i, qint64 expected) {
+ for (auto unit : {TimeUnit::Nanoseconds, TimeUnit::Microseconds, TimeUnit::Milliseconds, TimeUnit::Seconds})
+ add(unit, d, i, expected);
+ };
+
+ forAllUnitsAdd(-0.5, -1, 0); // all negative values result in 0
+
+ forAllUnitsAdd(0, 0, 0);
+
+ add(TimeUnit::Nanoseconds, 1, 1, 1);
+ add(TimeUnit::Nanoseconds, 1000 * 1000, 1000 * 1000, 1);
+ add(TimeUnit::Nanoseconds, 1000 * 1000 + 0.5, 1000 * 1000 + 1, 2);
+
+ add(TimeUnit::Microseconds, 1, 1, 1);
+ add(TimeUnit::Microseconds, 1000, 1000, 1);
+ add(TimeUnit::Microseconds, 1000 + 0.5, 1000 + 1, 2);
+
+ add(TimeUnit::Milliseconds, 1, 1, 1);
+ add(TimeUnit::Milliseconds, 1.5, 2, 2);
+
+ add(TimeUnit::Seconds, 0.9991, 1, 1000);
+
+ //
+ // overflowing int results in INT_MAX (equivalent to a spurious wakeup after ~24 days); check it:
+ //
+
+ // spot on:
+ add(TimeUnit::Nanoseconds, INT_MAX * 1000. * 1000, INT_MAX * Q_INT64_C(1000) * 1000, INT_MAX);
+ add(TimeUnit::Microseconds, INT_MAX * 1000., INT_MAX * Q_INT64_C(1000), INT_MAX);
+ add(TimeUnit::Milliseconds, INT_MAX, INT_MAX, INT_MAX);
+
+ // minimally above:
+ add(TimeUnit::Nanoseconds, INT_MAX * 1000. * 1000 + 1, INT_MAX * Q_INT64_C(1000) * 1000 + 1, INT_MAX);
+ add(TimeUnit::Microseconds, INT_MAX * 1000. + 1, INT_MAX * Q_INT64_C(1000) + 1, INT_MAX);
+ add(TimeUnit::Milliseconds, INT_MAX + 1., INT_MAX + Q_INT64_C(1), INT_MAX);
+ add(TimeUnit::Seconds, INT_MAX / 1000. + 1, INT_MAX / 1000 + 1, INT_MAX);
+
+ // minimally below:
+ add(TimeUnit::Nanoseconds, INT_MAX * 1000. * 1000 - 1, INT_MAX * Q_INT64_C(1000) * 1000 - 1, INT_MAX);
+ add(TimeUnit::Microseconds, INT_MAX * 1000. - 1, INT_MAX * Q_INT64_C(1000) - 1, INT_MAX);
+ add(TimeUnit::Milliseconds, INT_MAX - 0.1, INT_MAX , INT_MAX);
+
+}
+
+void tst_QMutex::convertToMilliseconds()
+{
+#if !QT_HAS_INCLUDE(<chrono>)
+ QSKIP("This test requires <chrono>");
+#else
+ QFETCH(TimeUnit, unit);
+ QFETCH(double, doubleValue);
+ QFETCH(qint64, intValue);
+ QFETCH(qint64, expected);
+
+ Q_CONSTEXPR qint64 maxShort = std::numeric_limits<short>::max();
+ Q_CONSTEXPR qint64 maxInt = std::numeric_limits<int>::max();
+ Q_CONSTEXPR qint64 maxUInt = std::numeric_limits<uint>::max();
+
+ switch (unit) {
+#define CASE(Unit, Period) \
+ case TimeUnit::Unit: \
+ DO(double, Period, doubleValue); \
+ if (intValue < maxShort) \
+ DO(short, Period, short(intValue)); \
+ if (intValue < maxInt) \
+ DO(int, Period, int(intValue)); \
+ DO(qint64, Period, intValue); \
+ if (intValue >= 0) { \
+ if (intValue < maxUInt) \
+ DO(uint, Period, uint(intValue)); \
+ DO(quint64, Period, quint64(intValue)); \
+ } \
+ break
+#define DO(Rep, Period, val) \
+ do { \
+ const std::chrono::duration<Rep, Period> wait((val)); \
+ QCOMPARE(QMutex::convertToMilliseconds(wait), expected); \
+ } while (0)
+
+ CASE(Nanoseconds, std::nano);
+ CASE(Microseconds, std::micro);
+ CASE(Milliseconds, std::milli);
+ CASE(Seconds, std::ratio<1>);
+#undef DO
+#undef CASE
+ }
+#endif
+}
+
void tst_QMutex::tryLock_non_recursive()
{
class Thread : public QThread
diff --git a/tests/auto/corelib/thread/qthread/tst_qthread.cpp b/tests/auto/corelib/thread/qthread/tst_qthread.cpp
index 06b27f79cd..0efbc5d01e 100644
--- a/tests/auto/corelib/thread/qthread/tst_qthread.cpp
+++ b/tests/auto/corelib/thread/qthread/tst_qthread.cpp
@@ -1059,8 +1059,8 @@ void tst_QThread::wait2()
thread.start();
timer.start();
QVERIFY(!thread.wait(Waiting_Thread::WaitTime));
- qint64 elapsed = timer.elapsed(); // On Windows, we sometimes get (WaitTime - 1).
- QVERIFY2(elapsed >= Waiting_Thread::WaitTime - 1, qPrintable(QString::fromLatin1("elapsed: %1").arg(elapsed)));
+ qint64 elapsed = timer.elapsed(); // On Windows, we sometimes get (WaitTime - 9).
+ QVERIFY2(elapsed >= Waiting_Thread::WaitTime - 10, qPrintable(QString::fromLatin1("elapsed: %1").arg(elapsed)));
timer.start();
thread.cond1.wakeOne();
diff --git a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp
index 65887e50d3..ba2adddca0 100644
--- a/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp
+++ b/tests/auto/corelib/tools/qarraydata/tst_qarraydata.cpp
@@ -801,8 +801,8 @@ void tst_QArrayData::alignment_data()
{
QTest::addColumn<size_t>("alignment");
- for (int i = 1; i < 10; ++i) {
- size_t alignment = 1u << i;
+ for (size_t i = 1; i < 10; ++i) {
+ size_t alignment = size_t(1u) << i;
QTest::newRow(qPrintable(QString::number(alignment))) << alignment;
}
}
diff --git a/tests/auto/corelib/tools/qchar/tst_qchar.cpp b/tests/auto/corelib/tools/qchar/tst_qchar.cpp
index 92585fd471..fb436b67d6 100644
--- a/tests/auto/corelib/tools/qchar/tst_qchar.cpp
+++ b/tests/auto/corelib/tools/qchar/tst_qchar.cpp
@@ -72,6 +72,9 @@ private slots:
void unicodeVersion();
};
+QT_WARNING_PUSH
+QT_WARNING_DISABLE_DEPRECATED
+
void tst_QChar::operator_eqeq_int()
{
{
@@ -96,6 +99,8 @@ void tst_QChar::operator_eqeq_int()
}
}
+QT_WARNING_POP
+
void tst_QChar::operators_data()
{
QTest::addColumn<QChar>("lhs");
diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
index a0a872710c..414ba2d8cf 100644
--- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp
+++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
@@ -1255,6 +1255,11 @@ void tst_QString::fill()
QCOMPARE(f, QLatin1String("FFF"));
}
+static inline const void *ptrValue(quintptr v)
+{
+ return reinterpret_cast<const void *>(v);
+}
+
void tst_QString::sprintf()
{
QString a;
@@ -1266,21 +1271,21 @@ void tst_QString::sprintf()
QCOMPARE(a.sprintf("X%9iY", 50000 ), QLatin1String("X 50000Y"));
QCOMPARE(a.sprintf("X%-9sY","hello"), QLatin1String("Xhello Y"));
QCOMPARE(a.sprintf("X%-9iY", 50000 ), QLatin1String("X50000 Y"));
- QCOMPARE(a.sprintf("%lf", 1.23), QString("1.230000"));
- QCOMPARE(a.sprintf("%lf", 1.23456789), QString("1.234568"));
- QCOMPARE(a.sprintf("%p", (void *)0xbfffd350), QString("0xbfffd350"));
- QCOMPARE(a.sprintf("%p", (void *)0), QString("0x0"));
+ QCOMPARE(a.sprintf("%lf", 1.23), QLatin1String("1.230000"));
+ QCOMPARE(a.sprintf("%lf", 1.23456789), QLatin1String("1.234568"));
+ QCOMPARE(a.sprintf("%p", ptrValue(0xbfffd350)), QLatin1String("0xbfffd350"));
+ QCOMPARE(a.sprintf("%p", ptrValue(0)), QLatin1String("0x0"));
int i = 6;
long l = -2;
float f = 4.023f;
QString S1;
S1.sprintf("%d %ld %f",i,l,f);
- QCOMPARE(S1,QString("6 -2 4.023000"));
+ QCOMPARE(S1, QLatin1String("6 -2 4.023000"));
double d = -514.25683;
S1.sprintf("%f",d);
- QCOMPARE(S1, QString("-514.256830"));
+ QCOMPARE(S1, QLatin1String("-514.256830"));
}
void tst_QString::sprintfS()
diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
index a9ac18144e..3562bc63f4 100644
--- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
+++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
@@ -300,6 +300,9 @@ private slots:
void QTBUG56252();
+ void blendNullRGB32();
+ void toRGB64();
+
private:
void fillData();
void setPenColor(QPainter& p);
@@ -5151,6 +5154,39 @@ void tst_QPainter::QTBUG56252()
// If no crash or illegal memory read, all is fine
}
+void tst_QPainter::blendNullRGB32()
+{
+ quint32 data[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+
+ QImage nullImage((const uchar*)data, 16, 1, QImage::Format_RGB32);
+ QImage image(16, 1, QImage::Format_RGB32);
+ image.fill(Qt::white);
+
+ QPainter paint(&image);
+ paint.setCompositionMode(QPainter::CompositionMode_Source);
+ paint.setOpacity(0.5);
+ paint.drawImage(0, 0, nullImage);
+ paint.end();
+
+ for (int i=0; i < image.width(); ++i)
+ QVERIFY(image.pixel(i,0) != 0xffffffff);
+}
+
+void tst_QPainter::toRGB64()
+{
+ QImage dst(10, 1, QImage::Format_BGR30);
+ QImage src(10, 1, QImage::Format_RGB16);
+ src.fill(Qt::white);
+
+ QPainter paint(&dst);
+ paint.drawImage(0, 0, src);
+ paint.end();
+
+ for (int i=0; i < dst.width(); ++i) {
+ QVERIFY(dst.pixelColor(i,0) == QColor(Qt::white));
+ }
+}
+
QTEST_MAIN(tst_QPainter)
#include "tst_qpainter.moc"
diff --git a/tests/auto/gui/text/qfont/tst_qfont.cpp b/tests/auto/gui/text/qfont/tst_qfont.cpp
index ca984a26a5..a6d8944656 100644
--- a/tests/auto/gui/text/qfont/tst_qfont.cpp
+++ b/tests/auto/gui/text/qfont/tst_qfont.cpp
@@ -130,7 +130,6 @@ void tst_QFont::italicOblique()
QString family = *f_it;
QStringList styles = fdb.styles(family);
- QVERIFY(!styles.isEmpty());
QStringList::ConstIterator s_it, s_end = styles.end();
for (s_it = styles.begin(); s_it != s_end; ++s_it) {
QString style = *s_it;
diff --git a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
index 8c26f8a91f..e8244a0e5d 100644
--- a/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
+++ b/tests/auto/gui/text/qfontdatabase/tst_qfontdatabase.cpp
@@ -326,6 +326,10 @@ void tst_QFontDatabase::condensedFontMatching()
QFont tfcByStyleName("QtBidiTestFont");
tfcByStyleName.setStyleName("Condensed");
+#ifdef Q_OS_WIN
+ QEXPECT_FAIL("","No matching of sub-family by stretch on Windows", Continue);
+#endif
+
QCOMPARE(QFontMetrics(tfcByStretch).width(testString()),
QFontMetrics(tfcByStyleName).width(testString()));
diff --git a/tests/auto/gui/text/qinputcontrol/qinputcontrol.pro b/tests/auto/gui/text/qinputcontrol/qinputcontrol.pro
new file mode 100644
index 0000000000..811c9aab90
--- /dev/null
+++ b/tests/auto/gui/text/qinputcontrol/qinputcontrol.pro
@@ -0,0 +1,7 @@
+CONFIG += testcase
+TARGET = tst_qinputcontrol
+
+QT = core gui gui-private testlib
+
+SOURCES += \
+ tst_qinputcontrol.cpp
diff --git a/tests/auto/gui/text/qinputcontrol/tst_qinputcontrol.cpp b/tests/auto/gui/text/qinputcontrol/tst_qinputcontrol.cpp
new file mode 100644
index 0000000000..ad5ba6affb
--- /dev/null
+++ b/tests/auto/gui/text/qinputcontrol/tst_qinputcontrol.cpp
@@ -0,0 +1,100 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+
+#include <private/qinputcontrol_p.h>
+#include <QtGui/QKeyEvent>
+
+class tst_QInputControl: public QObject
+{
+ Q_OBJECT
+private slots:
+ void isAcceptableInput_data();
+ void isAcceptableInput();
+ void tabOnlyAcceptableInputForTextEdit();
+};
+
+void tst_QInputControl::isAcceptableInput_data()
+{
+ QTest::addColumn<QString>("text");
+ QTest::addColumn<Qt::KeyboardModifiers>("modifiers");
+ QTest::addColumn<bool>("acceptable");
+
+ QTest::newRow("empty-string") << QString() << Qt::KeyboardModifiers() << false;
+ QTest::newRow("zwnj") << QString(QChar(0x200C)) << Qt::KeyboardModifiers() << true;
+ QTest::newRow("zwnj-with-ctrl") << QString(QChar(0x200C)) << Qt::KeyboardModifiers(Qt::ControlModifier) << true;
+ QTest::newRow("zwnj-with-ctrl-shift") << QString(QChar(0x200C)) << Qt::KeyboardModifiers(Qt::ControlModifier | Qt::ShiftModifier) << true;
+ QTest::newRow("zwj") << QString(QChar(0x200D)) << Qt::KeyboardModifiers() << true;
+ QTest::newRow("zwj-with-ctrl") << QString(QChar(0x200D)) << Qt::KeyboardModifiers(Qt::ControlModifier) << true;
+ QTest::newRow("zwj-with-ctrl-shift") << QString(QChar(0x200D)) << Qt::KeyboardModifiers(Qt::ControlModifier | Qt::ShiftModifier) << true;
+ QTest::newRow("printable-latin") << QString(QLatin1Char('a')) << Qt::KeyboardModifiers() << true;
+ QTest::newRow("printable-latin-with-ctrl") << QString(QLatin1Char('a')) << Qt::KeyboardModifiers(Qt::ControlModifier) << false;
+ QTest::newRow("printable-latin-with-ctrl-shift") << QString(QLatin1Char('a')) << Qt::KeyboardModifiers(Qt::ControlModifier | Qt::ShiftModifier) << false;
+ 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;
+}
+
+void tst_QInputControl::isAcceptableInput()
+{
+ QFETCH(QString, text);
+ QFETCH(Qt::KeyboardModifiers, modifiers);
+ QFETCH(bool, acceptable);
+
+ QKeyEvent keyEvent(QKeyEvent::KeyPress, Qt::Key_unknown, modifiers, text);
+
+ {
+ QInputControl inputControl(QInputControl::TextEdit);
+ QCOMPARE(inputControl.isAcceptableInput(&keyEvent), acceptable);
+ }
+
+ {
+ QInputControl inputControl(QInputControl::LineEdit);
+ QCOMPARE(inputControl.isAcceptableInput(&keyEvent), acceptable);
+ }
+}
+
+void tst_QInputControl::tabOnlyAcceptableInputForTextEdit()
+{
+ QKeyEvent keyEvent(QKeyEvent::KeyPress, Qt::Key_unknown, Qt::KeyboardModifiers(), QLatin1String("\t"));
+
+ {
+ QInputControl inputControl(QInputControl::TextEdit);
+ QCOMPARE(inputControl.isAcceptableInput(&keyEvent), true);
+ }
+
+ {
+ QInputControl inputControl(QInputControl::LineEdit);
+ QCOMPARE(inputControl.isAcceptableInput(&keyEvent), false);
+ }
+}
+
+QTEST_MAIN(tst_QInputControl)
+#include "tst_qinputcontrol.moc"
+
diff --git a/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp b/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp
index b3d1b75a42..9f84f64ee9 100644
--- a/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp
+++ b/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp
@@ -859,7 +859,7 @@ void tst_QStaticText::textDocumentColor()
class TestPaintEngine: public QPaintEngine
{
public:
- void drawTextItem(const QPointF &p, const QTextItem &textItem) Q_DECL_OVERRIDE
+ void drawTextItem(const QPointF &p, const QTextItem &) Q_DECL_OVERRIDE
{
differentVerticalPositions.insert(qRound(p.y()));
}
diff --git a/tests/auto/gui/text/text.pro b/tests/auto/gui/text/text.pro
index bb4984767f..d1a3eda4fc 100644
--- a/tests/auto/gui/text/text.pro
+++ b/tests/auto/gui/text/text.pro
@@ -23,7 +23,8 @@ SUBDIRS=\
qtextscriptengine \
qtexttable \
qzip \
- qtextodfwriter
+ qtextodfwriter \
+ qinputcontrol
win32:SUBDIRS -= qtextpiecetable
diff --git a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp
index 8cc06a77ba..74bffef4f4 100644
--- a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp
+++ b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp
@@ -698,7 +698,7 @@ void tst_QLocalSocket::simpleCommandProtocol2()
QObject::connect(localSocketRead, &QLocalSocket::readyRead, [&] {
forever {
- if (localSocketRead->bytesAvailable() < sizeof(qint64))
+ if (localSocketRead->bytesAvailable() < qint64(sizeof(qint64)))
return;
if (blockSize == 0) {
diff --git a/tests/auto/network/socket/qsctpsocket/tst_qsctpsocket.cpp b/tests/auto/network/socket/qsctpsocket/tst_qsctpsocket.cpp
index fc976fbd0d..cf15e60531 100644
--- a/tests/auto/network/socket/qsctpsocket/tst_qsctpsocket.cpp
+++ b/tests/auto/network/socket/qsctpsocket/tst_qsctpsocket.cpp
@@ -112,7 +112,7 @@ void tst_QSctpSocket::constructing()
QVERIFY(!socket.isOpen());
QVERIFY(!socket.isValid());
QCOMPARE(socket.socketType(), QAbstractSocket::SctpSocket);
- QCOMPARE(socket.maxChannelCount(), 0);
+ QCOMPARE(socket.maximumChannelCount(), 0);
QCOMPARE(socket.readChannelCount(), 0);
QCOMPARE(socket.writeChannelCount(), 0);
@@ -202,7 +202,7 @@ void tst_QSctpSocket::setSocketDescriptor()
{
QSctpServer server;
- server.setMaxChannelCount(16);
+ server.setMaximumChannelCount(16);
QVERIFY(server.listen());
SOCKET sock = ::socket(AF_INET, SOCK_STREAM, IPPROTO_SCTP);
@@ -218,8 +218,8 @@ void tst_QSctpSocket::setSocketDescriptor()
QVERIFY(socket.waitForConnected(3000));
QVERIFY(server.waitForNewConnection(3000));
- QCOMPARE(socket.readChannelCount(), server.maxChannelCount());
- QVERIFY(socket.writeChannelCount() <= server.maxChannelCount());
+ QCOMPARE(socket.readChannelCount(), server.maximumChannelCount());
+ QVERIFY(socket.writeChannelCount() <= server.maximumChannelCount());
QSctpSocket *acceptedSocket = server.nextPendingDatagramConnection();
QVERIFY(acceptedSocket);
@@ -338,11 +338,11 @@ void tst_QSctpSocket::loop()
QSctpServer server;
- server.setMaxChannelCount(10);
+ server.setMaximumChannelCount(10);
QVERIFY(server.listen());
QSctpSocket peter;
- peter.setMaxChannelCount(10);
+ peter.setMaximumChannelCount(10);
peter.connectToHost(QHostAddress::LocalHost, server.serverPort());
QVERIFY(peter.waitForConnected(3000));
@@ -389,11 +389,11 @@ void tst_QSctpSocket::loopInTCPMode()
QSctpServer server;
- server.setMaxChannelCount(-1);
+ server.setMaximumChannelCount(-1);
QVERIFY(server.listen());
QSctpSocket peter;
- peter.setMaxChannelCount(-1);
+ peter.setMaximumChannelCount(-1);
peter.connectToHost(QHostAddress::LocalHost, server.serverPort());
QVERIFY(peter.waitForConnected(3000));
QVERIFY(server.waitForNewConnection(3000));
diff --git a/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp b/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp
index 5a0baf73b5..4bbd0662e4 100644
--- a/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp
+++ b/tests/auto/network/socket/qtcpserver/tst_qtcpserver.cpp
@@ -929,15 +929,16 @@ void tst_QTcpServer::linkLocal()
//each server should have two connections
foreach (QTcpServer* server, servers) {
- QTcpSocket* remote;
//qDebug() << "checking for connections" << server->serverAddress() << ":" << server->serverPort();
QVERIFY(server->waitForNewConnection(5000));
- QVERIFY(remote = server->nextPendingConnection());
+ QTcpSocket* remote = server->nextPendingConnection();
+ QVERIFY(remote != nullptr);
remote->close();
delete remote;
if (!server->hasPendingConnections())
QVERIFY(server->waitForNewConnection(5000));
- QVERIFY(remote = server->nextPendingConnection());
+ remote = server->nextPendingConnection();
+ QVERIFY(remote != nullptr);
remote->close();
delete remote;
QVERIFY(!server->hasPendingConnections());
diff --git a/tests/auto/network/socket/qtcpsocket/stressTest/Test.cpp b/tests/auto/network/socket/qtcpsocket/stressTest/Test.cpp
index 407d244f15..ed61db1a13 100644
--- a/tests/auto/network/socket/qtcpsocket/stressTest/Test.cpp
+++ b/tests/auto/network/socket/qtcpsocket/stressTest/Test.cpp
@@ -47,7 +47,8 @@ void My4Socket::read(void)
{
QDataStream in(this);
- quint32 num, reply;
+ quint32 num = 0;
+ quint32 reply = 0;
while (bytesAvailable()) {
in >> num;
diff --git a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp
index fb6b0c6e32..9fd5620cec 100644
--- a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp
+++ b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp
@@ -603,7 +603,7 @@ void tst_QTcpSocket::bind()
if (port)
QCOMPARE(int(boundPort), port);
fd = socket->socketDescriptor();
- QVERIFY(fd != INVALID_SOCKET);
+ QVERIFY(fd != qintptr(INVALID_SOCKET));
} else {
QVERIFY(!socket->bind(addr, port));
QCOMPARE(socket->localPort(), quint16(0));
@@ -667,7 +667,7 @@ void tst_QTcpSocket::bindThenResolveHost()
QCOMPARE(socket->state(), QAbstractSocket::BoundState);
quint16 boundPort = socket->localPort();
qintptr fd = socket->socketDescriptor();
- QVERIFY(fd != INVALID_SOCKET);
+ QVERIFY(fd != quint16(INVALID_SOCKET));
dummySocket.close();
@@ -2251,7 +2251,8 @@ void tst_QTcpSocket::abortiveClose()
enterLoop(10);
QVERIFY(server.hasPendingConnections());
- QVERIFY(tmpSocket = server.nextPendingConnection());
+ tmpSocket = server.nextPendingConnection();
+ QVERIFY(tmpSocket != nullptr);
qRegisterMetaType<QAbstractSocket::SocketError>("QAbstractSocket::SocketError");
QSignalSpy readyReadSpy(clientSocket, SIGNAL(readyRead()));
diff --git a/tests/auto/other/lancelot/scripts/pixmap_rotation.qps b/tests/auto/other/lancelot/scripts/pixmap_rotation.qps
index 2f1ffb53e6..8427af85af 100644
--- a/tests/auto/other/lancelot/scripts/pixmap_rotation.qps
+++ b/tests/auto/other/lancelot/scripts/pixmap_rotation.qps
@@ -22,9 +22,10 @@ end_block
resetMatrix
translate 340 120
+setRenderHint SmoothPixmapTransformation
repeat_block drawing
resetMatrix
-drawText 50 240 "Normal X form"
-drawText 270 240 "Smooth xform" \ No newline at end of file
+drawText 50 240 "Normal Xform"
+drawText 270 240 "Smooth Xform"
diff --git a/tests/auto/other/lancelot/scripts/pixmap_rotation2.qps b/tests/auto/other/lancelot/scripts/pixmap_rotation2.qps
new file mode 100644
index 0000000000..dfb93fe09c
--- /dev/null
+++ b/tests/auto/other/lancelot/scripts/pixmap_rotation2.qps
@@ -0,0 +1,8 @@
+# Version: 1
+# CheckVsReference: 1%
+
+setRenderHint SmoothPixmapTransformation
+translate 400 -120
+rotate 45
+scale 400 400
+drawImage solid2x2.png 0 0
diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
index 2f5936f1ad..11baee7335 100644
--- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
+++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
@@ -2897,7 +2897,10 @@ void tst_QAccessibility::listTest()
QAccessibleInterface *cellMunich3 = table2->cellAt(2,0);
QCOMPARE(cell4, cellMunich3);
QCOMPARE(axidMunich, QAccessible::uniqueId(cellMunich3));
-
+ delete listView->takeItem(2);
+ // list: Oslo, Helsinki
+ // verify that it doesn't return an invalid item from the cache
+ QVERIFY(table2->cellAt(2,0) == 0);
delete listView;
}
diff --git a/tests/auto/other/qprocess_and_guieventloop/write-read-write/main.cpp b/tests/auto/other/qprocess_and_guieventloop/write-read-write/main.cpp
index 46002dd326..5e75f7db3c 100644
--- a/tests/auto/other/qprocess_and_guieventloop/write-read-write/main.cpp
+++ b/tests/auto/other/qprocess_and_guieventloop/write-read-write/main.cpp
@@ -37,7 +37,9 @@ int main(int, char **argv)
fflush(stdout);
// wait for a newline
- fgets(buf, sizeof buf, stdin);
+ const char *result = fgets(buf, sizeof buf, stdin);
+ if (result != buf)
+ return -1;
puts(msg);
fflush(stdout);
diff --git a/tests/auto/sql/kernel/qsql/tst_qsql.cpp b/tests/auto/sql/kernel/qsql/tst_qsql.cpp
index 282fed2584..2ce43b85a7 100644
--- a/tests/auto/sql/kernel/qsql/tst_qsql.cpp
+++ b/tests/auto/sql/kernel/qsql/tst_qsql.cpp
@@ -33,7 +33,6 @@
#include <qsqlerror.h>
#include <qsqlquery.h>
#include <qsqlrecord.h>
-#include <qsql.h>
#include <qsqlresult.h>
#include <qsqldriver.h>
#include <qdebug.h>
diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
index 84e9643e77..8deb5ddf8f 100644
--- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
+++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp
@@ -3995,35 +3995,29 @@ void tst_QSqlQuery::aggregateFunctionTypes()
}
template<typename T>
-void runIntegralTypesMysqlTest(QSqlDatabase &db, const QString &tableName, const QString &type, const bool withPreparedStatement,
- const T min = std::numeric_limits<T>::min(), const T max = std::numeric_limits<T>::max())
+void runIntegralTypesMysqlTest(QSqlDatabase &db, const QString &tableName,
+ const QString &type, bool withPreparedStatement,
+ const QVector<T> &values)
{
+ QVector<QVariant> variantValues;
+ variantValues.reserve(values.size());
+
QSqlQuery q(db);
QVERIFY_SQL(q, exec("DROP TABLE IF EXISTS " + tableName));
QVERIFY_SQL(q, exec("CREATE TABLE " + tableName + " (id " + type + ')'));
- const int steps = (max == min + 1) ? 2 : 20;
- const T increment = (max == min + 1) ? 1 : (max / steps - min / steps);
-
- // insert some values
- QVector<T> values;
- QVector<QVariant> variantValues;
- values.resize(steps);
- variantValues.resize(steps);
- T v = min;
if (withPreparedStatement) {
QVERIFY_SQL(q, prepare("INSERT INTO " + tableName + " (id) VALUES (?)"));
}
for (int i = 0; i < values.size(); ++i) {
+ const T v = values.at(i);
if (withPreparedStatement) {
q.bindValue(0, v);
QVERIFY_SQL(q, exec());
} else {
QVERIFY_SQL(q, exec("INSERT INTO " + tableName + " (id) VALUES (" + QString::number(v) + QLatin1Char(')')));
}
- values[i] = v;
- variantValues[i] = QVariant::fromValue(v);
- v += increment;
+ variantValues.append(QVariant::fromValue(v));
}
// ensure we can read them back properly
@@ -4048,16 +4042,34 @@ void runIntegralTypesMysqlTest(QSqlDatabase &db, const QString &tableName, const
QCOMPARE(actualVariantValues, variantValues);
}
+template<typename T>
+void runIntegralTypesMysqlTest(QSqlDatabase &db, const QString &tableName,
+ const QString &type, const bool withPreparedStatement,
+ const T min = std::numeric_limits<T>::min(),
+ const T max = std::numeric_limits<T>::max())
+{
+ // insert some values
+ const int steps = 20;
+ const T increment = (max / steps - min / steps);
+ QVector<T> values;
+ values.reserve(steps);
+ T v = min;
+ for (int i = 0; i < steps; ++i, v += increment)
+ values.append(v);
+ runIntegralTypesMysqlTest(db, tableName, type, withPreparedStatement, values);
+}
+
void tst_QSqlQuery::integralTypesMysql()
{
QFETCH(QString, dbName);
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
+ const QVector<bool> boolValues = QVector<bool>() << false << true;
for (int i = 0; i < 2; ++i) {
const bool withPreparedStatement = (i == 1);
- runIntegralTypesMysqlTest<bool>(db, "tinyInt1Test", "TINYINT(1)", withPreparedStatement);
- runIntegralTypesMysqlTest<bool>(db, "unsignedTinyInt1Test", "TINYINT(1) UNSIGNED", withPreparedStatement);
+ runIntegralTypesMysqlTest<bool>(db, "tinyInt1Test", "TINYINT(1)", withPreparedStatement, boolValues);
+ runIntegralTypesMysqlTest<bool>(db, "unsignedTinyInt1Test", "TINYINT(1) UNSIGNED", withPreparedStatement, boolValues);
runIntegralTypesMysqlTest<qint8>(db, "tinyIntTest", "TINYINT", withPreparedStatement);
runIntegralTypesMysqlTest<quint8>(db, "unsignedTinyIntTest", "TINYINT UNSIGNED", withPreparedStatement);
runIntegralTypesMysqlTest<qint16>(db, "smallIntTest", "SMALLINT", withPreparedStatement);
diff --git a/tests/auto/testlib/selftests/tst_selftests.cpp b/tests/auto/testlib/selftests/tst_selftests.cpp
index 0806077031..35b759bcc2 100644
--- a/tests/auto/testlib/selftests/tst_selftests.cpp
+++ b/tests/auto/testlib/selftests/tst_selftests.cpp
@@ -592,8 +592,10 @@ void tst_Selftests::doRunSubTest(QString const& subdir, QStringList const& logge
QProcess proc;
QProcessEnvironment environment = processEnvironment();
- if (crashes)
+ if (crashes) {
+ environment.insert("QTEST_DISABLE_CORE_DUMP", "1");
environment.insert("QTEST_DISABLE_STACK_DUMP", "1");
+ }
proc.setProcessEnvironment(environment);
const QString path = subdir + QLatin1Char('/') + subdir;
proc.start(path, arguments);
diff --git a/tests/auto/tools/rcc/data/images/images.expected b/tests/auto/tools/rcc/data/images/images.expected
index 1f0157d51c..eb5d9222c8 100644
--- a/tests/auto/tools/rcc/data/images/images.expected
+++ b/tests/auto/tools/rcc/data/images/images.expected
@@ -79,16 +79,22 @@ static const unsigned char qt_resource_name[] = {
static const unsigned char qt_resource_struct[] = {
// :
0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x1,
+0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
// :/images
0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x3,0x0,0x0,0x0,0x2,
+0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
// :/images/subdir
0x0,0x0,0x0,0x12,0x0,0x2,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x5,
+0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,
// :/images/square.png
0x0,0x0,0x0,0x3e,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0xa9,
+TIMESTAMP:images/square.png
// :/images/circle.png
0x0,0x0,0x0,0x24,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x0,
+TIMESTAMP:images/circle.png
// :/images/subdir/triangle.png
0x0,0x0,0x0,0x58,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x1,0xb,
+TIMESTAMP:images/subdir/triangle.png
};
@@ -120,7 +126,7 @@ int QT_RCC_MANGLE_NAMESPACE(qInitResources)();
int QT_RCC_MANGLE_NAMESPACE(qInitResources)()
{
QT_RCC_PREPEND_NAMESPACE(qRegisterResourceData)
- (0x01, qt_resource_struct, qt_resource_name, qt_resource_data);
+ (0x02, qt_resource_struct, qt_resource_name, qt_resource_data);
return 1;
}
@@ -128,7 +134,7 @@ int QT_RCC_MANGLE_NAMESPACE(qCleanupResources)();
int QT_RCC_MANGLE_NAMESPACE(qCleanupResources)()
{
QT_RCC_PREPEND_NAMESPACE(qUnregisterResourceData)
- (0x01, qt_resource_struct, qt_resource_name, qt_resource_data);
+ (0x02, qt_resource_struct, qt_resource_name, qt_resource_data);
return 1;
}
diff --git a/tests/auto/tools/rcc/tst_rcc.cpp b/tests/auto/tools/rcc/tst_rcc.cpp
index 8d95d06e30..54a2854ede 100644
--- a/tests/auto/tools/rcc/tst_rcc.cpp
+++ b/tests/auto/tools/rcc/tst_rcc.cpp
@@ -92,12 +92,23 @@ static QString doCompare(const QStringList &actual, const QStringList &expected)
QByteArray ba;
for (int i = 0, n = expected.size(); i != n; ++i) {
- if (expected.at(i).startsWith("IGNORE:"))
+ QString expectedLine = expected.at(i);
+ if (expectedLine.startsWith("IGNORE:"))
continue;
- if (expected.at(i) != actual.at(i)) {
+ if (expectedLine.startsWith("TIMESTAMP:")) {
+ const QString relativePath = expectedLine.mid(strlen("TIMESTAMP:"));
+ const quint64 timeStamp = QFileInfo(relativePath).lastModified().toMSecsSinceEpoch();
+ expectedLine.clear();
+ for (int shift = 56; shift >= 0; shift -= 8) {
+ expectedLine.append(QLatin1String("0x"));
+ expectedLine.append(QString::number(quint8(timeStamp >> shift), 16));
+ expectedLine.append(QLatin1Char(','));
+ }
+ }
+ if (expectedLine != actual.at(i)) {
qDebug() << "LINES" << i << "DIFFER";
ba.append(
- "\n<<<<<< actual\n" + actual.at(i) + "\n======\n" + expected.at(i)
+ "\n<<<<<< actual\n" + actual.at(i) + "\n======\n" + expectedLine
+ "\n>>>>>> expected\n"
);
}
diff --git a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
index 741b5e8aae..c9aef497af 100644
--- a/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
+++ b/tests/auto/widgets/dialogs/qfiledialog/tst_qfiledialog.cpp
@@ -1026,17 +1026,17 @@ void tst_QFiledialog::viewMode()
void tst_QFiledialog::proxymodel()
{
QFileDialog fd;
- QCOMPARE(fd.proxyModel(), (QAbstractProxyModel*)0);
+ QCOMPARE(fd.proxyModel(), nullptr);
fd.setProxyModel(0);
- QCOMPARE(fd.proxyModel(), (QAbstractProxyModel*)0);
+ QCOMPARE(fd.proxyModel(), nullptr);
QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel(&fd);
fd.setProxyModel(proxyModel);
QCOMPARE(fd.proxyModel(), (QAbstractProxyModel *)proxyModel);
fd.setProxyModel(0);
- QCOMPARE(fd.proxyModel(), (QAbstractProxyModel*)0);
+ QCOMPARE(fd.proxyModel(), nullptr);
}
void tst_QFiledialog::setEmptyNameFilter()
diff --git a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
index a16bd1a787..1ff7a0c97b 100644
--- a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
+++ b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
@@ -340,8 +340,7 @@ void tst_QFileDialog2::task143519_deleteAndRenameActionBehavior()
// test based on task233037_selectingDirectory
struct TestContext {
- TestContext()
- : current(QDir::current()) {}
+ explicit TestContext(const QString &path) : current(path) {}
~TestContext() {
file.remove();
current.rmdir(test.dirName());
@@ -349,7 +348,9 @@ void tst_QFileDialog2::task143519_deleteAndRenameActionBehavior()
QDir current;
QDir test;
QFile file;
- } ctx;
+ };
+
+ TestContext ctx(tempDir.path());
// setup testbed
QVERIFY(ctx.current.mkdir("task143519_deleteAndRenameActionBehavior_test")); // ensure at least one item
@@ -363,6 +364,7 @@ void tst_QFileDialog2::task143519_deleteAndRenameActionBehavior()
QFileDialog fd;
fd.setViewMode(QFileDialog::List);
fd.setDirectory(ctx.test.absolutePath());
+ fd.selectFile(ctx.file.fileName());
fd.show();
QTest::qWaitForWindowActive(&fd);
@@ -377,7 +379,7 @@ void tst_QFileDialog2::task143519_deleteAndRenameActionBehavior()
// defaults
QVERIFY(openContextMenu(fd));
- QCOMPARE(fd.selectedFiles().size(), 1);
+ QCOMPARE(fd.selectedFiles(), QStringList(ctx.file.fileName()));
QCOMPARE(rm->isEnabled(), !fd.isReadOnly());
QCOMPARE(mv->isEnabled(), !fd.isReadOnly());
diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp
index 0bb2c50b9d..31df66e312 100644
--- a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp
+++ b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp
@@ -135,7 +135,7 @@ tst_QFileSystemModel::tst_QFileSystemModel() : model(0)
void tst_QFileSystemModel::init()
{
cleanup();
- QCOMPARE(model, (QFileSystemModel*)0);
+ QCOMPARE(model, nullptr);
model = new QFileSystemModel;
}
diff --git a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp
index 2a629c3ff0..db86fba59c 100644
--- a/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp
+++ b/tests/auto/widgets/dialogs/qwizard/tst_qwizard.cpp
@@ -2400,7 +2400,7 @@ void tst_QWizard::removePage()
QCOMPARE(arguments.at(0).toInt(), 3);
QVERIFY(wizard.visitedPages().empty());
QVERIFY(wizard.pageIds().empty());
- QCOMPARE(wizard.currentPage(), static_cast<QWizardPage *>(0));
+ QCOMPARE(wizard.currentPage(), nullptr);
}
void tst_QWizard::sideWidget()
diff --git a/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp b/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
index f5b2269297..9d4b640272 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp
@@ -1073,7 +1073,7 @@ void tst_QGraphicsGridLayout::itemAt()
} else {
const QByteArray message = "QGraphicsGridLayout::itemAt: invalid index " + QByteArray::number(i);
QTest::ignoreMessage(QtWarningMsg, message.constData());
- QCOMPARE(layout->itemAt(i), static_cast<QGraphicsLayoutItem*>(0));
+ QCOMPARE(layout->itemAt(i), nullptr);
}
}
delete widget;
@@ -1102,7 +1102,7 @@ void tst_QGraphicsGridLayout::removeAt()
QGraphicsLayoutItem *item0 = layout->itemAt(0);
QCOMPARE(item0->parentLayoutItem(), static_cast<QGraphicsLayoutItem *>(layout));
layout->removeAt(0);
- QCOMPARE(item0->parentLayoutItem(), static_cast<QGraphicsLayoutItem *>(0));
+ QCOMPARE(item0->parentLayoutItem(), nullptr);
QCOMPARE(layout->count(), 0);
QTest::ignoreMessage(QtWarningMsg, QString::fromLatin1("QGraphicsGridLayout::removeAt: invalid index 0").toLatin1().constData());
layout->removeAt(0);
diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
index 96a76d885d..96827022a8 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -486,7 +486,7 @@ void tst_QGraphicsItem::construction()
((QGraphicsEllipseItem *)item)->setPen(QPen(Qt::black, 0));
QCOMPARE(int(item->type()), int(QGraphicsEllipseItem::Type));
QCOMPARE(qgraphicsitem_cast<QGraphicsEllipseItem *>(item), (QGraphicsEllipseItem *)item);
- QCOMPARE(qgraphicsitem_cast<QGraphicsRectItem *>(item), (QGraphicsRectItem *)0);
+ QCOMPARE(qgraphicsitem_cast<QGraphicsRectItem *>(item), nullptr);
QCOMPARE(item->flags(), 0);
break;
case 1:
@@ -494,7 +494,7 @@ void tst_QGraphicsItem::construction()
((QGraphicsLineItem *)item)->setPen(QPen(Qt::black, 0));
QCOMPARE(int(item->type()), int(QGraphicsLineItem::Type));
QCOMPARE(qgraphicsitem_cast<QGraphicsLineItem *>(item), (QGraphicsLineItem *)item);
- QCOMPARE(qgraphicsitem_cast<QGraphicsRectItem *>(item), (QGraphicsRectItem *)0);
+ QCOMPARE(qgraphicsitem_cast<QGraphicsRectItem *>(item), nullptr);
QCOMPARE(item->flags(), 0);
break;
case 2:
@@ -502,14 +502,14 @@ void tst_QGraphicsItem::construction()
((QGraphicsPathItem *)item)->setPen(QPen(Qt::black, 0));
QCOMPARE(int(item->type()), int(QGraphicsPathItem::Type));
QCOMPARE(qgraphicsitem_cast<QGraphicsPathItem *>(item), (QGraphicsPathItem *)item);
- QCOMPARE(qgraphicsitem_cast<QGraphicsRectItem *>(item), (QGraphicsRectItem *)0);
+ QCOMPARE(qgraphicsitem_cast<QGraphicsRectItem *>(item), nullptr);
QCOMPARE(item->flags(), 0);
break;
case 3:
item = new QGraphicsPixmapItem;
QCOMPARE(int(item->type()), int(QGraphicsPixmapItem::Type));
QCOMPARE(qgraphicsitem_cast<QGraphicsPixmapItem *>(item), (QGraphicsPixmapItem *)item);
- QCOMPARE(qgraphicsitem_cast<QGraphicsRectItem *>(item), (QGraphicsRectItem *)0);
+ QCOMPARE(qgraphicsitem_cast<QGraphicsRectItem *>(item), nullptr);
QCOMPARE(item->flags(), 0);
break;
case 4:
@@ -517,7 +517,7 @@ void tst_QGraphicsItem::construction()
((QGraphicsPolygonItem *)item)->setPen(QPen(Qt::black, 0));
QCOMPARE(int(item->type()), int(QGraphicsPolygonItem::Type));
QCOMPARE(qgraphicsitem_cast<QGraphicsPolygonItem *>(item), (QGraphicsPolygonItem *)item);
- QCOMPARE(qgraphicsitem_cast<QGraphicsRectItem *>(item), (QGraphicsRectItem *)0);
+ QCOMPARE(qgraphicsitem_cast<QGraphicsRectItem *>(item), nullptr);
QCOMPARE(item->flags(), 0);
break;
case 5:
@@ -525,14 +525,14 @@ void tst_QGraphicsItem::construction()
((QGraphicsRectItem *)item)->setPen(QPen(Qt::black, 0));
QCOMPARE(int(item->type()), int(QGraphicsRectItem::Type));
QCOMPARE(qgraphicsitem_cast<QGraphicsRectItem *>(item), (QGraphicsRectItem *)item);
- QCOMPARE(qgraphicsitem_cast<QGraphicsLineItem *>(item), (QGraphicsLineItem *)0);
+ QCOMPARE(qgraphicsitem_cast<QGraphicsLineItem *>(item), nullptr);
QCOMPARE(item->flags(), 0);
break;
case 6:
item = new QGraphicsTextItem;
QCOMPARE(int(item->type()), int(QGraphicsTextItem::Type));
QCOMPARE(qgraphicsitem_cast<QGraphicsTextItem *>(item), (QGraphicsTextItem *)item);
- QCOMPARE(qgraphicsitem_cast<QGraphicsRectItem *>(item), (QGraphicsRectItem *)0);
+ QCOMPARE(qgraphicsitem_cast<QGraphicsRectItem *>(item), nullptr);
// This is the only item that uses an extended style option.
QCOMPARE(item->flags(), QGraphicsItem::GraphicsItemFlags(QGraphicsItem::ItemUsesExtendedStyleOption));
break;
@@ -541,8 +541,8 @@ void tst_QGraphicsItem::construction()
break;
}
- QCOMPARE(item->scene(), (QGraphicsScene *)0);
- QCOMPARE(item->parentItem(), (QGraphicsItem *)0);
+ QCOMPARE(item->scene(), nullptr);
+ QCOMPARE(item->parentItem(), nullptr);
QVERIFY(item->childItems().isEmpty());
QVERIFY(item->isVisible());
QVERIFY(item->isEnabled());
@@ -640,7 +640,7 @@ void tst_QGraphicsItem::destruction()
QGraphicsScene scene;
QGraphicsItem *parent = new QGraphicsRectItem;
Item *child = new Item;
- QCOMPARE(child->parentItem(), (QGraphicsItem *)0);
+ QCOMPARE(child->parentItem(), nullptr);
child->setParentItem(parent);
QCOMPARE(child->parentItem(), parent);
scene.addItem(parent);
@@ -669,7 +669,7 @@ void tst_QGraphicsItem::destruction()
scene.addItem(parent);
QCOMPARE(child->scene(), &scene);
scene.removeItem(parent);
- QCOMPARE(child->scene(), (QGraphicsScene *)0);
+ QCOMPARE(child->scene(), nullptr);
delete parent;
QCOMPARE(itemDeleted, 5);
}
@@ -678,14 +678,14 @@ void tst_QGraphicsItem::destruction()
QGraphicsItem *parent = new QGraphicsRectItem;
Item *child = new Item;
child->setParentItem(parent);
- QCOMPARE(child->scene(), (QGraphicsScene *)0);
- QCOMPARE(parent->scene(), (QGraphicsScene *)0);
+ QCOMPARE(child->scene(), nullptr);
+ QCOMPARE(parent->scene(), nullptr);
scene.addItem(parent);
QCOMPARE(child->scene(), &scene);
scene.removeItem(child);
- QCOMPARE(child->scene(), (QGraphicsScene *)0);
+ QCOMPARE(child->scene(), nullptr);
QCOMPARE(parent->scene(), &scene);
- QCOMPARE(child->parentItem(), (QGraphicsItem *)0);
+ QCOMPARE(child->parentItem(), nullptr);
QVERIFY(parent->childItems().isEmpty());
delete parent;
QCOMPARE(itemDeleted, 5);
@@ -799,7 +799,7 @@ void tst_QGraphicsItem::deleteChildItem()
void tst_QGraphicsItem::scene()
{
QGraphicsRectItem *item = new QGraphicsRectItem;
- QCOMPARE(item->scene(), (QGraphicsScene *)0);
+ QCOMPARE(item->scene(), nullptr);
QGraphicsScene scene;
scene.addItem(item);
@@ -810,7 +810,7 @@ void tst_QGraphicsItem::scene()
QCOMPARE(item->scene(), (QGraphicsScene *)&scene2);
scene2.removeItem(item);
- QCOMPARE(item->scene(), (QGraphicsScene *)0);
+ QCOMPARE(item->scene(), nullptr);
delete item;
}
@@ -818,14 +818,14 @@ void tst_QGraphicsItem::scene()
void tst_QGraphicsItem::parentItem()
{
QGraphicsRectItem item;
- QCOMPARE(item.parentItem(), (QGraphicsItem *)0);
+ QCOMPARE(item.parentItem(), nullptr);
QGraphicsRectItem *item2 = new QGraphicsRectItem(QRectF(), &item);
QCOMPARE(item2->parentItem(), (QGraphicsItem *)&item);
item2->setParentItem(&item);
QCOMPARE(item2->parentItem(), (QGraphicsItem *)&item);
item2->setParentItem(0);
- QCOMPARE(item2->parentItem(), (QGraphicsItem *)0);
+ QCOMPARE(item2->parentItem(), nullptr);
delete item2;
}
@@ -837,7 +837,7 @@ void tst_QGraphicsItem::setParentItem()
QCOMPARE(item->scene(), &scene);
const QScopedPointer<QGraphicsRectItem> child(new QGraphicsRectItem);
- QCOMPARE(child->scene(), (QGraphicsScene *)0);
+ QCOMPARE(child->scene(), nullptr);
// This implicitly adds the item to the parent's scene
child->setParentItem(item.data());
@@ -850,7 +850,7 @@ void tst_QGraphicsItem::setParentItem()
// Add the child back to the parent, then remove the parent from the scene
child->setParentItem(item.data());
scene.removeItem(item.data());
- QCOMPARE(child->scene(), (QGraphicsScene *)0);
+ QCOMPARE(child->scene(), nullptr);
}
void tst_QGraphicsItem::children()
@@ -917,7 +917,7 @@ void tst_QGraphicsItem::flags()
event.setButton(Qt::LeftButton);
event.setButtons(Qt::LeftButton);
QApplication::sendEvent(&scene, &event);
- QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *)0); // mouse grabber is reset
+ QCOMPARE(scene.mouseGrabberItem(), nullptr); // mouse grabber is reset
QGraphicsSceneMouseEvent event2(QEvent::GraphicsSceneMouseMove);
event2.setScenePos(QPointF(10, 10));
@@ -930,7 +930,7 @@ void tst_QGraphicsItem::flags()
event3.setScenePos(QPointF(10, 10));
event3.setButtons(0);
QApplication::sendEvent(&scene, &event3);
- QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *)0);
+ QCOMPARE(scene.mouseGrabberItem(), nullptr);
item->setFlag(QGraphicsItem::ItemIsMovable, true);
QGraphicsSceneMouseEvent event4(QEvent::GraphicsSceneMousePress);
@@ -1122,9 +1122,9 @@ void tst_QGraphicsItem::visible()
QApplication::sendEvent(&scene, &event);
QCOMPARE(scene.mouseGrabberItem(), item);
item->setVisible(false);
- QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *)0);
+ QCOMPARE(scene.mouseGrabberItem(), nullptr);
item->setVisible(true);
- QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *)0);
+ QCOMPARE(scene.mouseGrabberItem(), nullptr);
item->setFlag(QGraphicsItem::ItemIsFocusable);
item->setFocus();
@@ -1378,12 +1378,12 @@ void tst_QGraphicsItem::enabled()
event.setButton(Qt::LeftButton);
event.setScenePos(QPointF(0, 0));
QApplication::sendEvent(&scene, &event);
- QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *)0);
+ QCOMPARE(scene.mouseGrabberItem(), nullptr);
item->setEnabled(true);
QApplication::sendEvent(&scene, &event);
QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *)item);
item->setEnabled(false);
- QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *)0);
+ QCOMPARE(scene.mouseGrabberItem(), nullptr);
}
void tst_QGraphicsItem::explicitlyEnabled()
@@ -1888,7 +1888,7 @@ void tst_QGraphicsItem::acceptedMouseButtons()
QApplication::sendEvent(&scene, &event);
QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *)item2);
item2->setAcceptedMouseButtons(0);
- QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *)0);
+ QCOMPARE(scene.mouseGrabberItem(), nullptr);
QApplication::sendEvent(&scene, &event);
QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *)item1);
}
@@ -2069,8 +2069,8 @@ void tst_QGraphicsItem::hasFocus()
scene2.addItem(line);
QVERIFY(!line->hasFocus());
- QCOMPARE(scene.focusItem(), (QGraphicsItem *)0);
- QCOMPARE(scene2.focusItem(), (QGraphicsItem *)0);
+ QCOMPARE(scene.focusItem(), nullptr);
+ QCOMPARE(scene2.focusItem(), nullptr);
line->setFocus();
QVERIFY(line->hasFocus());
@@ -3137,7 +3137,7 @@ void tst_QGraphicsItem::commonAncestorItem()
grandPa->setParentItem(ancestor);
QCOMPARE(grandMa->commonAncestorItem(grandMa), grandMa);
- QCOMPARE(grandMa->commonAncestorItem(0), (QGraphicsItem *)0);
+ QCOMPARE(grandMa->commonAncestorItem(0), nullptr);
QCOMPARE(grandMa->commonAncestorItem(grandPa), ancestor);
QCOMPARE(grandPa->commonAncestorItem(grandMa), ancestor);
QCOMPARE(grandPa->commonAncestorItem(husband), grandPa);
@@ -3556,9 +3556,9 @@ void tst_QGraphicsItem::group()
parent->setPos(25, 25);
child->setPos(25, 25);
- QCOMPARE(parent->group(), (QGraphicsItemGroup *)0);
- QCOMPARE(parent2->group(), (QGraphicsItemGroup *)0);
- QCOMPARE(child->group(), (QGraphicsItemGroup *)0);
+ QCOMPARE(parent->group(), nullptr);
+ QCOMPARE(parent2->group(), nullptr);
+ QCOMPARE(child->group(), nullptr);
QGraphicsView view(&scene);
view.show();
@@ -3620,8 +3620,8 @@ void tst_QGraphicsItem::setGroup()
QGraphicsItemGroup group2;
const QScopedPointer<QGraphicsRectItem> rect(new QGraphicsRectItem);
- QCOMPARE(rect->group(), (QGraphicsItemGroup *)0);
- QCOMPARE(rect->parentItem(), (QGraphicsItem *)0);
+ QCOMPARE(rect->group(), nullptr);
+ QCOMPARE(rect->parentItem(), nullptr);
rect->setGroup(&group1);
QCOMPARE(rect->group(), &group1);
QCOMPARE(rect->parentItem(), (QGraphicsItem *)&group1);
@@ -3629,8 +3629,8 @@ void tst_QGraphicsItem::setGroup()
QCOMPARE(rect->group(), &group2);
QCOMPARE(rect->parentItem(), (QGraphicsItem *)&group2);
rect->setGroup(0);
- QCOMPARE(rect->group(), (QGraphicsItemGroup *)0);
- QCOMPARE(rect->parentItem(), (QGraphicsItem *)0);
+ QCOMPARE(rect->group(), nullptr);
+ QCOMPARE(rect->parentItem(), nullptr);
}
void tst_QGraphicsItem::setGroup2()
@@ -3679,14 +3679,14 @@ void tst_QGraphicsItem::nestedGroups()
QCOMPARE(rect->group(), group1);
QCOMPARE(rect2->group(), group1);
QCOMPARE(group1->group(), group2);
- QCOMPARE(group2->group(), (QGraphicsItemGroup *)0);
+ QCOMPARE(group2->group(), nullptr);
QGraphicsScene scene;
scene.addItem(group1);
QCOMPARE(rect->group(), group1);
QCOMPARE(rect2->group(), group1);
- QCOMPARE(group1->group(), (QGraphicsItemGroup *)0);
+ QCOMPARE(group1->group(), nullptr);
QVERIFY(group2->childItems().isEmpty());
delete group2;
@@ -4769,8 +4769,8 @@ void tst_QGraphicsItem::itemChange()
QCOMPARE(tester.changes.size(), ++changeCount);
QCOMPARE(tester.changes.last(), QGraphicsItem::ItemParentChange);
QCOMPARE(qvariant_cast<QGraphicsItem *>(tester.values.last()), (QGraphicsItem *)&testerHelper);
- QCOMPARE(qvariant_cast<QGraphicsItem *>(tester.oldValues.last()), (QGraphicsItem *)0);
- QCOMPARE(tester.parentItem(), (QGraphicsItem *)0);
+ QCOMPARE(qvariant_cast<QGraphicsItem *>(tester.oldValues.last()), nullptr);
+ QCOMPARE(tester.parentItem(), nullptr);
}
{
// ItemOpacityChange
@@ -4866,7 +4866,7 @@ void tst_QGraphicsItem::itemChange()
QCOMPARE(tester.changes.at(tester.changes.size() - 1), QGraphicsItem::ItemSceneHasChanged);
// Item's old value was 0
// Item's current value is scene
- QCOMPARE(qvariant_cast<QGraphicsScene *>(tester.oldValues.last()), (QGraphicsScene *)0);
+ QCOMPARE(qvariant_cast<QGraphicsScene *>(tester.oldValues.last()), nullptr);
QCOMPARE(qvariant_cast<QGraphicsScene *>(tester.values.last()), (QGraphicsScene *)&scene);
scene2.addItem(&tester);
++changeCount; // ItemSceneChange (0) was: (scene)
@@ -4884,14 +4884,14 @@ void tst_QGraphicsItem::itemChange()
// Item's last current value is 0
QCOMPARE(qvariant_cast<QGraphicsScene *>(tester.oldValues.at(tester.oldValues.size() - 2)), (QGraphicsScene *)&scene);
- QCOMPARE(qvariant_cast<QGraphicsScene *>(tester.oldValues.at(tester.oldValues.size() - 1)), (QGraphicsScene *)0);
- QCOMPARE(qvariant_cast<QGraphicsScene *>(tester.values.at(tester.values.size() - 4)), (QGraphicsScene *)0);
- QCOMPARE(qvariant_cast<QGraphicsScene *>(tester.values.at(tester.values.size() - 3)), (QGraphicsScene *)0);
+ QCOMPARE(qvariant_cast<QGraphicsScene *>(tester.oldValues.at(tester.oldValues.size() - 1)), nullptr);
+ QCOMPARE(qvariant_cast<QGraphicsScene *>(tester.values.at(tester.values.size() - 4)), nullptr);
+ QCOMPARE(qvariant_cast<QGraphicsScene *>(tester.values.at(tester.values.size() - 3)), nullptr);
QCOMPARE(qvariant_cast<QGraphicsScene *>(tester.values.at(tester.values.size() - 2)), (QGraphicsScene *)&scene2);
QCOMPARE(qvariant_cast<QGraphicsScene *>(tester.values.at(tester.values.size() - 1)), (QGraphicsScene *)&scene2);
// Item's last old value was 0
// Item's last current value is scene2
- QCOMPARE(qvariant_cast<QGraphicsScene *>(tester.oldValues.last()), (QGraphicsScene *)0);
+ QCOMPARE(qvariant_cast<QGraphicsScene *>(tester.oldValues.last()), nullptr);
QCOMPARE(qvariant_cast<QGraphicsScene *>(tester.values.last()), (QGraphicsScene *)&scene2);
scene2.removeItem(&tester);
@@ -4899,14 +4899,14 @@ void tst_QGraphicsItem::itemChange()
++changeCount; // ItemSceneHasChanged (0)
QCOMPARE(tester.changes.size(), changeCount);
- QCOMPARE(tester.scene(), (QGraphicsScene *)0);
+ QCOMPARE(tester.scene(), nullptr);
QCOMPARE(tester.changes.at(tester.changes.size() - 2), QGraphicsItem::ItemSceneChange);
QCOMPARE(tester.changes.at(tester.changes.size() - 1), QGraphicsItem::ItemSceneHasChanged);
// Item's last old value was scene2
// Item's last current value is 0
QCOMPARE(qvariant_cast<QGraphicsScene *>(tester.oldValues.last()), (QGraphicsScene *)&scene2);
- QCOMPARE(qvariant_cast<QGraphicsScene *>(tester.values.at(tester.values.size() - 2)), (QGraphicsScene *)0);
- QCOMPARE(qvariant_cast<QGraphicsScene *>(tester.values.at(tester.values.size() - 1)), (QGraphicsScene *)0);
+ QCOMPARE(qvariant_cast<QGraphicsScene *>(tester.values.at(tester.values.size() - 2)), nullptr);
+ QCOMPARE(qvariant_cast<QGraphicsScene *>(tester.values.at(tester.values.size() - 1)), nullptr);
tester.itemSceneChangeTargetScene = &scene;
scene2.addItem(&tester);
@@ -4925,7 +4925,7 @@ void tst_QGraphicsItem::itemChange()
scene.removeItem(&tester);
++changeCount; // ItemSceneChange
++changeCount; // ItemSceneHasChanged
- QCOMPARE(tester.scene(), (QGraphicsScene *)0);
+ QCOMPARE(tester.scene(), nullptr);
}
{
// ItemToolTipChange/ItemToolTipHasChanged
@@ -6505,7 +6505,7 @@ void tst_QGraphicsItem::task240400_clickOnTextItem()
if (flags || textFlags)
QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *)item);
else
- QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *)0);
+ QCOMPARE(scene.mouseGrabberItem(), nullptr);
{
QGraphicsSceneMouseEvent event(QEvent::GraphicsSceneMouseRelease);
event.setScenePos(item->sceneBoundingRect().topLeft() + QPointF(0.1, 0.1));
@@ -6532,7 +6532,7 @@ void tst_QGraphicsItem::task240400_clickOnTextItem()
if (flags || textFlags)
QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *)item);
else
- QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *)0);
+ QCOMPARE(scene.mouseGrabberItem(), nullptr);
{
QGraphicsSceneMouseEvent event(QEvent::GraphicsSceneMouseRelease);
event.setScenePos(item->sceneBoundingRect().center());
@@ -8454,17 +8454,17 @@ void tst_QGraphicsItem::focusProxy()
QTest::ignoreMessage(QtWarningMsg, err.toLatin1().constData());
item2->setFocusProxy(item); // fails
QCOMPARE(item->focusProxy(), (QGraphicsItem *)item2);
- QCOMPARE(item2->focusProxy(), (QGraphicsItem *)0);
+ QCOMPARE(item2->focusProxy(), nullptr);
// Try to assign self as focus proxy
QTest::ignoreMessage(QtWarningMsg, "QGraphicsItem::setFocusProxy: cannot assign self as focus proxy");
item->setFocusProxy(item); // fails
QCOMPARE(item->focusProxy(), (QGraphicsItem *)item2);
- QCOMPARE(item2->focusProxy(), (QGraphicsItem *)0);
+ QCOMPARE(item2->focusProxy(), nullptr);
// Reset the focus proxy
item->setFocusProxy(0);
- QCOMPARE(item->focusProxy(), (QGraphicsItem *)0);
+ QCOMPARE(item->focusProxy(), nullptr);
QVERIFY(!item->hasFocus());
QVERIFY(item2->hasFocus());
@@ -8472,7 +8472,7 @@ void tst_QGraphicsItem::focusProxy()
item->setFocusProxy(item2);
QCOMPARE(item->focusProxy(), (QGraphicsItem *)item2);
delete item2;
- QCOMPARE(item->focusProxy(), (QGraphicsItem *)0);
+ QCOMPARE(item->focusProxy(), nullptr);
// Test event delivery
item2 = scene.addRect(0, 0, 10, 10);
@@ -8502,11 +8502,11 @@ void tst_QGraphicsItem::focusProxy()
item3->setFocusProxy(item2); // item and item3 use item2 as proxy
QCOMPARE(item->focusProxy(), item2);
- QCOMPARE(item2->focusProxy(), (QGraphicsItem *)0);
+ QCOMPARE(item2->focusProxy(), nullptr);
QCOMPARE(item3->focusProxy(), item2);
delete item2;
- QCOMPARE(item->focusProxy(), (QGraphicsItem *)0);
- QCOMPARE(item3->focusProxy(), (QGraphicsItem *)0);
+ QCOMPARE(item->focusProxy(), nullptr);
+ QCOMPARE(item3->focusProxy(), nullptr);
}
void tst_QGraphicsItem::subFocus()
@@ -8557,8 +8557,8 @@ void tst_QGraphicsItem::subFocus()
// readd them. Now the subfocus should kick in and give
// text2 focus.
scene.removeItem(text);
- QCOMPARE(text->focusItem(), (QGraphicsItem *)0);
- QCOMPARE(text2->focusItem(), (QGraphicsItem *)0);
+ QCOMPARE(text->focusItem(), nullptr);
+ QCOMPARE(text2->focusItem(), nullptr);
text2->setFocus();
QCOMPARE(text->focusItem(), (QGraphicsItem *)text2);
QCOMPARE(text2->focusItem(), (QGraphicsItem *)text2);
@@ -8596,9 +8596,9 @@ void tst_QGraphicsItem::subFocus()
QVERIFY(rect3->hasFocus());
delete rect2;
- QCOMPARE(text->focusItem(), (QGraphicsItem *)0);
- QCOMPARE(text2->focusItem(), (QGraphicsItem *)0);
- QCOMPARE(rect->focusItem(), (QGraphicsItem *)0);
+ QCOMPARE(text->focusItem(), nullptr);
+ QCOMPARE(text2->focusItem(), nullptr);
+ QCOMPARE(rect->focusItem(), nullptr);
}
void tst_QGraphicsItem::focusProxyDeletion()
@@ -8609,7 +8609,7 @@ void tst_QGraphicsItem::focusProxyDeletion()
QCOMPARE(rect->focusProxy(), (QGraphicsItem *)rect2);
delete rect2;
- QCOMPARE(rect->focusProxy(), (QGraphicsItem *)0);
+ QCOMPARE(rect->focusProxy(), nullptr);
rect2 = new QGraphicsRectItem;
rect->setFocusProxy(rect2);
@@ -8623,12 +8623,12 @@ void tst_QGraphicsItem::focusProxyDeletion()
scene->addItem(rect);
scene->addItem(rect2);
delete rect2;
- QCOMPARE(rect->focusProxy(), (QGraphicsItem *)0);
+ QCOMPARE(rect->focusProxy(), nullptr);
rect2 = new QGraphicsRectItem;
QTest::ignoreMessage(QtWarningMsg, "QGraphicsItem::setFocusProxy: focus proxy must be in same scene");
rect->setFocusProxy(rect2);
- QCOMPARE(rect->focusProxy(), (QGraphicsItem *)0);
+ QCOMPARE(rect->focusProxy(), nullptr);
scene->addItem(rect2);
rect->setFocusProxy(rect2);
QCOMPARE(rect->focusProxy(), (QGraphicsItem *)rect2);
@@ -9003,7 +9003,7 @@ void tst_QGraphicsItem::activate()
QVERIFY(rect3->isActive());
scene.removeItem(rect3);
QVERIFY(!rect3->isActive()); // no panel is active anymore
- QCOMPARE(scene.activePanel(), (QGraphicsItem *)0);
+ QCOMPARE(scene.activePanel(), nullptr);
scene.addItem(rect3);
QVERIFY(rect3->isActive()); // second panel item is activated
@@ -9043,7 +9043,7 @@ void tst_QGraphicsItem::activate()
QVERIFY(!rect4->isActive());
QVERIFY(!rect5->isActive());
QVERIFY(!rect6->isActive());
- QCOMPARE(scene.activePanel(), (QGraphicsItem *)0);
+ QCOMPARE(scene.activePanel(), nullptr);
// Controlling auto-activation when the scene changes activation.
rect4->setActive(true);
@@ -9071,7 +9071,7 @@ void tst_QGraphicsItem::setActivePanelOnInactiveScene()
EventSpy sceneActivationChangeSpy(&scene, QEvent::ActivationChange);
scene.setActivePanel(panel);
- QCOMPARE(scene.activePanel(), (QGraphicsItem *)0);
+ QCOMPARE(scene.activePanel(), nullptr);
QCOMPARE(itemActivateSpy.count(), 0);
QCOMPARE(itemDeactivateSpy.count(), 0);
QCOMPARE(panelActivateSpy.count(), 0);
@@ -9350,7 +9350,7 @@ void tst_QGraphicsItem::focusScope()
QCOMPARE(scope3->focusItem(), (QGraphicsItem *)scope3);
QCOMPARE(scope1->focusScopeItem(), (QGraphicsItem *)scope2);
QCOMPARE(scope2->focusScopeItem(), (QGraphicsItem *)scope3);
- QCOMPARE(scope3->focusScopeItem(), (QGraphicsItem *)0);
+ QCOMPARE(scope3->focusScopeItem(), nullptr);
scene.addItem(scope1);
@@ -9363,7 +9363,7 @@ void tst_QGraphicsItem::focusScope()
QCOMPARE(scope3->focusItem(), (QGraphicsItem *)scope3);
QCOMPARE(scope1->focusScopeItem(), (QGraphicsItem *)scope2);
QCOMPARE(scope2->focusScopeItem(), (QGraphicsItem *)scope3);
- QCOMPARE(scope3->focusScopeItem(), (QGraphicsItem *)0);
+ QCOMPARE(scope3->focusScopeItem(), nullptr);
QVERIFY(scope3->hasFocus());
@@ -9445,8 +9445,8 @@ void tst_QGraphicsItem::focusScope()
rect4->setParentItem(0);
QVERIFY(rect5->hasFocus());
- QCOMPARE(scope3->focusScopeItem(), (QGraphicsItem *)0);
- QCOMPARE(scope3->focusItem(), (QGraphicsItem *)0);
+ QCOMPARE(scope3->focusScopeItem(), nullptr);
+ QCOMPARE(scope3->focusItem(), nullptr);
QVERIFY(!scope3->hasFocus());
QGraphicsRectItem *rectA = new QGraphicsRectItem;
@@ -9501,7 +9501,7 @@ void tst_QGraphicsItem::focusScope2()
siblingChild2->setParentItem(siblingFocusScope);
QCOMPARE(siblingFocusScope->focusScopeItem(), (QGraphicsItem *)siblingChild1);
- QCOMPARE(siblingFocusScope->focusItem(), (QGraphicsItem *)0);
+ QCOMPARE(siblingFocusScope->focusItem(), nullptr);
QGraphicsItem *root = new QGraphicsRectItem;
rootFocusScope->setParentItem(root);
@@ -9526,7 +9526,7 @@ void tst_QGraphicsItem::focusScope2()
QVERIFY(!siblingChild2->hasFocus());
QVERIFY(!siblingChild2->focusItem());
QCOMPARE(siblingFocusScope->focusScopeItem(), (QGraphicsItem *)siblingChild2);
- QCOMPARE(siblingFocusScope->focusItem(), (QGraphicsItem *)0);
+ QCOMPARE(siblingFocusScope->focusItem(), nullptr);
// Set focus on the scope; focus is forwarded to the focus scope item.
siblingFocusScope->setFocus();
@@ -9571,7 +9571,7 @@ void tst_QGraphicsItem::focusScopeItemChangedWhileScopeDoesntHaveFocus()
FocusScopeItem *child1 = new FocusScopeItem(&rect);
FocusScopeItem *child2 = new FocusScopeItem(&rect);
- QCOMPARE(rect.focusScopeItem(), (QGraphicsItem *)0);
+ QCOMPARE(rect.focusScopeItem(), nullptr);
QCOMPARE(child1->focusScopeChanged, 0);
QCOMPARE(child2->focusScopeChanged, 0);
child1->setFocus();
@@ -9587,7 +9587,7 @@ void tst_QGraphicsItem::focusScopeItemChangedWhileScopeDoesntHaveFocus()
QCOMPARE(child1->focusScopeChanged, 3);
QCOMPARE(child2->focusScopeChanged, 2);
child1->clearFocus();
- QCOMPARE(rect.focusScopeItem(), (QGraphicsItem *)0);
+ QCOMPARE(rect.focusScopeItem(), nullptr);
QCOMPARE(child1->focusScopeChanged, 4);
QCOMPARE(child2->focusScopeChanged, 2);
}
@@ -10245,7 +10245,7 @@ void tst_QGraphicsItem::modality_mouseGrabber()
QCOMPARE(rect1Spy.counts[QEvent::UngrabMouse], 1);
QCOMPARE(rect2Spy.counts[QEvent::GrabMouse], 0);
QCOMPARE(rect2Spy.counts[QEvent::UngrabMouse], 0);
- QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *) 0);
+ QCOMPARE(scene.mouseGrabberItem(), nullptr);
// releasing goes nowhere
sendMouseRelease(&scene, QPoint(-25, -25));
@@ -10255,7 +10255,7 @@ void tst_QGraphicsItem::modality_mouseGrabber()
QCOMPARE(rect2Spy.counts[QEvent::GrabMouse], 0);
QCOMPARE(rect2Spy.counts[QEvent::GraphicsSceneMouseRelease], 0);
QCOMPARE(rect2Spy.counts[QEvent::UngrabMouse], 0);
- QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *) 0);
+ QCOMPARE(scene.mouseGrabberItem(), nullptr);
// pressing mouse on rect1 starts implicit grab on rect2 (since it is modal)
sendMouseClick(&scene, QPoint(-25, -25));
@@ -10285,7 +10285,7 @@ void tst_QGraphicsItem::modality_mouseGrabber()
QCOMPARE(rect1Spy.counts[QEvent::UngrabMouse], 2);
QCOMPARE(rect2Spy.counts[QEvent::GrabMouse], 1);
QCOMPARE(rect2Spy.counts[QEvent::UngrabMouse], 1);
- QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *) 0);
+ QCOMPARE(scene.mouseGrabberItem(), nullptr);
// rect1 does *not* re-grab when rect2 is no longer modal
rect2->setPanelModality(QGraphicsItem::NonModal);
@@ -10293,7 +10293,7 @@ void tst_QGraphicsItem::modality_mouseGrabber()
QCOMPARE(rect1Spy.counts[QEvent::UngrabMouse], 2);
QCOMPARE(rect2Spy.counts[QEvent::GrabMouse], 1);
QCOMPARE(rect2Spy.counts[QEvent::UngrabMouse], 1);
- QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *) 0);
+ QCOMPARE(scene.mouseGrabberItem(), nullptr);
// release goes nowhere
sendMouseRelease(&scene, QPoint(-25, -25));
@@ -10302,7 +10302,7 @@ void tst_QGraphicsItem::modality_mouseGrabber()
QCOMPARE(rect1Spy.counts[QEvent::UngrabMouse], 2);
QCOMPARE(rect2Spy.counts[QEvent::GrabMouse], 1);
QCOMPARE(rect2Spy.counts[QEvent::UngrabMouse], 1);
- QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *) 0);
+ QCOMPARE(scene.mouseGrabberItem(), nullptr);
}
{
// repeat the test using PanelModal
@@ -10325,7 +10325,7 @@ void tst_QGraphicsItem::modality_mouseGrabber()
QCOMPARE(rect1Spy.counts[QEvent::UngrabMouse], 1);
QCOMPARE(rect2Spy.counts[QEvent::GrabMouse], 0);
QCOMPARE(rect2Spy.counts[QEvent::UngrabMouse], 0);
- QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *) 0);
+ QCOMPARE(scene.mouseGrabberItem(), nullptr);
// releasing goes nowhere
sendMouseRelease(&scene, QPoint(-25, -25));
@@ -10335,7 +10335,7 @@ void tst_QGraphicsItem::modality_mouseGrabber()
QCOMPARE(rect2Spy.counts[QEvent::GrabMouse], 0);
QCOMPARE(rect2Spy.counts[QEvent::GraphicsSceneMouseRelease], 0);
QCOMPARE(rect2Spy.counts[QEvent::UngrabMouse], 0);
- QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *) 0);
+ QCOMPARE(scene.mouseGrabberItem(), nullptr);
// pressing mouse on rect1 starts implicit grab on rect2 (since it is modal)
sendMouseClick(&scene, QPoint(-25, -25));
@@ -10365,7 +10365,7 @@ void tst_QGraphicsItem::modality_mouseGrabber()
QCOMPARE(rect1Spy.counts[QEvent::UngrabMouse], 2);
QCOMPARE(rect2Spy.counts[QEvent::GrabMouse], 1);
QCOMPARE(rect2Spy.counts[QEvent::UngrabMouse], 1);
- QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *) 0);
+ QCOMPARE(scene.mouseGrabberItem(), nullptr);
// rect1 does *not* re-grab when rect2 is no longer modal
rect2->setPanelModality(QGraphicsItem::NonModal);
@@ -10373,7 +10373,7 @@ void tst_QGraphicsItem::modality_mouseGrabber()
QCOMPARE(rect1Spy.counts[QEvent::UngrabMouse], 2);
QCOMPARE(rect2Spy.counts[QEvent::GrabMouse], 1);
QCOMPARE(rect2Spy.counts[QEvent::UngrabMouse], 1);
- QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *) 0);
+ QCOMPARE(scene.mouseGrabberItem(), nullptr);
// release goes nowhere
sendMouseRelease(&scene, QPoint(-25, -25));
@@ -10382,7 +10382,7 @@ void tst_QGraphicsItem::modality_mouseGrabber()
QCOMPARE(rect1Spy.counts[QEvent::UngrabMouse], 2);
QCOMPARE(rect2Spy.counts[QEvent::GrabMouse], 1);
QCOMPARE(rect2Spy.counts[QEvent::UngrabMouse], 1);
- QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *) 0);
+ QCOMPARE(scene.mouseGrabberItem(), nullptr);
}
{
@@ -10430,7 +10430,7 @@ void tst_QGraphicsItem::modality_mouseGrabber()
QCOMPARE(rect3Spy.counts[QEvent::GrabMouse], 1);
QCOMPARE(rect3Spy.counts[QEvent::GraphicsSceneMouseRelease], 1);
QCOMPARE(rect3Spy.counts[QEvent::UngrabMouse], 1);
- QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *) 0);
+ QCOMPARE(scene.mouseGrabberItem(), nullptr);
rect2->setPanelModality(QGraphicsItem::NonModal);
@@ -10472,7 +10472,7 @@ void tst_QGraphicsItem::modality_mouseGrabber()
QCOMPARE(rect2Spy.counts[QEvent::UngrabMouse], 0);
QCOMPARE(rect3Spy.counts[QEvent::GrabMouse], 2);
QCOMPARE(rect3Spy.counts[QEvent::UngrabMouse], 2);
- QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *) 0);
+ QCOMPARE(scene.mouseGrabberItem(), nullptr);
}
}
@@ -10512,7 +10512,7 @@ void tst_QGraphicsItem::modality_clickFocus()
// clicking on rect1 should not set it's focus item
rect1->clearFocus();
sendMouseClick(&scene, QPointF(-25, -25));
- QCOMPARE(rect1->focusItem(), (QGraphicsItem *) 0);
+ QCOMPARE(rect1->focusItem(), nullptr);
QCOMPARE(rect1Spy.counts[QEvent::FocusIn], 1);
QCOMPARE(rect1Spy.counts[QEvent::FocusOut], 1);
QCOMPARE(rect2Spy.counts[QEvent::FocusIn], 0);
@@ -10531,7 +10531,7 @@ void tst_QGraphicsItem::modality_clickFocus()
rect1->setActive(true);
rect1->clearFocus();
sendMouseClick(&scene, QPointF(-25, -25));
- QCOMPARE(scene.focusItem(), (QGraphicsItem *) 0);
+ QCOMPARE(scene.focusItem(), nullptr);
QCOMPARE(rect1Spy.counts[QEvent::FocusIn], 2);
QCOMPARE(rect1Spy.counts[QEvent::FocusOut], 2);
QCOMPARE(rect2Spy.counts[QEvent::FocusIn], 1);
@@ -10539,7 +10539,7 @@ void tst_QGraphicsItem::modality_clickFocus()
// focus doesn't change when leaving modality either
rect2->setPanelModality(QGraphicsItem::NonModal);
- QCOMPARE(scene.focusItem(), (QGraphicsItem *) 0);
+ QCOMPARE(scene.focusItem(), nullptr);
QCOMPARE(rect1Spy.counts[QEvent::FocusIn], 2);
QCOMPARE(rect1Spy.counts[QEvent::FocusOut], 2);
QCOMPARE(rect2Spy.counts[QEvent::FocusIn], 1);
@@ -10938,7 +10938,7 @@ void tst_QGraphicsItem::focusHandling()
switch (expectedFocusItem) {
case 0:
- QCOMPARE(scene.focusItem(), static_cast<QGraphicsRectItem *>(0));
+ QCOMPARE(scene.focusItem(), nullptr);
break;
case 1:
QCOMPARE(scene.focusItem(), focusableUnder);
@@ -11304,7 +11304,7 @@ void tst_QGraphicsItem::QT_2649_focusScope()
scope->setFocus();
subFocusItem->setParentItem(scope);
QCOMPARE(subFocusItem->focusItem(), (QGraphicsItem *)subFocusItem);
- QCOMPARE(subFocusItem->focusScopeItem(), (QGraphicsItem *)0);
+ QCOMPARE(subFocusItem->focusScopeItem(), nullptr);
QCOMPARE(scope->focusItem(), (QGraphicsItem *)subFocusItem);
QCOMPARE(scope->focusScopeItem(), (QGraphicsItem *)subFocusItem);
@@ -11312,9 +11312,9 @@ void tst_QGraphicsItem::QT_2649_focusScope()
rootItem->setFlags(QGraphicsItem::ItemIsFocusable);
scope->setParentItem(rootItem);
QCOMPARE(rootItem->focusItem(), (QGraphicsItem *)subFocusItem);
- QCOMPARE(rootItem->focusScopeItem(), (QGraphicsItem *)0);
+ QCOMPARE(rootItem->focusScopeItem(), nullptr);
QCOMPARE(subFocusItem->focusItem(), (QGraphicsItem *)subFocusItem);
- QCOMPARE(subFocusItem->focusScopeItem(), (QGraphicsItem *)0);
+ QCOMPARE(subFocusItem->focusScopeItem(), nullptr);
QCOMPARE(scope->focusItem(), (QGraphicsItem *)subFocusItem);
QCOMPARE(scope->focusScopeItem(), (QGraphicsItem *)subFocusItem);
@@ -11327,19 +11327,19 @@ void tst_QGraphicsItem::QT_2649_focusScope()
QCOMPARE(rootItem->focusItem(), (QGraphicsItem *)subFocusItem);
QCOMPARE(scope->focusItem(), (QGraphicsItem *)subFocusItem);
QCOMPARE(subFocusItem->focusItem(), (QGraphicsItem *)subFocusItem);
- QCOMPARE(rootItem->focusScopeItem(), (QGraphicsItem *)0);
+ QCOMPARE(rootItem->focusScopeItem(), nullptr);
QCOMPARE(scope->focusScopeItem(), (QGraphicsItem *)subFocusItem);
- QCOMPARE(subFocusItem->focusScopeItem(), (QGraphicsItem *)0);
+ QCOMPARE(subFocusItem->focusScopeItem(), nullptr);
QVERIFY(subFocusItem->hasFocus());
scope->hide();
- QCOMPARE(rootItem->focusItem(), (QGraphicsItem *)0);
- QCOMPARE(scope->focusItem(), (QGraphicsItem *)0);
- QCOMPARE(subFocusItem->focusItem(), (QGraphicsItem *)0);
- QCOMPARE(rootItem->focusScopeItem(), (QGraphicsItem *)0);
+ QCOMPARE(rootItem->focusItem(), nullptr);
+ QCOMPARE(scope->focusItem(), nullptr);
+ QCOMPARE(subFocusItem->focusItem(), nullptr);
+ QCOMPARE(rootItem->focusScopeItem(), nullptr);
QCOMPARE(scope->focusScopeItem(), (QGraphicsItem *)subFocusItem);
- QCOMPARE(subFocusItem->focusScopeItem(), (QGraphicsItem *)0);
+ QCOMPARE(subFocusItem->focusScopeItem(), nullptr);
QVERIFY(!subFocusItem->hasFocus());
scope->show();
@@ -11347,9 +11347,9 @@ void tst_QGraphicsItem::QT_2649_focusScope()
QCOMPARE(rootItem->focusItem(), (QGraphicsItem *)subFocusItem);
QCOMPARE(scope->focusItem(), (QGraphicsItem *)subFocusItem);
QCOMPARE(subFocusItem->focusItem(), (QGraphicsItem *)subFocusItem);
- QCOMPARE(rootItem->focusScopeItem(), (QGraphicsItem *)0);
+ QCOMPARE(rootItem->focusScopeItem(), nullptr);
QCOMPARE(scope->focusScopeItem(), (QGraphicsItem *)subFocusItem);
- QCOMPARE(subFocusItem->focusScopeItem(), (QGraphicsItem *)0);
+ QCOMPARE(subFocusItem->focusScopeItem(), nullptr);
QVERIFY(subFocusItem->hasFocus());
// This should not crash
diff --git a/tests/auto/widgets/graphicsview/qgraphicsitemanimation/tst_qgraphicsitemanimation.cpp b/tests/auto/widgets/graphicsview/qgraphicsitemanimation/tst_qgraphicsitemanimation.cpp
index acdd3cff81..dfb2752ee0 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsitemanimation/tst_qgraphicsitemanimation.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsitemanimation/tst_qgraphicsitemanimation.cpp
@@ -151,7 +151,7 @@ void tst_QGraphicsItemAnimation::overwriteValueForStep()
void tst_QGraphicsItemAnimation::setTimeLine()
{
QGraphicsItemAnimation animation;
- QCOMPARE(animation.timeLine(), (QTimeLine *)0);
+ QCOMPARE(animation.timeLine(), nullptr);
QPointer<QTimeLine> line1 = new QTimeLine;
animation.setTimeLine(line1);
@@ -161,7 +161,7 @@ void tst_QGraphicsItemAnimation::setTimeLine()
QCOMPARE(animation.timeLine(), (QTimeLine *)line1);
animation.setTimeLine(0);
- QCOMPARE(animation.timeLine(), (QTimeLine *)0);
+ QCOMPARE(animation.timeLine(), nullptr);
QVERIFY(!line1);
QTimeLine *line2 = new QTimeLine;
@@ -169,7 +169,7 @@ void tst_QGraphicsItemAnimation::setTimeLine()
QCOMPARE(animation.timeLine(), (QTimeLine *)line2);
delete line2;
- QCOMPARE(animation.timeLine(), (QTimeLine *)0);
+ QCOMPARE(animation.timeLine(), nullptr);
}
QTEST_MAIN(tst_QGraphicsItemAnimation)
diff --git a/tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp b/tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp
index 87cd032ad0..cfc18c6e32 100644
--- a/tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicslayout/tst_qgraphicslayout.cpp
@@ -186,10 +186,10 @@ void tst_QGraphicsLayout::automaticReparenting()
l1->addItem(w1);
QGraphicsWidget *w2 = new QGraphicsWidget();
l1->addItem(w2);
- QCOMPARE(w1->parentItem(), static_cast<QGraphicsItem*>(0));
- QCOMPARE(w2->parentItem(), static_cast<QGraphicsItem*>(0));
+ QCOMPARE(w1->parentItem(), nullptr);
+ QCOMPARE(w2->parentItem(), nullptr);
scene.addItem(w1);
- QCOMPARE(w1->parentItem(), static_cast<QGraphicsItem*>(0));
+ QCOMPARE(w1->parentItem(), nullptr);
window->setLayout(l1);
QCOMPARE(w1->parentItem(), static_cast<QGraphicsItem*>(window));
QCOMPARE(w2->parentItem(), static_cast<QGraphicsItem*>(window));
diff --git a/tests/auto/widgets/graphicsview/qgraphicslayoutitem/tst_qgraphicslayoutitem.cpp b/tests/auto/widgets/graphicsview/qgraphicslayoutitem/tst_qgraphicslayoutitem.cpp
index 9b52366855..5b0ceabe62 100644
--- a/tests/auto/widgets/graphicsview/qgraphicslayoutitem/tst_qgraphicslayoutitem.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicslayoutitem/tst_qgraphicslayoutitem.cpp
@@ -94,7 +94,7 @@ void tst_QGraphicsLayoutItem::qgraphicslayoutitem()
QCOMPARE(layoutItem.isLayout(), false);
layoutItem.maximumSize();
layoutItem.minimumSize();
- QCOMPARE(layoutItem.parentLayoutItem(), (QGraphicsLayoutItem*)0);
+ QCOMPARE(layoutItem.parentLayoutItem(), nullptr);
layoutItem.preferredSize();
layoutItem.sizePolicy();
layoutItem.sizeHint(Qt::MinimumSize);
diff --git a/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp b/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
index 5794c32803..322af7c236 100644
--- a/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicslinearlayout/tst_qgraphicslinearlayout.cpp
@@ -800,7 +800,7 @@ void tst_QGraphicsLinearLayout::removeAt()
QCOMPARE(wParent, static_cast<QGraphicsLayoutItem *>(&layout));
layout.removeAt(removeItemAt);
wParent = w->parentLayoutItem();
- QCOMPARE(wParent, static_cast<QGraphicsLayoutItem *>(0));
+ QCOMPARE(wParent, nullptr);
delete w;
}
QCOMPARE(layout.count(), itemCount + layoutCount - (w ? 1 : 0));
diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
index d99c056abe..65c9938f89 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp
@@ -482,7 +482,7 @@ void tst_QGraphicsProxyWidget::setWidget()
QCOMPARE((qreal)bottom, rbottom);
} else {
// proxy shouldn't mess with the widget if it can't insert it.
- QCOMPARE(proxy->widget(), (QWidget*)0);
+ QCOMPARE(proxy->widget(), nullptr);
QCOMPARE(proxy->acceptHoverEvents(), false);
if (subWidget) {
QVERIFY(!subWidget->testAttribute(Qt::WA_DontShowOnScreen));
@@ -493,7 +493,7 @@ void tst_QGraphicsProxyWidget::setWidget()
}
if (widgetExists) {
- QCOMPARE(existingSubWidget->parent(), static_cast<QObject*>(0));
+ QCOMPARE(existingSubWidget->parent(), nullptr);
QVERIFY(!existingSubWidget->testAttribute(Qt::WA_DontShowOnScreen));
QVERIFY(!existingSubWidget->testAttribute(Qt::WA_QuitOnClose));
}
diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
index d95f6e408e..7615c5e821 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
@@ -1539,22 +1539,22 @@ void tst_QGraphicsScene::mouseGrabberItem()
QApplication::sendEvent(&scene, &moveEvent);
QCOMPARE(scene.mouseGrabberItem(), item);
item->setVisible(false);
- QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *)0);
+ QCOMPARE(scene.mouseGrabberItem(), nullptr);
QApplication::sendEvent(&scene, &pressEvent);
QCOMPARE(scene.mouseGrabberItem(), item2);
item2->setVisible(false);
- QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *)0);
+ QCOMPARE(scene.mouseGrabberItem(), nullptr);
QApplication::sendEvent(&scene, &moveEvent);
- QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *)0);
+ QCOMPARE(scene.mouseGrabberItem(), nullptr);
item2->setVisible(true);
QApplication::sendEvent(&scene, &moveEvent);
- QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *)0);
+ QCOMPARE(scene.mouseGrabberItem(), nullptr);
QApplication::sendEvent(&scene, &pressEvent);
QApplication::sendEvent(&scene, &moveEvent);
QCOMPARE(scene.mouseGrabberItem(), item2);
scene.removeItem(item2);
delete item2;
- QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *)0);
+ QCOMPARE(scene.mouseGrabberItem(), nullptr);
}
void tst_QGraphicsScene::hoverEvents_siblings()
@@ -1757,7 +1757,7 @@ void tst_QGraphicsScene::createItemGroup()
// These share no common parent
group = scene.createItemGroup(children3);
- QCOMPARE(group->parentItem(), (QGraphicsItem *)0);
+ QCOMPARE(group->parentItem(), nullptr);
scene.destroyItemGroup(group);
// Make children3 children of parent3
@@ -1886,7 +1886,7 @@ void tst_QGraphicsScene::mouseEventPropagation()
QCOMPARE(c->eventTypes.size(), 0);
QCOMPARE(b->eventTypes.size(), 0);
QCOMPARE(a->eventTypes.size(), 0);
- QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *)0);
+ QCOMPARE(scene.mouseGrabberItem(), nullptr);
d->setAcceptedMouseButtons(Qt::RightButton);
@@ -1927,7 +1927,7 @@ void tst_QGraphicsScene::mouseEventPropagation()
QCOMPARE(c->eventTypes.at(5), QEvent::UngrabMouse);
QCOMPARE(b->eventTypes.size(), 0);
QCOMPARE(a->eventTypes.size(), 0);
- QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *)0);
+ QCOMPARE(scene.mouseGrabberItem(), nullptr);
// Disabled items eat events. c should not get this.
d->setEnabled(false);
@@ -1939,7 +1939,7 @@ void tst_QGraphicsScene::mouseEventPropagation()
QCOMPARE(c->eventTypes.size(), 6);
QCOMPARE(b->eventTypes.size(), 0);
QCOMPARE(a->eventTypes.size(), 0);
- QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *)0);
+ QCOMPARE(scene.mouseGrabberItem(), nullptr);
// Send a left press. This goes to c.
pressEvent.setButton(Qt::LeftButton);
@@ -4609,7 +4609,7 @@ void tst_QGraphicsScene::focusItemChangedSignal()
QList<QVariant> arguments = spy.takeFirst();
QCOMPARE(arguments.size(), 3);
QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(0)), (QGraphicsItem *)topLevelItem2);
- QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(1)), (QGraphicsItem *)0);
+ QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(1)), nullptr);
QCOMPARE(qvariant_cast<Qt::FocusReason>(arguments.at(2)), Qt::OtherFocusReason);
QVERIFY(topLevelItem2->hasFocus());
@@ -4617,7 +4617,7 @@ void tst_QGraphicsScene::focusItemChangedSignal()
QCOMPARE(spy.count(), 1);
arguments = spy.takeFirst();
QCOMPARE(arguments.size(), 3);
- QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(0)), (QGraphicsItem *)0);
+ QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(0)), nullptr);
QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(1)), (QGraphicsItem *)topLevelItem2);
QCOMPARE(qvariant_cast<Qt::FocusReason>(arguments.at(2)), Qt::OtherFocusReason);
@@ -4626,7 +4626,7 @@ void tst_QGraphicsScene::focusItemChangedSignal()
arguments = spy.takeFirst();
QCOMPARE(arguments.size(), 3);
QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(0)), (QGraphicsItem *)topLevelItem2);
- QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(1)), (QGraphicsItem *)0);
+ QCOMPARE(qvariant_cast<QGraphicsItem *>(arguments.at(1)), nullptr);
QCOMPARE(qvariant_cast<Qt::FocusReason>(arguments.at(2)), Qt::MenuBarFocusReason);
for (int i = 0; i < 3; ++i) {
diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
index 2e76ea3bb3..c8bdcbde09 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp
@@ -489,7 +489,7 @@ void tst_QGraphicsView::scene()
QCOMPARE(view.scene(), &scene);
}
- QCOMPARE(view.scene(), (QGraphicsScene *)0);
+ QCOMPARE(view.scene(), nullptr);
}
void tst_QGraphicsView::setScene()
@@ -529,9 +529,9 @@ void tst_QGraphicsView::deleteScene()
QGraphicsView view3(scene);
view3.show();
delete scene;
- QCOMPARE(view1.scene(), (QGraphicsScene *)0);
- QCOMPARE(view2.scene(), (QGraphicsScene *)0);
- QCOMPARE(view3.scene(), (QGraphicsScene *)0);
+ QCOMPARE(view1.scene(), nullptr);
+ QCOMPARE(view2.scene(), nullptr);
+ QCOMPARE(view3.scene(), nullptr);
}
void tst_QGraphicsView::sceneRect()
diff --git a/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp
index 9e390e45a6..1be17b552e 100644
--- a/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp
@@ -287,14 +287,14 @@ void tst_QGraphicsWidget::qgraphicswidget()
QVERIFY(!widget.isWindow());
QCOMPARE(widget.boundingRect(), QRectF(0, 0, 0, 0));
- QCOMPARE(widget.focusWidget(), (QGraphicsWidget*)0);
+ QCOMPARE(widget.focusWidget(), nullptr);
QCOMPARE(widget.focusPolicy(), Qt::NoFocus);
QCOMPARE(widget.font(), QFont());
QCOMPARE(widget.geometry(), QRectF(widget.pos(), widget.size()));
- QCOMPARE(widget.layout(), (QGraphicsLayout*)0);
+ QCOMPARE(widget.layout(), nullptr);
QCOMPARE(widget.layoutDirection(), Qt::LeftToRight);
QCOMPARE(widget.palette(), QPalette());
- QCOMPARE(widget.parentWidget(), (QGraphicsWidget*)0);
+ QCOMPARE(widget.parentWidget(), nullptr);
QCOMPARE(widget.rect(), QRectF(QPointF(), widget.size()));
QCOMPARE(widget.size(), QSizeF(0, 0));
QVERIFY(widget.style() != (QStyle*)0);
@@ -415,7 +415,7 @@ void tst_QGraphicsWidget::focusWidget_data()
void tst_QGraphicsWidget::focusWidget()
{
SubQGraphicsWidget *parent = new SubQGraphicsWidget;
- QCOMPARE(parent->focusWidget(), (QGraphicsWidget *)0);
+ QCOMPARE(parent->focusWidget(), nullptr);
QGraphicsScene scene;
QEvent windowActivate(QEvent::WindowActivate);
qApp->sendEvent(&scene, &windowActivate);
@@ -1131,7 +1131,7 @@ void tst_QGraphicsWidget::layout()
{
SubQGraphicsWidget widget;
widget.setContentsMargins(10, 5, 50, 100);
- QCOMPARE(widget.layout(), (QGraphicsLayout *)0);
+ QCOMPARE(widget.layout(), nullptr);
QFETCH(int, childCount);
QGraphicsLinearLayout *layout = new QGraphicsLinearLayout;
@@ -1292,9 +1292,9 @@ void tst_QGraphicsWidget::parentWidget()
SubQGraphicsWidget widgetChild(&standAlongWidget);
SubQGraphicsWidget itemChild(&standAlongItem);
- QCOMPARE(standAlongWidget.parentWidget(), (QGraphicsWidget*)0);
+ QCOMPARE(standAlongWidget.parentWidget(), nullptr);
QCOMPARE(widgetChild.parentWidget(), static_cast<QGraphicsWidget*>(&standAlongWidget));
- QCOMPARE(itemChild.parentWidget(), (QGraphicsWidget*)0);
+ QCOMPARE(itemChild.parentWidget(), nullptr);
for (int i = 0; i < childrenCount; ++i) {
SubQGraphicsWidget *item = new SubQGraphicsWidget(&standAlongWidget);
@@ -1497,7 +1497,7 @@ void tst_QGraphicsWidget::setTabOrderAndReparent()
w[2]->setFocus();
QVERIFY2(compareFocusChain(&view, w + 2, w + 3, &errorMessage), errorMessage.constData());
w[2]->setParentItem(p);
- QCOMPARE(scene.focusItem(), static_cast<QGraphicsItem*>(0));
+ QCOMPARE(scene.focusItem(), nullptr);
scene.addItem(p);
p->setFocus();
@@ -2117,7 +2117,7 @@ void tst_QGraphicsWidget::explicitMouseGrabber()
QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *)widget);
QCOMPARE(widgetGrabEventSpy.count(), 1);
widget->ungrabMouse();
- QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *)0);
+ QCOMPARE(scene.mouseGrabberItem(), nullptr);
QCOMPARE(widgetUngrabEventSpy.count(), 1);
// Grab while grabbing
@@ -2165,7 +2165,7 @@ void tst_QGraphicsWidget::explicitMouseGrabber()
QCOMPARE(widgetGrabEventSpy.count(), 4);
QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *)widget);
widget->ungrabMouse();
- QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *)0);
+ QCOMPARE(scene.mouseGrabberItem(), nullptr);
// Out of order ungrab
widget->grabMouse();
@@ -2210,7 +2210,7 @@ void tst_QGraphicsWidget::implicitMouseGrabber()
event.setScenePos(QPointF(50, 50));
qApp->sendEvent(&scene, &event);
}
- QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *)0);
+ QCOMPARE(scene.mouseGrabberItem(), nullptr);
QCOMPARE(widgetGrabEventSpy.count(), 1);
QCOMPARE(widgetUngrabEventSpy.count(), 1);
@@ -2238,7 +2238,7 @@ void tst_QGraphicsWidget::implicitMouseGrabber()
QCOMPARE(widgetUngrabEventSpy.count(), 1);
widget->ungrabMouse();
QCOMPARE(widgetUngrabEventSpy.count(), 2);
- QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *)0);
+ QCOMPARE(scene.mouseGrabberItem(), nullptr);
// Implicit mouse grabber tries to explicitly grab the mouse
{
@@ -2263,7 +2263,7 @@ void tst_QGraphicsWidget::implicitMouseGrabber()
QCOMPARE(widgetGrabEventSpy.count(), 3);
QCOMPARE(widgetUngrabEventSpy.count(), 2);
widget->ungrabMouse();
- QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *)0);
+ QCOMPARE(scene.mouseGrabberItem(), nullptr);
QCOMPARE(widgetGrabEventSpy.count(), 3);
QCOMPARE(widgetUngrabEventSpy.count(), 3);
@@ -2293,7 +2293,7 @@ void tst_QGraphicsWidget::implicitMouseGrabber()
scene.removeItem(widget);
QCOMPARE(widgetUngrabEventSpy.count(), 4);
- QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *)0);
+ QCOMPARE(scene.mouseGrabberItem(), nullptr);
}
class GrabOnPressItem : public QGraphicsRectItem
@@ -2367,7 +2367,7 @@ void tst_QGraphicsWidget::doubleClickAfterExplicitMouseGrab()
event.setScenePos(QPointF(50, 50));
qApp->sendEvent(&scene, &event);
}
- QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *)0);
+ QCOMPARE(scene.mouseGrabberItem(), nullptr);
QCOMPARE(item->nrelease, 1);
QCOMPARE(item->nungrab, 1);
{
@@ -2389,7 +2389,7 @@ void tst_QGraphicsWidget::doubleClickAfterExplicitMouseGrab()
event.setScenePos(QPointF(50, 50));
qApp->sendEvent(&scene, &event);
}
- QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *)0);
+ QCOMPARE(scene.mouseGrabberItem(), nullptr);
QCOMPARE(item->nrelease, 2);
QCOMPARE(item->nungrab, 2);
}
@@ -2411,7 +2411,7 @@ void tst_QGraphicsWidget::popupMouseGrabber()
// Hiding it loses the grab again.
widget->hide();
QCOMPARE(widgetUngrabEventSpy.count(), 1);
- QCOMPARE(scene.mouseGrabberItem(), (QGraphicsItem *)0);
+ QCOMPARE(scene.mouseGrabberItem(), nullptr);
// Showing it grabs the mouse again
widget->show();
diff --git a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
index 5567641dde..bd6733e2d0 100644
--- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
+++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
@@ -558,7 +558,7 @@ void tst_QAbstractItemView::noModel()
view.setModel(0);
// Due to the model is removed, this will generate a valueChanged signal on both scrollbars. (value to 0)
QApplication::processEvents();
- QCOMPARE(view.model(), (QAbstractItemModel*)0);
+ QCOMPARE(view.model(), nullptr);
}
void tst_QAbstractItemView::dragSelect()
diff --git a/tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp b/tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp
index e6c4ab44f8..62acf49f4a 100644
--- a/tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp
+++ b/tests/auto/widgets/itemviews/qcolumnview/tst_qcolumnview.cpp
@@ -770,15 +770,15 @@ void tst_QColumnView::gripMoved()
void tst_QColumnView::preview()
{
QColumnView view;
- QCOMPARE(view.previewWidget(), (QWidget*)0);
+ QCOMPARE(view.previewWidget(), nullptr);
TreeModel model;
view.setModel(&model);
- QCOMPARE(view.previewWidget(), (QWidget*)0);
+ QCOMPARE(view.previewWidget(), nullptr);
QModelIndex home = model.index(0, 0);
QVERIFY(home.isValid());
QVERIFY(model.hasChildren(home));
view.setCurrentIndex(home);
- QCOMPARE(view.previewWidget(), (QWidget*)0);
+ QCOMPARE(view.previewWidget(), nullptr);
QModelIndex file;
QVERIFY(model.rowCount(home) > 0);
diff --git a/tests/auto/widgets/itemviews/qdatawidgetmapper/tst_qdatawidgetmapper.cpp b/tests/auto/widgets/itemviews/qdatawidgetmapper/tst_qdatawidgetmapper.cpp
index ea88020a56..5ab0a226b7 100644
--- a/tests/auto/widgets/itemviews/qdatawidgetmapper/tst_qdatawidgetmapper.cpp
+++ b/tests/auto/widgets/itemviews/qdatawidgetmapper/tst_qdatawidgetmapper.cpp
@@ -79,7 +79,7 @@ void tst_QDataWidgetMapper::setModel()
{
QDataWidgetMapper mapper;
- QCOMPARE(mapper.model(), (QAbstractItemModel *)0);
+ QCOMPARE(mapper.model(), nullptr);
{ // let the model go out of scope firstma
QStandardItemModel model;
@@ -87,7 +87,7 @@ void tst_QDataWidgetMapper::setModel()
QCOMPARE(mapper.model(), static_cast<QAbstractItemModel *>(&model));
}
- QCOMPARE(mapper.model(), (QAbstractItemModel *)0);
+ QCOMPARE(mapper.model(), nullptr);
{ // let the mapper go out of scope first
QStandardItemModel model2;
@@ -263,7 +263,7 @@ void tst_QDataWidgetMapper::addMapping()
QCOMPARE(edit2.text(), QString("item 0 2"));
} // let the edit go out of scope
- QCOMPARE(mapper.mappedWidgetAt(2), (QWidget *)0);
+ QCOMPARE(mapper.mappedWidgetAt(2), nullptr);
mapper.toLast();
}
@@ -400,7 +400,7 @@ void tst_QDataWidgetMapper::mappedWidgetAt()
QLineEdit lineEdit1;
QLineEdit lineEdit2;
- QCOMPARE(mapper.mappedWidgetAt(432312), (QWidget*)0);
+ QCOMPARE(mapper.mappedWidgetAt(432312), nullptr);
mapper.addMapping(&lineEdit1, 1);
mapper.addMapping(&lineEdit2, 2);
@@ -410,7 +410,7 @@ void tst_QDataWidgetMapper::mappedWidgetAt()
mapper.addMapping(&lineEdit2, 4242);
- QCOMPARE(mapper.mappedWidgetAt(2), (QWidget*)0);
+ QCOMPARE(mapper.mappedWidgetAt(2), nullptr);
QCOMPARE(mapper.mappedWidgetAt(4242), static_cast<QWidget *>(&lineEdit2));
}
diff --git a/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp b/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp
index e8bd86bee5..eb93e4c167 100644
--- a/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp
+++ b/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp
@@ -193,7 +193,7 @@ void tst_QListWidget::init()
void tst_QListWidget::checkDefaultValues()
{
- QCOMPARE(testWidget->currentItem(), (QListWidgetItem *)0);
+ QCOMPARE(testWidget->currentItem(), nullptr);
QCOMPARE(testWidget->currentRow(), -1);
QCOMPARE(testWidget->count(), 0);
}
@@ -413,7 +413,7 @@ void tst_QListWidget::currentItem()
if (currentIndex.isValid())
QCOMPARE(testWidget->currentItem(), testWidget->item(currentIndex.row()));
else
- QCOMPARE(testWidget->currentItem(), (QListWidgetItem*)0);
+ QCOMPARE(testWidget->currentItem(), nullptr);
}
void tst_QListWidget::currentRow()
@@ -631,7 +631,7 @@ void tst_QListWidget::item()
QListWidgetItem *item = testWidget->item(row);
if (outOfBounds) {
- QCOMPARE(item, static_cast<QListWidgetItem*>(0));
+ QCOMPARE(item, nullptr);
QCOMPARE(testWidget->count(), 3);
} else {
QCOMPARE(item->text(), QStringLiteral("item") + QString::number(row));
@@ -664,7 +664,7 @@ void tst_QListWidget::takeItem()
QListWidgetItem *item = testWidget->takeItem(row);
if (outOfBounds) {
- QCOMPARE(item, static_cast<QListWidgetItem*>(0));
+ QCOMPARE(item, nullptr);
QCOMPARE(testWidget->count(), 3);
} else {
QCOMPARE(item->text(), QStringLiteral("item") + QString::number(row));
@@ -1445,11 +1445,11 @@ void tst_QListWidget::itemWidget()
QListWidgetItem *item = new QListWidgetItem(&list);
- QCOMPARE(list.itemWidget(item), static_cast<QWidget*>(0));
+ QCOMPARE(list.itemWidget(item), nullptr);
list.setItemWidget(item, &widget);
QCOMPARE(list.itemWidget(item), &widget);
list.removeItemWidget(item);
- QCOMPARE(list.itemWidget(item), static_cast<QWidget*>(0));
+ QCOMPARE(list.itemWidget(item), nullptr);
}
#ifndef Q_OS_MAC
@@ -1672,16 +1672,16 @@ void tst_QListWidget::mimeData()
QMimeData *data;
- QVERIFY(data = list.mimeData(tableWidgetItemList));
+ QVERIFY((data = list.mimeData(tableWidgetItemList)));
delete data;
- QVERIFY(data = list.model()->mimeData(modelIndexList));
+ QVERIFY((data = list.model()->mimeData(modelIndexList)));
delete data;
- QVERIFY(data = list.model()->mimeData(modelIndexList));
+ QVERIFY((data = list.model()->mimeData(modelIndexList)));
delete data;
- QVERIFY(data = list.mimeData(tableWidgetItemList));
+ QVERIFY((data = list.mimeData(tableWidgetItemList)));
delete data;
// check the saved data is actually the same
diff --git a/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp b/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp
index 8f871b03f6..4d4a95b3f5 100644
--- a/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp
+++ b/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp
@@ -809,13 +809,13 @@ void tst_QTableWidget::itemOwnership()
headerItem = new QObjectTableItem();
testWidget->setVerticalHeaderItem(0, headerItem);
delete headerItem;
- QCOMPARE(testWidget->verticalHeaderItem(0), (QTableWidgetItem *)0);
+ QCOMPARE(testWidget->verticalHeaderItem(0), nullptr);
//delete horizontal headeritem from outside
headerItem = new QObjectTableItem();
testWidget->setHorizontalHeaderItem(0, headerItem);
delete headerItem;
- QCOMPARE(testWidget->horizontalHeaderItem(0), (QTableWidgetItem *)0);
+ QCOMPARE(testWidget->horizontalHeaderItem(0), nullptr);
//setItem
item = new QObjectTableItem();
@@ -1520,16 +1520,16 @@ void tst_QTableWidget::mimeData()
QMimeData *data;
- QVERIFY(data = table.mimeData(tableWidgetItemList));
+ QVERIFY((data = table.mimeData(tableWidgetItemList)));
delete data;
- QVERIFY(data = table.model()->mimeData(modelIndexList));
+ QVERIFY((data = table.model()->mimeData(modelIndexList)));
delete data;
- QVERIFY(data = table.model()->mimeData(modelIndexList));
+ QVERIFY((data = table.model()->mimeData(modelIndexList)));
delete data;
- QVERIFY(data = table.mimeData(tableWidgetItemList));
+ QVERIFY((data = table.mimeData(tableWidgetItemList)));
delete data;
// check the saved data is actually the same
diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
index c7b7ffaf95..80ef0879cc 100644
--- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
+++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp
@@ -1107,10 +1107,10 @@ void tst_QTreeView::setModel()
{
QTreeView view;
view.show();
- QCOMPARE(view.model(), (QAbstractItemModel*)0);
- QCOMPARE(view.selectionModel(), (QItemSelectionModel*)0);
- QCOMPARE(view.header()->model(), (QAbstractItemModel*)0);
- QCOMPARE(view.header()->selectionModel(), (QItemSelectionModel*)0);
+ QCOMPARE(view.model(), nullptr);
+ QCOMPARE(view.selectionModel(), nullptr);
+ QCOMPARE(view.header()->model(), nullptr);
+ QCOMPARE(view.header()->selectionModel(), nullptr);
for (int x = 0; x < 2; ++x) {
QtTestModel *model = new QtTestModel(10, 8);
@@ -1131,9 +1131,9 @@ void tst_QTreeView::setModel()
QTRY_COMPARE(modelDestroyedSpy.count(), 0);
view.setModel(0);
- QCOMPARE(view.model(), (QAbstractItemModel*)0);
+ QCOMPARE(view.model(), nullptr);
// ### shouldn't selectionModel also be 0 now?
-// QCOMPARE(view.selectionModel(), (QItemSelectionModel*)0);
+// QCOMPARE(view.selectionModel(), nullptr);
delete model;
}
}
@@ -1283,7 +1283,7 @@ void tst_QTreeView::noDelegate()
QTreeView view;
view.setModel(&model);
view.setItemDelegate(0);
- QCOMPARE(view.itemDelegate(), (QAbstractItemDelegate *)0);
+ QCOMPARE(view.itemDelegate(), nullptr);
}
void tst_QTreeView::noModel()
diff --git a/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp b/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp
index f1e8c7c814..fcffaa0eb9 100644
--- a/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp
+++ b/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp
@@ -194,7 +194,7 @@ void tst_QTreeWidget::getSetCheck()
QCOMPARE(obj1.headerItem(), var2);
obj1.setHeaderItem((QTreeWidgetItem *)0);
-// QCOMPARE(obj1.headerItem(), (QTreeWidgetItem *)0);
+// QCOMPARE(obj1.headerItem(), nullptr);
// QTreeWidgetItem * QTreeWidget::currentItem()
// void QTreeWidget::setCurrentItem(QTreeWidgetItem *)
@@ -203,7 +203,7 @@ void tst_QTreeWidget::getSetCheck()
QCOMPARE(obj1.currentItem(), var3);
obj1.setCurrentItem((QTreeWidgetItem *)0);
- QCOMPARE(obj1.currentItem(), (QTreeWidgetItem *)0);
+ QCOMPARE(obj1.currentItem(), nullptr);
}
typedef QList<int> IntList;
@@ -285,9 +285,9 @@ void tst_QTreeWidget::addTopLevelItem()
tree.addTopLevelItem(ti);
QCOMPARE(tree.topLevelItemCount(), i+1);
QCOMPARE(tree.topLevelItem(i), ti);
- QCOMPARE(tree.topLevelItem(-1), static_cast<TreeItem*>(0));
+ QCOMPARE(tree.topLevelItem(-1), nullptr);
QCOMPARE(tree.indexOfTopLevelItem(ti), i);
- QCOMPARE(ti->parent(), static_cast<TreeItem*>(0));
+ QCOMPARE(ti->parent(), nullptr);
tree.addTopLevelItem(ti);
QCOMPARE(tree.topLevelItemCount(), i+1);
tops.append(ti);
@@ -419,7 +419,7 @@ void tst_QTreeWidget::currentItem()
// can't set the headerItem to be the current item
tree.setCurrentItem(tree.headerItem());
- QCOMPARE(tree.currentItem(), static_cast<TreeItem*>(0));
+ QCOMPARE(tree.currentItem(), nullptr);
}
void tst_QTreeWidget::editItem_data()
@@ -520,7 +520,7 @@ void tst_QTreeWidget::takeItem()
int count = testWidget->topLevelItemCount();
QTreeWidgetItem *item = testWidget->takeTopLevelItem(index);
if (outOfBounds) {
- QCOMPARE(item, (QTreeWidgetItem *)0);
+ QCOMPARE(item, nullptr);
QCOMPARE(count, testWidget->topLevelItemCount());
} else {
QCOMPARE(item->text(0), QStringLiteral("top") + QString::number(index));
@@ -531,7 +531,7 @@ void tst_QTreeWidget::takeItem()
int count = testWidget->topLevelItem(0)->childCount();
QTreeWidgetItem *item = testWidget->topLevelItem(0)->takeChild(index);
if (outOfBounds) {
- QCOMPARE(item, (QTreeWidgetItem *)0);
+ QCOMPARE(item, nullptr);
QCOMPARE(count, testWidget->topLevelItem(0)->childCount());
} else {
QCOMPARE(item->text(0), QStringLiteral("child") + QString::number(index));
@@ -1664,8 +1664,8 @@ void tst_QTreeWidget::addChild()
QCOMPARE(taken, children);
QCOMPARE(item->childCount(), 0);
for (int i = 0; i < taken.count(); ++i) {
- QCOMPARE(taken.at(i)->parent(), static_cast<QTreeWidgetItem*>(0));
- QCOMPARE(taken.at(i)->treeWidget(), static_cast<QTreeWidget*>(0));
+ QCOMPARE(taken.at(i)->parent(), nullptr);
+ QCOMPARE(taken.at(i)->treeWidget(), nullptr);
item->addChild(taken.at(i)); // re-add
}
diff --git a/tests/auto/widgets/itemviews/qtreewidgetitemiterator/tst_qtreewidgetitemiterator.cpp b/tests/auto/widgets/itemviews/qtreewidgetitemiterator/tst_qtreewidgetitemiterator.cpp
index f08e57c84b..c2c02f3766 100644
--- a/tests/auto/widgets/itemviews/qtreewidgetitemiterator/tst_qtreewidgetitemiterator.cpp
+++ b/tests/auto/widgets/itemviews/qtreewidgetitemiterator/tst_qtreewidgetitemiterator.cpp
@@ -1160,7 +1160,7 @@ void tst_QTreeWidgetItemIterator::updateIteratorAfterDeletedItem_and_ContinueIte
delete item;
it+=iterator_advance_after_removal;
if (iterator_new_value.isNull()) {
- QCOMPARE((*it), (QTreeWidgetItem*)0);
+ QCOMPARE((*it), nullptr);
} else {
QCOMPARE((*it)->text(0), iterator_new_value);
}
@@ -1202,7 +1202,7 @@ void tst_QTreeWidgetItemIterator::initializeIterator()
QTreeWidget tw;
QTreeWidgetItemIterator it(&tw);
- QCOMPARE((*it), static_cast<QTreeWidgetItem*>(0));
+ QCOMPARE((*it), nullptr);
}
void tst_QTreeWidgetItemIterator::sortingEnabled()
diff --git a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
index 01e3d7bac0..d8239b5a28 100644
--- a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
+++ b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
@@ -43,6 +43,10 @@
#include <qformlayout.h>
+// ItemRole has enumerators for numerical values 0..2, thus the only
+// valid numerical values for storing into an ItemRole variable are 0..3:
+Q_CONSTEXPR QFormLayout::ItemRole invalidRole = QFormLayout::ItemRole(3);
+
static inline void setFrameless(QWidget *w)
{
Qt::WindowFlags flags = w->windowFlags();
@@ -567,7 +571,7 @@ void tst_QFormLayout::insertRow_QWidget_QWidget()
{
int row = -1;
- QFormLayout::ItemRole role = QFormLayout::ItemRole(-123);
+ QFormLayout::ItemRole role = invalidRole;
layout->getWidgetPosition(lbl1, &row, &role);
QCOMPARE(row, 0);
QCOMPARE(int(role), int(QFormLayout::LabelRole));
@@ -575,7 +579,7 @@ void tst_QFormLayout::insertRow_QWidget_QWidget()
{
int row = -1;
- QFormLayout::ItemRole role = QFormLayout::ItemRole(-123);
+ QFormLayout::ItemRole role = invalidRole;
layout->getWidgetPosition(fld1, &row, &role);
QCOMPARE(row, 0);
QCOMPARE(int(role), int(QFormLayout::FieldRole));
@@ -636,7 +640,7 @@ void tst_QFormLayout::insertRow_QWidget_QLayout()
{
int row = -1;
- QFormLayout::ItemRole role = QFormLayout::ItemRole(-123);
+ QFormLayout::ItemRole role = invalidRole;
layout->getWidgetPosition(lbl1, &row, &role);
QCOMPARE(row, 0);
QCOMPARE(int(role), int(QFormLayout::LabelRole));
@@ -644,7 +648,7 @@ void tst_QFormLayout::insertRow_QWidget_QLayout()
{
int row = -1;
- QFormLayout::ItemRole role = QFormLayout::ItemRole(-123);
+ QFormLayout::ItemRole role = invalidRole;
layout->getLayoutPosition(fld1, &row, &role);
QCOMPARE(row, 0);
QCOMPARE(int(role), int(QFormLayout::FieldRole));
@@ -992,7 +996,7 @@ void tst_QFormLayout::setWidget()
{
int row = -1;
- QFormLayout::ItemRole role = QFormLayout::ItemRole(-123);
+ QFormLayout::ItemRole role = invalidRole;
layout.getWidgetPosition(&w1, &row, &role);
QCOMPARE(row, 5);
QCOMPARE(int(role), int(QFormLayout::LabelRole));
@@ -1000,7 +1004,7 @@ void tst_QFormLayout::setWidget()
{
int row = -1;
- QFormLayout::ItemRole role = QFormLayout::ItemRole(-123);
+ QFormLayout::ItemRole role = invalidRole;
layout.getWidgetPosition(&w2, &row, &role);
QCOMPARE(row, 3);
QCOMPARE(int(role), int(QFormLayout::FieldRole));
@@ -1008,7 +1012,7 @@ void tst_QFormLayout::setWidget()
{
int row = -1;
- QFormLayout::ItemRole role = QFormLayout::ItemRole(-123);
+ QFormLayout::ItemRole role = invalidRole;
layout.getWidgetPosition(&w3, &row, &role);
QCOMPARE(row, 3);
QCOMPARE(int(role), int(QFormLayout::LabelRole));
@@ -1016,18 +1020,20 @@ void tst_QFormLayout::setWidget()
{
int row = -1;
- QFormLayout::ItemRole role = QFormLayout::ItemRole(-123);
+ QFormLayout::ItemRole role = invalidRole;
layout.getWidgetPosition(&w4, &row, &role);
+ // not found
QCOMPARE(row, -1);
- QCOMPARE(int(role), -123);
+ QCOMPARE(int(role), int(invalidRole));
}
{
int row = -1;
- QFormLayout::ItemRole role = QFormLayout::ItemRole(-123);
+ QFormLayout::ItemRole role = invalidRole;
layout.getWidgetPosition(0, &row, &role);
+ // not found
QCOMPARE(row, -1);
- QCOMPARE(int(role), -123);
+ QCOMPARE(int(role), int(invalidRole));
}
}
@@ -1060,7 +1066,7 @@ void tst_QFormLayout::setLayout()
{
int row = -1;
- QFormLayout::ItemRole role = QFormLayout::ItemRole(-123);
+ QFormLayout::ItemRole role = invalidRole;
layout.getLayoutPosition(&l1, &row, &role);
QCOMPARE(row, 5);
QCOMPARE(int(role), int(QFormLayout::LabelRole));
@@ -1068,7 +1074,7 @@ void tst_QFormLayout::setLayout()
{
int row = -1;
- QFormLayout::ItemRole role = QFormLayout::ItemRole(-123);
+ QFormLayout::ItemRole role = invalidRole;
layout.getLayoutPosition(&l2, &row, &role);
QCOMPARE(row, 3);
QCOMPARE(int(role), int(QFormLayout::FieldRole));
@@ -1076,7 +1082,7 @@ void tst_QFormLayout::setLayout()
{
int row = -1;
- QFormLayout::ItemRole role = QFormLayout::ItemRole(-123);
+ QFormLayout::ItemRole role = invalidRole;
layout.getLayoutPosition(&l3, &row, &role);
QCOMPARE(row, 3);
QCOMPARE(int(role), int(QFormLayout::LabelRole));
@@ -1084,18 +1090,18 @@ void tst_QFormLayout::setLayout()
{
int row = -1;
- QFormLayout::ItemRole role = QFormLayout::ItemRole(-123);
+ QFormLayout::ItemRole role = invalidRole;
layout.getLayoutPosition(&l4, &row, &role);
QCOMPARE(row, -1);
- QCOMPARE(int(role), -123);
+ QCOMPARE(int(role), int(invalidRole));
}
{
int row = -1;
- QFormLayout::ItemRole role = QFormLayout::ItemRole(-123);
+ QFormLayout::ItemRole role = invalidRole;
layout.getLayoutPosition(0, &row, &role);
QCOMPARE(row, -1);
- QCOMPARE(int(role), -123);
+ QCOMPARE(int(role), int(invalidRole));
}
}
diff --git a/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp b/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp
index 47fc002196..829d0ea098 100644
--- a/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp
+++ b/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp
@@ -297,7 +297,7 @@ void tst_QLayout::warnIfWrongParent()
QHBoxLayout lay;
lay.setParent(&root);
QTest::ignoreMessage(QtWarningMsg, "QLayout::parentWidget: A layout can only have another layout as a parent.");
- QCOMPARE(lay.parentWidget(), static_cast<QWidget*>(0));
+ QCOMPARE(lay.parentWidget(), nullptr);
}
void tst_QLayout::controlTypes()
diff --git a/tests/auto/widgets/kernel/qstackedlayout/tst_qstackedlayout.cpp b/tests/auto/widgets/kernel/qstackedlayout/tst_qstackedlayout.cpp
index badeca69bb..835b6ca799 100644
--- a/tests/auto/widgets/kernel/qstackedlayout/tst_qstackedlayout.cpp
+++ b/tests/auto/widgets/kernel/qstackedlayout/tst_qstackedlayout.cpp
@@ -122,7 +122,7 @@ void tst_QStackedLayout::testCase()
// Nothing in layout
QCOMPARE(testLayout->currentIndex(), -1);
- QCOMPARE(testLayout->currentWidget(), static_cast<QWidget*>(0));
+ QCOMPARE(testLayout->currentWidget(), nullptr);
QCOMPARE(testLayout->count(), 0);
// One widget added to layout
@@ -163,7 +163,7 @@ void tst_QStackedLayout::testCase()
QCOMPARE(spy.at(0).at(0).toInt(), -1);
spy.clear();
QCOMPARE(testLayout->currentIndex(), -1);
- QCOMPARE(testLayout->currentWidget(), static_cast<QWidget*>(0));
+ QCOMPARE(testLayout->currentWidget(), nullptr);
QCOMPARE(testLayout->count(), 0);
// Another widget inserted at current index.
@@ -217,7 +217,7 @@ void tst_QStackedLayout::testCase()
QVERIFY(w3->isVisible());
testLayout->removeWidget(w3);
QCOMPARE(testLayout->currentIndex(), -1);
- QCOMPARE(testLayout->currentWidget(), static_cast<QWidget*>(0));
+ QCOMPARE(testLayout->currentWidget(), nullptr);
}
void tst_QStackedLayout::deleteCurrent()
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index 28849e345b..54f1a1bf1e 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -2188,8 +2188,8 @@ void tst_QWidget::showMinimizedKeepsFocus()
QTRY_COMPARE(qApp->focusWidget(), child);
delete child;
- QCOMPARE(window.focusWidget(), static_cast<QWidget*>(0));
- QCOMPARE(qApp->focusWidget(), static_cast<QWidget*>(0));
+ QCOMPARE(window.focusWidget(), nullptr);
+ QCOMPARE(QApplication::focusWidget(), nullptr);
}
//testing reparenting the focus widget
@@ -2207,8 +2207,8 @@ void tst_QWidget::showMinimizedKeepsFocus()
child->setParent(0);
QScopedPointer<QWidget> childGuard(child);
- QCOMPARE(window.focusWidget(), static_cast<QWidget*>(0));
- QCOMPARE(qApp->focusWidget(), static_cast<QWidget*>(0));
+ QCOMPARE(window.focusWidget(), nullptr);
+ QCOMPARE(QApplication::focusWidget(), nullptr);
}
//testing setEnabled(false)
@@ -2225,8 +2225,8 @@ void tst_QWidget::showMinimizedKeepsFocus()
QTRY_COMPARE(qApp->focusWidget(), child);
child->setEnabled(false);
- QCOMPARE(window.focusWidget(), static_cast<QWidget*>(0));
- QCOMPARE(qApp->focusWidget(), static_cast<QWidget*>(0));
+ QCOMPARE(window.focusWidget(), nullptr);
+ QCOMPARE(QApplication::focusWidget(), nullptr);
}
//testing clearFocus
@@ -2245,14 +2245,14 @@ void tst_QWidget::showMinimizedKeepsFocus()
QTRY_COMPARE(qApp->focusWidget(), child);
child->clearFocus();
- QCOMPARE(window.focusWidget(), static_cast<QWidget*>(0));
- QCOMPARE(qApp->focusWidget(), static_cast<QWidget*>(0));
+ QCOMPARE(window.focusWidget(), nullptr);
+ QCOMPARE(QApplication::focusWidget(), nullptr);
window.showMinimized();
QTest::qWait(30);
QTRY_VERIFY(window.isMinimized());
- QCOMPARE(window.focusWidget(), static_cast<QWidget*>(0));
- QTRY_COMPARE(qApp->focusWidget(), static_cast<QWidget*>(0));
+ QCOMPARE(window.focusWidget(), nullptr);
+ QTRY_COMPARE(QApplication::focusWidget(), nullptr);
window.showNormal();
qApp->setActiveWindow(&window);
@@ -5260,12 +5260,12 @@ void tst_QWidget::setFocus()
child1.setFocus();
QVERIFY(!child1.hasFocus());
QCOMPARE(window.focusWidget(), &child1);
- QCOMPARE(QApplication::focusWidget(), static_cast<QWidget *>(0));
+ QCOMPARE(QApplication::focusWidget(), nullptr);
child2.setFocus();
QVERIFY(!child2.hasFocus());
QCOMPARE(window.focusWidget(), &child2);
- QCOMPARE(QApplication::focusWidget(), static_cast<QWidget *>(0));
+ QCOMPARE(QApplication::focusWidget(), nullptr);
}
{
@@ -5294,12 +5294,12 @@ void tst_QWidget::setFocus()
child1.setFocus();
QVERIFY(!child1.hasFocus());
QCOMPARE(window.focusWidget(), &child1);
- QCOMPARE(QApplication::focusWidget(), static_cast<QWidget *>(0));
+ QCOMPARE(QApplication::focusWidget(), nullptr);
child2.setFocus();
QVERIFY(!child2.hasFocus());
QCOMPARE(window.focusWidget(), &child2);
- QCOMPARE(QApplication::focusWidget(), static_cast<QWidget *>(0));
+ QCOMPARE(QApplication::focusWidget(), nullptr);
}
{
@@ -5355,8 +5355,8 @@ void tst_QWidget::setFocus()
child1.setFocus();
QVERIFY(!child1.hasFocus());
- QCOMPARE(window.focusWidget(), static_cast<QWidget *>(0));
- QCOMPARE(QApplication::focusWidget(), static_cast<QWidget *>(0));
+ QCOMPARE(window.focusWidget(), nullptr);
+ QCOMPARE(QApplication::focusWidget(), nullptr);
child1.show();
QApplication::processEvents();
@@ -5396,33 +5396,33 @@ void tst_QWidget::setFocus()
child1.setFocus();
QVERIFY(!child1.hasFocus());
- QCOMPARE(window.focusWidget(), static_cast<QWidget *>(0));
- QCOMPARE(QApplication::focusWidget(), static_cast<QWidget *>(0));
+ QCOMPARE(window.focusWidget(), nullptr);
+ QCOMPARE(QApplication::focusWidget(), nullptr);
child1.hide();
QVERIFY(!child1.hasFocus());
- QCOMPARE(window.focusWidget(), static_cast<QWidget *>(0));
- QCOMPARE(QApplication::focusWidget(), static_cast<QWidget *>(0));
+ QCOMPARE(window.focusWidget(), nullptr);
+ QCOMPARE(QApplication::focusWidget(), nullptr);
child1.show();
QVERIFY(!child1.hasFocus());
- QCOMPARE(window.focusWidget(), static_cast<QWidget *>(0));
- QCOMPARE(QApplication::focusWidget(), static_cast<QWidget *>(0));
+ QCOMPARE(window.focusWidget(), nullptr);
+ QCOMPARE(QApplication::focusWidget(), nullptr);
child2.setFocus();
QVERIFY(!child2.hasFocus());
- QCOMPARE(window.focusWidget(), static_cast<QWidget *>(0));
- QCOMPARE(QApplication::focusWidget(), static_cast<QWidget *>(0));
+ QCOMPARE(window.focusWidget(), nullptr);
+ QCOMPARE(QApplication::focusWidget(), nullptr);
child2.hide();
QVERIFY(!child2.hasFocus());
- QCOMPARE(window.focusWidget(), static_cast<QWidget *>(0));
- QCOMPARE(QApplication::focusWidget(), static_cast<QWidget *>(0));
+ QCOMPARE(window.focusWidget(), nullptr);
+ QCOMPARE(QApplication::focusWidget(), nullptr);
child2.show();
QVERIFY(!child2.hasFocus());
- QCOMPARE(window.focusWidget(), static_cast<QWidget *>(0));
- QCOMPARE(QApplication::focusWidget(), static_cast<QWidget *>(0));
+ QCOMPARE(window.focusWidget(), nullptr);
+ QCOMPARE(QApplication::focusWidget(), nullptr);
}
}
diff --git a/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp b/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp
index 406b21ccf6..5e3868ea8f 100644
--- a/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp
+++ b/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp
@@ -161,7 +161,7 @@ void tst_QWindowContainer::testOwnership()
delete container;
- QCOMPARE(window.data(), (QWindow *) 0);
+ QCOMPARE(window.data(), nullptr);
}
diff --git a/tests/auto/widgets/styles/qstyleoption/tst_qstyleoption.cpp b/tests/auto/widgets/styles/qstyleoption/tst_qstyleoption.cpp
index 883336b28f..1d46886d1c 100644
--- a/tests/auto/widgets/styles/qstyleoption/tst_qstyleoption.cpp
+++ b/tests/auto/widgets/styles/qstyleoption/tst_qstyleoption.cpp
@@ -121,7 +121,7 @@ void tst_QStyleOption::qstyleoptioncast()
// Cast a null pointer
castOption = qstyleoption_cast<QStyleOption*>((QStyleOption*)0);
- QCOMPARE(castOption,(QStyleOption*)0);
+ QCOMPARE(castOption, nullptr);
// Deallocate
delete testOption;
diff --git a/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp b/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp
index 99d067b7d7..f5cf9d7750 100644
--- a/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp
+++ b/tests/auto/widgets/util/qundogroup/tst_qundogroup.cpp
@@ -215,7 +215,7 @@ void tst_QUndoGroup::setActive()
QUndoGroup group;
QUndoStack stack1(&group), stack2(&group);
- QCOMPARE(group.activeStack(), (QUndoStack*)0);
+ QCOMPARE(group.activeStack(), nullptr);
QCOMPARE(stack1.isActive(), false);
QCOMPARE(stack2.isActive(), false);
@@ -238,13 +238,13 @@ void tst_QUndoGroup::setActive()
QCOMPARE(stack3.isActive(), false);
group.removeStack(&stack2);
- QCOMPARE(group.activeStack(), (QUndoStack*)0);
+ QCOMPARE(group.activeStack(), nullptr);
QCOMPARE(stack1.isActive(), false);
QCOMPARE(stack2.isActive(), true);
QCOMPARE(stack3.isActive(), false);
group.removeStack(&stack2);
- QCOMPARE(group.activeStack(), (QUndoStack*)0);
+ QCOMPARE(group.activeStack(), nullptr);
QCOMPARE(stack1.isActive(), false);
QCOMPARE(stack2.isActive(), true);
QCOMPARE(stack3.isActive(), false);
@@ -280,7 +280,7 @@ void tst_QUndoGroup::deleteStack()
QUndoStack *stack1 = new QUndoStack(&group);
QCOMPARE(group.stacks(), QList<QUndoStack*>() << stack1);
- QCOMPARE(group.activeStack(), (QUndoStack*)0);
+ QCOMPARE(group.activeStack(), nullptr);
stack1->setActive();
QCOMPARE(group.activeStack(), stack1);
@@ -299,17 +299,17 @@ void tst_QUndoGroup::deleteStack()
delete stack1;
QCOMPARE(group.stacks(), QList<QUndoStack*>() << stack3);
- QCOMPARE(group.activeStack(), (QUndoStack*)0);
+ QCOMPARE(group.activeStack(), nullptr);
stack3->setActive(false);
- QCOMPARE(group.activeStack(), (QUndoStack*)0);
+ QCOMPARE(group.activeStack(), nullptr);
stack3->setActive(true);
QCOMPARE(group.activeStack(), stack3);
group.removeStack(stack3);
QCOMPARE(group.stacks(), QList<QUndoStack*>());
- QCOMPARE(group.activeStack(), (QUndoStack*)0);
+ QCOMPARE(group.activeStack(), nullptr);
delete stack3;
}
diff --git a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
index edaf033678..3afdc0a12a 100644
--- a/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
+++ b/tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp
@@ -305,17 +305,17 @@ void tst_QComboBox::getSetCheck()
obj1.setValidator(var9);
QCOMPARE(obj1.validator(), (const QValidator *)var9);
obj1.setValidator((QValidator *)0);
- QCOMPARE(obj1.validator(), (const QValidator *)0);
+ QCOMPARE(obj1.validator(), nullptr);
delete var9;
// QAbstractItemDelegate * QComboBox::itemDelegate()
// void QComboBox::setItemDelegate(QAbstractItemDelegate *)
MyAbstractItemDelegate *var10 = new MyAbstractItemDelegate;
obj1.setItemDelegate(var10);
- QCOMPARE(obj1.itemDelegate(), (QAbstractItemDelegate *)var10);
+ QCOMPARE(obj1.itemDelegate(), var10);
QTest::ignoreMessage(QtWarningMsg, "QComboBox::setItemDelegate: cannot set a 0 delegate");
obj1.setItemDelegate((QAbstractItemDelegate *)0);
- QCOMPARE(obj1.itemDelegate(), (QAbstractItemDelegate *)var10);
+ QCOMPARE(obj1.itemDelegate(), var10);
// delete var10; // No delete, since QComboBox takes ownership
// QAbstractItemModel * QComboBox::model()
diff --git a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp
index 09ab20f7ca..9ab755c5f1 100644
--- a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp
+++ b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp
@@ -3710,7 +3710,7 @@ void tst_QDateTimeEdit::dateEditCorrectSectionSize()
QTest::keyClick(&edit, keyPair.first, keyPair.second);
QDateTimeEditPrivate* edit_d_ptr(static_cast<QDateTimeEditPrivate*>(qt_widget_private(&edit)));
- QCOMPARE(edit_d_ptr->text, expectedDisplayString);
+ QCOMPARE(edit_d_ptr->QDateTimeParser::displayText(), expectedDisplayString);
}
#endif
diff --git a/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp b/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp
index cb55bd32b0..1a1023208a 100644
--- a/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp
+++ b/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp
@@ -857,8 +857,8 @@ void tst_QDockWidget::task165177_deleteFocusWidget()
qApp->processEvents();
dw->setFloating(true);
delete ledit;
- QCOMPARE(mw.focusWidget(), (QWidget *)0);
- QCOMPARE(dw->focusWidget(), (QWidget *)0);
+ QCOMPARE(mw.focusWidget(), nullptr);
+ QCOMPARE(dw->focusWidget(), nullptr);
}
void tst_QDockWidget::task169808_setFloating()
diff --git a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
index cb7643d1ac..3218b8ac68 100644
--- a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
+++ b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
@@ -388,7 +388,7 @@ void tst_QMenu::keyboardNavigation()
#ifndef Q_OS_MAC
QEXPECT_FAIL("shortcut0", "QTBUG-22449: QMenu doesn't remove highlight if a menu item is activated by a shortcut", Abort);
#endif
- QCOMPARE(menus[expected_menu]->activeAction(), (QAction *)0);
+ QCOMPARE(menus[expected_menu]->activeAction(), nullptr);
} else {
QCOMPARE(menus[expected_menu]->activeAction(), builtins[expected_action]);
}
@@ -396,7 +396,7 @@ void tst_QMenu::keyboardNavigation()
if (expected_highlighted)
QCOMPARE(menus[expected_menu]->activeAction(), highlighted);
else
- QCOMPARE(highlighted, (QAction *)0);
+ QCOMPARE(highlighted, nullptr);
}
#ifdef Q_OS_MAC
diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
index 70d0e9ac9a..2d335c532a 100644
--- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
+++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
@@ -134,6 +134,7 @@ private slots:
#ifdef Q_OS_MACOS
void taskQTBUG56275_reinsertMenuInParentlessQMenuBar();
#endif
+ void taskQTBUG55966_subMenuRemoved();
void platformMenu();
@@ -1582,5 +1583,22 @@ void tst_QMenuBar::taskQTBUG56275_reinsertMenuInParentlessQMenuBar()
}
#endif // Q_OS_MACOS
+void tst_QMenuBar::taskQTBUG55966_subMenuRemoved()
+{
+ QMainWindow window;
+ QMenuBar *menubar = window.menuBar();
+ QMenu *parentMenu = menubar->addMenu("Parent menu");
+
+ QAction *action = parentMenu->addAction("Action in parent menu");
+ QMenu *subMenu = new QMenu("Submenu");
+ action->setMenu(subMenu);
+ delete subMenu;
+
+ window.show();
+ QApplication::setActiveWindow(&window);
+ QVERIFY(QTest::qWaitForWindowActive(&window));
+ QTest::qWait(500);
+}
+
QTEST_MAIN(tst_QMenuBar)
#include "tst_qmenubar.moc"
diff --git a/tests/manual/qstorageinfo/printvolumes.cpp b/tests/manual/qstorageinfo/printvolumes.cpp
index 31047c2fcd..29fba80bb6 100644
--- a/tests/manual/qstorageinfo/printvolumes.cpp
+++ b/tests/manual/qstorageinfo/printvolumes.cpp
@@ -42,7 +42,7 @@ void printVolumes(const QList<QStorageInfo> &volumes, int (*printer)(const char
// 214958080 39088272 4096 /
// /dev/disk1s2 (hfs) RW 488050672 419909696 4096 Macintosh HD2 /Volumes/Macintosh HD2
- printf("Filesystem (Type) Size Available BSize Label Mounted on\n");
+ printer("Filesystem (Type) Size Available BSize Label Mounted on\n");
foreach (const QStorageInfo &info, volumes) {
QByteArray fsAndType = info.device();
if (info.fileSystemType() != fsAndType)
diff --git a/tests/manual/windowflags/controllerwindow.cpp b/tests/manual/windowflags/controllerwindow.cpp
index 7196608aa5..d02f64c27b 100644
--- a/tests/manual/windowflags/controllerwindow.cpp
+++ b/tests/manual/windowflags/controllerwindow.cpp
@@ -26,20 +26,33 @@
**
****************************************************************************/
-#include <QMainWindow>
-#include <QLabel>
-#include <QPushButton>
-#include <QRadioButton>
+#include "controllerwindow.h"
+#include "controls.h"
+
+#include <QAction>
+#include <QApplication>
#include <QCheckBox>
#include <QGroupBox>
-#include <QApplication>
#include <QHBoxLayout>
+#include <QLabel>
+#include <QMainWindow>
+#include <QMenu>
+#include <QPushButton>
+#include <QRadioButton>
+#include <QTabWidget>
-#include "controllerwindow.h"
-#include "controls.h"
+#include <QMoveEvent>
+
+#if QT_VERSION >= 0x050000
+# include <QWindow>
+# include <qlogging.h>
+# include <QLibraryInfo>
+#endif
+#include <QDebug>
-//! [0]
-ControllerWindow::ControllerWindow() : previewWidget(0)
+ControllerWidget::ControllerWidget(QWidget *parent)
+ : QWidget(parent)
+ , previewWidget(0)
{
parentWindow = new QMainWindow;
parentWindow->setWindowTitle(tr("Preview parent window"));
@@ -53,18 +66,6 @@ ControllerWindow::ControllerWindow() : previewWidget(0)
createTypeGroupBox();
- quitButton = new QPushButton(tr("&Quit"));
- connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit()));
-
- QHBoxLayout *bottomLayout = new QHBoxLayout;
- bottomLayout->addStretch();
-
- QPushButton *updateControlsButton = new QPushButton(tr("&Update"));
- connect(updateControlsButton, SIGNAL(clicked()), this, SLOT(updateStateControl()));
-
- bottomLayout->addWidget(updateControlsButton);
- bottomLayout->addWidget(quitButton);
-
hintsControl = new HintControl;
hintsControl->setHints(previewWindow->windowFlags());
connect(hintsControl, SIGNAL(changed(Qt::WindowFlags)), this, SLOT(updatePreview()));
@@ -78,39 +79,30 @@ ControllerWindow::ControllerWindow() : previewWidget(0)
typeControl->setType(previewWindow->windowFlags());
connect(typeControl, SIGNAL(changed(Qt::WindowFlags)), this, SLOT(updatePreview()));
- QVBoxLayout *mainLayout = new QVBoxLayout;
+ QVBoxLayout *mainLayout = new QVBoxLayout(this);
mainLayout->addWidget(widgetTypeGroupBox);
mainLayout->addWidget(additionalOptionsGroupBox);
mainLayout->addWidget(typeControl);
mainLayout->addWidget(hintsControl);
mainLayout->addWidget(statesControl);
- mainLayout->addLayout(bottomLayout);
- setLayout(mainLayout);
- setWindowTitle(tr("Window Flags (Qt version %1, %2)")
- .arg(QLatin1String(qVersion()),
-#if QT_VERSION >= 0x050000
- qApp->platformName()));
-#else
- QLatin1String("<unknown>")));
-#endif
updatePreview();
}
-bool ControllerWindow::eventFilter(QObject *, QEvent *e)
+bool ControllerWidget::eventFilter(QObject *, QEvent *e)
{
if (e->type() == QEvent::WindowStateChange)
updateStateControl();
return false;
}
-void ControllerWindow::updateStateControl()
+void ControllerWidget::updateStateControl()
{
if (previewWidget)
statesControl->setStates(previewWidget->windowState());
}
-void ControllerWindow::updatePreview()
+void ControllerWidget::updatePreview()
{
const Qt::WindowFlags flags = typeControl->type() | hintsControl->hints();
@@ -154,7 +146,7 @@ void ControllerWindow::updatePreview()
previewWidget->setVisible(statesControl->visibleValue());
}
-void ControllerWindow::createTypeGroupBox()
+void ControllerWidget::createTypeGroupBox()
{
widgetTypeGroupBox = new QGroupBox(tr("Widget Type"));
previewWidgetButton = createRadioButton(tr("QWidget"));
@@ -173,24 +165,181 @@ void ControllerWindow::createTypeGroupBox()
l->addWidget(fixedSizeWindowCheckBox);
additionalOptionsGroupBox->setLayout(l);
}
-//! [5]
-
-//! [6]
-//! [7]
-QCheckBox *ControllerWindow::createCheckBox(const QString &text)
+QCheckBox *ControllerWidget::createCheckBox(const QString &text)
{
QCheckBox *checkBox = new QCheckBox(text);
connect(checkBox, SIGNAL(clicked()), this, SLOT(updatePreview()));
return checkBox;
}
-//! [7]
-//! [8]
-QRadioButton *ControllerWindow::createRadioButton(const QString &text)
+QRadioButton *ControllerWidget::createRadioButton(const QString &text)
{
QRadioButton *button = new QRadioButton(text);
connect(button, SIGNAL(clicked()), this, SLOT(updatePreview()));
return button;
}
-//! [8]
+
+static bool isTopLevel(const QObject *o)
+{
+ if (o->isWidgetType())
+ return static_cast<const QWidget *>(o)->isWindow();
+#if QT_VERSION >= 0x050000
+ if (o->isWindowType())
+ return static_cast<const QWindow *>(o)->isTopLevel();
+#endif
+ return false;
+}
+
+static Qt::WindowState windowState(const QObject *o)
+{
+ if (o->isWidgetType()) {
+ Qt::WindowStates states = static_cast<const QWidget *>(o)->windowState();
+ states &= ~Qt::WindowActive;
+ return static_cast<Qt::WindowState>(int(states));
+ }
+#if QT_VERSION >= 0x050000
+ if (o->isWindowType())
+ return static_cast<const QWindow *>(o)->windowState();
+#endif
+ return Qt::WindowNoState;
+}
+
+class EventFilter : public QObject {
+public:
+ explicit EventFilter(QObject *parent = 0) : QObject(parent) {}
+
+ bool eventFilter(QObject *o, QEvent *e)
+ {
+ switch (e->type()) {
+ case QEvent::Move:
+ case QEvent::Resize:
+ case QEvent::WindowStateChange:
+ case QEvent::ApplicationActivate:
+ case QEvent::ApplicationDeactivate:
+#if QT_VERSION >= 0x050000
+ case QEvent::ApplicationStateChange:
+#endif
+ if (isTopLevel(o))
+ formatEvent(o, e);
+ break;
+ default:
+ break;
+ }
+ return QObject::eventFilter(o ,e);
+ }
+
+private:
+ void formatEvent(QObject *o, QEvent *e)
+ {
+ static int n = 0;
+ QDebug debug = qDebug().nospace();
+#if QT_VERSION >= 0x050000
+ debug.noquote();
+#endif
+ debug << '#' << n++ << ' ' << o->metaObject()->className();
+ const QString name = o->objectName();
+ if (!name.isEmpty())
+ debug << "/\"" << name << '"';
+ debug << ' ' << e;
+ if (e->type() == QEvent::WindowStateChange)
+ debug << ' ' << windowState(o);
+ }
+};
+
+LogWidget *LogWidget::m_instance = 0;
+
+#if QT_VERSION >= 0x050000
+static void qt5MessageHandler(QtMsgType, const QMessageLogContext &, const QString &text)
+{
+ if (LogWidget *lw = LogWidget::instance())
+ lw->appendText(text);
+}
+#else // Qt 5
+static void qt4MessageHandler(QtMsgType, const char *text)
+{
+ if (LogWidget *lw = LogWidget::instance())
+ lw->appendText(QString::fromLocal8Bit(text));
+}
+#endif // Qt 4
+
+LogWidget::LogWidget(QWidget *parent)
+ : QPlainTextEdit(parent)
+{
+ LogWidget::m_instance = this;
+ setReadOnly(true);
+ appendText(startupMessage());
+}
+
+LogWidget::~LogWidget()
+{
+ LogWidget::m_instance = 0;
+}
+
+void LogWidget::install()
+{
+#if QT_VERSION >= 0x050000
+ qInstallMessageHandler(qt5MessageHandler);
+#else
+ qInstallMsgHandler(qt4MessageHandler);
+#endif
+}
+
+QString LogWidget::startupMessage()
+{
+ QString result;
+#if QT_VERSION >= 0x050300
+ result += QLatin1String(QLibraryInfo::build());
+#else
+ result += QLatin1String("Qt ") + QLatin1String(QT_VERSION_STR);
+#endif
+#if QT_VERSION >= 0x050000
+ result += QLatin1Char(' ');
+ result += QGuiApplication::platformName();
+#endif
+ return result;
+}
+
+void LogWidget::appendText(const QString &message)
+{
+ appendPlainText(message);
+ ensureCursorVisible();
+}
+
+ControllerWindow::ControllerWindow()
+{
+ setWindowTitle(tr("Window Flags (Qt version %1, %2)")
+ .arg(QLatin1String(qVersion()),
+#if QT_VERSION >= 0x050000
+ qApp->platformName()));
+#else
+ QLatin1String("<unknown>")));
+#endif
+
+ QVBoxLayout *layout = new QVBoxLayout(this);
+ QTabWidget *tabWidget = new QTabWidget(this);
+ ControllerWidget *controllerWidget = new ControllerWidget(tabWidget);
+ tabWidget->addTab(controllerWidget, tr("Control"));
+ LogWidget *logWidget = new LogWidget(tabWidget);
+ tabWidget->addTab(logWidget, tr("Event log"));
+ layout->addWidget(tabWidget);
+
+ QHBoxLayout *bottomLayout = new QHBoxLayout;
+ layout->addLayout(bottomLayout);
+ bottomLayout->addStretch();
+ QPushButton *updateControlsButton = new QPushButton(tr("&Update"));
+ connect(updateControlsButton, SIGNAL(clicked()), controllerWidget, SLOT(updateStateControl()));
+ bottomLayout->addWidget(updateControlsButton);
+ QPushButton *clearLogButton = new QPushButton(tr("Clear &Log"));
+ connect(clearLogButton, SIGNAL(clicked()), logWidget, SLOT(clear()));
+ bottomLayout->addWidget(clearLogButton);
+ QPushButton *quitButton = new QPushButton(tr("&Quit"));
+ connect(quitButton, SIGNAL(clicked()), qApp, SLOT(quit()));
+ quitButton->setShortcut(Qt::CTRL + Qt::Key_Q);
+ bottomLayout->addWidget(quitButton);
+}
+
+void ControllerWindow::registerEventFilter()
+{
+ qApp->installEventFilter(new EventFilter(qApp));
+}
diff --git a/tests/manual/windowflags/controllerwindow.h b/tests/manual/windowflags/controllerwindow.h
index 81126085ea..43a125a9ae 100644
--- a/tests/manual/windowflags/controllerwindow.h
+++ b/tests/manual/windowflags/controllerwindow.h
@@ -29,7 +29,7 @@
#ifndef CONTROLLERWINDOW_H
#define CONTROLLERWINDOW_H
-#include <QWidget>
+#include <QPlainTextEdit>
#include "previewwindow.h"
@@ -46,13 +46,12 @@ class HintControl;
class WindowStatesControl;
class TypeControl;
-//! [0]
-class ControllerWindow : public QWidget
+class ControllerWidget : public QWidget
{
Q_OBJECT
public:
- ControllerWindow();
+ explicit ControllerWidget(QWidget *parent = 0);
virtual bool eventFilter(QObject *o, QEvent *e);
@@ -75,13 +74,37 @@ private:
HintControl *hintsControl;
WindowStatesControl *statesControl;
- QPushButton *quitButton;
-
QRadioButton *previewWidgetButton;
QRadioButton *previewDialogButton;
QCheckBox *modalWindowCheckBox;
QCheckBox *fixedSizeWindowCheckBox;
};
-//! [0]
-#endif
+class LogWidget : public QPlainTextEdit
+{
+ Q_OBJECT
+public:
+ explicit LogWidget(QWidget *parent = 0);
+ ~LogWidget();
+
+ static LogWidget *instance() { return m_instance; }
+ static void install();
+
+public slots:
+ void appendText(const QString &);
+
+private:
+ static QString startupMessage();
+
+ static LogWidget *m_instance;
+};
+
+class ControllerWindow : public QWidget {
+ Q_OBJECT
+public:
+ ControllerWindow();
+
+ void registerEventFilter();
+};
+
+#endif // CONTROLLERWINDOW_H
diff --git a/tests/manual/windowflags/main.cpp b/tests/manual/windowflags/main.cpp
index 86825dbb0d..a7d7307525 100644
--- a/tests/manual/windowflags/main.cpp
+++ b/tests/manual/windowflags/main.cpp
@@ -27,13 +27,21 @@
****************************************************************************/
#include <QApplication>
+#include <QStringList>
#include "controllerwindow.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
+ QStringList arguments = QCoreApplication::arguments();
+ arguments.pop_front();
+
ControllerWindow controller;
+ if (!arguments.contains(QLatin1String("-l")))
+ LogWidget::install();
+ if (!arguments.contains(QLatin1String("-e")))
+ controller.registerEventFilter();
controller.show();
return app.exec();
}
diff --git a/tests/manual/windowflags/previewwindow.cpp b/tests/manual/windowflags/previewwindow.cpp
index 11810763e7..54084fd1bc 100644
--- a/tests/manual/windowflags/previewwindow.cpp
+++ b/tests/manual/windowflags/previewwindow.cpp
@@ -26,136 +26,235 @@
**
****************************************************************************/
-#include <QTextEdit>
+#include <QPlainTextEdit>
#include <QPushButton>
+#include <QGridLayout>
#include <QVBoxLayout>
+#include <QTextStream>
+#include <QTimer>
#include "previewwindow.h"
-static QString windowFlagsToString(Qt::WindowFlags flags)
+static void formatWindowFlags(QTextStream &str, Qt::WindowFlags flags)
{
- QString text;
-
- Qt::WindowFlags type = (flags & Qt::WindowType_Mask);
- if (type == Qt::Window) {
- text = "Qt::Window";
- } else if (type == Qt::Dialog) {
- text = "Qt::Dialog";
- } else if (type == Qt::Sheet) {
- text = "Qt::Sheet";
- } else if (type == Qt::Drawer) {
- text = "Qt::Drawer";
- } else if (type == Qt::Popup) {
- text = "Qt::Popup";
- } else if (type == Qt::Tool) {
- text = "Qt::Tool";
- } else if (type == Qt::ToolTip) {
- text = "Qt::ToolTip";
- } else if (type == Qt::SplashScreen) {
- text = "Qt::SplashScreen";
+ str << "Window flags: " << hex << showbase << unsigned(flags) << noshowbase << dec << ' ';
+ switch (flags & Qt::WindowType_Mask) {
+ case Qt::Window:
+ str << "Qt::Window";
+ break;
+ case Qt::Dialog:
+ str << "Qt::Dialog";
+ break;
+ case Qt::Sheet:
+ str << "Qt::Sheet";
+ break;
+ case Qt::Drawer:
+ str << "Qt::Drawer";
+ break;
+ case Qt::Popup:
+ str << "Qt::Popup";
+ break;
+ case Qt::Tool:
+ str << "Qt::Tool";
+ break;
+ case Qt::ToolTip:
+ str << "Qt::ToolTip";
+ break;
+ case Qt::SplashScreen:
+ str << "Qt::SplashScreen";
+ break;
}
if (flags & Qt::MSWindowsFixedSizeDialogHint)
- text += "\n| Qt::MSWindowsFixedSizeDialogHint";
+ str << "\n| Qt::MSWindowsFixedSizeDialogHint";
+#if QT_VERSION >= 0x050000
+ if (flags & Qt::BypassWindowManagerHint)
+ str << "\n| Qt::BypassWindowManagerHint";
+#else
if (flags & Qt::X11BypassWindowManagerHint)
- text += "\n| Qt::X11BypassWindowManagerHint";
+ str << "\n| Qt::X11BypassWindowManagerHint";
+#endif
if (flags & Qt::FramelessWindowHint)
- text += "\n| Qt::FramelessWindowHint";
+ str << "\n| Qt::FramelessWindowHint";
if (flags & Qt::WindowTitleHint)
- text += "\n| Qt::WindowTitleHint";
+ str << "\n| Qt::WindowTitleHint";
if (flags & Qt::WindowSystemMenuHint)
- text += "\n| Qt::WindowSystemMenuHint";
+ str << "\n| Qt::WindowSystemMenuHint";
if (flags & Qt::WindowMinimizeButtonHint)
- text += "\n| Qt::WindowMinimizeButtonHint";
+ str << "\n| Qt::WindowMinimizeButtonHint";
if (flags & Qt::WindowMaximizeButtonHint)
- text += "\n| Qt::WindowMaximizeButtonHint";
+ str << "\n| Qt::WindowMaximizeButtonHint";
if (flags & Qt::WindowCloseButtonHint)
- text += "\n| Qt::WindowCloseButtonHint";
+ str << "\n| Qt::WindowCloseButtonHint";
if (flags & Qt::WindowContextHelpButtonHint)
- text += "\n| Qt::WindowContextHelpButtonHint";
+ str << "\n| Qt::WindowContextHelpButtonHint";
if (flags & Qt::WindowShadeButtonHint)
- text += "\n| Qt::WindowShadeButtonHint";
+ str << "\n| Qt::WindowShadeButtonHint";
if (flags & Qt::WindowStaysOnTopHint)
- text += "\n| Qt::WindowStaysOnTopHint";
+ str << "\n| Qt::WindowStaysOnTopHint";
if (flags & Qt::CustomizeWindowHint)
- text += "\n| Qt::CustomizeWindowHint";
- return text;
+ str << "\n| Qt::CustomizeWindowHint";
+ if (flags & Qt::WindowStaysOnBottomHint)
+ str << "\n| Qt::WindowStaysOnBottomHint";
+#if QT_VERSION >= 0x050000
+ if (flags & Qt::WindowFullscreenButtonHint)
+ str << "\n| Qt::WindowFullscreenButtonHint";
+ if (flags & Qt::WindowTransparentForInput)
+ str << "\n| Qt::WindowTransparentForInput";
+ if (flags & Qt::WindowOverridesSystemGestures)
+ str << "\n| Qt::WindowOverridesSystemGestures";
+ if (flags & Qt::WindowDoesNotAcceptFocus)
+ str << "\n| Qt::WindowDoesNotAcceptFocus";
+ if (flags & Qt::MaximizeUsingFullscreenGeometryHint)
+ str << "\n| Qt::MaximizeUsingFullscreenGeometryHint";
+ if (flags & Qt::NoDropShadowWindowHint)
+ str << "\n| Qt::NoDropShadowWindowHint";
+#endif // Qt 5
}
-PreviewWindow::PreviewWindow(QWidget *parent)
- : QWidget(parent)
+static void formatWindowStates(QTextStream &str, Qt::WindowStates states)
{
- textEdit = new QTextEdit;
- textEdit->setReadOnly(true);
- textEdit->setLineWrapMode(QTextEdit::NoWrap);
+ str << "Window states: " << hex << showbase << unsigned(states) << noshowbase << dec << ' ';
+ if (states & Qt::WindowActive) {
+ str << "Qt::WindowActive ";
+ states &= ~Qt::WindowActive;
+ }
+ switch (states) {
+ case Qt::WindowNoState:
+ str << "Qt::WindowNoState";
+ break;
+ case Qt::WindowMinimized:
+ str << "Qt::WindowMinimized";
+ break;
+ case Qt::WindowMaximized:
+ str << "Qt::WindowMaximized";
+ break;
+ case Qt::WindowFullScreen:
+ str << "Qt::WindowFullScreen";
+ break;
+ default:
+ break;
+ }
+}
- closeButton = new QPushButton(tr("&Close"));
- connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
+QTextStream &operator<<(QTextStream &str, const QRect &r)
+{
+ str << r.width() << 'x' << r.height() << forcesign << r.x() << r.y() << noforcesign;
+ return str;
+}
- showNormalButton = new QPushButton(tr("Show normal"));
- connect(showNormalButton, SIGNAL(clicked()), this, SLOT(showNormal()));
- showMinimizedButton = new QPushButton(tr("Show minimized"));
- connect(showMinimizedButton, SIGNAL(clicked()), this, SLOT(showMinimized()));
- showMaximizedButton = new QPushButton(tr("Show maximized"));
- connect(showMaximizedButton, SIGNAL(clicked()), this, SLOT(showMaximized()));
- showFullScreenButton = new QPushButton(tr("Show fullscreen"));
- connect(showFullScreenButton, SIGNAL(clicked()), this, SLOT(showFullScreen()));
+static QString formatWidgetInfo(const QWidget *w)
+{
+ QString result;
+ QTextStream str(&result);
+ formatWindowFlags(str, w->windowFlags());
+ str << '\n';
+ formatWindowStates(str, w->windowState());
+ const QRect frame = w->frameGeometry();
+ const QRect geometry = w->geometry();
+ str << "\n\nFrame: " << frame << "\nGeometry: " << geometry << "\nMargins: "
+ << (geometry.x() - frame.x()) << ", " << (geometry.top() - frame.top())
+ << ", " << (frame.right() - geometry.right()) << ", "
+ << (frame.bottom() - geometry.bottom());
+ return result;
+}
- QVBoxLayout *layout = new QVBoxLayout;
+static QPlainTextEdit *createControlPanel(QWidget *widget)
+{
+ QVBoxLayout *layout = new QVBoxLayout(widget);
+ QPlainTextEdit *textEdit = new QPlainTextEdit;
+ textEdit->setReadOnly(true);
+ textEdit->setLineWrapMode(QPlainTextEdit::NoWrap);
layout->addWidget(textEdit);
- layout->addWidget(showNormalButton);
- layout->addWidget(showMinimizedButton);
- layout->addWidget(showMaximizedButton);
- layout->addWidget(showFullScreenButton);
- layout->addWidget(closeButton);
- setLayout(layout);
-
- setWindowTitle(tr("Preview <QWidget>"));
+
+ QHBoxLayout *bottomLayout = new QHBoxLayout;
+ layout ->addLayout(bottomLayout);
+ QGridLayout *buttonLayout = new QGridLayout;
+ bottomLayout->addStretch();
+ bottomLayout->addLayout(buttonLayout);
+ QPushButton *showNormalButton = new QPushButton(PreviewWindow::tr("Show normal"));
+ QObject::connect(showNormalButton, SIGNAL(clicked()), widget, SLOT(showNormal()));
+ buttonLayout->addWidget(showNormalButton, 0, 0);
+ QPushButton *showMinimizedButton = new QPushButton(PreviewWindow::tr("Show minimized"));
+ QObject::connect(showMinimizedButton, SIGNAL(clicked()), widget, SLOT(showMinimized()));
+ buttonLayout->addWidget(showMinimizedButton, 0, 1);
+ QPushButton *showMaximizedButton = new QPushButton(PreviewWindow::tr("Show maximized"));
+ QObject::connect(showMaximizedButton, SIGNAL(clicked()), widget, SLOT(showMaximized()));
+ buttonLayout->addWidget(showMaximizedButton, 0, 2);
+ QPushButton *showFullScreenButton = new QPushButton(PreviewWindow::tr("Show fullscreen"));
+ QObject::connect(showFullScreenButton, SIGNAL(clicked()), widget, SLOT(showFullScreen()));
+ buttonLayout->addWidget(showFullScreenButton, 0, 3);
+
+ QPushButton *updateInfoButton = new QPushButton(PreviewWindow::tr("&Update Info"));
+ QObject::connect(updateInfoButton, SIGNAL(clicked()), widget, SLOT(updateInfo()));
+ buttonLayout->addWidget(updateInfoButton, 1, 0);
+ QPushButton *closeButton = new QPushButton(PreviewWindow::tr("&Close"));
+ QObject::connect(closeButton, SIGNAL(clicked()), widget, SLOT(close()));
+ buttonLayout->addWidget(closeButton, 1, 3);
+
+ return textEdit;
+}
+
+PreviewWindow::PreviewWindow(QWidget *parent)
+ : QWidget(parent)
+{
+ textEdit = createControlPanel(this);
+ setWindowTitle(tr("Preview <QWidget> Qt %1").arg(QLatin1String(QT_VERSION_STR)));
+}
+
+void PreviewWindow::resizeEvent(QResizeEvent *e)
+{
+ QWidget::resizeEvent(e);
+ updateInfo();
+}
+
+void PreviewWindow::moveEvent(QMoveEvent *e)
+{
+ QWidget::moveEvent(e);
+ updateInfo();
}
void PreviewWindow::setWindowFlags(Qt::WindowFlags flags)
{
+ if (flags == windowFlags())
+ return;
QWidget::setWindowFlags(flags);
+ QTimer::singleShot(0, this, SLOT(updateInfo()));
+}
- QString text = windowFlagsToString(flags);
- textEdit->setPlainText(text);
+void PreviewWindow::updateInfo()
+{
+ textEdit->setPlainText(formatWidgetInfo(this));
}
PreviewDialog::PreviewDialog(QWidget *parent)
: QDialog(parent)
{
- textEdit = new QTextEdit;
- textEdit->setReadOnly(true);
- textEdit->setLineWrapMode(QTextEdit::NoWrap);
-
- closeButton = new QPushButton(tr("&Close"));
- connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
+ textEdit = createControlPanel(this);
+ setWindowTitle(tr("Preview <QDialog> Qt %1").arg(QLatin1String(QT_VERSION_STR)));
+}
- showNormalButton = new QPushButton(tr("Show normal"));
- connect(showNormalButton, SIGNAL(clicked()), this, SLOT(showNormal()));
- showMinimizedButton = new QPushButton(tr("Show minimized"));
- connect(showMinimizedButton, SIGNAL(clicked()), this, SLOT(showMinimized()));
- showMaximizedButton = new QPushButton(tr("Show maximized"));
- connect(showMaximizedButton, SIGNAL(clicked()), this, SLOT(showMaximized()));
- showFullScreenButton = new QPushButton(tr("Show fullscreen"));
- connect(showFullScreenButton, SIGNAL(clicked()), this, SLOT(showFullScreen()));
+void PreviewDialog::resizeEvent(QResizeEvent *e)
+{
+ QDialog::resizeEvent(e);
+ updateInfo();
+}
- QVBoxLayout *layout = new QVBoxLayout;
- layout->addWidget(textEdit);
- layout->addWidget(showNormalButton);
- layout->addWidget(showMinimizedButton);
- layout->addWidget(showMaximizedButton);
- layout->addWidget(showFullScreenButton);
- layout->addWidget(closeButton);
- setLayout(layout);
-
- setWindowTitle(tr("Preview <QDialog>"));
+void PreviewDialog::moveEvent(QMoveEvent *e)
+{
+ QDialog::moveEvent(e);
+ updateInfo();
}
void PreviewDialog::setWindowFlags(Qt::WindowFlags flags)
{
+ if (flags == windowFlags())
+ return;
QWidget::setWindowFlags(flags);
+ QTimer::singleShot(0, this, SLOT(updateInfo()));
+}
- QString text = windowFlagsToString(flags);
- textEdit->setPlainText(text);
+void PreviewDialog::updateInfo()
+{
+ textEdit->setPlainText(formatWidgetInfo(this));
}
diff --git a/tests/manual/windowflags/previewwindow.h b/tests/manual/windowflags/previewwindow.h
index 00d5cc39f9..acd79735ad 100644
--- a/tests/manual/windowflags/previewwindow.h
+++ b/tests/manual/windowflags/previewwindow.h
@@ -32,8 +32,7 @@
#include <QDialog>
QT_BEGIN_NAMESPACE
-class QPushButton;
-class QTextEdit;
+class QPlainTextEdit;
QT_END_NAMESPACE
class PreviewWindow : public QWidget
@@ -45,13 +44,15 @@ public:
void setWindowFlags(Qt::WindowFlags flags);
+public slots:
+ void updateInfo();
+
+protected:
+ void resizeEvent(QResizeEvent *);
+ void moveEvent(QMoveEvent *);
+
private:
- QTextEdit *textEdit;
- QPushButton *closeButton;
- QPushButton *showNormalButton;
- QPushButton *showMinimizedButton;
- QPushButton *showMaximizedButton;
- QPushButton *showFullScreenButton;
+ QPlainTextEdit *textEdit;
};
class PreviewDialog : public QDialog
@@ -63,13 +64,15 @@ public:
void setWindowFlags(Qt::WindowFlags flags);
+public slots:
+ void updateInfo();
+
+protected:
+ void resizeEvent(QResizeEvent *);
+ void moveEvent(QMoveEvent *);
+
private:
- QTextEdit *textEdit;
- QPushButton *closeButton;
- QPushButton *showNormalButton;
- QPushButton *showMinimizedButton;
- QPushButton *showMaximizedButton;
- QPushButton *showFullScreenButton;
+ QPlainTextEdit *textEdit;
};
#endif