diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-03-22 04:09:20 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-03-22 04:09:20 (GMT) |
commit | c1958338bb94f045c846147bdb7224377a2122a6 (patch) | |
tree | bab76e1baed0fcc5f49697378c9d5e07bdec0b42 /tests | |
parent | 44660e6d34ce969069a82fe26f5e4b13d4d5ec78 (diff) | |
download | Qt-c1958338bb94f045c846147bdb7224377a2122a6.zip Qt-c1958338bb94f045c846147bdb7224377a2122a6.tar.gz Qt-c1958338bb94f045c846147bdb7224377a2122a6.tar.bz2 |
Set role names for QFileSystemModel and QDirModel
Task-number: QTBUG-7479
Reviewed-by: Alexis Menard
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qdirmodel/tst_qdirmodel.cpp | 28 | ||||
-rw-r--r-- | tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp | 29 |
2 files changed, 57 insertions, 0 deletions
diff --git a/tests/auto/qdirmodel/tst_qdirmodel.cpp b/tests/auto/qdirmodel/tst_qdirmodel.cpp index d7f0112..1bc5b7f 100644 --- a/tests/auto/qdirmodel/tst_qdirmodel.cpp +++ b/tests/auto/qdirmodel/tst_qdirmodel.cpp @@ -106,6 +106,9 @@ private slots: void filter(); void task244669_remove(); + + void roleNames_data(); + void roleNames(); }; // Testing get/set functions @@ -681,5 +684,30 @@ void tst_QDirModel::task244669_remove() QCOMPARE(parent.data() , model.index(SRCDIR "dirtest").data()); } +void tst_QDirModel::roleNames_data() +{ + QTest::addColumn<int>("role"); + QTest::addColumn<QByteArray>("roleName"); + QTest::newRow("decoration") << int(Qt::DecorationRole) << QByteArray("decoration"); + QTest::newRow("display") << int(Qt::DisplayRole) << QByteArray("display"); + QTest::newRow("fileIcon") << int(QDirModel::FileIconRole) << QByteArray("fileIcon"); + QTest::newRow("filePath") << int(QDirModel::FilePathRole) << QByteArray("filePath"); + QTest::newRow("fileName") << int(QDirModel::FileNameRole) << QByteArray("fileName"); +} + +void tst_QDirModel::roleNames() +{ + QDirModel model; + QHash<int, QByteArray> roles = model.roleNames(); + + QFETCH(int, role); + QVERIFY(roles.contains(role)); + + QFETCH(QByteArray, roleName); + QList<QByteArray> values = roles.values(role); + QVERIFY(values.contains(roleName)); +} + + QTEST_MAIN(tst_QDirModel) #include "tst_qdirmodel.moc" diff --git a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp index 9f67a5e..c234c96 100644 --- a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp +++ b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp @@ -137,6 +137,10 @@ private slots: void drives_data(); void drives(); void dirsBeforeFiles(); + + void roleNames_data(); + void roleNames(); + protected: bool createFiles(const QString &test_path, const QStringList &initial_files, int existingFileCount = 0, const QStringList &intial_dirs = QStringList(), const QString &baseDir = QDir::temp().absolutePath()); @@ -1016,6 +1020,31 @@ void tst_QFileSystemModel::dirsBeforeFiles() } } +void tst_QFileSystemModel::roleNames_data() +{ + QTest::addColumn<int>("role"); + QTest::addColumn<QByteArray>("roleName"); + QTest::newRow("decoration") << int(Qt::DecorationRole) << QByteArray("decoration"); + QTest::newRow("display") << int(Qt::DisplayRole) << QByteArray("display"); + QTest::newRow("fileIcon") << int(QFileSystemModel::FileIconRole) << QByteArray("fileIcon"); + QTest::newRow("filePath") << int(QFileSystemModel::FilePathRole) << QByteArray("filePath"); + QTest::newRow("fileName") << int(QFileSystemModel::FileNameRole) << QByteArray("fileName"); + QTest::newRow("filePermissions") << int(QFileSystemModel::FilePermissions) << QByteArray("filePermissions"); +} + +void tst_QFileSystemModel::roleNames() +{ + QFileSystemModel model; + QHash<int, QByteArray> roles = model.roleNames(); + + QFETCH(int, role); + QVERIFY(roles.contains(role)); + + QFETCH(QByteArray, roleName); + QList<QByteArray> values = roles.values(role); + QVERIFY(values.contains(roleName)); +} + QTEST_MAIN(tst_QFileSystemModel) #include "tst_qfilesystemmodel.moc" |