summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/dialogs/qfilesystemmodel
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-04-27 09:18:05 +0200
committerLiang Qi <liang.qi@qt.io>2016-04-27 09:18:05 +0200
commit23a36fd2bfcdb57849deaa1e10e6e3f7b1156ed8 (patch)
treeb527c7e3ba4a831b542b0bccfb6a5a748a8a4fd9 /tests/auto/widgets/dialogs/qfilesystemmodel
parentc003a18ee332abf2387172eb0856a176a32a6c8f (diff)
parent072f5b513e486e884ea7fa4a1cac9aedf3846374 (diff)
Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts: src/corelib/io/qprocess_win.cpp src/widgets/itemviews/qheaderview.cpp Change-Id: I0a59ade9cd6e91f770fdf298a7d72a41e79fd761
Diffstat (limited to 'tests/auto/widgets/dialogs/qfilesystemmodel')
-rw-r--r--tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp34
1 files changed, 29 insertions, 5 deletions
diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp
index 17c10bb43e..7939d88c73 100644
--- a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp
+++ b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp
@@ -693,6 +693,7 @@ void tst_QFileSystemModel::nameFilters()
}
void tst_QFileSystemModel::setData_data()
{
+ QTest::addColumn<QString>("subdirName");
QTest::addColumn<QStringList>("files");
QTest::addColumn<QString>("oldFileName");
QTest::addColumn<QString>("newFileName");
@@ -702,7 +703,15 @@ void tst_QFileSystemModel::setData_data()
<< QDir::temp().absolutePath() + '/' + "a"
<< false;
*/
- QTest::newRow("in current dir") << (QStringList() << "a" << "b" << "c")
+ QTest::newRow("in current dir")
+ << QString()
+ << (QStringList() << "a" << "b" << "c")
+ << "a"
+ << "d"
+ << true;
+ QTest::newRow("in subdir")
+ << "s"
+ << (QStringList() << "a" << "b" << "c")
<< "a"
<< "d"
<< true;
@@ -711,15 +720,25 @@ void tst_QFileSystemModel::setData_data()
void tst_QFileSystemModel::setData()
{
QSignalSpy spy(model, SIGNAL(fileRenamed(QString,QString,QString)));
- QString tmp = flatDirTestPath;
+ QFETCH(QString, subdirName);
QFETCH(QStringList, files);
QFETCH(QString, oldFileName);
QFETCH(QString, newFileName);
QFETCH(bool, success);
+ QString tmp = flatDirTestPath;
+ if (!subdirName.isEmpty()) {
+ QDir dir(tmp);
+ QVERIFY(dir.mkdir(subdirName));
+ tmp.append('/' + subdirName);
+ }
QVERIFY(createFiles(tmp, files));
- QModelIndex root = model->setRootPath(tmp);
- QTRY_COMPARE(model->rowCount(root), files.count());
+ QModelIndex tmpIdx = model->setRootPath(flatDirTestPath);
+ if (!subdirName.isEmpty()) {
+ tmpIdx = model->index(tmp);
+ model->fetchMore(tmpIdx);
+ }
+ QTRY_COMPARE(model->rowCount(tmpIdx), files.count());
QModelIndex idx = model->index(tmp + '/' + oldFileName);
QCOMPARE(idx.isValid(), true);
@@ -727,16 +746,21 @@ void tst_QFileSystemModel::setData()
model->setReadOnly(false);
QCOMPARE(model->setData(idx, newFileName), success);
+ model->setReadOnly(true);
if (success) {
QCOMPARE(spy.count(), 1);
QList<QVariant> arguments = spy.takeFirst();
QCOMPARE(model->data(idx, QFileSystemModel::FileNameRole).toString(), newFileName);
+ QCOMPARE(model->fileInfo(idx).filePath(), tmp + '/' + newFileName);
QCOMPARE(model->index(arguments.at(0).toString()), model->index(tmp));
QCOMPARE(arguments.at(1).toString(), oldFileName);
QCOMPARE(arguments.at(2).toString(), newFileName);
QCOMPARE(QFile::rename(tmp + '/' + newFileName, tmp + '/' + oldFileName), true);
}
- QTRY_COMPARE(model->rowCount(root), files.count());
+ QTRY_COMPARE(model->rowCount(tmpIdx), files.count());
+ // cleanup
+ if (!subdirName.isEmpty())
+ QVERIFY(QDir(tmp).removeRecursively());
}
void tst_QFileSystemModel::sortPersistentIndex()