diff options
Diffstat (limited to 'tests/auto/corelib/itemmodels')
16 files changed, 253 insertions, 300 deletions
diff --git a/tests/auto/corelib/itemmodels/qabstractitemmodel/qabstractitemmodel.pro b/tests/auto/corelib/itemmodels/qabstractitemmodel/qabstractitemmodel.pro index ef571de192..7480bd45f6 100644 --- a/tests/auto/corelib/itemmodels/qabstractitemmodel/qabstractitemmodel.pro +++ b/tests/auto/corelib/itemmodels/qabstractitemmodel/qabstractitemmodel.pro @@ -1,5 +1,4 @@ CONFIG += testcase -CONFIG += parallel_test TARGET = tst_qabstractitemmodel QT = core testlib diff --git a/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp b/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp index c4d2df7c3e..dcd9eda4bb 100644 --- a/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp +++ b/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp @@ -1,31 +1,26 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** @@ -157,9 +152,10 @@ QtTestModel::QtTestModel(int rows, int columns, QObject *parent) { table.resize(rows); for (int r = 0; r < rows; ++r) { + const QString prefix = QString::number(r) + QLatin1Char('/'); table[r].resize(columns); for (int c = 0; c < columns; ++c) - table[r][c] = QString("%1/%2").arg(r).arg(c); + table[r][c] = prefix + QString::number(c); } } @@ -1699,8 +1695,8 @@ void tst_QAbstractItemModel::testMoveToDescendants() moveCommand->setDestRow(row); moveCommand->doCommand(); - QVERIFY(beforeSpy.size() == 0); - QVERIFY(afterSpy.size() == 0); + QCOMPARE(beforeSpy.size(), 0); + QCOMPARE(afterSpy.size(), 0); } } } @@ -1757,8 +1753,8 @@ void tst_QAbstractItemModel::testMoveWithinOwnRange() moveCommand->setDestRow(destRow); moveCommand->doCommand(); - QVERIFY(beforeSpy.size() == 0); - QVERIFY(afterSpy.size() == 0); + QCOMPARE(beforeSpy.size(), 0); + QCOMPARE(afterSpy.size(), 0); } class ListenerObject : public QObject @@ -1823,7 +1819,7 @@ void ListenerObject::slotAboutToBeReset() // Nothing has been changed yet. All indexes should be the same. for (int i = 0; i < m_persistentIndexes.size(); ++i) { QModelIndex idx = m_persistentIndexes.at(i); - QVERIFY(idx == m_nonPersistentIndexes.at(i)); + QCOMPARE(idx, m_nonPersistentIndexes.at(i)); QVERIFY(m_model->mapToSource(idx).isValid()); } } @@ -1859,13 +1855,13 @@ void tst_QAbstractItemModel::testReset() resetCommand->doCommand(); // Verify that the correct signals were emitted - QVERIFY(beforeResetSpy.size() == 1); - QVERIFY(afterResetSpy.size() == 1); + QCOMPARE(beforeResetSpy.size(), 1); + QCOMPARE(afterResetSpy.size(), 1); // Verify that the move actually happened. - QVERIFY(m_model->rowCount() == 9); + QCOMPARE(m_model->rowCount(), 9); QModelIndex destIndex = m_model->index(4, 0); - QVERIFY(m_model->rowCount(destIndex) == 11); + QCOMPARE(m_model->rowCount(destIndex), 11); // Delete it because its slots test things which are not true after this point. delete listener; @@ -1877,14 +1873,14 @@ void tst_QAbstractItemModel::testReset() QCOMPARE(nullProxy->roleNames().value(Qt::UserRole + 1), QByteArray()); nullProxy->setSourceModel(new ModelWithCustomRole(this)); - QVERIFY(proxyBeforeResetSpy.size() == 1); - QVERIFY(proxyAfterResetSpy.size() == 1); + QCOMPARE(proxyBeforeResetSpy.size(), 1); + QCOMPARE(proxyAfterResetSpy.size(), 1); QCOMPARE(nullProxy->roleNames().value(Qt::UserRole + 1), QByteArray("custom")); nullProxy->setSourceModel(m_model); - QVERIFY(proxyBeforeResetSpy.size() == 2); - QVERIFY(proxyAfterResetSpy.size() == 2); + QCOMPARE(proxyBeforeResetSpy.size(), 2); + QCOMPARE(proxyAfterResetSpy.size(), 2); // After being reset the proxy must be queried again. QCOMPARE(nullProxy->roleNames().value(Qt::UserRole + 1), QByteArray()); @@ -2055,10 +2051,10 @@ void tst_QAbstractItemModel::testChildrenLayoutsChanged() QVERIFY(afterParents.contains(p2)); // The first will be the last, and the lest will be the first. - QVERIFY(p1FirstPersistent.row() == 1); - QVERIFY(p1LastPersistent.row() == 0); - QVERIFY(p2FirstPersistent.row() == 9); - QVERIFY(p2LastPersistent.row() == 8); + QCOMPARE(p1FirstPersistent.row(), 1); + QCOMPARE(p1LastPersistent.row(), 0); + QCOMPARE(p2FirstPersistent.row(), 9); + QCOMPARE(p2LastPersistent.row(), 8); } insertCommand = new ModelInsertCommand(&model, this); @@ -2115,8 +2111,8 @@ void tst_QAbstractItemModel::testChildrenLayoutsChanged() QCOMPARE(beforeSignal.size(), 2); QCOMPARE(afterSignal.size(), 2); - QVERIFY(p1FirstPersistent.row() == 1); - QVERIFY(p1LastPersistent.row() == 0); + QCOMPARE(p1FirstPersistent.row(), 1); + QCOMPARE(p1LastPersistent.row(), 0); QCOMPARE(p2FirstPersistent.row(), 9); QCOMPARE(p2LastPersistent.row(), 8); } diff --git a/tests/auto/corelib/itemmodels/qabstractproxymodel/qabstractproxymodel.pro b/tests/auto/corelib/itemmodels/qabstractproxymodel/qabstractproxymodel.pro index 7209620b91..19aec43072 100644 --- a/tests/auto/corelib/itemmodels/qabstractproxymodel/qabstractproxymodel.pro +++ b/tests/auto/corelib/itemmodels/qabstractproxymodel/qabstractproxymodel.pro @@ -1,5 +1,4 @@ CONFIG += testcase -CONFIG += parallel_test TARGET = tst_qabstractproxymodel QT += testlib SOURCES += tst_qabstractproxymodel.cpp diff --git a/tests/auto/corelib/itemmodels/qabstractproxymodel/tst_qabstractproxymodel.cpp b/tests/auto/corelib/itemmodels/qabstractproxymodel/tst_qabstractproxymodel.cpp index fb9d118d60..6c870737da 100644 --- a/tests/auto/corelib/itemmodels/qabstractproxymodel/tst_qabstractproxymodel.cpp +++ b/tests/auto/corelib/itemmodels/qabstractproxymodel/tst_qabstractproxymodel.cpp @@ -1,31 +1,26 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** @@ -351,7 +346,7 @@ static void verifySubSetOf(const QHash<int, QByteArray> &superSet, const QHash<i const QHash<int, QByteArray>::const_iterator end = subSet.constEnd(); for ( ; it != end; ++it ) { QVERIFY(superSet.contains(it.key())); - QVERIFY(it.value() == superSet.value(it.key())); + QCOMPARE(it.value(), superSet.value(it.key())); } } diff --git a/tests/auto/corelib/itemmodels/qidentityproxymodel/qidentityproxymodel.pro b/tests/auto/corelib/itemmodels/qidentityproxymodel/qidentityproxymodel.pro index f57b419ae5..ba32f02962 100644 --- a/tests/auto/corelib/itemmodels/qidentityproxymodel/qidentityproxymodel.pro +++ b/tests/auto/corelib/itemmodels/qidentityproxymodel/qidentityproxymodel.pro @@ -1,5 +1,4 @@ CONFIG += testcase -CONFIG += parallel_test TARGET = tst_qidentityproxymodel mtdir = ../../../other/modeltest @@ -7,4 +6,3 @@ INCLUDEPATH += $$PWD/$${mtdir} QT += testlib SOURCES += tst_qidentityproxymodel.cpp $${mtdir}/dynamictreemodel.cpp $${mtdir}/modeltest.cpp HEADERS += $${mtdir}/dynamictreemodel.h $${mtdir}/modeltest.h -DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp b/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp index 9eb3bc5113..e946f3104a 100644 --- a/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp +++ b/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp @@ -1,31 +1,26 @@ /**************************************************************************** ** ** Copyright (C) 2011 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> -** Contact: http://www.qt.io/licensing/ +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the QtGui module of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** @@ -111,25 +106,25 @@ void tst_QIdentityProxyModel::verifyIdentity(QAbstractItemModel *model, const QM const int columns = model->columnCount(parent); const QModelIndex proxyParent = m_proxy->mapFromSource(parent); - QVERIFY(m_proxy->mapToSource(proxyParent) == parent); - QVERIFY(rows == m_proxy->rowCount(proxyParent)); - QVERIFY(columns == m_proxy->columnCount(proxyParent)); + QCOMPARE(m_proxy->mapToSource(proxyParent), parent); + QCOMPARE(rows, m_proxy->rowCount(proxyParent)); + QCOMPARE(columns, m_proxy->columnCount(proxyParent)); for (int row = 0; row < rows; ++row) { for (int column = 0; column < columns; ++column) { const QModelIndex idx = model->index(row, column, parent); const QModelIndex proxyIdx = m_proxy->mapFromSource(idx); - QVERIFY(proxyIdx.model() == m_proxy); - QVERIFY(m_proxy->mapToSource(proxyIdx) == idx); + QCOMPARE(proxyIdx.model(), m_proxy); + QCOMPARE(m_proxy->mapToSource(proxyIdx), idx); QVERIFY(proxyIdx.isValid()); - QVERIFY(proxyIdx.row() == row); - QVERIFY(proxyIdx.column() == column); - QVERIFY(proxyIdx.parent() == proxyParent); - QVERIFY(proxyIdx.data() == idx.data()); - QVERIFY(proxyIdx.flags() == idx.flags()); + QCOMPARE(proxyIdx.row(), row); + QCOMPARE(proxyIdx.column(), column); + QCOMPARE(proxyIdx.parent(), proxyParent); + QCOMPARE(proxyIdx.data(), idx.data()); + QCOMPARE(proxyIdx.flags(), idx.flags()); const int childCount = m_proxy->rowCount(proxyIdx); const bool hasChildren = m_proxy->hasChildren(proxyIdx); - QVERIFY(model->hasChildren(idx) == hasChildren); + QCOMPARE(model->hasChildren(idx), hasChildren); QVERIFY((childCount > 0) == hasChildren); if (hasChildren) @@ -146,7 +141,7 @@ void tst_QIdentityProxyModel::insertRows() { QStandardItem *parentItem = m_model->invisibleRootItem(); for (int i = 0; i < 4; ++i) { - QStandardItem *item = new QStandardItem(QString("item %0").arg(i)); + QStandardItem *item = new QStandardItem(QLatin1String("item ") + QString::number(i)); parentItem->appendRow(item); parentItem = item; } @@ -171,13 +166,13 @@ void tst_QIdentityProxyModel::insertRows() QVERIFY(modelBeforeSpy.size() == 1 && 1 == proxyBeforeSpy.size()); QVERIFY(modelAfterSpy.size() == 1 && 1 == proxyAfterSpy.size()); - QVERIFY(modelBeforeSpy.first().first().value<QModelIndex>() == m_proxy->mapToSource(proxyBeforeSpy.first().first().value<QModelIndex>())); - QVERIFY(modelBeforeSpy.first().at(1) == proxyBeforeSpy.first().at(1)); - QVERIFY(modelBeforeSpy.first().at(2) == proxyBeforeSpy.first().at(2)); + QCOMPARE(modelBeforeSpy.first().first().value<QModelIndex>(), m_proxy->mapToSource(proxyBeforeSpy.first().first().value<QModelIndex>())); + QCOMPARE(modelBeforeSpy.first().at(1), proxyBeforeSpy.first().at(1)); + QCOMPARE(modelBeforeSpy.first().at(2), proxyBeforeSpy.first().at(2)); - QVERIFY(modelAfterSpy.first().first().value<QModelIndex>() == m_proxy->mapToSource(proxyAfterSpy.first().first().value<QModelIndex>())); - QVERIFY(modelAfterSpy.first().at(1) == proxyAfterSpy.first().at(1)); - QVERIFY(modelAfterSpy.first().at(2) == proxyAfterSpy.first().at(2)); + QCOMPARE(modelAfterSpy.first().first().value<QModelIndex>(), m_proxy->mapToSource(proxyAfterSpy.first().first().value<QModelIndex>())); + QCOMPARE(modelAfterSpy.first().at(1), proxyAfterSpy.first().at(1)); + QCOMPARE(modelAfterSpy.first().at(2), proxyAfterSpy.first().at(2)); verifyIdentity(m_model); } @@ -186,7 +181,7 @@ void tst_QIdentityProxyModel::removeRows() { QStandardItem *parentItem = m_model->invisibleRootItem(); for (int i = 0; i < 4; ++i) { - QStandardItem *item = new QStandardItem(QString("item %0").arg(i)); + QStandardItem *item = new QStandardItem(QLatin1String("item ") + QString::number(i)); parentItem->appendRow(item); parentItem = item; } @@ -216,13 +211,13 @@ void tst_QIdentityProxyModel::removeRows() QVERIFY(modelBeforeSpy.size() == 1 && 1 == proxyBeforeSpy.size()); QVERIFY(modelAfterSpy.size() == 1 && 1 == proxyAfterSpy.size()); - QVERIFY(modelBeforeSpy.first().first().value<QModelIndex>() == m_proxy->mapToSource(proxyBeforeSpy.first().first().value<QModelIndex>())); - QVERIFY(modelBeforeSpy.first().at(1) == proxyBeforeSpy.first().at(1)); - QVERIFY(modelBeforeSpy.first().at(2) == proxyBeforeSpy.first().at(2)); + QCOMPARE(modelBeforeSpy.first().first().value<QModelIndex>(), m_proxy->mapToSource(proxyBeforeSpy.first().first().value<QModelIndex>())); + QCOMPARE(modelBeforeSpy.first().at(1), proxyBeforeSpy.first().at(1)); + QCOMPARE(modelBeforeSpy.first().at(2), proxyBeforeSpy.first().at(2)); - QVERIFY(modelAfterSpy.first().first().value<QModelIndex>() == m_proxy->mapToSource(proxyAfterSpy.first().first().value<QModelIndex>())); - QVERIFY(modelAfterSpy.first().at(1) == proxyAfterSpy.first().at(1)); - QVERIFY(modelAfterSpy.first().at(2) == proxyAfterSpy.first().at(2)); + QCOMPARE(modelAfterSpy.first().first().value<QModelIndex>(), m_proxy->mapToSource(proxyAfterSpy.first().first().value<QModelIndex>())); + QCOMPARE(modelAfterSpy.first().at(1), proxyAfterSpy.first().at(1)); + QCOMPARE(modelAfterSpy.first().at(2), proxyAfterSpy.first().at(2)); verifyIdentity(m_model); } @@ -271,17 +266,17 @@ void tst_QIdentityProxyModel::moveRows() QVERIFY(modelBeforeSpy.size() == 1 && 1 == proxyBeforeSpy.size()); QVERIFY(modelAfterSpy.size() == 1 && 1 == proxyAfterSpy.size()); - QVERIFY(modelBeforeSpy.first().first().value<QModelIndex>() == m_proxy->mapToSource(proxyBeforeSpy.first().first().value<QModelIndex>())); - QVERIFY(modelBeforeSpy.first().at(1) == proxyBeforeSpy.first().at(1)); - QVERIFY(modelBeforeSpy.first().at(2) == proxyBeforeSpy.first().at(2)); - QVERIFY(modelBeforeSpy.first().at(3).value<QModelIndex>() == m_proxy->mapToSource(proxyBeforeSpy.first().at(3).value<QModelIndex>())); - QVERIFY(modelBeforeSpy.first().at(4) == proxyBeforeSpy.first().at(4)); + QCOMPARE(modelBeforeSpy.first().first().value<QModelIndex>(), m_proxy->mapToSource(proxyBeforeSpy.first().first().value<QModelIndex>())); + QCOMPARE(modelBeforeSpy.first().at(1), proxyBeforeSpy.first().at(1)); + QCOMPARE(modelBeforeSpy.first().at(2), proxyBeforeSpy.first().at(2)); + QCOMPARE(modelBeforeSpy.first().at(3).value<QModelIndex>(), m_proxy->mapToSource(proxyBeforeSpy.first().at(3).value<QModelIndex>())); + QCOMPARE(modelBeforeSpy.first().at(4), proxyBeforeSpy.first().at(4)); - QVERIFY(modelAfterSpy.first().first().value<QModelIndex>() == m_proxy->mapToSource(proxyAfterSpy.first().first().value<QModelIndex>())); - QVERIFY(modelAfterSpy.first().at(1) == proxyAfterSpy.first().at(1)); - QVERIFY(modelAfterSpy.first().at(2) == proxyAfterSpy.first().at(2)); - QVERIFY(modelAfterSpy.first().at(3).value<QModelIndex>() == m_proxy->mapToSource(proxyAfterSpy.first().at(3).value<QModelIndex>())); - QVERIFY(modelAfterSpy.first().at(4) == proxyAfterSpy.first().at(4)); + QCOMPARE(modelAfterSpy.first().first().value<QModelIndex>(), m_proxy->mapToSource(proxyAfterSpy.first().first().value<QModelIndex>())); + QCOMPARE(modelAfterSpy.first().at(1), proxyAfterSpy.first().at(1)); + QCOMPARE(modelAfterSpy.first().at(2), proxyAfterSpy.first().at(2)); + QCOMPARE(modelAfterSpy.first().at(3).value<QModelIndex>(), m_proxy->mapToSource(proxyAfterSpy.first().at(3).value<QModelIndex>())); + QCOMPARE(modelAfterSpy.first().at(4), proxyAfterSpy.first().at(4)); verifyIdentity(&model); @@ -352,7 +347,7 @@ void tst_QIdentityProxyModel::dataChanged() model.changeData(); QCOMPARE(modelSpy.first().at(2).value<QVector<int> >(), QVector<int>() << 1); - QVERIFY(modelSpy.first().at(2) == proxySpy.first().at(2)); + QCOMPARE(modelSpy.first().at(2), proxySpy.first().at(2)); verifyIdentity(&model); m_proxy->setSourceModel(0); diff --git a/tests/auto/corelib/itemmodels/qitemmodel/modelstotest.cpp b/tests/auto/corelib/itemmodels/qitemmodel/modelstotest.cpp index e0e688cc3a..4b3f76a78e 100644 --- a/tests/auto/corelib/itemmodels/qitemmodel/modelstotest.cpp +++ b/tests/auto/corelib/itemmodels/qitemmodel/modelstotest.cpp @@ -1,31 +1,26 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** @@ -236,7 +231,7 @@ QModelIndex ModelsToTest::populateTestArea(QAbstractItemModel *model) { if (QStringListModel *stringListModel = qobject_cast<QStringListModel *>(model)) { QString alphabet = "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z"; - stringListModel->setStringList( alphabet.split(",") ); + stringListModel->setStringList( alphabet.split(QLatin1Char(',')) ); return QModelIndex(); } @@ -317,7 +312,7 @@ QModelIndex ModelsToTest::populateTestArea(QAbstractItemModel *model) QDir tempDir(m_dirModelTempDir->path()); for (int i = 0; i < 26; ++i) { - const QString subdir = QString("foo_") + QString::number(i); + const QString subdir = QLatin1String("foo_") + QString::number(i); if (!tempDir.mkdir(subdir)) qFatal("Cannot create directory %s", qPrintable(QDir::toNativeSeparators(tempDir.path() + QLatin1Char('/') +subdir))); @@ -355,7 +350,7 @@ QModelIndex ModelsToTest::populateTestArea(QAbstractItemModel *model) int items = 50; #endif while (items--) - listWidget->addItem(QString("item %1").arg(items)); + listWidget->addItem(QLatin1String("item ") + QString::number(items)); return QModelIndex(); } @@ -370,9 +365,10 @@ QModelIndex ModelsToTest::populateTestArea(QAbstractItemModel *model) treeWidget->setColumnCount(1); QTreeWidgetItem *parent; while (topItems--){ - parent = new QTreeWidgetItem(treeWidget, QStringList(QString("top %1").arg(topItems))); + const QString tS = QString::number(topItems); + parent = new QTreeWidgetItem(treeWidget, QStringList(QLatin1String("top ") + tS)); for (int i = 0; i < 20; ++i) - new QTreeWidgetItem(parent, QStringList(QString("child %1").arg(topItems))); + new QTreeWidgetItem(parent, QStringList(QLatin1String("child ") + tS)); } return QModelIndex(); } diff --git a/tests/auto/corelib/itemmodels/qitemmodel/qitemmodel.pro b/tests/auto/corelib/itemmodels/qitemmodel/qitemmodel.pro index 42c9c8f9fb..ff21d6afa5 100644 --- a/tests/auto/corelib/itemmodels/qitemmodel/qitemmodel.pro +++ b/tests/auto/corelib/itemmodels/qitemmodel/qitemmodel.pro @@ -2,4 +2,3 @@ CONFIG += testcase TARGET = tst_qitemmodel QT += widgets sql testlib SOURCES = tst_qitemmodel.cpp -DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp b/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp index 6971f7ef78..8ebb860edd 100644 --- a/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp +++ b/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp @@ -1,31 +1,26 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** @@ -359,7 +354,7 @@ void tst_QItemModel::index() // Make sure that the same index is always returned QModelIndex a = currentModel->index(0,0); QModelIndex b = currentModel->index(0,0); - QVERIFY(a == b); + QCOMPARE(a, b); // index is tested more extensivly more later in checkChildren(), // but this catches the big mistakes @@ -423,7 +418,7 @@ void checkChildren(QAbstractItemModel *currentModel, const QModelIndex &parent, // Make sure we get the same index if we request it twice in a row QModelIndex a = currentModel->index(r, c, parent); QModelIndex b = currentModel->index(r, c, parent); - QVERIFY(a == b); + QCOMPARE(a, b); { const QModelIndex sibling = currentModel->sibling( r, c, topLeftChild ); @@ -435,7 +430,7 @@ void checkChildren(QAbstractItemModel *currentModel, const QModelIndex &parent, } // Some basic checking on the index that is returned - QVERIFY(index.model() == currentModel); + QCOMPARE(index.model(), currentModel); QCOMPARE(index.row(), r); QCOMPARE(index.column(), c); QCOMPARE(currentModel->data(index, Qt::DisplayRole).isValid(), true); diff --git a/tests/auto/corelib/itemmodels/qitemselectionmodel/qitemselectionmodel.pro b/tests/auto/corelib/itemmodels/qitemselectionmodel/qitemselectionmodel.pro index 1b6279ba1b..4dcddc8feb 100644 --- a/tests/auto/corelib/itemmodels/qitemselectionmodel/qitemselectionmodel.pro +++ b/tests/auto/corelib/itemmodels/qitemselectionmodel/qitemselectionmodel.pro @@ -1,6 +1,4 @@ CONFIG += testcase -CONFIG += parallel_test TARGET = tst_qitemselectionmodel QT += testlib SOURCES += tst_qitemselectionmodel.cpp -DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp b/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp index 38e2900c25..fb3968c838 100644 --- a/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp +++ b/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp @@ -1,31 +1,26 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** @@ -1515,7 +1510,7 @@ class MyStandardItemModel: public QStandardItemModel Q_OBJECT public: inline MyStandardItemModel(int i1, int i2): QStandardItemModel(i1, i2) {} - inline void reset() { QStandardItemModel::reset(); } + inline void reset() { beginResetModel(); endResetModel(); } }; void tst_QItemSelectionModel::resetModel() @@ -1760,7 +1755,7 @@ void tst_QItemSelectionModel::modelLayoutChanged() // verify that selection is as expected QItemSelection selection = selectionModel.selection(); QCOMPARE(selection.count(), expectedSelectedRanges.count()); - QVERIFY(selectionModel.hasSelection() == !expectedSelectedRanges.isEmpty()); + QCOMPARE(selectionModel.hasSelection(), !expectedSelectedRanges.isEmpty()); for (int i = 0; i < expectedSelectedRanges.count(); ++i) { IntPairPair expectedRange = expectedSelectedRanges.at(i); @@ -1974,8 +1969,9 @@ void tst_QItemSelectionModel::rowIntersectsSelection2() { QStandardItemModel m; for (int i=0; i<8; ++i) { + const QString text = QLatin1String("Item number ") + QString::number(i); for (int j=0; j<8; ++j) { - QStandardItem *item = new QStandardItem(QString("Item number %1").arg(i)); + QStandardItem *item = new QStandardItem(text); if ((i % 2 == 0 && j == 0) || (j % 2 == 0 && i == 0) || j == 5 || i == 5 ) { @@ -2021,7 +2017,7 @@ void tst_QItemSelectionModel::rowIntersectsSelection3() QStandardItemModel model; QStandardItem *parentItem = model.invisibleRootItem(); for (int i = 0; i < 4; ++i) { - QStandardItem *item = new QStandardItem(QString("item %0").arg(i)); + QStandardItem *item = new QStandardItem(QLatin1String("item ") + QString::number(i)); parentItem->appendRow(item); parentItem = item; } @@ -2046,7 +2042,7 @@ void tst_QItemSelectionModel::unselectable() QStandardItem *parentItem = model.invisibleRootItem(); for (int i = 0; i < 10; ++i) { - QStandardItem *item = new QStandardItem(QString("item %0").arg(i)); + QStandardItem *item = new QStandardItem(QLatin1String("item ") + QString::number(i)); parentItem->appendRow(item); } QItemSelectionModel selectionModel(&model); @@ -2093,7 +2089,8 @@ public: QVariant data(const QModelIndex &idx, int role) const { if (role == Qt::DisplayRole || role == Qt::EditRole) - return QString("[%1,%2]").arg(idx.row()).arg(idx.column()); + return QLatin1Char('[') + QString::number(idx.row()) + QLatin1Char(',') + + QString::number(idx.column()) + QLatin1Char(']'); return QVariant(); } @@ -2202,7 +2199,7 @@ void tst_QItemSelectionModel::childrenDeselectionSignal() QStandardItem *parentItem = model.invisibleRootItem(); for (int i = 0; i < 4; ++i) { - QStandardItem *item = new QStandardItem(QString("item %0").arg(i)); + QStandardItem *item = new QStandardItem(QLatin1String("item ") + QString::number(i)); parentItem->appendRow(item); parentItem = item; } @@ -2217,7 +2214,7 @@ void tst_QItemSelectionModel::childrenDeselectionSignal() QSignalSpy deselectSpy(&selectionModel, &QItemSelectionModel::selectionChanged); QVERIFY(deselectSpy.isValid()); model.removeRows(0, 1, root); - QVERIFY(deselectSpy.count() == 1); + QCOMPARE(deselectSpy.count(), 1); // More testing stress for the patch. model.clear(); @@ -2225,13 +2222,14 @@ void tst_QItemSelectionModel::childrenDeselectionSignal() parentItem = model.invisibleRootItem(); for (int i = 0; i < 2; ++i) { - QStandardItem *item = new QStandardItem(QString("item %0").arg(i)); + QStandardItem *item = new QStandardItem(QLatin1String("item ") + QString::number(i)); parentItem->appendRow(item); } for (int i = 0; i < 2; ++i) { parentItem = model.invisibleRootItem()->child(i, 0); + const QString prefix = QLatin1String("item ") + QString::number(i) + QLatin1Char('.'); for (int j = 0; j < 2; ++j) { - QStandardItem *item = new QStandardItem(QString("item %0.%1").arg(i).arg(j)); + QStandardItem *item = new QStandardItem(prefix + QString::number(j)); parentItem->appendRow(item); } } @@ -2245,7 +2243,7 @@ void tst_QItemSelectionModel::childrenDeselectionSignal() QVERIFY(selectionModel.selection().contains(sel2)); deselectSpy.clear(); model.removeRow(0, model.index(0, 0)); - QVERIFY(deselectSpy.count() == 1); + QCOMPARE(deselectSpy.count(), 1); QVERIFY(!selectionModel.selection().contains(sel)); QVERIFY(selectionModel.selection().contains(sel2)); } @@ -2304,13 +2302,12 @@ void tst_QItemSelectionModel::layoutChangedWithAllSelected2() // Populate the tree view. for (unsigned int i = 0; i < cNumCols; i++) - model.setHeaderData( i, Qt::Horizontal, QString::fromLatin1("Column %1").arg(i)); + model.setHeaderData( i, Qt::Horizontal, QLatin1String("Column ") + QString::number(i)); for (unsigned int r = 0; r < cNumRows; r++) { - for (unsigned int c = 0; c < cNumCols; c++) { - model.setData(model.index(r, c, QModelIndex()), - QString::fromLatin1("r:%1/c:%2").arg(r, c)); - } + const QString prefix = QLatin1String("r:") + QString::number(r) + QLatin1String("/c:"); + for (unsigned int c = 0; c < cNumCols; c++) + model.setData(model.index(r, c, QModelIndex()), prefix + QString::number(c)); } QCOMPARE(model.rowCount(), int(cNumRows)); @@ -2375,7 +2372,7 @@ public slots: foreach(const QModelIndex &index, deselected.indexes()) { QVERIFY(!m_itemSelectionModel->selection().contains(index)); } - QVERIFY(m_itemSelectionModel->selection().size() == 2); + QCOMPARE(m_itemSelectionModel->selection().size(), 2); } }; @@ -2393,7 +2390,7 @@ void tst_QItemSelectionModel::deselectRemovedMiddleRange() selModel.select(QItemSelection(model.index(3, 0), model.index(6, 0)), QItemSelectionModel::Select); - QVERIFY(selModel.selection().size() == 1); + QCOMPARE(selModel.selection().size(), 1); RemovalObserver ro(&selModel); @@ -2402,7 +2399,7 @@ void tst_QItemSelectionModel::deselectRemovedMiddleRange() bool ok = model.removeRows(4, 2); QVERIFY(ok); - QVERIFY(spy.size() == 1); + QCOMPARE(spy.size(), 1); } static QStandardItemModel* getModel(QObject *parent) @@ -2412,15 +2409,16 @@ static QStandardItemModel* getModel(QObject *parent) for (int i = 0; i < 4; ++i) { QStandardItem *parentItem = model->invisibleRootItem(); QList<QStandardItem*> list; + const QString prefix = QLatin1String("item ") + QString::number(i) + QLatin1String(", "); for (int j = 0; j < 4; ++j) { - list.append(new QStandardItem(QString("item %1, %2").arg(i).arg(j))); + list.append(new QStandardItem(prefix + QString::number(j))); } parentItem->appendRow(list); parentItem = list.first(); for (int j = 0; j < 4; ++j) { QList<QStandardItem*> list; for (int k = 0; k < 4; ++k) { - list.append(new QStandardItem(QString("item %1, %2").arg(i).arg(j))); + list.append(new QStandardItem(prefix + QString::number(j))); } parentItem->appendRow(list); } @@ -2713,8 +2711,8 @@ void tst_QItemSelectionModel::testChainedSelectionClear() QModelIndexList selectedIndexes = selectionModel.selection().indexes(); QModelIndexList duplicatedIndexes = duplicate.selection().indexes(); - QVERIFY(selectedIndexes.size() == duplicatedIndexes.size()); - QVERIFY(selectedIndexes.size() == 1); + QCOMPARE(selectedIndexes.size(), duplicatedIndexes.size()); + QCOMPARE(selectedIndexes.size(), 1); QVERIFY(selectedIndexes.first() == model.index(0, 0)); } @@ -2724,18 +2722,18 @@ void tst_QItemSelectionModel::testChainedSelectionClear() QModelIndexList selectedIndexes = selectionModel.selection().indexes(); QModelIndexList duplicatedIndexes = duplicate.selection().indexes(); - QVERIFY(selectedIndexes.size() == duplicatedIndexes.size()); - QVERIFY(selectedIndexes.size() == 0); + QCOMPARE(selectedIndexes.size(), duplicatedIndexes.size()); + QCOMPARE(selectedIndexes.size(), 0); } duplicate.setCurrentIndex(model.index(0, 0), QItemSelectionModel::NoUpdate); - QVERIFY(selectionModel.currentIndex() == duplicate.currentIndex()); + QCOMPARE(selectionModel.currentIndex(), duplicate.currentIndex()); duplicate.clearCurrentIndex(); QVERIFY(!duplicate.currentIndex().isValid()); - QVERIFY(selectionModel.currentIndex() == duplicate.currentIndex()); + QCOMPARE(selectionModel.currentIndex(), duplicate.currentIndex()); } void tst_QItemSelectionModel::testClearCurrentIndex() @@ -2750,13 +2748,13 @@ void tst_QItemSelectionModel::testClearCurrentIndex() QModelIndex firstIndex = model.index(0, 0); QVERIFY(firstIndex.isValid()); selectionModel.setCurrentIndex(firstIndex, QItemSelectionModel::NoUpdate); - QVERIFY(selectionModel.currentIndex() == firstIndex); - QVERIFY(currentIndexSpy.size() == 1); + QCOMPARE(selectionModel.currentIndex(), firstIndex); + QCOMPARE(currentIndexSpy.size(), 1); selectionModel.clearCurrentIndex(); - QVERIFY(selectionModel.currentIndex() == QModelIndex()); - QVERIFY(currentIndexSpy.size() == 2); + QCOMPARE(selectionModel.currentIndex(), QModelIndex()); + QCOMPARE(currentIndexSpy.size(), 2); } void tst_QItemSelectionModel::QTBUG48402_data() diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/qsortfilterproxymodel.pro b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/qsortfilterproxymodel.pro index 25947990a7..099f666def 100644 --- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/qsortfilterproxymodel.pro +++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/qsortfilterproxymodel.pro @@ -1,5 +1,4 @@ CONFIG += testcase -CONFIG += parallel_test TARGET = tst_qsortfilterproxymodel QT += widgets testlib @@ -8,4 +7,3 @@ mtdir = ../../../other/modeltest INCLUDEPATH += $$PWD/$${mtdir} SOURCES += tst_qsortfilterproxymodel.cpp $${mtdir}/dynamictreemodel.cpp $${mtdir}/modeltest.cpp HEADERS += $${mtdir}/dynamictreemodel.h $${mtdir}/modeltest.h -DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp index 0302ae5cbf..8e2d583961 100644 --- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp +++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp @@ -1,31 +1,26 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** @@ -341,7 +336,7 @@ void tst_QSortFilterProxyModel::sort_data() QStringList list; for (int i = 10000; i < 20000; ++i) - list.append(QString("Number: %1").arg(i)); + list.append(QStringLiteral("Number: ") + QString::number(i)); QTest::newRow("large set ascending") << static_cast<int>(Qt::AscendingOrder) << int(Qt::CaseSensitive) << list << list; } @@ -1346,14 +1341,14 @@ void tst_QSortFilterProxyModel::buildHierarchy(const QStringList &l, QAbstractIt QStack<QModelIndex> parent_stack; for (int i = 0; i < l.count(); ++i) { QString token = l.at(i); - if (token == "<") { // start table + if (token == QLatin1String("<")) { // start table ++ind; parent_stack.push(parent); row_stack.push(row); parent = m->index(row - 1, 0, parent); row = 0; QVERIFY(m->insertColumns(0, 1, parent)); // add column - } else if (token == ">") { // end table + } else if (token == QLatin1String(">")) { // end table --ind; parent = parent_stack.pop(); row = row_stack.pop(); @@ -1376,14 +1371,14 @@ void tst_QSortFilterProxyModel::checkHierarchy(const QStringList &l, const QAbst QStack<QModelIndex> parent_stack; for (int i = 0; i < l.count(); ++i) { QString token = l.at(i); - if (token == "<") { // start table + if (token == QLatin1String("<")) { // start table ++indent; parent_stack.push(parent); row_stack.push(row); parent = m->index(row - 1, 0, parent); QVERIFY(parent.isValid()); row = 0; - } else if (token == ">") { // end table + } else if (token == QLatin1String(">")) { // end table --indent; parent = parent_stack.pop(); row = row_stack.pop(); @@ -1418,7 +1413,7 @@ void tst_QSortFilterProxyModel::filterTable() filter.setFilterRegExp("9"); for (int i = 0; i < filter.rowCount(); ++i) - QVERIFY(filter.data(filter.index(i, 0)).toString().contains("9")); + QVERIFY(filter.data(filter.index(i, 0)).toString().contains(QLatin1Char('9'))); } void tst_QSortFilterProxyModel::insertAfterSelect() @@ -1663,16 +1658,16 @@ void tst_QSortFilterProxyModel::removeSourceRows() QCOMPARE(aboutToRemoveSpy.count(), expectedRemovedProxyIntervals.count()); for (int i = 0; i < aboutToRemoveSpy.count(); ++i) { QList<QVariant> args = aboutToRemoveSpy.at(i); - QVERIFY(args.at(1).type() == QVariant::Int); - QVERIFY(args.at(2).type() == QVariant::Int); + QCOMPARE(args.at(1).type(), QVariant::Int); + QCOMPARE(args.at(2).type(), QVariant::Int); QCOMPARE(args.at(1).toInt(), expectedRemovedProxyIntervals.at(i).first); QCOMPARE(args.at(2).toInt(), expectedRemovedProxyIntervals.at(i).second); } QCOMPARE(removeSpy.count(), expectedRemovedProxyIntervals.count()); for (int i = 0; i < removeSpy.count(); ++i) { QList<QVariant> args = removeSpy.at(i); - QVERIFY(args.at(1).type() == QVariant::Int); - QVERIFY(args.at(2).type() == QVariant::Int); + QCOMPARE(args.at(1).type(), QVariant::Int); + QCOMPARE(args.at(2).type(), QVariant::Int); QCOMPARE(args.at(1).toInt(), expectedRemovedProxyIntervals.at(i).first); QCOMPARE(args.at(2).toInt(), expectedRemovedProxyIntervals.at(i).second); } @@ -1841,8 +1836,8 @@ void tst_QSortFilterProxyModel::changeFilter() QCOMPARE(initialInsertSpy.count(), 0); for (int i = 0; i < initialRemoveSpy.count(); ++i) { QList<QVariant> args = initialRemoveSpy.at(i); - QVERIFY(args.at(1).type() == QVariant::Int); - QVERIFY(args.at(2).type() == QVariant::Int); + QCOMPARE(args.at(1).type(), QVariant::Int); + QCOMPARE(args.at(2).type(), QVariant::Int); QCOMPARE(args.at(1).toInt(), initialRemoveIntervals.at(i).first); QCOMPARE(args.at(2).toInt(), initialRemoveIntervals.at(i).second); } @@ -1864,8 +1859,8 @@ void tst_QSortFilterProxyModel::changeFilter() QCOMPARE(finalRemoveSpy.count(), finalRemoveIntervals.count()); for (int i = 0; i < finalRemoveSpy.count(); ++i) { QList<QVariant> args = finalRemoveSpy.at(i); - QVERIFY(args.at(1).type() == QVariant::Int); - QVERIFY(args.at(2).type() == QVariant::Int); + QCOMPARE(args.at(1).type(), QVariant::Int); + QCOMPARE(args.at(2).type(), QVariant::Int); QCOMPARE(args.at(1).toInt(), finalRemoveIntervals.at(i).first); QCOMPARE(args.at(2).toInt(), finalRemoveIntervals.at(i).second); } @@ -1876,8 +1871,8 @@ void tst_QSortFilterProxyModel::changeFilter() QCOMPARE(finalInsertSpy.count(), insertIntervals.count()); for (int i = 0; i < finalInsertSpy.count(); ++i) { QList<QVariant> args = finalInsertSpy.at(i); - QVERIFY(args.at(1).type() == QVariant::Int); - QVERIFY(args.at(2).type() == QVariant::Int); + QCOMPARE(args.at(1).type(), QVariant::Int); + QCOMPARE(args.at(2).type(), QVariant::Int); QCOMPARE(args.at(1).toInt(), insertIntervals.at(i).first); QCOMPARE(args.at(2).toInt(), insertIntervals.at(i).second); } @@ -2018,8 +2013,8 @@ void tst_QSortFilterProxyModel::changeSourceData() QCOMPARE(removeSpy.count(), removeIntervals.count()); for (int i = 0; i < removeSpy.count(); ++i) { QList<QVariant> args = removeSpy.at(i); - QVERIFY(args.at(1).type() == QVariant::Int); - QVERIFY(args.at(2).type() == QVariant::Int); + QCOMPARE(args.at(1).type(), QVariant::Int); + QCOMPARE(args.at(2).type(), QVariant::Int); QCOMPARE(args.at(1).toInt(), removeIntervals.at(i).first); QCOMPARE(args.at(2).toInt(), removeIntervals.at(i).second); } @@ -2027,8 +2022,8 @@ void tst_QSortFilterProxyModel::changeSourceData() QCOMPARE(insertSpy.count(), insertIntervals.count()); for (int i = 0; i < insertSpy.count(); ++i) { QList<QVariant> args = insertSpy.at(i); - QVERIFY(args.at(1).type() == QVariant::Int); - QVERIFY(args.at(2).type() == QVariant::Int); + QCOMPARE(args.at(1).type(), QVariant::Int); + QCOMPARE(args.at(2).type(), QVariant::Int); QCOMPARE(args.at(1).toInt(), insertIntervals.at(i).first); QCOMPARE(args.at(2).toInt(), insertIntervals.at(i).second); } @@ -2545,12 +2540,11 @@ void tst_QSortFilterProxyModel::sortStable() { QStandardItemModel* model = new QStandardItemModel(5, 2); for (int r = 0; r < 5; r++) { + const QString prefix = QLatin1String("Row:") + QString::number(r) + QLatin1String(", Column:"); for (int c = 0; c < 2; c++) { - QStandardItem* item = new QStandardItem( - QString("Row:%0, Column:%1").arg(r).arg(c) ); + QStandardItem* item = new QStandardItem(prefix + QString::number(c)); for (int i = 0; i < 3; i++) { - QStandardItem* child = new QStandardItem( - QString("Item %0").arg(i) ); + QStandardItem* child = new QStandardItem(QLatin1String("Item ") + QString::number(i)); item->appendRow( child ); } model->setItem(r, c, item); @@ -2581,7 +2575,7 @@ void tst_QSortFilterProxyModel::hiddenColumns() public: MyStandardItemModel() : QStandardItemModel(0,5) {} void reset() - { QStandardItemModel::reset(); } + { beginResetModel(); endResetModel(); } friend class tst_QSortFilterProxyModel; } model; QSortFilterProxyModel proxy; @@ -2625,7 +2619,7 @@ void tst_QSortFilterProxyModel::staticSorting() QSortFilterProxyModel proxy; proxy.setSourceModel(&model); proxy.setDynamicSortFilter(false); - QStringList initial = QString("bateau avion dragon hirondelle flamme camion elephant").split(" "); + QStringList initial = QString("bateau avion dragon hirondelle flamme camion elephant").split(QLatin1Char(' ')); // prepare model QStandardItem *root = model.invisibleRootItem (); @@ -2680,7 +2674,7 @@ void tst_QSortFilterProxyModel::staticSorting() void tst_QSortFilterProxyModel::dynamicSorting() { QStringListModel model1; - const QStringList initial = QString("bateau avion dragon hirondelle flamme camion elephant").split(" "); + const QStringList initial = QString("bateau avion dragon hirondelle flamme camion elephant").split(QLatin1Char(' ')); model1.setStringList(initial); QSortFilterProxyModel proxy1; proxy1.setDynamicSortFilter(false); @@ -2806,7 +2800,8 @@ public: qWarning("Invalid modelIndex [%d,%d,%p]", idx.row(), idx.column(), idx.internalPointer()); } - return QString("[%1,%2]").arg(idx.row()).arg(idx.column()); + return QLatin1Char('[') + QString::number(idx.row()) + QLatin1Char(',') + + QString::number(idx.column()) + QLatin1Char(']'); } return QVariant(); } @@ -2971,7 +2966,7 @@ void tst_QSortFilterProxyModel::doubleProxySelectionSetSourceModel() QStandardItemModel *model1 = new QStandardItemModel; QStandardItem *parentItem = model1->invisibleRootItem(); for (int i = 0; i < 4; ++i) { - QStandardItem *item = new QStandardItem(QString("model1 item %0").arg(i)); + QStandardItem *item = new QStandardItem(QLatin1String("model1 item ") + QString::number(i)); parentItem->appendRow(item); parentItem = item; } @@ -2979,7 +2974,7 @@ void tst_QSortFilterProxyModel::doubleProxySelectionSetSourceModel() QStandardItemModel *model2 = new QStandardItemModel; QStandardItem *parentItem2 = model2->invisibleRootItem(); for (int i = 0; i < 4; ++i) { - QStandardItem *item = new QStandardItem(QString("model2 item %0").arg(i)); + QStandardItem *item = new QStandardItem(QLatin1String("model2 item ") + QString::number(i)); parentItem2->appendRow(item); parentItem2 = item; } @@ -3078,7 +3073,7 @@ void tst_QSortFilterProxyModel::appearsAndSort() void tst_QSortFilterProxyModel::unnecessaryDynamicSorting() { QStringListModel model; - const QStringList initial = QString("bravo charlie delta echo").split(" "); + const QStringList initial = QString("bravo charlie delta echo").split(QLatin1Char(' ')); model.setStringList(initial); QSortFilterProxyModel proxy; proxy.setDynamicSortFilter(false); @@ -3162,7 +3157,7 @@ private: void tst_QSortFilterProxyModel::testMultipleProxiesWithSelection() { QStringListModel model; - const QStringList initial = QString("bravo charlie delta echo").split(" "); + const QStringList initial = QString("bravo charlie delta echo").split(QLatin1Char(' ')); model.setStringList(initial); QSortFilterProxyModel proxy; @@ -3196,7 +3191,7 @@ static bool isValid(const QItemSelection &selection) void tst_QSortFilterProxyModel::mapSelectionFromSource() { QStringListModel model; - const QStringList initial = QString("bravo charlie delta echo").split(" "); + const QStringList initial = QString("bravo charlie delta echo").split(QLatin1Char(' ')); model.setStringList(initial); QSortFilterProxyModel proxy; @@ -3205,7 +3200,7 @@ void tst_QSortFilterProxyModel::mapSelectionFromSource() proxy.setSourceModel(&model); // Only "delta" remains. - QVERIFY(proxy.rowCount() == 1); + QCOMPARE(proxy.rowCount(), 1); QItemSelection selection; QModelIndex charlie = model.index(1, 0); @@ -3220,7 +3215,7 @@ void tst_QSortFilterProxyModel::mapSelectionFromSource() QItemSelection proxiedSelection = proxy.mapSelectionFromSource(selection); // Only "delta" is in the mapped result. - QVERIFY(proxiedSelection.size() == 1); + QCOMPARE(proxiedSelection.size(), 1); QVERIFY(isValid(proxiedSelection)); } @@ -3377,7 +3372,10 @@ void tst_QSortFilterProxyModel::resetInvalidate() { switch (test) { case 0: break; - case 1: reset(); break; + case 1: + beginResetModel(); + endResetModel(); + break; case 2: invalidate(); break; case 3: invalidateFilter(); break; } @@ -3551,11 +3549,11 @@ void tst_QSortFilterProxyModel::testParentLayoutChanged() QStandardItem *parentItem = model.invisibleRootItem(); for (int i = 0; i < 4; ++i) { { - QStandardItem *item = new QStandardItem(QString("item %0").arg(i)); + QStandardItem *item = new QStandardItem(QLatin1String("item ") + QString::number(i)); parentItem->appendRow(item); } { - QStandardItem *item = new QStandardItem(QString("item 1%0").arg(i)); + QStandardItem *item = new QStandardItem(QLatin1String("item 1") + QString::number(i)); parentItem->appendRow(item); parentItem = item; } @@ -3852,9 +3850,10 @@ void tst_QSortFilterProxyModel::hierarchyFilterInvalidation() { QStandardItemModel model; for (int i = 0; i < 10; ++i) { - QStandardItem *child = new QStandardItem(QString("Row %1").arg(i)); + const QString rowText = QLatin1String("Row ") + QString::number(i); + QStandardItem *child = new QStandardItem(rowText); for (int j = 0; j < 1; ++j) { - child->appendRow(new QStandardItem(QString("Row %1/%2").arg(i).arg(j))); + child->appendRow(new QStandardItem(rowText + QLatin1Char('/') + QString::number(j))); } model.appendRow(child); } @@ -3913,7 +3912,7 @@ void tst_QSortFilterProxyModel::simpleFilterInvalidation() { QStandardItemModel model; for (int i = 0; i < 2; ++i) { - QStandardItem *child = new QStandardItem(QString("Row %1").arg(i)); + QStandardItem *child = new QStandardItem(QLatin1String("Row ") + QString::number(i)); child->appendRow(new QStandardItem("child")); model.appendRow(child); } diff --git a/tests/auto/corelib/itemmodels/qstringlistmodel/qmodellistener.h b/tests/auto/corelib/itemmodels/qstringlistmodel/qmodellistener.h index b458f7abc9..e08a0bdb1f 100644 --- a/tests/auto/corelib/itemmodels/qstringlistmodel/qmodellistener.h +++ b/tests/auto/corelib/itemmodels/qstringlistmodel/qmodellistener.h @@ -1,31 +1,26 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** diff --git a/tests/auto/corelib/itemmodels/qstringlistmodel/qstringlistmodel.pro b/tests/auto/corelib/itemmodels/qstringlistmodel/qstringlistmodel.pro index e11e16b203..91a4cf306c 100644 --- a/tests/auto/corelib/itemmodels/qstringlistmodel/qstringlistmodel.pro +++ b/tests/auto/corelib/itemmodels/qstringlistmodel/qstringlistmodel.pro @@ -1,7 +1,5 @@ CONFIG += testcase -CONFIG += parallel_test TARGET = tst_qstringlistmodel QT = core testlib HEADERS += qmodellistener.h SOURCES += tst_qstringlistmodel.cpp -DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp b/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp index 53f3d9c0a2..61dda782d8 100644 --- a/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp +++ b/tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp @@ -1,31 +1,26 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. ** -** $QT_BEGIN_LICENSE:LGPL21$ +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. ** ** $QT_END_LICENSE$ ** |