From 2faccdf9a6586cb9b6f7bc276c39c814ab354003 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 3 Dec 2018 13:36:49 +0100 Subject: Don't insert multiple names for the same role It doesn't make a lot of sense to have two names for the same role. Use 'fileIcon' exclusively for the Qt::Decoration/ FileIconRole. Change-Id: Icaa46ba4aa61efc56ba007a14bab5e59ea26cd35 Reviewed-by: Friedemann Kleint --- .../auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'tests/auto/widgets/dialogs/qfilesystemmodel') diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp index f910b12cc6..3f67b0e1b4 100644 --- a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp +++ b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp @@ -1048,7 +1048,7 @@ void tst_QFileSystemModel::roleNames_data() { QTest::addColumn("role"); QTest::addColumn("roleName"); - QTest::newRow("decoration") << int(Qt::DecorationRole) << QByteArray("decoration"); + QTest::newRow("decoration") << int(Qt::DecorationRole) << QByteArray("fileIcon"); QTest::newRow("display") << int(Qt::DisplayRole) << QByteArray("display"); QTest::newRow("fileIcon") << int(QFileSystemModel::FileIconRole) << QByteArray("fileIcon"); QTest::newRow("filePath") << int(QFileSystemModel::FilePathRole) << QByteArray("filePath"); @@ -1065,8 +1065,8 @@ void tst_QFileSystemModel::roleNames() QVERIFY(roles.contains(role)); QFETCH(QByteArray, roleName); - QList values = roles.values(role); - QVERIFY(values.contains(roleName)); + QCOMPARE(roles.values(role).count(), 1); + QCOMPARE(roles.value(role), roleName); } static inline QByteArray permissionRowName(bool readOnly, int permission) -- cgit v1.2.3 From e6a0a945c591da3e3e66a6d7a350b4befd77a459 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Wed, 6 Nov 2019 10:59:32 +0100 Subject: Simplify two complex test conditions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since the test was fatuous for i == 0, iterate from i = 1, instead. Change-Id: I9b9c1b7b10639aefdd74f48051d592da4f84dc85 Reviewed-by: Jesus Fernandez Reviewed-by: MÃ¥rten Nordheim Reviewed-by: Friedemann Kleint --- .../widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'tests/auto/widgets/dialogs/qfilesystemmodel') diff --git a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp index f8f40e8488..590b3502f1 100644 --- a/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp +++ b/tests/auto/widgets/dialogs/qfilesystemmodel/tst_qfilesystemmodel.cpp @@ -1030,15 +1030,13 @@ void tst_QFileSystemModel::dirsBeforeFiles() // Wait for model to be notified by the file system watcher QTRY_COMPARE(model->rowCount(root), 2 * itemCount); - // ensure that no file occurs before a directory - for (int i = 0; i < model->rowCount(root); ++i) { + // Ensure that no file occurs before any directory: + for (int i = 1; i < model->rowCount(root); ++i) { #ifndef Q_OS_MAC - QVERIFY(i == 0 || - !(model->fileInfo(model->index(i - 1, 0, root)).isFile() + QVERIFY(!(model->fileInfo(model->index(i - 1, 0, root)).isFile() && model->fileInfo(model->index(i, 0, root)).isDir())); #else - QVERIFY(i == 0 || - model->fileInfo(model->index(i - 1, 0, root)).fileName() < + QVERIFY(model->fileInfo(model->index(i - 1, 0, root)).fileName() < model->fileInfo(model->index(i, 0, root)).fileName()); #endif } -- cgit v1.2.3