diff options
author | Gatis Paeglis <gatis.paeglis@digia.com> | 2014-08-12 14:46:05 +0200 |
---|---|---|
committer | Gatis Paeglis <gatis.paeglis@digia.com> | 2014-08-22 23:00:37 +0200 |
commit | 253e9257e1f586d1c1dfa585aa6f862d310cdec3 (patch) | |
tree | 4425049801c343aac4c39ee127104611b1484366 /tests | |
parent | 3cc2b8d7d94361ef786304024fd2ddca4103f94b (diff) |
Introspect qrc files in FolderListModel.
And don't use "file watchers" for resource file paths,
otherwise it generates the following warning:
QInotifyFileSystemWatcherEngine::addPaths: inotify_add_watch failed: No
such file or directory
Change-Id: I6b75c9195fb2b2ba7b3e0bb7d146fc5cd343927e
Task-number: QTBUG-40307
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Diffstat (limited to 'tests')
5 files changed, 32 insertions, 8 deletions
diff --git a/tests/auto/qml/qquickfolderlistmodel/data/introspect.qrc b/tests/auto/qml/qquickfolderlistmodel/data/introspect.qrc new file mode 100644 index 0000000000..9f07597bde --- /dev/null +++ b/tests/auto/qml/qquickfolderlistmodel/data/introspect.qrc @@ -0,0 +1,5 @@ +<RCC> +<qresource prefix="/myprefix/subdir"> +<file>txtdir/hello.txt</file> +</qresource> +</RCC> diff --git a/tests/auto/qml/qquickfolderlistmodel/data/qrc.qml b/tests/auto/qml/qquickfolderlistmodel/data/qrc.qml new file mode 100644 index 0000000000..30bc290dc9 --- /dev/null +++ b/tests/auto/qml/qquickfolderlistmodel/data/qrc.qml @@ -0,0 +1,7 @@ +import Qt.labs.folderlistmodel 2.1 + +FolderListModel { + nameFilters: [ "*.txt" ] + folder: "qrc:/myprefix/subdir/txtdir" +} + diff --git a/tests/auto/qml/qquickfolderlistmodel/data/txtdir/hello.txt b/tests/auto/qml/qquickfolderlistmodel/data/txtdir/hello.txt new file mode 100644 index 0000000000..87186bd001 --- /dev/null +++ b/tests/auto/qml/qquickfolderlistmodel/data/txtdir/hello.txt @@ -0,0 +1 @@ +Hello from hello.txt diff --git a/tests/auto/qml/qquickfolderlistmodel/qquickfolderlistmodel.pro b/tests/auto/qml/qquickfolderlistmodel/qquickfolderlistmodel.pro index d14f4fb278..c4fdcdc7dd 100644 --- a/tests/auto/qml/qquickfolderlistmodel/qquickfolderlistmodel.pro +++ b/tests/auto/qml/qquickfolderlistmodel/qquickfolderlistmodel.pro @@ -11,3 +11,5 @@ TESTDATA = data/* CONFIG += parallel_test QT += core-private gui-private qml-private testlib DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 + +RESOURCES += data/introspect.qrc diff --git a/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp b/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp index 4296ae4f09..17367bacdc 100644 --- a/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp +++ b/tests/auto/qml/qquickfolderlistmodel/tst_qquickfolderlistmodel.cpp @@ -83,6 +83,7 @@ private slots: void showDotAndDotDot(); void showDotAndDotDot_data(); void sortReversed(); + void introspectQrc(); private: void checkNoErrors(const QQmlComponent& component); @@ -127,7 +128,7 @@ void tst_qquickfolderlistmodel::basicProperties() QSignalSpy folderChangedSpy(flm, SIGNAL(folderChanged())); flm->setProperty("folder", dataDirectoryUrl()); QVERIFY(folderChangedSpy.wait()); - QCOMPARE(flm->property("count").toInt(), 6); + QCOMPARE(flm->property("count").toInt(), 8); QCOMPARE(flm->property("folder").toUrl(), dataDirectoryUrl()); QCOMPARE(flm->property("parentFolder").toUrl(), QUrl::fromLocalFile(QDir(directory()).canonicalPath())); QCOMPARE(flm->property("sortField").toInt(), int(Name)); @@ -153,12 +154,12 @@ void tst_qquickfolderlistmodel::showFiles() QVERIFY(flm != 0); flm->setProperty("folder", dataDirectoryUrl()); - QTRY_COMPARE(flm->property("count").toInt(), 6); // wait for refresh + QTRY_COMPARE(flm->property("count").toInt(), 8); // wait for refresh QCOMPARE(flm->property("showFiles").toBool(), true); flm->setProperty("showFiles", false); QCOMPARE(flm->property("showFiles").toBool(), false); - QTRY_COMPARE(flm->property("count").toInt(), 1); // wait for refresh + QTRY_COMPARE(flm->property("count").toInt(), 2); // wait for refresh } void tst_qquickfolderlistmodel::resetFiltering() @@ -225,7 +226,7 @@ void tst_qquickfolderlistmodel::refresh() QVERIFY(flm != 0); flm->setProperty("folder", dataDirectoryUrl()); - QTRY_COMPARE(flm->property("count").toInt(),6); // wait for refresh + QTRY_COMPARE(flm->property("count").toInt(),8); // wait for refresh int count = flm->rowCount(); @@ -329,7 +330,7 @@ void tst_qquickfolderlistmodel::showDotAndDotDot() flm->setProperty("rootFolder", rootFolder); flm->setProperty("showDotAndDotDot", showDotAndDotDot); - int count = 6; + int count = 9; if (showDot) count++; if (showDotDot) count++; QTRY_COMPARE(flm->property("count").toInt(), count); // wait for refresh @@ -360,10 +361,18 @@ void tst_qquickfolderlistmodel::sortReversed() QAbstractListModel *flm = qobject_cast<QAbstractListModel*>(component.create()); QVERIFY(flm != 0); flm->setProperty("folder", dataDirectoryUrl()); + QTRY_COMPARE(flm->property("count").toInt(), 9); // wait for refresh + QCOMPARE(flm->data(flm->index(0),FileNameRole).toString(), QLatin1String("txtdir")); +} - int count = 6; - QTRY_COMPARE(flm->property("count").toInt(), count); // wait for refresh - QCOMPARE(flm->data(flm->index(0),FileNameRole).toString(), QLatin1String("sortReversed.qml")); +void tst_qquickfolderlistmodel::introspectQrc() +{ + QQmlComponent component(&engine, testFileUrl("qrc.qml")); + checkNoErrors(component); + QAbstractListModel *flm = qobject_cast<QAbstractListModel*>(component.create()); + QVERIFY(flm != 0); + QTRY_COMPARE(flm->property("count").toInt(), 1); // wait for refresh + QCOMPARE(flm->data(flm->index(0),FileNameRole).toString(), QLatin1String("hello.txt")); } QTEST_MAIN(tst_qquickfolderlistmodel) |