summaryrefslogtreecommitdiff
path: root/tests/auto/qquicktreemodeladaptor/tst_qquicktreemodeladaptor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qquicktreemodeladaptor/tst_qquicktreemodeladaptor.cpp')
-rw-r--r--tests/auto/qquicktreemodeladaptor/tst_qquicktreemodeladaptor.cpp94
1 files changed, 43 insertions, 51 deletions
diff --git a/tests/auto/qquicktreemodeladaptor/tst_qquicktreemodeladaptor.cpp b/tests/auto/qquicktreemodeladaptor/tst_qquicktreemodeladaptor.cpp
index 13a92ea7..03927fc2 100644
--- a/tests/auto/qquicktreemodeladaptor/tst_qquicktreemodeladaptor.cpp
+++ b/tests/auto/qquicktreemodeladaptor/tst_qquicktreemodeladaptor.cpp
@@ -1,34 +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:LGPL3$
+** $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.
-**
-** 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.LGPLv3 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.html.
+** 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 2.0 or later as published by the Free
-** Software Foundation and appearing in the file LICENSE.GPL included in
-** the packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 2.0 requirements will be
-** met: http://www.gnu.org/licenses/gpl-2.0.html.
+** 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$
**
@@ -44,10 +36,10 @@ class tst_QQuickTreeModelAdaptor : public QObject
Q_OBJECT
public:
- void compareData(int row, QQuickTreeModelAdaptor &tma, const QModelIndex &idx, TestModel &model, bool expanded = false);
- void compareModels(QQuickTreeModelAdaptor &tma, TestModel &model);
- void expandAndTest(const QModelIndex &idx, QQuickTreeModelAdaptor &tma, bool expandable, int expectedRowCountDifference);
- void collapseAndTest(const QModelIndex &idx, QQuickTreeModelAdaptor &tma, bool expandable, int expectedRowCountDifference);
+ void compareData(int row, QQuickTreeModelAdaptor1 &tma, const QModelIndex &idx, TestModel &model, bool expanded = false);
+ void compareModels(QQuickTreeModelAdaptor1 &tma, TestModel &model);
+ void expandAndTest(const QModelIndex &idx, QQuickTreeModelAdaptor1 &tma, bool expandable, int expectedRowCountDifference);
+ void collapseAndTest(const QModelIndex &idx, QQuickTreeModelAdaptor1 &tma, bool expandable, int expectedRowCountDifference);
private slots:
void initTestCase();
@@ -95,18 +87,18 @@ void tst_QQuickTreeModelAdaptor::cleanup()
{
}
-void tst_QQuickTreeModelAdaptor::compareData(int row, QQuickTreeModelAdaptor &tma, const QModelIndex &modelIdx, TestModel &model, bool expanded)
+void tst_QQuickTreeModelAdaptor::compareData(int row, QQuickTreeModelAdaptor1 &tma, const QModelIndex &modelIdx, TestModel &model, bool expanded)
{
const QModelIndex &tmaIdx = tma.index(row);
const int indexDepth = model.level(modelIdx) - model.level(tma.rootIndex()) - 1;
QCOMPARE(tma.mapToModel(tmaIdx), modelIdx);
QCOMPARE(tma.data(tmaIdx, Qt::DisplayRole).toString(), model.displayData(modelIdx));
- QCOMPARE(tma.data(tmaIdx, QQuickTreeModelAdaptor::DepthRole).toInt(), indexDepth);
- QCOMPARE(tma.data(tmaIdx, QQuickTreeModelAdaptor::ExpandedRole).toBool(), expanded);
- QCOMPARE(tma.data(tmaIdx, QQuickTreeModelAdaptor::HasChildrenRole).toBool(), model.hasChildren(modelIdx));
+ QCOMPARE(tma.data(tmaIdx, QQuickTreeModelAdaptor1::DepthRole).toInt(), indexDepth);
+ QCOMPARE(tma.data(tmaIdx, QQuickTreeModelAdaptor1::ExpandedRole).toBool(), expanded);
+ QCOMPARE(tma.data(tmaIdx, QQuickTreeModelAdaptor1::HasChildrenRole).toBool(), model.hasChildren(modelIdx));
}
-void tst_QQuickTreeModelAdaptor::expandAndTest(const QModelIndex &idx, QQuickTreeModelAdaptor &tma, bool expandable,
+void tst_QQuickTreeModelAdaptor::expandAndTest(const QModelIndex &idx, QQuickTreeModelAdaptor1 &tma, bool expandable,
int expectedRowCountDifference)
{
QSignalSpy rowsAboutToBeInsertedSpy(&tma, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int)));
@@ -118,7 +110,7 @@ void tst_QQuickTreeModelAdaptor::expandAndTest(const QModelIndex &idx, QQuickTre
QCOMPARE(tma.isExpanded(idx), expandable);
const QModelIndex &tmaIdx = tma.index(tma.itemIndex(idx));
- QCOMPARE(tma.data(tmaIdx, QQuickTreeModelAdaptor::ExpandedRole).toBool(), expandable);
+ QCOMPARE(tma.data(tmaIdx, QQuickTreeModelAdaptor1::ExpandedRole).toBool(), expandable);
if (expandable && expectedRowCountDifference != 0) {
// Rows were added below the parent
@@ -140,7 +132,7 @@ void tst_QQuickTreeModelAdaptor::expandAndTest(const QModelIndex &idx, QQuickTre
const QVariantList &dataChangedArgs = dataChangedSpy.first();
QCOMPARE(dataChangedArgs.at(0).toModelIndex(), tmaIdx);
QCOMPARE(dataChangedArgs.at(1).toModelIndex(), tmaIdx);
- QCOMPARE(dataChangedArgs.at(2).value<QVector<int> >(), QVector<int>(1, QQuickTreeModelAdaptor::ExpandedRole));
+ QCOMPARE(dataChangedArgs.at(2).value<QVector<int> >(), QVector<int>(1, QQuickTreeModelAdaptor1::ExpandedRole));
} else {
QCOMPARE(tma.rowCount(), oldRowCount);
QCOMPARE(rowsAboutToBeInsertedSpy.count(), 0);
@@ -148,7 +140,7 @@ void tst_QQuickTreeModelAdaptor::expandAndTest(const QModelIndex &idx, QQuickTre
}
}
-void tst_QQuickTreeModelAdaptor::collapseAndTest(const QModelIndex &idx, QQuickTreeModelAdaptor &tma,
+void tst_QQuickTreeModelAdaptor::collapseAndTest(const QModelIndex &idx, QQuickTreeModelAdaptor1 &tma,
bool expandable, int expectedRowCountDifference)
{
QSignalSpy rowsAboutToBeRemovedSpy(&tma, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int)));
@@ -161,7 +153,7 @@ void tst_QQuickTreeModelAdaptor::collapseAndTest(const QModelIndex &idx, QQuickT
const QModelIndex &tmaIdx = tma.index(tma.itemIndex(idx));
if (tmaIdx.isValid())
- QCOMPARE(tma.data(tmaIdx, QQuickTreeModelAdaptor::ExpandedRole).toBool(), false);
+ QCOMPARE(tma.data(tmaIdx, QQuickTreeModelAdaptor1::ExpandedRole).toBool(), false);
if (expandable && expectedRowCountDifference != 0) {
// Rows were removed below the parent
@@ -181,7 +173,7 @@ void tst_QQuickTreeModelAdaptor::collapseAndTest(const QModelIndex &idx, QQuickT
const QVariantList &dataChangedArgs = dataChangedSpy.first();
QCOMPARE(dataChangedArgs.at(0).toModelIndex(), tmaIdx);
QCOMPARE(dataChangedArgs.at(1).toModelIndex(), tmaIdx);
- QCOMPARE(dataChangedArgs.at(2).value<QVector<int> >(), QVector<int>(1, QQuickTreeModelAdaptor::ExpandedRole));
+ QCOMPARE(dataChangedArgs.at(2).value<QVector<int> >(), QVector<int>(1, QQuickTreeModelAdaptor1::ExpandedRole));
} else {
QCOMPARE(tma.rowCount(), oldRowCount);
QCOMPARE(rowsAboutToBeRemovedSpy.count(), 0);
@@ -189,7 +181,7 @@ void tst_QQuickTreeModelAdaptor::collapseAndTest(const QModelIndex &idx, QQuickT
}
}
-void tst_QQuickTreeModelAdaptor::compareModels(QQuickTreeModelAdaptor &tma, TestModel &model)
+void tst_QQuickTreeModelAdaptor::compareModels(QQuickTreeModelAdaptor1 &tma, TestModel &model)
{
QModelIndex parent = tma.rootIndex();
QStack<QModelIndex> parents;
@@ -222,7 +214,7 @@ void tst_QQuickTreeModelAdaptor::compareModels(QQuickTreeModelAdaptor &tma, Test
void tst_QQuickTreeModelAdaptor::setModel()
{
TestModel model(5, 1);
- QQuickTreeModelAdaptor tma;
+ QQuickTreeModelAdaptor1 tma;
QSignalSpy modelChangedSpy(&tma, SIGNAL(modelChanged(QAbstractItemModel*)));
tma.setModel(&model);
@@ -242,7 +234,7 @@ void tst_QQuickTreeModelAdaptor::setModel()
void tst_QQuickTreeModelAdaptor::modelDestroyed()
{
TestModel *model = new TestModel(5, 1);
- QQuickTreeModelAdaptor tma;
+ QQuickTreeModelAdaptor1 tma;
QSignalSpy modelChangedSpy(&tma, SIGNAL(modelChanged(QAbstractItemModel*)));
tma.setModel(model);
@@ -260,7 +252,7 @@ void tst_QQuickTreeModelAdaptor::modelDestroyed()
void tst_QQuickTreeModelAdaptor::modelReset()
{
TestModel model(5, 1);
- QQuickTreeModelAdaptor tma;
+ QQuickTreeModelAdaptor1 tma;
tma.setModel(&model);
QSignalSpy modelAboutToBeResetSpy(&tma, SIGNAL(modelAboutToBeReset()));
@@ -290,7 +282,7 @@ void tst_QQuickTreeModelAdaptor::rootIndex()
{
TestModel model(5, 1);
- QQuickTreeModelAdaptor tma;
+ QQuickTreeModelAdaptor1 tma;
tma.setModel(&model);
QVERIFY(!tma.rootIndex().isValid());
@@ -324,7 +316,7 @@ void tst_QQuickTreeModelAdaptor::dataAccess()
{
TestModel model(5, 1);
- QQuickTreeModelAdaptor tma;
+ QQuickTreeModelAdaptor1 tma;
tma.setModel(&model);
QCOMPARE(tma.rowCount(), model.rowCount());
@@ -346,7 +338,7 @@ void tst_QQuickTreeModelAdaptor::dataChange()
{
TestModel model(5, 1);
- QQuickTreeModelAdaptor tma;
+ QQuickTreeModelAdaptor1 tma;
tma.setModel(&model);
QSignalSpy dataChangedSpy(&tma, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)));
@@ -389,7 +381,7 @@ void tst_QQuickTreeModelAdaptor::groupedDataChange()
const QModelIndex &topLeftIdx = model.index(1, 0);
const QModelIndex &bottomRightIdx = model.index(7, 0);
- QQuickTreeModelAdaptor tma;
+ QQuickTreeModelAdaptor1 tma;
tma.setModel(&model);
QSignalSpy dataChangedSpy(&tma, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)));
@@ -501,7 +493,7 @@ void tst_QQuickTreeModelAdaptor::expandAndCollapse()
const QModelIndex &parentIdx = model.index(parentRow, 0);
bool expandable = model.hasChildren(parentIdx);
- QQuickTreeModelAdaptor tma;
+ QQuickTreeModelAdaptor1 tma;
tma.setModel(&model);
expandAndTest(parentIdx, tma, expandable, model.rowCount(parentIdx));
@@ -520,7 +512,7 @@ void tst_QQuickTreeModelAdaptor::expandAndCollapse2ndLevel()
const QModelIndex &parentIdx = model.index(expandRows[i], 0);
QVERIFY(model.hasChildren(parentIdx));
- QQuickTreeModelAdaptor tma;
+ QQuickTreeModelAdaptor1 tma;
tma.setModel(&model);
tma.expand(parentIdx);
@@ -576,7 +568,7 @@ void tst_QQuickTreeModelAdaptor::layoutChange()
const QModelIndex &idx = model.index(0, 0);
const QModelIndex &idx2 = model.index(2, 0);
- QQuickTreeModelAdaptor tma;
+ QQuickTreeModelAdaptor1 tma;
tma.setModel(&model);
// Nothing expanded
@@ -695,7 +687,7 @@ void tst_QQuickTreeModelAdaptor::removeRows()
QFETCH(int, expectedRemovedCount);
TestModel model(ModelRowCount, 1);
- QQuickTreeModelAdaptor tma;
+ QQuickTreeModelAdaptor1 tma;
tma.setModel(&model);
const QModelIndex &expandParentIdx = expandParentRow == -1 ? QModelIndex() : model.index(expandParentRow, 0);
@@ -734,7 +726,7 @@ void tst_QQuickTreeModelAdaptor::removeRows()
void tst_QQuickTreeModelAdaptor::removeRowsChildrenAndParent()
{
TestModel model(ModelRowCount, 1);
- QQuickTreeModelAdaptor tma;
+ QQuickTreeModelAdaptor1 tma;
tma.setModel(&model);
// Expand the first node
@@ -776,7 +768,7 @@ void tst_QQuickTreeModelAdaptor::removeRowsChildrenAndParent()
void tst_QQuickTreeModelAdaptor::removeChildrenMoveParent()
{
TestModel model(ModelRowCount, 1);
- QQuickTreeModelAdaptor tma;
+ QQuickTreeModelAdaptor1 tma;
tma.setModel(&model);
// Expand the first node
@@ -819,7 +811,7 @@ void tst_QQuickTreeModelAdaptor::removeChildrenMoveParent()
void tst_QQuickTreeModelAdaptor::removeChildrenRelayoutParent()
{
TestModel model(ModelRowCount, 1);
- QQuickTreeModelAdaptor tma;
+ QQuickTreeModelAdaptor1 tma;
tma.setModel(&model);
// Expand the first node
@@ -887,7 +879,7 @@ void tst_QQuickTreeModelAdaptor::insertRows()
QFETCH(int, expectedInsertedCount);
TestModel model(ModelRowCount, 1);
- QQuickTreeModelAdaptor tma;
+ QQuickTreeModelAdaptor1 tma;
tma.setModel(&model);
const QModelIndex &expandParentIdx = expandParentRow == -1 ? QModelIndex() : model.index(expandParentRow, 0);
@@ -1048,7 +1040,7 @@ void tst_QQuickTreeModelAdaptor::moveRows()
TestModel model(ModelRowCount, 1);
model.alternateChildlessRows = false;
- QQuickTreeModelAdaptor tma;
+ QQuickTreeModelAdaptor1 tma;
tma.setModel(&model);
const QModelIndex &expandParentIdx = expandParentRow == -1 ? QModelIndex() : model.index(expandParentRow, 0);
@@ -1167,7 +1159,7 @@ void tst_QQuickTreeModelAdaptor::selectionForRowRange()
TestModel model(ModelRowCount, 1);
model.alternateChildlessRows = false;
- QQuickTreeModelAdaptor tma;
+ QQuickTreeModelAdaptor1 tma;
tma.setModel(&model);
// NOTE: Some selections may look a bit cryptic. Insert a call to
@@ -1335,7 +1327,7 @@ void tst_QQuickTreeModelAdaptor::hasChildrenEmit()
{
TestModel model(1, 1);
model.alternateChildlessRows = false;
- QQuickTreeModelAdaptor tma;
+ QQuickTreeModelAdaptor1 tma;
tma.setModel(&model);
QModelIndex root = model.index(0,0);