diff options
Diffstat (limited to 'tests/auto')
214 files changed, 6023 insertions, 1586 deletions
diff --git a/tests/auto/corelib/global/qglobal/qglobal.pro b/tests/auto/corelib/global/qglobal/qglobal.pro index a40cb9a288..b105769430 100644 --- a/tests/auto/corelib/global/qglobal/qglobal.pro +++ b/tests/auto/corelib/global/qglobal/qglobal.pro @@ -2,3 +2,4 @@ CONFIG += testcase TARGET = tst_qglobal QT = core testlib SOURCES = tst_qglobal.cpp qglobal.c +contains(QT_CONFIG, c++1z): CONFIG += c++1z diff --git a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp index 78b954f373..56da047147 100644 --- a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp +++ b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp @@ -126,6 +126,46 @@ void tst_QGlobal::for_each() QCOMPARE(i, counter++); } QCOMPARE(counter, list.count()); + + // Should also work with an existing variable + int local; + counter = 0; + foreach (local, list) { + QCOMPARE(local, counter++); + } + QCOMPARE(counter, list.count()); + QCOMPARE(local, counter - 1); + + // Test the macro does not mess if/else conditions + counter = 0; + if (true) + foreach (int i, list) + QCOMPARE(i, counter++); + else + QFAIL("If/Else mismatch"); + QCOMPARE(counter, list.count()); + + counter = 0; + if (false) + foreach (int i, list) + if (i) QFAIL("If/Else mismatch"); + else QFAIL("If/Else mismatch"); + else + foreach (int i, list) + if (false) { } + else QCOMPARE(i, counter++); + QCOMPARE(counter, list.count()); + + // break and continue + counter = 0; + foreach (int i, list) { + if (i == 0) + continue; + QCOMPARE(i, (counter++) + 1); + if (i == 3) + break; + } + QCOMPARE(counter, 3); } void tst_QGlobal::qassert() diff --git a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp index 017eebe153..3e29475636 100644 --- a/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp +++ b/tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp @@ -95,6 +95,38 @@ inline bool qIsLikelyToBeNfs(const QString &path) #endif } +#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) +# ifndef SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE // MinGW +# define SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE (0x2) +# endif + +static DWORD createSymbolicLink(const QString &symLinkName, const QString &target, + QString *errorMessage) +{ + DWORD result = ERROR_SUCCESS; + const QString nativeSymLinkName = QDir::toNativeSeparators(symLinkName); + const QString nativeTarget = QDir::toNativeSeparators(target); + DWORD flags = 0; + if (QOperatingSystemVersion::current() >= QOperatingSystemVersion(QOperatingSystemVersion::Windows, 10, 0, 14972)) + flags |= SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE; + if (QFileInfo(target).isDir()) + flags |= SYMBOLIC_LINK_FLAG_DIRECTORY; + if (CreateSymbolicLink(reinterpret_cast<const wchar_t*>(nativeSymLinkName.utf16()), + reinterpret_cast<const wchar_t*>(nativeTarget.utf16()), flags) == FALSE) { + result = GetLastError(); + QTextStream(errorMessage) << "CreateSymbolicLink(" << nativeSymLinkName << ", " + << nativeTarget << ", 0x" << hex << flags << dec << ") failed with error " << result + << ": " << qt_error_string(int(result)); + } + return result; +} + +static QByteArray msgInsufficientPrivileges(const QString &errorMessage) +{ + return "Insufficient privileges (" + errorMessage.toLocal8Bit() + ')'; +} +#endif // Q_OS_WIN && !Q_OS_WINRT + static QString seedAndTemplate() { QString base; @@ -704,19 +736,14 @@ void tst_QFileInfo::canonicalFilePath() #if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) { - // CreateSymbolicLink can return TRUE & still fail to create the link, - // the error code in that case is ERROR_PRIVILEGE_NOT_HELD (1314) - SetLastError(0); + QString errorMessage; const QString linkTarget = QStringLiteral("res"); - BOOL ret = CreateSymbolicLink((wchar_t*)linkTarget.utf16(), (wchar_t*)m_resourcesDir.utf16(), 1); - DWORD dwErr = GetLastError(); - if (!ret) - QSKIP("Symbolic links aren't supported by FS"); + const DWORD dwErr = createSymbolicLink(linkTarget, m_resourcesDir, &errorMessage); + if (dwErr == ERROR_PRIVILEGE_NOT_HELD) + QSKIP(msgInsufficientPrivileges(errorMessage)); + QVERIFY2(dwErr == ERROR_SUCCESS, qPrintable(errorMessage)); QString currentPath = QDir::currentPath(); - bool is_res_Current = QDir::setCurrent(linkTarget); - if (!is_res_Current && dwErr == 1314) - QSKIP("Not enough privilages to create Symbolic links"); - QCOMPARE(is_res_Current, true); + QVERIFY(QDir::setCurrent(linkTarget)); const QString actualCanonicalPath = QFileInfo("file1").canonicalFilePath(); QVERIFY(QDir::setCurrent(currentPath)); QCOMPARE(actualCanonicalPath, m_resourcesDir + QStringLiteral("/file1")); @@ -1455,8 +1482,24 @@ void tst_QFileInfo::refresh() } #if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) + +struct NtfsTestResource { + + enum Type { None, SymLink, Junction }; + + explicit NtfsTestResource(Type tp = None, const QString &s = QString(), const QString &t = QString()) + : source(s), target(t), type(tp) {} + + QString source; + QString target; + Type type; +}; + +Q_DECLARE_METATYPE(NtfsTestResource) + void tst_QFileInfo::ntfsJunctionPointsAndSymlinks_data() { + QTest::addColumn<NtfsTestResource>("resource"); QTest::addColumn<QString>("path"); QTest::addColumn<bool>("isSymLink"); QTest::addColumn<QString>("linkTarget"); @@ -1479,32 +1522,20 @@ void tst_QFileInfo::ntfsJunctionPointsAndSymlinks_data() QString fileInSymlink(absSymlink); fileInSymlink.append("\\file"); QFile file(fileInTarget); - file.open(QIODevice::ReadWrite); + QVERIFY2(file.open(QIODevice::ReadWrite), qPrintable(file.errorString())); file.close(); - DWORD err = ERROR_SUCCESS ; - if (!pwd.exists("abs_symlink")) - if (!CreateSymbolicLink((wchar_t*)absSymlink.utf16(),(wchar_t*)absTarget.utf16(),0x1)) - err = GetLastError(); - if (err == ERROR_SUCCESS && !pwd.exists(relSymlink)) - if (!CreateSymbolicLink((wchar_t*)relSymlink.utf16(),(wchar_t*)relTarget.utf16(),0x1)) - err = GetLastError(); - if (err != ERROR_SUCCESS) { - wchar_t errstr[0x100]; - DWORD count = FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM, - 0, err, 0, errstr, 0x100, 0); - QString error(QString::fromWCharArray(errstr, count)); - qWarning() << error; - //we need at least one data set for the test not to assert fail when skipping _data function - QDir target("target"); - QTest::newRow("dummy") << target.path() << false << "" << target.canonicalPath(); - QSKIP("link not supported by FS or insufficient privilege"); - } QVERIFY2(file.exists(), msgDoesNotExist(file.fileName()).constData()); - QTest::newRow("absolute dir symlink") << absSymlink << true << QDir::fromNativeSeparators(absTarget) << target.canonicalPath(); - QTest::newRow("relative dir symlink") << relSymlink << true << QDir::fromNativeSeparators(absTarget) << target.canonicalPath(); - QTest::newRow("file in symlink dir") << fileInSymlink << false << "" << target.canonicalPath().append("/file"); + QTest::newRow("absolute dir symlink") + << NtfsTestResource(NtfsTestResource::SymLink, absSymlink, absTarget) + << absSymlink << true << QDir::fromNativeSeparators(absTarget) << target.canonicalPath(); + QTest::newRow("relative dir symlink") + << NtfsTestResource(NtfsTestResource::SymLink, relSymlink, relTarget) + << relSymlink << true << QDir::fromNativeSeparators(absTarget) << target.canonicalPath(); + QTest::newRow("file in symlink dir") + << NtfsTestResource() + << fileInSymlink << false << "" << target.canonicalPath().append("/file"); } { //File symlinks @@ -1517,33 +1548,41 @@ void tst_QFileInfo::ntfsJunctionPointsAndSymlinks_data() QString relSymlink = "rel_symlink.cpp"; QString relToRelTarget = QDir::toNativeSeparators(relativeDir.relativeFilePath(target.absoluteFilePath())); QString relToRelSymlink = "relative/rel_symlink"; - QVERIFY(pwd.exists("abs_symlink.cpp") || CreateSymbolicLink((wchar_t*)absSymlink.utf16(),(wchar_t*)absTarget.utf16(),0x0)); - QVERIFY(pwd.exists(relSymlink) || CreateSymbolicLink((wchar_t*)relSymlink.utf16(),(wchar_t*)relTarget.utf16(),0x0)); - QVERIFY(pwd.exists(relToRelSymlink) || CreateSymbolicLink((wchar_t*)relToRelSymlink.utf16(), (wchar_t*)relToRelTarget.utf16(),0x0)); - QTest::newRow("absolute file symlink") << absSymlink << true << QDir::fromNativeSeparators(absTarget) << target.canonicalFilePath(); - QTest::newRow("relative file symlink") << relSymlink << true << QDir::fromNativeSeparators(absTarget) << target.canonicalFilePath(); - QTest::newRow("relative to relative file symlink") << relToRelSymlink << true << QDir::fromNativeSeparators(absTarget) << target.canonicalFilePath(); + + QTest::newRow("absolute file symlink") + << NtfsTestResource(NtfsTestResource::SymLink, absSymlink, absTarget) + << absSymlink << true << QDir::fromNativeSeparators(absTarget) << target.canonicalFilePath(); + QTest::newRow("relative file symlink") + << NtfsTestResource(NtfsTestResource::SymLink, relSymlink, relTarget) + << relSymlink << true << QDir::fromNativeSeparators(absTarget) << target.canonicalFilePath(); + QTest::newRow("relative to relative file symlink") + << NtfsTestResource(NtfsTestResource::SymLink, relToRelSymlink, relToRelTarget) + << relToRelSymlink << true << QDir::fromNativeSeparators(absTarget) << target.canonicalFilePath(); } //Junctions QString target = "target"; QString junction = "junction_pwd"; - FileSystem::createNtfsJunction(target, junction); QFileInfo targetInfo(target); - QTest::newRow("junction_pwd") << junction << false << QString() << QString(); + QTest::newRow("junction_pwd") + << NtfsTestResource(NtfsTestResource::Junction, junction, target) + << junction << false << QString() << QString(); QFileInfo fileInJunction(targetInfo.absoluteFilePath().append("/file")); QFile file(fileInJunction.absoluteFilePath()); - file.open(QIODevice::ReadWrite); + QVERIFY2(file.open(QIODevice::ReadWrite), qPrintable(file.errorString())); file.close(); QVERIFY2(file.exists(), msgDoesNotExist(file.fileName()).constData()); - QTest::newRow("file in junction") << fileInJunction.absoluteFilePath() << false << "" << fileInJunction.canonicalFilePath(); + QTest::newRow("file in junction") + << NtfsTestResource() + << fileInJunction.absoluteFilePath() << false << QString() << fileInJunction.canonicalFilePath(); target = QDir::rootPath(); junction = "junction_root"; - FileSystem::createNtfsJunction(target, junction); targetInfo.setFile(target); - QTest::newRow("junction_root") << junction << false << QString() << QString(); + QTest::newRow("junction_root") + << NtfsTestResource(NtfsTestResource::Junction, junction, target) + << junction << false << QString() << QString(); //Mountpoint wchar_t buffer[MAX_PATH]; @@ -1552,17 +1591,38 @@ void tst_QFileInfo::ntfsJunctionPointsAndSymlinks_data() QString rootVolume = QString::fromWCharArray(buffer); junction = "mountpoint"; rootVolume.replace("\\\\?\\","\\??\\"); - FileSystem::createNtfsJunction(rootVolume, junction); - QTest::newRow("mountpoint") << junction << false << QString() << QString(); + QTest::newRow("mountpoint") + << NtfsTestResource(NtfsTestResource::Junction, junction, rootVolume) + << junction << false << QString() << QString(); } void tst_QFileInfo::ntfsJunctionPointsAndSymlinks() { + QFETCH(NtfsTestResource, resource); QFETCH(QString, path); QFETCH(bool, isSymLink); QFETCH(QString, linkTarget); QFETCH(QString, canonicalFilePath); + QString errorMessage; + DWORD creationResult = ERROR_SUCCESS; + switch (resource.type) { + case NtfsTestResource::None: + break; + case NtfsTestResource::SymLink: + creationResult = createSymbolicLink(resource.source, resource.target, &errorMessage); + break; + case NtfsTestResource::Junction: + creationResult = FileSystem::createNtfsJunction(resource.target, resource.source, &errorMessage); + if (creationResult == ERROR_NOT_SUPPORTED) // Special value indicating non-NTFS drive + QSKIP(qPrintable(errorMessage)); + break; + } + + if (creationResult == ERROR_PRIVILEGE_NOT_HELD) + QSKIP(msgInsufficientPrivileges(errorMessage)); + QVERIFY2(creationResult == ERROR_SUCCESS, qPrintable(errorMessage)); + QFileInfo fi(path); const bool actualIsSymLink = fi.isSymLink(); const QString actualSymLinkTarget = isSymLink ? fi.symLinkTarget() : QString(); diff --git a/tests/auto/corelib/itemmodels/itemmodels.pro b/tests/auto/corelib/itemmodels/itemmodels.pro index cca350ad43..ffbda6ec40 100644 --- a/tests/auto/corelib/itemmodels/itemmodels.pro +++ b/tests/auto/corelib/itemmodels/itemmodels.pro @@ -5,9 +5,11 @@ SUBDIRS = qstringlistmodel qtHaveModule(gui): SUBDIRS += \ qabstractitemmodel \ qabstractproxymodel \ + qconcatenatetablesproxymodel \ qidentityproxymodel \ qitemselectionmodel \ qsortfilterproxymodel_recursive \ + qtransposeproxymodel \ qtHaveModule(widgets) { SUBDIRS += \ diff --git a/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/qconcatenatetablesproxymodel.pro b/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/qconcatenatetablesproxymodel.pro new file mode 100644 index 0000000000..ee4ea28b5b --- /dev/null +++ b/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/qconcatenatetablesproxymodel.pro @@ -0,0 +1,5 @@ +CONFIG += testcase +TARGET = tst_qconcatenatetablesproxymodel +QT = core gui testlib + +SOURCES = tst_qconcatenatetablesproxymodel.cpp diff --git a/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp b/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp new file mode 100644 index 0000000000..40617c1f7d --- /dev/null +++ b/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp @@ -0,0 +1,823 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author David Faure <david.faure@kdab.com> +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QSignalSpy> +#include <QSortFilterProxyModel> +#include <QTest> +#include <QStandardItemModel> +#include <QIdentityProxyModel> +#include <QItemSelectionModel> +#include <QMimeData> +#include <QStringListModel> +#include <QAbstractItemModelTester> + +#include <qconcatenatetablesproxymodel.h> + +Q_DECLARE_METATYPE(QModelIndex) + +// Extracts a full row from a model as a string +// Works best if every cell contains only one character +static QString extractRowTexts(QAbstractItemModel *model, int row, const QModelIndex &parent = QModelIndex()) +{ + QString result; + const int colCount = model->columnCount(); + for (int col = 0; col < colCount; ++col) { + const QString txt = model->index(row, col, parent).data().toString(); + result += txt.isEmpty() ? QStringLiteral(" ") : txt; + } + return result; +} + +// Extracts a full column from a model as a string +// Works best if every cell contains only one character +static QString extractColumnTexts(QAbstractItemModel *model, int column, const QModelIndex &parent = QModelIndex()) +{ + QString result; + const int rowCount = model->rowCount(); + for (int row = 0; row < rowCount; ++row) { + const QString txt = model->index(row, column, parent).data().toString(); + result += txt.isEmpty() ? QStringLiteral(" ") : txt; + } + return result; +} + +static QString rowSpyToText(const QSignalSpy &spy) +{ + if (!spy.isValid()) + return QStringLiteral("THE SIGNALSPY IS INVALID!"); + QString str; + for (int i = 0; i < spy.count(); ++i) { + str += spy.at(i).at(1).toString() + QLatin1Char(',') + spy.at(i).at(2).toString(); + if (i + 1 < spy.count()) + str += QLatin1Char(';'); + } + return str; +} + +class tst_QConcatenateTablesProxyModel : public QObject +{ + Q_OBJECT + +private Q_SLOTS: + void init(); + void shouldAggregateTwoModelsCorrectly(); + void shouldAggregateThenRemoveTwoEmptyModelsCorrectly(); + void shouldAggregateTwoEmptyModelsWhichThenGetFilled(); + void shouldHandleDataChanged(); + void shouldHandleSetData(); + void shouldHandleSetItemData(); + void shouldHandleRowInsertionAndRemoval(); + void shouldAggregateAnotherModelThenRemoveModels(); + void shouldUseSmallestColumnCount(); + void shouldIncreaseColumnCountWhenRemovingFirstModel(); + void shouldHandleColumnInsertionAndRemoval(); + void shouldPropagateLayoutChanged(); + void shouldReactToModelReset(); + void shouldUpdateColumnsOnModelReset(); + void shouldPropagateDropOnItem_data(); + void shouldPropagateDropOnItem(); + void shouldPropagateDropBetweenItems(); + void shouldPropagateDropBetweenItemsAtModelBoundary(); + void shouldPropagateDropAfterLastRow_data(); + void shouldPropagateDropAfterLastRow(); + +private: + QStandardItemModel mod; + QStandardItemModel mod2; + QStandardItemModel mod3; +}; + +void tst_QConcatenateTablesProxyModel::init() +{ + // Prepare some source models to use later on + mod.clear(); + mod.appendRow({ new QStandardItem(QStringLiteral("A")), new QStandardItem(QStringLiteral("B")), new QStandardItem(QStringLiteral("C")) }); + mod.setHorizontalHeaderLabels(QStringList() << QStringLiteral("H1") << QStringLiteral("H2") << QStringLiteral("H3")); + mod.setVerticalHeaderLabels(QStringList() << QStringLiteral("One")); + + mod2.clear(); + mod2.appendRow({ new QStandardItem(QStringLiteral("D")), new QStandardItem(QStringLiteral("E")), new QStandardItem(QStringLiteral("F")) }); + mod2.setHorizontalHeaderLabels(QStringList() << QStringLiteral("H1") << QStringLiteral("H2") << QStringLiteral("H3")); + mod2.setVerticalHeaderLabels(QStringList() << QStringLiteral("Two")); + + mod3.clear(); + mod3.appendRow({ new QStandardItem(QStringLiteral("1")), new QStandardItem(QStringLiteral("2")), new QStandardItem(QStringLiteral("3")) }); + mod3.appendRow({ new QStandardItem(QStringLiteral("4")), new QStandardItem(QStringLiteral("5")), new QStandardItem(QStringLiteral("6")) }); +} + +void tst_QConcatenateTablesProxyModel::shouldAggregateTwoModelsCorrectly() +{ + // Given a combining proxy + QConcatenateTablesProxyModel pm; + + // When adding two source models + pm.addSourceModel(&mod); + pm.addSourceModel(&mod2); + QAbstractItemModelTester modelTest(&pm, this); + + // Then the proxy should show 2 rows + QCOMPARE(pm.rowCount(), 2); + QCOMPARE(extractRowTexts(&pm, 0), QStringLiteral("ABC")); + QCOMPARE(extractRowTexts(&pm, 1), QStringLiteral("DEF")); + + // ... and correct headers + QCOMPARE(pm.headerData(0, Qt::Horizontal).toString(), QStringLiteral("H1")); + QCOMPARE(pm.headerData(1, Qt::Horizontal).toString(), QStringLiteral("H2")); + QCOMPARE(pm.headerData(2, Qt::Horizontal).toString(), QStringLiteral("H3")); + QCOMPARE(pm.headerData(0, Qt::Vertical).toString(), QStringLiteral("One")); + QCOMPARE(pm.headerData(1, Qt::Vertical).toString(), QStringLiteral("Two")); + + QVERIFY(!pm.canFetchMore(QModelIndex())); +} + +void tst_QConcatenateTablesProxyModel::shouldAggregateThenRemoveTwoEmptyModelsCorrectly() +{ + // Given a combining proxy + QConcatenateTablesProxyModel pm; + + // When adding two empty models + QSignalSpy rowATBISpy(&pm, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int))); + QSignalSpy rowInsertedSpy(&pm, SIGNAL(rowsInserted(QModelIndex,int,int))); + QSignalSpy rowATBRSpy(&pm, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int))); + QSignalSpy rowRemovedSpy(&pm, SIGNAL(rowsRemoved(QModelIndex,int,int))); + QIdentityProxyModel i1, i2; + pm.addSourceModel(&i1); + pm.addSourceModel(&i2); + + // Then the proxy should still be empty (and no signals emitted) + QCOMPARE(pm.rowCount(), 0); + QCOMPARE(pm.columnCount(), 0); + QCOMPARE(rowATBISpy.count(), 0); + QCOMPARE(rowInsertedSpy.count(), 0); + + // When removing the empty models + pm.removeSourceModel(&i1); + pm.removeSourceModel(&i2); + + // Then the proxy should still be empty (and no signals emitted) + QCOMPARE(pm.rowCount(), 0); + QCOMPARE(pm.columnCount(), 0); + QCOMPARE(rowATBRSpy.count(), 0); + QCOMPARE(rowRemovedSpy.count(), 0); +} + +void tst_QConcatenateTablesProxyModel::shouldAggregateTwoEmptyModelsWhichThenGetFilled() +{ + // Given a combining proxy with two empty models + QConcatenateTablesProxyModel pm; + QIdentityProxyModel i1, i2; + pm.addSourceModel(&i1); + pm.addSourceModel(&i2); + + // When filling them afterwards + i1.setSourceModel(&mod); + i2.setSourceModel(&mod2); + QAbstractItemModelTester modelTest(&pm, this); + + // Then the proxy should show 2 rows + QCOMPARE(pm.rowCount(), 2); + QCOMPARE(pm.columnCount(), 3); + QCOMPARE(extractRowTexts(&pm, 0), QStringLiteral("ABC")); + QCOMPARE(extractRowTexts(&pm, 1), QStringLiteral("DEF")); + + // ... and correct headers + QCOMPARE(pm.headerData(0, Qt::Horizontal).toString(), QStringLiteral("H1")); + QCOMPARE(pm.headerData(1, Qt::Horizontal).toString(), QStringLiteral("H2")); + QCOMPARE(pm.headerData(2, Qt::Horizontal).toString(), QStringLiteral("H3")); + QCOMPARE(pm.headerData(0, Qt::Vertical).toString(), QStringLiteral("One")); + QCOMPARE(pm.headerData(1, Qt::Vertical).toString(), QStringLiteral("Two")); + + QVERIFY(!pm.canFetchMore(QModelIndex())); +} + +void tst_QConcatenateTablesProxyModel::shouldHandleDataChanged() +{ + // Given two models combined + QConcatenateTablesProxyModel pm; + pm.addSourceModel(&mod); + pm.addSourceModel(&mod2); + QAbstractItemModelTester modelTest(&pm, this); + QSignalSpy dataChangedSpy(&pm, SIGNAL(dataChanged(QModelIndex,QModelIndex))); + + // When a cell in a source model changes + mod.item(0, 0)->setData("a", Qt::EditRole); + + // Then the change should be notified to the proxy + QCOMPARE(dataChangedSpy.count(), 1); + QCOMPARE(dataChangedSpy.at(0).at(0).toModelIndex(), pm.index(0, 0)); + QCOMPARE(extractRowTexts(&pm, 0), QStringLiteral("aBC")); + + // Same test with the other model + mod2.item(0, 2)->setData("f", Qt::EditRole); + + QCOMPARE(dataChangedSpy.count(), 2); + QCOMPARE(dataChangedSpy.at(1).at(0).toModelIndex(), pm.index(1, 2)); + QCOMPARE(extractRowTexts(&pm, 1), QStringLiteral("DEf")); +} + +void tst_QConcatenateTablesProxyModel::shouldHandleSetData() +{ + // Given two models combined + QConcatenateTablesProxyModel pm; + pm.addSourceModel(&mod); + pm.addSourceModel(&mod2); + QAbstractItemModelTester modelTest(&pm, this); + QSignalSpy dataChangedSpy(&pm, SIGNAL(dataChanged(QModelIndex,QModelIndex))); + + // When changing a cell using setData + pm.setData(pm.index(0, 0), "a"); + + // Then the change should be notified to the proxy + QCOMPARE(dataChangedSpy.count(), 1); + QCOMPARE(dataChangedSpy.at(0).at(0).toModelIndex(), pm.index(0, 0)); + QCOMPARE(extractRowTexts(&pm, 0), QStringLiteral("aBC")); + + // Same test with the other model + pm.setData(pm.index(1, 2), "f"); + + QCOMPARE(dataChangedSpy.count(), 2); + QCOMPARE(dataChangedSpy.at(1).at(0).toModelIndex(), pm.index(1, 2)); + QCOMPARE(extractRowTexts(&pm, 1), QStringLiteral("DEf")); +} + +void tst_QConcatenateTablesProxyModel::shouldHandleSetItemData() +{ + // Given two models combined + QConcatenateTablesProxyModel pm; + pm.addSourceModel(&mod); + pm.addSourceModel(&mod2); + QAbstractItemModelTester modelTest(&pm, this); + QSignalSpy dataChangedSpy(&pm, SIGNAL(dataChanged(QModelIndex,QModelIndex))); + + // When changing a cell using setData + pm.setItemData(pm.index(0, 0), QMap<int, QVariant>{ std::make_pair<int, QVariant>(Qt::DisplayRole, QStringLiteral("X")), + std::make_pair<int, QVariant>(Qt::UserRole, 88) }); + + // Then the change should be notified to the proxy + QCOMPARE(dataChangedSpy.count(), 1); + QCOMPARE(dataChangedSpy.at(0).at(0).toModelIndex(), pm.index(0, 0)); + QCOMPARE(extractRowTexts(&pm, 0), QStringLiteral("XBC")); + QCOMPARE(pm.index(0, 0).data(Qt::UserRole).toInt(), 88); + + // Same test with the other model + pm.setItemData(pm.index(1, 2), QMap<int, QVariant>{ std::make_pair<int, QVariant>(Qt::DisplayRole, QStringLiteral("Y")), + std::make_pair<int, QVariant>(Qt::UserRole, 89) }); + + QCOMPARE(dataChangedSpy.count(), 2); + QCOMPARE(dataChangedSpy.at(1).at(0).toModelIndex(), pm.index(1, 2)); + QCOMPARE(extractRowTexts(&pm, 1), QStringLiteral("DEY")); + QCOMPARE(pm.index(1, 2).data(Qt::UserRole).toInt(), 89); +} + +void tst_QConcatenateTablesProxyModel::shouldHandleRowInsertionAndRemoval() +{ + // Given two models combined + QConcatenateTablesProxyModel pm; + pm.addSourceModel(&mod); + pm.addSourceModel(&mod2); + QAbstractItemModelTester modelTest(&pm, this); + QSignalSpy rowATBISpy(&pm, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int))); + QSignalSpy rowInsertedSpy(&pm, SIGNAL(rowsInserted(QModelIndex,int,int))); + + // When a source model inserts a new row + QList<QStandardItem *> row; + row.append(new QStandardItem(QStringLiteral("1"))); + row.append(new QStandardItem(QStringLiteral("2"))); + row.append(new QStandardItem(QStringLiteral("3"))); + mod2.insertRow(0, row); + + // Then the proxy should notify its users and show changes + QCOMPARE(rowSpyToText(rowATBISpy), QStringLiteral("1,1")); + QCOMPARE(rowSpyToText(rowInsertedSpy), QStringLiteral("1,1")); + QCOMPARE(pm.rowCount(), 3); + QCOMPARE(extractRowTexts(&pm, 0), QStringLiteral("ABC")); + QCOMPARE(extractRowTexts(&pm, 1), QStringLiteral("123")); + QCOMPARE(extractRowTexts(&pm, 2), QStringLiteral("DEF")); + + // When removing that row + QSignalSpy rowATBRSpy(&pm, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int))); + QSignalSpy rowRemovedSpy(&pm, SIGNAL(rowsRemoved(QModelIndex,int,int))); + mod2.removeRow(0); + + // Then the proxy should notify its users and show changes + QCOMPARE(rowATBRSpy.count(), 1); + QCOMPARE(rowATBRSpy.at(0).at(1).toInt(), 1); + QCOMPARE(rowATBRSpy.at(0).at(2).toInt(), 1); + QCOMPARE(rowRemovedSpy.count(), 1); + QCOMPARE(rowRemovedSpy.at(0).at(1).toInt(), 1); + QCOMPARE(rowRemovedSpy.at(0).at(2).toInt(), 1); + QCOMPARE(pm.rowCount(), 2); + QCOMPARE(extractRowTexts(&pm, 0), QStringLiteral("ABC")); + QCOMPARE(extractRowTexts(&pm, 1), QStringLiteral("DEF")); + + // When removing the last row from mod2 + rowATBRSpy.clear(); + rowRemovedSpy.clear(); + mod2.removeRow(0); + + // Then the proxy should notify its users and show changes + QCOMPARE(rowATBRSpy.count(), 1); + QCOMPARE(rowATBRSpy.at(0).at(1).toInt(), 1); + QCOMPARE(rowATBRSpy.at(0).at(2).toInt(), 1); + QCOMPARE(rowRemovedSpy.count(), 1); + QCOMPARE(rowRemovedSpy.at(0).at(1).toInt(), 1); + QCOMPARE(rowRemovedSpy.at(0).at(2).toInt(), 1); + QCOMPARE(pm.rowCount(), 1); + QCOMPARE(extractRowTexts(&pm, 0), QStringLiteral("ABC")); +} + +void tst_QConcatenateTablesProxyModel::shouldAggregateAnotherModelThenRemoveModels() +{ + // Given two models combined, and a third model + QConcatenateTablesProxyModel pm; + pm.addSourceModel(&mod); + pm.addSourceModel(&mod2); + QAbstractItemModelTester modelTest(&pm, this); + + QSignalSpy rowATBISpy(&pm, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int))); + QSignalSpy rowInsertedSpy(&pm, SIGNAL(rowsInserted(QModelIndex,int,int))); + + // When adding the new source model + pm.addSourceModel(&mod3); + + // Then the proxy should notify its users about the two rows inserted + QCOMPARE(rowSpyToText(rowATBISpy), QStringLiteral("2,3")); + QCOMPARE(rowSpyToText(rowInsertedSpy), QStringLiteral("2,3")); + QCOMPARE(pm.rowCount(), 4); + QCOMPARE(extractRowTexts(&pm, 0), QStringLiteral("ABC")); + QCOMPARE(extractRowTexts(&pm, 1), QStringLiteral("DEF")); + QCOMPARE(extractRowTexts(&pm, 2), QStringLiteral("123")); + QCOMPARE(extractRowTexts(&pm, 3), QStringLiteral("456")); + + // When removing that source model again + QSignalSpy rowATBRSpy(&pm, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int))); + QSignalSpy rowRemovedSpy(&pm, SIGNAL(rowsRemoved(QModelIndex,int,int))); + pm.removeSourceModel(&mod3); + + // Then the proxy should notify its users about the row removed + QCOMPARE(rowATBRSpy.count(), 1); + QCOMPARE(rowATBRSpy.at(0).at(1).toInt(), 2); + QCOMPARE(rowATBRSpy.at(0).at(2).toInt(), 3); + QCOMPARE(rowRemovedSpy.count(), 1); + QCOMPARE(rowRemovedSpy.at(0).at(1).toInt(), 2); + QCOMPARE(rowRemovedSpy.at(0).at(2).toInt(), 3); + QCOMPARE(pm.rowCount(), 2); + QCOMPARE(extractRowTexts(&pm, 0), QStringLiteral("ABC")); + QCOMPARE(extractRowTexts(&pm, 1), QStringLiteral("DEF")); + + // When removing model 2 + rowATBRSpy.clear(); + rowRemovedSpy.clear(); + pm.removeSourceModel(&mod2); + QCOMPARE(rowATBRSpy.count(), 1); + QCOMPARE(rowATBRSpy.at(0).at(1).toInt(), 1); + QCOMPARE(rowATBRSpy.at(0).at(2).toInt(), 1); + QCOMPARE(rowRemovedSpy.count(), 1); + QCOMPARE(rowRemovedSpy.at(0).at(1).toInt(), 1); + QCOMPARE(rowRemovedSpy.at(0).at(2).toInt(), 1); + QCOMPARE(pm.rowCount(), 1); + QCOMPARE(extractRowTexts(&pm, 0), QStringLiteral("ABC")); + + // When removing model 1 + rowATBRSpy.clear(); + rowRemovedSpy.clear(); + pm.removeSourceModel(&mod); + QCOMPARE(rowATBRSpy.count(), 1); + QCOMPARE(rowATBRSpy.at(0).at(1).toInt(), 0); + QCOMPARE(rowATBRSpy.at(0).at(2).toInt(), 0); + QCOMPARE(rowRemovedSpy.count(), 1); + QCOMPARE(rowRemovedSpy.at(0).at(1).toInt(), 0); + QCOMPARE(rowRemovedSpy.at(0).at(2).toInt(), 0); + QCOMPARE(pm.rowCount(), 0); +} + +void tst_QConcatenateTablesProxyModel::shouldUseSmallestColumnCount() +{ + QConcatenateTablesProxyModel pm; + pm.addSourceModel(&mod); + pm.addSourceModel(&mod2); + mod2.setColumnCount(1); + pm.addSourceModel(&mod3); + QAbstractItemModelTester modelTest(&pm, this); + + QCOMPARE(pm.rowCount(), 4); + QCOMPARE(pm.columnCount(), 1); + QCOMPARE(extractRowTexts(&pm, 0), QStringLiteral("A")); + QCOMPARE(extractRowTexts(&pm, 1), QStringLiteral("D")); + QCOMPARE(extractRowTexts(&pm, 2), QStringLiteral("1")); + QCOMPARE(extractRowTexts(&pm, 3), QStringLiteral("4")); + + const QModelIndex indexA = pm.mapFromSource(mod.index(0, 0)); + QVERIFY(indexA.isValid()); + QCOMPARE(indexA, pm.index(0, 0)); + + const QModelIndex indexB = pm.mapFromSource(mod.index(0, 1)); + QVERIFY(!indexB.isValid()); + + const QModelIndex indexD = pm.mapFromSource(mod2.index(0, 0)); + QVERIFY(indexD.isValid()); + QCOMPARE(indexD, pm.index(1, 0)); +} + +void tst_QConcatenateTablesProxyModel::shouldIncreaseColumnCountWhenRemovingFirstModel() +{ + // Given a model with 2 columns and one with 3 columns + QConcatenateTablesProxyModel pm; + pm.addSourceModel(&mod); + QAbstractItemModelTester modelTest(&pm, this); + mod.setColumnCount(2); + pm.addSourceModel(&mod2); + QCOMPARE(pm.rowCount(), 2); + QCOMPARE(pm.columnCount(), 2); + + QSignalSpy colATBISpy(&pm, SIGNAL(columnsAboutToBeInserted(QModelIndex,int,int))); + QSignalSpy colInsertedSpy(&pm, SIGNAL(columnsInserted(QModelIndex,int,int))); + QSignalSpy rowATBRSpy(&pm, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int))); + QSignalSpy rowRemovedSpy(&pm, SIGNAL(rowsRemoved(QModelIndex,int,int))); + + // When removing the first source model + pm.removeSourceModel(&mod); + + // Then the proxy should notify its users about the row removed, and the column added + QCOMPARE(pm.rowCount(), 1); + QCOMPARE(pm.columnCount(), 3); + QCOMPARE(rowSpyToText(rowATBRSpy), QStringLiteral("0,0")); + QCOMPARE(rowSpyToText(rowRemovedSpy), QStringLiteral("0,0")); + QCOMPARE(rowSpyToText(colATBISpy), QStringLiteral("2,2")); + QCOMPARE(rowSpyToText(colInsertedSpy), QStringLiteral("2,2")); + QCOMPARE(extractRowTexts(&pm, 0), QStringLiteral("DEF")); +} + +void tst_QConcatenateTablesProxyModel::shouldHandleColumnInsertionAndRemoval() +{ + // Given two models combined, one with 2 columns and one with 3 + QConcatenateTablesProxyModel pm; + pm.addSourceModel(&mod); + QAbstractItemModelTester modelTest(&pm, this); + mod.setColumnCount(2); + pm.addSourceModel(&mod2); + QSignalSpy colATBISpy(&pm, SIGNAL(columnsAboutToBeInserted(QModelIndex,int,int))); + QSignalSpy colInsertedSpy(&pm, SIGNAL(columnsInserted(QModelIndex,int,int))); + QSignalSpy colATBRSpy(&pm, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int))); + QSignalSpy colRemovedSpy(&pm, SIGNAL(columnsRemoved(QModelIndex,int,int))); + + // When the first source model inserts a new column + QCOMPARE(mod.columnCount(), 2); + mod.setColumnCount(3); + + // Then the proxy should notify its users and show changes + QCOMPARE(rowSpyToText(colATBISpy), QStringLiteral("2,2")); + QCOMPARE(rowSpyToText(colInsertedSpy), QStringLiteral("2,2")); + QCOMPARE(pm.rowCount(), 2); + QCOMPARE(pm.columnCount(), 3); + QCOMPARE(extractRowTexts(&pm, 0), QStringLiteral("AB ")); + QCOMPARE(extractRowTexts(&pm, 1), QStringLiteral("DEF")); + + // And when removing two columns + mod.setColumnCount(1); + + // Then the proxy should notify its users and show changes + QCOMPARE(rowSpyToText(colATBRSpy), QStringLiteral("1,2")); + QCOMPARE(rowSpyToText(colRemovedSpy), QStringLiteral("1,2")); + QCOMPARE(pm.rowCount(), 2); + QCOMPARE(pm.columnCount(), 1); + QCOMPARE(extractRowTexts(&pm, 0), QStringLiteral("A")); + QCOMPARE(extractRowTexts(&pm, 1), QStringLiteral("D")); +} + +void tst_QConcatenateTablesProxyModel::shouldPropagateLayoutChanged() +{ + // Given two source models, the second one being a QSFPM + QConcatenateTablesProxyModel pm; + pm.addSourceModel(&mod); + QAbstractItemModelTester modelTest(&pm, this); + + QSortFilterProxyModel qsfpm; + qsfpm.setSourceModel(&mod3); + pm.addSourceModel(&qsfpm); + + QCOMPARE(extractRowTexts(&pm, 0), QStringLiteral("ABC")); + QCOMPARE(extractRowTexts(&pm, 1), QStringLiteral("123")); + QCOMPARE(extractRowTexts(&pm, 2), QStringLiteral("456")); + + // And a selection (row 1) + QItemSelectionModel selection(&pm); + selection.select(pm.index(1, 0), QItemSelectionModel::Select | QItemSelectionModel::Rows); + const QModelIndexList lst = selection.selectedIndexes(); + QCOMPARE(lst.count(), 3); + for (int col = 0; col < lst.count(); ++col) { + QCOMPARE(lst.at(col).row(), 1); + QCOMPARE(lst.at(col).column(), col); + } + + QSignalSpy layoutATBCSpy(&pm, SIGNAL(layoutAboutToBeChanged())); + QSignalSpy layoutChangedSpy(&pm, SIGNAL(layoutChanged())); + + // When changing the sorting in the QSFPM + qsfpm.sort(0, Qt::DescendingOrder); + + // Then the proxy should emit the layoutChanged signals, and show re-sorted data + QCOMPARE(extractRowTexts(&pm, 0), QStringLiteral("ABC")); + QCOMPARE(extractRowTexts(&pm, 1), QStringLiteral("456")); + QCOMPARE(extractRowTexts(&pm, 2), QStringLiteral("123")); + QCOMPARE(layoutATBCSpy.count(), 1); + QCOMPARE(layoutChangedSpy.count(), 1); + + // And the selection should be updated accordingly (it became row 2) + const QModelIndexList lstAfter = selection.selectedIndexes(); + QCOMPARE(lstAfter.count(), 3); + for (int col = 0; col < lstAfter.count(); ++col) { + QCOMPARE(lstAfter.at(col).row(), 2); + QCOMPARE(lstAfter.at(col).column(), col); + } +} + +void tst_QConcatenateTablesProxyModel::shouldReactToModelReset() +{ + // Given two source models, the second one being a QSFPM + QConcatenateTablesProxyModel pm; + pm.addSourceModel(&mod); + QAbstractItemModelTester modelTest(&pm, this); + + QSortFilterProxyModel qsfpm; + qsfpm.setSourceModel(&mod3); + pm.addSourceModel(&qsfpm); + + QCOMPARE(extractRowTexts(&pm, 0), QStringLiteral("ABC")); + QCOMPARE(extractRowTexts(&pm, 1), QStringLiteral("123")); + QCOMPARE(extractRowTexts(&pm, 2), QStringLiteral("456")); + QSignalSpy rowATBRSpy(&pm, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int))); + QSignalSpy rowRemovedSpy(&pm, SIGNAL(rowsRemoved(QModelIndex,int,int))); + QSignalSpy rowATBISpy(&pm, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int))); + QSignalSpy rowInsertedSpy(&pm, SIGNAL(rowsInserted(QModelIndex,int,int))); + QSignalSpy colATBRSpy(&pm, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int))); + QSignalSpy colRemovedSpy(&pm, SIGNAL(columnsRemoved(QModelIndex,int,int))); + QSignalSpy modelATBResetSpy(&pm, SIGNAL(modelAboutToBeReset())); + QSignalSpy modelResetSpy(&pm, SIGNAL(modelReset())); + + // When changing the source model of the QSFPM + qsfpm.setSourceModel(&mod2); + + // Then the proxy should emit the reset signals, and show the new data + QCOMPARE(extractRowTexts(&pm, 0), QStringLiteral("ABC")); + QCOMPARE(extractRowTexts(&pm, 1), QStringLiteral("DEF")); + QCOMPARE(rowATBRSpy.count(), 0); + QCOMPARE(rowRemovedSpy.count(), 0); + QCOMPARE(rowATBISpy.count(), 0); + QCOMPARE(rowInsertedSpy.count(), 0); + QCOMPARE(colATBRSpy.count(), 0); + QCOMPARE(colRemovedSpy.count(), 0); + QCOMPARE(modelATBResetSpy.count(), 1); + QCOMPARE(modelResetSpy.count(), 1); +} + +void tst_QConcatenateTablesProxyModel::shouldUpdateColumnsOnModelReset() +{ + // Given two source models, the first one being a QSFPM + QConcatenateTablesProxyModel pm; + + QSortFilterProxyModel qsfpm; + qsfpm.setSourceModel(&mod3); + pm.addSourceModel(&qsfpm); + pm.addSourceModel(&mod); + QAbstractItemModelTester modelTest(&pm, this); + + QCOMPARE(extractRowTexts(&pm, 0), QStringLiteral("123")); + QCOMPARE(extractRowTexts(&pm, 1), QStringLiteral("456")); + QCOMPARE(extractRowTexts(&pm, 2), QStringLiteral("ABC")); + + // ... and a model with only 2 columns + QStandardItemModel mod2Columns; + mod2Columns.appendRow({ new QStandardItem(QStringLiteral("W")), new QStandardItem(QStringLiteral("X")) }); + + QSignalSpy rowATBRSpy(&pm, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int))); + QSignalSpy rowRemovedSpy(&pm, SIGNAL(rowsRemoved(QModelIndex,int,int))); + QSignalSpy rowATBISpy(&pm, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int))); + QSignalSpy rowInsertedSpy(&pm, SIGNAL(rowsInserted(QModelIndex,int,int))); + QSignalSpy colATBRSpy(&pm, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int))); + QSignalSpy colRemovedSpy(&pm, SIGNAL(columnsRemoved(QModelIndex,int,int))); + QSignalSpy modelATBResetSpy(&pm, SIGNAL(modelAboutToBeReset())); + QSignalSpy modelResetSpy(&pm, SIGNAL(modelReset())); + + // When changing the source model of the QSFPM + qsfpm.setSourceModel(&mod2Columns); + + // Then the proxy should reset, and show the new data + QCOMPARE(modelATBResetSpy.count(), 1); + QCOMPARE(modelResetSpy.count(), 1); + QCOMPARE(rowATBRSpy.count(), 0); + QCOMPARE(rowRemovedSpy.count(), 0); + QCOMPARE(rowATBISpy.count(), 0); + QCOMPARE(rowInsertedSpy.count(), 0); + QCOMPARE(colATBRSpy.count(), 0); + QCOMPARE(colRemovedSpy.count(), 0); + + QCOMPARE(pm.rowCount(), 2); + QCOMPARE(extractRowTexts(&pm, 0), QStringLiteral("WX")); + QCOMPARE(extractRowTexts(&pm, 1), QStringLiteral("AB")); +} + +void tst_QConcatenateTablesProxyModel::shouldPropagateDropOnItem_data() +{ + QTest::addColumn<int>("sourceRow"); + QTest::addColumn<int>("destRow"); + QTest::addColumn<QString>("expectedResult"); + + QTest::newRow("0-3") << 0 << 3 << QStringLiteral("ABCA"); + QTest::newRow("1-2") << 1 << 2 << QStringLiteral("ABBD"); + QTest::newRow("2-1") << 2 << 1 << QStringLiteral("ACCD"); + QTest::newRow("3-0") << 3 << 0 << QStringLiteral("DBCD"); + +} + +void tst_QConcatenateTablesProxyModel::shouldPropagateDropOnItem() +{ + // Given two source models who handle drops + + // Note: QStandardItemModel handles drop onto items by inserting child rows, + // which is good for QTreeView but not for QTableView or QConcatenateTablesProxyModel. + // So we use QStringListModel here instead. + QConcatenateTablesProxyModel pm; + QStringListModel model1({QStringLiteral("A"), QStringLiteral("B")}); + QStringListModel model2({QStringLiteral("C"), QStringLiteral("D")}); + pm.addSourceModel(&model1); + pm.addSourceModel(&model2); + QAbstractItemModelTester modelTest(&pm, this); + QCOMPARE(extractColumnTexts(&pm, 0), QStringLiteral("ABCD")); + + // When dragging one item + QFETCH(int, sourceRow); + QMimeData* mimeData = pm.mimeData({pm.index(sourceRow, 0)}); + QVERIFY(mimeData); + + // and dropping onto another item + QFETCH(int, destRow); + QVERIFY(pm.canDropMimeData(mimeData, Qt::CopyAction, -1, -1, pm.index(destRow, 0))); + QVERIFY(pm.dropMimeData(mimeData, Qt::CopyAction, -1, -1, pm.index(destRow, 0))); + delete mimeData; + + // Then the result should be as expected + QFETCH(QString, expectedResult); + QCOMPARE(extractColumnTexts(&pm, 0), expectedResult); +} + +void tst_QConcatenateTablesProxyModel::shouldPropagateDropBetweenItems() +{ + // Given two models combined + QConcatenateTablesProxyModel pm; + pm.addSourceModel(&mod3); + pm.addSourceModel(&mod2); + QAbstractItemModelTester modelTest(&pm, this); + QCOMPARE(pm.rowCount(), 3); + QCOMPARE(extractRowTexts(&pm, 0), QStringLiteral("123")); + QCOMPARE(extractRowTexts(&pm, 1), QStringLiteral("456")); + QCOMPARE(extractRowTexts(&pm, 2), QStringLiteral("DEF")); + + // When dragging the last row + QModelIndexList indexes; + indexes.reserve(pm.columnCount()); + for (int col = 0; col < pm.columnCount(); ++col) { + indexes.append(pm.index(2, col)); + } + QMimeData* mimeData = pm.mimeData(indexes); + QVERIFY(mimeData); + + // and dropping it before row 1 + const int destRow = 1; + QVERIFY(pm.canDropMimeData(mimeData, Qt::CopyAction, destRow, 0, QModelIndex())); + QVERIFY(pm.dropMimeData(mimeData, Qt::CopyAction, destRow, 0, QModelIndex())); + delete mimeData; + + // Then a new row should be inserted + QCOMPARE(pm.rowCount(), 4); + QCOMPARE(extractRowTexts(&pm, 0), QStringLiteral("123")); + QCOMPARE(extractRowTexts(&pm, 1), QStringLiteral("DEF")); + QCOMPARE(extractRowTexts(&pm, 2), QStringLiteral("456")); + QCOMPARE(extractRowTexts(&pm, 3), QStringLiteral("DEF")); +} + +void tst_QConcatenateTablesProxyModel::shouldPropagateDropBetweenItemsAtModelBoundary() +{ + // Given two models combined + QConcatenateTablesProxyModel pm; + pm.addSourceModel(&mod3); + pm.addSourceModel(&mod2); + QAbstractItemModelTester modelTest(&pm, this); + QCOMPARE(pm.rowCount(), 3); + QCOMPARE(extractRowTexts(&pm, 0), QStringLiteral("123")); + QCOMPARE(extractRowTexts(&pm, 1), QStringLiteral("456")); + QCOMPARE(extractRowTexts(&pm, 2), QStringLiteral("DEF")); + + // When dragging the first row + QModelIndexList indexes; + indexes.reserve(pm.columnCount()); + for (int col = 0; col < pm.columnCount(); ++col) { + indexes.append(pm.index(0, col)); + } + QMimeData* mimeData = pm.mimeData(indexes); + QVERIFY(mimeData); + + // and dropping it before row 2 + const int destRow = 2; + QVERIFY(pm.canDropMimeData(mimeData, Qt::CopyAction, destRow, 0, QModelIndex())); + QVERIFY(pm.dropMimeData(mimeData, Qt::CopyAction, destRow, 0, QModelIndex())); + delete mimeData; + + // Then a new row should be inserted + QCOMPARE(pm.rowCount(), 4); + QCOMPARE(extractRowTexts(&pm, 0), QStringLiteral("123")); + QCOMPARE(extractRowTexts(&pm, 1), QStringLiteral("456")); + QCOMPARE(extractRowTexts(&pm, 2), QStringLiteral("123")); + QCOMPARE(extractRowTexts(&pm, 3), QStringLiteral("DEF")); + + // and it should be part of the second model + QCOMPARE(mod2.rowCount(), 2); +} + +void tst_QConcatenateTablesProxyModel::shouldPropagateDropAfterLastRow_data() +{ + QTest::addColumn<int>("destRow"); + + // Dropping after the last row is documented to be done with destRow == -1. + QTest::newRow("-1") << -1; + // However, sometimes QTreeView calls dropMimeData with destRow == rowCount... + // Not sure if that's a bug or not, but let's support it in the model, just in case. + QTest::newRow("3") << 3; +} + +void tst_QConcatenateTablesProxyModel::shouldPropagateDropAfterLastRow() +{ + QFETCH(int, destRow); + + // Given two models combined + QConcatenateTablesProxyModel pm; + pm.addSourceModel(&mod3); + pm.addSourceModel(&mod2); + QAbstractItemModelTester modelTest(&pm, this); + QCOMPARE(pm.rowCount(), 3); + QCOMPARE(extractRowTexts(&pm, 0), QStringLiteral("123")); + QCOMPARE(extractRowTexts(&pm, 1), QStringLiteral("456")); + QCOMPARE(extractRowTexts(&pm, 2), QStringLiteral("DEF")); + + // When dragging the second row + QModelIndexList indexes; + indexes.reserve(pm.columnCount()); + for (int col = 0; col < pm.columnCount(); ++col) { + indexes.append(pm.index(1, col)); + } + QMimeData* mimeData = pm.mimeData(indexes); + QVERIFY(mimeData); + + // and dropping it after the last row + QVERIFY(pm.canDropMimeData(mimeData, Qt::CopyAction, destRow, 0, QModelIndex())); + QVERIFY(pm.dropMimeData(mimeData, Qt::CopyAction, destRow, 0, QModelIndex())); + delete mimeData; + + // Then a new row should be inserted at the end + QCOMPARE(pm.rowCount(), 4); + QCOMPARE(extractRowTexts(&pm, 0), QStringLiteral("123")); + QCOMPARE(extractRowTexts(&pm, 1), QStringLiteral("456")); + QCOMPARE(extractRowTexts(&pm, 2), QStringLiteral("DEF")); + QCOMPARE(extractRowTexts(&pm, 3), QStringLiteral("456")); + +} + +QTEST_GUILESS_MAIN(tst_QConcatenateTablesProxyModel) + +#include "tst_qconcatenatetablesproxymodel.moc" diff --git a/tests/auto/corelib/itemmodels/qitemmodel/modelstotest.cpp b/tests/auto/corelib/itemmodels/qitemmodel/modelstotest.cpp index 6ea7a38137..dbc7173028 100644 --- a/tests/auto/corelib/itemmodels/qitemmodel/modelstotest.cpp +++ b/tests/auto/corelib/itemmodels/qitemmodel/modelstotest.cpp @@ -251,7 +251,7 @@ QModelIndex ModelsToTest::populateTestArea(QAbstractItemModel *model) QString val = xval + QString::number(y) + QString::number(i); QModelIndex index = model->index(x, y, parent); model->setData(index, val); - model->setData(index, blue, Qt::TextColorRole); + model->setData(index, blue, Qt::ForegroundRole); } } */ @@ -276,7 +276,7 @@ QModelIndex ModelsToTest::populateTestArea(QAbstractItemModel *model) QString val = xval + QString::number(y) + QString::number(i); QModelIndex index = realModel->index(x, y, parent); realModel->setData(index, val); - realModel->setData(index, blue, Qt::TextColorRole); + realModel->setData(index, blue, Qt::ForegroundRole); } } */ diff --git a/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp b/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp index 7cd220e684..da13b9f33f 100644 --- a/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp +++ b/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp @@ -576,12 +576,12 @@ void tst_QItemModel::data() alignment == Qt::AlignJustify); } - QVariant colorVariant = currentModel->data(currentModel->index(0,0), Qt::BackgroundColorRole); + QVariant colorVariant = currentModel->data(currentModel->index(0,0), Qt::BackgroundRole); if (colorVariant.isValid()) { QVERIFY(colorVariant.canConvert<QColor>()); } - colorVariant = currentModel->data(currentModel->index(0,0), Qt::TextColorRole); + colorVariant = currentModel->data(currentModel->index(0,0), Qt::ForegroundRole); if (colorVariant.isValid()) { QVERIFY(colorVariant.canConvert<QColor>()); } diff --git a/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp b/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp index 9a54c0a70d..16e5170a47 100644 --- a/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp +++ b/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp @@ -82,8 +82,116 @@ private slots: void setData_emits_both_roles(); void supportedDragDropActions(); + + void moveRows_data(); + void moveRows(); + void moveRowsInvalid_data(); + void moveRowsInvalid(); + + void itemData(); + void setItemData(); }; +void tst_QStringListModel::moveRowsInvalid_data() +{ + QTest::addColumn<QStringListModel*>("baseModel"); + QTest::addColumn<QModelIndex>("startParent"); + QTest::addColumn<int>("startRow"); + QTest::addColumn<int>("count"); + QTest::addColumn<QModelIndex>("destinationParent"); + QTest::addColumn<int>("destination"); + + QStringListModel* tempModel = new QStringListModel(QStringList{"A", "B", "C", "D", "E", "F"}, this); + QTest::addRow("destination_equal_source") << tempModel << QModelIndex() << 0 << 1 << QModelIndex() << 1; + tempModel = new QStringListModel(QStringList{"A", "B", "C", "D", "E", "F"}, this); + QTest::addRow("count_equal_0") << tempModel << QModelIndex() << 0 << 0 << QModelIndex() << 2; + tempModel = new QStringListModel(QStringList{"A", "B", "C", "D", "E", "F"}, this); + QTest::addRow("move_child") << tempModel << tempModel->index(0, 0) << 0 << 1 << QModelIndex() << 2; + tempModel = new QStringListModel(QStringList{"A", "B", "C", "D", "E", "F"}, this); + QTest::addRow("move_to_child") << tempModel << QModelIndex() << 0 << 1 << tempModel->index(0, 0) << 2; + tempModel = new QStringListModel(QStringList{"A", "B", "C", "D", "E", "F"}, this); + QTest::addRow("negative_count") << tempModel << QModelIndex() << 0 << -1 << QModelIndex() << 2; + tempModel = new QStringListModel(QStringList{"A", "B", "C", "D", "E", "F"}, this); + QTest::addRow("negative_source_row") << tempModel << QModelIndex() << -1 << 1 << QModelIndex() << 2; + tempModel = new QStringListModel(QStringList{"A", "B", "C", "D", "E", "F"}, this); + QTest::addRow("negative_destination_row") << tempModel << QModelIndex() << 0 << 1 << QModelIndex() << -1; + tempModel = new QStringListModel(QStringList{"A", "B", "C", "D", "E", "F"}, this); + QTest::addRow("source_row_equal_rowCount") << tempModel << QModelIndex() << tempModel->rowCount() << 1 << QModelIndex() << 1; + tempModel = new QStringListModel(QStringList{"A", "B", "C", "D", "E", "F"}, this); + QTest::addRow("destination_row_greater_rowCount") << tempModel << QModelIndex() << 0 << 1 << QModelIndex() << tempModel->rowCount() + 1; + tempModel = new QStringListModel(QStringList{"A", "B", "C", "D", "E", "F"}, this); + QTest::addRow("move_row_within_source_range") << tempModel << QModelIndex() << 0 << 3 << QModelIndex() << 2; + tempModel = new QStringListModel(QStringList{"A", "B", "C", "D", "E", "F"}, this); + QTest::addRow("destination_row_before_0") << tempModel << QModelIndex() << 1 << 1 << QModelIndex() << 0; +} + +void tst_QStringListModel::moveRowsInvalid() +{ + QFETCH(QStringListModel* const, baseModel); + QFETCH(const QModelIndex, startParent); + QFETCH(const int, startRow); + QFETCH(const int, count); + QFETCH(const QModelIndex, destinationParent); + QFETCH(const int, destination); + + QSignalSpy rowMovedSpy(baseModel, &QAbstractItemModel::rowsMoved); + QSignalSpy rowAboutMovedSpy(baseModel, &QAbstractItemModel::rowsAboutToBeMoved); + QVERIFY(rowMovedSpy.isValid()); + QVERIFY(rowAboutMovedSpy.isValid()); + QVERIFY(!baseModel->moveRows(startParent, startRow, count, destinationParent, destination)); + QCOMPARE(rowMovedSpy.size(), 0); + QCOMPARE(rowAboutMovedSpy.size(), 0); + delete baseModel; +} + +void tst_QStringListModel::moveRows_data() +{ + QTest::addColumn<int>("startRow"); + QTest::addColumn<int>("count"); + QTest::addColumn<int>("destination"); + QTest::addColumn<QStringList>("expected"); + + QTest::newRow("1_Item_from_top_to_middle") << 0 << 1 << 3 << QStringList{"B", "C", "A", "D", "E", "F"}; + QTest::newRow("1_Item_from_top_to_bottom") << 0 << 1 << 6 << QStringList{"B", "C", "D", "E", "F", "A"}; + QTest::newRow("1_Item_from_middle_to_top") << 2 << 1 << 1 << QStringList{"C", "A", "B", "D", "E", "F"}; + QTest::newRow("1_Item_from_bottom_to_middle") << 5 << 1 << 3 << QStringList{"A", "B", "F", "C", "D", "E"}; + QTest::newRow("1_Item_from_bottom to_top") << 5 << 1 << 1 << QStringList{"F", "A", "B", "C", "D", "E"}; + QTest::newRow("1_Item_from_middle_to_bottom") << 2 << 1 << 6 << QStringList{"A", "B", "D", "E", "F", "C"}; + QTest::newRow("1_Item_from_middle_to_middle_before") << 2 << 1 << 1 << QStringList{"C", "A", "B", "D", "E", "F"}; + QTest::newRow("1_Item_from_middle_to_middle_after") << 2 << 1 << 4 << QStringList{"A", "B", "D", "C", "E", "F"}; + + QTest::newRow("2_Items_from_top_to_middle") << 0 << 2 << 3 << QStringList{"C", "A", "B", "D", "E", "F"}; + QTest::newRow("2_Items_from_top_to_bottom") << 0 << 2 << 6 << QStringList{"C", "D", "E", "F", "A", "B"}; + QTest::newRow("2_Items_from_middle_to_top") << 2 << 2 << 1 << QStringList{"C", "D", "A", "B", "E", "F"}; + QTest::newRow("2_Items_from_bottom_to_middle") << 4 << 2 << 3 << QStringList{"A", "B", "E", "F", "C", "D"}; + QTest::newRow("2_Items_from_bottom_to_top") << 4 << 2 << 1 << QStringList{"E", "F", "A", "B", "C", "D"}; + QTest::newRow("2_Items_from_middle_to_bottom") << 2 << 2 << 6 << QStringList{"A", "B", "E", "F", "C", "D"}; + QTest::newRow("2_Items_from_middle_to_middle_before") << 3 << 2 << 2 << QStringList{"A", "D", "E", "B", "C", "F"}; + QTest::newRow("2_Items_from_middle_to_middle_after") << 1 << 2 << 5 << QStringList{"A", "D", "E", "B", "C", "F"}; +} + +void tst_QStringListModel::moveRows() +{ + QFETCH(const int, startRow); + QFETCH(const int, count); + QFETCH(const int, destination); + QFETCH(const QStringList, expected); + QStringListModel baseModel(QStringList{"A", "B", "C", "D", "E", "F"}); + QSignalSpy rowMovedSpy(&baseModel, &QAbstractItemModel::rowsMoved); + QSignalSpy rowAboutMovedSpy(&baseModel, &QAbstractItemModel::rowsAboutToBeMoved); + QVERIFY(baseModel.moveRows(QModelIndex(), startRow, count, QModelIndex(), destination)); + QCOMPARE(baseModel.stringList(), expected); + QCOMPARE(rowMovedSpy.size(), 1); + QCOMPARE(rowAboutMovedSpy.size(), 1); + for (const QList<QVariant> &signalArgs : {rowMovedSpy.first(), rowAboutMovedSpy.first()}){ + QVERIFY(!signalArgs.at(0).value<QModelIndex>().isValid()); + QCOMPARE(signalArgs.at(1).toInt(), startRow); + QCOMPARE(signalArgs.at(2).toInt(), startRow + count - 1); + QVERIFY(!signalArgs.at(3).value<QModelIndex>().isValid()); + QCOMPARE(signalArgs.at(4).toInt(), destination); + } +} + void tst_QStringListModel::rowsAboutToBeRemoved_rowsRemoved_data() { QTest::addColumn<QStringList>("input"); @@ -246,6 +354,74 @@ void tst_QStringListModel::setData_emits_both_roles() expected); } +void tst_QStringListModel::itemData() +{ + QStringListModel testModel{ QStringList { + QStringLiteral("One"), + QStringLiteral("Two"), + QStringLiteral("Three"), + QStringLiteral("Four"), + QStringLiteral("Five") + }}; + QMap<int, QVariant> compareMap; + QCOMPARE(testModel.itemData(QModelIndex()), compareMap); + compareMap.insert(Qt::DisplayRole, QStringLiteral("Two")); + compareMap.insert(Qt::EditRole, QStringLiteral("Two")); + QCOMPARE(testModel.itemData(testModel.index(1, 0)), compareMap); +} + +void tst_QStringListModel::setItemData() +{ + QStringListModel testModel{ QStringList { + QStringLiteral("One"), + QStringLiteral("Two"), + QStringLiteral("Three"), + QStringLiteral("Four"), + QStringLiteral("Five") + }}; + QSignalSpy dataChangedSpy(&testModel, &QAbstractItemModel::dataChanged); + QModelIndex changeIndex = testModel.index(1, 0); + const QVector<int> changeRoles{Qt::DisplayRole, Qt::EditRole}; + const QString changedString("Changed"); + QMap<int, QVariant> newItemData{std::make_pair<int>(Qt::DisplayRole, changedString)}; + // invalid index does nothing and returns false + QVERIFY(!testModel.setItemData(QModelIndex(), newItemData)); + // valid data is set, return value is true and dataChanged is emitted once + QVERIFY(testModel.setItemData(changeIndex, newItemData)); + QCOMPARE(changeIndex.data(Qt::DisplayRole).toString(), changedString); + QCOMPARE(changeIndex.data(Qt::EditRole).toString(), changedString); + QCOMPARE(dataChangedSpy.size(), 1); + QVariantList dataChangedArguments = dataChangedSpy.takeFirst(); + QCOMPARE(dataChangedArguments.at(0).value<QModelIndex>(), changeIndex); + QCOMPARE(dataChangedArguments.at(1).value<QModelIndex>(), changeIndex); + QCOMPARE(dataChangedArguments.at(2).value<QVector<int> >(), changeRoles); + // Unsupported roles do nothing return false + newItemData.clear(); + newItemData.insert(Qt::UserRole, changedString); + QVERIFY(!testModel.setItemData(changeIndex, newItemData)); + QCOMPARE(dataChangedSpy.size(), 0); + // If some but not all the roles are supported it returns false and does nothing + newItemData.insert(Qt::EditRole, changedString); + changeIndex = testModel.index(2, 0); + QVERIFY(!testModel.setItemData(changeIndex, newItemData)); + QCOMPARE(changeIndex.data(Qt::DisplayRole).toString(), QStringLiteral("Three")); + QCOMPARE(changeIndex.data(Qt::EditRole).toString(), QStringLiteral("Three")); + QCOMPARE(dataChangedSpy.size(), 0); + // Qt::EditRole and Qt::DisplayRole are both set, Qt::EditRole takes precedence + newItemData.clear(); + newItemData.insert(Qt::EditRole, changedString); + newItemData.insert(Qt::DisplayRole, QStringLiteral("Ignored")); + changeIndex = testModel.index(3, 0); + QVERIFY(testModel.setItemData(changeIndex, newItemData)); + QCOMPARE(changeIndex.data(Qt::DisplayRole).toString(), changedString); + QCOMPARE(changeIndex.data(Qt::EditRole).toString(), changedString); + QCOMPARE(dataChangedSpy.size(), 1); + dataChangedArguments = dataChangedSpy.takeFirst(); + QCOMPARE(dataChangedArguments.at(0).value<QModelIndex>(), changeIndex); + QCOMPARE(dataChangedArguments.at(1).value<QModelIndex>(), changeIndex); + QCOMPARE(dataChangedArguments.at(2).value<QVector<int> >(), changeRoles); +} + void tst_QStringListModel::supportedDragDropActions() { QStringListModel model; diff --git a/tests/auto/corelib/itemmodels/qtransposeproxymodel/qtransposeproxymodel.pro b/tests/auto/corelib/itemmodels/qtransposeproxymodel/qtransposeproxymodel.pro new file mode 100644 index 0000000000..3834add115 --- /dev/null +++ b/tests/auto/corelib/itemmodels/qtransposeproxymodel/qtransposeproxymodel.pro @@ -0,0 +1,6 @@ +CONFIG += testcase +TARGET = tst_qtransposeproxymodel +QT = core gui testlib + +SOURCES = tst_qtransposeproxymodel.cpp + diff --git a/tests/auto/corelib/itemmodels/qtransposeproxymodel/tst_qtransposeproxymodel.cpp b/tests/auto/corelib/itemmodels/qtransposeproxymodel/tst_qtransposeproxymodel.cpp new file mode 100644 index 0000000000..a30ac46571 --- /dev/null +++ b/tests/auto/corelib/itemmodels/qtransposeproxymodel/tst_qtransposeproxymodel.cpp @@ -0,0 +1,915 @@ +/**************************************************************************** +** +** Copyright (C) 2018 Luca Beldi <v.ronin@yahoo.it> +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtCore module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QTest> +#include <QSignalSpy> +#include <QStandardItemModel> +#include <QStringListModel> +#include <QAbstractItemModelTester> +#include <random> + +#include <qtransposeproxymodel.h> + +class tst_QTransposeProxyModel : public QObject +{ + Q_OBJECT +private Q_SLOTS: + void initTestCase(); + void index(); + void data(); + void setData_data(); + void setData(); + void parent(); + void mapToSource(); + void mapFromSource(); + void basicTest_data(); + void basicTest(); + void sort(); + void insertRowBase_data(); + void insertRowBase(); + void insertColumnBase_data(); + void insertColumnBase(); + void insertColumnProxy_data(); + void insertColumnProxy(); + void insertRowProxy_data(); + void insertRowProxy(); + void removeRowBase_data(); + void removeRowBase(); + void removeColumnBase_data(); + void removeColumnBase(); + void removeColumnProxy_data(); + void removeColumnProxy(); + void removeRowProxy_data(); + void removeRowProxy(); + void headerData(); + void setHeaderData(); + void span(); + void itemData(); + void setItemData(); + void moveRowsBase(); + void moveColumnsProxy(); +private: + void testTransposed( + const QAbstractItemModel *const baseModel, + const QAbstractItemModel *const transposed, + const QModelIndex &baseParent = QModelIndex(), + const QModelIndex &transposedParent = QModelIndex() + ); + QAbstractItemModel *createListModel(QObject *parent); + QAbstractItemModel *createTableModel(QObject *parent); + QAbstractItemModel *createTreeModel(QObject *parent); +}; + +QAbstractItemModel *tst_QTransposeProxyModel::createListModel(QObject *parent) +{ + QStringList sequence; + sequence.reserve(10); + for (int i = 0; i < 10; ++i) + sequence.append(QString::number(i)); + return new QStringListModel(sequence, parent); +} + +QAbstractItemModel *tst_QTransposeProxyModel::createTableModel(QObject *parent) +{ + QAbstractItemModel *model = new QStandardItemModel(parent); + model->insertRows(0, 5); + model->insertColumns(0, 4); + for (int i = 0; i < model->rowCount(); ++i) { + for (int j = 0; j < model->columnCount(); ++j) { + model->setData(model->index(i, j), QStringLiteral("%1,%2").arg(i).arg(j), Qt::EditRole); + model->setData(model->index(i, j), i, Qt::UserRole); + model->setData(model->index(i, j), j, Qt::UserRole + 1); + } + } + return model; +} + +QAbstractItemModel *tst_QTransposeProxyModel::createTreeModel(QObject *parent) +{ + QAbstractItemModel *model = new QStandardItemModel(parent); + model->insertRows(0, 5); + model->insertColumns(0, 4); + for (int i = 0; i < model->rowCount(); ++i) { + for (int j = 0; j < model->columnCount(); ++j) { + const QModelIndex parIdx = model->index(i, j); + model->setData(parIdx, QStringLiteral("%1,%2").arg(i).arg(j), Qt::EditRole); + model->setData(parIdx, i, Qt::UserRole); + model->setData(parIdx, j, Qt::UserRole + 1); + model->insertRows(0, 3, parIdx); + model->insertColumns(0, 2, parIdx); + for (int h = 0; h < model->rowCount(parIdx); ++h) { + for (int k = 0; k < model->columnCount(parIdx); ++k) { + const QModelIndex childIdx = model->index(h, k, parIdx); + model->setData(childIdx, QStringLiteral("%1,%2,%3,%4").arg(i).arg(j).arg(h).arg(k), Qt::EditRole); + model->setData(childIdx, i, Qt::UserRole); + model->setData(childIdx, j, Qt::UserRole + 1); + model->setData(childIdx, h, Qt::UserRole + 2); + model->setData(childIdx, k, Qt::UserRole + 3); + } + } + } + } + return model; +} + +void tst_QTransposeProxyModel::testTransposed( + const QAbstractItemModel *const baseModel, + const QAbstractItemModel *const transposed, + const QModelIndex &baseParent, + const QModelIndex &transposedParent +) +{ + QCOMPARE(transposed->hasChildren(transposedParent), baseModel->hasChildren(baseParent)); + QCOMPARE(transposed->columnCount(transposedParent), baseModel->rowCount(baseParent)); + QCOMPARE(transposed->rowCount(transposedParent), baseModel->columnCount(baseParent)); + for (int i = 0, maxRow = baseModel->rowCount(baseParent); i < maxRow; ++i) { + for (int j = 0, maxCol = baseModel->columnCount(baseParent); j < maxCol; ++j) { + const QModelIndex baseIdx = baseModel->index(i, j, baseParent); + const QModelIndex transIdx = transposed->index(j, i, transposedParent); + QCOMPARE(transIdx.data(), baseIdx.data()); + QCOMPARE(transIdx.data(Qt::UserRole), baseIdx.data(Qt::UserRole)); + QCOMPARE(transIdx.data(Qt::UserRole + 1), baseIdx.data(Qt::UserRole + 1)); + QCOMPARE(transIdx.data(Qt::UserRole + 2), baseIdx.data(Qt::UserRole + 2)); + QCOMPARE(transIdx.data(Qt::UserRole + 3), baseIdx.data(Qt::UserRole + 3)); + if (baseModel->hasChildren(baseIdx)) { + testTransposed(baseModel, transposed, baseIdx, transIdx); + } + } + } +} + +void tst_QTransposeProxyModel::initTestCase() +{ + qRegisterMetaType<QList<QPersistentModelIndex> >(); + qRegisterMetaType<QAbstractItemModel::LayoutChangeHint>(); +} + +void tst_QTransposeProxyModel::index() +{ + QAbstractItemModel *model = createTreeModel(this); + QTransposeProxyModel proxy; + new QAbstractItemModelTester(&proxy, &proxy); + proxy.setSourceModel(model); + QVERIFY(!proxy.index(0, -1).isValid()); + QVERIFY(!proxy.index(0, -1).isValid()); + QVERIFY(!proxy.index(-1, -1).isValid()); + QVERIFY(!proxy.index(0, proxy.columnCount()).isValid()); + QVERIFY(!proxy.index(proxy.rowCount(), 0).isValid()); + QVERIFY(!proxy.index(proxy.rowCount(), proxy.columnCount()).isValid()); + QModelIndex tempIdx = proxy.index(0, 1); + QVERIFY(tempIdx.isValid()); + QCOMPARE(tempIdx.row(), 0); + QCOMPARE(tempIdx.column(), 1); + tempIdx = proxy.index(0, 1, tempIdx); + QVERIFY(tempIdx.isValid()); + QCOMPARE(tempIdx.row(), 0); + QCOMPARE(tempIdx.column(), 1); + delete model; +} + +void tst_QTransposeProxyModel::data() +{ + QStringListModel model{QStringList{"A", "B"}}; + QTransposeProxyModel proxy; + new QAbstractItemModelTester(&proxy, &proxy); + proxy.setSourceModel(&model); + QCOMPARE(proxy.index(0, 1).data().toString(), QStringLiteral("B")); +} + +void tst_QTransposeProxyModel::parent() +{ + QAbstractItemModel *model = createTreeModel(this); + QTransposeProxyModel proxy; + new QAbstractItemModelTester(&proxy, &proxy); + proxy.setSourceModel(model); + const QModelIndex parentIdx = proxy.index(0, 0); + const QModelIndex childIdx = proxy.index(0, 0, parentIdx); + QVERIFY(parentIdx.isValid()); + QVERIFY(childIdx.isValid()); + QCOMPARE(childIdx.parent(), parentIdx); + delete model; +} + +void tst_QTransposeProxyModel::mapToSource() +{ + QAbstractItemModel *model = createTreeModel(this); + QTransposeProxyModel proxy; + new QAbstractItemModelTester(&proxy, &proxy); + proxy.setSourceModel(model); + QVERIFY(!proxy.mapToSource(QModelIndex()).isValid()); + QCOMPARE(proxy.mapToSource(proxy.index(0, 0)), model->index(0, 0)); + QCOMPARE(proxy.mapToSource(proxy.index(1, 0)), model->index(0, 1)); + QCOMPARE(proxy.mapToSource(proxy.index(0, 1)), model->index(1, 0)); + const QModelIndex proxyParent = proxy.index(1, 0); + const QModelIndex sourceParent = model->index(0, 1); + QCOMPARE(proxy.mapToSource(proxy.index(0, 0, proxyParent)), model->index(0, 0, sourceParent)); + QCOMPARE(proxy.mapToSource(proxy.index(1, 0, proxyParent)), model->index(0, 1, sourceParent)); + QCOMPARE(proxy.mapToSource(proxy.index(0, 1, proxyParent)), model->index(1, 0, sourceParent)); + delete model; +} + +void tst_QTransposeProxyModel::mapFromSource() +{ + QAbstractItemModel *model = createTreeModel(this); + QTransposeProxyModel proxy; + new QAbstractItemModelTester(&proxy, &proxy); + proxy.setSourceModel(model); + QVERIFY(!proxy.mapFromSource(QModelIndex()).isValid()); + QCOMPARE(proxy.mapFromSource(model->index(0, 0)), proxy.index(0, 0)); + QCOMPARE(proxy.mapFromSource(model->index(0, 1)), proxy.index(1, 0)); + QCOMPARE(proxy.mapFromSource(model->index(1, 0)), proxy.index(0, 1)); + const QModelIndex proxyParent = proxy.index(1, 0); + const QModelIndex sourceParent = model->index(0, 1); + QCOMPARE(proxy.mapToSource(proxy.index(0, 0, proxyParent)), model->index(0, 0, sourceParent)); + QCOMPARE(proxy.mapFromSource(model->index(1, 0, sourceParent)), proxy.index(0, 1, proxyParent)); + QCOMPARE(proxy.mapFromSource(model->index(0, 1, sourceParent)), proxy.index(1, 0, proxyParent)); + delete model; +} + +void tst_QTransposeProxyModel::basicTest_data() +{ + QTest::addColumn<QAbstractItemModel *>("model"); + QTest::newRow("List") << createListModel(this); + QTest::newRow("Table") << createTableModel(this); + QTest::newRow("Tree") << createTreeModel(this); +} + +void tst_QTransposeProxyModel::basicTest() +{ + QFETCH(QAbstractItemModel *, model); + QTransposeProxyModel proxy; + new QAbstractItemModelTester(&proxy, &proxy); + proxy.setSourceModel(model); + testTransposed(model, &proxy); + delete model; +} + +void tst_QTransposeProxyModel::sort() +{ + QStringList sequence; + sequence.reserve(100); + for (int i = 0; i < 100; ++i) + sequence.append(QStringLiteral("%1").arg(i, 3, 10, QLatin1Char('0'))); + std::shuffle(sequence.begin(), sequence.end(), std::mt19937(88)); + const QString firstItemBeforeSort = sequence.first(); + QStringListModel baseModel(sequence); + QTransposeProxyModel proxyModel; + new QAbstractItemModelTester(&proxyModel, &proxyModel); + proxyModel.setSourceModel(&baseModel); + QSignalSpy layoutChangedSpy(&proxyModel, &QAbstractItemModel::layoutChanged); + QVERIFY(layoutChangedSpy.isValid()); + QSignalSpy layoutAboutToBeChangedSpy(&proxyModel, &QAbstractItemModel::layoutAboutToBeChanged); + QVERIFY(layoutAboutToBeChangedSpy.isValid()); + QPersistentModelIndex firstIndexBeforeSort = proxyModel.index(0, 0); + baseModel.sort(0, Qt::AscendingOrder); + QCOMPARE(layoutChangedSpy.count(), 1); + QCOMPARE(layoutAboutToBeChangedSpy.count(), 1); + QCOMPARE(layoutChangedSpy.takeFirst().at(1).toInt(), int(QAbstractItemModel::HorizontalSortHint)); + QCOMPARE(firstIndexBeforeSort.data().toString(), firstItemBeforeSort); + for (int i = 0; i < 100; ++i) + QCOMPARE(proxyModel.index(0, i).data().toInt(), i); +} + +void tst_QTransposeProxyModel::removeColumnBase_data() +{ + QTest::addColumn<QAbstractItemModel *>("model"); + QTest::addColumn<QModelIndex>("parent"); + QTest::newRow("Table") << createTableModel(this) << QModelIndex(); + QTest::newRow("Tree_Root_Item") << createTreeModel(this) << QModelIndex(); + QAbstractItemModel *model = createTreeModel(this); + QTest::newRow("Tree_Child_Item") << model << model->index(0, 0); +} + +void tst_QTransposeProxyModel::removeColumnBase() +{ + QFETCH(QAbstractItemModel * const, model); + QFETCH(const QModelIndex, parent); + QTransposeProxyModel proxy; + QSignalSpy rowRemoveSpy(&proxy, &QAbstractItemModel::rowsRemoved); + QVERIFY(rowRemoveSpy.isValid()); + QSignalSpy rowAboutToBeRemoveSpy(&proxy, &QAbstractItemModel::rowsAboutToBeRemoved); + QVERIFY(rowAboutToBeRemoveSpy.isValid()); + new QAbstractItemModelTester(&proxy, &proxy); + proxy.setSourceModel(model); + const int oldRowCount = proxy.rowCount(proxy.mapFromSource(parent)); + const QVariant expectedNewVal = model->index(0, 2, parent).data(); + QVERIFY(model->removeColumn(1, parent)); + QCOMPARE(proxy.rowCount(proxy.mapFromSource(parent)), oldRowCount - 1); + QCOMPARE(proxy.index(1, 0, proxy.mapFromSource(parent)).data(), expectedNewVal); + QCOMPARE(rowRemoveSpy.count(), 1); + QCOMPARE(rowAboutToBeRemoveSpy.count(), 1); + for (const auto &spyArgs : {rowRemoveSpy.takeFirst(), + rowAboutToBeRemoveSpy.takeFirst()}) { + QCOMPARE(spyArgs.at(0).value<QModelIndex>(), proxy.mapFromSource(parent)); + QCOMPARE(spyArgs.at(1).toInt(), 1); + QCOMPARE(spyArgs.at(2).toInt(), 1); + } + delete model; +} + +void tst_QTransposeProxyModel::insertColumnBase_data() +{ + QTest::addColumn<QAbstractItemModel *>("model"); + QTest::addColumn<QModelIndex>("parent"); + QTest::newRow("Table") << createTableModel(this) << QModelIndex(); + QTest::newRow("Tree_Root_Item") << createTreeModel(this) << QModelIndex(); + QAbstractItemModel *model = createTreeModel(this); + QTest::newRow("Tree_Child_Item") << model << model->index(0, 0); +} + +void tst_QTransposeProxyModel::insertColumnBase() +{ + QFETCH(QAbstractItemModel * const, model); + QFETCH(const QModelIndex, parent); + QTransposeProxyModel proxy; + QSignalSpy rowInsertSpy(&proxy, &QAbstractItemModel::rowsInserted); + QVERIFY(rowInsertSpy.isValid()); + QSignalSpy rowAboutToBeInsertSpy(&proxy, &QAbstractItemModel::rowsAboutToBeInserted); + QVERIFY(rowAboutToBeInsertSpy.isValid()); + new QAbstractItemModelTester(&proxy, &proxy); + proxy.setSourceModel(model); + const int oldRowCount = proxy.rowCount(proxy.mapFromSource(parent)); + QVERIFY(model->insertColumn(1, parent)); + QCOMPARE(proxy.rowCount(proxy.mapFromSource(parent)), oldRowCount + 1); + QVERIFY(!proxy.index(1, 0, proxy.mapFromSource(parent)).data().isValid()); + QCOMPARE(rowInsertSpy.count(), 1); + QCOMPARE(rowAboutToBeInsertSpy.count(), 1); + for (const auto &spyArgs : {rowInsertSpy.takeFirst(), + rowAboutToBeInsertSpy.takeFirst()}) { + QCOMPARE(spyArgs.at(0).value<QModelIndex>(), proxy.mapFromSource(parent)); + QCOMPARE(spyArgs.at(1).toInt(), 1); + QCOMPARE(spyArgs.at(2).toInt(), 1); + } + delete model; +} + +void tst_QTransposeProxyModel::removeRowBase_data() +{ + QTest::addColumn<QAbstractItemModel *>("model"); + QTest::addColumn<QModelIndex>("parent"); + QTest::newRow("List") << createListModel(this) << QModelIndex(); + QTest::newRow("Table") << createTableModel(this) << QModelIndex(); + QTest::newRow("Tree_Root_Item") << createTreeModel(this) << QModelIndex(); + QAbstractItemModel *model = createTreeModel(this); + QTest::newRow("Tree_Child_Item") << model << model->index(0, 0); +} + +void tst_QTransposeProxyModel::removeRowBase() +{ + QFETCH(QAbstractItemModel * const, model); + QFETCH(const QModelIndex, parent); + QTransposeProxyModel proxy; + QSignalSpy columnsRemoveSpy(&proxy, &QAbstractItemModel::columnsRemoved); + QVERIFY(columnsRemoveSpy.isValid()); + QSignalSpy columnsAboutToBeRemoveSpy(&proxy, &QAbstractItemModel::columnsAboutToBeRemoved); + QVERIFY(columnsAboutToBeRemoveSpy.isValid()); + new QAbstractItemModelTester(&proxy, &proxy); + proxy.setSourceModel(model); + const int oldColCount = proxy.columnCount(proxy.mapFromSource(parent)); + const QVariant expectedNewVal = model->index(2, 0, parent).data(); + QVERIFY(model->removeRow(1, parent)); + QCOMPARE(proxy.columnCount(proxy.mapFromSource(parent)), oldColCount - 1); + QCOMPARE(proxy.index(0, 1, proxy.mapFromSource(parent)).data(), expectedNewVal); + QCOMPARE(columnsRemoveSpy.count(), 1); + QCOMPARE(columnsAboutToBeRemoveSpy.count(), 1); + for (const auto &spyArgs : {columnsRemoveSpy.takeFirst(), + columnsAboutToBeRemoveSpy.takeFirst()}) { + QCOMPARE(spyArgs.at(0).value<QModelIndex>(), proxy.mapFromSource(parent)); + QCOMPARE(spyArgs.at(1).toInt(), 1); + QCOMPARE(spyArgs.at(2).toInt(), 1); + } + delete model; +} + +void tst_QTransposeProxyModel::insertRowBase_data() +{ + QTest::addColumn<QAbstractItemModel *>("model"); + QTest::addColumn<QModelIndex>("parent"); + QTest::newRow("List") << createListModel(this) << QModelIndex(); + QTest::newRow("Table") << createTableModel(this) << QModelIndex(); + QTest::newRow("Tree_Root_Item") << createTreeModel(this) << QModelIndex(); + QAbstractItemModel *model = createTreeModel(this); + QTest::newRow("Tree_Child_Item") << model << model->index(0, 0); +} + +void tst_QTransposeProxyModel::insertRowBase() +{ + QFETCH(QAbstractItemModel * const, model); + QFETCH(const QModelIndex, parent); + QTransposeProxyModel proxy; + QSignalSpy columnsInsertSpy(&proxy, &QAbstractItemModel::columnsInserted); + QVERIFY(columnsInsertSpy.isValid()); + QSignalSpy columnsAboutToBeInsertSpy(&proxy, &QAbstractItemModel::columnsAboutToBeInserted); + QVERIFY(columnsAboutToBeInsertSpy.isValid()); + new QAbstractItemModelTester(&proxy, &proxy); + proxy.setSourceModel(model); + const int oldColCount = proxy.columnCount(proxy.mapFromSource(parent)); + QVERIFY(model->insertRow(1, parent)); + QCOMPARE(proxy.columnCount(proxy.mapFromSource(parent)), oldColCount + 1); + QVERIFY(proxy.index(0, 1, proxy.mapFromSource(parent)).data().isNull()); + QCOMPARE(columnsInsertSpy.count(), 1); + QCOMPARE(columnsAboutToBeInsertSpy.count(), 1); + for (const auto &spyArgs : {columnsInsertSpy.takeFirst(), + columnsAboutToBeInsertSpy.takeFirst()}) { + QCOMPARE(spyArgs.at(0).value<QModelIndex>(), proxy.mapFromSource(parent)); + QCOMPARE(spyArgs.at(1).toInt(), 1); + QCOMPARE(spyArgs.at(2).toInt(), 1); + } + delete model; +} + +void tst_QTransposeProxyModel::removeColumnProxy_data() +{ + QTest::addColumn<QAbstractItemModel *>("model"); + QTest::addColumn<bool>("rootItem"); + QTest::newRow("List") << createListModel(this) << true; + QTest::newRow("Table") << createTableModel(this) << true; + QTest::newRow("Tree_Root_Item") << createTreeModel(this) << true; + QTest::newRow("Tree_Child_Item") << createTreeModel(this) << false; +} + +void tst_QTransposeProxyModel::removeColumnProxy() +{ + QFETCH(QAbstractItemModel *, model); + QFETCH(bool, rootItem); + QTransposeProxyModel proxy; + new QAbstractItemModelTester(&proxy, &proxy); + QSignalSpy columnsRemoveSpy(&proxy, &QAbstractItemModel::columnsRemoved); + QVERIFY(columnsRemoveSpy.isValid()); + QSignalSpy columnsAboutToBeRemoveSpy(&proxy, &QAbstractItemModel::columnsAboutToBeRemoved); + QVERIFY(columnsAboutToBeRemoveSpy.isValid()); + QSignalSpy rowsRemoveSpy(model, &QAbstractItemModel::rowsRemoved); + QVERIFY(rowsRemoveSpy.isValid()); + QSignalSpy rowsAboutToBeRemoveSpy(model, &QAbstractItemModel::rowsAboutToBeRemoved); + QVERIFY(rowsAboutToBeRemoveSpy.isValid()); + proxy.setSourceModel(model); + const QModelIndex proxyParent = rootItem ? QModelIndex() : proxy.index(0, 1); + const QModelIndex sourceParent = proxy.mapToSource(proxyParent); + const int oldColCount = proxy.columnCount(proxyParent); + const int oldRowCount = model->rowCount(sourceParent); + const QVariant expectedNewVal = proxy.index(0, 2, proxyParent).data(); + QVERIFY(proxy.removeColumn(1, proxyParent)); + QCOMPARE(proxy.columnCount(proxyParent), oldColCount - 1); + QCOMPARE(model->rowCount(sourceParent), oldRowCount - 1); + QCOMPARE(proxy.index(0, 1, proxyParent).data(), expectedNewVal); + QCOMPARE(model->index(1, 0, sourceParent).data(), expectedNewVal); + QCOMPARE(columnsRemoveSpy.count(), 1); + QCOMPARE(columnsAboutToBeRemoveSpy.count(), 1); + QCOMPARE(rowsRemoveSpy.count(), 1); + QCOMPARE(rowsAboutToBeRemoveSpy.count(), 1); + for (const auto &spyArgs : {columnsRemoveSpy.takeFirst(), + columnsAboutToBeRemoveSpy.takeFirst()}) { + QCOMPARE(spyArgs.at(0).value<QModelIndex>(), proxyParent); + QCOMPARE(spyArgs.at(1).toInt(), 1); + QCOMPARE(spyArgs.at(2).toInt(), 1); + } + for (const auto &spyArgs : {rowsRemoveSpy.takeFirst(), + rowsAboutToBeRemoveSpy.takeFirst()}) { + QCOMPARE(spyArgs.at(0).value<QModelIndex>(), sourceParent); + QCOMPARE(spyArgs.at(1).toInt(), 1); + QCOMPARE(spyArgs.at(2).toInt(), 1); + } + delete model; +} + +void tst_QTransposeProxyModel::insertColumnProxy_data() +{ + QTest::addColumn<QAbstractItemModel *>("model"); + QTest::addColumn<bool>("rootItem"); + QTest::newRow("List") << createListModel(this) << true; + QTest::newRow("Table") << createTableModel(this) << true; + QTest::newRow("Tree_Root_Item") << createTreeModel(this) << true; + QTest::newRow("Tree_Child_Item") << createTreeModel(this) << false; +} + +void tst_QTransposeProxyModel::insertColumnProxy() +{ + QFETCH(QAbstractItemModel *, model); + QFETCH(bool, rootItem); + QTransposeProxyModel proxy; + new QAbstractItemModelTester(&proxy, &proxy); + QSignalSpy columnsInsertSpy(&proxy, &QAbstractItemModel::columnsInserted); + QVERIFY(columnsInsertSpy.isValid()); + QSignalSpy columnsAboutToBeInsertSpy(&proxy, &QAbstractItemModel::columnsAboutToBeInserted); + QVERIFY(columnsAboutToBeInsertSpy.isValid()); + QSignalSpy rowsInsertSpy(model, &QAbstractItemModel::rowsInserted); + QVERIFY(rowsInsertSpy.isValid()); + QSignalSpy rowsAboutToBeInsertSpy(model, &QAbstractItemModel::rowsAboutToBeInserted); + QVERIFY(rowsAboutToBeInsertSpy.isValid()); + proxy.setSourceModel(model); + const QModelIndex proxyParent = rootItem ? QModelIndex() : proxy.index(0, 1); + const QModelIndex sourceParent = proxy.mapToSource(proxyParent); + const int oldColCount = proxy.columnCount(proxyParent); + const int oldRowCount = model->rowCount(sourceParent); + QVERIFY(proxy.insertColumn(1, proxyParent)); + QCOMPARE(proxy.columnCount(proxyParent), oldColCount + 1); + QCOMPARE(model->rowCount(sourceParent), oldRowCount + 1); + QVERIFY(proxy.index(0, 1, proxyParent).data().isNull()); + QVERIFY(model->index(1, 0, sourceParent).data().isNull()); + QCOMPARE(columnsInsertSpy.count(), 1); + QCOMPARE(columnsAboutToBeInsertSpy.count(), 1); + QCOMPARE(rowsInsertSpy.count(), 1); + QCOMPARE(rowsAboutToBeInsertSpy.count(), 1); + for (const auto &spyArgs : {columnsInsertSpy.takeFirst(), + columnsAboutToBeInsertSpy.takeFirst()}) { + QCOMPARE(spyArgs.at(0).value<QModelIndex>(), proxyParent); + QCOMPARE(spyArgs.at(1).toInt(), 1); + QCOMPARE(spyArgs.at(2).toInt(), 1); + } + for (const auto &spyArgs : {rowsInsertSpy.takeFirst(), + rowsAboutToBeInsertSpy.takeFirst()}) { + QCOMPARE(spyArgs.at(0).value<QModelIndex>(), sourceParent); + QCOMPARE(spyArgs.at(1).toInt(), 1); + QCOMPARE(spyArgs.at(2).toInt(), 1); + } + delete model; +} + +void tst_QTransposeProxyModel::removeRowProxy_data() +{ + QTest::addColumn<QAbstractItemModel *>("model"); + QTest::addColumn<bool>("rootItem"); + QTest::newRow("Table") << createTableModel(this) << true; + QTest::newRow("Tree_Root_Item") << createTreeModel(this) << true; + QTest::newRow("Tree_Child_Item") << createTreeModel(this) << false; +} + +void tst_QTransposeProxyModel::removeRowProxy() +{ + QFETCH(QAbstractItemModel *, model); + QFETCH(bool, rootItem); + QTransposeProxyModel proxy; + new QAbstractItemModelTester(&proxy, &proxy); + QSignalSpy rowsRemoveSpy(&proxy, &QAbstractItemModel::rowsRemoved); + QVERIFY(rowsRemoveSpy.isValid()); + QSignalSpy rowsAboutToBeRemoveSpy(&proxy, &QAbstractItemModel::rowsAboutToBeRemoved); + QVERIFY(rowsAboutToBeRemoveSpy.isValid()); + QSignalSpy columnsRemoveSpy(model, &QAbstractItemModel::columnsRemoved); + QVERIFY(columnsRemoveSpy.isValid()); + QSignalSpy columnsAboutToBeRemoveSpy(model, &QAbstractItemModel::columnsAboutToBeRemoved); + QVERIFY(columnsAboutToBeRemoveSpy.isValid()); + proxy.setSourceModel(model); + const QModelIndex proxyParent = rootItem ? QModelIndex() : proxy.index(0, 1); + const QModelIndex sourceParent = proxy.mapToSource(proxyParent); + const int oldRowCount = proxy.rowCount(proxyParent); + const int oldColCount = model->columnCount(sourceParent); + const QVariant expectedNewVal = proxy.index(2, 0, proxyParent).data(); + QVERIFY(proxy.removeRow(1, proxyParent)); + QCOMPARE(proxy.rowCount(proxyParent), oldRowCount - 1); + QCOMPARE(model->columnCount(sourceParent), oldColCount - 1); + QCOMPARE(proxy.index(1, 0, proxyParent).data(), expectedNewVal); + QCOMPARE(model->index(0, 1, sourceParent).data(), expectedNewVal); + QCOMPARE(columnsRemoveSpy.count(), 1); + QCOMPARE(columnsAboutToBeRemoveSpy.count(), 1); + QCOMPARE(rowsRemoveSpy.count(), 1); + QCOMPARE(rowsAboutToBeRemoveSpy.count(), 1); + for (const auto &spyArgs : {columnsRemoveSpy.takeFirst(), + columnsAboutToBeRemoveSpy.takeFirst()}) { + QCOMPARE(spyArgs.at(0).value<QModelIndex>(), sourceParent); + QCOMPARE(spyArgs.at(1).toInt(), 1); + QCOMPARE(spyArgs.at(2).toInt(), 1); + } + for (const auto &spyArgs : {rowsRemoveSpy.takeFirst(), + rowsAboutToBeRemoveSpy.takeFirst()}) { + QCOMPARE(spyArgs.at(0).value<QModelIndex>(), proxyParent); + QCOMPARE(spyArgs.at(1).toInt(), 1); + QCOMPARE(spyArgs.at(2).toInt(), 1); + } + delete model; +} + +void tst_QTransposeProxyModel::insertRowProxy_data() +{ + QTest::addColumn<QAbstractItemModel *>("model"); + QTest::addColumn<bool>("rootItem"); + QTest::newRow("Table") << createTableModel(this) << true; + QTest::newRow("Tree_Root_Item") << createTreeModel(this) << true; + QTest::newRow("Tree_Child_Item") << createTreeModel(this) << false; +} + +void tst_QTransposeProxyModel::insertRowProxy() +{ + QFETCH(QAbstractItemModel *, model); + QFETCH(bool, rootItem); + QTransposeProxyModel proxy; + new QAbstractItemModelTester(&proxy, &proxy); + QSignalSpy rowsInsertSpy(&proxy, &QAbstractItemModel::rowsInserted); + QVERIFY(rowsInsertSpy.isValid()); + QSignalSpy rowsAboutToBeInsertSpy(&proxy, &QAbstractItemModel::rowsAboutToBeInserted); + QVERIFY(rowsAboutToBeInsertSpy.isValid()); + QSignalSpy columnsInsertSpy(model, &QAbstractItemModel::columnsInserted); + QVERIFY(columnsInsertSpy.isValid()); + QSignalSpy columnsAboutToBeInsertSpy(model, &QAbstractItemModel::columnsAboutToBeInserted); + QVERIFY(columnsAboutToBeInsertSpy.isValid()); + proxy.setSourceModel(model); + const QModelIndex proxyParent = rootItem ? QModelIndex() : proxy.index(0, 1); + const QModelIndex sourceParent = proxy.mapToSource(proxyParent); + const int oldRowCount = proxy.rowCount(proxyParent); + const int oldColCount = model->columnCount(sourceParent); + QVERIFY(proxy.insertRow(1, proxyParent)); + QCOMPARE(proxy.rowCount(proxyParent), oldRowCount + 1); + QCOMPARE(model->columnCount(sourceParent), oldColCount + 1); + QVERIFY(proxy.index(1, 0, proxyParent).data().isNull()); + QVERIFY(model->index(0, 1, sourceParent).data().isNull()); + QCOMPARE(columnsInsertSpy.count(), 1); + QCOMPARE(columnsAboutToBeInsertSpy.count(), 1); + QCOMPARE(rowsInsertSpy.count(), 1); + QCOMPARE(rowsAboutToBeInsertSpy.count(), 1); + for (const auto &spyArgs : {columnsInsertSpy.takeFirst(), + columnsAboutToBeInsertSpy.takeFirst()}) { + QCOMPARE(spyArgs.at(0).value<QModelIndex>(), sourceParent); + QCOMPARE(spyArgs.at(1).toInt(), 1); + QCOMPARE(spyArgs.at(2).toInt(), 1); + } + for (const auto &spyArgs : {rowsInsertSpy.takeFirst(), + rowsAboutToBeInsertSpy.takeFirst()}) { + QCOMPARE(spyArgs.at(0).value<QModelIndex>(), proxyParent); + QCOMPARE(spyArgs.at(1).toInt(), 1); + QCOMPARE(spyArgs.at(2).toInt(), 1); + } + delete model; +} + +void tst_QTransposeProxyModel::headerData() +{ + QStandardItemModel model; + model.insertRows(0, 3); + model.insertColumns(0, 5); + for (int i = 0; i < model.rowCount(); ++i) + model.setHeaderData(i, Qt::Horizontal, QChar('A' + i)); + for (int i = 1; i <= model.columnCount(); ++i) + model.setHeaderData(i, Qt::Vertical, i); + QTransposeProxyModel proxy; + new QAbstractItemModelTester(&proxy, &proxy); + proxy.setSourceModel(&model); + for (int i = 0; i < model.rowCount(); ++i) + QCOMPARE(model.headerData(i, Qt::Horizontal), proxy.headerData(i, Qt::Vertical)); + for (int i = 0; i < model.columnCount(); ++i) + QCOMPARE(model.headerData(i, Qt::Vertical), proxy.headerData(i, Qt::Horizontal)); +} + +void tst_QTransposeProxyModel::setHeaderData() +{ + QStandardItemModel model; + model.insertRows(0, 3); + model.insertColumns(0, 5); + for (int i = 0; i < model.rowCount(); ++i) + model.setHeaderData(i, Qt::Horizontal, QChar('A' + i)); + for (int i = 1; i <= model.columnCount(); ++i) + model.setHeaderData(i, Qt::Vertical, i); + QTransposeProxyModel proxy; + new QAbstractItemModelTester(&proxy, &proxy); + proxy.setSourceModel(&model); + QVERIFY(proxy.setHeaderData(1, Qt::Horizontal, 99)); + QCOMPARE(model.headerData(1, Qt::Vertical).toInt(), 99); + QVERIFY(proxy.setHeaderData(1, Qt::Vertical, QChar('Z'))); + QCOMPARE(model.headerData(1, Qt::Horizontal).toChar(), QChar('Z')); +} + +void tst_QTransposeProxyModel::span() +{ + class SpanModel : public QStandardItemModel + { + Q_DISABLE_COPY(SpanModel) + public: + SpanModel(int rows, int columns, QObject *parent = nullptr) + : QStandardItemModel(rows, columns, parent) + {} + QSize span(const QModelIndex &index) const override + { + Q_UNUSED(index) + return QSize(2, 1); + } + }; + SpanModel model(3, 5); + QTransposeProxyModel proxy; + new QAbstractItemModelTester(&proxy, &proxy); + proxy.setSourceModel(&model); + QCOMPARE(proxy.span(proxy.index(0, 0)), QSize(1, 2)); +} + +void tst_QTransposeProxyModel::itemData() +{ + QAbstractItemModel *model = createTreeModel(this); + QTransposeProxyModel proxy; + new QAbstractItemModelTester(&proxy, &proxy); + proxy.setSourceModel(model); + QMap<int, QVariant> itmData = proxy.itemData(proxy.index(0, 1)); + QCOMPARE(itmData.value(Qt::DisplayRole).toString(), QStringLiteral("1,0")); + QCOMPARE(itmData.value(Qt::UserRole).toInt(), 1); + QCOMPARE(itmData.value(Qt::UserRole + 1).toInt(), 0); + itmData = proxy.itemData(proxy.index(1, 2, proxy.index(0, 1))); + QCOMPARE(itmData.value(Qt::DisplayRole).toString(), QStringLiteral("1,0,2,1")); + QCOMPARE(itmData.value(Qt::UserRole).toInt(), 1); + QCOMPARE(itmData.value(Qt::UserRole + 1).toInt(), 0); + QCOMPARE(itmData.value(Qt::UserRole + 2).toInt(), 2); + QCOMPARE(itmData.value(Qt::UserRole + 3).toInt(), 1); + QVERIFY(proxy.itemData(QModelIndex()).isEmpty()); + delete model; +} + +void tst_QTransposeProxyModel::setItemData() +{ + QAbstractItemModel *model = createTreeModel(this); + QTransposeProxyModel proxy; + new QAbstractItemModelTester(&proxy, &proxy); + proxy.setSourceModel(model); + QSignalSpy sourceDataChangeSpy(model, &QAbstractItemModel::dataChanged); + QVERIFY(sourceDataChangeSpy.isValid()); + QSignalSpy proxyDataChangeSpy(&proxy, &QAbstractItemModel::dataChanged); + QVERIFY(proxyDataChangeSpy.isValid()); + const QMap<int, QVariant> itmData = { + std::make_pair<int, QVariant>(Qt::DisplayRole, QStringLiteral("Test")), + std::make_pair<int, QVariant>(Qt::UserRole, 88), + std::make_pair<int, QVariant>(Qt::UserRole + 1, 99), + }; + QModelIndex idx = proxy.index(0, 1); + QVERIFY(proxy.setItemData(idx, itmData)); + QCOMPARE(idx.data(Qt::DisplayRole).toString(), QStringLiteral("Test")); + QCOMPARE(idx.data(Qt::UserRole).toInt(), 88); + QCOMPARE(idx.data(Qt::UserRole + 1).toInt(), 99); + QCOMPARE(sourceDataChangeSpy.size(), 1); + QCOMPARE(proxyDataChangeSpy.size(), 1); + auto signalData = proxyDataChangeSpy.takeFirst(); + QCOMPARE(signalData.at(0).value<QModelIndex>(), idx); + QCOMPARE(signalData.at(1).value<QModelIndex>(), idx); + const QVector<int> expectedRoles{Qt::DisplayRole, Qt::UserRole, Qt::EditRole, Qt::UserRole + 1}; + QVector<int> receivedRoles = signalData.at(2).value<QVector<int> >(); + QCOMPARE(receivedRoles.size(), expectedRoles.size()); + for (int role : expectedRoles) + QVERIFY(receivedRoles.contains(role)); + signalData = sourceDataChangeSpy.takeFirst(); + QCOMPARE(signalData.at(0).value<QModelIndex>(), proxy.mapToSource(idx)); + QCOMPARE(signalData.at(1).value<QModelIndex>(), proxy.mapToSource(idx)); + receivedRoles = signalData.at(2).value<QVector<int> >(); + QCOMPARE(receivedRoles.size(), expectedRoles.size()); + for (int role : expectedRoles) + QVERIFY(receivedRoles.contains(role)); + idx = proxy.index(1, 2, proxy.index(0, 1)); + QVERIFY(proxy.setItemData(idx, itmData)); + QCOMPARE(idx.data(Qt::DisplayRole).toString(), QStringLiteral("Test")); + QCOMPARE(idx.data(Qt::UserRole).toInt(), 88); + QCOMPARE(idx.data(Qt::UserRole + 1).toInt(), 99); + QCOMPARE(idx.data(Qt::UserRole + 2).toInt(), 2); + QCOMPARE(idx.data(Qt::UserRole + 3).toInt(), 1); + QCOMPARE(sourceDataChangeSpy.size(), 1); + QCOMPARE(proxyDataChangeSpy.size(), 1); + signalData = proxyDataChangeSpy.takeFirst(); + QCOMPARE(signalData.at(0).value<QModelIndex>(), idx); + QCOMPARE(signalData.at(1).value<QModelIndex>(), idx); + receivedRoles = signalData.at(2).value<QVector<int> >(); + QCOMPARE(receivedRoles.size(), expectedRoles.size()); + for (int role : expectedRoles) + QVERIFY(receivedRoles.contains(role)); + signalData = sourceDataChangeSpy.takeFirst(); + QCOMPARE(signalData.at(0).value<QModelIndex>(), proxy.mapToSource(idx)); + QCOMPARE(signalData.at(1).value<QModelIndex>(), proxy.mapToSource(idx)); + receivedRoles = signalData.at(2).value<QVector<int> >(); + QCOMPARE(receivedRoles.size(), expectedRoles.size()); + for (int role : expectedRoles) + QVERIFY(receivedRoles.contains(role)); + QVERIFY(!proxy.setItemData(QModelIndex(), itmData)); + delete model; +} + +void tst_QTransposeProxyModel::moveRowsBase() +{ + QStringListModel model{QStringList{"A", "B", "C", "D"}}; + QTransposeProxyModel proxy; + QSignalSpy columnsMoveSpy(&proxy, &QAbstractItemModel::columnsMoved); + QVERIFY(columnsMoveSpy.isValid()); + QSignalSpy columnsAboutToBeMoveSpy(&proxy, &QAbstractItemModel::columnsAboutToBeMoved); + QVERIFY(columnsAboutToBeMoveSpy.isValid()); + new QAbstractItemModelTester(&proxy, &proxy); + proxy.setSourceModel(&model); + const QStringList expectedNewVal = {"B", "A", "C", "D"}; + QVERIFY(model.moveRows(QModelIndex(), 0, 1, QModelIndex(), 2)); + for (int i = 0; i < expectedNewVal.size(); ++i) + QCOMPARE(proxy.index(0, i).data(), expectedNewVal.at(i)); + QCOMPARE(columnsMoveSpy.count(), 1); + QCOMPARE(columnsAboutToBeMoveSpy.count(), 1); + for (const auto &spyArgs : {columnsMoveSpy.takeFirst(), + columnsAboutToBeMoveSpy.takeFirst()}) { + QVERIFY(!spyArgs.at(0).value<QModelIndex>().isValid()); + QCOMPARE(spyArgs.at(1).toInt(), 0); + QCOMPARE(spyArgs.at(2).toInt(), 0); + QVERIFY(!spyArgs.at(3).value<QModelIndex>().isValid()); + QCOMPARE(spyArgs.at(4).toInt(), 2); + } +} + +void tst_QTransposeProxyModel::moveColumnsProxy() +{ + QStringListModel model{QStringList{"A", "B", "C", "D"}}; + QTransposeProxyModel proxy; + new QAbstractItemModelTester(&proxy, &proxy); + QSignalSpy columnsMoveSpy(&proxy, &QAbstractItemModel::columnsMoved); + QVERIFY(columnsMoveSpy.isValid()); + QSignalSpy columnsAboutToBeMoveSpy(&proxy, &QAbstractItemModel::columnsAboutToBeMoved); + QVERIFY(columnsAboutToBeMoveSpy.isValid()); + QSignalSpy rowsMoveSpy(&model, &QAbstractItemModel::rowsMoved); + QVERIFY(rowsMoveSpy.isValid()); + QSignalSpy rowsAboutToBeMoveSpy(&model, &QAbstractItemModel::rowsAboutToBeMoved); + QVERIFY(rowsAboutToBeMoveSpy.isValid()); + proxy.setSourceModel(&model); + const QStringList expectedNewVal = {"B", "A", "C", "D"}; + QVERIFY(proxy.moveColumns(QModelIndex(), 0, 1, QModelIndex(), 2)); + for (int i = 0; i < expectedNewVal.size(); ++i) + QCOMPARE(proxy.index(0, i).data(), expectedNewVal.at(i)); + for (int i = 0; i < expectedNewVal.size(); ++i) + QCOMPARE(model.index(i, 0).data(), expectedNewVal.at(i)); + QCOMPARE(columnsMoveSpy.count(), 1); + QCOMPARE(columnsAboutToBeMoveSpy.count(), 1); + QCOMPARE(rowsMoveSpy.count(), 1); + QCOMPARE(rowsAboutToBeMoveSpy.count(), 1); + for (const auto &spyArgs : {columnsMoveSpy.takeFirst(), + columnsAboutToBeMoveSpy.takeFirst(), + rowsMoveSpy.takeFirst(),rowsAboutToBeMoveSpy.takeFirst()}) { + QVERIFY(!spyArgs.at(0).value<QModelIndex>().isValid()); + QCOMPARE(spyArgs.at(1).toInt(), 0); + QCOMPARE(spyArgs.at(2).toInt(), 0); + QVERIFY(!spyArgs.at(3).value<QModelIndex>().isValid()); + } +} + +void tst_QTransposeProxyModel::setData_data() +{ + QTest::addColumn<QAbstractItemModel *>("model"); + QTest::addColumn<bool>("rootItem"); + QTest::addColumn<bool>("viaProxy"); + QTest::newRow("List_via_Base") << createListModel(this) << true << false; + QTest::newRow("Table_via_Base") << createTableModel(this) << true << false; + QTest::newRow("Tree_via_Base_Root_Item") << createTreeModel(this) << true << false; + QTest::newRow("Tree_via_Base_Child_Item") << createTreeModel(this) << false << false; + QTest::newRow("List_via_Proxy") << createListModel(this) << true << true; + QTest::newRow("Table_via_Proxy") << createTableModel(this) << true << true; + QTest::newRow("Tree_via_Proxy_Root_Item") << createTreeModel(this) << true << true; + QTest::newRow("Tree_via_Proxy_Child_Item") << createTreeModel(this) << false << true; +} + +void tst_QTransposeProxyModel::setData() +{ + QFETCH(QAbstractItemModel *, model); + QFETCH(bool, rootItem); + QFETCH(bool, viaProxy); + QTransposeProxyModel proxy; + new QAbstractItemModelTester(&proxy, &proxy); + proxy.setSourceModel(model); + QSignalSpy sourceDataChangeSpy(model, &QAbstractItemModel::dataChanged); + QVERIFY(sourceDataChangeSpy.isValid()); + QSignalSpy proxyDataChangeSpy(&proxy, &QAbstractItemModel::dataChanged); + QVERIFY(proxyDataChangeSpy.isValid()); + const QString testData = QStringLiteral("TestingSetData"); + if (viaProxy) { + const QModelIndex parIdx = rootItem ? QModelIndex() : proxy.index(0, 1); + QVERIFY(proxy.setData(proxy.index(0, 1, parIdx), testData)); + QCOMPARE(model->index(1, 0, proxy.mapToSource(parIdx)).data().toString(), testData); + } else { + const QModelIndex parIdx = rootItem ? QModelIndex() : model->index(1, 0); + QVERIFY(model->setData(model->index(1, 0, parIdx), testData)); + QCOMPARE(proxy.index(0, 1, proxy.mapFromSource(parIdx)).data().toString(), testData); + } + QCOMPARE(sourceDataChangeSpy.size(), 1); + QCOMPARE(proxyDataChangeSpy.size(), 1); + delete model; +} + +QTEST_GUILESS_MAIN(tst_QTransposeProxyModel) + +#include "tst_qtransposeproxymodel.moc" diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp index 5d9b5ca95c..0c328dff58 100644 --- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp +++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp @@ -73,6 +73,7 @@ private slots: void defined(); void threadSafety(); void namespaces(); + void id(); void qMetaTypeId(); void properties(); void normalizedTypes(); @@ -475,6 +476,12 @@ void tst_QMetaType::namespaces() QCOMPARE(QMetaType::typeName(qungTfuId), "TestSpace::QungTfu"); } +void tst_QMetaType::id() +{ + QCOMPARE(QMetaType(QMetaType::QString).id(), QMetaType::QString); + QCOMPARE(QMetaType(::qMetaTypeId<TestSpace::Foo>()).id(), ::qMetaTypeId<TestSpace::Foo>()); +} + void tst_QMetaType::qMetaTypeId() { QCOMPARE(::qMetaTypeId<QString>(), int(QMetaType::QString)); @@ -1814,13 +1821,6 @@ DECLARE_NONSTREAMABLE(void) DECLARE_NONSTREAMABLE(void*) DECLARE_NONSTREAMABLE(QModelIndex) DECLARE_NONSTREAMABLE(QPersistentModelIndex) -DECLARE_NONSTREAMABLE(QJsonValue) -DECLARE_NONSTREAMABLE(QJsonObject) -DECLARE_NONSTREAMABLE(QJsonArray) -DECLARE_NONSTREAMABLE(QJsonDocument) -DECLARE_NONSTREAMABLE(QCborValue) -DECLARE_NONSTREAMABLE(QCborArray) -DECLARE_NONSTREAMABLE(QCborMap) DECLARE_NONSTREAMABLE(QObject*) DECLARE_NONSTREAMABLE(QWidget*) diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp index effc82261b..936cbd3894 100644 --- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp +++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp @@ -285,104 +285,100 @@ static void playWithObjects() void tst_QObject::disconnect() { - SenderObject *s = new SenderObject; - ReceiverObject *r1 = new ReceiverObject; - ReceiverObject *r2 = new ReceiverObject; + SenderObject s; + ReceiverObject r1; + ReceiverObject r2; - connect( s, SIGNAL(signal1()), r1, SLOT(slot1()) ); + connect(&s, SIGNAL(signal1()), &r1, SLOT(slot1())); - connect( s, SIGNAL(signal2()), r1, SLOT(slot2()) ); - connect( s, SIGNAL(signal3()), r1, SLOT(slot3()) ); - connect( s, SIGNAL(signal4()), r1, SLOT(slot4()) ); + connect(&s, SIGNAL(signal2()), &r1, SLOT(slot2())); + connect(&s, SIGNAL(signal3()), &r1, SLOT(slot3())); + connect(&s, SIGNAL(signal4()), &r1, SLOT(slot4())); - s->emitSignal1(); - s->emitSignal2(); - s->emitSignal3(); - s->emitSignal4(); + s.emitSignal1(); + s.emitSignal2(); + s.emitSignal3(); + s.emitSignal4(); - QVERIFY(r1->called(1)); - QVERIFY(r1->called(2)); - QVERIFY(r1->called(3)); - QVERIFY(r1->called(4)); - r1->reset(); + QVERIFY(r1.called(1)); + QVERIFY(r1.called(2)); + QVERIFY(r1.called(3)); + QVERIFY(r1.called(4)); + r1.reset(); // usual disconnect with all parameters given - bool ret = QObject::disconnect( s, SIGNAL(signal1()), r1, SLOT(slot1()) ); + bool ret = QObject::disconnect(&s, SIGNAL(signal1()), &r1, SLOT(slot1())); - s->emitSignal1(); + s.emitSignal1(); - QVERIFY(!r1->called(1)); - r1->reset(); + QVERIFY(!r1.called(1)); + r1.reset(); QVERIFY(ret); - ret = QObject::disconnect( s, SIGNAL(signal1()), r1, SLOT(slot1()) ); + ret = QObject::disconnect(&s, SIGNAL(signal1()), &r1, SLOT(slot1())); QVERIFY(!ret); // disconnect all signals from s from all slots from r1 - QObject::disconnect( s, 0, r1, 0 ); + QObject::disconnect(&s, 0, &r1, 0); - s->emitSignal2(); - s->emitSignal3(); - s->emitSignal4(); + s.emitSignal2(); + s.emitSignal3(); + s.emitSignal4(); - QVERIFY(!r1->called(2)); - QVERIFY(!r1->called(3)); - QVERIFY(!r1->called(4)); - r1->reset(); + QVERIFY(!r1.called(2)); + QVERIFY(!r1.called(3)); + QVERIFY(!r1.called(4)); + r1.reset(); - connect( s, SIGNAL(signal1()), r1, SLOT(slot1()) ); - connect( s, SIGNAL(signal1()), r1, SLOT(slot2()) ); - connect( s, SIGNAL(signal1()), r1, SLOT(slot3()) ); - connect( s, SIGNAL(signal2()), r1, SLOT(slot4()) ); + connect(&s, SIGNAL(signal1()), &r1, SLOT(slot1())); + connect(&s, SIGNAL(signal1()), &r1, SLOT(slot2())); + connect(&s, SIGNAL(signal1()), &r1, SLOT(slot3())); + connect(&s, SIGNAL(signal2()), &r1, SLOT(slot4())); // disconnect s's signal1() from all slots of r1 - QObject::disconnect( s, SIGNAL(signal1()), r1, 0 ); + QObject::disconnect(&s, SIGNAL(signal1()), &r1, 0); - s->emitSignal1(); - s->emitSignal2(); + s.emitSignal1(); + s.emitSignal2(); - QVERIFY(!r1->called(1)); - QVERIFY(!r1->called(2)); - QVERIFY(!r1->called(3)); - QVERIFY(r1->called(4)); - r1->reset(); + QVERIFY(!r1.called(1)); + QVERIFY(!r1.called(2)); + QVERIFY(!r1.called(3)); + QVERIFY(r1.called(4)); + r1.reset(); // make sure all is disconnected again - QObject::disconnect( s, 0, r1, 0 ); + QObject::disconnect(&s, 0, &r1, 0); - connect( s, SIGNAL(signal1()), r1, SLOT(slot1()) ); - connect( s, SIGNAL(signal1()), r2, SLOT(slot1()) ); - connect( s, SIGNAL(signal2()), r1, SLOT(slot2()) ); - connect( s, SIGNAL(signal2()), r2, SLOT(slot2()) ); - connect( s, SIGNAL(signal3()), r1, SLOT(slot3()) ); - connect( s, SIGNAL(signal3()), r2, SLOT(slot3()) ); + connect(&s, SIGNAL(signal1()), &r1, SLOT(slot1())); + connect(&s, SIGNAL(signal1()), &r2, SLOT(slot1())); + connect(&s, SIGNAL(signal2()), &r1, SLOT(slot2())); + connect(&s, SIGNAL(signal2()), &r2, SLOT(slot2())); + connect(&s, SIGNAL(signal3()), &r1, SLOT(slot3())); + connect(&s, SIGNAL(signal3()), &r2, SLOT(slot3())); // disconnect signal1() from all receivers - QObject::disconnect( s, SIGNAL(signal1()), 0, 0 ); - s->emitSignal1(); - s->emitSignal2(); - s->emitSignal3(); + QObject::disconnect(&s, SIGNAL(signal1()), 0, 0); + s.emitSignal1(); + s.emitSignal2(); + s.emitSignal3(); - QVERIFY(!r1->called(1)); - QVERIFY(!r2->called(1)); - QVERIFY(r1->called(2)); - QVERIFY(r2->called(2)); - QVERIFY(r1->called(2)); - QVERIFY(r2->called(2)); + QVERIFY(!r1.called(1)); + QVERIFY(!r2.called(1)); + QVERIFY(r1.called(2)); + QVERIFY(r2.called(2)); + QVERIFY(r1.called(2)); + QVERIFY(r2.called(2)); - r1->reset(); - r2->reset(); + r1.reset(); + r2.reset(); // disconnect all signals of s from all receivers - QObject::disconnect( s, 0, 0, 0 ); + QObject::disconnect(&s, 0, 0, 0); - QVERIFY(!r1->called(2)); - QVERIFY(!r2->called(2)); - QVERIFY(!r1->called(2)); - QVERIFY(!r2->called(2)); - - delete r2; - delete r1; - delete s; + QVERIFY(!r1.called(2)); + QVERIFY(!r2.called(2)); + QVERIFY(!r1.called(2)); + QVERIFY(!r2.called(2)); } class AutoConnectSender : public QObject @@ -798,192 +794,197 @@ void tst_QObject::connectDisconnectNotify_data() void tst_QObject::connectDisconnectNotify() { - NotifyObject *s = new NotifyObject; - NotifyObject *r = new NotifyObject; + NotifyObject s; + NotifyObject r; QFETCH(QString, a_signal); QFETCH(QString, a_slot); // Obtaining meta methods - int signalIndx = ((SenderObject*)s)->metaObject()->indexOfSignal( + int signalIndx = ((SenderObject &)s).metaObject()->indexOfSignal( QMetaObject::normalizedSignature(a_signal.toLatin1().constData()+1).constData()); - int methodIndx = ((ReceiverObject*)r)->metaObject()->indexOfMethod( + int methodIndx = ((ReceiverObject &)r).metaObject()->indexOfMethod( QMetaObject::normalizedSignature(a_slot.toLatin1().constData()+1).constData()); - QMetaMethod signal = ((SenderObject*)s)->metaObject()->method(signalIndx); - QMetaMethod method = ((ReceiverObject*)r)->metaObject()->method(methodIndx); + QMetaMethod signal = ((SenderObject &)s).metaObject()->method(signalIndx); + QMetaMethod method = ((ReceiverObject &)r).metaObject()->method(methodIndx); QVERIFY(signal.isValid()); QVERIFY(method.isValid()); // Test connectNotify - QVERIFY(QObject::connect((SenderObject*)s, a_signal.toLatin1(), (ReceiverObject*)r, a_slot.toLatin1())); - QCOMPARE(s->connectedSignals.size(), 1); - QCOMPARE(s->connectedSignals.at(0), signal); - QVERIFY(s->disconnectedSignals.isEmpty()); + QVERIFY(QObject::connect((SenderObject *)&s, a_signal.toLatin1(), + (ReceiverObject *)&r, a_slot.toLatin1())); + QCOMPARE(s.connectedSignals.size(), 1); + QCOMPARE(s.connectedSignals.at(0), signal); + QVERIFY(s.disconnectedSignals.isEmpty()); // Test disconnectNotify - QVERIFY(QObject::disconnect((SenderObject*)s, a_signal.toLatin1(), (ReceiverObject*)r, a_slot.toLatin1())); - QCOMPARE(s->disconnectedSignals.size(), 1); - QCOMPARE(s->disconnectedSignals.at(0), signal); - QCOMPARE(s->connectedSignals.size(), 1); + QVERIFY(QObject::disconnect((SenderObject *)&s, a_signal.toLatin1(), + (ReceiverObject *)&r, a_slot.toLatin1())); + QCOMPARE(s.disconnectedSignals.size(), 1); + QCOMPARE(s.disconnectedSignals.at(0), signal); + QCOMPARE(s.connectedSignals.size(), 1); // Reconnect - s->clearNotifications(); - QVERIFY(QObject::connect((SenderObject*)s, a_signal.toLatin1(), (ReceiverObject*)r, a_slot.toLatin1())); - QCOMPARE(s->connectedSignals.size(), 1); - QCOMPARE(s->connectedSignals.at(0), signal); - QVERIFY(s->disconnectedSignals.isEmpty()); + s.clearNotifications(); + QVERIFY(QObject::connect((SenderObject *)&s, a_signal.toLatin1(), + (ReceiverObject *)&r, a_slot.toLatin1())); + QCOMPARE(s.connectedSignals.size(), 1); + QCOMPARE(s.connectedSignals.at(0), signal); + QVERIFY(s.disconnectedSignals.isEmpty()); // Test disconnectNotify for a complete disconnect - QVERIFY(((SenderObject*)s)->disconnect((ReceiverObject*)r)); - QCOMPARE(s->disconnectedSignals.size(), 1); - QCOMPARE(s->disconnectedSignals.at(0), QMetaMethod()); - QCOMPARE(s->connectedSignals.size(), 1); + QVERIFY(((SenderObject *)&s)->disconnect((ReceiverObject *)&r)); + QCOMPARE(s.disconnectedSignals.size(), 1); + QCOMPARE(s.disconnectedSignals.at(0), QMetaMethod()); + QCOMPARE(s.connectedSignals.size(), 1); // Test connectNotify when connecting by QMetaMethod - s->clearNotifications(); - QVERIFY(QObject::connect((SenderObject*)s, signal, (ReceiverObject*)r, method)); - QCOMPARE(s->connectedSignals.size(), 1); - QCOMPARE(s->connectedSignals.at(0), signal); - QVERIFY(s->disconnectedSignals.isEmpty()); + s.clearNotifications(); + QVERIFY(QObject::connect((SenderObject *)&s, signal, (ReceiverObject *)&r, method)); + QCOMPARE(s.connectedSignals.size(), 1); + QCOMPARE(s.connectedSignals.at(0), signal); + QVERIFY(s.disconnectedSignals.isEmpty()); // Test disconnectNotify when disconnecting by QMetaMethod - QVERIFY(QObject::disconnect((SenderObject*)s, signal, (ReceiverObject*)r, method)); - QCOMPARE(s->disconnectedSignals.size(), 1); - QCOMPARE(s->disconnectedSignals.at(0), signal); - QCOMPARE(s->connectedSignals.size(), 1); + QVERIFY(QObject::disconnect((SenderObject *)&s, signal, (ReceiverObject *)&r, method)); + QCOMPARE(s.disconnectedSignals.size(), 1); + QCOMPARE(s.disconnectedSignals.at(0), signal); + QCOMPARE(s.connectedSignals.size(), 1); // Reconnect - s->clearNotifications(); - QVERIFY(QObject::connect((SenderObject*)s, a_signal.toLatin1(), (ReceiverObject*)r, a_slot.toLatin1())); + s.clearNotifications(); + QVERIFY(QObject::connect((SenderObject *)&s, a_signal.toLatin1(), + (ReceiverObject *)&r, a_slot.toLatin1())); // Test disconnectNotify for a complete disconnect by QMetaMethod - QVERIFY(QObject::disconnect((SenderObject*)s, QMetaMethod(), 0, QMetaMethod())); - QCOMPARE(s->disconnectedSignals.size(), 1); - QCOMPARE(s->disconnectedSignals.at(0), QMetaMethod()); - QCOMPARE(s->connectedSignals.size(), 1); + QVERIFY(QObject::disconnect((SenderObject *)&s, QMetaMethod(), 0, QMetaMethod())); + QCOMPARE(s.disconnectedSignals.size(), 1); + QCOMPARE(s.disconnectedSignals.at(0), QMetaMethod()); + QCOMPARE(s.connectedSignals.size(), 1); // Test connectNotify when connecting by index - s->clearNotifications(); - QVERIFY(QMetaObject::connect((SenderObject*)s, signalIndx, (ReceiverObject*)r, methodIndx)); - QCOMPARE(s->connectedSignals.size(), 1); - QCOMPARE(s->connectedSignals.at(0), signal); - QVERIFY(s->disconnectedSignals.isEmpty()); + s.clearNotifications(); + QVERIFY(QMetaObject::connect((SenderObject *)&s, signalIndx, (ReceiverObject *)&r, methodIndx)); + QCOMPARE(s.connectedSignals.size(), 1); + QCOMPARE(s.connectedSignals.at(0), signal); + QVERIFY(s.disconnectedSignals.isEmpty()); // Test disconnectNotify when disconnecting by index - QVERIFY(QMetaObject::disconnect((SenderObject*)s, signalIndx, (ReceiverObject*)r, methodIndx)); - QCOMPARE(s->disconnectedSignals.size(), 1); - QCOMPARE(s->disconnectedSignals.at(0), signal); - QCOMPARE(s->connectedSignals.size(), 1); - - delete s; - delete r; + QVERIFY(QMetaObject::disconnect((SenderObject *)&s, signalIndx, + (ReceiverObject *)&r, methodIndx)); + QCOMPARE(s.disconnectedSignals.size(), 1); + QCOMPARE(s.disconnectedSignals.at(0), signal); + QCOMPARE(s.connectedSignals.size(), 1); } static void connectDisconnectNotifyTestSlot() {} void tst_QObject::connectDisconnectNotifyPMF() { - NotifyObject *s = new NotifyObject; - NotifyObject *r = new NotifyObject; + NotifyObject s; + NotifyObject r; QMetaMethod signal = QMetaMethod::fromSignal(&SenderObject::signal1); // Test connectNotify - QVERIFY(QObject::connect((SenderObject*)s, &SenderObject::signal1, (ReceiverObject*)r, &ReceiverObject::slot1)); - QCOMPARE(s->connectedSignals.size(), 1); - QCOMPARE(s->connectedSignals.at(0), signal); - QVERIFY(s->disconnectedSignals.isEmpty()); + QVERIFY(QObject::connect((SenderObject *)&s, &SenderObject::signal1, + (ReceiverObject *)&r, &ReceiverObject::slot1)); + QCOMPARE(s.connectedSignals.size(), 1); + QCOMPARE(s.connectedSignals.at(0), signal); + QVERIFY(s.disconnectedSignals.isEmpty()); // Test disconnectNotify - QVERIFY(QObject::disconnect((SenderObject*)s, &SenderObject::signal1, (ReceiverObject*)r, &ReceiverObject::slot1)); - QCOMPARE(s->disconnectedSignals.size(), 1); - QCOMPARE(s->disconnectedSignals.at(0), signal); - QCOMPARE(s->connectedSignals.size(), 1); + QVERIFY(QObject::disconnect((SenderObject *)&s, &SenderObject::signal1, + (ReceiverObject *)&r, &ReceiverObject::slot1)); + QCOMPARE(s.disconnectedSignals.size(), 1); + QCOMPARE(s.disconnectedSignals.at(0), signal); + QCOMPARE(s.connectedSignals.size(), 1); // Reconnect - s->clearNotifications(); - QVERIFY(QObject::connect((SenderObject*)s, &SenderObject::signal1, (ReceiverObject*)r, &ReceiverObject::slot1)); - QCOMPARE(s->connectedSignals.size(), 1); - QCOMPARE(s->connectedSignals.at(0), signal); - QVERIFY(s->disconnectedSignals.isEmpty()); + s.clearNotifications(); + QVERIFY(QObject::connect((SenderObject *)&s, &SenderObject::signal1, + (ReceiverObject *)&r, &ReceiverObject::slot1)); + QCOMPARE(s.connectedSignals.size(), 1); + QCOMPARE(s.connectedSignals.at(0), signal); + QVERIFY(s.disconnectedSignals.isEmpty()); // Test disconnectNotify with wildcard slot - QVERIFY(QObject::disconnect((SenderObject*)s, &SenderObject::signal1, (ReceiverObject*)r, 0)); - QCOMPARE(s->disconnectedSignals.size(), 1); - QCOMPARE(s->disconnectedSignals.at(0), signal); - QCOMPARE(s->connectedSignals.size(), 1); + QVERIFY(QObject::disconnect((SenderObject *)&s, &SenderObject::signal1, + (ReceiverObject *)&r, 0)); + QCOMPARE(s.disconnectedSignals.size(), 1); + QCOMPARE(s.disconnectedSignals.at(0), signal); + QCOMPARE(s.connectedSignals.size(), 1); // Reconnect - s->clearNotifications(); - QMetaObject::Connection conn = connect((SenderObject*)s, &SenderObject::signal1, - (ReceiverObject*)r, &ReceiverObject::slot1); + s.clearNotifications(); + QMetaObject::Connection conn = connect((SenderObject *)&s, &SenderObject::signal1, + (ReceiverObject *)&r, &ReceiverObject::slot1); QVERIFY(conn); // Test disconnectNotify when disconnecting by QMetaObject::Connection QVERIFY(QObject::disconnect(conn)); - QVERIFY(!s->disconnectedSignals.isEmpty()); + QVERIFY(!s.disconnectedSignals.isEmpty()); // Test connectNotify when connecting by function pointer - s->clearNotifications(); - QVERIFY(QObject::connect((SenderObject*)s, &SenderObject::signal1, connectDisconnectNotifyTestSlot)); - QCOMPARE(s->connectedSignals.size(), 1); - QCOMPARE(s->connectedSignals.at(0), signal); - QVERIFY(s->disconnectedSignals.isEmpty()); - - delete s; - delete r; + s.clearNotifications(); + QVERIFY(QObject::connect((SenderObject *)&s, &SenderObject::signal1, + connectDisconnectNotifyTestSlot)); + QCOMPARE(s.connectedSignals.size(), 1); + QCOMPARE(s.connectedSignals.at(0), signal); + QVERIFY(s.disconnectedSignals.isEmpty()); } void tst_QObject::disconnectNotify_receiverDestroyed() { - NotifyObject *s = new NotifyObject; - NotifyObject *r = new NotifyObject; - - QVERIFY(QObject::connect((SenderObject*)s, SIGNAL(signal1()), (ReceiverObject*)r, SLOT(slot1()))); - - delete r; - QCOMPARE(s->disconnectedSignals.count(), 1); - QCOMPARE(s->disconnectedSignals.at(0), QMetaMethod::fromSignal(&SenderObject::signal1)); + NotifyObject s; - s->disconnectedSignals.clear(); - r = new NotifyObject; + { + NotifyObject r; + QVERIFY(QObject::connect((SenderObject *)&s, SIGNAL(signal1()), + (ReceiverObject *)&r, SLOT(slot1()))); + } + QCOMPARE(s.disconnectedSignals.count(), 1); + QCOMPARE(s.disconnectedSignals.at(0), QMetaMethod::fromSignal(&SenderObject::signal1)); - QVERIFY(QObject::connect((SenderObject*)s, SIGNAL(signal3()), (ReceiverObject*)r, SLOT(slot3()))); + s.disconnectedSignals.clear(); - delete r; - QCOMPARE(s->disconnectedSignals.count(), 1); - QCOMPARE(s->disconnectedSignals.at(0), QMetaMethod::fromSignal(&SenderObject::signal3)); + { + NotifyObject r; + QVERIFY(QObject::connect((SenderObject *)&s, SIGNAL(signal3()), + (ReceiverObject *)&r, SLOT(slot3()))); + } - s->disconnectedSignals.clear(); - r = new NotifyObject; + QCOMPARE(s.disconnectedSignals.count(), 1); + QCOMPARE(s.disconnectedSignals.at(0), QMetaMethod::fromSignal(&SenderObject::signal3)); - QVERIFY(QObject::connect((SenderObject*)s, SIGNAL(destroyed()), (ReceiverObject*)r, SLOT(slot3()))); + s.disconnectedSignals.clear(); - delete r; - QCOMPARE(s->disconnectedSignals.count(), 1); - QCOMPARE(s->disconnectedSignals.at(0), QMetaMethod::fromSignal(&QObject::destroyed)); + { + NotifyObject r; + QVERIFY(QObject::connect((SenderObject *)&s, SIGNAL(destroyed()), (ReceiverObject *)&r, SLOT(slot3()))); + } - delete s; + QCOMPARE(s.disconnectedSignals.count(), 1); + QCOMPARE(s.disconnectedSignals.at(0), QMetaMethod::fromSignal(&QObject::destroyed)); } void tst_QObject::disconnectNotify_metaObjConnection() { - NotifyObject *s = new NotifyObject; - NotifyObject *r = new NotifyObject; - - QMetaObject::Connection c = QObject::connect((SenderObject*)s, SIGNAL(signal1()), - (ReceiverObject*)r, SLOT(slot1())); - QVERIFY(c); - QVERIFY(QObject::disconnect(c)); + NotifyObject s; + { + NotifyObject r; - QCOMPARE(s->disconnectedSignals.count(), 1); - QCOMPARE(s->disconnectedSignals.at(0), QMetaMethod::fromSignal(&SenderObject::signal1)); + QMetaObject::Connection c = QObject::connect((SenderObject *)&s, SIGNAL(signal1()), + (ReceiverObject *)&r, SLOT(slot1())); + QVERIFY(c); + QVERIFY(QObject::disconnect(c)); - delete r; - QCOMPARE(s->disconnectedSignals.count(), 1); + QCOMPARE(s.disconnectedSignals.count(), 1); + QCOMPARE(s.disconnectedSignals.at(0), QMetaMethod::fromSignal(&SenderObject::signal1)); - delete s; + QCOMPARE(s.disconnectedSignals.count(), 1); + } } class ConnectByNameNotifySenderObject : public QObject @@ -3463,130 +3464,131 @@ void tst_QObject::qobjectConstCast() void tst_QObject::uniqConnection() { - SenderObject *s = new SenderObject; - ReceiverObject *r1 = new ReceiverObject; - ReceiverObject *r2 = new ReceiverObject; - r1->reset(); - r2->reset(); + SenderObject s; + ReceiverObject r1; + ReceiverObject r2; + r1.reset(); + r2.reset(); ReceiverObject::sequence = 0; - QVERIFY( connect( s, SIGNAL(signal1()), r1, SLOT(slot1()) , Qt::UniqueConnection) ); - QVERIFY( connect( s, SIGNAL(signal1()), r2, SLOT(slot1()) , Qt::UniqueConnection) ); - QVERIFY( connect( s, SIGNAL(signal1()), r1, SLOT(slot3()) , Qt::UniqueConnection) ); - QVERIFY( connect( s, SIGNAL(signal3()), r1, SLOT(slot3()) , Qt::UniqueConnection) ); + QVERIFY(connect(&s, SIGNAL(signal1()), &r1, SLOT(slot1()) , Qt::UniqueConnection) ); + QVERIFY(connect(&s, SIGNAL(signal1()), &r2, SLOT(slot1()) , Qt::UniqueConnection) ); + QVERIFY(connect(&s, SIGNAL(signal1()), &r1, SLOT(slot3()) , Qt::UniqueConnection) ); + QVERIFY(connect(&s, SIGNAL(signal3()), &r1, SLOT(slot3()) , Qt::UniqueConnection) ); - s->emitSignal1(); - s->emitSignal2(); - s->emitSignal3(); - s->emitSignal4(); - - QCOMPARE( r1->count_slot1, 1 ); - QCOMPARE( r1->count_slot2, 0 ); - QCOMPARE( r1->count_slot3, 2 ); - QCOMPARE( r1->count_slot4, 0 ); - QCOMPARE( r2->count_slot1, 1 ); - QCOMPARE( r2->count_slot2, 0 ); - QCOMPARE( r2->count_slot3, 0 ); - QCOMPARE( r2->count_slot4, 0 ); - QCOMPARE( r1->sequence_slot1, 1 ); - QCOMPARE( r2->sequence_slot1, 2 ); - QCOMPARE( r1->sequence_slot3, 4 ); - - r1->reset(); - r2->reset(); + s.emitSignal1(); + s.emitSignal2(); + s.emitSignal3(); + s.emitSignal4(); + + QCOMPARE(r1.count_slot1, 1); + QCOMPARE(r1.count_slot2, 0); + QCOMPARE(r1.count_slot3, 2); + QCOMPARE(r1.count_slot4, 0); + QCOMPARE(r2.count_slot1, 1); + QCOMPARE(r2.count_slot2, 0); + QCOMPARE(r2.count_slot3, 0); + QCOMPARE(r2.count_slot4, 0); + QCOMPARE(r1.sequence_slot1, 1); + QCOMPARE(r2.sequence_slot1, 2); + QCOMPARE(r1.sequence_slot3, 4); + + r1.reset(); + r2.reset(); ReceiverObject::sequence = 0; - QVERIFY( connect( s, SIGNAL(signal4()), r1, SLOT(slot4()) , Qt::UniqueConnection) ); - QVERIFY( connect( s, SIGNAL(signal4()), r2, SLOT(slot4()) , Qt::UniqueConnection) ); - QVERIFY(!connect( s, SIGNAL(signal4()), r2, SLOT(slot4()) , Qt::UniqueConnection) ); - QVERIFY( connect( s, SIGNAL(signal1()), r2, SLOT(slot4()) , Qt::UniqueConnection) ); - QVERIFY(!connect( s, SIGNAL(signal4()), r1, SLOT(slot4()) , Qt::UniqueConnection) ); + QVERIFY( connect(&s, SIGNAL(signal4()), &r1, SLOT(slot4()) , Qt::UniqueConnection)); + QVERIFY( connect(&s, SIGNAL(signal4()), &r2, SLOT(slot4()) , Qt::UniqueConnection)); + QVERIFY(!connect(&s, SIGNAL(signal4()), &r2, SLOT(slot4()) , Qt::UniqueConnection)); + QVERIFY( connect(&s, SIGNAL(signal1()), &r2, SLOT(slot4()) , Qt::UniqueConnection)); + QVERIFY(!connect(&s, SIGNAL(signal4()), &r1, SLOT(slot4()) , Qt::UniqueConnection)); - s->emitSignal4(); - QCOMPARE( r1->count_slot4, 1 ); - QCOMPARE( r2->count_slot4, 1 ); - QCOMPARE( r1->sequence_slot4, 1 ); - QCOMPARE( r2->sequence_slot4, 2 ); + s.emitSignal4(); + QCOMPARE(r1.count_slot4, 1); + QCOMPARE(r2.count_slot4, 1); + QCOMPARE(r1.sequence_slot4, 1); + QCOMPARE(r2.sequence_slot4, 2); - r1->reset(); - r2->reset(); + r1.reset(); + r2.reset(); ReceiverObject::sequence = 0; - connect( s, SIGNAL(signal4()), r1, SLOT(slot4()) ); - - s->emitSignal4(); - QCOMPARE( r1->count_slot4, 2 ); - QCOMPARE( r2->count_slot4, 1 ); - QCOMPARE( r1->sequence_slot4, 3 ); - QCOMPARE( r2->sequence_slot4, 2 ); + connect(&s, SIGNAL(signal4()), &r1, SLOT(slot4())); - delete s; - delete r1; - delete r2; + s.emitSignal4(); + QCOMPARE(r1.count_slot4, 2); + QCOMPARE(r2.count_slot4, 1); + QCOMPARE(r1.sequence_slot4, 3); + QCOMPARE(r2.sequence_slot4, 2); } void tst_QObject::uniqConnectionPtr() { - SenderObject *s = new SenderObject; - ReceiverObject *r1 = new ReceiverObject; - ReceiverObject *r2 = new ReceiverObject; - r1->reset(); - r2->reset(); + SenderObject s; + ReceiverObject r1; + ReceiverObject r2; + r1.reset(); + r2.reset(); ReceiverObject::sequence = 0; - QVERIFY( connect( s, &SenderObject::signal1, r1, &ReceiverObject::slot1 , Qt::UniqueConnection) ); - QVERIFY( connect( s, &SenderObject::signal1, r2, &ReceiverObject::slot1 , Qt::UniqueConnection) ); - QVERIFY( connect( s, &SenderObject::signal1, r1, &ReceiverObject::slot3 , Qt::UniqueConnection) ); - QVERIFY( connect( s, &SenderObject::signal3, r1, &ReceiverObject::slot3 , Qt::UniqueConnection) ); + QVERIFY(connect(&s, &SenderObject::signal1, &r1, &ReceiverObject::slot1 , + Qt::UniqueConnection)); + QVERIFY(connect(&s, &SenderObject::signal1, &r2, &ReceiverObject::slot1 , + Qt::UniqueConnection)); + QVERIFY(connect(&s, &SenderObject::signal1, &r1, &ReceiverObject::slot3 , + Qt::UniqueConnection)); + QVERIFY(connect(&s, &SenderObject::signal3, &r1, &ReceiverObject::slot3 , + Qt::UniqueConnection)); - s->emitSignal1(); - s->emitSignal2(); - s->emitSignal3(); - s->emitSignal4(); - - QCOMPARE( r1->count_slot1, 1 ); - QCOMPARE( r1->count_slot2, 0 ); - QCOMPARE( r1->count_slot3, 2 ); - QCOMPARE( r1->count_slot4, 0 ); - QCOMPARE( r2->count_slot1, 1 ); - QCOMPARE( r2->count_slot2, 0 ); - QCOMPARE( r2->count_slot3, 0 ); - QCOMPARE( r2->count_slot4, 0 ); - QCOMPARE( r1->sequence_slot1, 1 ); - QCOMPARE( r2->sequence_slot1, 2 ); - QCOMPARE( r1->sequence_slot3, 4 ); - - r1->reset(); - r2->reset(); + s.emitSignal1(); + s.emitSignal2(); + s.emitSignal3(); + s.emitSignal4(); + + QCOMPARE(r1.count_slot1, 1); + QCOMPARE(r1.count_slot2, 0); + QCOMPARE(r1.count_slot3, 2); + QCOMPARE(r1.count_slot4, 0); + QCOMPARE(r2.count_slot1, 1); + QCOMPARE(r2.count_slot2, 0); + QCOMPARE(r2.count_slot3, 0); + QCOMPARE(r2.count_slot4, 0); + QCOMPARE(r1.sequence_slot1, 1); + QCOMPARE(r2.sequence_slot1, 2); + QCOMPARE(r1.sequence_slot3, 4); + + r1.reset(); + r2.reset(); ReceiverObject::sequence = 0; - QVERIFY( connect( s, &SenderObject::signal4, r1, &ReceiverObject::slot4 , Qt::UniqueConnection) ); - QVERIFY( connect( s, &SenderObject::signal4, r2, &ReceiverObject::slot4 , Qt::UniqueConnection) ); - QVERIFY(!connect( s, &SenderObject::signal4, r2, &ReceiverObject::slot4 , Qt::UniqueConnection) ); - QVERIFY( connect( s, &SenderObject::signal1, r2, &ReceiverObject::slot4 , Qt::UniqueConnection) ); - QVERIFY(!connect( s, &SenderObject::signal4, r1, &ReceiverObject::slot4 , Qt::UniqueConnection) ); + QVERIFY( connect(&s, &SenderObject::signal4, &r1, &ReceiverObject::slot4 , + Qt::UniqueConnection)); + QVERIFY( connect(&s, &SenderObject::signal4, &r2, &ReceiverObject::slot4 , + Qt::UniqueConnection)); + QVERIFY(!connect(&s, &SenderObject::signal4, &r2, &ReceiverObject::slot4 , + Qt::UniqueConnection)); + QVERIFY( connect(&s, &SenderObject::signal1, &r2, &ReceiverObject::slot4 , + Qt::UniqueConnection)); + QVERIFY(!connect(&s, &SenderObject::signal4, &r1, &ReceiverObject::slot4 , + Qt::UniqueConnection)); - s->emitSignal4(); - QCOMPARE( r1->count_slot4, 1 ); - QCOMPARE( r2->count_slot4, 1 ); - QCOMPARE( r1->sequence_slot4, 1 ); - QCOMPARE( r2->sequence_slot4, 2 ); + s.emitSignal4(); + QCOMPARE(r1.count_slot4, 1); + QCOMPARE(r2.count_slot4, 1); + QCOMPARE(r1.sequence_slot4, 1); + QCOMPARE(r2.sequence_slot4, 2); - r1->reset(); - r2->reset(); + r1.reset(); + r2.reset(); ReceiverObject::sequence = 0; - connect( s, &SenderObject::signal4, r1, &ReceiverObject::slot4 ); + connect(&s, &SenderObject::signal4, &r1, &ReceiverObject::slot4); - s->emitSignal4(); - QCOMPARE( r1->count_slot4, 2 ); - QCOMPARE( r2->count_slot4, 1 ); - QCOMPARE( r1->sequence_slot4, 3 ); - QCOMPARE( r2->sequence_slot4, 2 ); - - delete s; - delete r1; - delete r2; + s.emitSignal4(); + QCOMPARE(r1.count_slot4, 2); + QCOMPARE(r2.count_slot4, 1); + QCOMPARE(r1.sequence_slot4, 3); + QCOMPARE(r2.sequence_slot4, 2); } void tst_QObject::interfaceIid() @@ -3890,217 +3892,214 @@ void tst_QObject::isSignalConnectedAfterDisconnection() void tst_QObject::qMetaObjectConnect() { - SenderObject *s = new SenderObject; - ReceiverObject *r1 = new ReceiverObject; - ReceiverObject *r2 = new ReceiverObject; - r1->reset(); - r2->reset(); - ReceiverObject::sequence = 0; - - int signal1Index = s->metaObject()->indexOfSignal("signal1()"); - int signal3Index = s->metaObject()->indexOfSignal("signal3()"); - int slot1Index = r1->metaObject()->indexOfSlot("slot1()"); - int slot2Index = r1->metaObject()->indexOfSlot("slot2()"); - int slot3Index = r1->metaObject()->indexOfSlot("slot3()"); - - QVERIFY(slot1Index > 0); - QVERIFY(slot2Index > 0); - QVERIFY(slot3Index > 0); - - QVERIFY( QMetaObject::connect( s, signal1Index, r1, slot1Index) ); - QVERIFY( QMetaObject::connect( s, signal3Index, r2, slot3Index) ); - QVERIFY( QMetaObject::connect( s, -1, r2, slot2Index) ); - - QCOMPARE( r1->count_slot1, 0 ); - QCOMPARE( r1->count_slot2, 0 ); - QCOMPARE( r1->count_slot3, 0 ); - QCOMPARE( r2->count_slot1, 0 ); - QCOMPARE( r2->count_slot2, 0 ); - QCOMPARE( r2->count_slot3, 0 ); - - s->emitSignal1(); - - QCOMPARE( r1->count_slot1, 1 ); - QCOMPARE( r1->count_slot2, 0 ); - QCOMPARE( r1->count_slot3, 0 ); - QCOMPARE( r2->count_slot1, 0 ); - QCOMPARE( r2->count_slot2, 1 ); - QCOMPARE( r2->count_slot3, 0 ); - - s->emitSignal2(); - s->emitSignal3(); - s->emitSignal4(); - - QCOMPARE( r1->count_slot1, 1 ); - QCOMPARE( r1->count_slot2, 0 ); - QCOMPARE( r1->count_slot3, 0 ); - QCOMPARE( r2->count_slot1, 0 ); - QCOMPARE( r2->count_slot2, 4 ); - QCOMPARE( r2->count_slot3, 1 ); - - QVERIFY( QMetaObject::disconnect( s, signal1Index, r1, slot1Index) ); - QVERIFY( QMetaObject::disconnect( s, signal3Index, r2, slot3Index) ); - QVERIFY( QMetaObject::disconnect( s, -1, r2, slot2Index) ); - - s->emitSignal1(); - s->emitSignal2(); - s->emitSignal3(); - s->emitSignal4(); - - QCOMPARE( r1->count_slot1, 1 ); - QCOMPARE( r1->count_slot2, 0 ); - QCOMPARE( r1->count_slot3, 0 ); - QCOMPARE( r2->count_slot1, 0 ); - QCOMPARE( r2->count_slot2, 4 ); - QCOMPARE( r2->count_slot3, 1 ); - - //some "dynamic" signal - QVERIFY( QMetaObject::connect( s, s->metaObject()->methodOffset() + 20, r1, slot3Index) ); - QVERIFY( QMetaObject::connect( s, s->metaObject()->methodOffset() + 35, r2, slot1Index) ); - QVERIFY( QMetaObject::connect( s, -1, r1, slot2Index) ); - - r1->reset(); - r2->reset(); - - void *args[] = { 0 , 0 }; - QMetaObject::activate(s, s->metaObject()->methodOffset() + 20, args); - QMetaObject::activate(s, s->metaObject()->methodOffset() + 48, args); - QCOMPARE( r1->count_slot1, 0 ); - QCOMPARE( r1->count_slot2, 2 ); - QCOMPARE( r1->count_slot3, 1 ); - QCOMPARE( r2->count_slot1, 0 ); - QCOMPARE( r2->count_slot2, 0 ); - QCOMPARE( r2->count_slot3, 0 ); - - QMetaObject::activate(s, s->metaObject()->methodOffset() + 35, args); - s->emitSignal1(); - s->emitSignal2(); - - QCOMPARE( r1->count_slot1, 0 ); - QCOMPARE( r1->count_slot2, 5 ); - QCOMPARE( r1->count_slot3, 1 ); - QCOMPARE( r2->count_slot1, 1 ); - QCOMPARE( r2->count_slot2, 0 ); - QCOMPARE( r2->count_slot3, 0 ); + ReceiverObject r1; + ReceiverObject r2; + int slot1Index, slot2Index, slot3Index; + { + SenderObject s; + r1.reset(); + r2.reset(); + ReceiverObject::sequence = 0; + + int signal1Index = s.metaObject()->indexOfSignal("signal1()"); + int signal3Index = s.metaObject()->indexOfSignal("signal3()"); + slot1Index = r1.metaObject()->indexOfSlot("slot1()"); + slot2Index = r1.metaObject()->indexOfSlot("slot2()"); + slot3Index = r1.metaObject()->indexOfSlot("slot3()"); + + QVERIFY(slot1Index > 0); + QVERIFY(slot2Index > 0); + QVERIFY(slot3Index > 0); + + QVERIFY(QMetaObject::connect(&s, signal1Index, &r1, slot1Index)); + QVERIFY(QMetaObject::connect(&s, signal3Index, &r2, slot3Index)); + QVERIFY(QMetaObject::connect(&s, -1, &r2, slot2Index)); + + QCOMPARE(r1.count_slot1, 0); + QCOMPARE(r1.count_slot2, 0); + QCOMPARE(r1.count_slot3, 0); + QCOMPARE(r2.count_slot1, 0); + QCOMPARE(r2.count_slot2, 0); + QCOMPARE(r2.count_slot3, 0); + + s.emitSignal1(); + + QCOMPARE(r1.count_slot1, 1); + QCOMPARE(r1.count_slot2, 0); + QCOMPARE(r1.count_slot3, 0); + QCOMPARE(r2.count_slot1, 0); + QCOMPARE(r2.count_slot2, 1); + QCOMPARE(r2.count_slot3, 0); + + s.emitSignal2(); + s.emitSignal3(); + s.emitSignal4(); + + QCOMPARE(r1.count_slot1, 1); + QCOMPARE(r1.count_slot2, 0); + QCOMPARE(r1.count_slot3, 0); + QCOMPARE(r2.count_slot1, 0); + QCOMPARE(r2.count_slot2, 4); + QCOMPARE(r2.count_slot3, 1); + + QVERIFY(QMetaObject::disconnect(&s, signal1Index, &r1, slot1Index)); + QVERIFY(QMetaObject::disconnect(&s, signal3Index, &r2, slot3Index)); + QVERIFY(QMetaObject::disconnect(&s, -1, &r2, slot2Index)); + + s.emitSignal1(); + s.emitSignal2(); + s.emitSignal3(); + s.emitSignal4(); + + QCOMPARE(r1.count_slot1, 1); + QCOMPARE(r1.count_slot2, 0); + QCOMPARE(r1.count_slot3, 0); + QCOMPARE(r2.count_slot1, 0); + QCOMPARE(r2.count_slot2, 4); + QCOMPARE(r2.count_slot3, 1); + + //some "dynamic" signal + QVERIFY(QMetaObject::connect(&s, s.metaObject()->methodOffset() + 20, &r1, slot3Index)); + QVERIFY(QMetaObject::connect(&s, s.metaObject()->methodOffset() + 35, &r2, slot1Index)); + QVERIFY(QMetaObject::connect(&s, -1, &r1, slot2Index)); + + r1.reset(); + r2.reset(); + + void *args[] = { 0 , 0 }; + QMetaObject::activate(&s, s.metaObject()->methodOffset() + 20, args); + QMetaObject::activate(&s, s.metaObject()->methodOffset() + 48, args); + QCOMPARE(r1.count_slot1, 0); + QCOMPARE(r1.count_slot2, 2); + QCOMPARE(r1.count_slot3, 1); + QCOMPARE(r2.count_slot1, 0); + QCOMPARE(r2.count_slot2, 0); + QCOMPARE(r2.count_slot3, 0); + + QMetaObject::activate(&s, s.metaObject()->methodOffset() + 35, args); + s.emitSignal1(); + s.emitSignal2(); + + QCOMPARE(r1.count_slot1, 0); + QCOMPARE(r1.count_slot2, 5); + QCOMPARE(r1.count_slot3, 1); + QCOMPARE(r2.count_slot1, 1); + QCOMPARE(r2.count_slot2, 0); + QCOMPARE(r2.count_slot3, 0); + } - delete s; - r1->reset(); - r2->reset(); + r1.reset(); + r2.reset(); #define SIGNAL_INDEX(S) obj1.metaObject()->indexOfSignal(QMetaObject::normalizedSignature(#S)) OverloadObject obj1; QObject obj2, obj3; - QMetaObject::connect(&obj1, SIGNAL_INDEX(sig(int)) , r1, slot1Index); - QMetaObject::connect(&obj1, SIGNAL_INDEX(sig(QObject *, QObject *, QObject *)) , r2, slot1Index); + QMetaObject::connect(&obj1, SIGNAL_INDEX(sig(int)) , &r1, slot1Index); + QMetaObject::connect(&obj1, SIGNAL_INDEX(sig(QObject *, QObject *, QObject *)) , + &r2, slot1Index); - QMetaObject::connect(&obj1, SIGNAL_INDEX(sig(QObject *, QObject *, QObject *, QObject *)) , r1, slot2Index); - QMetaObject::connect(&obj1, SIGNAL_INDEX(sig(QObject *)) , r2, slot2Index); - QMetaObject::connect(&obj1, SIGNAL_INDEX(sig(int, int)) , r1, slot3Index); + QMetaObject::connect(&obj1, SIGNAL_INDEX(sig(QObject *, QObject *, QObject *, QObject *)) , + &r1, slot2Index); + QMetaObject::connect(&obj1, SIGNAL_INDEX(sig(QObject *)) , &r2, slot2Index); + QMetaObject::connect(&obj1, SIGNAL_INDEX(sig(int, int)) , &r1, slot3Index); emit obj1.sig(0.5); //connected to nothing emit obj1.sig(1, 'a'); //connected to nothing - QCOMPARE( r1->count_slot1, 0 ); - QCOMPARE( r1->count_slot2, 0 ); - QCOMPARE( r1->count_slot3, 0 ); - QCOMPARE( r2->count_slot1, 0 ); - QCOMPARE( r2->count_slot2, 0 ); - QCOMPARE( r2->count_slot3, 0 ); + QCOMPARE(r1.count_slot1, 0); + QCOMPARE(r1.count_slot2, 0); + QCOMPARE(r1.count_slot3, 0); + QCOMPARE(r2.count_slot1, 0); + QCOMPARE(r2.count_slot2, 0); + QCOMPARE(r2.count_slot3, 0); emit obj1.sig(1); //this signal is connected emit obj1.sig(&obj2); - QCOMPARE( r1->count_slot1, 1 ); - QCOMPARE( r1->count_slot2, 0 ); - QCOMPARE( r1->count_slot3, 1 ); - QCOMPARE( r2->count_slot1, 0 ); - QCOMPARE( r2->count_slot2, 1 ); - QCOMPARE( r2->count_slot3, 0 ); + QCOMPARE(r1.count_slot1, 1); + QCOMPARE(r1.count_slot2, 0); + QCOMPARE(r1.count_slot3, 1); + QCOMPARE(r2.count_slot1, 0); + QCOMPARE(r2.count_slot2, 1); + QCOMPARE(r2.count_slot3, 0); emit obj1.sig(&obj2, &obj3); //this signal is connected - QCOMPARE( r1->count_slot1, 1 ); - QCOMPARE( r1->count_slot2, 1 ); - QCOMPARE( r1->count_slot3, 1 ); - QCOMPARE( r2->count_slot1, 1 ); - QCOMPARE( r2->count_slot2, 1 ); - QCOMPARE( r2->count_slot3, 0 ); - - delete r1; - delete r2; - + QCOMPARE(r1.count_slot1, 1); + QCOMPARE(r1.count_slot2, 1); + QCOMPARE(r1.count_slot3, 1); + QCOMPARE(r2.count_slot1, 1); + QCOMPARE(r2.count_slot2, 1); + QCOMPARE(r2.count_slot3, 0); } void tst_QObject::qMetaObjectDisconnectOne() { - SenderObject *s = new SenderObject; - ReceiverObject *r1 = new ReceiverObject; + SenderObject s; + ReceiverObject r1; - int signal1Index = s->metaObject()->indexOfSignal("signal1()"); - int signal3Index = s->metaObject()->indexOfSignal("signal3()"); - int slot1Index = r1->metaObject()->indexOfSlot("slot1()"); - int slot2Index = r1->metaObject()->indexOfSlot("slot2()"); + int signal1Index = s.metaObject()->indexOfSignal("signal1()"); + int signal3Index = s.metaObject()->indexOfSignal("signal3()"); + int slot1Index = r1.metaObject()->indexOfSlot("slot1()"); + int slot2Index = r1.metaObject()->indexOfSlot("slot2()"); QVERIFY(signal1Index > 0); QVERIFY(signal3Index > 0); QVERIFY(slot1Index > 0); QVERIFY(slot2Index > 0); - QVERIFY( QMetaObject::connect(s, signal1Index, r1, slot1Index) ); - QVERIFY( QMetaObject::connect(s, signal3Index, r1, slot2Index) ); - QVERIFY( QMetaObject::connect(s, signal3Index, r1, slot2Index) ); - QVERIFY( QMetaObject::connect(s, signal3Index, r1, slot2Index) ); - - r1->reset(); - QCOMPARE( r1->count_slot1, 0 ); - QCOMPARE( r1->count_slot2, 0 ); + QVERIFY(QMetaObject::connect(&s, signal1Index, &r1, slot1Index)); + QVERIFY(QMetaObject::connect(&s, signal3Index, &r1, slot2Index)); + QVERIFY(QMetaObject::connect(&s, signal3Index, &r1, slot2Index)); + QVERIFY(QMetaObject::connect(&s, signal3Index, &r1, slot2Index)); - s->emitSignal1(); - QCOMPARE( r1->count_slot1, 1 ); - QCOMPARE( r1->count_slot2, 0 ); + r1.reset(); + QCOMPARE(r1.count_slot1, 0); + QCOMPARE(r1.count_slot2, 0); - s->emitSignal3(); - QCOMPARE( r1->count_slot1, 1 ); - QCOMPARE( r1->count_slot2, 3 ); + s.emitSignal1(); + QCOMPARE(r1.count_slot1, 1); + QCOMPARE(r1.count_slot2, 0); - r1->reset(); - QVERIFY( QMetaObject::disconnectOne(s, signal1Index, r1, slot1Index) ); - QVERIFY( QMetaObject::disconnectOne(s, signal3Index, r1, slot2Index) ); + s.emitSignal3(); + QCOMPARE(r1.count_slot1, 1); + QCOMPARE(r1.count_slot2, 3); - s->emitSignal1(); - QCOMPARE( r1->count_slot1, 0 ); - QCOMPARE( r1->count_slot2, 0 ); + r1.reset(); + QVERIFY(QMetaObject::disconnectOne(&s, signal1Index, &r1, slot1Index)); + QVERIFY(QMetaObject::disconnectOne(&s, signal3Index, &r1, slot2Index)); - s->emitSignal3(); - QCOMPARE( r1->count_slot1, 0 ); - QCOMPARE( r1->count_slot2, 2 ); + s.emitSignal1(); + QCOMPARE(r1.count_slot1, 0); + QCOMPARE(r1.count_slot2, 0); - r1->reset(); - QVERIFY( false == QMetaObject::disconnectOne(s, signal1Index, r1, slot1Index) ); - QVERIFY( QMetaObject::disconnectOne(s, signal3Index, r1, slot2Index) ); + s.emitSignal3(); + QCOMPARE(r1.count_slot1, 0); + QCOMPARE(r1.count_slot2, 2); - s->emitSignal1(); - QCOMPARE( r1->count_slot1, 0 ); - QCOMPARE( r1->count_slot2, 0 ); + r1.reset(); + QVERIFY(!QMetaObject::disconnectOne(&s, signal1Index, &r1, slot1Index)); + QVERIFY( QMetaObject::disconnectOne(&s, signal3Index, &r1, slot2Index)); - s->emitSignal3(); - QCOMPARE( r1->count_slot1, 0 ); - QCOMPARE( r1->count_slot2, 1 ); + s.emitSignal1(); + QCOMPARE(r1.count_slot1, 0); + QCOMPARE(r1.count_slot2, 0); - r1->reset(); - QVERIFY( false == QMetaObject::disconnectOne(s, signal1Index, r1, slot1Index) ); - QVERIFY( QMetaObject::disconnectOne(s, signal3Index, r1, slot2Index) ); + s.emitSignal3(); + QCOMPARE(r1.count_slot1, 0); + QCOMPARE(r1.count_slot2, 1); - s->emitSignal1(); - QCOMPARE( r1->count_slot1, 0 ); - QCOMPARE( r1->count_slot2, 0 ); + r1.reset(); + QVERIFY(!QMetaObject::disconnectOne(&s, signal1Index, &r1, slot1Index)); + QVERIFY( QMetaObject::disconnectOne(&s, signal3Index, &r1, slot2Index)); - s->emitSignal3(); - QCOMPARE( r1->count_slot1, 0 ); - QCOMPARE( r1->count_slot2, 0 ); + s.emitSignal1(); + QCOMPARE(r1.count_slot1, 0); + QCOMPARE(r1.count_slot2, 0); - delete s; - delete r1; + s.emitSignal3(); + QCOMPARE(r1.count_slot1, 0); + QCOMPARE(r1.count_slot2, 0); } class ConfusingObject : public SenderObject @@ -4222,106 +4221,95 @@ void tst_QObject::connectConstructorByMetaMethod() void tst_QObject::disconnectByMetaMethod() { - SenderObject *s = new SenderObject; - ReceiverObject *r1 = new ReceiverObject; - ReceiverObject *r2 = new ReceiverObject; - - QMetaMethod signal1 = s->metaObject()->method( - s->metaObject()->indexOfMethod("signal1()")); - QMetaMethod signal2 = s->metaObject()->method( - s->metaObject()->indexOfMethod("signal2()")); - QMetaMethod signal3 = s->metaObject()->method( - s->metaObject()->indexOfMethod("signal3()")); - - QMetaMethod slot1 = r1->metaObject()->method( - r1->metaObject()->indexOfMethod("slot1()")); - QMetaMethod slot2 = r1->metaObject()->method( - r1->metaObject()->indexOfMethod("slot2()")); - QMetaMethod slot3 = r1->metaObject()->method( - r1->metaObject()->indexOfMethod("slot3()")); - QMetaMethod slot4 = r1->metaObject()->method( - r1->metaObject()->indexOfMethod("slot4()")); - - connect(s, signal1, r1, slot1); + SenderObject s; + ReceiverObject r1; + ReceiverObject r2; - s->emitSignal1(); + QMetaMethod signal1 = s.metaObject()->method(s.metaObject()->indexOfMethod("signal1()")); + QMetaMethod signal2 = s.metaObject()->method(s.metaObject()->indexOfMethod("signal2()")); + QMetaMethod signal3 = s.metaObject()->method(s.metaObject()->indexOfMethod("signal3()")); + + QMetaMethod slot1 = r1.metaObject()->method(r1.metaObject()->indexOfMethod("slot1()")); + QMetaMethod slot2 = r1.metaObject()->method(r1.metaObject()->indexOfMethod("slot2()")); + QMetaMethod slot3 = r1.metaObject()->method(r1.metaObject()->indexOfMethod("slot3()")); + QMetaMethod slot4 = r1.metaObject()->method(r1.metaObject()->indexOfMethod("slot4()")); + + connect(&s, signal1, &r1, slot1); - QVERIFY(r1->called(1)); - r1->reset(); + s.emitSignal1(); + + QVERIFY(r1.called(1)); + r1.reset(); // usual disconnect with all parameters given - bool ret = QObject::disconnect(s, signal1, r1, slot1); + bool ret = QObject::disconnect(&s, signal1, &r1, slot1); - s->emitSignal1(); + s.emitSignal1(); - QVERIFY(!r1->called(1)); - r1->reset(); + QVERIFY(!r1.called(1)); + r1.reset(); QVERIFY(ret); - ret = QObject::disconnect(s, signal1, r1, slot1); + ret = QObject::disconnect(&s, signal1, &r1, slot1); QVERIFY(!ret); - r1->reset(); + r1.reset(); - connect( s, signal1, r1, slot1 ); - connect( s, signal1, r1, slot2 ); - connect( s, signal1, r1, slot3 ); - connect( s, signal2, r1, slot4 ); + connect(&s, signal1, &r1, slot1); + connect(&s, signal1, &r1, slot2); + connect(&s, signal1, &r1, slot3); + connect(&s, signal2, &r1, slot4); // disconnect s's signal1() from all slots of r1 - QObject::disconnect(s, signal1, r1, QMetaMethod()); + QObject::disconnect(&s, signal1, &r1, QMetaMethod()); - s->emitSignal1(); - s->emitSignal2(); + s.emitSignal1(); + s.emitSignal2(); - QVERIFY(!r1->called(1)); - QVERIFY(!r1->called(2)); - QVERIFY(!r1->called(3)); - QVERIFY(r1->called(4)); - r1->reset(); + QVERIFY(!r1.called(1)); + QVERIFY(!r1.called(2)); + QVERIFY(!r1.called(3)); + QVERIFY(r1.called(4)); + r1.reset(); // make sure all is disconnected again - QObject::disconnect(s, 0, r1, 0); + QObject::disconnect(&s, 0, &r1, 0); - connect(s, signal1, r1, slot1); - connect(s, signal1, r2, slot1); - connect(s, signal2, r1, slot2); - connect(s, signal2, r2, slot2); - connect(s, signal3, r1, slot3); - connect(s, signal3, r2, slot3); + connect(&s, signal1, &r1, slot1); + connect(&s, signal1, &r2, slot1); + connect(&s, signal2, &r1, slot2); + connect(&s, signal2, &r2, slot2); + connect(&s, signal3, &r1, slot3); + connect(&s, signal3, &r2, slot3); // disconnect signal1() from all receivers - QObject::disconnect(s, signal1, 0, QMetaMethod()); - s->emitSignal1(); - s->emitSignal2(); - s->emitSignal3(); + QObject::disconnect(&s, signal1, 0, QMetaMethod()); + s.emitSignal1(); + s.emitSignal2(); + s.emitSignal3(); - QVERIFY(!r1->called(1)); - QVERIFY(!r2->called(1)); - QVERIFY(r1->called(2)); - QVERIFY(r2->called(2)); - QVERIFY(r1->called(2)); - QVERIFY(r2->called(2)); + QVERIFY(!r1.called(1)); + QVERIFY(!r2.called(1)); + QVERIFY(r1.called(2)); + QVERIFY(r2.called(2)); + QVERIFY(r1.called(2)); + QVERIFY(r2.called(2)); - r1->reset(); - r2->reset(); + r1.reset(); + r2.reset(); // disconnect all signals of s from all receivers - QObject::disconnect( s, 0, 0, 0 ); + QObject::disconnect(&s, 0, 0, 0); - connect( s, signal1, r1, slot1 ); - connect( s, signal1, r2, slot1 ); + connect(&s, signal1, &r1, slot1); + connect(&s, signal1, &r2, slot1); // disconnect all signals from slot1 of r1 - QObject::disconnect(s, QMetaMethod(), r1, slot1); + QObject::disconnect(&s, QMetaMethod(), &r1, slot1); - s->emitSignal1(); - - QVERIFY(!r1->called(1)); - QVERIFY(r2->called(1)); + s.emitSignal1(); - delete r2; - delete r1; - delete s; + QVERIFY(!r1.called(1)); + QVERIFY(r2.called(1)); } void tst_QObject::disconnectNotSignalMetaMethod() @@ -4459,63 +4447,64 @@ void tst_QObject::baseDestroyed() void tst_QObject::pointerConnect() { - SenderObject *s = new SenderObject; - ReceiverObject *r1 = new ReceiverObject; - ReceiverObject *r2 = new ReceiverObject; - r1->reset(); - r2->reset(); + SenderObject s; + ReceiverObject r1; + ReceiverObject r2; + r1.reset(); + r2.reset(); ReceiverObject::sequence = 0; QTimer timer; - QVERIFY( connect( s, &SenderObject::signal1 , r1, &ReceiverObject::slot1 ) ); - QVERIFY( connect( s, &SenderObject::signal1 , r2, &ReceiverObject::slot1 ) ); - QVERIFY( connect( s, &SenderObject::signal1 , r1, &ReceiverObject::slot3 ) ); - QVERIFY( connect( s, &SenderObject::signal3 , r1, &ReceiverObject::slot3 ) ); - QVERIFY2( connect( &timer, &QTimer::timeout, r1, &ReceiverObject::deleteLater ), - "Signal connection failed most likely due to failing comparison of pointers to member functions caused by problems with -reduce-relocations on this platform."); + QVERIFY(connect(&s, &SenderObject::signal1 , &r1, &ReceiverObject::slot1)); + QVERIFY(connect(&s, &SenderObject::signal1 , &r2, &ReceiverObject::slot1)); + QVERIFY(connect(&s, &SenderObject::signal1 , &r1, &ReceiverObject::slot3)); + QVERIFY(connect(&s, &SenderObject::signal3 , &r1, &ReceiverObject::slot3)); + QVERIFY2(connect(&timer, &QTimer::timeout, &r1, &ReceiverObject::deleteLater), + "Signal connection failed most likely due to failing comparison of pointers to member " + "functions caused by problems with -reduce-relocations on this platform."); - s->emitSignal1(); - s->emitSignal2(); - s->emitSignal3(); - s->emitSignal4(); - - QCOMPARE( r1->count_slot1, 1 ); - QCOMPARE( r1->count_slot2, 0 ); - QCOMPARE( r1->count_slot3, 2 ); - QCOMPARE( r1->count_slot4, 0 ); - QCOMPARE( r2->count_slot1, 1 ); - QCOMPARE( r2->count_slot2, 0 ); - QCOMPARE( r2->count_slot3, 0 ); - QCOMPARE( r2->count_slot4, 0 ); - QCOMPARE( r1->sequence_slot1, 1 ); - QCOMPARE( r2->sequence_slot1, 2 ); - QCOMPARE( r1->sequence_slot3, 4 ); - - r1->reset(); - r2->reset(); + s.emitSignal1(); + s.emitSignal2(); + s.emitSignal3(); + s.emitSignal4(); + + QCOMPARE(r1.count_slot1, 1); + QCOMPARE(r1.count_slot2, 0); + QCOMPARE(r1.count_slot3, 2); + QCOMPARE(r1.count_slot4, 0); + QCOMPARE(r2.count_slot1, 1); + QCOMPARE(r2.count_slot2, 0); + QCOMPARE(r2.count_slot3, 0); + QCOMPARE(r2.count_slot4, 0); + QCOMPARE(r1.sequence_slot1, 1); + QCOMPARE(r2.sequence_slot1, 2); + QCOMPARE(r1.sequence_slot3, 4); + + r1.reset(); + r2.reset(); ReceiverObject::sequence = 0; - QVERIFY( connect( s, &SenderObject::signal4, r1, &ReceiverObject::slot4 ) ); - QVERIFY( connect( s, &SenderObject::signal4, r2, &ReceiverObject::slot4 ) ); - QVERIFY( connect( s, &SenderObject::signal1, r2, &ReceiverObject::slot4 ) ); + QVERIFY(connect(&s, &SenderObject::signal4, &r1, &ReceiverObject::slot4)); + QVERIFY(connect(&s, &SenderObject::signal4, &r2, &ReceiverObject::slot4)); + QVERIFY(connect(&s, &SenderObject::signal1, &r2, &ReceiverObject::slot4)); - s->emitSignal4(); - QCOMPARE( r1->count_slot4, 1 ); - QCOMPARE( r2->count_slot4, 1 ); - QCOMPARE( r1->sequence_slot4, 1 ); - QCOMPARE( r2->sequence_slot4, 2 ); + s.emitSignal4(); + QCOMPARE(r1.count_slot4, 1); + QCOMPARE(r2.count_slot4, 1); + QCOMPARE(r1.sequence_slot4, 1); + QCOMPARE(r2.sequence_slot4, 2); - r1->reset(); - r2->reset(); + r1.reset(); + r2.reset(); ReceiverObject::sequence = 0; - connect( s, &SenderObject::signal4 , r1, &ReceiverObject::slot4 ); + connect(&s, &SenderObject::signal4 , &r1, &ReceiverObject::slot4); - s->emitSignal4(); - QCOMPARE( r1->count_slot4, 2 ); - QCOMPARE( r2->count_slot4, 1 ); - QCOMPARE( r1->sequence_slot4, 3 ); - QCOMPARE( r2->sequence_slot4, 2 ); + s.emitSignal4(); + QCOMPARE(r1.count_slot4, 2); + QCOMPARE(r2.count_slot4, 1); + QCOMPARE(r1.sequence_slot4, 3); + QCOMPARE(r2.sequence_slot4, 2); QMetaObject::Connection con; QVERIFY(!con); @@ -4523,116 +4512,107 @@ void tst_QObject::pointerConnect() //connect a slot to a signal (== error) QTest::ignoreMessage(QtWarningMsg, "QObject::connect: signal not found in ReceiverObject"); - con = connect(r1, &ReceiverObject::slot4 , s, &SenderObject::signal4 ); + con = connect(&r1, &ReceiverObject::slot4 , &s, &SenderObject::signal4); QVERIFY(!con); QVERIFY(!QObject::disconnect(con)); - - delete s; - delete r1; - delete r2; } void tst_QObject::pointerDisconnect() { - SenderObject *s = new SenderObject; - ReceiverObject *r1 = new ReceiverObject; - ReceiverObject *r2 = new ReceiverObject; + SenderObject s; + ReceiverObject r1; + ReceiverObject r2; - connect( s, &SenderObject::signal1, r1, &ReceiverObject::slot1 ); + connect(&s, &SenderObject::signal1, &r1, &ReceiverObject::slot1); - connect( s, &SenderObject::signal2, r1, &ReceiverObject::slot2 ); - connect( s, &SenderObject::signal3, r1, &ReceiverObject::slot3 ); - connect( s, &SenderObject::signal4, r1, &ReceiverObject::slot4 ); + connect(&s, &SenderObject::signal2, &r1, &ReceiverObject::slot2); + connect(&s, &SenderObject::signal3, &r1, &ReceiverObject::slot3); + connect(&s, &SenderObject::signal4, &r1, &ReceiverObject::slot4); - s->emitSignal1(); - s->emitSignal2(); - s->emitSignal3(); - s->emitSignal4(); + s.emitSignal1(); + s.emitSignal2(); + s.emitSignal3(); + s.emitSignal4(); - QVERIFY(r1->called(1)); - QVERIFY(r1->called(2)); - QVERIFY(r1->called(3)); - QVERIFY(r1->called(4)); - r1->reset(); + QVERIFY(r1.called(1)); + QVERIFY(r1.called(2)); + QVERIFY(r1.called(3)); + QVERIFY(r1.called(4)); + r1.reset(); // usual disconnect with all parameters given - bool ret = QObject::disconnect( s, &SenderObject::signal1, r1, &ReceiverObject::slot1 ); + bool ret = QObject::disconnect(&s, &SenderObject::signal1, &r1, &ReceiverObject::slot1); - s->emitSignal1(); + s.emitSignal1(); - QVERIFY(!r1->called(1)); - r1->reset(); + QVERIFY(!r1.called(1)); + r1.reset(); QVERIFY(ret); - ret = QObject::disconnect( s, &SenderObject::signal1, r1, &ReceiverObject::slot1 ); + ret = QObject::disconnect(&s, &SenderObject::signal1, &r1, &ReceiverObject::slot1); QVERIFY(!ret); // disconnect all signals from s from all slots from r1 - QObject::disconnect( s, 0, r1, 0 ); + QObject::disconnect(&s, 0, &r1, 0); - s->emitSignal2(); - s->emitSignal3(); - s->emitSignal4(); + s.emitSignal2(); + s.emitSignal3(); + s.emitSignal4(); - QVERIFY(!r1->called(2)); - QVERIFY(!r1->called(3)); - QVERIFY(!r1->called(4)); - r1->reset(); + QVERIFY(!r1.called(2)); + QVERIFY(!r1.called(3)); + QVERIFY(!r1.called(4)); + r1.reset(); - connect( s, &SenderObject::signal1, r1, &ReceiverObject::slot1 ); - connect( s, &SenderObject::signal1, r1, &ReceiverObject::slot2 ); - connect( s, &SenderObject::signal1, r1, &ReceiverObject::slot3 ); - connect( s, &SenderObject::signal2, r1, &ReceiverObject::slot4 ); + connect(&s, &SenderObject::signal1, &r1, &ReceiverObject::slot1); + connect(&s, &SenderObject::signal1, &r1, &ReceiverObject::slot2); + connect(&s, &SenderObject::signal1, &r1, &ReceiverObject::slot3); + connect(&s, &SenderObject::signal2, &r1, &ReceiverObject::slot4); // disconnect s's signal1() from all slots of r1 - QObject::disconnect( s, &SenderObject::signal1, r1, 0 ); + QObject::disconnect(&s, &SenderObject::signal1, &r1, 0); - s->emitSignal1(); - s->emitSignal2(); + s.emitSignal1(); + s.emitSignal2(); - QVERIFY(!r1->called(1)); - QVERIFY(!r1->called(2)); - QVERIFY(!r1->called(3)); - QVERIFY(r1->called(4)); - r1->reset(); + QVERIFY(!r1.called(1)); + QVERIFY(!r1.called(2)); + QVERIFY(!r1.called(3)); + QVERIFY(r1.called(4)); + r1.reset(); // make sure all is disconnected again - QObject::disconnect( s, 0, r1, 0 ); + QObject::disconnect(&s, 0, &r1, 0); - connect( s, &SenderObject::signal1, r1, &ReceiverObject::slot1 ); - connect( s, &SenderObject::signal1, r2, &ReceiverObject::slot1 ); - connect( s, &SenderObject::signal2, r1, &ReceiverObject::slot2 ); - connect( s, &SenderObject::signal2, r2, &ReceiverObject::slot2 ); - connect( s, &SenderObject::signal3, r1, &ReceiverObject::slot3 ); - connect( s, &SenderObject::signal3, r2, &ReceiverObject::slot3 ); + connect(&s, &SenderObject::signal1, &r1, &ReceiverObject::slot1); + connect(&s, &SenderObject::signal1, &r2, &ReceiverObject::slot1); + connect(&s, &SenderObject::signal2, &r1, &ReceiverObject::slot2); + connect(&s, &SenderObject::signal2, &r2, &ReceiverObject::slot2); + connect(&s, &SenderObject::signal3, &r1, &ReceiverObject::slot3); + connect(&s, &SenderObject::signal3, &r2, &ReceiverObject::slot3); // disconnect signal1() from all receivers - QObject::disconnect( s, &SenderObject::signal1, 0, 0 ); - s->emitSignal1(); - s->emitSignal2(); - s->emitSignal3(); + QObject::disconnect(&s, &SenderObject::signal1, 0, 0); + s.emitSignal1(); + s.emitSignal2(); + s.emitSignal3(); - QVERIFY(!r1->called(1)); - QVERIFY(!r2->called(1)); - QVERIFY(r1->called(2)); - QVERIFY(r2->called(2)); - QVERIFY(r1->called(2)); - QVERIFY(r2->called(2)); + QVERIFY(!r1.called(1)); + QVERIFY(!r2.called(1)); + QVERIFY(r1.called(2)); + QVERIFY(r2.called(2)); + QVERIFY(r1.called(2)); + QVERIFY(r2.called(2)); - r1->reset(); - r2->reset(); + r1.reset(); + r2.reset(); // disconnect all signals of s from all receivers - QObject::disconnect( s, 0, 0, 0 ); - - QVERIFY(!r1->called(2)); - QVERIFY(!r2->called(2)); - QVERIFY(!r1->called(2)); - QVERIFY(!r2->called(2)); - - delete r2; - delete r1; - delete s; + QObject::disconnect(&s, 0, 0, 0); + QVERIFY(!r1.called(2)); + QVERIFY(!r2.called(2)); + QVERIFY(!r1.called(2)); + QVERIFY(!r2.called(2)); } @@ -4756,35 +4736,32 @@ void tst_QObject::customTypesPointer() void tst_QObject::connectCxx0x() { - SenderObject *s = new SenderObject; - ReceiverObject *r1 = new ReceiverObject; + SenderObject s; + ReceiverObject r1; - QObject::connect(s, &SenderObject::signal1, r1, &ReceiverObject::slot1); - QObject::connect(s, &SenderObject::signal3, r1, &ReceiverObject::slot2); - QObject::connect(s, &SenderObject::signal3, r1, &ReceiverObject::slot2); - QObject::connect(s, &SenderObject::signal3, r1, &ReceiverObject::slot2); + QObject::connect(&s, &SenderObject::signal1, &r1, &ReceiverObject::slot1); + QObject::connect(&s, &SenderObject::signal3, &r1, &ReceiverObject::slot2); + QObject::connect(&s, &SenderObject::signal3, &r1, &ReceiverObject::slot2); + QObject::connect(&s, &SenderObject::signal3, &r1, &ReceiverObject::slot2); - r1->reset(); - QCOMPARE( r1->count_slot1, 0 ); - QCOMPARE( r1->count_slot2, 0 ); + r1.reset(); + QCOMPARE(r1.count_slot1, 0); + QCOMPARE(r1.count_slot2, 0); - s->emitSignal1(); - QCOMPARE( r1->count_slot1, 1 ); - QCOMPARE( r1->count_slot2, 0 ); + s.emitSignal1(); + QCOMPARE(r1.count_slot1, 1); + QCOMPARE(r1.count_slot2, 0); - s->emitSignal3(); - QCOMPARE( r1->count_slot1, 1 ); - QCOMPARE( r1->count_slot2, 3 ); + s.emitSignal3(); + QCOMPARE(r1.count_slot1, 1); + QCOMPARE(r1.count_slot2, 3); // connect signal to signal - QObject::connect(s, &SenderObject::signal2, s, &SenderObject::signal1); + QObject::connect(&s, &SenderObject::signal2, &s, &SenderObject::signal1); - r1->reset(); - s->emitSignal2(); - QCOMPARE( r1->count_slot1, 1 ); - - delete s; - delete r1; + r1.reset(); + s.emitSignal2(); + QCOMPARE(r1.count_slot1, 1); } int receivedCount; diff --git a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp index 9df52887f7..fd3cc18af5 100644 --- a/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp +++ b/tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp @@ -73,12 +73,12 @@ static inline QString testSuiteWarning() str << "\nCannot find the shared-mime-info test suite\nstarting from: " << QDir::toNativeSeparators(QDir::currentPath()) << "\n" "cd " << QDir::toNativeSeparators(QStringLiteral("tests/auto/corelib/mimetypes/qmimedatabase")) << "\n" - "wget http://cgit.freedesktop.org/xdg/shared-mime-info/snapshot/Release-1-8.zip\n" - "unzip Release-1-8.zip\n"; + "wget http://cgit.freedesktop.org/xdg/shared-mime-info/snapshot/Release-1-10.zip\n" + "unzip Release-1-10.zip\n"; #ifdef Q_OS_WIN - str << "mkdir testfiles\nxcopy /s Release-1-8 s-m-i\n"; + str << "mkdir testfiles\nxcopy /s Release-1-10 s-m-i\n"; #else - str << "ln -s Release-1-8 s-m-i\n"; + str << "ln -s Release-1-10 s-m-i\n"; #endif return result; } @@ -611,7 +611,7 @@ void tst_QMimeDatabase::allMimeTypes() QVERIFY(!lst.isEmpty()); // Hardcoding this is the only way to check both providers find the same number of mimetypes. - QCOMPARE(lst.count(), 749); + QCOMPARE(lst.count(), 779); foreach (const QMimeType &mime, lst) { const QString name = mime.name(); @@ -640,7 +640,7 @@ void tst_QMimeDatabase::suffixes_data() QTest::newRow("mimetype with multiple patterns") << "text/plain" << "*.asc;*.txt;*,v" << "txt"; QTest::newRow("mimetype with uncommon pattern") << "text/x-readme" << "README*" << QString(); QTest::newRow("mimetype with no patterns") << "application/x-ole-storage" << QString() << QString(); - QTest::newRow("default_mimetype") << "application/octet-stream" << "*.bin" << QString(); + QTest::newRow("default_mimetype") << "application/octet-stream" << QString() << QString(); } void tst_QMimeDatabase::suffixes() diff --git a/tests/auto/corelib/plugin/qpluginloader/qpluginloader.pro b/tests/auto/corelib/plugin/qpluginloader/qpluginloader.pro index 541e73636c..5efe68f4af 100644 --- a/tests/auto/corelib/plugin/qpluginloader/qpluginloader.pro +++ b/tests/auto/corelib/plugin/qpluginloader/qpluginloader.pro @@ -3,6 +3,7 @@ TEMPLATE = subdirs tst.depends = lib theplugin SUBDIRS = lib \ + staticplugin \ theplugin \ tst !android:!win32:!darwin { diff --git a/tests/auto/corelib/plugin/qpluginloader/staticplugin/.gitignore b/tests/auto/corelib/plugin/qpluginloader/staticplugin/.gitignore new file mode 100644 index 0000000000..26f7ecd506 --- /dev/null +++ b/tests/auto/corelib/plugin/qpluginloader/staticplugin/.gitignore @@ -0,0 +1,3 @@ +*staticplugin.prl +libstaticplugin.a +staticplugin.lib diff --git a/tests/auto/corelib/plugin/qpluginloader/staticplugin/main.cpp b/tests/auto/corelib/plugin/qpluginloader/staticplugin/main.cpp new file mode 100644 index 0000000000..d891839b1e --- /dev/null +++ b/tests/auto/corelib/plugin/qpluginloader/staticplugin/main.cpp @@ -0,0 +1,39 @@ +/**************************************************************************** +** +** Copyright (C) 2018 Intel Corporation. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include <QtPlugin> +#include <QObject> + +class StaticPlugin : public QObject +{ + Q_OBJECT + Q_PLUGIN_METADATA(IID "SomeIID") +public: + StaticPlugin() {} +}; + +#include "main.moc" diff --git a/tests/auto/corelib/plugin/qpluginloader/staticplugin/staticplugin.pro b/tests/auto/corelib/plugin/qpluginloader/staticplugin/staticplugin.pro new file mode 100644 index 0000000000..ff65ab728c --- /dev/null +++ b/tests/auto/corelib/plugin/qpluginloader/staticplugin/staticplugin.pro @@ -0,0 +1,7 @@ +TEMPLATE = lib +CONFIG += plugin static +SOURCES = main.cpp +QT = core + +# Add extra metadata to the plugin +QMAKE_MOC_OPTIONS += -M ExtraMetaData=StaticPlugin -M ExtraMetaData=foo diff --git a/tests/auto/corelib/plugin/qpluginloader/tst/tst.pro b/tests/auto/corelib/plugin/qpluginloader/tst/tst.pro index c20e56ba4c..a3885f4134 100644 --- a/tests/auto/corelib/plugin/qpluginloader/tst/tst.pro +++ b/tests/auto/corelib/plugin/qpluginloader/tst/tst.pro @@ -8,9 +8,14 @@ HEADERS = ../theplugin/plugininterface.h win32 { CONFIG(debug, debug|release) { TARGET = ../../debug/tst_qpluginloader + LIBS += -L../staticplugin/debug } else { TARGET = ../../release/tst_qpluginloader + LIBS += -L../staticplugin/release } +} else { + LIBS += -L../staticplugin } +LIBS += -lstaticplugin TESTDATA += ../elftest ../machtest diff --git a/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp b/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp index c517c0809a..4316ea14ea 100644 --- a/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp +++ b/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2016 The Qt Company Ltd. -** Copyright (C) 2016 Intel Corporation. +** Copyright (C) 2018 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. @@ -121,8 +121,11 @@ private slots: void reloadPlugin(); void preloadedPlugin_data(); void preloadedPlugin(); + void staticPlugins(); }; +Q_IMPORT_PLUGIN(StaticPlugin) + void tst_QPluginLoader::cleanup() { // check if the library/plugin was leaked @@ -520,5 +523,37 @@ void tst_QPluginLoader::preloadedPlugin() QVERIFY(lib.unload()); } +void tst_QPluginLoader::staticPlugins() +{ + const QObjectList instances = QPluginLoader::staticInstances(); + QVERIFY(instances.size()); + + bool found = false; + for (QObject *obj : instances) { + found = obj->metaObject()->className() == QLatin1String("StaticPlugin"); + if (found) + break; + } + QVERIFY(found); + + const auto plugins = QPluginLoader::staticPlugins(); + QCOMPARE(plugins.size(), instances.size()); + + // find the metadata + QJsonObject metaData; + for (const auto &p : plugins) { + metaData = p.metaData(); + found = metaData.value("className").toString() == QLatin1String("StaticPlugin"); + if (found) + break; + } + QVERIFY(found); + + QCOMPARE(metaData.value("version").toInt(), QT_VERSION); + QCOMPARE(metaData.value("IID").toString(), "SomeIID"); + QCOMPARE(metaData.value("ExtraMetaData"), QJsonArray({ "StaticPlugin", "foo" })); +} + + QTEST_MAIN(tst_QPluginLoader) #include "tst_qpluginloader.moc" diff --git a/tests/auto/corelib/serialization/json/tst_qtjson.cpp b/tests/auto/corelib/serialization/json/tst_qtjson.cpp index 4651258ef3..083e78375a 100644 --- a/tests/auto/corelib/serialization/json/tst_qtjson.cpp +++ b/tests/auto/corelib/serialization/json/tst_qtjson.cpp @@ -153,6 +153,17 @@ private Q_SLOTS: void implicitValueType(); void implicitDocumentType(); + void streamSerializationQJsonDocument_data(); + void streamSerializationQJsonDocument(); + void streamSerializationQJsonArray_data(); + void streamSerializationQJsonArray(); + void streamSerializationQJsonObject_data(); + void streamSerializationQJsonObject(); + void streamSerializationQJsonValue_data(); + void streamSerializationQJsonValue(); + void streamSerializationQJsonValueEmpty(); + void streamVariantSerialization(); + private: QString testDataDir; }; @@ -3011,5 +3022,164 @@ void tst_QtJson::implicitDocumentType() QCOMPARE(arrayDocument[-1].toInt(123), 123); } +void tst_QtJson::streamSerializationQJsonDocument_data() +{ + QTest::addColumn<QJsonDocument>("document"); + QTest::newRow("empty") << QJsonDocument(); + QTest::newRow("object") << QJsonDocument(QJsonObject{{"value", 42}}); +} + +void tst_QtJson::streamSerializationQJsonDocument() +{ + // Check interface only, implementation is tested through to and from + // json functions. + QByteArray buffer; + QFETCH(QJsonDocument, document); + QJsonDocument output; + QDataStream save(&buffer, QIODevice::WriteOnly); + save << document; + QDataStream load(buffer); + load >> output; + QCOMPARE(output, document); +} + +void tst_QtJson::streamSerializationQJsonArray_data() +{ + QTest::addColumn<QJsonArray>("array"); + QTest::newRow("empty") << QJsonArray(); + QTest::newRow("values") << QJsonArray{665, 666, 667}; +} + +void tst_QtJson::streamSerializationQJsonArray() +{ + // Check interface only, implementation is tested through to and from + // json functions. + QByteArray buffer; + QFETCH(QJsonArray, array); + QJsonArray output; + QDataStream save(&buffer, QIODevice::WriteOnly); + save << array; + QDataStream load(buffer); + load >> output; + QCOMPARE(output, array); +} + +void tst_QtJson::streamSerializationQJsonObject_data() +{ + QTest::addColumn<QJsonObject>("object"); + QTest::newRow("empty") << QJsonObject(); + QTest::newRow("non-empty") << QJsonObject{{"foo", 665}, {"bar", 666}}; +} + +void tst_QtJson::streamSerializationQJsonObject() +{ + // Check interface only, implementation is tested through to and from + // json functions. + QByteArray buffer; + QFETCH(QJsonObject, object); + QJsonObject output; + QDataStream save(&buffer, QIODevice::WriteOnly); + save << object; + QDataStream load(buffer); + load >> output; + QCOMPARE(output, object); +} + +void tst_QtJson::streamSerializationQJsonValue_data() +{ + QTest::addColumn<QJsonValue>("value"); + QTest::newRow("double") << QJsonValue{665}; + QTest::newRow("bool") << QJsonValue{true}; + QTest::newRow("string") << QJsonValue{QStringLiteral("bum")}; + QTest::newRow("array") << QJsonValue{QJsonArray{12,1,5,6,7}}; + QTest::newRow("object") << QJsonValue{QJsonObject{{"foo", 665}, {"bar", 666}}}; +} + +void tst_QtJson::streamSerializationQJsonValue() +{ + QByteArray buffer; + QFETCH(QJsonValue, value); + QJsonValue output; + QDataStream save(&buffer, QIODevice::WriteOnly); + save << value; + QDataStream load(buffer); + load >> output; + QCOMPARE(output, value); +} + +void tst_QtJson::streamSerializationQJsonValueEmpty() +{ + QByteArray buffer; + { + QJsonValue undef{QJsonValue::Undefined}; + QDataStream save(&buffer, QIODevice::WriteOnly); + save << undef; + QDataStream load(buffer); + QJsonValue output; + load >> output; + QVERIFY(output.isUndefined()); + } + { + QJsonValue null{QJsonValue::Null}; + QDataStream save(&buffer, QIODevice::WriteOnly); + save << null; + QDataStream load(buffer); + QJsonValue output; + load >> output; + QVERIFY(output.isNull()); + } +} + +void tst_QtJson::streamVariantSerialization() +{ + // Check interface only, implementation is tested through to and from + // json functions. + QByteArray buffer; + { + QJsonDocument objectDoc(QJsonArray{665, 666, 667}); + QVariant output; + QVariant variant(objectDoc); + QDataStream save(&buffer, QIODevice::WriteOnly); + save << variant; + QDataStream load(buffer); + load >> output; + QCOMPARE(output.userType(), QMetaType::QJsonDocument); + QCOMPARE(output.toJsonDocument(), objectDoc); + } + { + QJsonArray array{665, 666, 667}; + QVariant output; + QVariant variant(array); + QDataStream save(&buffer, QIODevice::WriteOnly); + save << variant; + QDataStream load(buffer); + load >> output; + QCOMPARE(output.userType(), QMetaType::QJsonArray); + QCOMPARE(output.toJsonArray(), array); + } + { + QJsonObject obj{{"foo", 42}}; + QVariant output; + QVariant variant(obj); + QDataStream save(&buffer, QIODevice::WriteOnly); + save << variant; + QDataStream load(buffer); + load >> output; + QCOMPARE(output.userType(), QMetaType::QJsonObject); + QCOMPARE(output.toJsonObject(), obj); + } + { + QJsonValue value{42}; + QVariant output; + QVariant variant(value); + QDataStream save(&buffer, QIODevice::WriteOnly); + save << variant; + QDataStream load(buffer); + load >> output; + QCOMPARE(output.userType(), QMetaType::QJsonValue); + QCOMPARE(output.toJsonValue(), value); + } +} + QTEST_MAIN(tst_QtJson) #include "tst_qtjson.moc" diff --git a/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp b/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp index 4b753eab6b..f69ce4120d 100644 --- a/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp +++ b/tests/auto/corelib/serialization/qcborvalue/tst_qcborvalue.cpp @@ -97,6 +97,10 @@ private slots: void validation(); void toDiagnosticNotation_data(); void toDiagnosticNotation(); + + void datastreamSerialization_data(); + void datastreamSerialization(); + void streamVariantSerialization(); }; // Get the validation data from TinyCBOR (see src/3rdparty/tinycbor/tests/parser/data.cpp) @@ -380,11 +384,17 @@ void tst_QCborValue::arrayDefaultInitialization() QVERIFY(v.isArray()); QVERIFY(!v.isMap()); QVERIFY(!v.isTag()); - QVERIFY(v[0].isUndefined()); QCborArray a2 = v.toArray(); QVERIFY(a2.isEmpty()); QCOMPARE(a2, a); + auto front = v[0]; + QVERIFY(front.isUndefined()); + front = 1; + QCOMPARE(v[0], 1); + QVERIFY(a2.isEmpty()); + a2 = v.toArray(); + QCOMPARE(a2.size(), 1); } void tst_QCborValue::mapDefaultInitialization() @@ -421,7 +431,7 @@ void tst_QCborValue::mapDefaultInitialization() QVERIFY(m == QCborMap{}); QVERIFY(QCborMap{} == m); - QCborValue v(m); + const QCborValue v(m); QVERIFY(v.isMap()); QVERIFY(!v.isArray()); QVERIFY(!v.isTag()); @@ -723,6 +733,31 @@ void tst_QCborValue::arrayMutation() QCOMPARE(a.at(1), QCborValue(-1)); QCOMPARE(a2.at(1), QCborValue(nullptr)); QCOMPARE(++it, end); + + // Array accessed via value: + QCborValue val(a); + val[2] = QCborArray{2, 3, 5, 7}; + QCOMPARE(a.size(), 2); // Unchanged + QVERIFY(val.isArray()); + QCOMPARE(val.toArray().size(), 3); + val[2][4] = 17; + QVERIFY(val.isArray()); + QVERIFY(val[2].isArray()); + QCOMPARE(val[2].toArray().size(), 5); + QCOMPARE(val[2][4], 17); + QCOMPARE(val.toArray().size(), 3); + val[3] = 42; + QVERIFY(val.isArray()); + QCOMPARE(val.toArray().size(), 4); + QCOMPARE(val[3], 42); + + // Coerce to map on string key: + const QLatin1String any("any"); + val[any] = any; + QVERIFY(val.isMap()); + QCOMPARE(val.toMap().size(), 5); + QVERIFY(val[2].isArray()); + QCOMPARE(val[2].toArray().size(), 5); } void tst_QCborValue::mapMutation() @@ -778,6 +813,30 @@ void tst_QCborValue::mapMutation() QCOMPARE((m.end() - 1)->toInteger(), -1); QVERIFY((m2.end() - 1)->isNull()); QCOMPARE(++it, end); + + // Map accessed via value: + QCborValue val(m); + val[7] = QCborMap({{0, 2}, {1, 3}, {2, 5}}); + QCOMPARE(m.size(), 2); // Unchanged + QVERIFY(val.isMap()); + QCOMPARE(val.toMap().size(), 3); + val[7][3] = 11; + QVERIFY(val.isMap()); + QVERIFY(val[7].isMap()); + QCOMPARE(val[7].toMap().size(), 4); + val[14] = 42; + QVERIFY(val.isMap()); + QCOMPARE(val.toMap().size(), 4); + + const QLatin1String any("any"); + const QString hello(QStringLiteral("Hello World")); + val[any][3][hello] = any; + QVERIFY(val.isMap()); + QCOMPARE(val.toMap().size(), 5); + QVERIFY(val[any].isMap()); + QCOMPARE(val[any].toMap().size(), 1); + QVERIFY(val[any][3].isMap()); + QCOMPARE(val[any][3].toMap().size(), 1); } void tst_QCborValue::arrayPrepend() @@ -1690,6 +1749,83 @@ void tst_QCborValue::toDiagnosticNotation() QCOMPARE(result, expected); } + +void tst_QCborValue::datastreamSerialization_data() +{ + addCommonCborData(); +} + +void tst_QCborValue::datastreamSerialization() +{ + QFETCH(QCborValue, v); + QByteArray buffer; + { + QDataStream save(&buffer, QIODevice::WriteOnly); + save << v; + QDataStream load(buffer); + QCborValue output; + load >> output; + QCOMPARE(output, v); + } + if (v.isArray()) { + QCborArray array = v.toArray(); + QDataStream save(&buffer, QIODevice::WriteOnly); + save << array; + QDataStream load(buffer); + QCborValue output; + load >> output; + QCOMPARE(output, array); + } else if (v.isMap()) { + QCborMap map = v.toMap(); + QDataStream save(&buffer, QIODevice::WriteOnly); + save << map; + QDataStream load(buffer); + QCborValue output; + load >> output; + QCOMPARE(output, map); + } +} + +void tst_QCborValue::streamVariantSerialization() +{ + // Check interface only, implementation is tested through to and from + // cbor functions. + QByteArray buffer; + { + QCborArray array{665, 666, 667}; + QVariant output; + QVariant variant = QVariant::fromValue(array); + QDataStream save(&buffer, QIODevice::WriteOnly); + save << variant; + QDataStream load(buffer); + load >> output; + QCOMPARE(output.userType(), QMetaType::QCborArray); + QCOMPARE(qvariant_cast<QCborArray>(output), array); + } + { + QCborMap obj{{"foo", 42}}; + QVariant output; + QVariant variant = QVariant::fromValue(obj); + QDataStream save(&buffer, QIODevice::WriteOnly); + save << variant; + QDataStream load(buffer); + load >> output; + QCOMPARE(output.userType(), QMetaType::QCborMap); + QCOMPARE(qvariant_cast<QCborMap>(output), obj); + } + { + QCborValue value{42}; + QVariant output; + QVariant variant = QVariant::fromValue(value); + QDataStream save(&buffer, QIODevice::WriteOnly); + save << variant; + QDataStream load(buffer); + load >> output; + QCOMPARE(output.userType(), QMetaType::QCborValue); + QCOMPARE(qvariant_cast<QCborValue>(output), value); + } +} + QTEST_MAIN(tst_QCborValue) #include "tst_qcborvalue.moc" diff --git a/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp b/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp index 011a0e1a85..d204727bbd 100644 --- a/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp +++ b/tests/auto/corelib/serialization/qdatastream/tst_qdatastream.cpp @@ -135,6 +135,15 @@ private slots: void stream_QByteArray2(); + void stream_QJsonDocument(); + void stream_QJsonArray(); + void stream_QJsonObject(); + void stream_QJsonValue(); + + void stream_QCborArray(); + void stream_QCborMap(); + void stream_QCborValue(); + void setVersion_data(); void setVersion(); @@ -2095,6 +2104,138 @@ void tst_QDataStream::stream_QByteArray2() } } +void tst_QDataStream::stream_QJsonDocument() +{ + QByteArray buffer; + { + QDataStream save(&buffer, QIODevice::WriteOnly); + save << QByteArrayLiteral("invalidJson"); + QDataStream load(&buffer, QIODevice::ReadOnly); + QJsonDocument doc; + load >> doc; + QVERIFY(doc.isEmpty()); + QVERIFY(load.status() != QDataStream::Ok); + QCOMPARE(load.status(), QDataStream::ReadCorruptData); + } + { + QDataStream save(&buffer, QIODevice::WriteOnly); + QJsonDocument docSave(QJsonArray{1,2,3}); + save << docSave; + QDataStream load(&buffer, QIODevice::ReadOnly); + QJsonDocument docLoad; + load >> docLoad; + QCOMPARE(docLoad, docSave); + } +} + +void tst_QDataStream::stream_QJsonArray() +{ + QByteArray buffer; + { + QDataStream save(&buffer, QIODevice::WriteOnly); + save << QByteArrayLiteral("invalidJson"); + QDataStream load(&buffer, QIODevice::ReadOnly); + QJsonArray array; + load >> array; + QVERIFY(array.isEmpty()); + QVERIFY(load.status() != QDataStream::Ok); + QCOMPARE(load.status(), QDataStream::ReadCorruptData); + } + { + QDataStream save(&buffer, QIODevice::WriteOnly); + QJsonArray arraySave(QJsonArray{1,2,3}); + save << arraySave; + QDataStream load(&buffer, QIODevice::ReadOnly); + QJsonArray arrayLoad; + load >> arrayLoad; + QCOMPARE(arrayLoad, arraySave); + } +} + +void tst_QDataStream::stream_QJsonObject() +{ + QByteArray buffer; + { + QDataStream save(&buffer, QIODevice::WriteOnly); + save << QByteArrayLiteral("invalidJson"); + QDataStream load(&buffer, QIODevice::ReadOnly); + QJsonObject object; + load >> object; + QVERIFY(object.isEmpty()); + QVERIFY(load.status() != QDataStream::Ok); + QCOMPARE(load.status(), QDataStream::ReadCorruptData); + } + { + QDataStream save(&buffer, QIODevice::WriteOnly); + QJsonObject objSave{{"foo", 1}, {"bar", 2}}; + save << objSave; + QDataStream load(&buffer, QIODevice::ReadOnly); + QJsonObject objLoad; + load >> objLoad; + QCOMPARE(objLoad, objSave); + } +} + +void tst_QDataStream::stream_QJsonValue() +{ + QByteArray buffer; + { + QDataStream save(&buffer, QIODevice::WriteOnly); + save << quint8(42); + QDataStream load(&buffer, QIODevice::ReadOnly); + QJsonValue value; + load >> value; + QVERIFY(value.isUndefined()); + QVERIFY(load.status() != QDataStream::Ok); + QCOMPARE(load.status(), QDataStream::ReadCorruptData); + } + { + QDataStream save(&buffer, QIODevice::WriteOnly); + QJsonValue valueSave{42}; + save << valueSave; + QDataStream load(&buffer, QIODevice::ReadOnly); + QJsonValue valueLoad; + load >> valueLoad; + QCOMPARE(valueLoad, valueSave); + } +} + +void tst_QDataStream::stream_QCborArray() +{ + QByteArray buffer; + QDataStream save(&buffer, QIODevice::WriteOnly); + QCborArray arraySave({1, 2, 3}); + save << arraySave; + QDataStream load(&buffer, QIODevice::ReadOnly); + QCborArray arrayLoad; + load >> arrayLoad; + QCOMPARE(arrayLoad, arraySave); +} + +void tst_QDataStream::stream_QCborMap() +{ + QByteArray buffer; + QDataStream save(&buffer, QIODevice::WriteOnly); + QCborMap objSave{{"foo", 1}, {"bar", 2}}; + save << objSave; + QDataStream load(&buffer, QIODevice::ReadOnly); + QCborMap objLoad; + load >> objLoad; + QCOMPARE(objLoad, objSave); +} + +void tst_QDataStream::stream_QCborValue() +{ + QByteArray buffer; + QDataStream save(&buffer, QIODevice::WriteOnly); + QCborValue valueSave{42}; + save << valueSave; + QDataStream load(&buffer, QIODevice::ReadOnly); + QCborValue valueLoad; + load >> valueLoad; + QCOMPARE(valueLoad, valueSave); +} + void tst_QDataStream::setVersion_data() { QTest::addColumn<int>("vers"); diff --git a/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp b/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp index edea4713a1..1c1631760b 100644 --- a/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp +++ b/tests/auto/corelib/serialization/qtextstream/tst_qtextstream.cpp @@ -2662,28 +2662,30 @@ void tst_QTextStream::useCase2() // ------------------------------------------------------------------------------ void tst_QTextStream::manipulators_data() { - QTest::addColumn<int>("flags"); + QTest::addColumn<int>("base"); + QTest::addColumn<int>("alignFlag"); + QTest::addColumn<int>("numberFlag"); QTest::addColumn<int>("width"); QTest::addColumn<double>("realNumber"); QTest::addColumn<int>("intNumber"); QTest::addColumn<QString>("textData"); QTest::addColumn<QByteArray>("result"); - QTest::newRow("no flags") << 0 << 0 << 5.0 << 5 << QString("five") << QByteArray("55five"); - QTest::newRow("rightadjust") << 0 << 10 << 5.0 << 5 << QString("five") << QByteArray(" 5 5 five"); - - // ### FIX -// QTest::newRow("leftadjust") << int(QTextStream::left) << 10 << 5.0 << 5 << QString("five") << QByteArray("5 5 five "); -// QTest::newRow("showpos") << int(QTextStream::showpos) << 10 << 5.0 << 5 << QString("five") << QByteArray(" +5 +5 five"); -// QTest::newRow("showpos2") << int(QTextStream::showpos) << 5 << 3.14 << -5 << QString("five") << QByteArray("+3.14 -5 five"); -// QTest::newRow("hex") << int(QTextStream::hex | QTextStream::showbase) << 5 << 3.14 << -5 << QString("five") << QByteArray(" 3.14 -0x5 five"); -// QTest::newRow("hex uppercase") << int(QTextStream::hex | QTextStream::uppercase | QTextStream::showbase) << 5 << 3.14 << -5 << QString("five") << QByteArray(" 3.14 -0X5 five"); + QTest::newRow("no flags") << 10 << 0 << 0 << 0 << 5.0 << 5 << QString("five") << QByteArray("55five"); + QTest::newRow("rightadjust") << 10 << int(QTextStream::AlignRight) << 0 << 10 << 5.0 << 5 << QString("five") << QByteArray(" 5 5 five"); + QTest::newRow("leftadjust") << 10 << int(QTextStream::AlignLeft) << 0 << 10 << 5.0 << 5 << QString("five") << QByteArray("5 5 five "); + QTest::newRow("showpos") << 10 << int(QTextStream::AlignRight) << int(QTextStream::ForceSign) << 10 << 5.0 << 5 << QString("five") << QByteArray(" +5 +5 five"); + QTest::newRow("showpos2") << 10 << int(QTextStream::AlignRight) << int(QTextStream::ForceSign) << 5 << 3.14 << -5 << QString("five") << QByteArray("+3.14 -5 five"); + QTest::newRow("hex") << 16 << int(QTextStream::AlignRight) << int(QTextStream::ShowBase) << 5 << 3.14 << -5 << QString("five") << QByteArray(" 3.14 -0x5 five"); + QTest::newRow("hex") << 16 << int(QTextStream::AlignRight) << int(QTextStream::ShowBase | QTextStream::UppercaseBase) << 5 << 3.14 << -5 << QString("five") << QByteArray(" 3.14 -0X5 five"); } // ------------------------------------------------------------------------------ void tst_QTextStream::manipulators() { -// QFETCH(int, flags); + QFETCH(int, base); + QFETCH(int, alignFlag); + QFETCH(int, numberFlag); QFETCH(int, width); QFETCH(double, realNumber); QFETCH(int, intNumber); @@ -2697,14 +2699,16 @@ void tst_QTextStream::manipulators() stream.setCodec(QTextCodec::codecForName("ISO-8859-1")); stream.setAutoDetectUnicode(true); -// stream.setFlags(flags); + stream.setIntegerBase(base); + stream.setFieldAlignment(QTextStream::FieldAlignment(alignFlag)); + stream.setNumberFlags(QTextStream::NumberFlag(numberFlag)); stream.setFieldWidth(width); stream << realNumber; stream << intNumber; stream << textData; stream.flush(); - QCOMPARE(buffer.data().constData(), result.constData()); + QCOMPARE(buffer.data(), result); } void tst_QTextStream::generateBOM() diff --git a/tests/auto/corelib/tools/qbytearraylist/tst_qbytearraylist.cpp b/tests/auto/corelib/tools/qbytearraylist/tst_qbytearraylist.cpp index 85b4c4bfb7..2d2c536453 100644 --- a/tests/auto/corelib/tools/qbytearraylist/tst_qbytearraylist.cpp +++ b/tests/auto/corelib/tools/qbytearraylist/tst_qbytearraylist.cpp @@ -49,6 +49,9 @@ private slots: void operator_plus() const; void operator_plus_data() const; + void indexOf_data() const; + void indexOf() const; + void initializerList() const; }; @@ -259,6 +262,29 @@ void tst_QByteArrayList::operator_plus_data() const << ( QByteArrayList() << "a" << "" << "c" ); } +void tst_QByteArrayList::indexOf_data() const +{ + QTest::addColumn<QByteArrayList>("list"); + QTest::addColumn<QByteArray>("item"); + QTest::addColumn<int>("expectedResult"); + + QTest::newRow("empty") << QByteArrayList() << QByteArray("a") << -1; + QTest::newRow("found_1") << ( QByteArrayList() << "a" ) << QByteArray("a") << 0; + QTest::newRow("not_found_1") << ( QByteArrayList() << "a" ) << QByteArray("b") << -1; + QTest::newRow("found_2") << ( QByteArrayList() << "hello" << "world" ) << QByteArray("world") << 1; + QTest::newRow("returns_first") << ( QByteArrayList() << "hello" << "world" << "hello" << "again" ) << QByteArray("hello") << 0; +} + +void tst_QByteArrayList::indexOf() const +{ + QFETCH(QByteArrayList, list); + QFETCH(QByteArray, item); + QFETCH(int, expectedResult); + + QCOMPARE(list.indexOf(item), expectedResult); + QCOMPARE(list.indexOf(item.constData()), expectedResult); +} + void tst_QByteArrayList::initializerList() const { #ifdef Q_COMPILER_INITIALIZER_LISTS diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp index 943805e228..56792f38fb 100644 --- a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp @@ -37,9 +37,6 @@ #ifdef Q_OS_WIN # include <qt_windows.h> -# if defined(Q_OS_WINRT) -# define tzset() -# endif #endif class tst_QDateTime : public QObject @@ -145,9 +142,7 @@ private slots: void isDaylightTime() const; void daylightTransitions() const; void timeZones() const; -#if defined(Q_OS_UNIX) void systemTimeZoneChange() const; -#endif void invalid() const; @@ -174,7 +169,7 @@ private: void reset(const QByteArray &zone) { qputenv("TZ", zone.constData()); - tzset(); + qTzSet(); } ~TimeZoneRollback() { @@ -182,7 +177,7 @@ private: qunsetenv("TZ"); else qputenv("TZ", prior.constData()); - tzset(); + qTzSet(); } }; }; @@ -3412,33 +3407,10 @@ void tst_QDateTime::timeZones() const QCOMPARE(future.offsetFromUtc(), 28800); } -#if defined(Q_OS_UNIX) -// Currently disabled on Windows as adjusting the timezone -// requires additional privileges that aren't normally -// enabled for a process. This can be achieved by calling -// AdjustTokenPrivileges() and then SetTimeZoneInformation(), -// which will require linking to a different library to access that API. -static void setTimeZone(const QByteArray &tz) -{ - qputenv("TZ", tz); - ::tzset(); - -// following left for future reference, see comment above -// #if defined(Q_OS_WIN32) -// ::_tzset(); -// #endif -} - void tst_QDateTime::systemTimeZoneChange() const { - struct ResetTZ { - QByteArray original; - ResetTZ() : original(qgetenv("TZ")) {} - ~ResetTZ() { setTimeZone(original); } - } scopedReset; - // Set the timezone to Brisbane time - setTimeZone(QByteArray("AEST-10:00")); + TimeZoneRollback useZone(QByteArray("AEST-10:00")); QDateTime localDate = QDateTime(QDate(2012, 6, 1), QTime(2, 15, 30), Qt::LocalTime); QDateTime utcDate = QDateTime(QDate(2012, 6, 1), QTime(2, 15, 30), Qt::UTC); @@ -3451,16 +3423,18 @@ void tst_QDateTime::systemTimeZoneChange() const QVERIFY(tzDate.timeZone().isValid()); // Change to Indian time - setTimeZone(QByteArray("IST-05:30")); + useZone.reset(QByteArray("IST-05:30")); QCOMPARE(localDate, QDateTime(QDate(2012, 6, 1), QTime(2, 15, 30), Qt::LocalTime)); +#ifdef Q_OS_WINRT + QEXPECT_FAIL("", "WinRT gets this wrong, QTBUG-71185", Continue); +#endif QVERIFY(localMsecs != localDate.toMSecsSinceEpoch()); QCOMPARE(utcDate, QDateTime(QDate(2012, 6, 1), QTime(2, 15, 30), Qt::UTC)); QCOMPARE(utcDate.toMSecsSinceEpoch(), utcMsecs); QCOMPARE(tzDate, QDateTime(QDate(2012, 6, 1), QTime(2, 15, 30), QTimeZone("Australia/Brisbane"))); QCOMPARE(tzDate.toMSecsSinceEpoch(), tzMsecs); } -#endif void tst_QDateTime::invalid() const { diff --git a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp index 261689d401..ff36beadcb 100644 --- a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp +++ b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp @@ -1869,9 +1869,11 @@ static void setWinLocaleInfo(LCTYPE type, const QString &value) # define LOCALE_SSHORTTIME 0x00000079 #endif -class RestoreLocaleHelper { +class RestoreLocaleHelper +{ public: - RestoreLocaleHelper() { + RestoreLocaleHelper() + { m_decimal = getWinLocaleInfo(LOCALE_SDECIMAL); m_thousand = getWinLocaleInfo(LOCALE_STHOUSAND); m_sdate = getWinLocaleInfo(LOCALE_SSHORTDATE); @@ -1879,7 +1881,8 @@ public: m_time = getWinLocaleInfo(LOCALE_SSHORTTIME); } - ~RestoreLocaleHelper() { + ~RestoreLocaleHelper() + { // restore these, or the user will get a surprise setWinLocaleInfo(LOCALE_SDECIMAL, m_decimal); setWinLocaleInfo(LOCALE_STHOUSAND, m_thousand); @@ -1887,12 +1890,10 @@ public: setWinLocaleInfo(LOCALE_SLONGDATE, m_ldate); setWinLocaleInfo(LOCALE_SSHORTTIME, m_time); - // make sure QLocale::system() gets updated - QLocalePrivate::updateSystemPrivate(); + QSystemLocale dummy; // to provoke a refresh of the system locale } QString m_decimal, m_thousand, m_sdate, m_ldate, m_time; - }; void tst_QLocale::windowsDefaultLocale() @@ -1908,8 +1909,7 @@ void tst_QLocale::windowsDefaultLocale() const QString shortTimeFormat = QStringLiteral("h^m^s"); setWinLocaleInfo(LOCALE_SSHORTTIME, shortTimeFormat); - // make sure QLocale::system() gets updated - QLocalePrivate::updateSystemPrivate(); + QSystemLocale dummy; // to provoke a refresh of the system locale QLocale locale = QLocale::system(); // make sure we are seeing the system's format strings @@ -2650,9 +2650,11 @@ void tst_QLocale::textDirection_data() case QLocale::Sabaean: case QLocale::Samaritan: case QLocale::Sindhi: + case QLocale::SouthernKurdish: case QLocale::Syriac: case QLocale::Uighur: case QLocale::Urdu: + case QLocale::WesternBalochi: case QLocale::Yiddish: // false if there is no locale data for language: rightToLeft = (QLocale(QLocale::Language(language)).language() diff --git a/tests/auto/corelib/tools/qoffsetstringarray/qoffsetstringarray.pro b/tests/auto/corelib/tools/qoffsetstringarray/qoffsetstringarray.pro new file mode 100644 index 0000000000..c8e6a8e05a --- /dev/null +++ b/tests/auto/corelib/tools/qoffsetstringarray/qoffsetstringarray.pro @@ -0,0 +1,6 @@ +CONFIG += testcase +TARGET = tst_qoffsetstringarray +QT = core testlib core-private +CONFIG += c++11 +CONFIG += strict_c++ +SOURCES = $$PWD/tst_qoffsetstringarray.cpp diff --git a/tests/auto/corelib/tools/qoffsetstringarray/tst_qoffsetstringarray.cpp b/tests/auto/corelib/tools/qoffsetstringarray/tst_qoffsetstringarray.cpp new file mode 100644 index 0000000000..dfa0450b18 --- /dev/null +++ b/tests/auto/corelib/tools/qoffsetstringarray/tst_qoffsetstringarray.cpp @@ -0,0 +1,121 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> + +#include <private/qoffsetstringarray_p.h> + + +class tst_QOffsetStringArray : public QObject +{ + Q_OBJECT + +private slots: + void init(); + void access(); +}; + + +constexpr const auto messages = qOffsetStringArray( + "level - 0", + "level - 1", + "level - 2", + "level - 3", + "level - 4", + "" +); + +constexpr const auto messages257 = qOffsetStringArray( + "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", + + "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", + + "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "", "", "", "", + "", "", "", "", "", "", "end" +); + +constexpr const auto messagesBigOffsets = qOffsetStringArray( + " 10 20 30 40 50 60 70 80 90", + " 10 20 30 40 50 60 70 80 90", + " 10 20 30 40 50 60 70 80 90", + " 10 20 30 40 50 60 70 80 90" +); + +void tst_QOffsetStringArray::init() +{ + static_assert(messages.sizeString == 51, "message.sizeString"); + static_assert(messages.sizeOffsets == 6, "message.sizeOffsets"); + static_assert(std::is_same<decltype(messages)::Type, quint8>::value, "messages::Type != quint8"); + + static_assert(messages257.sizeOffsets == 257, "messages257.sizeOffsets"); + static_assert(messages257.sizeString == 260, "messages257.sizeString"); + static_assert(std::is_same<decltype(messages257)::Type, quint16>::value, + "messages257::Type != quint16"); + + static_assert(messagesBigOffsets.sizeOffsets == 4, "messagesBigOffsets.sizeOffsets"); + static_assert(messagesBigOffsets.sizeString == 364, "messagesBigOffsets.sizeString"); + static_assert(std::is_same<decltype(messagesBigOffsets)::Type, quint16>::value, + "messagesBigOffsets::Type != quint16"); +} + +void tst_QOffsetStringArray::access() +{ + QCOMPARE(messages[0], "level - 0"); + QCOMPARE(messages[1], "level - 1"); + QCOMPARE(messages[2], "level - 2"); + QCOMPARE(messages[3], "level - 3"); + QCOMPARE(messages[4], "level - 4"); + QCOMPARE(messages[5], ""); + QCOMPARE(messages[6], ""); +} + + +QTEST_APPLESS_MAIN(tst_QOffsetStringArray) +#include "tst_qoffsetstringarray.moc" diff --git a/tests/auto/corelib/tools/tools.pro b/tests/auto/corelib/tools/tools.pro index f28cf21b8b..2a975e67d1 100644 --- a/tests/auto/corelib/tools/tools.pro +++ b/tests/auto/corelib/tools/tools.pro @@ -35,6 +35,7 @@ SUBDIRS=\ qmap_strictiterators \ qmargins \ qmessageauthenticationcode \ + qoffsetstringarray \ qpair \ qpoint \ qpointf \ diff --git a/tests/auto/dbus/qdbusservicewatcher/tst_qdbusservicewatcher.cpp b/tests/auto/dbus/qdbusservicewatcher/tst_qdbusservicewatcher.cpp index b79f3ea5e3..1ba7ee51b1 100644 --- a/tests/auto/dbus/qdbusservicewatcher/tst_qdbusservicewatcher.cpp +++ b/tests/auto/dbus/qdbusservicewatcher/tst_qdbusservicewatcher.cpp @@ -34,22 +34,27 @@ class tst_QDBusServiceWatcher: public QObject { Q_OBJECT - QString serviceName; int testCounter; public: tst_QDBusServiceWatcher(); private slots: void initTestCase(); - void init(); - + void watchForCreation_data(); void watchForCreation(); + void watchForDisappearance_data(); void watchForDisappearance(); void watchForDisappearanceUniqueConnection(); + void watchForOwnerChange_data(); void watchForOwnerChange(); + void modeChange_data(); void modeChange(); void disconnectedConnection(); + void setConnection_data(); void setConnection(); + +private: + QString generateServiceName(); }; tst_QDBusServiceWatcher::tst_QDBusServiceWatcher() @@ -63,18 +68,45 @@ void tst_QDBusServiceWatcher::initTestCase() QVERIFY(con.isConnected()); } -void tst_QDBusServiceWatcher::init() +QString tst_QDBusServiceWatcher::generateServiceName() { + return "com.example.TestService" + QString::number(testCounter++); +} + +void tst_QDBusServiceWatcher::watchForCreation_data() { - // change the service name from test to test - serviceName = "com.example.TestService" + QString::number(testCounter++); + QTest::addColumn<QString>("watchedName"); + QTest::addColumn<QString>("registeredName"); + + //com.example.TestService5 matches com.example.TestService5 + QString name = generateServiceName(); + QTest::newRow("normal") << name << name; + + //com.example* matches com.example.TestService5 + name = generateServiceName(); + QTest::newRow("wildcard") << "com.example*" << name; + + //com.example.TestService5* matches com.example.TestService5 + name = generateServiceName(); + QTest::newRow("wildcard_exact") << name+"*" << name; + + //com.example.TestService5* matches com.example.TestService5.Foo + name = generateServiceName(); + QTest::newRow("wildcard_subdomain") << name+"*" << name + ".Foo"; + + //com.example.TestService5* matches com.example.TestService5.Foo.Bar + name = generateServiceName(); + QTest::newRow("wildcard_subsubdomain") << name+"*" << name + ".Foo.Bar"; } void tst_QDBusServiceWatcher::watchForCreation() { + QFETCH(QString, watchedName); + QFETCH(QString, registeredName); + QDBusConnection con = QDBusConnection::sessionBus(); QVERIFY(con.isConnected()); - QDBusServiceWatcher watcher(serviceName, con, QDBusServiceWatcher::WatchForRegistration); + QDBusServiceWatcher watcher(watchedName, con, QDBusServiceWatcher::WatchForRegistration); QSignalSpy spyR(&watcher, SIGNAL(serviceRegistered(QString))); QSignalSpy spyU(&watcher, SIGNAL(serviceUnregistered(QString))); @@ -82,18 +114,18 @@ void tst_QDBusServiceWatcher::watchForCreation() QTestEventLoop::instance().connect(&watcher, SIGNAL(serviceRegistered(QString)), SLOT(exitLoop())); // register a name - QVERIFY(con.registerService(serviceName)); + QVERIFY(con.registerService(registeredName)); QTestEventLoop::instance().enterLoop(1); QVERIFY(!QTestEventLoop::instance().timeout()); QCOMPARE(spyR.count(), 1); - QCOMPARE(spyR.at(0).at(0).toString(), serviceName); + QCOMPARE(spyR.at(0).at(0).toString(), registeredName); QCOMPARE(spyU.count(), 0); QCOMPARE(spyO.count(), 1); - QCOMPARE(spyO.at(0).at(0).toString(), serviceName); + QCOMPARE(spyO.at(0).at(0).toString(), registeredName); QVERIFY(spyO.at(0).at(1).toString().isEmpty()); QCOMPARE(spyO.at(0).at(2).toString(), con.baseService()); @@ -102,31 +134,39 @@ void tst_QDBusServiceWatcher::watchForCreation() spyO.clear(); // unregister it: - con.unregisterService(serviceName); + con.unregisterService(registeredName); // and register again - QVERIFY(con.registerService(serviceName)); + QVERIFY(con.registerService(registeredName)); QTestEventLoop::instance().enterLoop(1); QVERIFY(!QTestEventLoop::instance().timeout()); QCOMPARE(spyR.count(), 1); - QCOMPARE(spyR.at(0).at(0).toString(), serviceName); + QCOMPARE(spyR.at(0).at(0).toString(), registeredName); QCOMPARE(spyU.count(), 0); QCOMPARE(spyO.count(), 1); - QCOMPARE(spyO.at(0).at(0).toString(), serviceName); + QCOMPARE(spyO.at(0).at(0).toString(), registeredName); QVERIFY(spyO.at(0).at(1).toString().isEmpty()); QCOMPARE(spyO.at(0).at(2).toString(), con.baseService()); } +void tst_QDBusServiceWatcher::watchForDisappearance_data() +{ + tst_QDBusServiceWatcher::watchForCreation_data(); +} + void tst_QDBusServiceWatcher::watchForDisappearance() { + QFETCH(QString, watchedName); + QFETCH(QString, registeredName); + QDBusConnection con = QDBusConnection::sessionBus(); QVERIFY(con.isConnected()); - QDBusServiceWatcher watcher(serviceName, con, QDBusServiceWatcher::WatchForUnregistration); + QDBusServiceWatcher watcher(watchedName, con, QDBusServiceWatcher::WatchForUnregistration); watcher.setObjectName("watcher for disappearance"); QSignalSpy spyR(&watcher, SIGNAL(serviceRegistered(QString))); @@ -135,10 +175,10 @@ void tst_QDBusServiceWatcher::watchForDisappearance() QTestEventLoop::instance().connect(&watcher, SIGNAL(serviceUnregistered(QString)), SLOT(exitLoop())); // register a name - QVERIFY(con.registerService(serviceName)); + QVERIFY(con.registerService(registeredName)); // unregister it: - con.unregisterService(serviceName); + con.unregisterService(registeredName); QTestEventLoop::instance().enterLoop(1); QVERIFY(!QTestEventLoop::instance().timeout()); @@ -146,10 +186,10 @@ void tst_QDBusServiceWatcher::watchForDisappearance() QCOMPARE(spyR.count(), 0); QCOMPARE(spyU.count(), 1); - QCOMPARE(spyU.at(0).at(0).toString(), serviceName); + QCOMPARE(spyU.at(0).at(0).toString(), registeredName); QCOMPARE(spyO.count(), 1); - QCOMPARE(spyO.at(0).at(0).toString(), serviceName); + QCOMPARE(spyO.at(0).at(0).toString(), registeredName); QCOMPARE(spyO.at(0).at(1).toString(), con.baseService()); QVERIFY(spyO.at(0).at(2).toString().isEmpty()); } @@ -188,12 +228,20 @@ void tst_QDBusServiceWatcher::watchForDisappearanceUniqueConnection() QVERIFY(spyO.at(0).at(2).toString().isEmpty()); } +void tst_QDBusServiceWatcher::watchForOwnerChange_data() +{ + watchForCreation_data(); +} + void tst_QDBusServiceWatcher::watchForOwnerChange() { + QFETCH(QString, watchedName); + QFETCH(QString, registeredName); + QDBusConnection con = QDBusConnection::sessionBus(); QVERIFY(con.isConnected()); - QDBusServiceWatcher watcher(serviceName, con, QDBusServiceWatcher::WatchForOwnerChange); + QDBusServiceWatcher watcher(watchedName, con, QDBusServiceWatcher::WatchForOwnerChange); QSignalSpy spyR(&watcher, SIGNAL(serviceRegistered(QString))); QSignalSpy spyU(&watcher, SIGNAL(serviceUnregistered(QString))); @@ -201,18 +249,18 @@ void tst_QDBusServiceWatcher::watchForOwnerChange() QTestEventLoop::instance().connect(&watcher, SIGNAL(serviceRegistered(QString)), SLOT(exitLoop())); // register a name - QVERIFY(con.registerService(serviceName)); + QVERIFY(con.registerService(registeredName)); QTestEventLoop::instance().enterLoop(1); QVERIFY(!QTestEventLoop::instance().timeout()); QCOMPARE(spyR.count(), 1); - QCOMPARE(spyR.at(0).at(0).toString(), serviceName); + QCOMPARE(spyR.at(0).at(0).toString(), registeredName); QCOMPARE(spyU.count(), 0); QCOMPARE(spyO.count(), 1); - QCOMPARE(spyO.at(0).at(0).toString(), serviceName); + QCOMPARE(spyO.at(0).at(0).toString(), registeredName); QVERIFY(spyO.at(0).at(1).toString().isEmpty()); QCOMPARE(spyO.at(0).at(2).toString(), con.baseService()); @@ -221,35 +269,43 @@ void tst_QDBusServiceWatcher::watchForOwnerChange() spyO.clear(); // unregister it: - con.unregisterService(serviceName); + con.unregisterService(registeredName); // and register again - QVERIFY(con.registerService(serviceName)); + QVERIFY(con.registerService(registeredName)); QTestEventLoop::instance().enterLoop(1); QVERIFY(!QTestEventLoop::instance().timeout()); QCOMPARE(spyR.count(), 1); - QCOMPARE(spyR.at(0).at(0).toString(), serviceName); + QCOMPARE(spyR.at(0).at(0).toString(), registeredName); QCOMPARE(spyU.count(), 1); - QCOMPARE(spyU.at(0).at(0).toString(), serviceName); + QCOMPARE(spyU.at(0).at(0).toString(), registeredName); QCOMPARE(spyO.count(), 2); - QCOMPARE(spyO.at(0).at(0).toString(), serviceName); + QCOMPARE(spyO.at(0).at(0).toString(), registeredName); QCOMPARE(spyO.at(0).at(1).toString(), con.baseService()); QVERIFY(spyO.at(0).at(2).toString().isEmpty()); - QCOMPARE(spyO.at(1).at(0).toString(), serviceName); + QCOMPARE(spyO.at(1).at(0).toString(), registeredName); QVERIFY(spyO.at(1).at(1).toString().isEmpty()); QCOMPARE(spyO.at(1).at(2).toString(), con.baseService()); } +void tst_QDBusServiceWatcher::modeChange_data() +{ + watchForCreation_data(); +} + void tst_QDBusServiceWatcher::modeChange() { + QFETCH(QString, watchedName); + QFETCH(QString, registeredName); + QDBusConnection con = QDBusConnection::sessionBus(); QVERIFY(con.isConnected()); - QDBusServiceWatcher watcher(serviceName, con, QDBusServiceWatcher::WatchForRegistration); + QDBusServiceWatcher watcher(watchedName, con, QDBusServiceWatcher::WatchForRegistration); QSignalSpy spyR(&watcher, SIGNAL(serviceRegistered(QString))); QSignalSpy spyU(&watcher, SIGNAL(serviceUnregistered(QString))); @@ -257,18 +313,18 @@ void tst_QDBusServiceWatcher::modeChange() QTestEventLoop::instance().connect(&watcher, SIGNAL(serviceRegistered(QString)), SLOT(exitLoop())); // register a name - QVERIFY(con.registerService(serviceName)); + QVERIFY(con.registerService(registeredName)); QTestEventLoop::instance().enterLoop(1); QVERIFY(!QTestEventLoop::instance().timeout()); QCOMPARE(spyR.count(), 1); - QCOMPARE(spyR.at(0).at(0).toString(), serviceName); + QCOMPARE(spyR.at(0).at(0).toString(), registeredName); QCOMPARE(spyU.count(), 0); QCOMPARE(spyO.count(), 1); - QCOMPARE(spyO.at(0).at(0).toString(), serviceName); + QCOMPARE(spyO.at(0).at(0).toString(), registeredName); QVERIFY(spyO.at(0).at(1).toString().isEmpty()); QCOMPARE(spyO.at(0).at(2).toString(), con.baseService()); @@ -279,7 +335,7 @@ void tst_QDBusServiceWatcher::modeChange() watcher.setWatchMode(QDBusServiceWatcher::WatchForUnregistration); // unregister it: - con.unregisterService(serviceName); + con.unregisterService(registeredName); QTestEventLoop::instance().connect(&watcher, SIGNAL(serviceUnregistered(QString)), SLOT(exitLoop())); QTestEventLoop::instance().enterLoop(1); @@ -288,10 +344,10 @@ void tst_QDBusServiceWatcher::modeChange() QCOMPARE(spyR.count(), 0); QCOMPARE(spyU.count(), 1); - QCOMPARE(spyU.at(0).at(0).toString(), serviceName); + QCOMPARE(spyU.at(0).at(0).toString(), registeredName); QCOMPARE(spyO.count(), 1); - QCOMPARE(spyO.at(0).at(0).toString(), serviceName); + QCOMPARE(spyO.at(0).at(0).toString(), registeredName); QCOMPARE(spyO.at(0).at(1).toString(), con.baseService()); QVERIFY(spyO.at(0).at(2).toString().isEmpty()); } @@ -301,7 +357,7 @@ void tst_QDBusServiceWatcher::disconnectedConnection() QDBusConnection con(""); QVERIFY(!con.isConnected()); - QDBusServiceWatcher watcher(serviceName, con, QDBusServiceWatcher::WatchForRegistration); + QDBusServiceWatcher watcher(generateServiceName(), con, QDBusServiceWatcher::WatchForRegistration); watcher.addWatchedService("com.example.somethingelse"); watcher.addWatchedService("org.freedesktop.DBus"); @@ -311,8 +367,15 @@ void tst_QDBusServiceWatcher::disconnectedConnection() watcher.setWatchedServices(QStringList()); } +void tst_QDBusServiceWatcher::setConnection_data() +{ + QTest::addColumn<QString>("serviceName"); + QTest::newRow("normal") << generateServiceName(); +} + void tst_QDBusServiceWatcher::setConnection() { + QFETCH(QString, serviceName); // begin with a disconnected connection QDBusConnection con(""); QVERIFY(!con.isConnected()); diff --git a/tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp b/tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp index d19aa9b54f..2deb84fa5f 100644 --- a/tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp +++ b/tests/auto/gui/itemmodels/qstandarditem/tst_qstandarditem.cpp @@ -202,9 +202,7 @@ void tst_QStandardItem::getSetData() QCOMPARE(qvariant_cast<QSize>(item.data(Qt::SizeHintRole)), sizeHint); QCOMPARE(qvariant_cast<QFont>(item.data(Qt::FontRole)), font); QCOMPARE(qvariant_cast<int>(item.data(Qt::TextAlignmentRole)), int(textAlignment)); - QCOMPARE(qvariant_cast<QBrush>(item.data(Qt::BackgroundColorRole)), QBrush(backgroundColor)); QCOMPARE(qvariant_cast<QBrush>(item.data(Qt::BackgroundRole)), QBrush(backgroundColor)); - QCOMPARE(qvariant_cast<QBrush>(item.data(Qt::TextColorRole)), QBrush(textColor)); QCOMPARE(qvariant_cast<QBrush>(item.data(Qt::ForegroundRole)), QBrush(textColor)); QCOMPARE(qvariant_cast<int>(item.data(Qt::CheckStateRole)), int(checkState)); QCOMPARE(qvariant_cast<QString>(item.data(Qt::AccessibleTextRole)), accessibleText); @@ -236,9 +234,7 @@ void tst_QStandardItem::getSetData() QCOMPARE(item.data(Qt::SizeHintRole), QVariant()); QCOMPARE(item.data(Qt::FontRole), QVariant()); QCOMPARE(item.data(Qt::TextAlignmentRole), QVariant()); - QCOMPARE(item.data(Qt::BackgroundColorRole), QVariant()); QCOMPARE(item.data(Qt::BackgroundRole), QVariant()); - QCOMPARE(item.data(Qt::TextColorRole), QVariant()); QCOMPARE(item.data(Qt::ForegroundRole), QVariant()); QCOMPARE(item.data(Qt::CheckStateRole), QVariant()); QCOMPARE(item.data(Qt::AccessibleTextRole), QVariant()); diff --git a/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp b/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp index e2d7a41bd1..550f70890e 100644 --- a/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp +++ b/tests/auto/gui/itemmodels/qstandarditemmodel/tst_qstandarditemmodel.cpp @@ -1160,7 +1160,7 @@ void tst_QStandardItemModel::getSetItemData() QColor backgroundColor(Qt::blue); roles.insert(Qt::BackgroundRole, backgroundColor); QColor textColor(Qt::green); - roles.insert(Qt::TextColorRole, textColor); + roles.insert(Qt::ForegroundRole, textColor); Qt::CheckState checkState(Qt::PartiallyChecked); roles.insert(Qt::CheckStateRole, int(checkState)); QLatin1String accessibleText("accessibleText"); diff --git a/tests/auto/gui/kernel/qguimetatype/tst_qguimetatype.cpp b/tests/auto/gui/kernel/qguimetatype/tst_qguimetatype.cpp index cca0e95c29..b2572188b9 100644 --- a/tests/auto/gui/kernel/qguimetatype/tst_qguimetatype.cpp +++ b/tests/auto/gui/kernel/qguimetatype/tst_qguimetatype.cpp @@ -49,6 +49,8 @@ private slots: void construct(); void constructCopy_data(); void constructCopy(); + void saveAndLoadBuiltin_data(); + void saveAndLoadBuiltin(); }; #define FOR_EACH_GUI_METATYPE_BASE(F) \ @@ -442,5 +444,49 @@ FOR_EACH_GUI_METATYPE(RETURN_CONSTRUCT_COPY_FUNCTION) TypeTestFunctionGetter::get(type)(); } +template <typename T> +struct StreamingTraits +{ + // Streamable by default, as currently all gui built-in types are streamable + enum { isStreamable = 1 }; +}; + +void tst_QGuiMetaType::saveAndLoadBuiltin_data() +{ + QTest::addColumn<int>("type"); + QTest::addColumn<bool>("isStreamable"); + +#define ADD_METATYPE_TEST_ROW(MetaTypeName, MetaTypeId, RealType) \ + QTest::newRow(#RealType) << MetaTypeId << bool(StreamingTraits<RealType>::isStreamable); + QT_FOR_EACH_STATIC_GUI_CLASS(ADD_METATYPE_TEST_ROW) +#undef ADD_METATYPE_TEST_ROW +} + +void tst_QGuiMetaType::saveAndLoadBuiltin() +{ + QFETCH(int, type); + QFETCH(bool, isStreamable); + + void *value = QMetaType::create(type); + + QByteArray ba; + QDataStream stream(&ba, QIODevice::ReadWrite); + QCOMPARE(QMetaType::save(stream, type, value), isStreamable); + QCOMPARE(stream.status(), QDataStream::Ok); + + if (isStreamable) + QVERIFY(QMetaType::load(stream, type, value)); + + stream.device()->seek(0); + stream.resetStatus(); + QCOMPARE(QMetaType::load(stream, type, value), isStreamable); + QCOMPARE(stream.status(), QDataStream::Ok); + + if (isStreamable) + QVERIFY(QMetaType::load(stream, type, value)); + + QMetaType::destroy(type, value); +} + QTEST_MAIN(tst_QGuiMetaType) #include "tst_qguimetatype.moc" diff --git a/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp b/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp index cfd24a8701..7dbeb13aa7 100644 --- a/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp +++ b/tests/auto/gui/text/qcssparser/tst_qcssparser.cpp @@ -835,17 +835,32 @@ void tst_QCssParser::colorValue_data() QTest::newRow("hexcolor") << "color: #12af0e" << QColor(0x12, 0xaf, 0x0e); QTest::newRow("functional1") << "color: rgb(21, 45, 73)" << QColor(21, 45, 73); QTest::newRow("functional2") << "color: rgb(100%, 0%, 100%)" << QColor(0xff, 0, 0xff); + QTest::newRow("rgb") << "color: rgb(10, 20, 30)" << QColor(10, 20, 30); QTest::newRow("rgba") << "color: rgba(10, 20, 30, 40)" << QColor(10, 20, 30, 40); QTest::newRow("rgbaf") << "color: rgba(10, 20, 30, 0.5)" << QColor(10, 20, 30, 127); - QTest::newRow("rgb") << "color: rgb(10, 20, 30, 40)" << QColor(10, 20, 30, 40); - QTest::newRow("hsl") << "color: hsv(10, 20, 30)" << QColor::fromHsv(10, 20, 30, 255); - QTest::newRow("hsla") << "color: hsva(10, 20, 30, 40)" << QColor::fromHsv(10, 20, 30, 40); + QTest::newRow("hsv") << "color: hsv(10, 20, 30)" << QColor::fromHsv(10, 20, 30); + QTest::newRow("hsva") << "color: hsva(10, 20, 30, 40)" << QColor::fromHsv(10, 20, 30, 40); + // the percent and float values are well chosen to not get in trouble due to rounding errors + QTest::newRow("hsva-percent") << "color: hsva(100%, 20%, 40%, 60%)" << QColor::fromHsv(359, 51, 102, 153); + QTest::newRow("hsva-float") << "color: hsva(180, 20%, 40%, 0.6)" << QColor::fromHsvF(0.5, 0.2, 0.4, 0.6); + QTest::newRow("hsl") << "color: hsl(60, 100%, 50%)" << QColor::fromHsl(60., 255, 127); + QTest::newRow("hsla") << "color: hsla(240, 255, 127, 192)" << QColor::fromHsl(240, 255, 127, 192); + QTest::newRow("hsla-percent") << "color: hsla(100%, 80%, 40%, 0%)" << QColor::fromHsl(359, 204, 102, 0); + QTest::newRow("hsla-float") << "color: hsla(252, 40%, 60%, 0.2)" << QColor::fromHslF(0.7, 0.4, 0.6, 0.2); QTest::newRow("invalid1") << "color: rgb(why, does, it, always, rain, on, me)" << QColor(); QTest::newRow("invalid2") << "color: rgba(i, meant, norway)" << QColor(); QTest::newRow("invalid3") << "color: rgb(21)" << QColor(); + QTest::newRow("invalid4") << "color: rgbx(1, 2, 3)" << QColor(); + QTest::newRow("invalid5") << "color: rgbax(1, 2, 3, 4)" << QColor(); + QTest::newRow("invalid6") << "color: hsv(360, 0, 0)" << QColor(); + QTest::newRow("invalid7") << "color: hsla(1, a, 1, 21)" << QColor(); QTest::newRow("role") << "color: palette(base)" << qApp->palette().color(QPalette::Base); QTest::newRow("role2") << "color: palette( window-text ) " << qApp->palette().color(QPalette::WindowText); QTest::newRow("transparent") << "color: transparent" << QColor(Qt::transparent); + + // ### Qt6: no longer valid + QTest::newRow("rgb-invalid") << "color: rgb(10, 20, 30, 40)" << QColor(10, 20, 30, 40); + QTest::newRow("rgba-invalid") << "color: rgba(10, 20, 30)" << QColor(10, 20, 30, 255); } void tst_QCssParser::colorValue() diff --git a/tests/auto/gui/text/qfont/qfont.pro b/tests/auto/gui/text/qfont/qfont.pro index 048d952faf..96cd4cfdab 100644 --- a/tests/auto/gui/text/qfont/qfont.pro +++ b/tests/auto/gui/text/qfont/qfont.pro @@ -4,3 +4,4 @@ QT += testlib QT += core-private gui-private qtHaveModule(widgets): QT += widgets SOURCES += tst_qfont.cpp +RESOURCES += testfont.qrc diff --git a/tests/auto/gui/text/qfont/testfont.qrc b/tests/auto/gui/text/qfont/testfont.qrc new file mode 100644 index 0000000000..cf51e4a2b4 --- /dev/null +++ b/tests/auto/gui/text/qfont/testfont.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/"> + <file>weirdfont.otf</file> + </qresource> +</RCC> diff --git a/tests/auto/gui/text/qfont/tst_qfont.cpp b/tests/auto/gui/text/qfont/tst_qfont.cpp index 8090f38a2c..9acf877790 100644 --- a/tests/auto/gui/text/qfont/tst_qfont.cpp +++ b/tests/auto/gui/text/qfont/tst_qfont.cpp @@ -66,6 +66,12 @@ private slots: void fromStringWithoutStyleName(); void sharing(); + void familyNameWithCommaQuote_data(); + void familyNameWithCommaQuote(); + void setFamilies_data(); + void setFamilies(); + void setFamiliesAndFamily_data(); + void setFamiliesAndFamily(); }; // Testing get/set functions @@ -116,6 +122,14 @@ void tst_QFont::exactMatch() QVERIFY(!QFont("sans-serif").exactMatch()); QVERIFY(!QFont("serif").exactMatch()); QVERIFY(!QFont("monospace").exactMatch()); + + font.setFamilies(QStringList() << "BogusFont"); + QVERIFY(!font.exactMatch()); + QVERIFY(!QFont("sans").exactMatch()); + QVERIFY(!QFont("sans-serif").exactMatch()); + QVERIFY(!QFont("serif").exactMatch()); + QVERIFY(!QFont("monospace").exactMatch()); + } void tst_QFont::italicOblique() @@ -277,6 +291,12 @@ void tst_QFont::resolve() QCOMPARE(f4.pointSize(), 45); f4 = f4.resolve(f3); QCOMPARE(f4.pointSize(), 55); + + QFont font5, font6; + const QStringList fontFamilies = { QStringLiteral("Arial") }; + font5.setFamilies(fontFamilies); + font6 = font6.resolve(font5); + QCOMPARE(font6.families(), fontFamilies); } #ifndef QT_NO_WIDGETS @@ -624,5 +644,108 @@ void tst_QFont::sharing() QVERIFY(QFontPrivate::get(f2)->engineData != QFontPrivate::get(f)->engineData); } +void tst_QFont::familyNameWithCommaQuote_data() +{ + QTest::addColumn<QString>("familyName"); + QTest::addColumn<QString>("chosenFamilyName"); + + const QString standardFont(QFont().defaultFamily()); + if (standardFont.isEmpty()) + QSKIP("No default font available on the system"); + const QString weirdFont(QLatin1String("'My, weird'' font name',")); + const QString commaSeparated(standardFont + QLatin1String(",Times New Roman")); + const QString commaSeparatedWeird(weirdFont + QLatin1String(",") + standardFont); + const QString commaSeparatedBogus(QLatin1String("BogusFont,") + standardFont); + + QTest::newRow("standard") << standardFont << standardFont; + QTest::newRow("weird") << weirdFont << weirdFont; + QTest::newRow("commaSeparated") << commaSeparated << standardFont; + QTest::newRow("commaSeparatedWeird") << commaSeparatedWeird << weirdFont; + QTest::newRow("commaSeparatedBogus") << commaSeparatedBogus << standardFont; +} + +void tst_QFont::familyNameWithCommaQuote() +{ + QFETCH(QString, familyName); + QFETCH(QString, chosenFamilyName); + + const int weirdFontId = QFontDatabase::addApplicationFont(":/weirdfont.otf"); + + QVERIFY(weirdFontId != -1); + QFont f(familyName); + QCOMPARE(f.family(), familyName); + QCOMPARE(QFontInfo(f).family(), chosenFamilyName); + + QFontDatabase::removeApplicationFont(weirdFontId); +} + +void tst_QFont::setFamilies_data() +{ + QTest::addColumn<QStringList>("families"); + QTest::addColumn<QString>("chosenFamilyName"); + + const QString weirdFont(QLatin1String("'My, weird'' font name',")); + const QString standardFont(QFont().defaultFamily()); + if (standardFont.isEmpty()) + QSKIP("No default font available on the system"); + + QTest::newRow("standard") << (QStringList() << standardFont) << standardFont; + QTest::newRow("weird") << (QStringList() << weirdFont) << weirdFont; + QTest::newRow("standard-weird") << (QStringList() << standardFont << weirdFont) << standardFont; + QTest::newRow("weird-standard") << (QStringList() << weirdFont << standardFont) << weirdFont; + QTest::newRow("nonexist-weird") << (QStringList() << "NonExistentFont" << weirdFont) << weirdFont; +} + +void tst_QFont::setFamilies() +{ + QFETCH(QStringList, families); + QFETCH(QString, chosenFamilyName); + + const int weirdFontId = QFontDatabase::addApplicationFont(":/weirdfont.otf"); + + QVERIFY(weirdFontId != -1); + QFont f; + f.setFamilies(families); + QCOMPARE(QFontInfo(f).family(), chosenFamilyName); + + QFontDatabase::removeApplicationFont(weirdFontId); +} + +void tst_QFont::setFamiliesAndFamily_data() +{ + QTest::addColumn<QStringList>("families"); + QTest::addColumn<QString>("family"); + QTest::addColumn<QString>("chosenFamilyName"); + + const QString weirdFont(QLatin1String("'My, weird'' font name',")); + const QString defaultFont(QFont().defaultFamily()); + if (defaultFont.isEmpty()) + QSKIP("No default font available on the system"); + + const QString timesFont(QLatin1String("Times")); + const QString nonExistFont(QLatin1String("NonExistentFont")); + + QTest::newRow("firstInFamilies") << (QStringList() << defaultFont << timesFont) << weirdFont << defaultFont; + QTest::newRow("secondInFamilies") << (QStringList() << nonExistFont << weirdFont) << defaultFont << weirdFont; + QTest::newRow("family") << (QStringList() << nonExistFont) << defaultFont << defaultFont; +} + +void tst_QFont::setFamiliesAndFamily() +{ + QFETCH(QStringList, families); + QFETCH(QString, family); + QFETCH(QString, chosenFamilyName); + + const int weirdFontId = QFontDatabase::addApplicationFont(":/weirdfont.otf"); + + QVERIFY(weirdFontId != -1); + QFont f; + f.setFamilies(families); + f.setFamily(family); + QCOMPARE(QFontInfo(f).family(), chosenFamilyName); + + QFontDatabase::removeApplicationFont(weirdFontId); +} + QTEST_MAIN(tst_QFont) #include "tst_qfont.moc" diff --git a/tests/auto/gui/text/qfont/weirdfont.otf b/tests/auto/gui/text/qfont/weirdfont.otf Binary files differnew file mode 100644 index 0000000000..b91c559f5b --- /dev/null +++ b/tests/auto/gui/text/qfont/weirdfont.otf diff --git a/tests/auto/gui/text/qfontcache/tst_qfontcache.cpp b/tests/auto/gui/text/qfontcache/tst_qfontcache.cpp index fbca313ea3..785cc3fef2 100644 --- a/tests/auto/gui/text/qfontcache/tst_qfontcache.cpp +++ b/tests/auto/gui/text/qfontcache/tst_qfontcache.cpp @@ -45,6 +45,8 @@ public: private slots: void engineData_data(); void engineData(); + void engineDataFamilies_data(); + void engineDataFamilies(); void clear(); }; @@ -109,6 +111,49 @@ void tst_QFontCache::engineData() QCOMPARE(engineData, QFontPrivate::get(f)->engineData); } +void tst_QFontCache::engineDataFamilies_data() +{ + QTest::addColumn<QStringList>("families"); + + const QStringList multiple = { QLatin1String("invalid"), QLatin1String("Times New Roman") }; + const QStringList multipleQuotes = { QLatin1String("'invalid'"), QLatin1String("Times New Roman") }; + const QStringList multiple2 = { QLatin1String("invalid"), QLatin1String("Times New Roman"), + QLatin1String("foobar"), QLatin1String("'baz'") }; + + QTest::newRow("unquoted-family-name") << QStringList(QLatin1String("Times New Roman")); + QTest::newRow("quoted-family-name") << QStringList(QLatin1String("Times New Roman")); + QTest::newRow("invalid") << QStringList(QLatin1String("invalid")); + QTest::newRow("multiple") << multiple; + QTest::newRow("multiple spaces quotes") << multipleQuotes; + QTest::newRow("multiple2") << multiple2; +} + +void tst_QFontCache::engineDataFamilies() +{ + QFETCH(QStringList, families); + + QFont f; + f.setFamily(QString()); // Unset the family as taken from the QGuiApplication default + f.setFamilies(families); + f.exactMatch(); // loads engine + QFontPrivate *d = QFontPrivate::get(f); + + QFontDef req = d->request; + // copy-pasted from QFontDatabase::load(), to engineer the cache key + if (req.pixelSize == -1) { + req.pixelSize = std::floor(((req.pointSize * d->dpi) / 72) * 100 + 0.5) / 100; + req.pixelSize = qRound(req.pixelSize); + } + if (req.pointSize < 0) + req.pointSize = req.pixelSize*72.0/d->dpi; + + req.families = families; + + QFontEngineData *engineData = QFontCache::instance()->findEngineData(req); + + QCOMPARE(engineData, QFontPrivate::get(f)->engineData); +} + void tst_QFontCache::clear() { #ifdef QT_BUILD_INTERNAL diff --git a/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp b/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp index b7f014d0e2..1429e4cb7f 100644 --- a/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp +++ b/tests/auto/gui/text/qglyphrun/tst_qglyphrun.cpp @@ -491,10 +491,6 @@ void tst_QGlyphRun::drawMultiScriptText2() drawGlyphs.save("drawMultiScriptText2_drawGlyphIndexes.png"); #endif -#ifdef Q_OS_OSX - if (drawGlyphs.toImage() != textLayoutDraw.toImage()) - QEXPECT_FAIL("", "See QTBUG-32690", Continue); -#endif // Q_OS_OSX QCOMPARE(drawGlyphs, textLayoutDraw); } diff --git a/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp b/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp index 3e354b7523..08f7cf4fb2 100644 --- a/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp +++ b/tests/auto/gui/text/qtextdocumentfragment/tst_qtextdocumentfragment.cpp @@ -159,6 +159,7 @@ private slots: void nonZeroMarginOnImport(); void html_charFormatPropertiesUnset(); void html_headings(); + void html_quotedFontFamily_data(); void html_quotedFontFamily(); void html_spanBackgroundColor(); void defaultFont(); @@ -2184,23 +2185,45 @@ void tst_QTextDocumentFragment::html_headings() QCOMPARE(doc->blockCount(), 2); } -void tst_QTextDocumentFragment::html_quotedFontFamily() +void tst_QTextDocumentFragment::html_quotedFontFamily_data() { - setHtml("<div style=\"font-family: 'Foo Bar';\">Test</div>"); - QCOMPARE(doc->begin().begin().fragment().charFormat().fontFamily(), QString("Foo Bar")); - - setHtml("<div style='font-family: \"Foo Bar\";'>Test</div>"); - QCOMPARE(doc->begin().begin().fragment().charFormat().fontFamily(), QString("Foo Bar")); - - setHtml("<div style='font-family: \"Foo Bar\";'>Test</div>"); - QCOMPARE(doc->begin().begin().fragment().charFormat().fontFamily(), QString("Foo Bar")); - - setHtml("<div style='font-family: Foo\n Bar;'>Test</div>"); - QCOMPARE(doc->begin().begin().fragment().charFormat().fontFamily(), QString("Foo Bar")); + QTest::addColumn<QString>("html"); + QTest::addColumn<QString>("fontFamily"); + QTest::addColumn<QStringList>("fontFamilies"); + + const QString fooFamily = QLatin1String("Foo Bar"); + const QString weirdFamily = QLatin1String("'Weird, & font '' name',"); + + QTest::newRow("data1") << QString("<div style=\"font-family: 'Foo Bar';\">Test</div>") + << fooFamily << QStringList(fooFamily); + QTest::newRow("data2") << QString("<div style='font-family: \"Foo Bar\";'>Test</div>") + << QString("Foo Bar") << QStringList("Foo Bar"); + QTest::newRow("data3") << QString("<div style='font-family: Foo\n Bar;'>Test</div>") + << fooFamily << QStringList(fooFamily); + QTest::newRow("data4") << QString("<div style='font-family: Foo\n Bar, serif, \"bar foo\";'>Test" + "</div>") + << fooFamily << (QStringList() << "Foo Bar" << "serif" << "bar foo"); + QTest::newRow("data5") << QString("<div style='font-family: \"\\'Weird, & font \\'\\' name\\'," + "\";'>Test</div>") + << weirdFamily << QStringList(weirdFamily); + QTest::newRow("data6") << QString("<div style='font-family: \"\\'Weird, & font \\'\\' name\\'," + "\";'>Test</div>") + << weirdFamily << QStringList(weirdFamily); + QTest::newRow("data7") << QString("<div style='font-family: \"\\'Weird, & font \\'\\' name\\',\", " + "serif, \"bar foo\";'>Test</div>") + << weirdFamily + << (QStringList() << weirdFamily << "serif" << "bar foo"); +} - setHtml("<div style='font-family: Foo\n Bar, serif, \"bar foo\";'>Test</div>"); - QCOMPARE(doc->begin().begin().fragment().charFormat().fontFamily(), QString("Foo Bar,serif,bar foo")); +void tst_QTextDocumentFragment::html_quotedFontFamily() +{ + QFETCH(QString, html); + QFETCH(QString, fontFamily); + QFETCH(QStringList, fontFamilies); + setHtml(html); + QCOMPARE(doc->begin().begin().fragment().charFormat().fontFamily(), fontFamily); + QCOMPARE(doc->begin().begin().fragment().charFormat().font().families(), fontFamilies); } void tst_QTextDocumentFragment::defaultFont() diff --git a/tests/auto/network-settings.h b/tests/auto/network-settings.h index a3c318420f..4225ff11c7 100644 --- a/tests/auto/network-settings.h +++ b/tests/auto/network-settings.h @@ -176,7 +176,7 @@ public: static QString ftpServerName() { -#ifdef QT_TEST_SERVER +#ifdef QT_TEST_SERVER_NAME return QString("vsftpd.") % serverDomainName(); #else return serverName(); @@ -184,7 +184,7 @@ public: } static QString ftpProxyServerName() { -#ifdef QT_TEST_SERVER +#ifdef QT_TEST_SERVER_NAME return QString("ftp-proxy.") % serverDomainName(); #else return serverName(); @@ -192,7 +192,7 @@ public: } static QString httpServerName() { -#ifdef QT_TEST_SERVER +#ifdef QT_TEST_SERVER_NAME return QString("apache2.") % serverDomainName(); #else return serverName(); @@ -200,7 +200,7 @@ public: } static QString httpProxyServerName() { -#ifdef QT_TEST_SERVER +#ifdef QT_TEST_SERVER_NAME return QString("squid.") % serverDomainName(); #else return serverName(); @@ -208,7 +208,7 @@ public: } static QString socksProxyServerName() { -#ifdef QT_TEST_SERVER +#ifdef QT_TEST_SERVER_NAME return QString("danted.") % serverDomainName(); #else return serverName(); diff --git a/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp b/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp index 8b49679042..6c3443a735 100644 --- a/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp +++ b/tests/auto/network/access/qnetworkcookiejar/tst_qnetworkcookiejar.cpp @@ -35,7 +35,9 @@ #include <QtNetwork/QNetworkCookieJar> #include <QtNetwork/QNetworkCookie> #include <QtNetwork/QNetworkRequest> +#if QT_CONFIG(topleveldomain) #include "private/qtldurl_p.h" +#endif class tst_QNetworkCookieJar: public QObject { @@ -47,7 +49,7 @@ private slots: void setCookiesFromUrl(); void cookiesForUrl_data(); void cookiesForUrl(); -#ifdef QT_BUILD_INTERNAL +#if defined(QT_BUILD_INTERNAL) && QT_CONFIG(topleveldomain) void effectiveTLDs_data(); void effectiveTLDs(); #endif @@ -398,7 +400,7 @@ void tst_QNetworkCookieJar::cookiesForUrl() } // This test requires private API. -#ifdef QT_BUILD_INTERNAL +#if defined(QT_BUILD_INTERNAL) && QT_CONFIG(topleveldomain) void tst_QNetworkCookieJar::effectiveTLDs_data() { QTest::addColumn<QString>("domain"); diff --git a/tests/auto/network/ssl/qsslkey/keys/dh-pri-1024.der b/tests/auto/network/ssl/qsslkey/keys/dh-pri-1024.der Binary files differnew file mode 100644 index 0000000000..687009e087 --- /dev/null +++ b/tests/auto/network/ssl/qsslkey/keys/dh-pri-1024.der diff --git a/tests/auto/network/ssl/qsslkey/keys/dh-pri-1024.pem b/tests/auto/network/ssl/qsslkey/keys/dh-pri-1024.pem new file mode 100644 index 0000000000..233e0dfb37 --- /dev/null +++ b/tests/auto/network/ssl/qsslkey/keys/dh-pri-1024.pem @@ -0,0 +1,9 @@ +-----BEGIN PRIVATE KEY----- +MIIBIQIBADCBlQYJKoZIhvcNAQMBMIGHAoGBAIlk2YX0TJzfQ18ZzZroQoE5Nyjt +bWxWRxBriG/c+JWhBwttVDb6lzLN+GVJxXVPfc6JJmDORVRxdxAlMqu++2Vqpsnl +/H8xIXsxjuTcTjq8sXagGRa0LfeggkUD64tEhO4iZ8Q2TIdb3OHkAF0Sn+06b/0e +iIz323Kywq0CsspTAgECBIGDAoGAQCo39UHP4s2ZVH4nOmWgNlb4JsHPX4EzqDBr +ig46hvMLAFrILYnsCbqqD/+GNAUl1PV/nfEQoAk/HvtACqLFLG5/3jK2w6dVHGEo +JnVOGz9vZpWUx+SCslHJRFaeE+6AAbbvrTr0lci29Ta4IesHlamRsj+ZaUrVX6k/ +/9OTGAo= +-----END PRIVATE KEY----- diff --git a/tests/auto/network/ssl/qsslkey/keys/dh-pri-2048.der b/tests/auto/network/ssl/qsslkey/keys/dh-pri-2048.der Binary files differnew file mode 100644 index 0000000000..e193f25f07 --- /dev/null +++ b/tests/auto/network/ssl/qsslkey/keys/dh-pri-2048.der diff --git a/tests/auto/network/ssl/qsslkey/keys/dh-pri-2048.pem b/tests/auto/network/ssl/qsslkey/keys/dh-pri-2048.pem new file mode 100644 index 0000000000..32299b2b6c --- /dev/null +++ b/tests/auto/network/ssl/qsslkey/keys/dh-pri-2048.pem @@ -0,0 +1,14 @@ +-----BEGIN PRIVATE KEY----- +MIICJgIBADCCARcGCSqGSIb3DQEDATCCAQgCggEBAJsiReJxBjkC7Hy99AJATusq +YsNQHhjoeTLPeHhsBuLtJK18Krk736V09efX6qeAEmvgMQbvbHqtrOaY3q6dut6C +UTGVW+oVg3d/Y8qakkanvEnIlliaTIyWIz0JMjO2prC6AuU/QEzZcQVUS6bxyn3D +iYFxCE6+7cJJpEH9HVbcrl+J6Ch6ax5rQGUyxpSMkmItLJx92upRxOnaxJMHR+ZF +OSdDPfrkINpEzahnhteLszddyLasnE0or6ZnXYLvKsT1Uu6QwDc4EO1FJHScoeep +zsK/VRcXzMpj/1Rl+F9E/AikCqHRrnvISt25wrK0Mwy854P2T7dJlBNewc6vE6MC +AQIEggEEAoIBAGIctO30MoZ9DiuKbOBpqM9rl2bNH/I46GGcfEiSsO/zOw2V9WFC +MxkjF0I1ilDfPY+Ag3bLB2n89DPcfXliYH9MFolehPTc1fWplhX3+ImdC6y95uXO +FV5xtcEQCbPktnUtkUdcAT5831p9lu1QJo+DzMPrQa7axMLj8heBAi4VqAi+8Q31 +dpGKuhCUlgs+pLENx1o0QY2kui6Z5uR0YhmA547lwBWA4XEv5OV9ExmxytiatvOv +PZKT1ID76LrL9bnnZvOEGczWLQvJ9VaaZSpoP+2QisRANWW4w57d+PIR1WR/FTSH +F6xocElUoTzuiSPzRz60aw/KkisImBBKERQ= +-----END PRIVATE KEY----- diff --git a/tests/auto/network/ssl/qsslkey/keys/dh-pri-512.der b/tests/auto/network/ssl/qsslkey/keys/dh-pri-512.der Binary files differnew file mode 100644 index 0000000000..42ddbaaae2 --- /dev/null +++ b/tests/auto/network/ssl/qsslkey/keys/dh-pri-512.der diff --git a/tests/auto/network/ssl/qsslkey/keys/dh-pri-512.pem b/tests/auto/network/ssl/qsslkey/keys/dh-pri-512.pem new file mode 100644 index 0000000000..d2c3170b16 --- /dev/null +++ b/tests/auto/network/ssl/qsslkey/keys/dh-pri-512.pem @@ -0,0 +1,6 @@ +-----BEGIN PRIVATE KEY----- +MIGcAgEAMFMGCSqGSIb3DQEDATBGAkEAvXx0QxJvIGA2ig8Je55R2rmeO4Ta2Esj +ANLuyVIFRbtuLFsdhU+amUc8bs9RUQmkUNzS92jkpAfqtCv+mQ06EwIBAgRCAkBJ +rDM0BTevOPIHpJzMtSQhw3e7Dr38HUfTn8zF3uYi1RCxjkTUukmzRLPTf0aqPgpd +8dSldjG/11aZORl8/mXO +-----END PRIVATE KEY----- diff --git a/tests/auto/network/ssl/qsslkey/keys/dh-pub-1024.der b/tests/auto/network/ssl/qsslkey/keys/dh-pub-1024.der Binary files differnew file mode 100644 index 0000000000..2805a67633 --- /dev/null +++ b/tests/auto/network/ssl/qsslkey/keys/dh-pub-1024.der diff --git a/tests/auto/network/ssl/qsslkey/keys/dh-pub-1024.pem b/tests/auto/network/ssl/qsslkey/keys/dh-pub-1024.pem new file mode 100644 index 0000000000..da4e327ac9 --- /dev/null +++ b/tests/auto/network/ssl/qsslkey/keys/dh-pub-1024.pem @@ -0,0 +1,9 @@ +-----BEGIN PUBLIC KEY----- +MIIBHzCBlQYJKoZIhvcNAQMBMIGHAoGBAIlk2YX0TJzfQ18ZzZroQoE5NyjtbWxW +RxBriG/c+JWhBwttVDb6lzLN+GVJxXVPfc6JJmDORVRxdxAlMqu++2Vqpsnl/H8x +IXsxjuTcTjq8sXagGRa0LfeggkUD64tEhO4iZ8Q2TIdb3OHkAF0Sn+06b/0eiIz3 +23Kywq0CsspTAgECA4GEAAKBgA8pxU1sMDvRWKpvJKNs3jNhZPQWFf4Tszu/cMcb +1qAQ/q0DRb41VvsUoMaCfef/plZleV4MG26owb574AJeC86wX5MbRDTPS4CzAn+I +an92AZl3vlYRQ2sSo3ktkyhw6LV1iewi08Ky7J4rqvG0Oo335QGEZlK1OgwBsyh0 +FKLe +-----END PUBLIC KEY----- diff --git a/tests/auto/network/ssl/qsslkey/keys/dh-pub-2048.der b/tests/auto/network/ssl/qsslkey/keys/dh-pub-2048.der Binary files differnew file mode 100644 index 0000000000..9e749d8a41 --- /dev/null +++ b/tests/auto/network/ssl/qsslkey/keys/dh-pub-2048.der diff --git a/tests/auto/network/ssl/qsslkey/keys/dh-pub-2048.pem b/tests/auto/network/ssl/qsslkey/keys/dh-pub-2048.pem new file mode 100644 index 0000000000..f751157c87 --- /dev/null +++ b/tests/auto/network/ssl/qsslkey/keys/dh-pub-2048.pem @@ -0,0 +1,14 @@ +-----BEGIN PUBLIC KEY----- +MIICJDCCARcGCSqGSIb3DQEDATCCAQgCggEBAJsiReJxBjkC7Hy99AJATusqYsNQ +HhjoeTLPeHhsBuLtJK18Krk736V09efX6qeAEmvgMQbvbHqtrOaY3q6dut6CUTGV +W+oVg3d/Y8qakkanvEnIlliaTIyWIz0JMjO2prC6AuU/QEzZcQVUS6bxyn3DiYFx +CE6+7cJJpEH9HVbcrl+J6Ch6ax5rQGUyxpSMkmItLJx92upRxOnaxJMHR+ZFOSdD +PfrkINpEzahnhteLszddyLasnE0or6ZnXYLvKsT1Uu6QwDc4EO1FJHScoeepzsK/ +VRcXzMpj/1Rl+F9E/AikCqHRrnvISt25wrK0Mwy854P2T7dJlBNewc6vE6MCAQID +ggEFAAKCAQAUeWRuqjl7F84USogxJOM1M4y8yKtBYY2KLs5iIVhzV4UZ+9+cMNZA +otLXJ/e8BH0diR0yk7tjxD6hjjqd+nyafIkJGPElDMnTbRPHg5zZYMmI5L/efdSm +OPbM7QsodrYH5aoF4c7hjMb/cttYVG2Yupsy4tfORuDbwL70upqOo6rkVq55eOGS +6pseEume/SD+7e3xIPJTkrMMzBFHG6H7bVHikT4O7yWV1iVzElj919yi+4Zy6TK8 +0hG6l31D5bsJpOduhHYZtN1yQpw+sGT6Yiepkjgt+1YkGFiiRs5vDl4DHeYHyAhL +oH9uKcm3q4lhaOeT5ml765g87qQD6+vr +-----END PUBLIC KEY----- diff --git a/tests/auto/network/ssl/qsslkey/keys/dh-pub-512.der b/tests/auto/network/ssl/qsslkey/keys/dh-pub-512.der Binary files differnew file mode 100644 index 0000000000..8a75babb6d --- /dev/null +++ b/tests/auto/network/ssl/qsslkey/keys/dh-pub-512.der diff --git a/tests/auto/network/ssl/qsslkey/keys/dh-pub-512.pem b/tests/auto/network/ssl/qsslkey/keys/dh-pub-512.pem new file mode 100644 index 0000000000..1f4e5c9a47 --- /dev/null +++ b/tests/auto/network/ssl/qsslkey/keys/dh-pub-512.pem @@ -0,0 +1,6 @@ +-----BEGIN PUBLIC KEY----- +MIGaMFMGCSqGSIb3DQEDATBGAkEAvXx0QxJvIGA2ig8Je55R2rmeO4Ta2EsjANLu +yVIFRbtuLFsdhU+amUc8bs9RUQmkUNzS92jkpAfqtCv+mQ06EwIBAgNDAAJARGBh +9FmRRZZAxBtXZmS8wIgDwWvjB63GQ+E1pDLtZPztvPQ2eqUjTgSuGKV5cDankAV1 +Pkj/IA0Xl+SuFhLLew== +-----END PUBLIC KEY----- diff --git a/tests/auto/network/ssl/qsslkey/keys/genkeys.sh b/tests/auto/network/ssl/qsslkey/keys/genkeys.sh index 6210b42ab4..0106953bff 100755 --- a/tests/auto/network/ssl/qsslkey/keys/genkeys.sh +++ b/tests/auto/network/ssl/qsslkey/keys/genkeys.sh @@ -88,6 +88,27 @@ do openssl ec -in ec-pri-$size-$curve.pem -pubout -out ec-pub-$size-$curve.der -outform DER done +#--- DH ---------------------------------------------------------------------------- +for size in 512 1024 2048 +do + echo -e "\ngenerating DH parameters to PEM file ..." + openssl dhparam -out dhpar-$size.pem $size + + echo -e "\ngenerating DH private key to PEM file ..." + openssl genpkey -paramfile dhpar-$size.pem -out dh-pri-$size.pem + + /bin/rm dhpar-$size.pem + + echo -e "\ngenerating DH private key to DER file ..." + openssl pkey -in dh-pri-$size.pem -out dh-pri-$size.der -outform DER + + echo -e "\ngenerating DH public key to PEM file ..." + openssl pkey -in dh-pri-$size.pem -pubout -out dh-pub-$size.pem + + echo -e "\ngenerating DH public key to DER file ..." + openssl pkey -in dh-pri-$size.pem -pubout -out dh-pub-$size.der -outform DER +done + #--- PKCS#8 ------------------------------------------------------------------------ # Note: We'll just grab some of the keys generated earlier and convert those # https://www.openssl.org/docs/manmaster/man1/pkcs8.html#PKCS-5-v1.5-and-PKCS-12-algorithms diff --git a/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp b/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp index ddfe52c5e4..70001f7375 100644 --- a/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp +++ b/tests/auto/network/ssl/qsslkey/tst_qsslkey.cpp @@ -63,7 +63,7 @@ class tst_QSslKey : public QObject QList<KeyInfo> keyInfoList; - void createPlainTestRows(bool filter = false, QSsl::EncodingFormat format = QSsl::EncodingFormat::Pem); + void createPlainTestRows(bool pemOnly = false); public slots: void initTestCase(); @@ -111,13 +111,14 @@ void tst_QSslKey::initTestCase() QDir dir(testDataDir + "keys"); const QFileInfoList fileInfoList = dir.entryInfoList(QDir::Files | QDir::Readable); - QRegExp rx(QLatin1String("^(rsa|dsa|ec)-(pub|pri)-(\\d+)-?[\\w-]*\\.(pem|der)$")); + QRegExp rx(QLatin1String("^(rsa|dsa|dh|ec)-(pub|pri)-(\\d+)-?[\\w-]*\\.(pem|der)$")); for (const QFileInfo &fileInfo : fileInfoList) { if (rx.indexIn(fileInfo.fileName()) >= 0) { keyInfoList << KeyInfo( fileInfo, rx.cap(1) == QLatin1String("rsa") ? QSsl::Rsa : - (rx.cap(1) == QLatin1String("dsa") ? QSsl::Dsa : QSsl::Ec), + rx.cap(1) == QLatin1String("dsa") ? QSsl::Dsa : + rx.cap(1) == QLatin1String("dh") ? QSsl::Dh : QSsl::Ec, rx.cap(2) == QLatin1String("pub") ? QSsl::PublicKey : QSsl::PrivateKey, rx.cap(3).toInt(), rx.cap(4) == QLatin1String("pem") ? QSsl::Pem : QSsl::Der); @@ -154,7 +155,7 @@ Q_DECLARE_METATYPE(QSsl::KeyAlgorithm) Q_DECLARE_METATYPE(QSsl::KeyType) Q_DECLARE_METATYPE(QSsl::EncodingFormat) -void tst_QSslKey::createPlainTestRows(bool filter, QSsl::EncodingFormat format) +void tst_QSslKey::createPlainTestRows(bool pemOnly) { QTest::addColumn<QString>("absFilePath"); QTest::addColumn<QSsl::KeyAlgorithm>("algorithm"); @@ -162,7 +163,7 @@ void tst_QSslKey::createPlainTestRows(bool filter, QSsl::EncodingFormat format) QTest::addColumn<int>("length"); QTest::addColumn<QSsl::EncodingFormat>("format"); foreach (KeyInfo keyInfo, keyInfoList) { - if (filter && keyInfo.format != format) + if (pemOnly && keyInfo.format != QSsl::EncodingFormat::Pem) continue; #ifdef Q_OS_WINRT if (keyInfo.fileInfo.fileName().contains("RC2-64")) diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp index bca142e245..3e55278b4f 100644 --- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp @@ -1389,10 +1389,10 @@ void tst_QSslSocket::protocolServerSide() if (server.socket) QVERIFY(server.socket->error() == QAbstractSocket::UnknownSocketError); - QCOMPARE(int(client.state()), int(expectedState)); + QCOMPARE(client.state(), expectedState); } else if (server.socket->error() != QAbstractSocket::UnknownSocketError) { QVERIFY(client.error() == QAbstractSocket::UnknownSocketError); - QCOMPARE(int(server.socket->state()), int(expectedState)); + QCOMPARE(server.socket->state(), expectedState); } QCOMPARE(client.isEncrypted(), works); @@ -3316,10 +3316,10 @@ void tst_QSslSocket::verifyClientCertificate_data() validCerts += QSslCertificate::fromPath(testDataDir + "certs/bogus-ca.crt"); QCOMPARE(validCerts.size(), 2); - QTest::newRow("ValidClientCert:AutoVerifyPeer") << QSslSocket::AutoVerifyPeer << validCerts << validKey << true; - QTest::newRow("ValidClientCert:QueryPeer") << QSslSocket::QueryPeer << validCerts << validKey << true; - QTest::newRow("ValidClientCert:VerifyNone") << QSslSocket::VerifyNone << validCerts << validKey << true; - QTest::newRow("ValidClientCert:VerifyPeer") << QSslSocket::VerifyPeer << validCerts << validKey << true; + QTest::newRow("ValidChainedClientCert:AutoVerifyPeer") << QSslSocket::AutoVerifyPeer << validCerts << validKey << true; + QTest::newRow("ValidChainedClientCert:QueryPeer") << QSslSocket::QueryPeer << validCerts << validKey << true; + QTest::newRow("ValidChainedClientCert:VerifyNone") << QSslSocket::VerifyNone << validCerts << validKey << true; + QTest::newRow("ValidChainedClientCert:VerifyPeer") << QSslSocket::VerifyPeer << validCerts << validKey << true; } void tst_QSslSocket::verifyClientCertificate() @@ -3375,7 +3375,7 @@ void tst_QSslSocket::verifyClientCertificate() // check server socket QVERIFY(server.socket); - QCOMPARE(int(server.socket->state()), int(expectedState)); + QCOMPARE(server.socket->state(), expectedState); QCOMPARE(server.socket->isEncrypted(), works); if (peerVerifyMode == QSslSocket::VerifyNone || clientCerts.isEmpty()) { @@ -3387,7 +3387,7 @@ void tst_QSslSocket::verifyClientCertificate() } // check client socket - QCOMPARE(int(client.state()), int(expectedState)); + QCOMPARE(client.state(), expectedState); QCOMPARE(client.isEncrypted(), works); } diff --git a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp index 8cf43e243b..bdfa957083 100644 --- a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp +++ b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp @@ -199,6 +199,9 @@ private slots: void sqlite_openError(); + void sqlite_check_json1_data() { generic_data("QSQLITE"); } + void sqlite_check_json1(); + private: void createTestTables(QSqlDatabase db); void dropTestTables(QSqlDatabase db); @@ -2350,6 +2353,30 @@ void tst_QSqlDatabase::sqlite_openError() QCOMPARE(error.databaseText(), "unable to open database file"); } +void tst_QSqlDatabase::sqlite_check_json1() +{ + QFETCH(QString, dbName); + QSqlDatabase db = QSqlDatabase::database(dbName); + CHECK_DATABASE(db); + const QSqlDriver::DbmsType dbType = tst_Databases::getDatabaseType(db); + if (dbType != QSqlDriver::SQLite) + QSKIP("SQLite3 specific test"); + + QSqlQuery q(db); + const QString json1("{\"id\":1}"); + const QString tableName(qTableName("sqlite_check_json1", __FILE__, db)); + tst_Databases::safeDropTable(db, tableName); + QVERIFY_SQL(q, exec(QString("CREATE TABLE %1(text TEXT)").arg(tableName))); + QVERIFY_SQL(q, exec(QString("INSERT INTO %1 VALUES(json('%2'))").arg(tableName, json1))); + QVERIFY_SQL(q, prepare(QString("INSERT INTO %1 VALUES(?)").arg(tableName))); + q.addBindValue("json('{\"id\":2}')"); + QVERIFY_SQL(q, prepare(QString("SELECT * from %1 WHERE text = json('%2')").arg(tableName, json1))); + QVERIFY_SQL(q, exec()); + QVERIFY_SQL(q, next()); + QCOMPARE(q.value(0).toString(), json1); + QFAIL_SQL(q, next()); +} + void tst_QSqlDatabase::cloneDatabase() { QFETCH(QString, dbName); diff --git a/tests/auto/testlib/outformat/outformat.pro b/tests/auto/testlib/outformat/outformat.pro new file mode 100644 index 0000000000..ea02f3167f --- /dev/null +++ b/tests/auto/testlib/outformat/outformat.pro @@ -0,0 +1,7 @@ +CONFIG += testcase +QT = core testlib + +SOURCES += tst_outformat.cpp +TARGET = outformat + +include($$QT_SOURCE_TREE/src/testlib/selfcover.pri) diff --git a/tests/auto/testlib/outformat/tst_outformat.cpp b/tests/auto/testlib/outformat/tst_outformat.cpp new file mode 100644 index 0000000000..5d131159a9 --- /dev/null +++ b/tests/auto/testlib/outformat/tst_outformat.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2018 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> + +class tst_OutFormat : public QObject +{ + Q_OBJECT +private slots: + void toHex_data() const; + void toHex() const; + // other formats of interest ? +}; + +void tst_OutFormat::toHex_data() const +{ + QTest::addColumn<QByteArray>("raw"); + QTest::addColumn<QByteArray>("hex"); + + QTest::newRow("empty") << QByteArray("") << QByteArray(""); + QTest::newRow("long") + << QByteArray("Truncates in ellipsis when more than fifty characters long") + << QByteArray("54 72 75 6E 63 61 74 65 73 20 69 6E 20 65 6C 6C " + "69 70 73 69 73 20 77 68 65 6E 20 6D 6F 72 65 20 " + "74 68 61 6E 20 66 69 66 74 79 20 63 68 61 72 61 " + "63 74 ..."); + QTest::newRow("spaces") + << QByteArray(" \t\n\v\f\r") << QByteArray("20 09 0A 0B 0C 0D"); + QTest::newRow("ASCII-escapes") + << QByteArray("\a\b\\\"'\177") << QByteArray("07 08 5C 22 27 7F"); + // These are the ISO Latin-15 , pound, Euro, ..., y-umlaut + QTest::newRow("8-bit-sampler") + << QByteArray("\240\243\244\261\327\360\377") << QByteArray("A0 A3 A4 B1 D7 F0 FF"); +} + +void tst_OutFormat::toHex() const +{ + QFETCH(QByteArray, raw); + QFETCH(QByteArray, hex); + QScopedArrayPointer<char> repr(QTest::toHexRepresentation(raw.constData(), raw.size())); + QCOMPARE(repr.data(), hex); +} + +QTEST_APPLESS_MAIN(tst_OutFormat) + +#include "tst_outformat.moc" diff --git a/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp b/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp index 0593ae74bf..60aa350145 100644 --- a/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp +++ b/tests/auto/testlib/qabstractitemmodeltester/tst_qabstractitemmodeltester.cpp @@ -79,9 +79,9 @@ void tst_QAbstractItemModelTester::treeWidgetModel() root->removeChild(remove); QTreeWidgetItem *parent = new QTreeWidgetItem(&widget, QStringList("parent")); new QTreeWidgetItem(parent, QStringList("child")); - widget.setItemHidden(parent, true); + parent->setHidden(true); - widget.sortByColumn(0); + widget.sortByColumn(0, Qt::AscendingOrder); } void tst_QAbstractItemModelTester::standardItemModel() diff --git a/tests/auto/testlib/selftests/blacklisted/BLACKLIST b/tests/auto/testlib/selftests/blacklisted/BLACKLIST index 36b7699cbd..a923c11416 100644 --- a/tests/auto/testlib/selftests/blacklisted/BLACKLIST +++ b/tests/auto/testlib/selftests/blacklisted/BLACKLIST @@ -1,12 +1,20 @@ -[pass] +obscure # no such platform; is ignored * + +[pass] +!* + [skip] * + [fail] * -[xpass] -* + [xfail] * + +[xpass] +* + [messages] * diff --git a/tests/auto/testlib/selftests/blacklisted/tst_blacklisted.cpp b/tests/auto/testlib/selftests/blacklisted/tst_blacklisted.cpp index 8578752e22..90520385ec 100644 --- a/tests/auto/testlib/selftests/blacklisted/tst_blacklisted.cpp +++ b/tests/auto/testlib/selftests/blacklisted/tst_blacklisted.cpp @@ -45,7 +45,8 @@ private slots: void messages(); }; -// All the tests below have been blacklisted in blacklisted/BLACKLIST +// All the tests below except pass() have been blacklisted in blacklisted/BLACKLIST +// Contrast with ../silent/, for the same tests without blacklisting but with -silent void tst_Blacklisted::pass() { @@ -64,7 +65,7 @@ void tst_Blacklisted::fail() void tst_Blacklisted::xfail() { - QEXPECT_FAIL("", "This test should XFAIL then BFAIL", Abort); + QEXPECT_FAIL("", "This test should XFAIL then BPASS", Abort); QVERIFY(false); } diff --git a/tests/auto/testlib/selftests/expected_blacklisted.lightxml b/tests/auto/testlib/selftests/expected_blacklisted.lightxml index 4193628e7c..98d7a38ca9 100644 --- a/tests/auto/testlib/selftests/expected_blacklisted.lightxml +++ b/tests/auto/testlib/selftests/expected_blacklisted.lightxml @@ -25,7 +25,7 @@ </TestFunction> <TestFunction name="xfail"> <Incident type="xfail" file="qtbase/tests/auto/testlib/selftests/blacklisted/tst_blacklisted.cpp" line="0"> - <Description><![CDATA[This test should XFAIL then BFAIL]]></Description> + <Description><![CDATA[This test should XFAIL then BPASS]]></Description> </Incident> <Incident type="bpass" file="" line="0" /> <Duration msecs="0"/> diff --git a/tests/auto/testlib/selftests/expected_blacklisted.tap b/tests/auto/testlib/selftests/expected_blacklisted.tap new file mode 100644 index 0000000000..f26155ded0 --- /dev/null +++ b/tests/auto/testlib/selftests/expected_blacklisted.tap @@ -0,0 +1,43 @@ +TAP version 13 +# tst_Blacklisted +ok 1 - initTestCase() +ok 2 - pass() # TODO +ok 3 - skip() # SKIP This test should SKIP +not ok 4 - fail() # TODO 'false' returned FALSE. (This test should BFAIL) + --- + type: QVERIFY + message: This test should BFAIL + wanted: true (false) + found: false (false) + expected: true (false) + actual: false (false) + at: tst_Blacklisted::fail() (qtbase/tests/auto/testlib/selftests/blacklisted/tst_blacklisted.cpp:63) + file: qtbase/tests/auto/testlib/selftests/blacklisted/tst_blacklisted.cpp + line: 63 + ... +not ok 5 - xfail() # TODO This test should XFAIL then BPASS + --- + at: tst_Blacklisted::xfail() (qtbase/tests/auto/testlib/selftests/blacklisted/tst_blacklisted.cpp:69) + file: qtbase/tests/auto/testlib/selftests/blacklisted/tst_blacklisted.cpp + line: 69 + ... +ok 5 - xfail() # TODO +ok 6 - xpass() # TODO 'true' returned TRUE unexpectedly. (This test should XPASS, blacklist ignored for XPASS) +# This is a warning that should not appear in silent test output +# This is an internal testlib warning that should not appear in silent test output +# This is a debug message that should not appear in silent test output +# This is a critical message that should not appear in silent test output +# This is an info message that should not appear in silent test output +# This is an internal testlib info message that should not appear in silent test output +# This is a fatal error message that should still appear in silent test output +not ok 7 - messages() # TODO Received a fatal error. + --- + # Received a fatal error. + at: tst_Blacklisted::messages() (Unknown file:0) + file: Unknown file + line: 0 + ... +1..7 +# tests 7 +# pass 1 +# fail 1 diff --git a/tests/auto/testlib/selftests/expected_blacklisted.teamcity b/tests/auto/testlib/selftests/expected_blacklisted.teamcity index 8180a7ce76..df58208fb3 100644 --- a/tests/auto/testlib/selftests/expected_blacklisted.teamcity +++ b/tests/auto/testlib/selftests/expected_blacklisted.teamcity @@ -7,7 +7,7 @@ ##teamcity[testStarted name='fail()' flowId='tst_Blacklisted'] ##teamcity[testFinished name='fail()' flowId='tst_Blacklisted'] ##teamcity[testStarted name='xfail()' flowId='tst_Blacklisted'] -##teamcity[testStdOut name='xfail()' out='XFAIL |[Loc: qtbase/tests/auto/testlib/selftests/blacklisted/tst_blacklisted.cpp(0)|]: This test should XFAIL then BFAIL' flowId='tst_Blacklisted'] +##teamcity[testStdOut name='xfail()' out='XFAIL |[Loc: qtbase/tests/auto/testlib/selftests/blacklisted/tst_blacklisted.cpp(0)|]: This test should XFAIL then BPASS' flowId='tst_Blacklisted'] ##teamcity[testFinished name='xfail()' flowId='tst_Blacklisted'] ##teamcity[testStarted name='xpass()' flowId='tst_Blacklisted'] ##teamcity[testFailed name='xpass()' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/blacklisted/tst_blacklisted.cpp(0)|]' details='|'true|' returned TRUE unexpectedly. (This test should XPASS, blacklist ignored for XPASS)' flowId='tst_Blacklisted'] diff --git a/tests/auto/testlib/selftests/expected_blacklisted.txt b/tests/auto/testlib/selftests/expected_blacklisted.txt index 6fa2403b59..3cfe40eb12 100644 --- a/tests/auto/testlib/selftests/expected_blacklisted.txt +++ b/tests/auto/testlib/selftests/expected_blacklisted.txt @@ -6,7 +6,7 @@ SKIP : tst_Blacklisted::skip() This test should SKIP Loc: [qtbase/tests/auto/testlib/selftests/blacklisted/tst_blacklisted.cpp(0)] BFAIL : tst_Blacklisted::fail() 'false' returned FALSE. (This test should BFAIL) Loc: [qtbase/tests/auto/testlib/selftests/blacklisted/tst_blacklisted.cpp(0)] -XFAIL : tst_Blacklisted::xfail() This test should XFAIL then BFAIL +XFAIL : tst_Blacklisted::xfail() This test should XFAIL then BPASS Loc: [qtbase/tests/auto/testlib/selftests/blacklisted/tst_blacklisted.cpp(0)] BPASS : tst_Blacklisted::xfail() XPASS : tst_Blacklisted::xpass() 'true' returned TRUE unexpectedly. (This test should XPASS, blacklist ignored for XPASS) diff --git a/tests/auto/testlib/selftests/expected_blacklisted.xml b/tests/auto/testlib/selftests/expected_blacklisted.xml index 443bc6b199..f0387bae00 100644 --- a/tests/auto/testlib/selftests/expected_blacklisted.xml +++ b/tests/auto/testlib/selftests/expected_blacklisted.xml @@ -27,7 +27,7 @@ </TestFunction> <TestFunction name="xfail"> <Incident type="xfail" file="qtbase/tests/auto/testlib/selftests/blacklisted/tst_blacklisted.cpp" line="0"> - <Description><![CDATA[This test should XFAIL then BFAIL]]></Description> + <Description><![CDATA[This test should XFAIL then BPASS]]></Description> </Incident> <Incident type="bpass" file="" line="0" /> <Duration msecs="0"/> diff --git a/tests/auto/testlib/selftests/expected_blacklisted.xunitxml b/tests/auto/testlib/selftests/expected_blacklisted.xunitxml index 2752bc18b4..e2d0cd009b 100644 --- a/tests/auto/testlib/selftests/expected_blacklisted.xunitxml +++ b/tests/auto/testlib/selftests/expected_blacklisted.xunitxml @@ -12,7 +12,7 @@ </testcase> <testcase result="bfail" name="fail"/> <testcase result="xfail" name="xfail"> - <!-- message="This test should XFAIL then BFAIL" type="info" --> + <!-- message="This test should XFAIL then BPASS" type="info" --> </testcase> <testcase result="xpass" name="xpass"> <failure message="'true' returned TRUE unexpectedly. (This test should XPASS, blacklist ignored for XPASS)" result="xpass"/> @@ -28,7 +28,7 @@ </testcase> <system-err> <![CDATA[This test should SKIP]]> -<![CDATA[This test should XFAIL then BFAIL]]> +<![CDATA[This test should XFAIL then BPASS]]> <![CDATA[This is a warning that should not appear in silent test output]]> <![CDATA[This is an internal testlib warning that should not appear in silent test output]]> <![CDATA[This is a debug message that should not appear in silent test output]]> diff --git a/tests/auto/testlib/selftests/expected_float.lightxml b/tests/auto/testlib/selftests/expected_float.lightxml index 0dbc5dd8c8..37ccbfc2c5 100644 --- a/tests/auto/testlib/selftests/expected_float.lightxml +++ b/tests/auto/testlib/selftests/expected_float.lightxml @@ -34,6 +34,33 @@ </Incident> <Duration msecs="0"/> </TestFunction> +<TestFunction name="float16Comparisons"> +<Incident type="pass" file="" line="0"> + <DataTag><![CDATA[should SUCCEED 1]]></DataTag> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL 1]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 1 + Expected (operandRight): 3]]></Description> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL 2]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 0.0001 + Expected (operandRight): 0.0003]]></Description> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL 3]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 98 + Expected (operandRight): 99]]></Description> +</Incident> +<Incident type="pass" file="" line="0"> + <DataTag><![CDATA[should SUCCEED 2]]></DataTag> +</Incident> + <Duration msecs="0"/> +</TestFunction> <TestFunction name="compareFloatTests"> <Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> <DataTag><![CDATA[1e0]]></DataTag> diff --git a/tests/auto/testlib/selftests/expected_float.tap b/tests/auto/testlib/selftests/expected_float.tap index fae2dc9796..158eff1470 100644 --- a/tests/auto/testlib/selftests/expected_float.tap +++ b/tests/auto/testlib/selftests/expected_float.tap @@ -10,9 +10,9 @@ not ok 3 - floatComparisons(should FAIL 1) found: 1 (operandLeft) expected: 3 (operandRight) actual: 1 (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:48) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:51) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 48 + line: 51 ... not ok 4 - floatComparisons(should FAIL 2) --- @@ -22,9 +22,9 @@ not ok 4 - floatComparisons(should FAIL 2) found: 1e-07 (operandLeft) expected: 3e-07 (operandRight) actual: 1e-07 (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:48) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:51) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 48 + line: 51 ... not ok 5 - floatComparisons(should FAIL 3) --- @@ -34,12 +34,50 @@ not ok 5 - floatComparisons(should FAIL 3) found: 99998 (operandLeft) expected: 99999 (operandRight) actual: 99998 (operandLeft) - at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:48) + at: tst_float::floatComparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:51) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 48 + line: 51 ... ok 6 - floatComparisons(should SUCCEED 2) -not ok 7 - compareFloatTests(1e0) +ok 7 - float16Comparisons(should SUCCEED 1) +not ok 8 - float16Comparisons(should FAIL 1) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: 3 (operandRight) + found: 1 (operandLeft) + expected: 3 (operandRight) + actual: 1 (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:90) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 90 + ... +not ok 9 - float16Comparisons(should FAIL 2) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: 0.0003 (operandRight) + found: 0.0001 (operandLeft) + expected: 0.0003 (operandRight) + actual: 0.0001 (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:90) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 90 + ... +not ok 10 - float16Comparisons(should FAIL 3) + --- + type: QCOMPARE + message: Compared qfloat16s are not the same (fuzzy compare) + wanted: 99 (operandRight) + found: 98 (operandLeft) + expected: 99 (operandRight) + actual: 98 (operandLeft) + at: tst_float::float16Comparisons() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:90) + file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp + line: 90 + ... +ok 11 - float16Comparisons(should SUCCEED 2) +not ok 12 - compareFloatTests(1e0) --- type: QCOMPARE message: Compared floats are not the same (fuzzy compare) @@ -47,11 +85,11 @@ not ok 7 - compareFloatTests(1e0) found: 1 (t1) expected: 3 (t3) actual: 1 (t1) - at: tst_float::compareFloatTests() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:96) + at: tst_float::compareFloatTests() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:135) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 96 + line: 135 ... -not ok 8 - compareFloatTests(1e-7) +not ok 13 - compareFloatTests(1e-7) --- type: QCOMPARE message: Compared floats are not the same (fuzzy compare) @@ -59,11 +97,11 @@ not ok 8 - compareFloatTests(1e-7) found: 1e-07 (t1) expected: 3e-07 (t3) actual: 1e-07 (t1) - at: tst_float::compareFloatTests() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:96) + at: tst_float::compareFloatTests() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:135) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 96 + line: 135 ... -not ok 9 - compareFloatTests(1e+7) +not ok 14 - compareFloatTests(1e+7) --- type: QCOMPARE message: Compared floats are not the same (fuzzy compare) @@ -71,12 +109,12 @@ not ok 9 - compareFloatTests(1e+7) found: 1e+07 (t1) expected: 3e+07 (t3) actual: 1e+07 (t1) - at: tst_float::compareFloatTests() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:96) + at: tst_float::compareFloatTests() (qtbase/tests/auto/testlib/selftests/float/tst_float.cpp:135) file: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp - line: 96 + line: 135 ... -ok 10 - cleanupTestCase() -1..10 -# tests 10 -# pass 4 -# fail 6 +ok 15 - cleanupTestCase() +1..15 +# tests 15 +# pass 6 +# fail 9 diff --git a/tests/auto/testlib/selftests/expected_float.teamcity b/tests/auto/testlib/selftests/expected_float.teamcity index d5b81593d8..140dc7edf9 100644 --- a/tests/auto/testlib/selftests/expected_float.teamcity +++ b/tests/auto/testlib/selftests/expected_float.teamcity @@ -14,6 +14,19 @@ ##teamcity[testFinished name='floatComparisons(should FAIL 3)' flowId='tst_float'] ##teamcity[testStarted name='floatComparisons(should SUCCEED 2)' flowId='tst_float'] ##teamcity[testFinished name='floatComparisons(should SUCCEED 2)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should SUCCEED 1)' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should SUCCEED 1)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL 1)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL 1)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : 1|n Expected (operandRight): 3' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL 1)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL 2)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL 2)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : 0.0001|n Expected (operandRight): 0.0003' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL 2)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should FAIL 3)' flowId='tst_float'] +##teamcity[testFailed name='float16Comparisons(should FAIL 3)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared qfloat16s are not the same (fuzzy compare)|n Actual (operandLeft) : 98|n Expected (operandRight): 99' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should FAIL 3)' flowId='tst_float'] +##teamcity[testStarted name='float16Comparisons(should SUCCEED 2)' flowId='tst_float'] +##teamcity[testFinished name='float16Comparisons(should SUCCEED 2)' flowId='tst_float'] ##teamcity[testStarted name='compareFloatTests(1e0)' flowId='tst_float'] ##teamcity[testFailed name='compareFloatTests(1e0)' message='Failure! |[Loc: qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)|]' details='Compared floats are not the same (fuzzy compare)|n Actual (t1): 1|n Expected (t3): 3' flowId='tst_float'] ##teamcity[testFinished name='compareFloatTests(1e0)' flowId='tst_float'] diff --git a/tests/auto/testlib/selftests/expected_float.txt b/tests/auto/testlib/selftests/expected_float.txt index 8abea6a67e..4e3554758d 100644 --- a/tests/auto/testlib/selftests/expected_float.txt +++ b/tests/auto/testlib/selftests/expected_float.txt @@ -15,6 +15,20 @@ FAIL! : tst_float::floatComparisons(should FAIL 3) Compared floats are not the Expected (operandRight): 99999 Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] PASS : tst_float::floatComparisons(should SUCCEED 2) +PASS : tst_float::float16Comparisons(should SUCCEED 1) +FAIL! : tst_float::float16Comparisons(should FAIL 1) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 1 + Expected (operandRight): 3 + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +FAIL! : tst_float::float16Comparisons(should FAIL 2) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 0.0001 + Expected (operandRight): 0.0003 + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +FAIL! : tst_float::float16Comparisons(should FAIL 3) Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 98 + Expected (operandRight): 99 + Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] +PASS : tst_float::float16Comparisons(should SUCCEED 2) FAIL! : tst_float::compareFloatTests(1e0) Compared floats are not the same (fuzzy compare) Actual (t1): 1 Expected (t3): 3 @@ -28,5 +42,5 @@ FAIL! : tst_float::compareFloatTests(1e+7) Compared floats are not the same (fu Expected (t3): 3e+07 Loc: [qtbase/tests/auto/testlib/selftests/float/tst_float.cpp(0)] PASS : tst_float::cleanupTestCase() -Totals: 4 passed, 6 failed, 0 skipped, 0 blacklisted, 0ms +Totals: 6 passed, 9 failed, 0 skipped, 0 blacklisted, 0ms ********* Finished testing of tst_float ********* diff --git a/tests/auto/testlib/selftests/expected_float.xml b/tests/auto/testlib/selftests/expected_float.xml index 096e1a5b54..1f17d48d1b 100644 --- a/tests/auto/testlib/selftests/expected_float.xml +++ b/tests/auto/testlib/selftests/expected_float.xml @@ -36,6 +36,33 @@ </Incident> <Duration msecs="0"/> </TestFunction> +<TestFunction name="float16Comparisons"> +<Incident type="pass" file="" line="0"> + <DataTag><![CDATA[should SUCCEED 1]]></DataTag> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL 1]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 1 + Expected (operandRight): 3]]></Description> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL 2]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 0.0001 + Expected (operandRight): 0.0003]]></Description> +</Incident> +<Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> + <DataTag><![CDATA[should FAIL 3]]></DataTag> + <Description><![CDATA[Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 98 + Expected (operandRight): 99]]></Description> +</Incident> +<Incident type="pass" file="" line="0"> + <DataTag><![CDATA[should SUCCEED 2]]></DataTag> +</Incident> + <Duration msecs="0"/> +</TestFunction> <TestFunction name="compareFloatTests"> <Incident type="fail" file="qtbase/tests/auto/testlib/selftests/float/tst_float.cpp" line="0"> <DataTag><![CDATA[1e0]]></DataTag> diff --git a/tests/auto/testlib/selftests/expected_float.xunitxml b/tests/auto/testlib/selftests/expected_float.xunitxml index 5de14e8d9b..87f11ccba5 100644 --- a/tests/auto/testlib/selftests/expected_float.xunitxml +++ b/tests/auto/testlib/selftests/expected_float.xunitxml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<testsuite errors="0" failures="6" tests="4" name="tst_float"> +<testsuite errors="0" failures="9" tests="5" name="tst_float"> <properties> <property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/> <property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/> @@ -17,6 +17,17 @@ Actual (operandLeft) : 99998 Expected (operandRight): 99999" result="fail"/> </testcase> + <testcase result="fail" name="float16Comparisons"> + <failure tag="should FAIL 1" message="Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 1 + Expected (operandRight): 3" result="fail"/> + <failure tag="should FAIL 2" message="Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 0.0001 + Expected (operandRight): 0.0003" result="fail"/> + <failure tag="should FAIL 3" message="Compared qfloat16s are not the same (fuzzy compare) + Actual (operandLeft) : 98 + Expected (operandRight): 99" result="fail"/> + </testcase> <testcase result="fail" name="compareFloatTests"> <failure tag="1e0" message="Compared floats are not the same (fuzzy compare) Actual (t1): 1 diff --git a/tests/auto/testlib/selftests/float/tst_float.cpp b/tests/auto/testlib/selftests/float/tst_float.cpp index 2fffcc7803..b12bc24c58 100644 --- a/tests/auto/testlib/selftests/float/tst_float.cpp +++ b/tests/auto/testlib/selftests/float/tst_float.cpp @@ -27,6 +27,7 @@ ****************************************************************************/ #include <QtCore/QCoreApplication> +#include <QtCore/qfloat16.h> #include <QtTest/QtTest> #include <QDebug> @@ -36,6 +37,8 @@ class tst_float: public QObject private slots: void floatComparisons() const; void floatComparisons_data() const; + void float16Comparisons() const; + void float16Comparisons_data() const; void compareFloatTests() const; void compareFloatTests_data() const; }; @@ -79,6 +82,42 @@ void tst_float::floatComparisons_data() const << float(100002); } +void tst_float::float16Comparisons() const +{ + QFETCH(qfloat16, operandLeft); + QFETCH(qfloat16, operandRight); + + QCOMPARE(operandLeft, operandRight); +} + +void tst_float::float16Comparisons_data() const +{ + QTest::addColumn<qfloat16>("operandLeft"); + QTest::addColumn<qfloat16>("operandRight"); + + QTest::newRow("should SUCCEED 1") + << qfloat16(0) + << qfloat16(0); + + QTest::newRow("should FAIL 1") + << qfloat16(1.000) + << qfloat16(3.000); + + QTest::newRow("should FAIL 2") + << qfloat16(1.000e-4f) + << qfloat16(3.000e-4f); + + // QCOMPARE for qfloat16s uses qFuzzyCompare() + + QTest::newRow("should FAIL 3") + << qfloat16(98) + << qfloat16(99); + + QTest::newRow("should SUCCEED 2") + << qfloat16(1001) + << qfloat16(1002); +} + void tst_float::compareFloatTests() const { QFETCH(float, t1); diff --git a/tests/auto/testlib/selftests/generate_expected_output.py b/tests/auto/testlib/selftests/generate_expected_output.py index 1996416e8c..3c5f922c75 100755 --- a/tests/auto/testlib/selftests/generate_expected_output.py +++ b/tests/auto/testlib/selftests/generate_expected_output.py @@ -223,6 +223,7 @@ del re def generateTestData(testname, clean, formats = ('xml', 'txt', 'xunitxml', 'lightxml', 'teamcity', 'tap'), + # Make sure this matches tst_Selftests::runSubTest_data(): extraArgs = { "commandlinedata": "fiveTablePasses fiveTablePasses:fiveTablePasses_data1 -v2", "benchlibcallgrind": "-callgrind", @@ -236,7 +237,15 @@ def generateTestData(testname, clean, "silent": "-silent", "verbose1": "-v1", "verbose2": "-v2", - }): + }, + # Make sure this matches tst_Selftests::doRunSubTest(): + extraEnv = { + "crashes": { "QTEST_DISABLE_CORE_DUMP": "1", "QTEST_DISABLE_STACK_DUMP": "1" }, + }, + # These are actually *other* crashers, beside those in extraEnv; + # must match tst_Selftests::runSubTest_data(): + crashers = ("assert", "blacklisted", "crashedterminate", + "exceptionthrow", "fetchbogus", "silent")): """Run one test and save its cleaned results. Required arguments are the name of the test directory (the binary @@ -248,6 +257,16 @@ def generateTestData(testname, clean, if not os.path.isfile(path): print("Warning: directory", testname, "contains no test executable") return + env = None + try: + env = extraEnv[testname] + except KeyError: + if env in crashers: + env = extraEnv["crashes"] + if env: + data = os.environ.copy() + data.update(env) + env = data print(" running", testname) for format in formats: @@ -255,7 +274,7 @@ def generateTestData(testname, clean, if testname in extraArgs: cmd += extraArgs[testname].split() - data = subprocess.Popen(cmd, stdout=subprocess.PIPE, + data = subprocess.Popen(cmd, stdout=subprocess.PIPE, env=env, universal_newlines=True).communicate()[0] with open('expected_' + testname + '.' + format, 'w') as out: out.write('\n'.join(clean(data))) # write() appends a newline, too diff --git a/tests/auto/testlib/selftests/tst_selftests.cpp b/tests/auto/testlib/selftests/tst_selftests.cpp index c5f847562e..008cce6218 100644 --- a/tests/auto/testlib/selftests/tst_selftests.cpp +++ b/tests/auto/testlib/selftests/tst_selftests.cpp @@ -520,6 +520,7 @@ void tst_Selftests::runSubTest_data() foreach (QString const& subtest, tests) { QStringList arguments = loggerSet.arguments; + // Keep in sync with generateTestData()'s extraArgs in generate_expected_output.py: if (subtest == "commandlinedata") { arguments << QString("fiveTablePasses fiveTablePasses:fiveTablePasses_data1 -v2").split(' '); } @@ -612,6 +613,7 @@ void tst_Selftests::runSubTest_data() if (loggerSet.name.contains("teamcity") && subtest.startsWith("benchlib")) continue; // Skip benchmark for TeamCity logger + // Keep in sync with generateTestData()'s crashers in generate_expected_output.py: const bool crashes = subtest == QLatin1String("assert") || subtest == QLatin1String("exceptionthrow") || subtest == QLatin1String("fetchbogus") || subtest == QLatin1String("crashedterminate") || subtest == QLatin1String("crashes") || subtest == QLatin1String("silent") @@ -687,6 +689,7 @@ void tst_Selftests::doRunSubTest(QString const& subdir, QStringList const& logge QProcess proc; QProcessEnvironment environment = processEnvironment(); + // Keep in sync with generateTestData()'s extraEnv in generate_expected_output.py: if (crashes) { environment.insert("QTEST_DISABLE_CORE_DUMP", "1"); environment.insert("QTEST_DISABLE_STACK_DUMP", "1"); @@ -893,16 +896,19 @@ bool tst_Selftests::compareLine(const QString &logger, const QString &subdir, const QString &actualLine, const QString &expectedLine, QString *errorMessage) const { - if (subdir == QLatin1String("assert") && actualLine.contains(QLatin1String("ASSERT: ")) - && expectedLine.contains(QLatin1String("ASSERT: ")) && actualLine != expectedLine) { + if (actualLine == expectedLine) + return true; + + if (subdir == QLatin1String("assert") + && actualLine.contains(QLatin1String("ASSERT: ")) + && expectedLine.contains(QLatin1String("ASSERT: "))) { // Q_ASSERT uses __FILE__, the exact contents of which are // undefined. If have we something that looks like a Q_ASSERT and we // were expecting to see a Q_ASSERT, we'll skip the line. return true; } - if (expectedLine.startsWith(QLatin1String("FAIL! : tst_Exception::throwException() Caught unhandled exce")) - && actualLine != expectedLine) { + if (expectedLine.startsWith(QLatin1String("FAIL! : tst_Exception::throwException() Caught unhandled exce"))) { // On some platforms we compile without RTTI, and as a result we never throw an exception if (actualLine.simplified() != QLatin1String("tst_Exception::throwException()")) { *errorMessage = QString::fromLatin1("'%1' != 'tst_Exception::throwException()'").arg(actualLine); @@ -941,9 +947,6 @@ bool tst_Selftests::compareLine(const QString &logger, const QString &subdir, if (actualLine.startsWith(QLatin1String("Totals:")) && expectedLine.startsWith(QLatin1String("Totals:"))) return true; - if (actualLine == expectedLine) - return true; - *errorMessage = msgMismatch(actualLine, expectedLine); return false; } diff --git a/tests/auto/testlib/testlib.pro b/tests/auto/testlib/testlib.pro index 25ccc591d6..587c76a189 100644 --- a/tests/auto/testlib/testlib.pro +++ b/tests/auto/testlib/testlib.pro @@ -1,6 +1,7 @@ -TEMPLATE=subdirs -SUBDIRS=\ +TEMPLATE = subdirs +SUBDIRS = \ + outformat \ qsignalspy \ selftests \ -qtHaveModule(widgets):SUBDIRS += qabstractitemmodeltester +qtHaveModule(widgets): SUBDIRS += qabstractitemmodeltester diff --git a/tests/auto/testserver.pri b/tests/auto/testserver.pri index b2f593235f..7dd32db0af 100644 --- a/tests/auto/testserver.pri +++ b/tests/auto/testserver.pri @@ -51,7 +51,6 @@ # 2. testserver_clean - Clean up server containers/images and tidy away related # files. -TESTSERVER_COMPOSE_FILE = $$dirname(_QMAKE_CONF_)/tests/testserver/docker-compose.yml TESTSERVER_VERSION = $$system(docker-compose --version) equals(QMAKE_HOST.os, Windows)|isEmpty(TESTSERVER_VERSION) { @@ -59,30 +58,59 @@ equals(QMAKE_HOST.os, Windows)|isEmpty(TESTSERVER_VERSION) { message("testserver: qt-test-server.qt-test-net") } else { # Make check with test servers - message("testserver:" $$TESTSERVER_VERSION) + equals(QMAKE_HOST.os, Darwin) { + # There is no docker bridge on macOS. It is impossible to ping a container. + # Docker docs recommends using port mapping to connect to a container; + # but it causes a port conflict if the user is running a service that + # binds the same port on the host. An alternative solution is to deploy + # the docker environment into VirtualBox using docker-machine. + TESTSERVER_COMPOSE_FILE = \ + $$dirname(_QMAKE_CONF_)/tests/testserver/docker-compose-for-macOS.yml + + # The connection configuration for the target machine + MACHINE_CONFIG = $(shell docker-machine config qt-test-server) + + # The environment variables passed to the docker-compose file + TEST_ENV = 'MACHINE_IP=$(shell docker-machine ip qt-test-server)' + } else { + TESTSERVER_COMPOSE_FILE = $$dirname(_QMAKE_CONF_)/tests/testserver/docker-compose.yml + DEFINES += QT_TEST_SERVER_NAME + } # Ensure that the docker-compose file is provided. It is a configuration # file which is mandatory for all docker-compose commands. You can get more # detail from the description of TESTSERVER_COMPOSE_FILE above. There is # also an example showing how to configure it manually. FILE_PRETEST_MSG = "Project variable 'TESTSERVER_COMPOSE_FILE' is not set" - testserver_pretest.commands = $(if $$TESTSERVER_COMPOSE_FILE,,$(error $$FILE_PRETEST_MSG)) + testserver_pretest.commands = $(info "testserver:" $$TESTSERVER_VERSION) + testserver_pretest.commands += $(if $$TESTSERVER_COMPOSE_FILE,,$(error $$FILE_PRETEST_MSG)) + + # Make sure docker-machine is both created and running. The docker_machine + # script is used to deploy the docker environment into VirtualBox. + # Example: qt5/coin/provisioning/common/shared/testserver/docker_machine.sh + !isEmpty(MACHINE_CONFIG) { + MACHINE_LIST_CMD = docker-machine ls -q --filter "Name=^qt-test-server$" + MACHINE_LIST_MSG = "Docker machine qt-test-server not found" + testserver_pretest.commands += \ + $(if $(shell $$MACHINE_LIST_CMD),,$(error $$MACHINE_LIST_MSG)) + + MACHINE_STATE_CMD = \ + docker-machine ls -q --filter "State=Running" --filter "Name=^qt-test-server$" + MACHINE_START_CMD = docker-machine start qt-test-server + testserver_pretest.commands += \ + $(if $(shell $$MACHINE_STATE_CMD),,$(shell $$MACHINE_START_CMD > /dev/null)) + } # Before starting the test servers, it requires the user to run the setup # script (coin/provisioning/.../testserver/docker_testserver.sh) in advance. - IMAGE_PRETEST_CMD = docker images -aq "qt-test-server-*" + IMAGE_PRETEST_CMD = docker $$MACHINE_CONFIG images -aq "qt-test-server-*" IMAGE_PRETEST_MSG = "Docker image qt-test-server-* not found" testserver_pretest.commands += $(if $(shell $$IMAGE_PRETEST_CMD),,$(error $$IMAGE_PRETEST_MSG)) # The domain name is relevant to https keycert (qnetworkreply/crts/qt-test-net-cacert.pem). DNSDOMAIN = test-net.qt.local - TEST_ENV += TESTSERVER_DOMAIN=$$DNSDOMAIN DEFINES += QT_TEST_SERVER QT_TEST_SERVER_DOMAIN=$$shell_quote(\"$${DNSDOMAIN}\") - # There is no docker bridge on macOS. It is impossible to ping a container. - # Docker docs recommends using port mapping to connect to a container. - equals(QMAKE_HOST.os, Darwin): TEST_ENV += TESTSERVER_BIND_LOCAL=1 - # Rename the check target of testcase feature check.target = check_network testserver_test.target = check @@ -91,18 +119,19 @@ equals(QMAKE_HOST.os, Windows)|isEmpty(TESTSERVER_VERSION) { testserver_test.depends = testserver_pretest # Bring up test servers and make sure the services are ready. - testserver_test.commands = $$TEST_ENV docker-compose -f $$TESTSERVER_COMPOSE_FILE up -d \ - --force-recreate --timeout 1 $${QT_TEST_SERVER_LIST} && + !isEmpty(TEST_ENV): testserver_test.commands = env $$TEST_ENV + testserver_test.commands += docker-compose $$MACHINE_CONFIG -f $$TESTSERVER_COMPOSE_FILE up \ + --detach --force-recreate --timeout 1 $${QT_TEST_SERVER_LIST} && # Check test cases with docker-based test servers. testserver_test.commands += $(MAKE) check_network; # Stop and remove test servers after testing. - testserver_test.commands += $$TEST_ENV docker-compose -f $$TESTSERVER_COMPOSE_FILE down \ + testserver_test.commands += docker-compose $$MACHINE_CONFIG -f $$TESTSERVER_COMPOSE_FILE down \ --timeout 1 # Destroy test servers and tidy away related files. - testserver_clean.commands = $$TEST_ENV docker-compose -f $$TESTSERVER_COMPOSE_FILE down \ + testserver_clean.commands = docker-compose $$MACHINE_CONFIG -f $$TESTSERVER_COMPOSE_FILE down \ --rmi all QMAKE_EXTRA_TARGETS += testserver_pretest testserver_test testserver_clean diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index 92a94055a4..f1888aebab 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -682,6 +682,7 @@ private slots: void finalClasses(); void explicitOverrideControl_data(); void explicitOverrideControl(); + void overloadedAddressOperator(); void autoPropertyMetaTypeRegistration(); void autoMethodArgumentMetaTypeRegistration(); void autoSignalSpyMetaTypeRegistration(); @@ -2939,6 +2940,34 @@ void tst_Moc::explicitOverrideControl() #endif } +class OverloadedAddressOperator : public QObject +{ + Q_OBJECT +public: + void* operator&() { return nullptr; } +signals: + void self(OverloadedAddressOperator&); +public slots: + void assertSelf(OverloadedAddressOperator &o) + { + QCOMPARE(std::addressof(o), this); + testResult = (std::addressof(o) == this); + } +public: + bool testResult = false; +}; + +void tst_Moc::overloadedAddressOperator() +{ + OverloadedAddressOperator o; + OverloadedAddressOperator *p = std::addressof(o); + QCOMPARE(&o, nullptr); + QVERIFY(p); + QObject::connect(p, &OverloadedAddressOperator::self, p, &OverloadedAddressOperator::assertSelf); + emit o.self(o); + QVERIFY(o.testResult); +} + class CustomQObject : public QObject { Q_OBJECT diff --git a/tests/auto/tools/rcc/data/sizes/data/data-0.txt b/tests/auto/tools/rcc/data/sizes/data/data-0.txt new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/tests/auto/tools/rcc/data/sizes/data/data-0.txt diff --git a/tests/auto/tools/rcc/data/sizes/data/data-1.txt b/tests/auto/tools/rcc/data/sizes/data/data-1.txt new file mode 100644 index 0000000000..b516b2c489 --- /dev/null +++ b/tests/auto/tools/rcc/data/sizes/data/data-1.txt @@ -0,0 +1 @@ +@
\ No newline at end of file diff --git a/tests/auto/tools/rcc/data/sizes/data/data-2.txt b/tests/auto/tools/rcc/data/sizes/data/data-2.txt new file mode 100644 index 0000000000..a616ad491b --- /dev/null +++ b/tests/auto/tools/rcc/data/sizes/data/data-2.txt @@ -0,0 +1 @@ +01
\ No newline at end of file diff --git a/tests/auto/tools/rcc/data/sizes/data/data-35.txt b/tests/auto/tools/rcc/data/sizes/data/data-35.txt new file mode 100644 index 0000000000..19a8036a15 --- /dev/null +++ b/tests/auto/tools/rcc/data/sizes/data/data-35.txt @@ -0,0 +1 @@ +0123456789 0123456789 0123456789 12
\ No newline at end of file diff --git a/tests/auto/tools/rcc/data/sizes/size-0.expected b/tests/auto/tools/rcc/data/sizes/size-0.expected new file mode 100644 index 0000000000..e862310153 --- /dev/null +++ b/tests/auto/tools/rcc/data/sizes/size-0.expected @@ -0,0 +1,88 @@ +/**************************************************************************** +** Resource object code +** +IGNORE: ** Created by: The Resource Compiler for Qt version 5.11.2 +** +** WARNING! All changes made in this file will be lost! +*****************************************************************************/ + +static const unsigned char qt_resource_data[] = { +IGNORE: // /data/dev/qt-5/qtbase/tests/auto/tools/rcc/data/sizes/data/data-0.txt + 0x0,0x0,0x0,0x0, + + +}; + +static const unsigned char qt_resource_name[] = { + // data + 0x0,0x4, + 0x0,0x6,0xa8,0xa1, + 0x0,0x64, + 0x0,0x61,0x0,0x74,0x0,0x61, + // data-0.txt + 0x0,0xa, + 0x4,0xe,0xa,0xb4, + 0x0,0x64, + 0x0,0x61,0x0,0x74,0x0,0x61,0x0,0x2d,0x0,0x30,0x0,0x2e,0x0,0x74,0x0,0x78,0x0,0x74, + +}; + +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, + // :/data + 0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x2, +0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, + // :/data/data-0.txt + 0x0,0x0,0x0,0xe,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x0, +TIMESTAMP:data/data-0.txt + +}; + +#ifdef QT_NAMESPACE +# define QT_RCC_PREPEND_NAMESPACE(name) ::QT_NAMESPACE::name +# define QT_RCC_MANGLE_NAMESPACE0(x) x +# define QT_RCC_MANGLE_NAMESPACE1(a, b) a##_##b +# define QT_RCC_MANGLE_NAMESPACE2(a, b) QT_RCC_MANGLE_NAMESPACE1(a,b) +# define QT_RCC_MANGLE_NAMESPACE(name) QT_RCC_MANGLE_NAMESPACE2( \ + QT_RCC_MANGLE_NAMESPACE0(name), QT_RCC_MANGLE_NAMESPACE0(QT_NAMESPACE)) +#else +# define QT_RCC_PREPEND_NAMESPACE(name) name +# define QT_RCC_MANGLE_NAMESPACE(name) name +#endif + +#ifdef QT_NAMESPACE +namespace QT_NAMESPACE { +#endif + +bool qRegisterResourceData(int, const unsigned char *, const unsigned char *, const unsigned char *); + +bool qUnregisterResourceData(int, const unsigned char *, const unsigned char *, const unsigned char *); + +#ifdef QT_NAMESPACE +} +#endif + +int QT_RCC_MANGLE_NAMESPACE(qInitResources)(); +int QT_RCC_MANGLE_NAMESPACE(qInitResources)() +{ + QT_RCC_PREPEND_NAMESPACE(qRegisterResourceData) + (0x2, qt_resource_struct, qt_resource_name, qt_resource_data); + return 1; +} + +int QT_RCC_MANGLE_NAMESPACE(qCleanupResources)(); +int QT_RCC_MANGLE_NAMESPACE(qCleanupResources)() +{ + QT_RCC_PREPEND_NAMESPACE(qUnregisterResourceData) + (0x2, qt_resource_struct, qt_resource_name, qt_resource_data); + return 1; +} + +namespace { + struct initializer { + initializer() { QT_RCC_MANGLE_NAMESPACE(qInitResources)(); } + ~initializer() { QT_RCC_MANGLE_NAMESPACE(qCleanupResources)(); } + } dummy; +} diff --git a/tests/auto/tools/rcc/data/sizes/size-0.qrc b/tests/auto/tools/rcc/data/sizes/size-0.qrc new file mode 100644 index 0000000000..9f47732fe2 --- /dev/null +++ b/tests/auto/tools/rcc/data/sizes/size-0.qrc @@ -0,0 +1,5 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource> + <file>data/data-0.txt</file> +</qresource> +</RCC> diff --git a/tests/auto/tools/rcc/data/sizes/size-1.expected b/tests/auto/tools/rcc/data/sizes/size-1.expected new file mode 100644 index 0000000000..9e5161272a --- /dev/null +++ b/tests/auto/tools/rcc/data/sizes/size-1.expected @@ -0,0 +1,89 @@ +/**************************************************************************** +** Resource object code +** +IGNORE:** Created by: The Resource Compiler for Qt version 5.11.2 +** +** WARNING! All changes made in this file will be lost! +*****************************************************************************/ + +static const unsigned char qt_resource_data[] = { +IGNORE: // /data/dev/qt-5/qtbase/tests/auto/tools/rcc/data/sizes/data/data-1.txt + 0x0,0x0,0x0,0x1, + 0x40, + + +}; + +static const unsigned char qt_resource_name[] = { + // data + 0x0,0x4, + 0x0,0x6,0xa8,0xa1, + 0x0,0x64, + 0x0,0x61,0x0,0x74,0x0,0x61, + // data-1.txt + 0x0,0xa, + 0x4,0x11,0xa,0xb4, + 0x0,0x64, + 0x0,0x61,0x0,0x74,0x0,0x61,0x0,0x2d,0x0,0x31,0x0,0x2e,0x0,0x74,0x0,0x78,0x0,0x74, + +}; + +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, + // :/data + 0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x2, +0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, + // :/data/data-1.txt + 0x0,0x0,0x0,0xe,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x0, +TIMESTAMP:data/data-1.txt + +}; + +#ifdef QT_NAMESPACE +# define QT_RCC_PREPEND_NAMESPACE(name) ::QT_NAMESPACE::name +# define QT_RCC_MANGLE_NAMESPACE0(x) x +# define QT_RCC_MANGLE_NAMESPACE1(a, b) a##_##b +# define QT_RCC_MANGLE_NAMESPACE2(a, b) QT_RCC_MANGLE_NAMESPACE1(a,b) +# define QT_RCC_MANGLE_NAMESPACE(name) QT_RCC_MANGLE_NAMESPACE2( \ + QT_RCC_MANGLE_NAMESPACE0(name), QT_RCC_MANGLE_NAMESPACE0(QT_NAMESPACE)) +#else +# define QT_RCC_PREPEND_NAMESPACE(name) name +# define QT_RCC_MANGLE_NAMESPACE(name) name +#endif + +#ifdef QT_NAMESPACE +namespace QT_NAMESPACE { +#endif + +bool qRegisterResourceData(int, const unsigned char *, const unsigned char *, const unsigned char *); + +bool qUnregisterResourceData(int, const unsigned char *, const unsigned char *, const unsigned char *); + +#ifdef QT_NAMESPACE +} +#endif + +int QT_RCC_MANGLE_NAMESPACE(qInitResources)(); +int QT_RCC_MANGLE_NAMESPACE(qInitResources)() +{ + QT_RCC_PREPEND_NAMESPACE(qRegisterResourceData) + (0x2, qt_resource_struct, qt_resource_name, qt_resource_data); + return 1; +} + +int QT_RCC_MANGLE_NAMESPACE(qCleanupResources)(); +int QT_RCC_MANGLE_NAMESPACE(qCleanupResources)() +{ + QT_RCC_PREPEND_NAMESPACE(qUnregisterResourceData) + (0x2, qt_resource_struct, qt_resource_name, qt_resource_data); + return 1; +} + +namespace { + struct initializer { + initializer() { QT_RCC_MANGLE_NAMESPACE(qInitResources)(); } + ~initializer() { QT_RCC_MANGLE_NAMESPACE(qCleanupResources)(); } + } dummy; +} diff --git a/tests/auto/tools/rcc/data/sizes/size-1.qrc b/tests/auto/tools/rcc/data/sizes/size-1.qrc new file mode 100644 index 0000000000..9fde9a1722 --- /dev/null +++ b/tests/auto/tools/rcc/data/sizes/size-1.qrc @@ -0,0 +1,5 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource> + <file>data/data-1.txt</file> +</qresource> +</RCC> diff --git a/tests/auto/tools/rcc/data/sizes/size-2-0-35-1.expected b/tests/auto/tools/rcc/data/sizes/size-2-0-35-1.expected new file mode 100644 index 0000000000..0fc953351a --- /dev/null +++ b/tests/auto/tools/rcc/data/sizes/size-2-0-35-1.expected @@ -0,0 +1,126 @@ +/**************************************************************************** +** Resource object code +** +IGNORE: ** Created by: The Resource Compiler for Qt version 5.11.2 +** +** WARNING! All changes made in this file will be lost! +*****************************************************************************/ + +static const unsigned char qt_resource_data[] = { +IGNORE: // /data/dev/qt-5/qtbase/tests/auto/tools/rcc/data/sizes/data/data-2.txt + 0x0,0x0,0x0,0x2, + 0x30, + 0x31, +IGNORE: // /data/dev/qt-5/qtbase/tests/auto/tools/rcc/data/sizes/data/data-35.txt + 0x0,0x0,0x0,0x23, + 0x30, + 0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x20,0x30,0x31,0x32,0x33,0x34,0x35, + 0x36,0x37,0x38,0x39,0x20,0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x20, + 0x31,0x32, +IGNORE: // /data/dev/qt-5/qtbase/tests/auto/tools/rcc/data/sizes/data/data-1.txt + 0x0,0x0,0x0,0x1, + 0x40, + +IGNORE: // /data/dev/qt-5/qtbase/tests/auto/tools/rcc/data/sizes/data/data-0.txt + 0x0,0x0,0x0,0x0, + + +}; + +static const unsigned char qt_resource_name[] = { + // data + 0x0,0x4, + 0x0,0x6,0xa8,0xa1, + 0x0,0x64, + 0x0,0x61,0x0,0x74,0x0,0x61, + // data-2.txt + 0x0,0xa, + 0x4,0x8,0xa,0xb4, + 0x0,0x64, + 0x0,0x61,0x0,0x74,0x0,0x61,0x0,0x2d,0x0,0x32,0x0,0x2e,0x0,0x74,0x0,0x78,0x0,0x74, + // data-35.txt + 0x0,0xb, + 0x0,0xb5,0x4f,0x74, + 0x0,0x64, + 0x0,0x61,0x0,0x74,0x0,0x61,0x0,0x2d,0x0,0x33,0x0,0x35,0x0,0x2e,0x0,0x74,0x0,0x78,0x0,0x74, + // data-1.txt + 0x0,0xa, + 0x4,0x11,0xa,0xb4, + 0x0,0x64, + 0x0,0x61,0x0,0x74,0x0,0x61,0x0,0x2d,0x0,0x31,0x0,0x2e,0x0,0x74,0x0,0x78,0x0,0x74, + // data-0.txt + 0x0,0xa, + 0x4,0xe,0xa,0xb4, + 0x0,0x64, + 0x0,0x61,0x0,0x74,0x0,0x61,0x0,0x2d,0x0,0x30,0x0,0x2e,0x0,0x74,0x0,0x78,0x0,0x74, + +}; + +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, + // :/data + 0x0,0x0,0x0,0x0,0x0,0x2,0x0,0x0,0x0,0x4,0x0,0x0,0x0,0x2, +0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, + // :/data/data-35.txt + 0x0,0x0,0x0,0x28,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x6, +TIMESTAMP:data/data-35.txt + // :/data/data-2.txt + 0x0,0x0,0x0,0xe,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x0, +TIMESTAMP:data/data-2.txt + // :/data/data-0.txt + 0x0,0x0,0x0,0x5e,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x32, +TIMESTAMP:data/data-0.txt + // :/data/data-1.txt + 0x0,0x0,0x0,0x44,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x2d, +TIMESTAMP:data/data-1.txt + +}; + +#ifdef QT_NAMESPACE +# define QT_RCC_PREPEND_NAMESPACE(name) ::QT_NAMESPACE::name +# define QT_RCC_MANGLE_NAMESPACE0(x) x +# define QT_RCC_MANGLE_NAMESPACE1(a, b) a##_##b +# define QT_RCC_MANGLE_NAMESPACE2(a, b) QT_RCC_MANGLE_NAMESPACE1(a,b) +# define QT_RCC_MANGLE_NAMESPACE(name) QT_RCC_MANGLE_NAMESPACE2( \ + QT_RCC_MANGLE_NAMESPACE0(name), QT_RCC_MANGLE_NAMESPACE0(QT_NAMESPACE)) +#else +# define QT_RCC_PREPEND_NAMESPACE(name) name +# define QT_RCC_MANGLE_NAMESPACE(name) name +#endif + +#ifdef QT_NAMESPACE +namespace QT_NAMESPACE { +#endif + +bool qRegisterResourceData(int, const unsigned char *, const unsigned char *, const unsigned char *); + +bool qUnregisterResourceData(int, const unsigned char *, const unsigned char *, const unsigned char *); + +#ifdef QT_NAMESPACE +} +#endif + +int QT_RCC_MANGLE_NAMESPACE(qInitResources)(); +int QT_RCC_MANGLE_NAMESPACE(qInitResources)() +{ + QT_RCC_PREPEND_NAMESPACE(qRegisterResourceData) + (0x2, qt_resource_struct, qt_resource_name, qt_resource_data); + return 1; +} + +int QT_RCC_MANGLE_NAMESPACE(qCleanupResources)(); +int QT_RCC_MANGLE_NAMESPACE(qCleanupResources)() +{ + QT_RCC_PREPEND_NAMESPACE(qUnregisterResourceData) + (0x2, qt_resource_struct, qt_resource_name, qt_resource_data); + return 1; +} + +namespace { + struct initializer { + initializer() { QT_RCC_MANGLE_NAMESPACE(qInitResources)(); } + ~initializer() { QT_RCC_MANGLE_NAMESPACE(qCleanupResources)(); } + } dummy; +} diff --git a/tests/auto/tools/rcc/data/sizes/size-2-0-35-1.qrc b/tests/auto/tools/rcc/data/sizes/size-2-0-35-1.qrc new file mode 100644 index 0000000000..039c9203ff --- /dev/null +++ b/tests/auto/tools/rcc/data/sizes/size-2-0-35-1.qrc @@ -0,0 +1,8 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource> + <file>data/data-2.txt</file> + <file>data/data-0.txt</file> + <file>data/data-35.txt</file> + <file>data/data-1.txt</file> +</qresource> +</RCC> diff --git a/tests/auto/tools/rcc/rcc.pro b/tests/auto/tools/rcc/rcc.pro index 264b8ecc66..3fdc4132a7 100644 --- a/tests/auto/tools/rcc/rcc.pro +++ b/tests/auto/tools/rcc/rcc.pro @@ -3,3 +3,10 @@ QT = core testlib TARGET = tst_rcc SOURCES += tst_rcc.cpp + +RESOURCES += \ + $$PWD/data/images/images.qrc \ + $$PWD/data/sizes/size-0.qrc \ + $$PWD/data/sizes/size-2-0-35-1.qrc \ + $$PWD/data/sizes/size-1.qrc + diff --git a/tests/auto/tools/rcc/tst_rcc.cpp b/tests/auto/tools/rcc/tst_rcc.cpp index 54a2854ede..0876af6759 100644 --- a/tests/auto/tools/rcc/tst_rcc.cpp +++ b/tests/auto/tools/rcc/tst_rcc.cpp @@ -55,9 +55,13 @@ private slots: void rcc_data(); void rcc(); + void binary_data(); void binary(); + void readback_data(); + void readback(); + void cleanupTestCase(); private: @@ -126,6 +130,13 @@ void tst_rcc::rcc_data() if (dataPath.isEmpty()) QFAIL("data path not found"); QTest::newRow("images") << dataPath << "images.qrc" << "images.expected"; + + QString sizesPath = QFINDTESTDATA("data/sizes/"); + if (sizesPath.isEmpty()) + QFAIL("data path not found"); + QTest::newRow("size-0") << sizesPath << "size-0.qrc" << "size-0.expected"; + QTest::newRow("size-1") << sizesPath << "size-1.qrc" << "size-1.expected"; + QTest::newRow("size-2-0-35-1") << sizesPath << "size-2-0-35-1.qrc" << "size-2-0-35-1.expected"; } void tst_rcc::rcc() @@ -353,6 +364,42 @@ void tst_rcc::binary() QLocale::setDefault(oldDefaultLocale); } +void tst_rcc::readback_data() +{ + QTest::addColumn<QString>("resourceName"); + QTest::addColumn<QString>("fileSystemName"); + + QTest::newRow("data-0") << ":data/data-0.txt" << "sizes/data/data-0.txt"; + QTest::newRow("data-1") << ":data/data-1.txt" << "sizes/data/data-1.txt"; + QTest::newRow("data-2") << ":data/data-2.txt" << "sizes/data/data-2.txt"; + QTest::newRow("data-35") << ":data/data-35.txt" << "sizes/data/data-35.txt"; + QTest::newRow("circle") << ":images/circle.png" << "images/images/circle.png"; + QTest::newRow("square") << ":images/square.png" << "images/images/square.png"; + QTest::newRow("triangle") << ":images/subdir/triangle.png" + << "images/images/subdir/triangle.png"; +} + +void tst_rcc::readback() +{ + QFETCH(QString, resourceName); + QFETCH(QString, fileSystemName); + + QString dataPath = QFINDTESTDATA("data/"); + if (dataPath.isEmpty()) + QFAIL("data path not found"); + + QFile resourceFile(resourceName); + QVERIFY(resourceFile.open(QIODevice::ReadOnly)); + QByteArray resourceData = resourceFile.readAll(); + resourceFile.close(); + + QFile fileSystemFile(dataPath + fileSystemName); + QVERIFY(fileSystemFile.open(QIODevice::ReadOnly)); + QByteArray fileSystemData = fileSystemFile.readAll(); + fileSystemFile.close(); + + QCOMPARE(resourceData, fileSystemData); +} void tst_rcc::cleanupTestCase() { diff --git a/tests/auto/tools/uic/baseline/Dialog_with_Buttons_Bottom.ui.h b/tests/auto/tools/uic/baseline/Dialog_with_Buttons_Bottom.ui.h index 1f5004b2aa..0da4e150ed 100644 --- a/tests/auto/tools/uic/baseline/Dialog_with_Buttons_Bottom.ui.h +++ b/tests/auto/tools/uic/baseline/Dialog_with_Buttons_Bottom.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'Dialog_with_Buttons_Bottom.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/Dialog_with_Buttons_Right.ui.h b/tests/auto/tools/uic/baseline/Dialog_with_Buttons_Right.ui.h index 8dd8b11b62..5acbefd998 100644 --- a/tests/auto/tools/uic/baseline/Dialog_with_Buttons_Right.ui.h +++ b/tests/auto/tools/uic/baseline/Dialog_with_Buttons_Right.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'Dialog_with_Buttons_Right.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/Dialog_without_Buttons.ui.h b/tests/auto/tools/uic/baseline/Dialog_without_Buttons.ui.h index 95acabf3f8..c9d803a090 100644 --- a/tests/auto/tools/uic/baseline/Dialog_without_Buttons.ui.h +++ b/tests/auto/tools/uic/baseline/Dialog_without_Buttons.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'Dialog_without_Buttons.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/Main_Window.ui.h b/tests/auto/tools/uic/baseline/Main_Window.ui.h index 9e59e9f2e5..b0ab882a6f 100644 --- a/tests/auto/tools/uic/baseline/Main_Window.ui.h +++ b/tests/auto/tools/uic/baseline/Main_Window.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'Main_Window.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/Widget.ui.h b/tests/auto/tools/uic/baseline/Widget.ui.h index 4318c2262f..bb62f52bb5 100644 --- a/tests/auto/tools/uic/baseline/Widget.ui.h +++ b/tests/auto/tools/uic/baseline/Widget.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'Widget.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/addlinkdialog.ui.h b/tests/auto/tools/uic/baseline/addlinkdialog.ui.h index 17f51a92f8..fced16ba64 100644 --- a/tests/auto/tools/uic/baseline/addlinkdialog.ui.h +++ b/tests/auto/tools/uic/baseline/addlinkdialog.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'addlinkdialog.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/addtorrentform.ui.h b/tests/auto/tools/uic/baseline/addtorrentform.ui.h index d259a011bf..5fd04eeb21 100644 --- a/tests/auto/tools/uic/baseline/addtorrentform.ui.h +++ b/tests/auto/tools/uic/baseline/addtorrentform.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'addtorrentform.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/authenticationdialog.ui.h b/tests/auto/tools/uic/baseline/authenticationdialog.ui.h index 16c9ce16a8..888e381695 100644 --- a/tests/auto/tools/uic/baseline/authenticationdialog.ui.h +++ b/tests/auto/tools/uic/baseline/authenticationdialog.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'authenticationdialog.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/backside.ui.h b/tests/auto/tools/uic/baseline/backside.ui.h index e7053c632f..b3e04dc810 100644 --- a/tests/auto/tools/uic/baseline/backside.ui.h +++ b/tests/auto/tools/uic/baseline/backside.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'backside.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/batchtranslation.ui.h b/tests/auto/tools/uic/baseline/batchtranslation.ui.h index 8a4dc7a677..fef162ead8 100644 --- a/tests/auto/tools/uic/baseline/batchtranslation.ui.h +++ b/tests/auto/tools/uic/baseline/batchtranslation.ui.h @@ -31,7 +31,7 @@ /******************************************************************************** ** Form generated from reading UI file 'batchtranslation.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/bookmarkdialog.ui.h b/tests/auto/tools/uic/baseline/bookmarkdialog.ui.h index b5a44998be..0e2f10500b 100644 --- a/tests/auto/tools/uic/baseline/bookmarkdialog.ui.h +++ b/tests/auto/tools/uic/baseline/bookmarkdialog.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'bookmarkdialog.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/bookwindow.ui.h b/tests/auto/tools/uic/baseline/bookwindow.ui.h index 8fe5f000e2..b9af619991 100644 --- a/tests/auto/tools/uic/baseline/bookwindow.ui.h +++ b/tests/auto/tools/uic/baseline/bookwindow.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'bookwindow.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/browserwidget.ui.h b/tests/auto/tools/uic/baseline/browserwidget.ui.h index 3db93c34cf..aab629f85b 100644 --- a/tests/auto/tools/uic/baseline/browserwidget.ui.h +++ b/tests/auto/tools/uic/baseline/browserwidget.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'browserwidget.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ @@ -157,13 +157,13 @@ public: { Browser->setWindowTitle(QApplication::translate("Browser", "Qt SQL Browser", nullptr)); insertRowAction->setText(QApplication::translate("Browser", "&Insert Row", nullptr)); -#ifndef QT_NO_STATUSTIP +#if QT_CONFIG(statustip) insertRowAction->setStatusTip(QApplication::translate("Browser", "Inserts a new Row", nullptr)); -#endif // QT_NO_STATUSTIP +#endif // QT_CONFIG(statustip) deleteRowAction->setText(QApplication::translate("Browser", "&Delete Row", nullptr)); -#ifndef QT_NO_STATUSTIP +#if QT_CONFIG(statustip) deleteRowAction->setStatusTip(QApplication::translate("Browser", "Deletes the current Row", nullptr)); -#endif // QT_NO_STATUSTIP +#endif // QT_CONFIG(statustip) groupBox->setTitle(QApplication::translate("Browser", "SQL Query", nullptr)); clearButton->setText(QApplication::translate("Browser", "&Clear", nullptr)); submitButton->setText(QApplication::translate("Browser", "&Submit", nullptr)); diff --git a/tests/auto/tools/uic/baseline/bug18156QTreeWidget.ui.h b/tests/auto/tools/uic/baseline/bug18156QTreeWidget.ui.h index 47f8f22132..1d090bcd86 100644 --- a/tests/auto/tools/uic/baseline/bug18156QTreeWidget.ui.h +++ b/tests/auto/tools/uic/baseline/bug18156QTreeWidget.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'bug18156QTreeWidget.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/calculator.ui.h b/tests/auto/tools/uic/baseline/calculator.ui.h index 0387ee472b..0a374ecf01 100644 --- a/tests/auto/tools/uic/baseline/calculator.ui.h +++ b/tests/auto/tools/uic/baseline/calculator.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'calculator.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/calculatorform.ui.h b/tests/auto/tools/uic/baseline/calculatorform.ui.h index f4661c6237..24027fd3fb 100644 --- a/tests/auto/tools/uic/baseline/calculatorform.ui.h +++ b/tests/auto/tools/uic/baseline/calculatorform.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'calculatorform.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/certificateinfo.ui.h b/tests/auto/tools/uic/baseline/certificateinfo.ui.h index 2aa47d40ad..75e4639d08 100644 --- a/tests/auto/tools/uic/baseline/certificateinfo.ui.h +++ b/tests/auto/tools/uic/baseline/certificateinfo.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'certificateinfo.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/chatdialog.ui.h b/tests/auto/tools/uic/baseline/chatdialog.ui.h index ace6951669..8138a2cdd8 100644 --- a/tests/auto/tools/uic/baseline/chatdialog.ui.h +++ b/tests/auto/tools/uic/baseline/chatdialog.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'chatdialog.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/chatmainwindow.ui.h b/tests/auto/tools/uic/baseline/chatmainwindow.ui.h index 8d4ccd53ae..a3cb6203a9 100644 --- a/tests/auto/tools/uic/baseline/chatmainwindow.ui.h +++ b/tests/auto/tools/uic/baseline/chatmainwindow.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'chatmainwindow.ui' ** -** Created by: Qt User Interface Compiler version 5.9.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ @@ -125,9 +125,9 @@ public: statusbar = new QStatusBar(ChatMainWindow); statusbar->setObjectName(QString::fromUtf8("statusbar")); ChatMainWindow->setStatusBar(statusbar); -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) label->setBuddy(messageLineEdit); -#endif // QT_NO_SHORTCUT +#endif // QT_CONFIG(shortcut) QWidget::setTabOrder(chatHistory, messageLineEdit); QWidget::setTabOrder(messageLineEdit, sendButton); @@ -149,24 +149,24 @@ public: { ChatMainWindow->setWindowTitle(QApplication::translate("ChatMainWindow", "Qt D-Bus Chat", nullptr)); actionQuit->setText(QApplication::translate("ChatMainWindow", "Quit", nullptr)); -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) actionQuit->setShortcut(QApplication::translate("ChatMainWindow", "Ctrl+Q", nullptr)); -#endif // QT_NO_SHORTCUT +#endif // QT_CONFIG(shortcut) actionAboutQt->setText(QApplication::translate("ChatMainWindow", "About Qt...", nullptr)); actionChangeNickname->setText(QApplication::translate("ChatMainWindow", "Change nickname...", nullptr)); -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) actionChangeNickname->setShortcut(QApplication::translate("ChatMainWindow", "Ctrl+N", nullptr)); -#endif // QT_NO_SHORTCUT -#ifndef QT_NO_TOOLTIP +#endif // QT_CONFIG(shortcut) +#if QT_CONFIG(tooltip) chatHistory->setToolTip(QApplication::translate("ChatMainWindow", "Messages sent and received from other users", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) label->setText(QApplication::translate("ChatMainWindow", "Message:", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) sendButton->setToolTip(QApplication::translate("ChatMainWindow", "Sends a message to other people", nullptr)); -#endif // QT_NO_TOOLTIP -#ifndef QT_NO_WHATSTHIS +#endif // QT_CONFIG(tooltip) +#if QT_CONFIG(whatsthis) sendButton->setWhatsThis(QString()); -#endif // QT_NO_WHATSTHIS +#endif // QT_CONFIG(whatsthis) sendButton->setText(QApplication::translate("ChatMainWindow", "Send", nullptr)); menuQuit->setTitle(QApplication::translate("ChatMainWindow", "Help", nullptr)); menuFile->setTitle(QApplication::translate("ChatMainWindow", "File", nullptr)); diff --git a/tests/auto/tools/uic/baseline/chatsetnickname.ui.h b/tests/auto/tools/uic/baseline/chatsetnickname.ui.h index c73dfb2c6e..c735f4b889 100644 --- a/tests/auto/tools/uic/baseline/chatsetnickname.ui.h +++ b/tests/auto/tools/uic/baseline/chatsetnickname.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'chatsetnickname.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/config.ui.h b/tests/auto/tools/uic/baseline/config.ui.h index 8287e0b1ac..71ac8535c7 100644 --- a/tests/auto/tools/uic/baseline/config.ui.h +++ b/tests/auto/tools/uic/baseline/config.ui.h @@ -31,7 +31,7 @@ /******************************************************************************** ** Form generated from reading UI file 'config.ui' ** -** Created by: Qt User Interface Compiler version 5.10.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/connectdialog.ui.h b/tests/auto/tools/uic/baseline/connectdialog.ui.h index a470a6705d..55198d43f3 100644 --- a/tests/auto/tools/uic/baseline/connectdialog.ui.h +++ b/tests/auto/tools/uic/baseline/connectdialog.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'connectdialog.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/controller.ui.h b/tests/auto/tools/uic/baseline/controller.ui.h index 72b0956472..814a0c0430 100644 --- a/tests/auto/tools/uic/baseline/controller.ui.h +++ b/tests/auto/tools/uic/baseline/controller.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'controller.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/cookies.ui.h b/tests/auto/tools/uic/baseline/cookies.ui.h index 144c306874..a3793f6def 100644 --- a/tests/auto/tools/uic/baseline/cookies.ui.h +++ b/tests/auto/tools/uic/baseline/cookies.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'cookies.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/cookiesexceptions.ui.h b/tests/auto/tools/uic/baseline/cookiesexceptions.ui.h index a3bf7a449e..22b06f65a2 100644 --- a/tests/auto/tools/uic/baseline/cookiesexceptions.ui.h +++ b/tests/auto/tools/uic/baseline/cookiesexceptions.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'cookiesexceptions.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/default.ui.h b/tests/auto/tools/uic/baseline/default.ui.h index fafff9d728..af68bac7fd 100644 --- a/tests/auto/tools/uic/baseline/default.ui.h +++ b/tests/auto/tools/uic/baseline/default.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'default.ui' ** -** Created by: Qt User Interface Compiler version 5.10.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ @@ -192,13 +192,13 @@ public: statusbar = new QStatusBar(MainWindow); statusbar->setObjectName(QString::fromUtf8("statusbar")); MainWindow->setStatusBar(statusbar); -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) nameLabel->setBuddy(nameCombo); ageLabel->setBuddy(ageSpinBox); passwordLabel->setBuddy(passwordEdit); label->setBuddy(professionList); countryLabel->setBuddy(professionList); -#endif // QT_NO_SHORTCUT +#endif // QT_CONFIG(shortcut) QWidget::setTabOrder(maleRadioButton, femaleRadioButton); QWidget::setTabOrder(femaleRadioButton, ageSpinBox); QWidget::setTabOrder(ageSpinBox, passwordEdit); @@ -237,36 +237,36 @@ public: nameCombo->setItemText(2, QApplication::translate("MainWindow", "Simon", nullptr)); nameCombo->setItemText(3, QApplication::translate("MainWindow", "Zack", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) nameCombo->setToolTip(QApplication::translate("MainWindow", "Specify your name", nullptr)); -#endif // QT_NO_TOOLTIP -#ifndef QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) +#if QT_CONFIG(tooltip) femaleRadioButton->setToolTip(QApplication::translate("MainWindow", "Check this if you are female", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) femaleRadioButton->setText(QApplication::translate("MainWindow", "&Female", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) agreeCheckBox->setToolTip(QApplication::translate("MainWindow", "Please read the license before checking this", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) agreeCheckBox->setText(QApplication::translate("MainWindow", "I &accept the terms and conditions", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) maleRadioButton->setToolTip(QApplication::translate("MainWindow", "Check this if you are male", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) maleRadioButton->setText(QApplication::translate("MainWindow", "&Male", nullptr)); genderLabel->setText(QApplication::translate("MainWindow", "Gender:", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) ageSpinBox->setToolTip(QApplication::translate("MainWindow", "Specify your age", nullptr)); -#endif // QT_NO_TOOLTIP -#ifndef QT_NO_STATUSTIP +#endif // QT_CONFIG(tooltip) +#if QT_CONFIG(statustip) ageSpinBox->setStatusTip(QApplication::translate("MainWindow", "Specify your age here", nullptr)); -#endif // QT_NO_STATUSTIP +#endif // QT_CONFIG(statustip) ageLabel->setText(QApplication::translate("MainWindow", "&Age:", nullptr)); passwordLabel->setText(QApplication::translate("MainWindow", "&Password:", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) passwordEdit->setToolTip(QApplication::translate("MainWindow", "Specify your password", nullptr)); -#endif // QT_NO_TOOLTIP -#ifndef QT_NO_STATUSTIP +#endif // QT_CONFIG(tooltip) +#if QT_CONFIG(statustip) passwordEdit->setStatusTip(QApplication::translate("MainWindow", "Specify your password here", nullptr)); -#endif // QT_NO_STATUSTIP +#endif // QT_CONFIG(statustip) passwordEdit->setText(QApplication::translate("MainWindow", "Password", nullptr)); label->setText(QApplication::translate("MainWindow", "Profession", nullptr)); countryLabel->setText(QApplication::translate("MainWindow", "&Country", nullptr)); @@ -281,27 +281,27 @@ public: ___qlistwidgetitem2->setText(QApplication::translate("MainWindow", "Fisherman", nullptr)); professionList->setSortingEnabled(__sortingEnabled); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) professionList->setToolTip(QApplication::translate("MainWindow", "Select your profession", nullptr)); -#endif // QT_NO_TOOLTIP -#ifndef QT_NO_STATUSTIP +#endif // QT_CONFIG(tooltip) +#if QT_CONFIG(statustip) professionList->setStatusTip(QApplication::translate("MainWindow", "Select your profession", nullptr)); -#endif // QT_NO_STATUSTIP -#ifndef QT_NO_WHATSTHIS +#endif // QT_CONFIG(statustip) +#if QT_CONFIG(whatsthis) professionList->setWhatsThis(QApplication::translate("MainWindow", "Select your profession", nullptr)); -#endif // QT_NO_WHATSTHIS +#endif // QT_CONFIG(whatsthis) countryCombo->setItemText(0, QApplication::translate("MainWindow", "Germany", nullptr)); countryCombo->setItemText(1, QApplication::translate("MainWindow", "India", nullptr)); countryCombo->setItemText(2, QApplication::translate("MainWindow", "Norway", nullptr)); countryCombo->setItemText(3, QApplication::translate("MainWindow", "United States Of America", nullptr)); countryCombo->setItemText(4, QApplication::translate("MainWindow", "United Kingdom", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) countryCombo->setToolTip(QApplication::translate("MainWindow", "Specify your country", nullptr)); -#endif // QT_NO_TOOLTIP -#ifndef QT_NO_STATUSTIP +#endif // QT_CONFIG(tooltip) +#if QT_CONFIG(statustip) countryCombo->setStatusTip(QApplication::translate("MainWindow", "Specify your country here", nullptr)); -#endif // QT_NO_STATUSTIP +#endif // QT_CONFIG(statustip) menu_File->setTitle(QApplication::translate("MainWindow", "&File", nullptr)); menu_Help->setTitle(QApplication::translate("MainWindow", "&Help", nullptr)); } // retranslateUi diff --git a/tests/auto/tools/uic/baseline/dialog.ui.h b/tests/auto/tools/uic/baseline/dialog.ui.h index 2a159312b9..4c0edf4127 100644 --- a/tests/auto/tools/uic/baseline/dialog.ui.h +++ b/tests/auto/tools/uic/baseline/dialog.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'dialog.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/downloaditem.ui.h b/tests/auto/tools/uic/baseline/downloaditem.ui.h index f0e8e88307..b4a5e23226 100644 --- a/tests/auto/tools/uic/baseline/downloaditem.ui.h +++ b/tests/auto/tools/uic/baseline/downloaditem.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'downloaditem.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/downloads.ui.h b/tests/auto/tools/uic/baseline/downloads.ui.h index 1df992d30f..5b9f405f8f 100644 --- a/tests/auto/tools/uic/baseline/downloads.ui.h +++ b/tests/auto/tools/uic/baseline/downloads.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'downloads.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/embeddeddialog.ui.h b/tests/auto/tools/uic/baseline/embeddeddialog.ui.h index 194ff578e8..eb07718da3 100644 --- a/tests/auto/tools/uic/baseline/embeddeddialog.ui.h +++ b/tests/auto/tools/uic/baseline/embeddeddialog.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'embeddeddialog.ui' ** -** Created by: Qt User Interface Compiler version 5.10.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ @@ -83,12 +83,12 @@ public: formLayout->setWidget(3, QFormLayout::FieldRole, spacing); -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) label->setBuddy(layoutDirection); label_2->setBuddy(fontComboBox); label_3->setBuddy(style); label_4->setBuddy(spacing); -#endif // QT_NO_SHORTCUT +#endif // QT_CONFIG(shortcut) retranslateUi(embeddedDialog); diff --git a/tests/auto/tools/uic/baseline/filespage.ui.h b/tests/auto/tools/uic/baseline/filespage.ui.h index 29ed981a8a..8738109bd5 100644 --- a/tests/auto/tools/uic/baseline/filespage.ui.h +++ b/tests/auto/tools/uic/baseline/filespage.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'filespage.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/filternamedialog.ui.h b/tests/auto/tools/uic/baseline/filternamedialog.ui.h index 716c291fdd..8e5782c387 100644 --- a/tests/auto/tools/uic/baseline/filternamedialog.ui.h +++ b/tests/auto/tools/uic/baseline/filternamedialog.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'filternamedialog.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/filterpage.ui.h b/tests/auto/tools/uic/baseline/filterpage.ui.h index f6610fdc4d..a899938e33 100644 --- a/tests/auto/tools/uic/baseline/filterpage.ui.h +++ b/tests/auto/tools/uic/baseline/filterpage.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'filterpage.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/finddialog.ui.h b/tests/auto/tools/uic/baseline/finddialog.ui.h index a427be3614..843c747b72 100644 --- a/tests/auto/tools/uic/baseline/finddialog.ui.h +++ b/tests/auto/tools/uic/baseline/finddialog.ui.h @@ -31,7 +31,7 @@ /******************************************************************************** ** Form generated from reading UI file 'finddialog.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ @@ -172,9 +172,9 @@ public: hboxLayout->addLayout(vboxLayout1); -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) findWhat->setBuddy(led); -#endif // QT_NO_SHORTCUT +#endif // QT_CONFIG(shortcut) QWidget::setTabOrder(led, findNxt); QWidget::setTabOrder(findNxt, cancel); QWidget::setTabOrder(cancel, comments); @@ -194,38 +194,38 @@ public: void retranslateUi(QDialog *FindDialog) { FindDialog->setWindowTitle(QApplication::translate("FindDialog", "Find", nullptr)); -#ifndef QT_NO_WHATSTHIS +#if QT_CONFIG(whatsthis) FindDialog->setWhatsThis(QApplication::translate("FindDialog", "This window allows you to search for some text in the translation source file.", nullptr)); -#endif // QT_NO_WHATSTHIS +#endif // QT_CONFIG(whatsthis) findWhat->setText(QApplication::translate("FindDialog", "&Find what:", nullptr)); -#ifndef QT_NO_WHATSTHIS +#if QT_CONFIG(whatsthis) led->setWhatsThis(QApplication::translate("FindDialog", "Type in the text to search for.", nullptr)); -#endif // QT_NO_WHATSTHIS +#endif // QT_CONFIG(whatsthis) groupBox->setTitle(QApplication::translate("FindDialog", "Options", nullptr)); -#ifndef QT_NO_WHATSTHIS +#if QT_CONFIG(whatsthis) sourceText->setWhatsThis(QApplication::translate("FindDialog", "Source texts are searched when checked.", nullptr)); -#endif // QT_NO_WHATSTHIS +#endif // QT_CONFIG(whatsthis) sourceText->setText(QApplication::translate("FindDialog", "&Source texts", nullptr)); -#ifndef QT_NO_WHATSTHIS +#if QT_CONFIG(whatsthis) translations->setWhatsThis(QApplication::translate("FindDialog", "Translations are searched when checked.", nullptr)); -#endif // QT_NO_WHATSTHIS +#endif // QT_CONFIG(whatsthis) translations->setText(QApplication::translate("FindDialog", "&Translations", nullptr)); -#ifndef QT_NO_WHATSTHIS +#if QT_CONFIG(whatsthis) matchCase->setWhatsThis(QApplication::translate("FindDialog", "Texts such as 'TeX' and 'tex' are considered as different when checked.", nullptr)); -#endif // QT_NO_WHATSTHIS +#endif // QT_CONFIG(whatsthis) matchCase->setText(QApplication::translate("FindDialog", "&Match case", nullptr)); -#ifndef QT_NO_WHATSTHIS +#if QT_CONFIG(whatsthis) comments->setWhatsThis(QApplication::translate("FindDialog", "Comments and contexts are searched when checked.", nullptr)); -#endif // QT_NO_WHATSTHIS +#endif // QT_CONFIG(whatsthis) comments->setText(QApplication::translate("FindDialog", "&Comments", nullptr)); ignoreAccelerators->setText(QApplication::translate("FindDialog", "Ignore &accelerators", nullptr)); -#ifndef QT_NO_WHATSTHIS +#if QT_CONFIG(whatsthis) findNxt->setWhatsThis(QApplication::translate("FindDialog", "Click here to find the next occurrence of the text you typed in.", nullptr)); -#endif // QT_NO_WHATSTHIS +#endif // QT_CONFIG(whatsthis) findNxt->setText(QApplication::translate("FindDialog", "Find Next", nullptr)); -#ifndef QT_NO_WHATSTHIS +#if QT_CONFIG(whatsthis) cancel->setWhatsThis(QApplication::translate("FindDialog", "Click here to close this window.", nullptr)); -#endif // QT_NO_WHATSTHIS +#endif // QT_CONFIG(whatsthis) cancel->setText(QApplication::translate("FindDialog", "Cancel", nullptr)); } // retranslateUi diff --git a/tests/auto/tools/uic/baseline/form.ui.h b/tests/auto/tools/uic/baseline/form.ui.h index ecc63e339b..9fda6daac4 100644 --- a/tests/auto/tools/uic/baseline/form.ui.h +++ b/tests/auto/tools/uic/baseline/form.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'form.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/formwindowsettings.ui.h b/tests/auto/tools/uic/baseline/formwindowsettings.ui.h index d2cfa03edb..e18b72cb5b 100644 --- a/tests/auto/tools/uic/baseline/formwindowsettings.ui.h +++ b/tests/auto/tools/uic/baseline/formwindowsettings.ui.h @@ -31,7 +31,7 @@ /******************************************************************************** ** Form generated from reading UI file 'formwindowsettings.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ @@ -250,12 +250,12 @@ public: gridLayout->addWidget(gridPanel, 1, 0, 1, 2); -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) label_2->setBuddy(defaultSpacingSpinBox); label->setBuddy(defaultMarginSpinBox); label_3->setBuddy(marginFunctionLineEdit); label_3_2->setBuddy(spacingFunctionLineEdit); -#endif // QT_NO_SHORTCUT +#endif // QT_CONFIG(shortcut) QWidget::setTabOrder(authorLineEdit, defaultMarginSpinBox); QWidget::setTabOrder(defaultMarginSpinBox, defaultSpacingSpinBox); QWidget::setTabOrder(defaultSpacingSpinBox, marginFunctionLineEdit); diff --git a/tests/auto/tools/uic/baseline/generalpage.ui.h b/tests/auto/tools/uic/baseline/generalpage.ui.h index bd04285d28..f13cc7faca 100644 --- a/tests/auto/tools/uic/baseline/generalpage.ui.h +++ b/tests/auto/tools/uic/baseline/generalpage.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'generalpage.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/gridalignment.ui.h b/tests/auto/tools/uic/baseline/gridalignment.ui.h index 421f257c9a..c8ce4bc477 100644 --- a/tests/auto/tools/uic/baseline/gridalignment.ui.h +++ b/tests/auto/tools/uic/baseline/gridalignment.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'gridalignment.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/gridpanel.ui.h b/tests/auto/tools/uic/baseline/gridpanel.ui.h index 858b71d0cc..22b639a95f 100644 --- a/tests/auto/tools/uic/baseline/gridpanel.ui.h +++ b/tests/auto/tools/uic/baseline/gridpanel.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'gridpanel.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ @@ -120,10 +120,10 @@ public: vboxLayout->addWidget(m_gridGroupBox); -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) label->setBuddy(m_deltaXSpinBox); label_2->setBuddy(m_deltaYSpinBox); -#endif // QT_NO_SHORTCUT +#endif // QT_CONFIG(shortcut) retranslateUi(qdesigner_internal__GridPanel); diff --git a/tests/auto/tools/uic/baseline/helpdialog.ui.h b/tests/auto/tools/uic/baseline/helpdialog.ui.h index abcf280cf9..070f0484f1 100644 --- a/tests/auto/tools/uic/baseline/helpdialog.ui.h +++ b/tests/auto/tools/uic/baseline/helpdialog.ui.h @@ -31,7 +31,7 @@ /******************************************************************************** ** Form generated from reading UI file 'helpdialog.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ @@ -273,11 +273,11 @@ public: vboxLayout->addWidget(framePrepare); -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) TextLabel1->setBuddy(editIndex); TextLabel1_2->setBuddy(termsEdit); TextLabel2->setBuddy(resultBox); -#endif // QT_NO_SHORTCUT +#endif // QT_CONFIG(shortcut) QWidget::setTabOrder(tabWidget, listContents); QWidget::setTabOrder(listContents, editIndex); QWidget::setTabOrder(editIndex, listIndex); @@ -297,73 +297,73 @@ public: void retranslateUi(QWidget *HelpDialog) { HelpDialog->setWindowTitle(QApplication::translate("HelpDialog", "Help", nullptr)); -#ifndef QT_NO_WHATSTHIS +#if QT_CONFIG(whatsthis) HelpDialog->setWhatsThis(QApplication::translate("HelpDialog", "<b>Help</b><p>Choose the topic you want help on from the contents list, or search the index for keywords.</p>", nullptr)); -#endif // QT_NO_WHATSTHIS -#ifndef QT_NO_WHATSTHIS +#endif // QT_CONFIG(whatsthis) +#if QT_CONFIG(whatsthis) tabWidget->setWhatsThis(QApplication::translate("HelpDialog", "Displays help topics organized by category, index or bookmarks. Another tab inherits the full text search.", nullptr)); -#endif // QT_NO_WHATSTHIS +#endif // QT_CONFIG(whatsthis) QTreeWidgetItem *___qtreewidgetitem = listContents->headerItem(); ___qtreewidgetitem->setText(0, QApplication::translate("HelpDialog", "column 1", nullptr)); -#ifndef QT_NO_WHATSTHIS +#if QT_CONFIG(whatsthis) listContents->setWhatsThis(QApplication::translate("HelpDialog", "<b>Help topics organized by category.</b><p>Double-click an item to see the topics in that category. To view a topic, just double-click it.</p>", nullptr)); -#endif // QT_NO_WHATSTHIS +#endif // QT_CONFIG(whatsthis) tabWidget->setTabText(tabWidget->indexOf(contentPage), QApplication::translate("HelpDialog", "Con&tents", nullptr)); TextLabel1->setText(QApplication::translate("HelpDialog", "&Look For:", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) editIndex->setToolTip(QApplication::translate("HelpDialog", "Enter keyword", nullptr)); -#endif // QT_NO_TOOLTIP -#ifndef QT_NO_WHATSTHIS +#endif // QT_CONFIG(tooltip) +#if QT_CONFIG(whatsthis) editIndex->setWhatsThis(QApplication::translate("HelpDialog", "<b>Enter a keyword.</b><p>The list will select an item that matches the entered string best.</p>", nullptr)); -#endif // QT_NO_WHATSTHIS -#ifndef QT_NO_WHATSTHIS +#endif // QT_CONFIG(whatsthis) +#if QT_CONFIG(whatsthis) listIndex->setWhatsThis(QApplication::translate("HelpDialog", "<b>List of available help topics.</b><p>Double-click on an item to open its help page. If more than one is found, you must specify which page you want.</p>", nullptr)); -#endif // QT_NO_WHATSTHIS +#endif // QT_CONFIG(whatsthis) tabWidget->setTabText(tabWidget->indexOf(indexPage), QApplication::translate("HelpDialog", "&Index", nullptr)); QTreeWidgetItem *___qtreewidgetitem1 = listBookmarks->headerItem(); ___qtreewidgetitem1->setText(0, QApplication::translate("HelpDialog", "column 1", nullptr)); -#ifndef QT_NO_WHATSTHIS +#if QT_CONFIG(whatsthis) listBookmarks->setWhatsThis(QApplication::translate("HelpDialog", "Displays the list of bookmarks.", nullptr)); -#endif // QT_NO_WHATSTHIS -#ifndef QT_NO_TOOLTIP +#endif // QT_CONFIG(whatsthis) +#if QT_CONFIG(tooltip) buttonAdd->setToolTip(QApplication::translate("HelpDialog", "Add new bookmark", nullptr)); -#endif // QT_NO_TOOLTIP -#ifndef QT_NO_WHATSTHIS +#endif // QT_CONFIG(tooltip) +#if QT_CONFIG(whatsthis) buttonAdd->setWhatsThis(QApplication::translate("HelpDialog", "Add the currently displayed page as a new bookmark.", nullptr)); -#endif // QT_NO_WHATSTHIS +#endif // QT_CONFIG(whatsthis) buttonAdd->setText(QApplication::translate("HelpDialog", "&New", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) buttonRemove->setToolTip(QApplication::translate("HelpDialog", "Delete bookmark", nullptr)); -#endif // QT_NO_TOOLTIP -#ifndef QT_NO_WHATSTHIS +#endif // QT_CONFIG(tooltip) +#if QT_CONFIG(whatsthis) buttonRemove->setWhatsThis(QApplication::translate("HelpDialog", "Delete the selected bookmark.", nullptr)); -#endif // QT_NO_WHATSTHIS +#endif // QT_CONFIG(whatsthis) buttonRemove->setText(QApplication::translate("HelpDialog", "&Delete", nullptr)); tabWidget->setTabText(tabWidget->indexOf(bookmarkPage), QApplication::translate("HelpDialog", "&Bookmarks", nullptr)); TextLabel1_2->setText(QApplication::translate("HelpDialog", "Searching f&or:", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) termsEdit->setToolTip(QApplication::translate("HelpDialog", "Enter searchword(s).", nullptr)); -#endif // QT_NO_TOOLTIP -#ifndef QT_NO_WHATSTHIS +#endif // QT_CONFIG(tooltip) +#if QT_CONFIG(whatsthis) termsEdit->setWhatsThis(QApplication::translate("HelpDialog", "<b>Enter search word(s).</b><p>Enter here the word(s) you are looking for. The words may contain wildcards (*). For a sequence of words quote them.</p>", nullptr)); -#endif // QT_NO_WHATSTHIS -#ifndef QT_NO_WHATSTHIS +#endif // QT_CONFIG(whatsthis) +#if QT_CONFIG(whatsthis) resultBox->setWhatsThis(QApplication::translate("HelpDialog", "<b>Found documents</b><p>This list contains all found documents from the last search. The documents are ordered, i.e. the first document has the most matches.</p>", nullptr)); -#endif // QT_NO_WHATSTHIS +#endif // QT_CONFIG(whatsthis) TextLabel2->setText(QApplication::translate("HelpDialog", "Found &Documents:", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) helpButton->setToolTip(QApplication::translate("HelpDialog", "Display the help page.", nullptr)); -#endif // QT_NO_TOOLTIP -#ifndef QT_NO_WHATSTHIS +#endif // QT_CONFIG(tooltip) +#if QT_CONFIG(whatsthis) helpButton->setWhatsThis(QApplication::translate("HelpDialog", "Display the help page for the full text search.", nullptr)); -#endif // QT_NO_WHATSTHIS +#endif // QT_CONFIG(whatsthis) helpButton->setText(QApplication::translate("HelpDialog", "He&lp", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) searchButton->setToolTip(QApplication::translate("HelpDialog", "Start searching.", nullptr)); -#endif // QT_NO_TOOLTIP -#ifndef QT_NO_WHATSTHIS +#endif // QT_CONFIG(tooltip) +#if QT_CONFIG(whatsthis) searchButton->setWhatsThis(QApplication::translate("HelpDialog", "Pressing this button starts the search.", nullptr)); -#endif // QT_NO_WHATSTHIS +#endif // QT_CONFIG(whatsthis) searchButton->setText(QApplication::translate("HelpDialog", "&Search", nullptr)); tabWidget->setTabText(tabWidget->indexOf(searchPage), QApplication::translate("HelpDialog", "&Search", nullptr)); labelPrepare->setText(QApplication::translate("HelpDialog", "Preparing...", nullptr)); diff --git a/tests/auto/tools/uic/baseline/history.ui.h b/tests/auto/tools/uic/baseline/history.ui.h index 715312d11a..30477b8fb6 100644 --- a/tests/auto/tools/uic/baseline/history.ui.h +++ b/tests/auto/tools/uic/baseline/history.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'history.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/icontheme.ui.h b/tests/auto/tools/uic/baseline/icontheme.ui.h index 936d6b5cf7..3baf5539ee 100644 --- a/tests/auto/tools/uic/baseline/icontheme.ui.h +++ b/tests/auto/tools/uic/baseline/icontheme.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'icontheme.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/idbased.ui.h b/tests/auto/tools/uic/baseline/idbased.ui.h index e246313e11..0209895a3c 100644 --- a/tests/auto/tools/uic/baseline/idbased.ui.h +++ b/tests/auto/tools/uic/baseline/idbased.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'idbased.ui' ** -** Created by: Qt User Interface Compiler version 5.11.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ @@ -44,15 +44,15 @@ public: void retranslateUi(QWidget *Form) { Form->setWindowTitle(qtTrId("windowTitleId")); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) pushButton->setToolTip(qtTrId("buttonToolTipId")); -#endif // QT_NO_TOOLTIP -#ifndef QT_NO_STATUSTIP +#endif // QT_CONFIG(tooltip) +#if QT_CONFIG(statustip) pushButton->setStatusTip(qtTrId("buttonStatusTipId")); -#endif // QT_NO_STATUSTIP -#ifndef QT_NO_WHATSTHIS +#endif // QT_CONFIG(statustip) +#if QT_CONFIG(whatsthis) pushButton->setWhatsThis(qtTrId("buttonWhatsThisId")); -#endif // QT_NO_WHATSTHIS +#endif // QT_CONFIG(whatsthis) pushButton->setText(qtTrId("buttonTextId")); } // retranslateUi diff --git a/tests/auto/tools/uic/baseline/identifierpage.ui.h b/tests/auto/tools/uic/baseline/identifierpage.ui.h index 322a9cf30a..c0d86de1b3 100644 --- a/tests/auto/tools/uic/baseline/identifierpage.ui.h +++ b/tests/auto/tools/uic/baseline/identifierpage.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'identifierpage.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/imagedialog.ui.h b/tests/auto/tools/uic/baseline/imagedialog.ui.h index e32e7639fa..78384a21e4 100644 --- a/tests/auto/tools/uic/baseline/imagedialog.ui.h +++ b/tests/auto/tools/uic/baseline/imagedialog.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'imagedialog.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/inputpage.ui.h b/tests/auto/tools/uic/baseline/inputpage.ui.h index 9367dec6df..26bcca1ca4 100644 --- a/tests/auto/tools/uic/baseline/inputpage.ui.h +++ b/tests/auto/tools/uic/baseline/inputpage.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'inputpage.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/installdialog.ui.h b/tests/auto/tools/uic/baseline/installdialog.ui.h index 3ec7f69b76..45a0431f15 100644 --- a/tests/auto/tools/uic/baseline/installdialog.ui.h +++ b/tests/auto/tools/uic/baseline/installdialog.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'installdialog.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/languagesdialog.ui.h b/tests/auto/tools/uic/baseline/languagesdialog.ui.h index cf2599fd07..b04d8f1766 100644 --- a/tests/auto/tools/uic/baseline/languagesdialog.ui.h +++ b/tests/auto/tools/uic/baseline/languagesdialog.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'languagesdialog.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ @@ -112,33 +112,33 @@ public: QTreeWidgetItem *___qtreewidgetitem = languagesList->headerItem(); ___qtreewidgetitem->setText(1, QApplication::translate("LanguagesDialog", "File", nullptr)); ___qtreewidgetitem->setText(0, QApplication::translate("LanguagesDialog", "Locale", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) upButton->setToolTip(QApplication::translate("LanguagesDialog", "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n" "p, li { white-space: pre-wrap; }\n" "</style></head><body style=\" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n" "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Move selected language up</p></body></html>", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) upButton->setText(QApplication::translate("LanguagesDialog", "up", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) downButton->setToolTip(QApplication::translate("LanguagesDialog", "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n" "p, li { white-space: pre-wrap; }\n" "</style></head><body style=\" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n" "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;\">Move selected language down</p></body></html>", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) downButton->setText(QApplication::translate("LanguagesDialog", "down", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) removeButton->setToolTip(QApplication::translate("LanguagesDialog", "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n" "p, li { white-space: pre-wrap; }\n" "</style></head><body style=\" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n" "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Remove selected language</p></body></html>", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) removeButton->setText(QApplication::translate("LanguagesDialog", "remove", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) openFileButton->setToolTip(QApplication::translate("LanguagesDialog", "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n" "p, li { white-space: pre-wrap; }\n" "</style></head><body style=\" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n" "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Open auxiliary language files</p></body></html>", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) openFileButton->setText(QApplication::translate("LanguagesDialog", "...", nullptr)); okButton->setText(QApplication::translate("LanguagesDialog", "OK", nullptr)); } // retranslateUi diff --git a/tests/auto/tools/uic/baseline/listwidgeteditor.ui.h b/tests/auto/tools/uic/baseline/listwidgeteditor.ui.h index 14067ced18..56df9f1beb 100644 --- a/tests/auto/tools/uic/baseline/listwidgeteditor.ui.h +++ b/tests/auto/tools/uic/baseline/listwidgeteditor.ui.h @@ -31,7 +31,7 @@ /******************************************************************************** ** Form generated from reading UI file 'listwidgeteditor.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ @@ -174,24 +174,24 @@ public: { qdesigner_internal__ListWidgetEditor->setWindowTitle(QApplication::translate("qdesigner_internal::ListWidgetEditor", "Dialog", nullptr)); groupBox->setTitle(QApplication::translate("qdesigner_internal::ListWidgetEditor", "Items List", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) listWidget->setToolTip(QApplication::translate("qdesigner_internal::ListWidgetEditor", "Items List", nullptr)); -#endif // QT_NO_TOOLTIP -#ifndef QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) +#if QT_CONFIG(tooltip) newItemButton->setToolTip(QApplication::translate("qdesigner_internal::ListWidgetEditor", "New Item", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) newItemButton->setText(QApplication::translate("qdesigner_internal::ListWidgetEditor", "&New", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) deleteItemButton->setToolTip(QApplication::translate("qdesigner_internal::ListWidgetEditor", "Delete Item", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) deleteItemButton->setText(QApplication::translate("qdesigner_internal::ListWidgetEditor", "&Delete", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) moveItemUpButton->setToolTip(QApplication::translate("qdesigner_internal::ListWidgetEditor", "Move Item Up", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) moveItemUpButton->setText(QApplication::translate("qdesigner_internal::ListWidgetEditor", "U", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) moveItemDownButton->setToolTip(QApplication::translate("qdesigner_internal::ListWidgetEditor", "Move Item Down", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) moveItemDownButton->setText(QApplication::translate("qdesigner_internal::ListWidgetEditor", "D", nullptr)); label->setText(QApplication::translate("qdesigner_internal::ListWidgetEditor", "Icon", nullptr)); } // retranslateUi diff --git a/tests/auto/tools/uic/baseline/mainwindow.ui.h b/tests/auto/tools/uic/baseline/mainwindow.ui.h index fe84d0baa3..ed13a49860 100644 --- a/tests/auto/tools/uic/baseline/mainwindow.ui.h +++ b/tests/auto/tools/uic/baseline/mainwindow.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'mainwindow.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/mydialog.ui.h b/tests/auto/tools/uic/baseline/mydialog.ui.h index 1a784d1b0a..940e13484a 100644 --- a/tests/auto/tools/uic/baseline/mydialog.ui.h +++ b/tests/auto/tools/uic/baseline/mydialog.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'mydialog.ui' ** -** Created by: Qt User Interface Compiler version 5.9.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ @@ -59,9 +59,9 @@ public: MyDialog->setWindowTitle(QApplication::translate("MyDialog", "Mach 2!", nullptr)); aLabel->setText(QApplication::translate("MyDialog", "Join the life in the fastlane; - PCH enable your project today! -", nullptr)); aButton->setText(QApplication::translate("MyDialog", "&Quit", nullptr)); -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) aButton->setShortcut(QApplication::translate("MyDialog", "Alt+Q", nullptr)); -#endif // QT_NO_SHORTCUT +#endif // QT_CONFIG(shortcut) } // retranslateUi }; diff --git a/tests/auto/tools/uic/baseline/myform.ui.h b/tests/auto/tools/uic/baseline/myform.ui.h index d3a08e04c9..20de979fb5 100644 --- a/tests/auto/tools/uic/baseline/myform.ui.h +++ b/tests/auto/tools/uic/baseline/myform.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'myform.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/newactiondialog.ui.h b/tests/auto/tools/uic/baseline/newactiondialog.ui.h index ca99ab8356..6b8f8bb9d7 100644 --- a/tests/auto/tools/uic/baseline/newactiondialog.ui.h +++ b/tests/auto/tools/uic/baseline/newactiondialog.ui.h @@ -31,7 +31,7 @@ /******************************************************************************** ** Form generated from reading UI file 'newactiondialog.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ @@ -143,11 +143,11 @@ public: verticalLayout->addWidget(buttonBox); -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) label->setBuddy(editActionText); label_3->setBuddy(editObjectName); label_2->setBuddy(iconSelector); -#endif // QT_NO_SHORTCUT +#endif // QT_CONFIG(shortcut) QWidget::setTabOrder(editActionText, editObjectName); retranslateUi(qdesigner_internal__NewActionDialog); diff --git a/tests/auto/tools/uic/baseline/newdynamicpropertydialog.ui.h b/tests/auto/tools/uic/baseline/newdynamicpropertydialog.ui.h index f5fd6f1fa4..96b52a6549 100644 --- a/tests/auto/tools/uic/baseline/newdynamicpropertydialog.ui.h +++ b/tests/auto/tools/uic/baseline/newdynamicpropertydialog.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'newdynamicpropertydialog.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/newform.ui.h b/tests/auto/tools/uic/baseline/newform.ui.h index 80e70dcf66..ff4746a500 100644 --- a/tests/auto/tools/uic/baseline/newform.ui.h +++ b/tests/auto/tools/uic/baseline/newform.ui.h @@ -31,7 +31,7 @@ /******************************************************************************** ** Form generated from reading UI file 'newform.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/orderdialog.ui.h b/tests/auto/tools/uic/baseline/orderdialog.ui.h index 0ee08257f4..26dbacf133 100644 --- a/tests/auto/tools/uic/baseline/orderdialog.ui.h +++ b/tests/auto/tools/uic/baseline/orderdialog.ui.h @@ -31,7 +31,7 @@ /******************************************************************************** ** Form generated from reading UI file 'orderdialog.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ @@ -132,12 +132,12 @@ public: { qdesigner_internal__OrderDialog->setWindowTitle(QApplication::translate("qdesigner_internal::OrderDialog", "Change Page Order", nullptr)); groupBox->setTitle(QApplication::translate("qdesigner_internal::OrderDialog", "Page Order", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) upButton->setToolTip(QApplication::translate("qdesigner_internal::OrderDialog", "Move page up", nullptr)); -#endif // QT_NO_TOOLTIP -#ifndef QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) +#if QT_CONFIG(tooltip) downButton->setToolTip(QApplication::translate("qdesigner_internal::OrderDialog", "Move page down", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) } // retranslateUi }; diff --git a/tests/auto/tools/uic/baseline/outputpage.ui.h b/tests/auto/tools/uic/baseline/outputpage.ui.h index 00491bb3d8..127f20d9fe 100644 --- a/tests/auto/tools/uic/baseline/outputpage.ui.h +++ b/tests/auto/tools/uic/baseline/outputpage.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'outputpage.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/pagefold.ui.h b/tests/auto/tools/uic/baseline/pagefold.ui.h index c1ff03648d..bcd11c14ff 100644 --- a/tests/auto/tools/uic/baseline/pagefold.ui.h +++ b/tests/auto/tools/uic/baseline/pagefold.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'pagefold.ui' ** -** Created by: Qt User Interface Compiler version 5.10.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ @@ -213,13 +213,13 @@ public: statusbar = new QStatusBar(MainWindow); statusbar->setObjectName(QString::fromUtf8("statusbar")); MainWindow->setStatusBar(statusbar); -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) ageLabel->setBuddy(ageSpinBox); nameLabel->setBuddy(nameCombo); passwordLabel->setBuddy(passwordEdit); label->setBuddy(professionList); countryLabel->setBuddy(professionList); -#endif // QT_NO_SHORTCUT +#endif // QT_CONFIG(shortcut) menubar->addAction(menu_File->menuAction()); menubar->addAction(menu_Help->menuAction()); @@ -252,35 +252,35 @@ public: nameCombo->setItemText(2, QApplication::translate("MainWindow", "Simon", nullptr)); nameCombo->setItemText(3, QApplication::translate("MainWindow", "Zack", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) nameCombo->setToolTip(QApplication::translate("MainWindow", "Specify your name", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) femaleRadioButton->setStyleSheet(QApplication::translate("MainWindow", "Check this if you are female", nullptr)); femaleRadioButton->setText(QApplication::translate("MainWindow", "&Female", nullptr)); genderLabel->setText(QApplication::translate("MainWindow", "Gender:", nullptr)); ageLabel->setText(QApplication::translate("MainWindow", "&Age:", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) maleRadioButton->setToolTip(QApplication::translate("MainWindow", "Check this if you are male", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) maleRadioButton->setText(QApplication::translate("MainWindow", "&Male", nullptr)); nameLabel->setText(QApplication::translate("MainWindow", "&Name:", nullptr)); passwordLabel->setText(QApplication::translate("MainWindow", "&Password:", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) ageSpinBox->setToolTip(QApplication::translate("MainWindow", "Specify your age", nullptr)); -#endif // QT_NO_TOOLTIP -#ifndef QT_NO_STATUSTIP +#endif // QT_CONFIG(tooltip) +#if QT_CONFIG(statustip) ageSpinBox->setStatusTip(QApplication::translate("MainWindow", "Specify your age", nullptr)); -#endif // QT_NO_STATUSTIP -#ifndef QT_NO_TOOLTIP +#endif // QT_CONFIG(statustip) +#if QT_CONFIG(tooltip) agreeCheckBox->setToolTip(QApplication::translate("MainWindow", "Please read the LICENSE file before checking", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) agreeCheckBox->setText(QApplication::translate("MainWindow", "I &accept the terms and &conditions", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) passwordEdit->setToolTip(QApplication::translate("MainWindow", "Specify your password", nullptr)); -#endif // QT_NO_TOOLTIP -#ifndef QT_NO_STATUSTIP +#endif // QT_CONFIG(tooltip) +#if QT_CONFIG(statustip) passwordEdit->setStatusTip(QApplication::translate("MainWindow", "Specify your password", nullptr)); -#endif // QT_NO_STATUSTIP +#endif // QT_CONFIG(statustip) passwordEdit->setText(QApplication::translate("MainWindow", "Password", nullptr)); const bool __sortingEnabled = professionList->isSortingEnabled(); @@ -293,15 +293,15 @@ public: ___qlistwidgetitem2->setText(QApplication::translate("MainWindow", "Fisherman", nullptr)); professionList->setSortingEnabled(__sortingEnabled); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) professionList->setToolTip(QApplication::translate("MainWindow", "Select your profession", nullptr)); -#endif // QT_NO_TOOLTIP -#ifndef QT_NO_STATUSTIP +#endif // QT_CONFIG(tooltip) +#if QT_CONFIG(statustip) professionList->setStatusTip(QApplication::translate("MainWindow", "Specify your name here", nullptr)); -#endif // QT_NO_STATUSTIP -#ifndef QT_NO_WHATSTHIS +#endif // QT_CONFIG(statustip) +#if QT_CONFIG(whatsthis) professionList->setWhatsThis(QApplication::translate("MainWindow", "Specify your name here", nullptr)); -#endif // QT_NO_WHATSTHIS +#endif // QT_CONFIG(whatsthis) label->setText(QApplication::translate("MainWindow", "Profession:", nullptr)); countryCombo->setItemText(0, QApplication::translate("MainWindow", "Egypt", nullptr)); countryCombo->setItemText(1, QApplication::translate("MainWindow", "France", nullptr)); @@ -311,12 +311,12 @@ public: countryCombo->setItemText(5, QApplication::translate("MainWindow", "Korea", nullptr)); countryCombo->setItemText(6, QApplication::translate("MainWindow", "Norway", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) countryCombo->setToolTip(QApplication::translate("MainWindow", "Specify country of origin", nullptr)); -#endif // QT_NO_TOOLTIP -#ifndef QT_NO_STATUSTIP +#endif // QT_CONFIG(tooltip) +#if QT_CONFIG(statustip) countryCombo->setStatusTip(QApplication::translate("MainWindow", "Specify country of origin", nullptr)); -#endif // QT_NO_STATUSTIP +#endif // QT_CONFIG(statustip) countryLabel->setText(QApplication::translate("MainWindow", "Pro&fession", nullptr)); menu_File->setTitle(QApplication::translate("MainWindow", "&File", nullptr)); menu_Help->setTitle(QApplication::translate("MainWindow", "&Help", nullptr)); diff --git a/tests/auto/tools/uic/baseline/paletteeditor.ui.h b/tests/auto/tools/uic/baseline/paletteeditor.ui.h index 0061164960..9be067eec3 100644 --- a/tests/auto/tools/uic/baseline/paletteeditor.ui.h +++ b/tests/auto/tools/uic/baseline/paletteeditor.ui.h @@ -31,7 +31,7 @@ /******************************************************************************** ** Form generated from reading UI file 'paletteeditor.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/passworddialog.ui.h b/tests/auto/tools/uic/baseline/passworddialog.ui.h index 9ab95c4de9..4f59efabb9 100644 --- a/tests/auto/tools/uic/baseline/passworddialog.ui.h +++ b/tests/auto/tools/uic/baseline/passworddialog.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'passworddialog.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/pathpage.ui.h b/tests/auto/tools/uic/baseline/pathpage.ui.h index eb151f9550..b71f76e3a5 100644 --- a/tests/auto/tools/uic/baseline/pathpage.ui.h +++ b/tests/auto/tools/uic/baseline/pathpage.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'pathpage.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/phrasebookbox.ui.h b/tests/auto/tools/uic/baseline/phrasebookbox.ui.h index 27a0fa79ed..9d7d5e8983 100644 --- a/tests/auto/tools/uic/baseline/phrasebookbox.ui.h +++ b/tests/auto/tools/uic/baseline/phrasebookbox.ui.h @@ -31,7 +31,7 @@ /******************************************************************************** ** Form generated from reading UI file 'phrasebookbox.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ @@ -165,11 +165,11 @@ public: unnamed->addLayout(buttonLayout); -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) target->setBuddy(targetLed); source->setBuddy(sourceLed); definition->setBuddy(definitionLed); -#endif // QT_NO_SHORTCUT +#endif // QT_CONFIG(shortcut) QWidget::setTabOrder(sourceLed, targetLed); QWidget::setTabOrder(targetLed, definitionLed); QWidget::setTabOrder(definitionLed, newBut); @@ -185,36 +185,36 @@ public: void retranslateUi(QDialog *PhraseBookBox) { PhraseBookBox->setWindowTitle(QApplication::translate("PhraseBookBox", "Edit Phrase Book", nullptr)); -#ifndef QT_NO_WHATSTHIS +#if QT_CONFIG(whatsthis) PhraseBookBox->setWhatsThis(QApplication::translate("PhraseBookBox", "This window allows you to add, modify, or delete phrases in a phrase book.", nullptr)); -#endif // QT_NO_WHATSTHIS +#endif // QT_CONFIG(whatsthis) target->setText(QApplication::translate("PhraseBookBox", "&Translation:", nullptr)); -#ifndef QT_NO_WHATSTHIS +#if QT_CONFIG(whatsthis) targetLed->setWhatsThis(QApplication::translate("PhraseBookBox", "This is the phrase in the target language corresponding to the source phrase.", nullptr)); -#endif // QT_NO_WHATSTHIS +#endif // QT_CONFIG(whatsthis) source->setText(QApplication::translate("PhraseBookBox", "S&ource phrase:", nullptr)); -#ifndef QT_NO_WHATSTHIS +#if QT_CONFIG(whatsthis) definitionLed->setWhatsThis(QApplication::translate("PhraseBookBox", "This is a definition for the source phrase.", nullptr)); -#endif // QT_NO_WHATSTHIS -#ifndef QT_NO_WHATSTHIS +#endif // QT_CONFIG(whatsthis) +#if QT_CONFIG(whatsthis) sourceLed->setWhatsThis(QApplication::translate("PhraseBookBox", "This is the phrase in the source language.", nullptr)); -#endif // QT_NO_WHATSTHIS +#endif // QT_CONFIG(whatsthis) definition->setText(QApplication::translate("PhraseBookBox", "&Definition:", nullptr)); -#ifndef QT_NO_WHATSTHIS +#if QT_CONFIG(whatsthis) newBut->setWhatsThis(QApplication::translate("PhraseBookBox", "Click here to add the phrase to the phrase book.", nullptr)); -#endif // QT_NO_WHATSTHIS +#endif // QT_CONFIG(whatsthis) newBut->setText(QApplication::translate("PhraseBookBox", "&New Phrase", nullptr)); -#ifndef QT_NO_WHATSTHIS +#if QT_CONFIG(whatsthis) removeBut->setWhatsThis(QApplication::translate("PhraseBookBox", "Click here to remove the phrase from the phrase book.", nullptr)); -#endif // QT_NO_WHATSTHIS +#endif // QT_CONFIG(whatsthis) removeBut->setText(QApplication::translate("PhraseBookBox", "&Remove Phrase", nullptr)); -#ifndef QT_NO_WHATSTHIS +#if QT_CONFIG(whatsthis) saveBut->setWhatsThis(QApplication::translate("PhraseBookBox", "Click here to save the changes made.", nullptr)); -#endif // QT_NO_WHATSTHIS +#endif // QT_CONFIG(whatsthis) saveBut->setText(QApplication::translate("PhraseBookBox", "&Save", nullptr)); -#ifndef QT_NO_WHATSTHIS +#if QT_CONFIG(whatsthis) closeBut->setWhatsThis(QApplication::translate("PhraseBookBox", "Click here to close this window.", nullptr)); -#endif // QT_NO_WHATSTHIS +#endif // QT_CONFIG(whatsthis) closeBut->setText(QApplication::translate("PhraseBookBox", "Close", nullptr)); } // retranslateUi diff --git a/tests/auto/tools/uic/baseline/plugindialog.ui.h b/tests/auto/tools/uic/baseline/plugindialog.ui.h index 3634b8436f..d25bfd1316 100644 --- a/tests/auto/tools/uic/baseline/plugindialog.ui.h +++ b/tests/auto/tools/uic/baseline/plugindialog.ui.h @@ -31,7 +31,7 @@ /******************************************************************************** ** Form generated from reading UI file 'plugindialog.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/preferencesdialog.ui.h b/tests/auto/tools/uic/baseline/preferencesdialog.ui.h index 289e6775b4..d81823fe75 100644 --- a/tests/auto/tools/uic/baseline/preferencesdialog.ui.h +++ b/tests/auto/tools/uic/baseline/preferencesdialog.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'preferencesdialog.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/previewconfigurationwidget.ui.h b/tests/auto/tools/uic/baseline/previewconfigurationwidget.ui.h index 3c729b9c65..cabdedeb97 100644 --- a/tests/auto/tools/uic/baseline/previewconfigurationwidget.ui.h +++ b/tests/auto/tools/uic/baseline/previewconfigurationwidget.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'previewconfigurationwidget.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/previewdialogbase.ui.h b/tests/auto/tools/uic/baseline/previewdialogbase.ui.h index 8d4c0dae9f..7c86215077 100644 --- a/tests/auto/tools/uic/baseline/previewdialogbase.ui.h +++ b/tests/auto/tools/uic/baseline/previewdialogbase.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'previewdialogbase.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ @@ -156,10 +156,10 @@ public: vboxLayout->addLayout(hboxLayout2); -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) label->setBuddy(paperSizeCombo); label_2->setBuddy(paperOrientationCombo); -#endif // QT_NO_SHORTCUT +#endif // QT_CONFIG(shortcut) retranslateUi(PreviewDialogBase); QObject::connect(buttonBox, SIGNAL(accepted()), PreviewDialogBase, SLOT(accept())); diff --git a/tests/auto/tools/uic/baseline/previewwidget.ui.h b/tests/auto/tools/uic/baseline/previewwidget.ui.h index 6e359416c8..a423ee7ff4 100644 --- a/tests/auto/tools/uic/baseline/previewwidget.ui.h +++ b/tests/auto/tools/uic/baseline/previewwidget.ui.h @@ -31,7 +31,7 @@ /******************************************************************************** ** Form generated from reading UI file 'previewwidget.ui' ** -** Created by: Qt User Interface Compiler version 5.10.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/proxy.ui.h b/tests/auto/tools/uic/baseline/proxy.ui.h index a1bc287190..47a15cc31b 100644 --- a/tests/auto/tools/uic/baseline/proxy.ui.h +++ b/tests/auto/tools/uic/baseline/proxy.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'proxy.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/qfiledialog.ui.h b/tests/auto/tools/uic/baseline/qfiledialog.ui.h index 53607db449..a544afa31d 100644 --- a/tests/auto/tools/uic/baseline/qfiledialog.ui.h +++ b/tests/auto/tools/uic/baseline/qfiledialog.ui.h @@ -31,7 +31,7 @@ /******************************************************************************** ** Form generated from reading UI file 'qfiledialog.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ @@ -272,24 +272,24 @@ public: void retranslateUi(QDialog *QFileDialog) { lookInLabel->setText(QApplication::translate("QFileDialog", "Look in:", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) backButton->setToolTip(QApplication::translate("QFileDialog", "Back", nullptr)); -#endif // QT_NO_TOOLTIP -#ifndef QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) +#if QT_CONFIG(tooltip) forwardButton->setToolTip(QApplication::translate("QFileDialog", "Forward", nullptr)); -#endif // QT_NO_TOOLTIP -#ifndef QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) +#if QT_CONFIG(tooltip) toParentButton->setToolTip(QApplication::translate("QFileDialog", "Parent Directory", nullptr)); -#endif // QT_NO_TOOLTIP -#ifndef QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) +#if QT_CONFIG(tooltip) newFolderButton->setToolTip(QApplication::translate("QFileDialog", "Create New Folder", nullptr)); -#endif // QT_NO_TOOLTIP -#ifndef QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) +#if QT_CONFIG(tooltip) listModeButton->setToolTip(QApplication::translate("QFileDialog", "List View", nullptr)); -#endif // QT_NO_TOOLTIP -#ifndef QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) +#if QT_CONFIG(tooltip) detailModeButton->setToolTip(QApplication::translate("QFileDialog", "Detail View", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) fileTypeLabel->setText(QApplication::translate("QFileDialog", "Files of type:", nullptr)); Q_UNUSED(QFileDialog); } // retranslateUi diff --git a/tests/auto/tools/uic/baseline/qpagesetupwidget.ui.h b/tests/auto/tools/uic/baseline/qpagesetupwidget.ui.h index a5379bc468..4227f38187 100644 --- a/tests/auto/tools/uic/baseline/qpagesetupwidget.ui.h +++ b/tests/auto/tools/uic/baseline/qpagesetupwidget.ui.h @@ -290,12 +290,12 @@ public: gridLayout_3->addItem(verticalSpacer, 6, 0, 1, 1); -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) pageSizeLabel->setBuddy(pageSizeCombo); widthLabel->setBuddy(pageWidth); heightLabel->setBuddy(pageHeight); paperSourceLabel->setBuddy(paperSource); -#endif // QT_NO_SHORTCUT +#endif // QT_CONFIG(shortcut) retranslateUi(QPageSetupWidget); @@ -316,30 +316,30 @@ public: reverseLandscape->setText(QApplication::translate("QPageSetupWidget", "Reverse landscape", nullptr)); reversePortrait->setText(QApplication::translate("QPageSetupWidget", "Reverse portrait", nullptr)); groupBox->setTitle(QApplication::translate("QPageSetupWidget", "Margins", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) topMargin->setToolTip(QApplication::translate("QPageSetupWidget", "top margin", nullptr)); -#endif // QT_NO_TOOLTIP -#ifndef QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(tooltip) +#if QT_CONFIG(accessibility) topMargin->setAccessibleName(QApplication::translate("QPageSetupWidget", "top margin", nullptr)); -#endif // QT_NO_ACCESSIBILITY -#ifndef QT_NO_TOOLTIP +#endif // QT_CONFIG(accessibility) +#if QT_CONFIG(tooltip) leftMargin->setToolTip(QApplication::translate("QPageSetupWidget", "left margin", nullptr)); -#endif // QT_NO_TOOLTIP -#ifndef QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(tooltip) +#if QT_CONFIG(accessibility) leftMargin->setAccessibleName(QApplication::translate("QPageSetupWidget", "left margin", nullptr)); -#endif // QT_NO_ACCESSIBILITY -#ifndef QT_NO_TOOLTIP +#endif // QT_CONFIG(accessibility) +#if QT_CONFIG(tooltip) rightMargin->setToolTip(QApplication::translate("QPageSetupWidget", "right margin", nullptr)); -#endif // QT_NO_TOOLTIP -#ifndef QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(tooltip) +#if QT_CONFIG(accessibility) rightMargin->setAccessibleName(QApplication::translate("QPageSetupWidget", "right margin", nullptr)); -#endif // QT_NO_ACCESSIBILITY -#ifndef QT_NO_TOOLTIP +#endif // QT_CONFIG(accessibility) +#if QT_CONFIG(tooltip) bottomMargin->setToolTip(QApplication::translate("QPageSetupWidget", "bottom margin", nullptr)); -#endif // QT_NO_TOOLTIP -#ifndef QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(tooltip) +#if QT_CONFIG(accessibility) bottomMargin->setAccessibleName(QApplication::translate("QPageSetupWidget", "bottom margin", nullptr)); -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) pagesPerSheetButtonGroup->setTitle(QApplication::translate("QPageSetupWidget", "Page Layout", nullptr)); label->setText(QApplication::translate("QPageSetupWidget", "Page order:", nullptr)); label_2->setText(QApplication::translate("QPageSetupWidget", "Pages per sheet:", nullptr)); diff --git a/tests/auto/tools/uic/baseline/qprintpropertieswidget.ui.h b/tests/auto/tools/uic/baseline/qprintpropertieswidget.ui.h index 8626a9fc3c..bedb6e184d 100644 --- a/tests/auto/tools/uic/baseline/qprintpropertieswidget.ui.h +++ b/tests/auto/tools/uic/baseline/qprintpropertieswidget.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'qprintpropertieswidget.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/qprintsettingsoutput.ui.h b/tests/auto/tools/uic/baseline/qprintsettingsoutput.ui.h index 656b5f9deb..2bf7584a61 100644 --- a/tests/auto/tools/uic/baseline/qprintsettingsoutput.ui.h +++ b/tests/auto/tools/uic/baseline/qprintsettingsoutput.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'qprintsettingsoutput.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ @@ -260,9 +260,9 @@ public: horizontalLayout_2->addWidget(tabs); -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) label->setBuddy(copies); -#endif // QT_NO_SHORTCUT +#endif // QT_CONFIG(shortcut) retranslateUi(QPrintSettingsOutput); QObject::connect(printRange, SIGNAL(toggled(bool)), from, SLOT(setEnabled(bool))); diff --git a/tests/auto/tools/uic/baseline/qprintwidget.ui.h b/tests/auto/tools/uic/baseline/qprintwidget.ui.h index 04b05143c6..d624e28297 100644 --- a/tests/auto/tools/uic/baseline/qprintwidget.ui.h +++ b/tests/auto/tools/uic/baseline/qprintwidget.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'qprintwidget.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ @@ -128,10 +128,10 @@ public: horizontalLayout_2->addWidget(printerGroup); -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) label->setBuddy(printers); lOutput->setBuddy(filename); -#endif // QT_NO_SHORTCUT +#endif // QT_CONFIG(shortcut) retranslateUi(QPrintWidget); diff --git a/tests/auto/tools/uic/baseline/qsqlconnectiondialog.ui.h b/tests/auto/tools/uic/baseline/qsqlconnectiondialog.ui.h index 2131bc6d9b..557918375a 100644 --- a/tests/auto/tools/uic/baseline/qsqlconnectiondialog.ui.h +++ b/tests/auto/tools/uic/baseline/qsqlconnectiondialog.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'qsqlconnectiondialog.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ @@ -179,14 +179,14 @@ public: vboxLayout->addLayout(hboxLayout1); -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) textLabel4->setBuddy(editUsername); textLabel2->setBuddy(comboDriver); textLabel3->setBuddy(editDatabase); textLabel5->setBuddy(editHostname); textLabel5_2->setBuddy(portSpinBox); textLabel4_2->setBuddy(editPassword); -#endif // QT_NO_SHORTCUT +#endif // QT_CONFIG(shortcut) QWidget::setTabOrder(comboDriver, editDatabase); QWidget::setTabOrder(editDatabase, editUsername); QWidget::setTabOrder(editUsername, editPassword); diff --git a/tests/auto/tools/uic/baseline/qtgradientdialog.ui.h b/tests/auto/tools/uic/baseline/qtgradientdialog.ui.h index 805f70e60d..8ef2e5f6de 100644 --- a/tests/auto/tools/uic/baseline/qtgradientdialog.ui.h +++ b/tests/auto/tools/uic/baseline/qtgradientdialog.ui.h @@ -31,7 +31,7 @@ /******************************************************************************** ** Form generated from reading UI file 'qtgradientdialog.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/qtgradienteditor.ui.h b/tests/auto/tools/uic/baseline/qtgradienteditor.ui.h index 9db07f35ac..814adff7bd 100644 --- a/tests/auto/tools/uic/baseline/qtgradienteditor.ui.h +++ b/tests/auto/tools/uic/baseline/qtgradienteditor.ui.h @@ -584,117 +584,117 @@ public: void retranslateUi(QWidget *QtGradientEditor) { QtGradientEditor->setWindowTitle(QApplication::translate("QtGradientEditor", "Form", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) gradientWidget->setToolTip(QApplication::translate("QtGradientEditor", "Gradient Editor", nullptr)); -#endif // QT_NO_TOOLTIP -#ifndef QT_NO_WHATSTHIS +#endif // QT_CONFIG(tooltip) +#if QT_CONFIG(whatsthis) gradientWidget->setWhatsThis(QApplication::translate("QtGradientEditor", "This area shows a preview of the gradient being edited. It also allows you to edit parameters specific to the gradient's type such as start and final point, radius, etc. by drag & drop.", nullptr)); -#endif // QT_NO_WHATSTHIS +#endif // QT_CONFIG(whatsthis) label1->setText(QApplication::translate("QtGradientEditor", "1", nullptr)); label2->setText(QApplication::translate("QtGradientEditor", "2", nullptr)); label3->setText(QApplication::translate("QtGradientEditor", "3", nullptr)); label4->setText(QApplication::translate("QtGradientEditor", "4", nullptr)); label5->setText(QApplication::translate("QtGradientEditor", "5", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) gradientStopsWidget->setToolTip(QApplication::translate("QtGradientEditor", "Gradient Stops Editor", nullptr)); -#endif // QT_NO_TOOLTIP -#ifndef QT_NO_WHATSTHIS +#endif // QT_CONFIG(tooltip) +#if QT_CONFIG(whatsthis) gradientStopsWidget->setWhatsThis(QApplication::translate("QtGradientEditor", "This area allows you to edit gradient stops. Double click on the existing stop handle to duplicate it. Double click outside of the existing stop handles to create a new stop. Drag & drop the handle to reposition it. Use right mouse button to popup context menu with extra actions.", nullptr)); -#endif // QT_NO_WHATSTHIS +#endif // QT_CONFIG(whatsthis) zoomLabel->setText(QApplication::translate("QtGradientEditor", "Zoom", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) zoomAllButton->setToolTip(QApplication::translate("QtGradientEditor", "Reset Zoom", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) zoomAllButton->setText(QApplication::translate("QtGradientEditor", "Reset Zoom", nullptr)); positionLabel->setText(QApplication::translate("QtGradientEditor", "Position", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) hLabel->setToolTip(QApplication::translate("QtGradientEditor", "Hue", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) hLabel->setText(QApplication::translate("QtGradientEditor", "H", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) hueColorLine->setToolTip(QApplication::translate("QtGradientEditor", "Hue", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) hueLabel->setText(QApplication::translate("QtGradientEditor", "Hue", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) sLabel->setToolTip(QApplication::translate("QtGradientEditor", "Saturation", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) sLabel->setText(QApplication::translate("QtGradientEditor", "S", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) saturationColorLine->setToolTip(QApplication::translate("QtGradientEditor", "Saturation", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) saturationLabel->setText(QApplication::translate("QtGradientEditor", "Sat", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) vLabel->setToolTip(QApplication::translate("QtGradientEditor", "Value", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) vLabel->setText(QApplication::translate("QtGradientEditor", "V", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) valueColorLine->setToolTip(QApplication::translate("QtGradientEditor", "Value", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) valueLabel->setText(QApplication::translate("QtGradientEditor", "Val", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) aLabel->setToolTip(QApplication::translate("QtGradientEditor", "Alpha", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) aLabel->setText(QApplication::translate("QtGradientEditor", "A", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) alphaColorLine->setToolTip(QApplication::translate("QtGradientEditor", "Alpha", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) alphaLabel->setText(QApplication::translate("QtGradientEditor", "Alpha", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) typeComboBox->setToolTip(QApplication::translate("QtGradientEditor", "Type", nullptr)); -#endif // QT_NO_TOOLTIP -#ifndef QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) +#if QT_CONFIG(tooltip) spreadComboBox->setToolTip(QApplication::translate("QtGradientEditor", "Spread", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) colorLabel->setText(QApplication::translate("QtGradientEditor", "Color", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) colorButton->setToolTip(QApplication::translate("QtGradientEditor", "Current stop's color", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) colorButton->setText(QString()); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) hsvRadioButton->setToolTip(QApplication::translate("QtGradientEditor", "Show HSV specification", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) hsvRadioButton->setText(QApplication::translate("QtGradientEditor", "HSV", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) rgbRadioButton->setToolTip(QApplication::translate("QtGradientEditor", "Show RGB specification", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) rgbRadioButton->setText(QApplication::translate("QtGradientEditor", "RGB", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) positionSpinBox->setToolTip(QApplication::translate("QtGradientEditor", "Current stop's position", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) zoomSpinBox->setSuffix(QApplication::translate("QtGradientEditor", "%", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) zoomInButton->setToolTip(QApplication::translate("QtGradientEditor", "Zoom In", nullptr)); -#endif // QT_NO_TOOLTIP -#ifndef QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) +#if QT_CONFIG(tooltip) zoomOutButton->setToolTip(QApplication::translate("QtGradientEditor", "Zoom Out", nullptr)); -#endif // QT_NO_TOOLTIP -#ifndef QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) +#if QT_CONFIG(tooltip) detailsButton->setToolTip(QApplication::translate("QtGradientEditor", "Toggle details extension", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) detailsButton->setText(QApplication::translate("QtGradientEditor", ">", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) linearButton->setToolTip(QApplication::translate("QtGradientEditor", "Linear Type", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) linearButton->setText(QApplication::translate("QtGradientEditor", "...", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) radialButton->setToolTip(QApplication::translate("QtGradientEditor", "Radial Type", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) radialButton->setText(QApplication::translate("QtGradientEditor", "...", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) conicalButton->setToolTip(QApplication::translate("QtGradientEditor", "Conical Type", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) conicalButton->setText(QApplication::translate("QtGradientEditor", "...", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) padButton->setToolTip(QApplication::translate("QtGradientEditor", "Pad Spread", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) padButton->setText(QApplication::translate("QtGradientEditor", "...", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) repeatButton->setToolTip(QApplication::translate("QtGradientEditor", "Repeat Spread", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) repeatButton->setText(QApplication::translate("QtGradientEditor", "...", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) reflectButton->setToolTip(QApplication::translate("QtGradientEditor", "Reflect Spread", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) reflectButton->setText(QApplication::translate("QtGradientEditor", "...", nullptr)); } // retranslateUi diff --git a/tests/auto/tools/uic/baseline/qtgradientview.ui.h b/tests/auto/tools/uic/baseline/qtgradientview.ui.h index aa3c03b02f..5e2ff941b7 100644 --- a/tests/auto/tools/uic/baseline/qtgradientview.ui.h +++ b/tests/auto/tools/uic/baseline/qtgradientview.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'qtgradientview.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/qtgradientviewdialog.ui.h b/tests/auto/tools/uic/baseline/qtgradientviewdialog.ui.h index e6d98ed4f0..567ec0b5e5 100644 --- a/tests/auto/tools/uic/baseline/qtgradientviewdialog.ui.h +++ b/tests/auto/tools/uic/baseline/qtgradientviewdialog.ui.h @@ -31,7 +31,7 @@ /******************************************************************************** ** Form generated from reading UI file 'qtgradientviewdialog.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/qtresourceeditordialog.ui.h b/tests/auto/tools/uic/baseline/qtresourceeditordialog.ui.h index 6a8c9c7172..6b394d7e8e 100644 --- a/tests/auto/tools/uic/baseline/qtresourceeditordialog.ui.h +++ b/tests/auto/tools/uic/baseline/qtresourceeditordialog.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'qtresourceeditordialog.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ @@ -142,23 +142,23 @@ public: void retranslateUi(QDialog *QtResourceEditorDialog) { QtResourceEditorDialog->setWindowTitle(QApplication::translate("QtResourceEditorDialog", "Dialog", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) newQrcButton->setToolTip(QApplication::translate("QtResourceEditorDialog", "New File", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) newQrcButton->setText(QApplication::translate("QtResourceEditorDialog", "N", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) removeQrcButton->setToolTip(QApplication::translate("QtResourceEditorDialog", "Remove File", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) removeQrcButton->setText(QApplication::translate("QtResourceEditorDialog", "R", nullptr)); importQrcButton->setText(QApplication::translate("QtResourceEditorDialog", "I", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) newResourceButton->setToolTip(QApplication::translate("QtResourceEditorDialog", "New Resource", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) newResourceButton->setText(QApplication::translate("QtResourceEditorDialog", "N", nullptr)); addResourceButton->setText(QApplication::translate("QtResourceEditorDialog", "A", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) removeResourceButton->setToolTip(QApplication::translate("QtResourceEditorDialog", "Remove Resource or File", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) removeResourceButton->setText(QApplication::translate("QtResourceEditorDialog", "R", nullptr)); } // retranslateUi diff --git a/tests/auto/tools/uic/baseline/qttoolbardialog.ui.h b/tests/auto/tools/uic/baseline/qttoolbardialog.ui.h index e893386d9b..7d8f91067c 100644 --- a/tests/auto/tools/uic/baseline/qttoolbardialog.ui.h +++ b/tests/auto/tools/uic/baseline/qttoolbardialog.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'qttoolbardialog.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ @@ -183,33 +183,33 @@ public: ___qtreewidgetitem->setText(0, QApplication::translate("QtToolBarDialog", "1", nullptr)); label->setText(QApplication::translate("QtToolBarDialog", "Actions", nullptr)); label_2->setText(QApplication::translate("QtToolBarDialog", "Toolbars", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) newButton->setToolTip(QApplication::translate("QtToolBarDialog", "Add new toolbar", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) newButton->setText(QApplication::translate("QtToolBarDialog", "New", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) removeButton->setToolTip(QApplication::translate("QtToolBarDialog", "Remove selected toolbar", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) removeButton->setText(QApplication::translate("QtToolBarDialog", "Remove", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) renameButton->setToolTip(QApplication::translate("QtToolBarDialog", "Rename toolbar", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) renameButton->setText(QApplication::translate("QtToolBarDialog", "Rename", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) upButton->setToolTip(QApplication::translate("QtToolBarDialog", "Move action up", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) upButton->setText(QApplication::translate("QtToolBarDialog", "Up", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) leftButton->setToolTip(QApplication::translate("QtToolBarDialog", "Remove action from toolbar", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) leftButton->setText(QApplication::translate("QtToolBarDialog", "<-", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) rightButton->setToolTip(QApplication::translate("QtToolBarDialog", "Add action to toolbar", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) rightButton->setText(QApplication::translate("QtToolBarDialog", "->", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) downButton->setToolTip(QApplication::translate("QtToolBarDialog", "Move action down", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) downButton->setText(QApplication::translate("QtToolBarDialog", "Down", nullptr)); label_3->setText(QApplication::translate("QtToolBarDialog", "Current Toolbar Actions", nullptr)); } // retranslateUi diff --git a/tests/auto/tools/uic/baseline/querywidget.ui.h b/tests/auto/tools/uic/baseline/querywidget.ui.h index 81516722d5..f1403d829d 100644 --- a/tests/auto/tools/uic/baseline/querywidget.ui.h +++ b/tests/auto/tools/uic/baseline/querywidget.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'querywidget.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/remotecontrol.ui.h b/tests/auto/tools/uic/baseline/remotecontrol.ui.h index 5893ff42af..aa4238c612 100644 --- a/tests/auto/tools/uic/baseline/remotecontrol.ui.h +++ b/tests/auto/tools/uic/baseline/remotecontrol.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'remotecontrol.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/saveformastemplate.ui.h b/tests/auto/tools/uic/baseline/saveformastemplate.ui.h index 9ef6eedb4c..3beff599a8 100644 --- a/tests/auto/tools/uic/baseline/saveformastemplate.ui.h +++ b/tests/auto/tools/uic/baseline/saveformastemplate.ui.h @@ -31,7 +31,7 @@ /******************************************************************************** ** Form generated from reading UI file 'saveformastemplate.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ @@ -117,10 +117,10 @@ public: vboxLayout->addWidget(buttonBox); -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) label->setBuddy(templateNameEdit); label_2->setBuddy(categoryCombo); -#endif // QT_NO_SHORTCUT +#endif // QT_CONFIG(shortcut) retranslateUi(SaveFormAsTemplate); QObject::connect(buttonBox, SIGNAL(accepted()), SaveFormAsTemplate, SLOT(accept())); diff --git a/tests/auto/tools/uic/baseline/settings.ui.h b/tests/auto/tools/uic/baseline/settings.ui.h index cc680c8033..d17b935239 100644 --- a/tests/auto/tools/uic/baseline/settings.ui.h +++ b/tests/auto/tools/uic/baseline/settings.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'settings.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/signalslotdialog.ui.h b/tests/auto/tools/uic/baseline/signalslotdialog.ui.h index 5833a25a8b..984198ba83 100644 --- a/tests/auto/tools/uic/baseline/signalslotdialog.ui.h +++ b/tests/auto/tools/uic/baseline/signalslotdialog.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'signalslotdialog.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ @@ -135,22 +135,22 @@ public: { SignalSlotDialogClass->setWindowTitle(QApplication::translate("SignalSlotDialogClass", "Signals and slots", nullptr)); slotGroupBox->setTitle(QApplication::translate("SignalSlotDialogClass", "Slots", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) addSlotButton->setToolTip(QApplication::translate("SignalSlotDialogClass", "Add", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) addSlotButton->setText(QApplication::translate("SignalSlotDialogClass", "...", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) removeSlotButton->setToolTip(QApplication::translate("SignalSlotDialogClass", "Delete", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) removeSlotButton->setText(QApplication::translate("SignalSlotDialogClass", "...", nullptr)); signalGroupBox->setTitle(QApplication::translate("SignalSlotDialogClass", "Signals", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) addSignalButton->setToolTip(QApplication::translate("SignalSlotDialogClass", "Add", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) addSignalButton->setText(QApplication::translate("SignalSlotDialogClass", "...", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) removeSignalButton->setToolTip(QApplication::translate("SignalSlotDialogClass", "Delete", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) removeSignalButton->setText(QApplication::translate("SignalSlotDialogClass", "...", nullptr)); } // retranslateUi diff --git a/tests/auto/tools/uic/baseline/sslclient.ui.h b/tests/auto/tools/uic/baseline/sslclient.ui.h index 382889648e..794577d3d9 100644 --- a/tests/auto/tools/uic/baseline/sslclient.ui.h +++ b/tests/auto/tools/uic/baseline/sslclient.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'sslclient.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/sslerrors.ui.h b/tests/auto/tools/uic/baseline/sslerrors.ui.h index 04f21ded43..a5c9b1b697 100644 --- a/tests/auto/tools/uic/baseline/sslerrors.ui.h +++ b/tests/auto/tools/uic/baseline/sslerrors.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'sslerrors.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/statistics.ui.h b/tests/auto/tools/uic/baseline/statistics.ui.h index 0b508836f2..02bd4cdfd1 100644 --- a/tests/auto/tools/uic/baseline/statistics.ui.h +++ b/tests/auto/tools/uic/baseline/statistics.ui.h @@ -31,7 +31,7 @@ /******************************************************************************** ** Form generated from reading UI file 'statistics.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/stringlisteditor.ui.h b/tests/auto/tools/uic/baseline/stringlisteditor.ui.h index fd78ce91c1..2baab1b90d 100644 --- a/tests/auto/tools/uic/baseline/stringlisteditor.ui.h +++ b/tests/auto/tools/uic/baseline/stringlisteditor.ui.h @@ -31,7 +31,7 @@ /******************************************************************************** ** Form generated from reading UI file 'stringlisteditor.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ @@ -201,9 +201,9 @@ public: vboxLayout->addWidget(buttonBox); -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) label->setBuddy(valueEdit); -#endif // QT_NO_SHORTCUT +#endif // QT_CONFIG(shortcut) retranslateUi(qdesigner_internal__Dialog); QObject::connect(buttonBox, SIGNAL(accepted()), qdesigner_internal__Dialog, SLOT(accept())); @@ -216,22 +216,22 @@ public: { qdesigner_internal__Dialog->setWindowTitle(QApplication::translate("qdesigner_internal::Dialog", "Dialog", nullptr)); groupBox->setTitle(QApplication::translate("qdesigner_internal::Dialog", "StringList", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) newButton->setToolTip(QApplication::translate("qdesigner_internal::Dialog", "New String", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) newButton->setText(QApplication::translate("qdesigner_internal::Dialog", "&New", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) deleteButton->setToolTip(QApplication::translate("qdesigner_internal::Dialog", "Delete String", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) deleteButton->setText(QApplication::translate("qdesigner_internal::Dialog", "&Delete", nullptr)); label->setText(QApplication::translate("qdesigner_internal::Dialog", "&Value:", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) upButton->setToolTip(QApplication::translate("qdesigner_internal::Dialog", "Move String Up", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) upButton->setText(QApplication::translate("qdesigner_internal::Dialog", "Up", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) downButton->setToolTip(QApplication::translate("qdesigner_internal::Dialog", "Move String Down", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) downButton->setText(QApplication::translate("qdesigner_internal::Dialog", "Down", nullptr)); } // retranslateUi diff --git a/tests/auto/tools/uic/baseline/stylesheeteditor.ui.h b/tests/auto/tools/uic/baseline/stylesheeteditor.ui.h index 5ae254ebab..4206f35857 100644 --- a/tests/auto/tools/uic/baseline/stylesheeteditor.ui.h +++ b/tests/auto/tools/uic/baseline/stylesheeteditor.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'stylesheeteditor.ui' ** -** Created by: Qt User Interface Compiler version 5.10.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/tabbedbrowser.ui.h b/tests/auto/tools/uic/baseline/tabbedbrowser.ui.h index 09b230f5df..d657a6cfcc 100644 --- a/tests/auto/tools/uic/baseline/tabbedbrowser.ui.h +++ b/tests/auto/tools/uic/baseline/tabbedbrowser.ui.h @@ -31,7 +31,7 @@ /******************************************************************************** ** Form generated from reading UI file 'tabbedbrowser.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/tablewidgeteditor.ui.h b/tests/auto/tools/uic/baseline/tablewidgeteditor.ui.h index e3ba00095e..f108c05fbd 100644 --- a/tests/auto/tools/uic/baseline/tablewidgeteditor.ui.h +++ b/tests/auto/tools/uic/baseline/tablewidgeteditor.ui.h @@ -31,7 +31,7 @@ /******************************************************************************** ** Form generated from reading UI file 'tablewidgeteditor.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ @@ -313,50 +313,50 @@ public: { qdesigner_internal__TableWidgetEditor->setWindowTitle(QApplication::translate("qdesigner_internal::TableWidgetEditor", "Edit Table Widget", nullptr)); itemsBox->setTitle(QApplication::translate("qdesigner_internal::TableWidgetEditor", "Table Items", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) tableWidget->setToolTip(QApplication::translate("qdesigner_internal::TableWidgetEditor", "Table Items", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) label_3->setText(QApplication::translate("qdesigner_internal::TableWidgetEditor", "Icon", nullptr)); columnsBox->setTitle(QApplication::translate("qdesigner_internal::TableWidgetEditor", "Columns", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) columnsListWidget->setToolTip(QApplication::translate("qdesigner_internal::TableWidgetEditor", "Table Columns", nullptr)); -#endif // QT_NO_TOOLTIP -#ifndef QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) +#if QT_CONFIG(tooltip) newColumnButton->setToolTip(QApplication::translate("qdesigner_internal::TableWidgetEditor", "New Column", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) newColumnButton->setText(QApplication::translate("qdesigner_internal::TableWidgetEditor", "New", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) deleteColumnButton->setToolTip(QApplication::translate("qdesigner_internal::TableWidgetEditor", "Delete Column", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) deleteColumnButton->setText(QApplication::translate("qdesigner_internal::TableWidgetEditor", "Delete", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) moveColumnUpButton->setToolTip(QApplication::translate("qdesigner_internal::TableWidgetEditor", "Move Column Up", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) moveColumnUpButton->setText(QApplication::translate("qdesigner_internal::TableWidgetEditor", "U", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) moveColumnDownButton->setToolTip(QApplication::translate("qdesigner_internal::TableWidgetEditor", "Move Column Down", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) moveColumnDownButton->setText(QApplication::translate("qdesigner_internal::TableWidgetEditor", "D", nullptr)); label->setText(QApplication::translate("qdesigner_internal::TableWidgetEditor", "Icon", nullptr)); rowsBox->setTitle(QApplication::translate("qdesigner_internal::TableWidgetEditor", "Rows", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) rowsListWidget->setToolTip(QApplication::translate("qdesigner_internal::TableWidgetEditor", "Table Rows", nullptr)); -#endif // QT_NO_TOOLTIP -#ifndef QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) +#if QT_CONFIG(tooltip) newRowButton->setToolTip(QApplication::translate("qdesigner_internal::TableWidgetEditor", "New Row", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) newRowButton->setText(QApplication::translate("qdesigner_internal::TableWidgetEditor", "New", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) deleteRowButton->setToolTip(QApplication::translate("qdesigner_internal::TableWidgetEditor", "Delete Row", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) deleteRowButton->setText(QApplication::translate("qdesigner_internal::TableWidgetEditor", "Delete", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) moveRowUpButton->setToolTip(QApplication::translate("qdesigner_internal::TableWidgetEditor", "Move Row Up", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) moveRowUpButton->setText(QApplication::translate("qdesigner_internal::TableWidgetEditor", "U", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) moveRowDownButton->setToolTip(QApplication::translate("qdesigner_internal::TableWidgetEditor", "Move Row Down", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) moveRowDownButton->setText(QApplication::translate("qdesigner_internal::TableWidgetEditor", "D", nullptr)); label_2->setText(QApplication::translate("qdesigner_internal::TableWidgetEditor", "Icon", nullptr)); } // retranslateUi diff --git a/tests/auto/tools/uic/baseline/tetrixwindow.ui.h b/tests/auto/tools/uic/baseline/tetrixwindow.ui.h index dc1033ce3a..53d94b7f50 100644 --- a/tests/auto/tools/uic/baseline/tetrixwindow.ui.h +++ b/tests/auto/tools/uic/baseline/tetrixwindow.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'tetrixwindow.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/baseline/textfinder.ui.h b/tests/auto/tools/uic/baseline/textfinder.ui.h index 2f6bfebf98..1cc082b34c 100644 --- a/tests/auto/tools/uic/baseline/textfinder.ui.h +++ b/tests/auto/tools/uic/baseline/textfinder.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'textfinder.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ @@ -81,9 +81,9 @@ public: vboxLayout->addItem(spacerItem); -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) searchLabel->setBuddy(lineEdit); -#endif // QT_NO_SHORTCUT +#endif // QT_CONFIG(shortcut) retranslateUi(Form); QObject::connect(lineEdit, SIGNAL(returnPressed()), findButton, SLOT(animateClick())); diff --git a/tests/auto/tools/uic/baseline/topicchooser.ui.h b/tests/auto/tools/uic/baseline/topicchooser.ui.h index 90ec485e39..00e30bd546 100644 --- a/tests/auto/tools/uic/baseline/topicchooser.ui.h +++ b/tests/auto/tools/uic/baseline/topicchooser.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'topicchooser.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ @@ -86,9 +86,9 @@ public: vboxLayout->addWidget(Layout16); -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) label->setBuddy(listWidget); -#endif // QT_NO_SHORTCUT +#endif // QT_CONFIG(shortcut) retranslateUi(TopicChooser); diff --git a/tests/auto/tools/uic/baseline/translatedialog.ui.h b/tests/auto/tools/uic/baseline/translatedialog.ui.h index 5bea11f9f2..dec725ac8f 100644 --- a/tests/auto/tools/uic/baseline/translatedialog.ui.h +++ b/tests/auto/tools/uic/baseline/translatedialog.ui.h @@ -31,7 +31,7 @@ /******************************************************************************** ** Form generated from reading UI file 'translatedialog.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ @@ -182,10 +182,10 @@ public: hboxLayout->addLayout(vboxLayout2); -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) findWhat->setBuddy(ledFindWhat); translateTo->setBuddy(ledTranslateTo); -#endif // QT_NO_SHORTCUT +#endif // QT_CONFIG(shortcut) QWidget::setTabOrder(ledFindWhat, ledTranslateTo); QWidget::setTabOrder(ledTranslateTo, findNxt); QWidget::setTabOrder(findNxt, translate); @@ -206,32 +206,32 @@ public: void retranslateUi(QDialog *TranslateDialog) { TranslateDialog->setWindowTitle(QApplication::translate("TranslateDialog", "Qt Linguist", nullptr)); -#ifndef QT_NO_WHATSTHIS +#if QT_CONFIG(whatsthis) TranslateDialog->setWhatsThis(QApplication::translate("TranslateDialog", "This window allows you to search for some text in the translation source file.", nullptr)); -#endif // QT_NO_WHATSTHIS -#ifndef QT_NO_WHATSTHIS +#endif // QT_CONFIG(whatsthis) +#if QT_CONFIG(whatsthis) ledTranslateTo->setWhatsThis(QApplication::translate("TranslateDialog", "Type in the text to search for.", nullptr)); -#endif // QT_NO_WHATSTHIS +#endif // QT_CONFIG(whatsthis) findWhat->setText(QApplication::translate("TranslateDialog", "Find &source text:", nullptr)); translateTo->setText(QApplication::translate("TranslateDialog", "&Translate to:", nullptr)); -#ifndef QT_NO_WHATSTHIS +#if QT_CONFIG(whatsthis) ledFindWhat->setWhatsThis(QApplication::translate("TranslateDialog", "Type in the text to search for.", nullptr)); -#endif // QT_NO_WHATSTHIS +#endif // QT_CONFIG(whatsthis) groupBox->setTitle(QApplication::translate("TranslateDialog", "Search options", nullptr)); -#ifndef QT_NO_WHATSTHIS +#if QT_CONFIG(whatsthis) ckMatchCase->setWhatsThis(QApplication::translate("TranslateDialog", "Texts such as 'TeX' and 'tex' are considered as different when checked.", nullptr)); -#endif // QT_NO_WHATSTHIS +#endif // QT_CONFIG(whatsthis) ckMatchCase->setText(QApplication::translate("TranslateDialog", "Match &case", nullptr)); ckMarkFinished->setText(QApplication::translate("TranslateDialog", "Mark new translation as &finished", nullptr)); -#ifndef QT_NO_WHATSTHIS +#if QT_CONFIG(whatsthis) findNxt->setWhatsThis(QApplication::translate("TranslateDialog", "Click here to find the next occurrence of the text you typed in.", nullptr)); -#endif // QT_NO_WHATSTHIS +#endif // QT_CONFIG(whatsthis) findNxt->setText(QApplication::translate("TranslateDialog", "Find Next", nullptr)); translate->setText(QApplication::translate("TranslateDialog", "Translate", nullptr)); translateAll->setText(QApplication::translate("TranslateDialog", "Translate All", nullptr)); -#ifndef QT_NO_WHATSTHIS +#if QT_CONFIG(whatsthis) cancel->setWhatsThis(QApplication::translate("TranslateDialog", "Click here to close this window.", nullptr)); -#endif // QT_NO_WHATSTHIS +#endif // QT_CONFIG(whatsthis) cancel->setText(QApplication::translate("TranslateDialog", "Cancel", nullptr)); } // retranslateUi diff --git a/tests/auto/tools/uic/baseline/translationsettings.ui.h b/tests/auto/tools/uic/baseline/translationsettings.ui.h index 764e3a85b6..88b0128e1b 100644 --- a/tests/auto/tools/uic/baseline/translationsettings.ui.h +++ b/tests/auto/tools/uic/baseline/translationsettings.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'translationsettings.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ @@ -86,9 +86,9 @@ public: vboxLayout->addWidget(buttonBox); -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) label->setBuddy(cbLanguageList); -#endif // QT_NO_SHORTCUT +#endif // QT_CONFIG(shortcut) retranslateUi(TranslationSettings); QObject::connect(buttonBox, SIGNAL(accepted()), TranslationSettings, SLOT(accept())); diff --git a/tests/auto/tools/uic/baseline/treewidgeteditor.ui.h b/tests/auto/tools/uic/baseline/treewidgeteditor.ui.h index d432195648..57347f2464 100644 --- a/tests/auto/tools/uic/baseline/treewidgeteditor.ui.h +++ b/tests/auto/tools/uic/baseline/treewidgeteditor.ui.h @@ -31,7 +31,7 @@ /******************************************************************************** ** Form generated from reading UI file 'treewidgeteditor.ui' ** -** Created by: Qt User Interface Compiler version 5.0.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ @@ -280,57 +280,57 @@ public: itemsBox->setTitle(QApplication::translate("qdesigner_internal::TreeWidgetEditor", "Tree Items", nullptr)); QTreeWidgetItem *___qtreewidgetitem = treeWidget->headerItem(); ___qtreewidgetitem->setText(0, QApplication::translate("qdesigner_internal::TreeWidgetEditor", "1", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) treeWidget->setToolTip(QApplication::translate("qdesigner_internal::TreeWidgetEditor", "Tree Items", nullptr)); -#endif // QT_NO_TOOLTIP -#ifndef QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) +#if QT_CONFIG(tooltip) newItemButton->setToolTip(QApplication::translate("qdesigner_internal::TreeWidgetEditor", "New Item", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) newItemButton->setText(QApplication::translate("qdesigner_internal::TreeWidgetEditor", "&New", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) newSubItemButton->setToolTip(QApplication::translate("qdesigner_internal::TreeWidgetEditor", "New Subitem", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) newSubItemButton->setText(QApplication::translate("qdesigner_internal::TreeWidgetEditor", "New &Subitem", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) deleteItemButton->setToolTip(QApplication::translate("qdesigner_internal::TreeWidgetEditor", "Delete Item", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) deleteItemButton->setText(QApplication::translate("qdesigner_internal::TreeWidgetEditor", "&Delete", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) moveItemLeftButton->setToolTip(QApplication::translate("qdesigner_internal::TreeWidgetEditor", "Move Item Left (before Parent Item)", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) moveItemLeftButton->setText(QApplication::translate("qdesigner_internal::TreeWidgetEditor", "L", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) moveItemRightButton->setToolTip(QApplication::translate("qdesigner_internal::TreeWidgetEditor", "Move Item Right (as a First Subitem of the Next Sibling Item)", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) moveItemRightButton->setText(QApplication::translate("qdesigner_internal::TreeWidgetEditor", "R", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) moveItemUpButton->setToolTip(QApplication::translate("qdesigner_internal::TreeWidgetEditor", "Move Item Up", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) moveItemUpButton->setText(QApplication::translate("qdesigner_internal::TreeWidgetEditor", "U", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) moveItemDownButton->setToolTip(QApplication::translate("qdesigner_internal::TreeWidgetEditor", "Move Item Down", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) moveItemDownButton->setText(QApplication::translate("qdesigner_internal::TreeWidgetEditor", "D", nullptr)); label_2->setText(QApplication::translate("qdesigner_internal::TreeWidgetEditor", "Icon", nullptr)); columnsBox->setTitle(QApplication::translate("qdesigner_internal::TreeWidgetEditor", "Columns", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) listWidget->setToolTip(QApplication::translate("qdesigner_internal::TreeWidgetEditor", "Tree Columns", nullptr)); -#endif // QT_NO_TOOLTIP -#ifndef QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) +#if QT_CONFIG(tooltip) newColumnButton->setToolTip(QApplication::translate("qdesigner_internal::TreeWidgetEditor", "New Column", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) newColumnButton->setText(QApplication::translate("qdesigner_internal::TreeWidgetEditor", "New", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) deleteColumnButton->setToolTip(QApplication::translate("qdesigner_internal::TreeWidgetEditor", "Delete Column", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) deleteColumnButton->setText(QApplication::translate("qdesigner_internal::TreeWidgetEditor", "Delete", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) moveColumnUpButton->setToolTip(QApplication::translate("qdesigner_internal::TreeWidgetEditor", "Move Column Up", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) moveColumnUpButton->setText(QApplication::translate("qdesigner_internal::TreeWidgetEditor", "U", nullptr)); -#ifndef QT_NO_TOOLTIP +#if QT_CONFIG(tooltip) moveColumnDownButton->setToolTip(QApplication::translate("qdesigner_internal::TreeWidgetEditor", "Move Column Down", nullptr)); -#endif // QT_NO_TOOLTIP +#endif // QT_CONFIG(tooltip) moveColumnDownButton->setText(QApplication::translate("qdesigner_internal::TreeWidgetEditor", "D", nullptr)); label->setText(QApplication::translate("qdesigner_internal::TreeWidgetEditor", "Icon", nullptr)); } // retranslateUi diff --git a/tests/auto/tools/uic/baseline/trpreviewtool.ui.h b/tests/auto/tools/uic/baseline/trpreviewtool.ui.h index 3fbf125a1f..e99bf81a4c 100644 --- a/tests/auto/tools/uic/baseline/trpreviewtool.ui.h +++ b/tests/auto/tools/uic/baseline/trpreviewtool.ui.h @@ -31,7 +31,7 @@ /******************************************************************************** ** Form generated from reading UI file 'trpreviewtool.ui' ** -** Created by: Qt User Interface Compiler version 5.9.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ @@ -166,9 +166,9 @@ public: actionOpenForm->setText(QApplication::translate("TrPreviewToolClass", "&Open Form...", nullptr)); actionLoadTranslation->setText(QApplication::translate("TrPreviewToolClass", "&Load Translation...", nullptr)); actionReloadTranslations->setText(QApplication::translate("TrPreviewToolClass", "&Reload Translations", nullptr)); -#ifndef QT_NO_SHORTCUT +#if QT_CONFIG(shortcut) actionReloadTranslations->setShortcut(QApplication::translate("TrPreviewToolClass", "F5", nullptr)); -#endif // QT_NO_SHORTCUT +#endif // QT_CONFIG(shortcut) actionClose->setText(QApplication::translate("TrPreviewToolClass", "&Close", nullptr)); actionAbout->setText(QApplication::translate("TrPreviewToolClass", "About", nullptr)); actionAbout_Qt->setText(QApplication::translate("TrPreviewToolClass", "About Qt", nullptr)); diff --git a/tests/auto/tools/uic/baseline/wateringconfigdialog.ui.h b/tests/auto/tools/uic/baseline/wateringconfigdialog.ui.h index d6f7ff5526..822a22336d 100644 --- a/tests/auto/tools/uic/baseline/wateringconfigdialog.ui.h +++ b/tests/auto/tools/uic/baseline/wateringconfigdialog.ui.h @@ -1,7 +1,7 @@ /******************************************************************************** ** Form generated from reading UI file 'wateringconfigdialog.ui' ** -** Created by: Qt User Interface Compiler version 5.10.0 +** Created by: Qt User Interface Compiler version 5.12.0 ** ** WARNING! All changes made in this file will be lost when recompiling UI file! ********************************************************************************/ diff --git a/tests/auto/tools/uic/tst_uic.cpp b/tests/auto/tools/uic/tst_uic.cpp index 85668c96d4..f9553028fe 100644 --- a/tests/auto/tools/uic/tst_uic.cpp +++ b/tests/auto/tools/uic/tst_uic.cpp @@ -37,6 +37,11 @@ #include <QtCore/QRegularExpression> #include <QtCore/QStandardPaths> +#include <cstdio> + +static const char keepEnvVar[] = "UIC_KEEP_GENERATED_FILES"; +static const char diffToStderrEnvVar[] = "UIC_STDERR_DIFF"; + class tst_uic : public QObject { Q_OBJECT @@ -69,7 +74,7 @@ private: tst_uic::tst_uic() : m_command(QLibraryInfo::location(QLibraryInfo::BinariesPath) + QLatin1String("/uic")) - , m_versionRegexp(QLatin1String("\\*\\* Created by: Qt User Interface Compiler version \\d{1,2}\\.\\d{1,2}\\.\\d{1,2}")) + , m_versionRegexp(QLatin1String(R"(\*\* Created by: Qt User Interface Compiler version \d{1,2}\.\d{1,2}\.\d{1,2})")) { } @@ -103,14 +108,19 @@ void tst_uic::initTestCase() qDebug("%s", qPrintable(msg)); } +static const char helpFormat[] = R"( +Note: The environment variable '%s' can be set to keep the temporary files +for error analysis. +The environment variable '%s' can be set to redirect the diff output to +stderr.)"; + void tst_uic::cleanupTestCase() { - static const char envVar[] = "UIC_KEEP_GENERATED_FILES"; - if (qgetenv(envVar).isEmpty()) { - qDebug("Note: The environment variable '%s' can be set to keep the temporary files for error analysis.", envVar); - } else { + if (qEnvironmentVariableIsSet(keepEnvVar)) { m_generated.setAutoRemove(false); qDebug("Keeping generated files in '%s'", qPrintable(QDir::toNativeSeparators(m_generated.path()))); + } else { + qDebug(helpFormat, keepEnvVar, diffToStderrEnvVar); } } @@ -152,7 +162,7 @@ void tst_uic::run() QVERIFY(process.waitForFinished()); QCOMPARE(process.exitStatus(), QProcess::NormalExit); QCOMPARE(process.exitCode(), 0); - QCOMPARE(QFileInfo(generatedFile).exists(), true); + QVERIFY(QFileInfo::exists(generatedFile)); } void tst_uic::run_data() const @@ -212,6 +222,16 @@ static QByteArray msgCannotReadFile(const QFile &file) return result.toLocal8Bit(); } +static void outputDiff(const QString &diff) +{ + // Use patch -p3 < diff to apply the obtained diff output in the baseline directory. + static const bool diffToStderr = qEnvironmentVariableIsSet(diffToStderrEnvVar); + if (diffToStderr) + std::fputs(qPrintable(diff), stderr); + else + qWarning("Difference:\n%s", qPrintable(diff)); +} + void tst_uic::compare() { QFETCH(QString, originalFile); @@ -233,7 +253,7 @@ void tst_uic::compare() if (generatedFileContents != originalFileContents) { const QString diff = generateDiff(originalFile, generatedFile); if (!diff.isEmpty()) - qWarning().noquote().nospace() << "Difference:\n" << diff; + outputDiff(diff); } QCOMPARE(generatedFileContents, originalFileContents); @@ -274,7 +294,7 @@ void tst_uic::runTranslation() QVERIFY(process.waitForFinished()); QCOMPARE(process.exitStatus(), QProcess::NormalExit); QCOMPARE(process.exitCode(), 0); - QCOMPARE(QFileInfo(generatedFile).exists(), true); + QVERIFY(QFileInfo::exists(generatedFile)); } @@ -301,7 +321,7 @@ void tst_uic::runCompare() if (generatedFileContents != originalFileContents) { const QString diff = generateDiff(originalFile, generatedFile); if (!diff.isEmpty()) - qWarning().noquote().nospace() << "Difference:\n" << diff; + outputDiff(diff); } QCOMPARE(generatedFileContents, originalFileContents); diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp index b6932d4892..9d3770064f 100644 --- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp +++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp @@ -253,11 +253,12 @@ protected: void calculateAndCheck(int cppline, const int precalced_comparedata[]); void testMinMaxSectionSize(bool stretchLastSection); - QWidget *topLevel; - QHeaderView *view; - QStandardItemModel *model; - QTableView *m_tableview; - bool m_using_reset_model; + QWidget *topLevel = nullptr; + QHeaderView *view = nullptr; + QStandardItemModel *model = nullptr; + QTableView *m_tableview = nullptr; + bool m_using_reset_model = false; + bool m_special_prepare = false; QElapsedTimer timer; }; @@ -614,6 +615,27 @@ void tst_QHeaderView::hidden() view->setSectionHidden(1, false); QCOMPARE(view->isSectionHidden(0), false); QCOMPARE(view->sectionSize(0), view->defaultSectionSize()); + + // d->hiddenSectionSize could go out of sync when a new model + // was set which has fewer sections than before and some of them + // were hidden + QStandardItemModel model2(model->rowCount() - 1, model->columnCount()); + + for (int i = 0; i < model->rowCount(); ++i) + view->setSectionHidden(i, true); + view->setModel(&model2); + QVERIFY(view->sectionsHidden()); + for (int i = 0; i < model2.rowCount(); ++i) { + QVERIFY(view->isSectionHidden(i)); + } + + view->setModel(model); + for (int i = 0; i < model2.rowCount(); ++i) { + QVERIFY(view->isSectionHidden(i)); + } + QCOMPARE(view->isSectionHidden(model->rowCount() - 1), false); + for (int i = 0; i < model->rowCount(); ++i) + view->setSectionHidden(i, false); } void tst_QHeaderView::stretch() @@ -2822,6 +2844,7 @@ void tst_QHeaderView::additionalInit() QFETCH(bool, reset_model); m_using_reset_model = reset_model; + m_special_prepare = special_prepare; if (m_using_reset_model) { XResetModel *m = new XResetModel(); @@ -3035,18 +3058,34 @@ void tst_QHeaderView::mixedTests() view->moveSection(0, 5); for (int u = model->rowCount(); u >= 0; --u) { - if (u % 5 != 0) + if (u % 5 != 0) { view->hideSection(u); - if (u % 3 != 0) + QVERIFY(view->isSectionHidden(u)); + } + if (u % 3 != 0) { view->showSection(u); + QVERIFY(!view->isSectionHidden(u)); + } } model->insertRows(3, 7); model->removeRows(8, 3); model->setRowCount(model->rowCount() - 10); + // the upper is not visible (when m_using_reset_model is true) + // the lower 11 are modified due to insert/removeRows + for (int u = model->rowCount() - 1; u >= 11; --u) { + // when using reset, the hidden rows will *not* move + const int calcMod = m_using_reset_model ? u : u - 4; // 7 added, 3 removed + if (calcMod % 5 != 0 && calcMod % 3 == 0) { + QVERIFY(view->isSectionHidden(u)); + } + if (calcMod % 3 != 0) { + QVERIFY(!view->isSectionHidden(u)); + } + } if (m_using_reset_model) { - const int precalced_results[] = { 898296472, 337096378, -543340640, 1, -1251526424, -568618976, 9250 }; + const int precalced_results[] = { 898296472, 337096378, -543340640, -1964432121, -1251526424, -568618976, 9250 }; calculateAndCheck(__LINE__, precalced_results); } else { const int precalced_results[] = { 1911338224, 1693514365, -613398968, -1912534953, 1582159424, -1851079000, 9300 }; diff --git a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp index a8f6906056..adedace8b2 100644 --- a/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp +++ b/tests/auto/widgets/itemviews/qitemdelegate/tst_qitemdelegate.cpp @@ -1215,7 +1215,7 @@ void tst_QItemDelegate::editorEvent() option.checkState = Qt::CheckState(checkState); const int checkMargin = qApp->style()->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, 0) + 1; - QPoint pos = inCheck ? qApp->style()->subElementRect(QStyle::SE_ViewItemCheckIndicator, &option, 0).center() + QPoint(checkMargin, 0) : QPoint(200,200); + QPoint pos = inCheck ? qApp->style()->subElementRect(QStyle::SE_ItemViewItemCheckIndicator, &option, 0).center() + QPoint(checkMargin, 0) : QPoint(200,200); QEvent *event = new QMouseEvent((QEvent::Type)type, pos, @@ -1371,7 +1371,7 @@ void tst_QItemDelegate::QTBUG4435_keepSelectionOnCheck() option.features = QStyleOptionViewItem::HasDisplay | QStyleOptionViewItem::HasCheckIndicator; option.checkState = Qt::CheckState(model.index(0, 0).data(Qt::CheckStateRole).toInt()); const int checkMargin = qApp->style()->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, 0) + 1; - QPoint pos = qApp->style()->subElementRect(QStyle::SE_ViewItemCheckIndicator, &option, 0).center() + QPoint pos = qApp->style()->subElementRect(QStyle::SE_ItemViewItemCheckIndicator, &option, 0).center() + QPoint(checkMargin, 0); QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ControlModifier, pos); QTRY_VERIFY(view.selectionModel()->isColumnSelected(0, QModelIndex())); diff --git a/tests/auto/widgets/itemviews/qitemview/tst_qitemview.cpp b/tests/auto/widgets/itemviews/qitemview/tst_qitemview.cpp index bbdaac5c6f..071665a5e3 100644 --- a/tests/auto/widgets/itemviews/qitemview/tst_qitemview.cpp +++ b/tests/auto/widgets/itemviews/qitemview/tst_qitemview.cpp @@ -249,7 +249,7 @@ void tst_QItemView::populate() for (int y = 0; y < treeModel->columnCount(); ++y) { QModelIndex index = treeModel->index(x, y, parent); treeModel->setData(index, xS + QLatin1Char('_') + QString::number(y) + QLatin1Char('_') + iS); - treeModel->setData(index, QVariant(QColor(Qt::blue)), Qt::TextColorRole); + treeModel->setData(index, QVariant(QColor(Qt::blue)), Qt::ForegroundRole); } } } diff --git a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp index 5227db64ec..433b9e55e1 100644 --- a/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp +++ b/tests/auto/widgets/itemviews/qlistview/tst_qlistview.cpp @@ -873,6 +873,10 @@ void tst_QListView::setCurrentIndex() } } } + while (model.rowCount()) { + view.setCurrentIndex(model.index(model.rowCount() - 1, 0)); + model.removeRow(model.rowCount() - 1); + } } class PublicListView : public QListView diff --git a/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp b/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp index 98b44fe8aa..d8e14df353 100644 --- a/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp +++ b/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp @@ -31,6 +31,7 @@ #include <QtGui/QtGui> #include <QtWidgets/QtWidgets> #include <qlist.h> +#include <QSignalSpy> #include <qlistwidget.h> #include <private/qlistwidget_p.h> @@ -116,6 +117,14 @@ private slots: void QTBUG14363_completerWithAnyKeyPressedEditTriggers(); void mimeData(); void QTBUG50891_ensureSelectionModelSignalConnectionsAreSet(); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + void clearItemData(); +#endif + + void moveRows_data(); + void moveRows(); + void moveRowsInvalid_data(); + void moveRowsInvalid(); protected slots: void rowsAboutToBeInserted(const QModelIndex &parent, int first, int last) @@ -148,6 +157,108 @@ private: }; +void tst_QListWidget::moveRowsInvalid_data() +{ + QTest::addColumn<QListWidget*>("baseWidget"); + QTest::addColumn<QModelIndex>("startParent"); + QTest::addColumn<int>("startRow"); + QTest::addColumn<int>("count"); + QTest::addColumn<QModelIndex>("destinationParent"); + QTest::addColumn<int>("destination"); + + const auto createWidget = []() -> QListWidget* { + QListWidget* result = new QListWidget; + result->addItems(QStringList{"A", "B", "C", "D", "E", "F"}); + return result; + }; + + QTest::addRow("destination_equal_source") << createWidget() << QModelIndex() << 0 << 1 << QModelIndex() << 1; + QTest::addRow("count_equal_0") << createWidget() << QModelIndex() << 0 << 0 << QModelIndex() << 2; + QListWidget* tempWidget = createWidget(); + QTest::addRow("move_child") << tempWidget << tempWidget->model()->index(0, 0) << 0 << 1 << QModelIndex() << 2; + tempWidget = createWidget(); + QTest::addRow("move_to_child") << tempWidget << QModelIndex() << 0 << 1 << tempWidget->model()->index(0, 0) << 2; + QTest::addRow("negative_count") << createWidget() << QModelIndex() << 0 << -1 << QModelIndex() << 2; + QTest::addRow("negative_source_row") << createWidget() << QModelIndex() << -1 << 1 << QModelIndex() << 2; + QTest::addRow("negative_destination_row") << createWidget() << QModelIndex() << 0 << 1 << QModelIndex() << -1; + QTest::addRow("source_row_equal_rowCount") << createWidget() << QModelIndex() << 6 << 1 << QModelIndex() << 1; + QTest::addRow("destination_row_greater_rowCount") << createWidget() << QModelIndex() << 0 << 1 << QModelIndex() << 6 + 1; + QTest::addRow("move_row_within_source_range") << createWidget() << QModelIndex() << 0 << 3 << QModelIndex() << 2; + QTest::addRow("destination_row_before_0") << createWidget() << QModelIndex() << 1 << 1 << QModelIndex() << 0; +} + +void tst_QListWidget::moveRowsInvalid() +{ + QFETCH(QListWidget* const, baseWidget); + QFETCH(const QModelIndex, startParent); + QFETCH(const int, startRow); + QFETCH(const int, count); + QFETCH(const QModelIndex, destinationParent); + QFETCH(const int, destination); + QAbstractItemModel *baseModel = baseWidget->model(); + QSignalSpy rowMovedSpy(baseModel, &QAbstractItemModel::rowsMoved); + QSignalSpy rowAboutMovedSpy(baseModel, &QAbstractItemModel::rowsAboutToBeMoved); + QVERIFY(rowMovedSpy.isValid()); + QVERIFY(rowAboutMovedSpy.isValid()); + QVERIFY(!baseModel->moveRows(startParent, startRow, count, destinationParent, destination)); + QCOMPARE(rowMovedSpy.size(), 0); + QCOMPARE(rowAboutMovedSpy.size(), 0); + delete baseWidget; +} + +void tst_QListWidget::moveRows_data() +{ + QTest::addColumn<int>("startRow"); + QTest::addColumn<int>("count"); + QTest::addColumn<int>("destination"); + QTest::addColumn<QStringList>("expected"); + + QTest::newRow("1_Item_from_top_to_middle") << 0 << 1 << 3 << QStringList{"B", "C", "A", "D", "E", "F"}; + QTest::newRow("1_Item_from_top_to_bottom") << 0 << 1 << 6 << QStringList{"B", "C", "D", "E", "F", "A"}; + QTest::newRow("1_Item_from_middle_to_top") << 2 << 1 << 1 << QStringList{"C", "A", "B", "D", "E", "F"}; + QTest::newRow("1_Item_from_bottom_to_middle") << 5 << 1 << 3 << QStringList{"A", "B", "F", "C", "D", "E"}; + QTest::newRow("1_Item_from_bottom to_top") << 5 << 1 << 1 << QStringList{"F", "A", "B", "C", "D", "E"}; + QTest::newRow("1_Item_from_middle_to_bottom") << 2 << 1 << 6 << QStringList{"A", "B", "D", "E", "F", "C"}; + QTest::newRow("1_Item_from_middle_to_middle_before") << 2 << 1 << 1 << QStringList{"C", "A", "B", "D", "E", "F"}; + QTest::newRow("1_Item_from_middle_to_middle_after") << 2 << 1 << 4 << QStringList{"A", "B", "D", "C", "E", "F"}; + + QTest::newRow("2_Items_from_top_to_middle") << 0 << 2 << 3 << QStringList{"C", "A", "B", "D", "E", "F"}; + QTest::newRow("2_Items_from_top_to_bottom") << 0 << 2 << 6 << QStringList{"C", "D", "E", "F", "A", "B"}; + QTest::newRow("2_Items_from_middle_to_top") << 2 << 2 << 1 << QStringList{"C", "D", "A", "B", "E", "F"}; + QTest::newRow("2_Items_from_bottom_to_middle") << 4 << 2 << 3 << QStringList{"A", "B", "E", "F", "C", "D"}; + QTest::newRow("2_Items_from_bottom_to_top") << 4 << 2 << 1 << QStringList{"E", "F", "A", "B", "C", "D"}; + QTest::newRow("2_Items_from_middle_to_bottom") << 2 << 2 << 6 << QStringList{"A", "B", "E", "F", "C", "D"}; + QTest::newRow("2_Items_from_middle_to_middle_before") << 3 << 2 << 2 << QStringList{"A", "D", "E", "B", "C", "F"}; + QTest::newRow("2_Items_from_middle_to_middle_after") << 1 << 2 << 5 << QStringList{"A", "D", "E", "B", "C", "F"}; +} + +void tst_QListWidget::moveRows() +{ + QFETCH(const int, startRow); + QFETCH(const int, count); + QFETCH(const int, destination); + QFETCH(const QStringList, expected); + QListWidget baseWidget; + baseWidget.addItems(QStringList{"A", "B", "C", "D", "E", "F"}); + QAbstractItemModel *baseModel = baseWidget.model(); + QSignalSpy rowMovedSpy(baseModel, &QAbstractItemModel::rowsMoved); + QSignalSpy rowAboutMovedSpy(baseModel, &QAbstractItemModel::rowsAboutToBeMoved); + QVERIFY(baseModel->moveRows(QModelIndex(), startRow, count, QModelIndex(), destination)); + QCOMPARE(baseModel->rowCount(), expected.size()); + for (int i = 0; i < expected.size(); ++i) + QCOMPARE(baseModel->index(i, 0).data().toString(), expected.at(i)); + QCOMPARE(rowMovedSpy.size(), 1); + QCOMPARE(rowAboutMovedSpy.size(), 1); + for (const QList<QVariant> &signalArgs : {rowMovedSpy.first(), rowAboutMovedSpy.first()}){ + QVERIFY(!signalArgs.at(0).value<QModelIndex>().isValid()); + QCOMPARE(signalArgs.at(1).toInt(), startRow); + QCOMPARE(signalArgs.at(2).toInt(), startRow + count - 1); + QVERIFY(!signalArgs.at(3).value<QModelIndex>().isValid()); + QCOMPARE(signalArgs.at(4).toInt(), destination); + } +} + + typedef QList<int> IntList; tst_QListWidget::tst_QListWidget(): testWidget(0), rcParent(8), rcFirst(8,0), rcLast(8,0) @@ -1743,5 +1854,27 @@ void tst_QListWidget::QTBUG50891_ensureSelectionModelSignalConnectionsAreSet() } +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +void tst_QListWidget::clearItemData() +{ + QListWidget list; + for (int i = 0 ; i < 4; ++i) + new QListWidgetItem(QString::number(i), &list); + QSignalSpy dataChangeSpy(list.model(), &QAbstractItemModel::dataChanged); + QVERIFY(dataChangeSpy.isValid()); + QVERIFY(!list.model()->clearItemData(QModelIndex())); + QCOMPARE(dataChangeSpy.size(), 0); + QVERIFY(list.model()->clearItemData(list.model()->index(0, 0))); + QVERIFY(!list.model()->index(0, 0).data().isValid()); + QCOMPARE(dataChangeSpy.size(), 1); + const QList<QVariant> dataChangeArgs = dataChangeSpy.takeFirst(); + QCOMPARE(dataChangeArgs.at(0).value<QModelIndex>(), list.model()->index(0, 0)); + QCOMPARE(dataChangeArgs.at(1).value<QModelIndex>(), list.model()->index(0, 0)); + QVERIFY(dataChangeArgs.at(2).value<QVector<int>>().isEmpty()); + QVERIFY(list.model()->clearItemData(list.model()->index(0, 0))); + QCOMPARE(dataChangeSpy.size(), 0); +} +#endif + QTEST_MAIN(tst_QListWidget) #include "tst_qlistwidget.moc" diff --git a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp index ab746dfee8..228d03350a 100644 --- a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp +++ b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp @@ -2506,7 +2506,6 @@ void tst_QTableView::columnViewportPosition() view.horizontalScrollBar()->setValue(horizontalScrollValue); #ifdef Q_OS_WINRT - QEXPECT_FAIL("column 1, scroll per item, 1", "Fails on WinRT - QTBUG-68297", Abort); QEXPECT_FAIL("column 5, scroll per item, 5", "Fails on WinRT - QTBUG-68297", Abort); QEXPECT_FAIL("column 9, scroll per item, 5", "Fails on WinRT - QTBUG-68297", Abort); QEXPECT_FAIL("column 1, scroll per pixel 1", "Fails on WinRT - QTBUG-68297", Abort); diff --git a/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp b/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp index 4155ff1ec6..2e8f262c85 100644 --- a/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp +++ b/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp @@ -83,12 +83,17 @@ private slots: void setItemData(); void cellWidget(); void cellWidgetGeometry(); + void sizeHint_data(); + void sizeHint(); void task231094(); void task219380_removeLastRow(); void task262056_sortDuplicate(); void itemWithHeaderItems(); void mimeData(); void selectedRowAfterSorting(); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + void clearItemData(); +#endif private: QTableWidget *testWidget; @@ -191,10 +196,10 @@ void tst_QTableWidget::clear() { QTableWidgetItem *item = new QTableWidgetItem("foo"); testWidget->setItem(0, 0, item); - testWidget->setItemSelected(item, true); + item->setSelected(true); QVERIFY(testWidget->item(0, 0) == item); - QVERIFY(testWidget->isItemSelected(item)); + QVERIFY(item->isSelected()); QPointer<QObjectTableItem> bla = new QObjectTableItem(); @@ -578,7 +583,7 @@ void tst_QTableWidget::selectedItems() continue; QTableWidgetItem *item = testWidget->item(row, column); - if (item && testWidget->isItemSelected(item)) + if (item && item->isSelected()) QVERIFY(selectedItems.contains(item)); } } @@ -1454,6 +1459,56 @@ void tst_QTableWidget::cellWidgetGeometry() QCOMPARE(tw.visualItemRect(item).top(), le->geometry().top()); } +void tst_QTableWidget::sizeHint_data() +{ + QTest::addColumn<int>("scrollBarPolicy"); + QTest::addColumn<QSize>("viewSize"); + QTest::newRow("ScrollBarAlwaysOn") << static_cast<int>(Qt::ScrollBarAlwaysOn) << QSize(); + QTest::newRow("ScrollBarAlwaysOff") << static_cast<int>(Qt::ScrollBarAlwaysOff) << QSize(); + // make sure the scrollbars are shown by resizing the view to 40x40 + QTest::newRow("ScrollBarAsNeeded (40x40)") << static_cast<int>(Qt::ScrollBarAsNeeded) << QSize(40, 40); + QTest::newRow("ScrollBarAsNeeded (1000x1000)") << static_cast<int>(Qt::ScrollBarAsNeeded) << QSize(1000, 1000); +} + +void tst_QTableWidget::sizeHint() +{ + QFETCH(int, scrollBarPolicy); + QFETCH(QSize, viewSize); + + QTableWidget view(2, 2); + view.setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents); + view.setVerticalScrollBarPolicy(static_cast<Qt::ScrollBarPolicy>(scrollBarPolicy)); + view.setHorizontalScrollBarPolicy(static_cast<Qt::ScrollBarPolicy>(scrollBarPolicy)); + for (int r = 0 ; r < view.rowCount(); ++r) + for (int c = 0 ; c < view.columnCount(); ++c) + view.setItem(r, c, new QTableWidgetItem(QString("%1/%2").arg(r).arg(c))); + + view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); + if (viewSize.isValid()) { + view.resize(viewSize); + view.setColumnWidth(0, 100); + view.setRowHeight(0, 100); + QTRY_COMPARE(view.size(), viewSize); + } + + auto sizeHint = view.sizeHint(); + view.hide(); + QCOMPARE(view.sizeHint(), sizeHint); + + view.horizontalHeader()->hide(); + view.show(); + sizeHint = view.sizeHint(); + view.hide(); + QCOMPARE(view.sizeHint(), sizeHint); + + view.verticalHeader()->hide(); + view.show(); + sizeHint = view.sizeHint(); + view.hide(); + QCOMPARE(view.sizeHint(), sizeHint); +} + void tst_QTableWidget::task231094() { QTableWidget tw(5, 3); @@ -1617,5 +1672,28 @@ void tst_QTableWidget::selectedRowAfterSorting() } } +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +void tst_QTableWidget::clearItemData() +{ + QTableWidget table(3,3); + for (int r = 0; r < 3; r++) + for (int c = 0; c < 3; c++) + table.setItem(r,c,new QTableWidgetItem(QStringLiteral("0"))); + QSignalSpy dataChangeSpy(table.model(), &QAbstractItemModel::dataChanged); + QVERIFY(dataChangeSpy.isValid()); + QVERIFY(!table.model()->clearItemData(QModelIndex())); + QCOMPARE(dataChangeSpy.size(), 0); + QVERIFY(table.model()->clearItemData(table.model()->index(0, 0))); + QVERIFY(!table.model()->index(0, 0).data().isValid()); + QCOMPARE(dataChangeSpy.size(), 1); + const QList<QVariant> dataChangeArgs = dataChangeSpy.takeFirst(); + QCOMPARE(dataChangeArgs.at(0).value<QModelIndex>(), table.model()->index(0, 0)); + QCOMPARE(dataChangeArgs.at(1).value<QModelIndex>(), table.model()->index(0, 0)); + QVERIFY(dataChangeArgs.at(2).value<QVector<int>>().isEmpty()); + QVERIFY(table.model()->clearItemData(table.model()->index(0, 0))); + QCOMPARE(dataChangeSpy.size(), 0); +} +#endif + QTEST_MAIN(tst_QTableWidget) #include "tst_qtablewidget.moc" diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp index 8f9afeea4d..e452efff07 100644 --- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp @@ -69,6 +69,7 @@ public slots: void selectionOrderTest(); private slots: + void initTestCase() { QApplication::setKeyboardInputInterval(100); } void getSetCheck(); // one test per QTreeView property @@ -1647,50 +1648,96 @@ void tst_QTreeView::expandAndCollapse() } } +static void checkExpandState(const QAbstractItemModel &model, const QTreeView &view, + const QModelIndex &startIdx, bool bIsExpanded, int *count) +{ + *count = 0; + QStack<QModelIndex> parents; + parents.push(startIdx); + if (startIdx.isValid()) { + QCOMPARE(view.isExpanded(startIdx), bIsExpanded); + *count += 1; + } + while (!parents.isEmpty()) { + const QModelIndex p = parents.pop(); + const int rows = model.rowCount(p); + for (int r = 0; r < rows; ++r) { + const QModelIndex c = model.index(r, 0, p); + QCOMPARE(view.isExpanded(c), bIsExpanded); + parents.push(c); + } + *count += rows; + } +} + void tst_QTreeView::expandAndCollapseAll() { - QtTestModel model(3, 2); - model.levels = 2; + QStandardItemModel model; + // QtTestModel has a broken parent/child handling which will break the test + for (int i1 = 0; i1 < 3; ++i1) { + QStandardItem *s1 = new QStandardItem; + s1->setText(QString::number(i1)); + model.appendRow(s1); + for (int i2 = 0; i2 < 3; ++i2) { + QStandardItem *s2 = new QStandardItem; + s2->setText(QStringLiteral("%1 - %2").arg(i1).arg(i2)); + s1->appendRow(s2); + for (int i3 = 0; i3 < 3; ++i3) { + QStandardItem *s3 = new QStandardItem; + s3->setText(QStringLiteral("%1 - %2 - %3").arg(i1).arg(i2).arg(i3)); + s2->appendRow(s3); + } + } + } QTreeView view; view.setUniformRowHeights(true); view.setModel(&model); + view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); - QSignalSpy expandedSpy(&view, SIGNAL(expanded(QModelIndex))); - QSignalSpy collapsedSpy(&view, SIGNAL(collapsed(QModelIndex))); + QSignalSpy expandedSpy(&view, &QTreeView::expanded); + QSignalSpy collapsedSpy(&view, &QTreeView::collapsed); + int count; view.expandAll(); - view.show(); - + checkExpandState(model, view, QModelIndex(), true, &count); QCOMPARE(collapsedSpy.count(), 0); + QCOMPARE(expandedSpy.count(), 39); // == 3 (first) + 9 (second) + 27 (third level) + QCOMPARE(count, 39); - QStack<QModelIndex> parents; - parents.push(QModelIndex()); - int count = 0; - while (!parents.isEmpty()) { - QModelIndex p = parents.pop(); - int rows = model.rowCount(p); - for (int r = 0; r < rows; ++r) - QVERIFY(view.isExpanded(model.index(r, 0, p))); - count += rows; - for (int r = 0; r < rows; ++r) - parents.push(model.index(r, 0, p)); - } - QCOMPARE(expandedSpy.count(), 12); // == (3+1)*(2+1) from QtTestModel model(3, 2); - + collapsedSpy.clear(); + expandedSpy.clear(); view.collapseAll(); - - parents.push(QModelIndex()); - count = 0; - while (!parents.isEmpty()) { - QModelIndex p = parents.pop(); - int rows = model.rowCount(p); - for (int r = 0; r < rows; ++r) - QVERIFY(!view.isExpanded(model.index(r, 0, p))); - count += rows; - for (int r = 0; r < rows; ++r) - parents.push(model.index(r, 0, p)); - } - QCOMPARE(collapsedSpy.count(), 12); + checkExpandState(model, view, QModelIndex(), false, &count); + QCOMPARE(collapsedSpy.count(), 39); + QCOMPARE(expandedSpy.count(), 0); + QCOMPARE(count, 39); + + collapsedSpy.clear(); + expandedSpy.clear(); + view.expandRecursively(model.index(0, 0)); + QCOMPARE(expandedSpy.count(), 13); // 1 + 3 + 9 + + checkExpandState(model, view, model.index(0, 0), true, &count); + QCOMPARE(count, 13); + checkExpandState(model, view, model.index(1, 0), false, &count); + QCOMPARE(count, 13); + checkExpandState(model, view, model.index(2, 0), false, &count); + QCOMPARE(count, 13); + + expandedSpy.clear(); + view.collapseAll(); + view.expandRecursively(model.index(0, 0), 1); + QCOMPARE(expandedSpy.count(), 4); // 1 + 3 + view.expandRecursively(model.index(0, 0), 2); + QCOMPARE(expandedSpy.count(), 13); // (1 + 3) + 9 + + checkExpandState(model, view, model.index(0, 0), true, &count); + QCOMPARE(count, 13); + checkExpandState(model, view, model.index(1, 0), false, &count); + QCOMPARE(count, 13); + checkExpandState(model, view, model.index(2, 0), false, &count); + QCOMPARE(count, 13); } void tst_QTreeView::expandWithNoChildren() @@ -2435,6 +2482,8 @@ void tst_QTreeView::selection() for (int i = 0;i < 10; ++i) m.setData(m.index(i, 0), i); treeView.setModel(&m); + treeView.show(); + QVERIFY(QTest::qWaitForWindowExposed(&treeView)); treeView.setSelectionBehavior(QAbstractItemView::SelectRows); treeView.setSelectionMode(QAbstractItemView::ExtendedSelection); @@ -2446,6 +2495,13 @@ void tst_QTreeView::selection() QTest::mousePress(treeView.viewport(), Qt::LeftButton, 0, treeView.visualRect(m.index(1, 0)).center()); QTest::keyPress(treeView.viewport(), Qt::Key_Down); + auto selectedRows = treeView.selectionModel()->selectedRows(); + QCOMPARE(selectedRows.size(), 1); + QCOMPARE(selectedRows.first(), m.index(2, 0, QModelIndex())); + QTest::keyPress(treeView.viewport(), Qt::Key_5); + selectedRows = treeView.selectionModel()->selectedRows(); + QCOMPARE(selectedRows.size(), 1); + QCOMPARE(selectedRows.first(), m.index(5, 0, QModelIndex())); } //From task 151686 QTreeView ExtendedSelection selects hidden rows @@ -2737,7 +2793,7 @@ void tst_QTreeView::sortByColumn() view.setSortingEnabled(sortingEnabled); view.setModel(&model); - view.sortByColumn(1); + view.sortByColumn(1, Qt::DescendingOrder); QCOMPARE(view.header()->sortIndicatorSection(), 1); QCOMPARE(view.model()->data(view.model()->index(0,1)).toString(), QString::fromLatin1("h")); QCOMPARE(view.model()->data(view.model()->index(1,1)).toString(), QString::fromLatin1("g")); @@ -3047,7 +3103,7 @@ void tst_QTreeView::evilModel() view.resizeColumnToContents(1); model.change(); - view.sortByColumn(1); + view.sortByColumn(1, Qt::DescendingOrder); model.change(); view.selectAll(); @@ -3891,7 +3947,7 @@ void tst_QTreeView::task254234_proxySort() model.setItem(2,1,new QStandardItem("h")); model.setItem(3,1,new QStandardItem("f")); - view.sortByColumn(1); + view.sortByColumn(1, Qt::DescendingOrder); view.setSortingEnabled(true); QSortFilterProxyModel proxy; diff --git a/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp b/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp index 8c93df9073..d15a472072 100644 --- a/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp +++ b/tests/auto/widgets/itemviews/qtreewidget/tst_qtreewidget.cpp @@ -115,6 +115,8 @@ private slots: void changeDataWithSorting(); void changeDataWithStableSorting_data(); void changeDataWithStableSorting(); + void sizeHint_data(); + void sizeHint(); void sortedIndexOfChild_data(); void sortedIndexOfChild(); @@ -161,6 +163,9 @@ private slots: void getMimeDataWithInvalidItem(); void testVisualItemRect(); void reparentHiddenItem(); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + void clearItemData(); +#endif public slots: void itemSelectionChanged(); @@ -603,31 +608,31 @@ void tst_QTreeWidget::setItemHidden() QVERIFY(testWidget->visualItemRect(child).isValid() && testWidget->viewport()->rect().intersects(testWidget->visualItemRect(child))); - QVERIFY(!testWidget->isItemHidden(parent)); - QVERIFY(!testWidget->isItemHidden(child)); + QVERIFY(!parent->isHidden()); + QVERIFY(!child->isHidden()); - testWidget->setItemHidden(parent, true); + parent->setHidden(true); QVERIFY(!(testWidget->visualItemRect(parent).isValid() && testWidget->viewport()->rect().intersects(testWidget->visualItemRect(parent)))); QVERIFY(!(testWidget->visualItemRect(child).isValid() && testWidget->viewport()->rect().intersects(testWidget->visualItemRect(child)))); - QVERIFY(testWidget->isItemHidden(parent)); - QVERIFY(!testWidget->isItemHidden(child)); + QVERIFY(parent->isHidden()); + QVERIFY(!child->isHidden()); // From task 78670 (This caused an core dump) // Check if we can set an item visible if it already is visible. - testWidget->setItemHidden(parent, false); - testWidget->setItemHidden(parent, false); - QVERIFY(!testWidget->isItemHidden(parent)); + parent->setHidden(false); + parent->setHidden(false); + QVERIFY(!parent->isHidden()); // hide, hide and then unhide. - testWidget->setItemHidden(parent, true); - testWidget->setItemHidden(parent, true); - testWidget->setItemHidden(parent, false); - QVERIFY(!testWidget->isItemHidden(parent)); + parent->setHidden(true); + parent->setHidden(true); + parent->setHidden(false); + QVERIFY(!parent->isHidden()); } @@ -653,7 +658,7 @@ void tst_QTreeWidget::setItemHidden2() if (testWidget->topLevelItemCount() > 0) { top = testWidget->topLevelItem(0); - testWidget->setItemExpanded(top, true); + top->setExpanded(true); } if (testWidget->topLevelItemCount() > 0) { @@ -661,8 +666,8 @@ void tst_QTreeWidget::setItemHidden2() for (int i = 0; i < top->childCount(); i++) { leaf = top->child(i); if (leaf->text(0).toInt() % 2 == 0) { - if (!testWidget->isItemHidden(leaf)) { - testWidget->setItemHidden(leaf, true); + if (!leaf->isHidden()) { + leaf->setHidden(true); } } } @@ -816,7 +821,7 @@ void tst_QTreeWidget::selectedItems() else item = item->child(index); } - testWidget->setItemSelected(item, true); + item->setSelected(true); } // hide rows @@ -828,7 +833,7 @@ void tst_QTreeWidget::selectedItems() else item = item->child(index); } - testWidget->setItemHidden(item, true); + item->setHidden(true); } // open/close toplevel @@ -857,18 +862,20 @@ void tst_QTreeWidget::selectedItems() // compare isSelected for (int t=0; t<testWidget->topLevelItemCount(); ++t) { QTreeWidgetItem *top = testWidget->topLevelItem(t); - if (testWidget->isItemSelected(top) && !testWidget->isItemHidden(top)) + if (top->isSelected() && !top->isHidden()) QVERIFY(sel.contains(top)); for (int c=0; c<top->childCount(); ++c) { QTreeWidgetItem *child = top->child(c); - if (testWidget->isItemSelected(child) && !testWidget->isItemHidden(child)) + if (child->isSelected() && !child->isHidden()) QVERIFY(sel.contains(child)); } } +#if QT_DEPRECATED_SINCE(5, 13) // Possible to select null without crashing? testWidget->setItemSelected(0, true); QVERIFY(!testWidget->isItemSelected(0)); +#endif // unselect foreach (IntList itemPath, selectedItems) { @@ -879,7 +886,7 @@ void tst_QTreeWidget::selectedItems() else item = item->child(index); } - testWidget->setItemSelected(item, false); + item->setSelected(false); } QCOMPARE(testWidget->selectedItems().count(), 0); } @@ -1005,21 +1012,21 @@ void tst_QTreeWidget::expand() QTreeWidgetItem *topLevelItem = testWidget->topLevelItem(topLevelIndex); QTreeWidgetItem *childItem = topLevelItem->child(childIndex); - QVERIFY(!testWidget->isItemExpanded(topLevelItem)); - testWidget->setItemExpanded(topLevelItem, true); - QVERIFY(testWidget->isItemExpanded(topLevelItem)); + QVERIFY(!topLevelItem->isExpanded()); + topLevelItem->setExpanded(true); + QVERIFY(topLevelItem->isExpanded()); - QVERIFY(!testWidget->isItemExpanded(childItem)); - testWidget->setItemExpanded(childItem, true); - QVERIFY(testWidget->isItemExpanded(childItem)); + QVERIFY(!childItem->isExpanded()); + childItem->setExpanded(true); + QVERIFY(childItem->isExpanded()); - QVERIFY(testWidget->isItemExpanded(topLevelItem)); - testWidget->setItemExpanded(topLevelItem, false); - QVERIFY(!testWidget->isItemExpanded(topLevelItem)); + QVERIFY(topLevelItem->isExpanded()); + topLevelItem->setExpanded(false); + QVERIFY(!topLevelItem->isExpanded()); - QVERIFY(testWidget->isItemExpanded(childItem)); - testWidget->setItemExpanded(childItem, false); - QVERIFY(!testWidget->isItemExpanded(childItem)); + QVERIFY(childItem->isExpanded()); + childItem->setExpanded(false); + QVERIFY(!childItem->isExpanded()); } void tst_QTreeWidget::checkState_data() @@ -1520,7 +1527,7 @@ void tst_QTreeWidget::keyboardNavigation() } break; case Qt::Key_Down: - if (testWidget->isItemExpanded(item)) { + if (item->isExpanded()) { row = 0; item = item->child(row); } else { @@ -1533,7 +1540,7 @@ void tst_QTreeWidget::keyboardNavigation() break; case Qt::Key_Left: if (checkScroll) { - QVERIFY(testWidget->isItemExpanded(item)); + QVERIFY(item->isExpanded()); QCOMPARE(scrollBar->value(), valueBeforeClick - scrollBar->singleStep()); } // windows style right will walk to the parent @@ -1592,9 +1599,9 @@ void tst_QTreeWidget::scrollToItem() QCOMPARE(search->text(0), QLatin1String("111")); QTreeWidgetItem *par = search->parent(); - QVERIFY(testWidget->isItemExpanded(par)); + QVERIFY(par->isExpanded()); par = par->parent(); - QVERIFY(testWidget->isItemExpanded(par)); + QVERIFY(par->isExpanded()); } // From task #85413 @@ -1880,9 +1887,8 @@ void tst_QTreeWidget::setData() QCOMPARE(qvariant_cast<QSize>(item->data(j, Qt::SizeHintRole)), sizeHint); QCOMPARE(qvariant_cast<QFont>(item->data(j, Qt::FontRole)), font); QCOMPARE(qvariant_cast<int>(item->data(j, Qt::TextAlignmentRole)), int(textAlignment)); - QCOMPARE(qvariant_cast<QBrush>(item->data(j, Qt::BackgroundColorRole)), QBrush(backgroundColor)); QCOMPARE(qvariant_cast<QBrush>(item->data(j, Qt::BackgroundRole)), QBrush(backgroundColor)); - QCOMPARE(qvariant_cast<QColor>(item->data(j, Qt::TextColorRole)), textColor); + QCOMPARE(qvariant_cast<QColor>(item->data(j, Qt::ForegroundRole)), textColor); QCOMPARE(qvariant_cast<int>(item->data(j, Qt::CheckStateRole)), int(checkState)); item->setBackground(j, pixmap); @@ -1902,8 +1908,8 @@ void tst_QTreeWidget::setData() item->setData(j, Qt::SizeHintRole, QVariant()); item->setData(j, Qt::FontRole, QVariant()); item->setData(j, Qt::TextAlignmentRole, QVariant()); - item->setData(j, Qt::BackgroundColorRole, QVariant()); - item->setData(j, Qt::TextColorRole, QVariant()); + item->setData(j, Qt::BackgroundRole, QVariant()); + item->setData(j, Qt::ForegroundRole, QVariant()); item->setData(j, Qt::CheckStateRole, QVariant()); QCOMPARE(itemChangedSpy.count(), 11); itemChangedSpy.clear(); @@ -1916,9 +1922,8 @@ void tst_QTreeWidget::setData() QCOMPARE(item->data(j, Qt::SizeHintRole), QVariant()); QCOMPARE(item->data(j, Qt::FontRole), QVariant()); QCOMPARE(item->data(j, Qt::TextAlignmentRole), QVariant()); - QCOMPARE(item->data(j, Qt::BackgroundColorRole), QVariant()); QCOMPARE(item->data(j, Qt::BackgroundRole), QVariant()); - QCOMPARE(item->data(j, Qt::TextColorRole), QVariant()); + QCOMPARE(item->data(j, Qt::ForegroundRole), QVariant()); QCOMPARE(item->data(j, Qt::CheckStateRole), QVariant()); } } @@ -2618,6 +2623,50 @@ void tst_QTreeWidget::changeDataWithStableSorting() QCOMPARE(layoutChangedSpy.count(), reorderingExpected ? 1 : 0); } +void tst_QTreeWidget::sizeHint_data() +{ + QTest::addColumn<int>("scrollBarPolicy"); + QTest::addColumn<QSize>("viewSize"); + QTest::newRow("ScrollBarAlwaysOn") << static_cast<int>(Qt::ScrollBarAlwaysOn) << QSize(); + QTest::newRow("ScrollBarAlwaysOff") << static_cast<int>(Qt::ScrollBarAlwaysOff) << QSize(); + // make sure the scrollbars are shown by resizing the view to 40x40 + QTest::newRow("ScrollBarAsNeeded (40x40)") << static_cast<int>(Qt::ScrollBarAsNeeded) << QSize(40, 40); + QTest::newRow("ScrollBarAsNeeded (1000x1000)") << static_cast<int>(Qt::ScrollBarAsNeeded) << QSize(1000, 1000); +} + +void tst_QTreeWidget::sizeHint() +{ + QFETCH(int, scrollBarPolicy); + QFETCH(QSize, viewSize); + + QTreeWidget view; + view.setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents); + view.setVerticalScrollBarPolicy(static_cast<Qt::ScrollBarPolicy>(scrollBarPolicy)); + view.setHorizontalScrollBarPolicy(static_cast<Qt::ScrollBarPolicy>(scrollBarPolicy)); + view.setColumnCount(2); + for (int i = 0 ; i < view.columnCount(); ++i) + view.addTopLevelItem(new QTreeWidgetItem(QStringList{"foo","bar"})); + + view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); + + if (viewSize.isValid()) { + view.resize(viewSize); + view.setColumnWidth(0, 100); + QTRY_COMPARE(view.size(), viewSize); + } + + auto sizeHint = view.sizeHint(); + view.hide(); + QCOMPARE(view.sizeHint(), sizeHint); + + view.header()->hide(); + view.show(); + sizeHint = view.sizeHint(); + view.hide(); + QCOMPARE(view.sizeHint(), sizeHint); +} + void tst_QTreeWidget::itemOperatorLessThan() { QTreeWidget tw; @@ -2870,14 +2919,14 @@ void tst_QTreeWidget::randomExpand() QTreeWidgetItem *newItem1 = 0; for (int i = 0; i < 100; i++) { newItem1 = new QTreeWidgetItem(&tree, item1); - tree.setItemExpanded(newItem1, true); - QCOMPARE(tree.isItemExpanded(newItem1), true); + newItem1->setExpanded(true); + QCOMPARE(newItem1->isExpanded(), true); QTreeWidgetItem *x = new QTreeWidgetItem(); - QCOMPARE(tree.isItemExpanded(newItem1), true); + QCOMPARE(newItem1->isExpanded(), true); newItem1->addChild(x); - QCOMPARE(tree.isItemExpanded(newItem1), true); + QCOMPARE(newItem1->isExpanded(), true); } } @@ -2890,19 +2939,19 @@ void tst_QTreeWidget::crashTest() QTreeWidgetItem *item1 = new QTreeWidgetItem(tree); item1->setText(0, "item1"); - tree->setItemExpanded(item1, true); + item1->setExpanded(true); QTreeWidgetItem *item2 = new QTreeWidgetItem(item1); item2->setText(0, "item2"); QTreeWidgetItem *item3 = new QTreeWidgetItem(tree, item1); item3->setText(0, "item3"); - tree->setItemExpanded(item3, true); + item3->setExpanded(true); QTreeWidgetItem *item4 = new QTreeWidgetItem(item3); item4->setText(0, "item4"); QTreeWidgetItem *item5 = new QTreeWidgetItem(tree, item3); item5->setText(0, "item5"); - tree->setItemExpanded(item5, true); + item5->setExpanded(true); QTreeWidgetItem *item6 = new QTreeWidgetItem(item5); item6->setText(0, "item6"); @@ -3004,7 +3053,7 @@ void tst_QTreeWidget::task191552_rtl() opt.features = QStyleOptionViewItem::HasDisplay | QStyleOptionViewItem::HasCheckIndicator; opt.checkState = Qt::Checked; opt.widget = &tw; - const QRect checkRect = tw.style()->subElementRect(QStyle::SE_ViewItemCheckIndicator, &opt, &tw); + const QRect checkRect = tw.style()->subElementRect(QStyle::SE_ItemViewItemCheckIndicator, &opt, &tw); QTest::mouseClick(tw.viewport(), Qt::LeftButton, Qt::NoModifier, checkRect.center()); QCOMPARE(item->checkState(0), Qt::Unchecked); @@ -3218,7 +3267,7 @@ void tst_QTreeWidget::nonEditableTristate() option.checkState = item->checkState(0); const int checkMargin = qApp->style()->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, 0) + 1; - QPoint pos = qApp->style()->subElementRect(QStyle::SE_ViewItemCheckIndicator, &option, 0).center() + QPoint(checkMargin, 0); + QPoint pos = qApp->style()->subElementRect(QStyle::SE_ItemViewItemCheckIndicator, &option, 0).center() + QPoint(checkMargin, 0); QTest::mouseClick(tree->viewport(), Qt::LeftButton, Qt::NoModifier, pos); QCOMPARE(int(item->checkState(0)), int(Qt::Checked)); @@ -3529,5 +3578,43 @@ void tst_QTreeWidget::reparentHiddenItem() QVERIFY(grandChild->isHidden()); } +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +void tst_QTreeWidget::clearItemData() +{ + QTreeWidget tree; + QAbstractItemModel* model = tree.model(); + QVERIFY(model->insertColumn(0)); + QVERIFY(model->insertRow(0)); + const QModelIndex parentIdx = model->index(0, 0); + QVERIFY(model->insertColumn(0, parentIdx)); + QVERIFY(model->insertRow(0, parentIdx)); + const QModelIndex childIdx = model->index(0, 0, parentIdx); + model->setData(parentIdx, QStringLiteral("parent")); + model->setData(parentIdx, QStringLiteral("parent"), Qt::UserRole); + model->setData(childIdx, QStringLiteral("child")); + QSignalSpy dataChangeSpy(model, &QAbstractItemModel::dataChanged); + QVERIFY(dataChangeSpy.isValid()); + QVERIFY(!model->clearItemData(QModelIndex())); + QCOMPARE(dataChangeSpy.size(), 0); + QVERIFY(model->clearItemData(parentIdx)); + QVERIFY(!model->data(parentIdx).isValid()); + QVERIFY(!model->data(parentIdx, Qt::UserRole).isValid()); + QCOMPARE(dataChangeSpy.size(), 1); + QList<QVariant> dataChangeArgs = dataChangeSpy.takeFirst(); + QCOMPARE(dataChangeArgs.at(0).value<QModelIndex>(), parentIdx); + QCOMPARE(dataChangeArgs.at(1).value<QModelIndex>(), parentIdx); + QVERIFY(dataChangeArgs.at(2).value<QVector<int>>().isEmpty()); + QVERIFY(model->clearItemData(parentIdx)); + QCOMPARE(dataChangeSpy.size(), 0); + QVERIFY(model->clearItemData(childIdx)); + QVERIFY(!model->data(childIdx).isValid()); + QCOMPARE(dataChangeSpy.size(), 1); + dataChangeArgs = dataChangeSpy.takeFirst(); + QCOMPARE(dataChangeArgs.at(0).value<QModelIndex>(), childIdx); + QCOMPARE(dataChangeArgs.at(1).value<QModelIndex>(), childIdx); + QVERIFY(dataChangeArgs.at(2).value<QVector<int>>().isEmpty()); +} +#endif + QTEST_MAIN(tst_QTreeWidget) #include "tst_qtreewidget.moc" diff --git a/tests/auto/widgets/itemviews/qtreewidgetitemiterator/tst_qtreewidgetitemiterator.cpp b/tests/auto/widgets/itemviews/qtreewidgetitemiterator/tst_qtreewidgetitemiterator.cpp index c2c02f3766..76ca148d3f 100644 --- a/tests/auto/widgets/itemviews/qtreewidgetitemiterator/tst_qtreewidgetitemiterator.cpp +++ b/tests/auto/widgets/itemviews/qtreewidgetitemiterator/tst_qtreewidgetitemiterator.cpp @@ -95,11 +95,11 @@ void tst_QTreeWidgetItemIterator::initTestCase() const QString topS = QLatin1String("top") + QString::number(i); top->setText(0, topS); switch (i) { - case 0: testWidget->setItemHidden(top, true);break; - case 1: testWidget->setItemHidden(top, false);break; + case 0: top->setHidden(true);break; + case 1: top->setHidden(false);break; - case 2: testWidget->setItemSelected(top, true);break; - case 3: testWidget->setItemSelected(top, false);break; + case 2: top->setSelected(true);break; + case 3: top->setSelected(false);break; case 4: top->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);break; case 5: top->setFlags(Qt::ItemIsEnabled);break; @@ -126,11 +126,11 @@ void tst_QTreeWidgetItemIterator::initTestCase() QTreeWidgetItem *child = new QTreeWidgetItem(top); child->setText(0, topS + QLatin1String(",child") + QString::number(j)); switch (j) { - case 0: testWidget->setItemHidden(child, true);break; - case 1: testWidget->setItemHidden(child, false);break; + case 0: child->setHidden(true);break; + case 1: child->setHidden(false);break; - case 2: testWidget->setItemSelected(child, true);break; - case 3: testWidget->setItemSelected(child, false);break; + case 2: child->setSelected(true);break; + case 3: child->setSelected(false);break; case 4: child->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);break; case 5: child->setFlags(Qt::ItemIsEnabled);break; diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp index d2a244b762..e2ef5635c2 100644 --- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp +++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp @@ -240,6 +240,7 @@ void tst_QApplication::staticSetup() QVERIFY(style); QApplication::setStyle(style); + bool palette_changed = false; QPalette pal; QApplication::setPalette(pal); @@ -247,7 +248,11 @@ void tst_QApplication::staticSetup() QApplication::setFont(font);*/ int argc = 0; - QApplication app(argc, 0); + QApplication app(argc, nullptr); + QObject::connect(&app, &QApplication::paletteChanged, [&palette_changed]{ palette_changed = true; }); + QVERIFY(!palette_changed); + qApp->setPalette(QPalette(Qt::red)); + QVERIFY(palette_changed); } @@ -355,8 +360,8 @@ void tst_QApplication::setFont_data() int cnt = 0; QFontDatabase fdb; QStringList families = fdb.families(); - for (QStringList::const_iterator itr = families.begin(); - itr != families.end(); + for (QStringList::const_iterator itr = families.cbegin(); + itr != families.cend(); ++itr) { if (cnt < 3) { QString family = *itr; diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 360e6986f6..648c63b637 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -7655,9 +7655,6 @@ void tst_QWidget::updateWhileMinimized() // Restore window. widget.showNormal(); - QTest::qWait(30); - if (m_platform == QStringLiteral("xcb")) - QSKIP("QTBUG-26424"); QTRY_COMPARE(widget.numPaintEvents, 1); QCOMPARE(widget.paintedRegion, QRegion(0, 0, 50, 50)); } @@ -9425,7 +9422,7 @@ QWidgetBackingStore* backingStore(QWidget &widget) void tst_QWidget::rectOutsideCoordinatesLimit_task144779() { #ifndef QT_NO_CURSOR - QApplication::setOverrideCursor(Qt::BlankCursor); //keep the cursor out of screen grabs + QGuiApplication::setOverrideCursor(Qt::BlankCursor); //keep the cursor out of screen grabs #endif QWidget main(0,Qt::FramelessWindowHint); //don't get confused by the size of the window frame QPalette palette; @@ -9462,7 +9459,7 @@ void tst_QWidget::rectOutsideCoordinatesLimit_task144779() QTRY_COMPARE(mainPixmap.toImage().convertToFormat(QImage::Format_RGB32), correct.toImage().convertToFormat(QImage::Format_RGB32)); #ifndef QT_NO_CURSOR - QApplication::restoreOverrideCursor(); + QGuiApplication::restoreOverrideCursor(); #endif } diff --git a/tests/auto/widgets/kernel/qwidgetmetatype/tst_qwidgetmetatype.cpp b/tests/auto/widgets/kernel/qwidgetmetatype/tst_qwidgetmetatype.cpp index 077e8de328..06522b2bd3 100644 --- a/tests/auto/widgets/kernel/qwidgetmetatype/tst_qwidgetmetatype.cpp +++ b/tests/auto/widgets/kernel/qwidgetmetatype/tst_qwidgetmetatype.cpp @@ -41,6 +41,8 @@ public: private slots: void metaObject(); + void saveAndLoadBuiltin_data(); + void saveAndLoadBuiltin(); }; class CustomWidget : public QWidget @@ -68,5 +70,50 @@ void tst_QWidgetMetaType::metaObject() QCOMPARE(QMetaType::metaObjectForType(qMetaTypeId<QSizePolicy>()), &QSizePolicy::staticMetaObject); } +template <typename T> +struct StreamingTraits +{ + // Streamable by default, as currently all widgets built-in types are streamable + enum { isStreamable = 1 }; +}; + +void tst_QWidgetMetaType::saveAndLoadBuiltin_data() +{ + QTest::addColumn<int>("type"); + QTest::addColumn<bool>("isStreamable"); + +#define ADD_METATYPE_TEST_ROW(MetaTypeName, MetaTypeId, RealType) \ + QTest::newRow(#RealType) << MetaTypeId << bool(StreamingTraits<RealType>::isStreamable); + QT_FOR_EACH_STATIC_WIDGETS_CLASS(ADD_METATYPE_TEST_ROW) +#undef ADD_METATYPE_TEST_ROW +} + +void tst_QWidgetMetaType::saveAndLoadBuiltin() +{ + QFETCH(int, type); + QFETCH(bool, isStreamable); + + void *value = QMetaType::create(type); + + QByteArray ba; + QDataStream stream(&ba, QIODevice::ReadWrite); + QCOMPARE(QMetaType::save(stream, type, value), isStreamable); + QCOMPARE(stream.status(), QDataStream::Ok); + + if (isStreamable) + QVERIFY(QMetaType::load(stream, type, value)); + + stream.device()->seek(0); + stream.resetStatus(); + QCOMPARE(QMetaType::load(stream, type, value), isStreamable); + QCOMPARE(stream.status(), QDataStream::Ok); + + if (isStreamable) + QVERIFY(QMetaType::load(stream, type, value)); + + QMetaType::destroy(type, value); +} + + QTEST_MAIN(tst_QWidgetMetaType) #include "tst_qwidgetmetatype.moc" diff --git a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp index f5d9433f70..bfef9d2ac4 100644 --- a/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp +++ b/tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp @@ -159,7 +159,7 @@ void tst_QStyleSheetStyle::numinstances() QCOMPARE(QStyleSheetStyle::numinstances, 0); qApp->setStyleSheet("* { color: red; }"); QCOMPARE(QStyleSheetStyle::numinstances, 1); - qApp->setStyleSheet(""); + qApp->setStyleSheet(QString()); QCOMPARE(QStyleSheetStyle::numinstances, 0); // set and unset application stylesheet+widget @@ -168,9 +168,9 @@ void tst_QStyleSheetStyle::numinstances() QCOMPARE(QStyleSheetStyle::numinstances, 2); w.setStyle(style); QCOMPARE(QStyleSheetStyle::numinstances, 2); - qApp->setStyleSheet(""); + qApp->setStyleSheet(QString()); QCOMPARE(QStyleSheetStyle::numinstances, 1); - w.setStyleSheet(""); + w.setStyleSheet(QString()); QCOMPARE(QStyleSheetStyle::numinstances, 0); // set and unset widget stylesheet @@ -179,7 +179,7 @@ void tst_QStyleSheetStyle::numinstances() QCOMPARE(QStyleSheetStyle::numinstances, 1); c.setStyle(style); QCOMPARE(QStyleSheetStyle::numinstances, 2); - w.setStyleSheet(""); + w.setStyleSheet(QString()); QCOMPARE(QStyleSheetStyle::numinstances, 0); } @@ -192,9 +192,9 @@ void tst_QStyleSheetStyle::widgetsBeforeAppStyleSheet() QCOMPARE(COLOR(w1), red); w1.setStyleSheet("color: white"); QCOMPARE(COLOR(w1), white); - qApp->setStyleSheet(""); + qApp->setStyleSheet(QString()); QCOMPARE(COLOR(w1), white); - w1.setStyleSheet(""); + w1.setStyleSheet(QString()); QCOMPARE(COLOR(w1), APPCOLOR(w1)); } @@ -217,17 +217,17 @@ void tst_QStyleSheetStyle::widgetsAfterAppStyleSheet() QCOMPARE(COLOR(w1), white); QCOMPARE(COLOR(spin), red); QCOMPARE(COLOR(*spin.lineEdit()), red); - w1.setStyleSheet(""); + w1.setStyleSheet(QString()); QCOMPARE(COLOR(w1), red); QCOMPARE(COLOR(spin), red); QCOMPARE(COLOR(*spin.lineEdit()), red); w1.setStyleSheet("color: white"); QCOMPARE(COLOR(w1), white); - qApp->setStyleSheet(""); + qApp->setStyleSheet(QString()); QCOMPARE(COLOR(w1), white); QCOMPARE(COLOR(spin), APPCOLOR(spin)); QCOMPARE(COLOR(*spin.lineEdit()), APPCOLOR(*spin.lineEdit())); - w1.setStyleSheet(""); + w1.setStyleSheet(QString()); QCOMPARE(COLOR(w1), APPCOLOR(w1)); // QCOMPARE(FONTSIZE(w1), APPFONTSIZE(w1)); //### task 244261 QCOMPARE(FONTSIZE(spin), APPFONTSIZE(spin)); @@ -243,7 +243,7 @@ void tst_QStyleSheetStyle::applicationStyleSheet() QCOMPARE(COLOR(w1), red); qApp->setStyleSheet("* { color: white; }"); QCOMPARE(COLOR(w1), white); - qApp->setStyleSheet(""); + qApp->setStyleSheet(QString()); QCOMPARE(COLOR(w1), APPCOLOR(w1)); qApp->setStyleSheet("* { color: red }"); QCOMPARE(COLOR(w1), red); @@ -254,21 +254,21 @@ void tst_QStyleSheetStyle::windowStyleSheet() const QColor red(Qt::red); const QColor white(Qt::white); QPushButton w1; - qApp->setStyleSheet(""); + qApp->setStyleSheet(QString()); w1.setStyleSheet("* { color: red; }"); QCOMPARE(COLOR(w1), red); w1.setStyleSheet("* { color: white; }"); QCOMPARE(COLOR(w1), white); - w1.setStyleSheet(""); + w1.setStyleSheet(QString()); QCOMPARE(COLOR(w1), APPCOLOR(w1)); w1.setStyleSheet("* { color: red }"); QCOMPARE(COLOR(w1), red); qApp->setStyleSheet("* { color: green }"); QCOMPARE(COLOR(w1), red); - w1.setStyleSheet(""); + w1.setStyleSheet(QString()); QCOMPARE(COLOR(w1), QColor("green")); - qApp->setStyleSheet(""); + qApp->setStyleSheet(QString()); QCOMPARE(COLOR(w1), APPCOLOR(w1)); } @@ -281,7 +281,7 @@ void tst_QStyleSheetStyle::widgetStyleSheet() QPushButton *pb = new QPushButton(&w1); QPushButton &w2 = *pb; - qApp->setStyleSheet(""); + qApp->setStyleSheet(QString()); w1.setStyleSheet("* { color: red }"); QCOMPARE(COLOR(w1), red); QCOMPARE(COLOR(w2), red); @@ -293,11 +293,11 @@ void tst_QStyleSheetStyle::widgetStyleSheet() QCOMPARE(COLOR(w1), blue); QCOMPARE(COLOR(w2), white); - w1.setStyleSheet(""); + w1.setStyleSheet(QString()); QCOMPARE(COLOR(w1), APPCOLOR(w1)); QCOMPARE(COLOR(w2), white); - w2.setStyleSheet(""); + w2.setStyleSheet(QString()); QCOMPARE(COLOR(w1), APPCOLOR(w1)); QCOMPARE(COLOR(w2), APPCOLOR(w2)); } @@ -311,7 +311,7 @@ void tst_QStyleSheetStyle::reparentWithNoChildStyleSheet() QPushButton *pb = new QPushButton(&p1); QPushButton &c1 = *pb; // child with no stylesheet - qApp->setStyleSheet(""); + qApp->setStyleSheet(QString()); p1.setStyleSheet("* { color: red }"); QCOMPARE(COLOR(c1), red); c1.setParent(&p2); @@ -333,7 +333,7 @@ void tst_QStyleSheetStyle::reparentWithChildStyleSheet() { const QColor gray("gray"); const QColor white(Qt::white); - qApp->setStyleSheet(""); + qApp->setStyleSheet(QString()); QPushButton p1, p2; QPushButton *pb = new QPushButton(&p1); QPushButton &c1 = *pb; @@ -353,7 +353,7 @@ void tst_QStyleSheetStyle::repolish() { const QColor red(Qt::red); const QColor white(Qt::white); - qApp->setStyleSheet(""); + qApp->setStyleSheet(QString()); QPushButton p1; p1.setStyleSheet("color: red; background: white"); QCOMPARE(BACKGROUND(p1), white); @@ -362,14 +362,14 @@ void tst_QStyleSheetStyle::repolish() p1.setStyleSheet("color: red"); QCOMPARE(COLOR(p1), red); QCOMPARE(BACKGROUND(p1), APPBACKGROUND(p1)); - p1.setStyleSheet(""); + p1.setStyleSheet(QString()); QCOMPARE(COLOR(p1), APPCOLOR(p1)); QCOMPARE(BACKGROUND(p1), APPBACKGROUND(p1)); } void tst_QStyleSheetStyle::widgetStyle() { - qApp->setStyleSheet(""); + qApp->setStyleSheet(QString()); QWidget *window1 = new QWidget; window1->setObjectName("window1"); @@ -429,7 +429,7 @@ void tst_QStyleSheetStyle::widgetStyle() // Remove the stylesheet proxy = (QStyleSheetStyle *)window1->style(); - window1->setStyleSheet(""); + window1->setStyleSheet(QString()); QVERIFY(proxy.isNull()); // should have disappeared QCOMPARE(window1->style(), style1.data()); // its restored @@ -457,7 +457,7 @@ void tst_QStyleSheetStyle::widgetStyle() QCOMPARE(proxy->baseStyle(), style1.data()); // Style Sheet propagation on a child widget with a custom style already set - window2->setStyleSheet(""); + window2->setStyleSheet(QString()); QCOMPARE(window2->style(), style2.data()); QCOMPARE(widget2->style(), style1.data()); widget2->setStyle(0); @@ -470,9 +470,9 @@ void tst_QStyleSheetStyle::widgetStyle() // clean everything out window1->setStyle(0); - window1->setStyleSheet(""); + window1->setStyleSheet(QString()); window2->setStyle(0); - window2->setStyleSheet(""); + window2->setStyleSheet(QString()); qApp->setStyle(0); qApp->setStyleSheet("may_insanity_prevail { }"); // app has stylesheet @@ -489,14 +489,14 @@ void tst_QStyleSheetStyle::widgetStyle() QCOMPARE(proxy->baseStyle(), newStyle); // magic ;) the widget still follows the application QCOMPARE(static_cast<QStyle *>(proxy), widget1->style()); // child still follows... - window1->setStyleSheet(""); // remove stylesheet + window1->setStyleSheet(QString()); // remove stylesheet QCOMPARE(window1->style(), qApp->style()); // is this cool or what QCOMPARE(widget1->style(), qApp->style()); // annoying child follows... QScopedPointer<QStyle> wndStyle(QStyleFactory::create("Windows")); window1->setStyle(wndStyle.data()); QCOMPARE(window1->style()->metaObject()->className(), "QStyleSheetStyle"); // auto wraps it QCOMPARE(widget1->style(), window1->style()); // and auto propagates to child - qApp->setStyleSheet(""); // remove the app stylesheet + qApp->setStyleSheet(QString()); // remove the app stylesheet QCOMPARE(window1->style(), wndStyle.data()); // auto dewrap QCOMPARE(widget1->style(), qApp->style()); // and child state is restored window1->setStyle(0); // let sanity prevail @@ -511,7 +511,7 @@ void tst_QStyleSheetStyle::widgetStyle() void tst_QStyleSheetStyle::appStyle() { - qApp->setStyleSheet(""); + qApp->setStyleSheet(QString()); // qApp style can never be 0 QVERIFY(QApplication::style() != 0); QPointer<QStyle> style1 = QStyleFactory::create("Windows"); @@ -544,11 +544,11 @@ void tst_QStyleSheetStyle::appStyle() QCOMPARE(sss->baseStyle(), style1.data()); // Revert the stylesheet - qApp->setStyleSheet(""); + qApp->setStyleSheet(QString()); QVERIFY(sss.isNull()); // should have disappeared QCOMPARE(QApplication::style(), style1.data()); - qApp->setStyleSheet(""); + qApp->setStyleSheet(QString()); QCOMPARE(QApplication::style(), style1.data()); } @@ -744,7 +744,7 @@ void tst_QStyleSheetStyle::fontPropagation() window.setStyleSheet("* { font-size: 10pt }"); pb.setParent(&window); QCOMPARE(FONTSIZE(pb), 10); - window.setStyleSheet(""); + window.setStyleSheet(QString()); QCOMPARE(FONTSIZE(pb), buttonFontSize); QTabWidget tw; @@ -757,7 +757,7 @@ void tst_QStyleSheetStyle::fontPropagation() void tst_QStyleSheetStyle::onWidgetDestroyed() { - qApp->setStyleSheet(""); + qApp->setStyleSheet(QString()); QLabel *l = new QLabel; l->setStyleSheet("QLabel { color: red }"); QPointer<QStyleSheetStyle> ss = (QStyleSheetStyle *) l->style(); @@ -778,14 +778,14 @@ void tst_QStyleSheetStyle::fontPrecedence() font.setPointSize(16); edit.setFont(font); QCOMPARE(FONTSIZE(edit), 22); - edit.setStyleSheet(""); + edit.setStyleSheet(QString()); QCOMPARE(FONTSIZE(edit), 16); font.setPointSize(18); edit.setFont(font); QCOMPARE(FONTSIZE(edit), 18); edit.setStyleSheet("QLineEdit { font-size: 20pt; }"); QCOMPARE(FONTSIZE(edit), 20); - edit.setStyleSheet(""); + edit.setStyleSheet(QString()); QCOMPARE(FONTSIZE(edit), 18); edit.hide(); @@ -1189,7 +1189,7 @@ void tst_QStyleSheetStyle::transparent() QPushButton *p3=new QPushButton(&w); p1->setStyleSheet("background:transparent"); p2->setStyleSheet("background-color:transparent"); - p3->setStyleSheet("background:rgb(0,0,0,0)"); + p3->setStyleSheet("background:rgba(0,0,0,0)"); QCOMPARE(BACKGROUND(*p1) , QColor(0,0,0,0)); QCOMPARE(BACKGROUND(*p2) , QColor(0,0,0,0)); QCOMPARE(BACKGROUND(*p3) , QColor(0,0,0,0)); @@ -2051,7 +2051,7 @@ void tst_QStyleSheetStyle::styleSheetTargetAttribute() QCOMPARE(lb.testAttribute(Qt::WA_StyleSheetTarget), true); QCOMPARE(pb.testAttribute(Qt::WA_StyleSheetTarget), false); - qApp->setStyleSheet(""); + qApp->setStyleSheet(QString()); gb.ensurePolished(); lb.ensurePolished(); pb.ensurePolished(); QCOMPARE(gb.testAttribute(Qt::WA_StyleSheetTarget), false); @@ -2066,7 +2066,7 @@ void tst_QStyleSheetStyle::unpolish() w.setStyleSheet("QWidget { min-width: 100; }"); w.ensurePolished(); QCOMPARE(w.minimumWidth(), 100); - w.setStyleSheet(""); + w.setStyleSheet(QString()); QCOMPARE(w.minimumWidth(), 0); } diff --git a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp index a88fd8d19c..634e258250 100644 --- a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp +++ b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp @@ -1143,8 +1143,16 @@ void tst_QMenu::QTBUG7411_submenus_activate() QTRY_VERIFY(sub1.isVisible()); } +static bool isPlatformWayland() +{ + return !QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive); +} + void tst_QMenu::QTBUG30595_rtl_submenu() { + if (isPlatformWayland()) + QSKIP("Creating xdg_popups on Wayland requires real input events. Positions would be off."); + QMenu menu("Test Menu"); menu.setLayoutDirection(Qt::RightToLeft); QMenu sub("&sub"); @@ -1179,6 +1187,9 @@ void tst_QMenu::QTBUG20403_nested_popup_on_shortcut_trigger() #ifndef Q_OS_MACOS void tst_QMenu::click_while_dismissing_submenu() { + if (isPlatformWayland()) + QSKIP("Wayland: Creating (grabbing) popups requires real mouse events."); + QMenu menu("Test Menu"); QAction *action = menu.addAction("action"); QMenu sub("&sub"); diff --git a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp index cfa2ddc4cc..be19cbc9d1 100644 --- a/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp +++ b/tests/auto/widgets/widgets/qplaintextedit/tst_qplaintextedit.cpp @@ -140,6 +140,11 @@ private slots: void findBackwardWithRegExp(); void findWithRegExpReturnsFalseIfNoMoreResults(); #endif +#if QT_CONFIG(regularexpression) + void findWithRegularExpression(); + void findBackwardWithRegularExpression(); + void findWithRegularExpressionReturnsFalseIfNoMoreResults(); +#endif void layoutAfterMultiLineRemove(); void undoCommandRemovesAndReinsertsBlock(); void taskQTBUG_43562_lineCountCrash(); @@ -147,6 +152,9 @@ private slots: void contextMenu(); #endif void inputMethodCursorRect(); +#if QT_CONFIG(scrollbar) + void updateAfterChangeCenterOnScroll(); +#endif private: void createSelection(); @@ -1579,6 +1587,45 @@ void tst_QPlainTextEdit::findWithRegExpReturnsFalseIfNoMoreResults() } #endif +#if QT_CONFIG(regularexpression) +void tst_QPlainTextEdit::findWithRegularExpression() +{ + ed->setPlainText(QStringLiteral("arbitrary text")); + QRegularExpression rx("\\w{2}xt"); + + bool found = ed->find(rx); + + QVERIFY(found); + QCOMPARE(ed->textCursor().selectedText(), QStringLiteral("text")); +} + +void tst_QPlainTextEdit::findBackwardWithRegularExpression() +{ + ed->setPlainText(QStringLiteral("arbitrary text")); + QTextCursor cursor = ed->textCursor(); + cursor.movePosition(QTextCursor::End); + ed->setTextCursor(cursor); + QRegularExpression rx("a\\w*t"); + + bool found = ed->find(rx, QTextDocument::FindBackward); + + QVERIFY(found); + QCOMPARE(ed->textCursor().selectedText(), QStringLiteral("arbit")); +} + +void tst_QPlainTextEdit::findWithRegularExpressionReturnsFalseIfNoMoreResults() +{ + ed->setPlainText(QStringLiteral("arbitrary text")); + QRegularExpression rx("t.xt"); + ed->find(rx); + + bool found = ed->find(rx); + + QVERIFY(!found); + QCOMPARE(ed->textCursor().selectedText(), QStringLiteral("text")); +} +#endif + void tst_QPlainTextEdit::layoutAfterMultiLineRemove() { ed->setVisible(true); // The widget must be visible to reproduce this bug. @@ -1727,5 +1774,20 @@ void tst_QPlainTextEdit::inputMethodCursorRect() QCOMPARE(cursorRectV.toRect(), cursorRect.toRect()); } +#if QT_CONFIG(scrollbar) +// QTBUG-64730: Verify that the scrollbar is updated after center on scroll was set +void tst_QPlainTextEdit::updateAfterChangeCenterOnScroll() +{ + ed->setPlainText("Line1\nLine2Line3\nLine3"); + ed->show(); + ed->setCenterOnScroll(true); + const int maxWithCenterOnScroll = ed->verticalScrollBar()->maximum(); + ed->setCenterOnScroll(false); + const int maxWithoutCenterOnScroll = ed->verticalScrollBar()->maximum(); + QVERIFY(maxWithCenterOnScroll > maxWithoutCenterOnScroll); +} + +#endif + QTEST_MAIN(tst_QPlainTextEdit) #include "tst_qplaintextedit.moc" diff --git a/tests/auto/widgets/widgets/qsplitter/BLACKLIST b/tests/auto/widgets/widgets/qsplitter/BLACKLIST deleted file mode 100644 index 1352805cd7..0000000000 --- a/tests/auto/widgets/widgets/qsplitter/BLACKLIST +++ /dev/null @@ -1,2 +0,0 @@ -[replaceWidget:visible, not collapsed] -xcb diff --git a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp index 6a2ae4951b..5f5cd78215 100644 --- a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp +++ b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp @@ -199,6 +199,12 @@ private slots: void findWithRegExpReturnsFalseIfNoMoreResults(); #endif +#if QT_CONFIG(regularexpression) + void findWithRegularExpression(); + void findBackwardWithRegularExpression(); + void findWithRegularExpressionReturnsFalseIfNoMoreResults(); +#endif + #if QT_CONFIG(wheelevent) void wheelEvent(); #endif @@ -2572,6 +2578,45 @@ void tst_QTextEdit::findWithRegExpReturnsFalseIfNoMoreResults() } #endif +#if QT_CONFIG(regularexpression) +void tst_QTextEdit::findWithRegularExpression() +{ + ed->setHtml(QStringLiteral("arbitrary te<span style=\"color:#ff0000\">xt</span>")); + QRegularExpression rx("\\w{2}xt"); + + bool found = ed->find(rx); + + QVERIFY(found); + QCOMPARE(ed->textCursor().selectedText(), QStringLiteral("text")); +} + +void tst_QTextEdit::findBackwardWithRegularExpression() +{ + ed->setPlainText(QStringLiteral("arbitrary text")); + QTextCursor cursor = ed->textCursor(); + cursor.movePosition(QTextCursor::End); + ed->setTextCursor(cursor); + QRegularExpression rx("a\\w*t"); + + bool found = ed->find(rx, QTextDocument::FindBackward); + + QVERIFY(found); + QCOMPARE(ed->textCursor().selectedText(), QStringLiteral("arbit")); +} + +void tst_QTextEdit::findWithRegularExpressionReturnsFalseIfNoMoreResults() +{ + ed->setPlainText(QStringLiteral("arbitrary text")); + QRegularExpression rx("t.xt"); + ed->find(rx); + + bool found = ed->find(rx); + + QVERIFY(!found); + QCOMPARE(ed->textCursor().selectedText(), QStringLiteral("text")); +} +#endif + #if QT_CONFIG(wheelevent) class TextEdit : public QTextEdit |